From loewis at users.sourceforge.net Sun Aug 1 12:02:17 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 1 12:02:20 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24627 Modified Files: msi.py Log Message: Refer to MSDN in many places. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** msi.py 27 Jul 2004 16:36:21 -0000 1.18 --- msi.py 1 Aug 2004 10:02:14 -0000 1.19 *************** *** 1,4 **** --- 1,5 ---- # Python MSI Generator # (C) 2003 Martin v. Loewis + # See "FOO" in comments refers to MSDN sections with the title FOO. import msilib, schema, sequence, os, glob, time from msilib import Feature, CAB, Directory, Dialog, Binary, add_data *************** *** 32,41 **** short_version = major+"."+minor ! # This should never change upgrade_code_alpha='{92A24481-3ECB-40FC-8836-04B7966EC0D5}' upgrade_code='{65E6DE48-A358-434D-AA4F-4AF72DB4718F}' ! # This should be extended for each Python release ! # Alpha releases have their own product code product_codes = { '2.3.2' : "{3ad0c9ed-7e5e-478c-b539-5cc3a2f8772a}", --- 33,50 ---- short_version = major+"."+minor ! # This should never change. The UpgradeCode of this package can be ! # used in the Upgrade table of future packages to make the future ! # package replace this one. See "UpgradeCode Property". upgrade_code_alpha='{92A24481-3ECB-40FC-8836-04B7966EC0D5}' upgrade_code='{65E6DE48-A358-434D-AA4F-4AF72DB4718F}' ! # This should be extended for each Python release. ! # The product code must change whenever the name of the MSI file ! # changes, and when new component codes are issued for existing ! # components. See "Changing the Product Code". As we change the ! # component codes with every build, we need a new product code ! # each time. For intermediate (alpha) releases, they are automatically ! # generated. For official releases, we record the product codes, ! # so people can refer to them. product_codes = { '2.3.2' : "{3ad0c9ed-7e5e-478c-b539-5cc3a2f8772a}", *************** *** 95,98 **** --- 104,109 ---- def build_database(): + """Generate an empty database, with just the schema and the + Summary information stream.""" if alpha: cv = "%s.%s.%s" % (major, minor, release) *************** *** 101,104 **** --- 112,118 ---- cv = current_version uc = upgrade_code + # schema represents the installer 2.0 database schema. + # sequence is the set of standard sequences + # (ui/execute, admin/advt/install) db = msilib.init_database("python%s.msi" % full_current_version, schema, ProductName="Python "+full_current_version, *************** *** 107,110 **** --- 121,129 ---- Manufacturer=u"Martin v. L\xf6wis") msilib.add_tables(db, sequence) + # We cannot set ALLUSERS in the property table, as this cannot be + # reset if the user choses a per-user installation. Instead, we + # maintain WhichUsers, which can be "ALL" or "JUSTME". The UI manages + # this property, and when the execution starts, ALLUSERS is set + # accordingly. add_data(db, "Property", [("UpgradeCode", uc), ("WhichUsers", "ALL"), *************** *** 114,124 **** def remove_old_versions(db): start = "%s.%s.0" % (major, minor) migrate_features = 1 if alpha: add_data(db, "Upgrade", [(upgrade_code_alpha, start, ! "%s.%s.%s" % (major, minor, release), None, migrate_features, ! None, "REMOVEOLDALPHA")]) props = "REMOVEOLDALPHA" else: --- 133,154 ---- def remove_old_versions(db): + "Fill the upgrade table." start = "%s.%s.0" % (major, minor) + # This requests that feature selection states of an older + # installation should be forwarded into this one. It currently + # does not work if the older installation was per-machine + # and the current installation starts as per-user. migrate_features = 1 + # See "Upgrade Table". We remove releases with the same major and + # minor version. For an alpha, we remove all earlier alphas. For + # a release, we remove all alphas, and all earlier releases. if alpha: add_data(db, "Upgrade", [(upgrade_code_alpha, start, ! "%s.%s.%s" % (major, minor, release), ! None, # Ignore language ! migrate_features, ! None, # Migrate ALL features ! "REMOVEOLDALPHA")]) props = "REMOVEOLDALPHA" else: *************** *** 129,137 **** None, migrate_features, None, "REMOVEOLDALPHA")]) props = "REMOVEOLDALPHA;REMOVEOLDVERSION" add_data(db, "Property", [("SecureCustomProperties", props)]) - class PyDialog(Dialog): def __init__(self, *args, **kw): Dialog.__init__(self, *args) ruler = self.h - 36 --- 159,174 ---- None, migrate_features, None, "REMOVEOLDALPHA")]) props = "REMOVEOLDALPHA;REMOVEOLDVERSION" + # Installer collects the product codes of the earlier releases in + # these properties. In order to allow modification of the properties, + # they must be declared as secure. See "SecureCustomProperties Property" add_data(db, "Property", [("SecureCustomProperties", props)]) class PyDialog(Dialog): + """Dialog class with a fixed layout: controls at the top, then a ruler, + then a list of buttons: back, next, cancel. Optionally a bitmap at the + left.""" def __init__(self, *args, **kw): + """Dialog(database, name, x, y, w, h, attributes, title, first, + default, cancel, bitmap=true)""" Dialog.__init__(self, *args) ruler = self.h - 36 *************** *** 142,170 **** def title(self, title): ! self.text("Title", 135, 10, 220, 60, 196611, r"{\VerdanaBold10}%s" % title) def back(self, title, next, name = "Back", active = 1): if active: ! flags = 3 else: ! flags = 1 return self.pushbutton(name, 180, self.h-27 , 56, 17, flags, title, next) def cancel(self, title, next, name = "Cancel", active = 1): if active: ! flags = 3 else: ! flags = 1 return self.pushbutton(name, 304, self.h-27, 56, 17, flags, title, next) def next(self, title, next, name = "Next", active = 1): if active: ! flags = 3 else: ! flags = 1 return self.pushbutton(name, 236, self.h-27, 56, 17, flags, title, next) def xbutton(self, name, title, next, xpos): return self.pushbutton(name, int(self.w*xpos - 28), self.h-27, 56, 17, 3, title, next) --- 179,227 ---- def title(self, title): ! "Set the title text of the dialog at the top." ! # name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix, ! # text, in VerdanaBold10 ! self.text("Title", 135, 10, 220, 60, 0x30003, r"{\VerdanaBold10}%s" % title) def back(self, title, next, name = "Back", active = 1): + """Add a back button with a given title, the tab-next button, + its name in the Control table, possibly initially disabled. + + Return the button, so that events can be associated""" if active: ! flags = 3 # Visible|Enabled else: ! flags = 1 # Visible return self.pushbutton(name, 180, self.h-27 , 56, 17, flags, title, next) def cancel(self, title, next, name = "Cancel", active = 1): + """Add a cancel button with a given title, the tab-next button, + its name in the Control table, possibly initially disabled. + + Return the button, so that events can be associated""" if active: ! flags = 3 # Visible|Enabled else: ! flags = 1 # Visible return self.pushbutton(name, 304, self.h-27, 56, 17, flags, title, next) def next(self, title, next, name = "Next", active = 1): + """Add a Next button with a given title, the tab-next button, + its name in the Control table, possibly initially disabled. + + Return the button, so that events can be associated""" if active: ! flags = 3 # Visible|Enabled else: ! flags = 1 # Visible return self.pushbutton(name, 236, self.h-27, 56, 17, flags, title, next) def xbutton(self, name, title, next, xpos): + """Add a button with a given title, the tab-next button, + its name in the Control table, giving its x position; the + y-position is aligned with the other buttons. + + Return the button, so that events can be associated""" return self.pushbutton(name, int(self.w*xpos - 28), self.h-27, 56, 17, 3, title, next) *************** *** 175,179 **** title = "[ProductName] Setup" ! # Dialog styles modal = 3 # visible | modal modeless = 1 # visible --- 232,236 ---- title = "[ProductName] Setup" ! # see "Dialog Style Bits" modal = 3 # visible | modal modeless = 1 # visible *************** *** 202,205 **** --- 259,263 ---- """) add_data(db, "Binary", [("Script", msilib.Binary("inst.vbs"))]) + # See "Custom Action Type 6" add_data(db, "CustomAction", [("CheckDir", 6, "Script", "CheckDir")]) os.unlink("inst.vbs") *************** *** 208,212 **** --- 266,272 ---- # UI customization properties add_data(db, "Property", + # See "DefaultUIFont Property" [("DefaultUIFont", "DlgFont8"), + # See "ErrorDialog Style Bit" ("ErrorDialog", "ErrorDlg"), ("Progress1", "Install"), # modified in maintenance type dlg *************** *** 214,218 **** ("MaintenanceForm_Action", "Repair")]) ! # Fonts add_data(db, "TextStyle", [("DlgFont8", "Tahoma", 9, None, 0), --- 274,278 ---- ("MaintenanceForm_Action", "Repair")]) ! # Fonts, see "TextStyle Table" add_data(db, "TextStyle", [("DlgFont8", "Tahoma", 9, None, 0), *************** *** 221,227 **** ]) ! # Custom actions add_data(db, "CustomAction", [ # msidbCustomActionTypeFirstSequence + msidbCustomActionTypeTextData + msidbCustomActionTypeProperty ("InitialTargetDir", 307, "TARGETDIR", "[WindowsVolume]Python%s%s" % (major, minor)), --- 281,289 ---- ]) ! # See "CustomAction Table" add_data(db, "CustomAction", [ # msidbCustomActionTypeFirstSequence + msidbCustomActionTypeTextData + msidbCustomActionTypeProperty + # See "Custom Action Type 51", + # "Custom Action Execution Scheduling Options" ("InitialTargetDir", 307, "TARGETDIR", "[WindowsVolume]Python%s%s" % (major, minor)), *************** *** 230,234 **** ]) ! # UI Sequences add_data(db, "InstallUISequence", [("PrepareDlg", None, 140), --- 292,297 ---- ]) ! # UI Sequences, see "InstallUISequence Table", "Using a Sequence Table" ! # Numbers indicate sequence; see sequence.py for how these action integrate add_data(db, "InstallUISequence", [("PrepareDlg", None, 140), *************** *** 238,242 **** ("SetDLLDirToTarget", 'DLLDIR="" and not Privileged', 752), ("SelectDirectoryDlg", "Not Installed", 1230), ! # XXX notyet #("ResumeDlg", "Installed AND (RESUME OR Preselected)", 1240), ("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250), --- 301,305 ---- ("SetDLLDirToTarget", 'DLLDIR="" and not Privileged', 752), ("SelectDirectoryDlg", "Not Installed", 1230), ! # XXX no support for resume installations yet #("ResumeDlg", "Installed AND (RESUME OR Preselected)", 1240), ("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250), *************** *** 265,271 **** fatal.back("< Back", "Finish", active = 0) fatal.cancel("Cancel", "Back", active = 0) ! fatal.text("Description1", 135, 70, 220, 80, 196611, "[ProductName] setup ended prematurely because of an error. Your system has not been modified. To install this program at a later time, please run the installation again.") ! fatal.text("Description2", 135, 155, 220, 20, 196611, "Click the Finish button to exit the Installer.") c=fatal.next("Finish", "Cancel", name="Finish") --- 328,334 ---- fatal.back("< Back", "Finish", active = 0) fatal.cancel("Cancel", "Back", active = 0) ! fatal.text("Description1", 135, 70, 220, 80, 0x30003, "[ProductName] setup ended prematurely because of an error. Your system has not been modified. To install this program at a later time, please run the installation again.") ! fatal.text("Description2", 135, 155, 220, 20, 0x30003, "Click the Finish button to exit the Installer.") c=fatal.next("Finish", "Cancel", name="Finish") *************** *** 277,284 **** user_exit.back("< Back", "Finish", active = 0) user_exit.cancel("Cancel", "Back", active = 0) ! user_exit.text("Description1", 135, 70, 220, 80, 196611, "[ProductName] setup was interrupted. Your system has not been modified. " "To install this program at a later time, please run the installation again.") ! user_exit.text("Description2", 135, 155, 220, 20, 196611, "Click the Finish button to exit the Installer.") c = user_exit.next("Finish", "Cancel", name="Finish") --- 340,347 ---- user_exit.back("< Back", "Finish", active = 0) user_exit.cancel("Cancel", "Back", active = 0) ! user_exit.text("Description1", 135, 70, 220, 80, 0x30003, "[ProductName] setup was interrupted. Your system has not been modified. " "To install this program at a later time, please run the installation again.") ! user_exit.text("Description2", 135, 155, 220, 20, 0x30003, "Click the Finish button to exit the Installer.") c = user_exit.next("Finish", "Cancel", name="Finish") *************** *** 290,294 **** exit_dialog.back("< Back", "Finish", active = 0) exit_dialog.cancel("Cancel", "Back", active = 0) ! exit_dialog.text("Description", 135, 115, 220, 20, 196611, "Click the Finish button to exit the Installer.") c = exit_dialog.next("Finish", "Cancel", name="Finish") --- 353,357 ---- exit_dialog.back("< Back", "Finish", active = 0) exit_dialog.cancel("Cancel", "Back", active = 0) ! exit_dialog.text("Description", 135, 115, 220, 20, 0x30003, "Click the Finish button to exit the Installer.") c = exit_dialog.next("Finish", "Cancel", name="Finish") *************** *** 297,305 **** ##################################################################### # Required dialog: FilesInUse, ErrorDlg ! inuse = PyDialog(db, "FilesInUse", x, y, w, h, 19, title, "Retry", "Retry", "Retry", bitmap=False) ! inuse.text("Title", 15, 6, 200, 15, 196611, r"{\DlgFontBold8}Files in Use") ! inuse.text("Description", 20, 23, 280, 20, 196611, "Some files that need to be updated are currently in use.") inuse.text("Text", 20, 55, 330, 50, 3, --- 360,371 ---- ##################################################################### # Required dialog: FilesInUse, ErrorDlg ! inuse = PyDialog(db, "FilesInUse", ! x, y, w, h, ! 19, # KeepModeless|Modal|Visible ! title, "Retry", "Retry", "Retry", bitmap=False) ! inuse.text("Title", 15, 6, 200, 15, 0x30003, r"{\DlgFontBold8}Files in Use") ! inuse.text("Description", 20, 23, 280, 20, 0x30003, "Some files that need to be updated are currently in use.") inuse.text("Text", 20, 55, 330, 50, 3, *************** *** 314,318 **** c.event("EndDialog","Retry") ! error = Dialog(db, "ErrorDlg", 50, 10, 330, 101, 65543, title, "ErrorText", None, None) error.text("ErrorText", 50,9,280,48,3, "") --- 380,389 ---- c.event("EndDialog","Retry") ! ! # See "Error Dialog". See "ICE20" for the required names of the controls. ! error = Dialog(db, "ErrorDlg", ! 50, 10, 330, 101, ! 65543, # Error|Minimize|Modal|Visible ! title, "ErrorText", None, None) error.text("ErrorText", 50,9,280,48,3, "") *************** *** 355,364 **** prep = PyDialog(db, "PrepareDlg", x, y, w, h, modeless, title, "Cancel", "Cancel", "Cancel") ! prep.text("Description", 135, 70, 220, 40, 196611, "Please wait while the Installer prepares to guide you through the installation.") prep.title("Welcome to the [ProductName] Installer") ! c=prep.text("ActionText", 135, 110, 220, 20, 196611, "Pondering...") c.mapping("ActionText", "Text") ! c=prep.text("ActionData", 135, 135, 220, 30, 196611, None) c.mapping("ActionData", "Text") prep.back("Back", None, active=0) --- 426,435 ---- prep = PyDialog(db, "PrepareDlg", x, y, w, h, modeless, title, "Cancel", "Cancel", "Cancel") ! prep.text("Description", 135, 70, 220, 40, 0x30003, "Please wait while the Installer prepares to guide you through the installation.") prep.title("Welcome to the [ProductName] Installer") ! c=prep.text("ActionText", 135, 110, 220, 20, 0x30003, "Pondering...") c.mapping("ActionText", "Text") ! c=prep.text("ActionData", 135, 135, 220, 30, 0x30003, None) c.mapping("ActionData", "Text") prep.back("Back", None, active=0) *************** *** 371,375 **** "Next", "Next", "Cancel") seldlg.title("Select Destination Directory") ! seldlg.text("Description", 135, 50, 220, 40, 196611, "Please select a directory for the [ProductName] files.") --- 442,446 ---- "Next", "Next", "Cancel") seldlg.title("Select Destination Directory") ! seldlg.text("Description", 135, 50, 220, 40, 0x30003, "Please select a directory for the [ProductName] files.") *************** *** 400,404 **** title, "Tree", "Next", "Cancel") features.title("Customize [ProductName]") ! features.text("Description", 135, 35, 220, 15, 196611, "Select the way you want features to be installed.") features.text("Text", 135,45,220,30, 3, --- 471,475 ---- title, "Tree", "Next", "Cancel") features.title("Customize [ProductName]") ! features.text("Description", 135, 35, 220, 15, 0x30003, "Select the way you want features to be installed.") features.text("Text", 135,45,220,30, 3, *************** *** 446,452 **** cost = PyDialog(db, "DiskCostDlg", x, y, w, h, modal, title, "OK", "OK", "OK", bitmap=False) ! cost.text("Title", 15, 6, 200, 15, 196611, "{\DlgFontBold8}Disk Space Requirements") ! cost.text("Description", 20, 20, 280, 20, 196611, "The disk space required for the installation of the selected features.") cost.text("Text", 20, 53, 330, 60, 3, --- 517,523 ---- cost = PyDialog(db, "DiskCostDlg", x, y, w, h, modal, title, "OK", "OK", "OK", bitmap=False) ! cost.text("Title", 15, 6, 200, 15, 0x30003, "{\DlgFontBold8}Disk Space Requirements") ! cost.text("Description", 20, 20, 280, 20, 0x30003, "The disk space required for the installation of the selected features.") cost.text("Text", 20, 53, 330, 60, 3, *************** *** 465,476 **** "OK", "OK", "OK") advanced.title("Advanced Options") g = advanced.radiogroup("AdminInstall", 135, 60, 160, 50, 3, "WhichUsers", "", "OK") # ALLUSERS should not be tempered with on W9x g.condition("Hide", "Windows9x or NOT Privileged") g.add("ALL", 0, 5, 150, 20, "Install for all users") g.add("JUSTME", 0, 25, 150, 20, "Install just for me") ! # Alternative texts if AdminInstall is not available c=advanced.text("Unprivileged", 135, 90, 160, 50, 3, "Installing Python for all users is not possible, because you lack privileges. Python will be installed for you only.") --- 536,549 ---- "OK", "OK", "OK") advanced.title("Advanced Options") + # A radio group with two options: allusers, justme g = advanced.radiogroup("AdminInstall", 135, 60, 160, 50, 3, "WhichUsers", "", "OK") # ALLUSERS should not be tempered with on W9x + # See "ControlCondition Table" g.condition("Hide", "Windows9x or NOT Privileged") g.add("ALL", 0, 5, 150, 20, "Install for all users") g.add("JUSTME", 0, 25, 150, 20, "Install just for me") ! # Alternative texts if privilged install is not available c=advanced.text("Unprivileged", 135, 90, 160, 50, 3, "Installing Python for all users is not possible, because you lack privileges. Python will be installed for you only.") *************** *** 481,484 **** --- 554,560 ---- c = advanced.cancel("Ok", "AdminInstall", name="OK") + # See "ControlEvent Table". Parameters are the event, the parameter + # to the action, the condition for the event, and optionally the order + # of events. c.event("DoAction", "SetDLLDirToTarget", 'WhichUsers="JUSTME"', 1) c.event("DoAction", "SetDLLDirToSystem32", 'WhichUsers="ALL" and (Windows9x or Privileged)', 2) *************** *** 502,506 **** progress = PyDialog(db, "ProgressDlg", x, y, w, h, modeless, title, "Cancel", "Cancel", "Cancel", bitmap=False) ! progress.text("Title", 20, 15, 200, 15, 196611, "{\DlgFontBold8}[Progress1] [ProductName]") progress.text("Text", 35, 65, 300, 30, 3, --- 578,582 ---- progress = PyDialog(db, "ProgressDlg", x, y, w, h, modeless, title, "Cancel", "Cancel", "Cancel", bitmap=False) ! progress.text("Title", 20, 15, 200, 15, 0x30003, "{\DlgFontBold8}[Progress1] [ProductName]") progress.text("Text", 35, 65, 300, 30, 3, *************** *** 556,559 **** --- 632,639 ---- + # See "Feature Table". The feature level is 1 for all features, + # and the feature attributes are 0 for the DefaultFeature, and + # FollowParent for all other features. The numbers are the Display + # column. def add_features(db): global default_feature, tcltk, htmlfiles, tools, testsuite, ext_feature *************** *** 597,600 **** --- 677,682 ---- installer.FileVersion("msvcr71.dll", 1) + # See "File Table", "Component Table", "Directory Table", + # "FeatureComponents Table" def add_files(db): cab = CAB("python") *************** *** 609,618 **** root.add_file("NEWS.txt", src="Misc/NEWS") root.add_file("LICENSE.txt", src="LICENSE") ! # msidbComponentAttributesSharedDllRefCount = 8 ! root.start_component("python.exe", flags = 8, keyfile="python.exe") root.add_file("PCBuild/python.exe") ! root.start_component("pythonw.exe", flags = 8, keyfile="pythonw.exe") root.add_file("PCBuild/pythonw.exe") dlldir = Directory(db, cab, root, srcdir, "DLLDIR", ".") pydll = "python%s%s.dll" % (major, minor) --- 691,700 ---- root.add_file("NEWS.txt", src="Misc/NEWS") root.add_file("LICENSE.txt", src="LICENSE") ! root.start_component("python.exe", keyfile="python.exe") root.add_file("PCBuild/python.exe") ! root.start_component("pythonw.exe", keyfile="pythonw.exe") root.add_file("PCBuild/pythonw.exe") + # msidbComponentAttributesSharedDllRefCount = 8, see "Component Table" dlldir = Directory(db, cab, root, srcdir, "DLLDIR", ".") pydll = "python%s%s.dll" % (major, minor) *************** *** 651,654 **** --- 733,737 ---- files += lib.glob("*.pyw") if files: + # Add an entry to the RemoveFile table to remove bytecode files. lib.remove_pyc() if dir=='test' and parent.physical=='Lib': *************** *** 760,763 **** --- 843,847 ---- os.unlink(f) + # See "Registry Table", "Component Table" def add_registry(db): # File extensions, associated with the REGISTRY.def component *************** *** 766,769 **** --- 850,854 ---- # -1 for Root specifies "dependent on ALLUSERS property" add_data(db, "Component", + # msidbComponentAttributesRegistryKeyPath = 4 [("REGISTRY", msilib.gen_uuid(), "TARGETDIR", 4, None, "InstallPath"), *************** *** 772,775 **** --- 857,861 ---- ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", 4, "&%s <> 2" % ext_feature.id, "py.IDLE")]) + # See "FeatureComponents Table" add_data(db, "FeatureComponents", [(default_feature.id, "REGISTRY"), *************** *** 839,843 **** "", r"[TARGETDIR]Python.exe", "REGISTRY.def") ]) ! # Shortcuts add_data(db, "Directory", [("ProgramMenuFolder", "TARGETDIR", "."), --- 925,929 ---- "", r"[TARGETDIR]Python.exe", "REGISTRY.def") ]) ! # Shortcuts, see "Shortcut Table" add_data(db, "Directory", [("ProgramMenuFolder", "TARGETDIR", "."), From loewis at users.sourceforge.net Sun Aug 1 12:03:18 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 1 12:03:21 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24807 Modified Files: msi.py Log Message: Rename alpha to snapshot. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** msi.py 1 Aug 2004 10:02:14 -0000 1.19 --- msi.py 1 Aug 2004 10:03:15 -0000 1.20 *************** *** 14,18 **** # 0 for beta or final releases; # 1 means to use a new product code for each package ! alpha = 1 # 1 means that file extension is px, not py, # and binaries start with x --- 14,18 ---- # 0 for beta or final releases; # 1 means to use a new product code for each package ! snapshot = 1 # 1 means that file extension is px, not py, # and binaries start with x *************** *** 22,26 **** # Text to be displayed as the version in dialogs etc. # goes into file name and ProductCode. Defaults to ! # current_version.day for Alpha, current_version otherwise full_current_version = None --- 22,26 ---- # Text to be displayed as the version in dialogs etc. # goes into file name and ProductCode. Defaults to ! # current_version.day for Snapshot, current_version otherwise full_current_version = None *************** *** 36,40 **** # used in the Upgrade table of future packages to make the future # package replace this one. See "UpgradeCode Property". ! upgrade_code_alpha='{92A24481-3ECB-40FC-8836-04B7966EC0D5}' upgrade_code='{65E6DE48-A358-434D-AA4F-4AF72DB4718F}' --- 36,40 ---- # used in the Upgrade table of future packages to make the future # package replace this one. See "UpgradeCode Property". ! upgrade_code_snapshot='{92A24481-3ECB-40FC-8836-04B7966EC0D5}' upgrade_code='{65E6DE48-A358-434D-AA4F-4AF72DB4718F}' *************** *** 44,48 **** # components. See "Changing the Product Code". As we change the # component codes with every build, we need a new product code ! # each time. For intermediate (alpha) releases, they are automatically # generated. For official releases, we record the product codes, # so people can refer to them. --- 44,48 ---- # components. See "Changing the Product Code". As we change the # component codes with every build, we need a new product code ! # each time. For intermediate (snapshot) releases, they are automatically # generated. For official releases, we record the product codes, # so people can refer to them. *************** *** 54,58 **** product_code = product_codes[current_version] ! if alpha: release = int(time.time()/3600/24) product_code = msilib.gen_uuid() --- 54,58 ---- product_code = product_codes[current_version] ! if snapshot: release = int(time.time()/3600/24) product_code = msilib.gen_uuid() *************** *** 84,88 **** if full_current_version is None: ! if alpha: full_current_version = "%s.%d" % (current_version, release) else: --- 84,88 ---- if full_current_version is None: ! if snapshot: full_current_version = "%s.%d" % (current_version, release) else: *************** *** 106,112 **** """Generate an empty database, with just the schema and the Summary information stream.""" ! if alpha: cv = "%s.%s.%s" % (major, minor, release) ! uc = upgrade_code_alpha else: cv = current_version --- 106,112 ---- """Generate an empty database, with just the schema and the Summary information stream.""" ! if snapshot: cv = "%s.%s.%s" % (major, minor, release) ! uc = upgrade_code_snapshot else: cv = current_version *************** *** 141,162 **** migrate_features = 1 # See "Upgrade Table". We remove releases with the same major and ! # minor version. For an alpha, we remove all earlier alphas. For ! # a release, we remove all alphas, and all earlier releases. ! if alpha: add_data(db, "Upgrade", ! [(upgrade_code_alpha, start, "%s.%s.%s" % (major, minor, release), None, # Ignore language migrate_features, None, # Migrate ALL features ! "REMOVEOLDALPHA")]) ! props = "REMOVEOLDALPHA" else: add_data(db, "Upgrade", [(upgrade_code, start, current_version, None, migrate_features, None, "REMOVEOLDVERSION"), ! (upgrade_code_alpha, start, "%s.%s.0" % (major, minor+1), ! None, migrate_features, None, "REMOVEOLDALPHA")]) ! props = "REMOVEOLDALPHA;REMOVEOLDVERSION" # Installer collects the product codes of the earlier releases in # these properties. In order to allow modification of the properties, --- 141,162 ---- migrate_features = 1 # See "Upgrade Table". We remove releases with the same major and ! # minor version. For an snapshot, we remove all earlier snapshots. For ! # a release, we remove all snapshots, and all earlier releases. ! if snapshot: add_data(db, "Upgrade", ! [(upgrade_code_snapshot, start, "%s.%s.%s" % (major, minor, release), None, # Ignore language migrate_features, None, # Migrate ALL features ! "REMOVEOLDSNAPSHOT")]) ! props = "REMOVEOLDSNAPSHOT" else: add_data(db, "Upgrade", [(upgrade_code, start, current_version, None, migrate_features, None, "REMOVEOLDVERSION"), ! (upgrade_code_snapshot, start, "%s.%s.0" % (major, minor+1), ! None, migrate_features, None, "REMOVEOLDSNAPSHOT")]) ! props = "REMOVEOLDSNAPSHOT;REMOVEOLDVERSION" # Installer collects the product codes of the earlier releases in # these properties. In order to allow modification of the properties, From loewis at users.sourceforge.net Sun Aug 1 12:41:20 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 1 12:41:22 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.20,1.21 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29115 Modified Files: msi.py Log Message: Extract version from patchlevel.h. Make releases have the same ProductVersion as the Python DLL. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** msi.py 1 Aug 2004 10:03:15 -0000 1.20 --- msi.py 1 Aug 2004 10:41:17 -0000 1.21 *************** *** 10,15 **** # 1 for Itanium build msilib.Win64 = 0 - # Micro version - current_version = "2.4.0" # 0 for beta or final releases; # 1 means to use a new product code for each package --- 10,13 ---- *************** *** 30,35 **** pass ! major, minor, micro = current_version.split(".") short_version = major+"."+minor # This should never change. The UpgradeCode of this package can be --- 28,57 ---- pass ! # Extract current version from Include/patchlevel.h ! lines = open(srcdir + "/Include/patchlevel.h").readlines() ! major = minor = micro = level = serial = None ! levels = { ! 'PY_RELEASE_LEVEL_ALPHA':0xA, ! 'PY_RELEASE_LEVEL_BETA': 0xB, ! 'PY_RELEASE_LEVEL_GAMMA':0xC, ! 'PY_RELEASE_LEVEL_FINAL':0xF ! } ! for l in lines: ! if not l.startswith("#define"): ! continue ! l = l.split() ! if len(l) != 3: ! continue ! _, name, value = l ! if name == 'PY_MAJOR_VERSION': major = value ! if name == 'PY_MINOR_VERSION': minor = value ! if name == 'PY_MICRO_VERSION': micro = value ! if name == 'PY_RELEASE_LEVEL': level = levels[value] ! if name == 'PY_RELEASE_SERIAL': serial = value ! short_version = major+"."+minor + # See PC/make_versioninfo.c + FIELD3 = 1000*int(micro) + 10*level + int(serial) + current_version = "%s.%d" % (short_version, FIELD3) # This should never change. The UpgradeCode of this package can be *************** *** 48,60 **** # so people can refer to them. product_codes = { ! '2.3.2' : "{3ad0c9ed-7e5e-478c-b539-5cc3a2f8772a}", ! '2.3.3' : "{aab605af-d181-4b68-bcb0-6beb32f32844}", ! '2.4.0': "{93792a5a-5bb0-43b1-904f-ba10c4f08ec8}", } - product_code = product_codes[current_version] if snapshot: ! release = int(time.time()/3600/24) product_code = msilib.gen_uuid() extensions = [ --- 70,91 ---- # so people can refer to them. product_codes = { ! '2.4.101': '{0e9b4d8e-6cda-446e-a208-7b92f3ddffa0}', # 2.4a1, released as a snapshot ! '2.4.102': '{1b998745-4901-4edb-bc52-213689e1b922}', # 2.4a2 ! '2.4.103': '{33fc8bd2-1e8f-4add-a40a-ade2728d5942}', # 2.4a3 ! '2.4.111': '{51a7e2a8-2025-4ef0-86ff-e6aab742d1fa}', # 2.4b1 ! '2.4.112': '{4a5e7c1d-c659-4fe3-b8c9-7c65bd9c95a5}', # 2.4b2 ! '2.4.121': '{75508821-a8e9-40a8-95bd-dbe6033ddbea}', # 2.4c1 ! '2.4.122': '{83a9118b-4bdd-473b-afc3-bcb142feca9e}', # 2.4c2 ! '2.4.150': '{82d9302e-f209-4805-b548-52087047483a}', # 2.4.0 } if snapshot: ! current_version = "%s.%s.%s" % (major, minor, int(time.time()/3600/24)) product_code = msilib.gen_uuid() + else: + product_code = product_codes[current_version] + + if full_current_version is None: + full_current_version = current_version extensions = [ *************** *** 83,92 **** ]) - if full_current_version is None: - if snapshot: - full_current_version = "%s.%d" % (current_version, release) - else: - full_current_version = current_version - if testpackage: ext = 'px' --- 114,117 ---- *************** *** 107,114 **** Summary information stream.""" if snapshot: - cv = "%s.%s.%s" % (major, minor, release) uc = upgrade_code_snapshot else: - cv = current_version uc = upgrade_code # schema represents the installer 2.0 database schema. --- 132,137 ---- *************** *** 118,122 **** ProductName="Python "+full_current_version, ProductCode=product_code, ! ProductVersion=cv, Manufacturer=u"Martin v. L\xf6wis") msilib.add_tables(db, sequence) --- 141,145 ---- ProductName="Python "+full_current_version, ProductCode=product_code, ! ProductVersion=current_version, Manufacturer=u"Martin v. L\xf6wis") msilib.add_tables(db, sequence) *************** *** 146,150 **** add_data(db, "Upgrade", [(upgrade_code_snapshot, start, ! "%s.%s.%s" % (major, minor, release), None, # Ignore language migrate_features, --- 169,173 ---- add_data(db, "Upgrade", [(upgrade_code_snapshot, start, ! current_version, None, # Ignore language migrate_features, *************** *** 702,707 **** dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll) installer = msilib.MakeInstaller() dlldir.add_file("PCBuild/python%s%s.dll" % (major, minor), ! version=installer.FileVersion(pydllsrc, 0), language=installer.FileVersion(pydllsrc, 1)) # XXX determine dependencies --- 725,735 ---- dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll) installer = msilib.MakeInstaller() + pyversion = installer.FileVersion(pydllsrc, 0) + if not snapshot: + # For releases, the Python DLL has the same version as the + # installer package. + assert pyversion == current_version dlldir.add_file("PCBuild/python%s%s.dll" % (major, minor), ! version=pyversion, language=installer.FileVersion(pydllsrc, 1)) # XXX determine dependencies From loewis at users.sourceforge.net Sun Aug 1 12:45:08 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 1 12:45:12 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29721 Modified Files: msi.py Log Message: Clarify snapshot semantics. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** msi.py 1 Aug 2004 10:41:17 -0000 1.21 --- msi.py 1 Aug 2004 10:45:04 -0000 1.22 *************** *** 10,15 **** # 1 for Itanium build msilib.Win64 = 0 ! # 0 for beta or final releases; ! # 1 means to use a new product code for each package snapshot = 1 # 1 means that file extension is px, not py, --- 10,16 ---- # 1 for Itanium build msilib.Win64 = 0 ! # 0 for official python.org releases ! # 1 for intermediate releases by anybody, with ! # a new product code for every package. snapshot = 1 # 1 means that file extension is px, not py, From vikkimichaelizjay at eyesonff.com Sun Aug 1 16:28:52 2004 From: vikkimichaelizjay at eyesonff.com (chung locke) Date: Sun Aug 1 19:06:55 2004 Subject: [Python-checkins] are you tired a lot Message-ID: <3FA9A152.6AA00C7@eyesonff.com> electrophoridae lnfnetheapethpirellis, m_,e`^ds from u_'s~.a & 0v`'ern,ight shi-pp`ing ann-marinorthcarolina http://www.myrx-is-number1.com The story was received with many doubtful looks and much grave shaking of heads, as was quite natural under the circumstances -----Original Message----- From: Mariko Shaw [mailto:rxluvfi@cpl.com] To: clay bear; emmanuel mattson Sent: Monday, October, 2004 3:54 PM Subject: elevate mood and improve sleep wabernat,comserver~ The birds did not sing, nor did the cows moo; yet there was more than ordinary activity everywhere Certainly apedernalado10desteto52bombardear,empina enjoyada. From loewis at users.sourceforge.net Sun Aug 1 19:18:18 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 1 19:18:21 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py, 1.22, 1.23 sequence.py, 1.1.1.1, 1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28415 Modified Files: msi.py sequence.py Log Message: Add support for upgrade installations. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** msi.py 1 Aug 2004 10:45:04 -0000 1.22 --- msi.py 1 Aug 2004 17:18:15 -0000 1.23 *************** *** 160,166 **** start = "%s.%s.0" % (major, minor) # This requests that feature selection states of an older ! # installation should be forwarded into this one. It currently ! # does not work if the older installation was per-machine ! # and the current installation starts as per-user. migrate_features = 1 # See "Upgrade Table". We remove releases with the same major and --- 160,166 ---- start = "%s.%s.0" % (major, minor) # This requests that feature selection states of an older ! # installation should be forwarded into this one. Upgrading ! # requires that both the old and the new installation are ! # either both per-machine or per-user. migrate_features = 1 # See "Upgrade Table". We remove releases with the same major and *************** *** 180,184 **** [(upgrade_code, start, current_version, None, migrate_features, None, "REMOVEOLDVERSION"), ! (upgrade_code_snapshot, start, "%s.%s.0" % (major, minor+1), None, migrate_features, None, "REMOVEOLDSNAPSHOT")]) props = "REMOVEOLDSNAPSHOT;REMOVEOLDVERSION" --- 180,184 ---- [(upgrade_code, start, current_version, None, migrate_features, None, "REMOVEOLDVERSION"), ! (upgrade_code_snapshot, start, "%s.%d.0" % (major, int(minor)+1), None, migrate_features, None, "REMOVEOLDSNAPSHOT")]) props = "REMOVEOLDSNAPSHOT;REMOVEOLDVERSION" *************** *** 319,323 **** # Numbers indicate sequence; see sequence.py for how these action integrate add_data(db, "InstallUISequence", ! [("PrepareDlg", None, 140), ("InitialTargetDir", 'TARGETDIR=""', 750), # In the user interface, assume all-users installation if privileged. --- 319,324 ---- # Numbers indicate sequence; see sequence.py for how these action integrate add_data(db, "InstallUISequence", ! [("PrepareDlg", "Not Privileged or Windows9x or Installed", 140), ! ("WhichUsersDlg", "Privileged and not Windows9x and not Installed", 141), ("InitialTargetDir", 'TARGETDIR=""', 750), # In the user interface, assume all-users installation if privileged. *************** *** 357,360 **** --- 358,364 ---- "Click the Finish button to exit the Installer.") c=fatal.next("Finish", "Cancel", name="Finish") + # See "ControlEvent Table". Parameters are the event, the parameter + # to the action, and optionally the condition for the event, and the order + # of events. c.event("EndDialog", "Exit") *************** *** 462,465 **** --- 466,470 ---- c.event("SpawnDialog", "CancelDlg") + ##################################################################### # Target directory selection seldlg = PyDialog(db, "SelectDirectoryDlg", x, y, w, h, modal, title, *************** *** 472,479 **** c = seldlg.next("Next >", "Cancel") c.event("DoAction", "CheckDir", "TargetExistsOk<>1", order=1) ! c.event("SpawnDialog", "ExistingDirectoryDlg", "TargetExists=1", 2) ! c.event("SetTargetPath", "TARGETDIR", "TargetExists=0", 3) c.event("SpawnWaitDialog", "WaitForCostingDlg", "CostingComplete=1", 4) ! c.event("NewDialog", "SelectFeaturesDlg", "TargetExists=0", 5) c = seldlg.cancel("Cancel", "DirectoryCombo") --- 477,488 ---- c = seldlg.next("Next >", "Cancel") c.event("DoAction", "CheckDir", "TargetExistsOk<>1", order=1) ! # If the target exists, but we found that we are going to remove old versions, don't bother ! # confirming that the target directory exists. Strictly speaking, we should determine that ! # the target directory is indeed the target of the product that we are going to remove, but ! # I don't know how to do that. ! c.event("SpawnDialog", "ExistingDirectoryDlg", 'TargetExists=1 and REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""', 2) ! c.event("SetTargetPath", "TARGETDIR", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 3) c.event("SpawnWaitDialog", "WaitForCostingDlg", "CostingComplete=1", 4) ! c.event("NewDialog", "SelectFeaturesDlg", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 5) c = seldlg.cancel("Cancel", "DirectoryCombo") *************** *** 505,511 **** c=features.next("Next >", "Cancel") c.mapping("SelectionNoItems", "Enabled") ! c.event("[ALLUSERS]", "2", 'VersionNT and WhichUsers="ALL"', order=1) ! c.event("SpawnDialog", "DiskCostDlg", "OutOfDiskSpace=1", order=2) ! c.event("EndDialog", "Return", "OutOfDiskSpace<>1", order=3) c=features.cancel("Cancel", "Tree") --- 514,519 ---- c=features.next("Next >", "Cancel") c.mapping("SelectionNoItems", "Enabled") ! c.event("SpawnDialog", "DiskCostDlg", "OutOfDiskSpace=1", order=1) ! c.event("EndDialog", "Return", "OutOfDiskSpace<>1", order=2) c=features.cancel("Cancel", "Tree") *************** *** 526,532 **** c.event("SpawnDialog", "DiskCostDlg") - c=features.xbutton("Advanced", "Advanced", None, 0.30) - c.event("SpawnDialog", "AdvancedDlg") - c=features.text("ItemDescription", 140, 180, 210, 30, 3, "Multiline description of the currently selected item.") --- 534,537 ---- *************** *** 556,587 **** ##################################################################### ! # Advanced Options ! advanced = PyDialog(db, "AdvancedDlg", x, y, w, h, modal, title, ! "OK", "OK", "OK") ! advanced.title("Advanced Options") # A radio group with two options: allusers, justme ! g = advanced.radiogroup("AdminInstall", 135, 60, 160, 50, 3, ! "WhichUsers", "", "OK") ! # ALLUSERS should not be tempered with on W9x ! # See "ControlCondition Table" ! g.condition("Hide", "Windows9x or NOT Privileged") g.add("ALL", 0, 5, 150, 20, "Install for all users") g.add("JUSTME", 0, 25, 150, 20, "Install just for me") ! # Alternative texts if privilged install is not available ! c=advanced.text("Unprivileged", 135, 90, 160, 50, 3, ! "Installing Python for all users is not possible, because you lack privileges. Python will be installed for you only.") ! c.condition("Hide", "Privileged") ! c=advanced.text("W9X", 135, 80, 160, 90, 3, ! "Installing Python for all users is not possible on Windows 9x.") ! c.condition("Hide", "NOT Windows9x") ! c = advanced.cancel("Ok", "AdminInstall", name="OK") ! # See "ControlEvent Table". Parameters are the event, the parameter ! # to the action, the condition for the event, and optionally the order ! # of events. ! c.event("DoAction", "SetDLLDirToTarget", 'WhichUsers="JUSTME"', 1) ! c.event("DoAction", "SetDLLDirToSystem32", 'WhichUsers="ALL" and (Windows9x or Privileged)', 2) ! c.event("EndDialog", "Return", order = 3) ##################################################################### --- 561,591 ---- ##################################################################### ! # WhichUsers Dialog. Only available on NT, and for privileged users. ! # This must be run before FindRelatedProducts, because that will ! # take into account whether the previous installation was per-user ! # or per-machine. We currently don't support going back to this ! # dialog after "Next" was selected; to support this, we would need to ! # find how to reset the ALLUSERS property, and how to re-run ! # FindRelatedProducts. ! # On Windows9x, the ALLUSERS property is ignored on the command line ! # and in the Property table, but installer fails according to the documentation ! # if a dialog attempts to set ALLUSERS. ! whichusers = PyDialog(db, "WhichUsersDlg", x, y, w, h, modal, title, ! "AdminInstall", "Next", "Cancel") ! whichusers.title("Select whether to install [ProductName] for all users of this computer.") # A radio group with two options: allusers, justme ! g = whichusers.radiogroup("AdminInstall", 135, 60, 160, 50, 3, ! "WhichUsers", "", "Next") g.add("ALL", 0, 5, 150, 20, "Install for all users") g.add("JUSTME", 0, 25, 150, 20, "Install just for me") ! whichusers.back("Back", None, active=0) ! c = whichusers.next("Next >", "Cancel") ! c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1) ! c.event("EndDialog", "Return", order = 2) ! ! c = whichusers.cancel("Cancel", "AdminInstall") ! c.event("SpawnDialog", "CancelDlg") ##################################################################### *************** *** 730,734 **** # For releases, the Python DLL has the same version as the # installer package. ! assert pyversion == current_version dlldir.add_file("PCBuild/python%s%s.dll" % (major, minor), version=pyversion, --- 734,738 ---- # For releases, the Python DLL has the same version as the # installer package. ! assert pyversion.split(".")[:3] == current_version.split(".") dlldir.add_file("PCBuild/python%s%s.dll" % (major, minor), version=pyversion, Index: sequence.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/sequence.py,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** sequence.py 29 Dec 2003 14:04:37 -0000 1.1.1.1 --- sequence.py 1 Aug 2004 17:18:16 -0000 1.2 *************** *** 77,81 **** (u'RemoveDuplicateFiles', None, 3400), (u'RemoveEnvironmentStrings', None, 3300), ! (u'RemoveExistingProducts', None, 6700), (u'RemoveFiles', None, 3500), (u'RemoveFolders', None, 3600), --- 77,85 ---- (u'RemoveDuplicateFiles', None, 3400), (u'RemoveEnvironmentStrings', None, 3300), ! # Microsoft it is best to run removal after the installation is committed, so ! # that only extra files get removed. However, this appears to delete all installed ! # files, so for the moment, we do what Microsoft says is most inefficient. ! #(u'RemoveExistingProducts', None, 6700), ! (u'RemoveExistingProducts', None, 1450), (u'RemoveFiles', None, 3500), (u'RemoveFolders', None, 3600), From adrienkeylon at jobcatalog.com Sun Aug 1 17:33:00 2004 From: adrienkeylon at jobcatalog.com (aurelio velmontes) Date: Sun Aug 1 19:43:27 2004 Subject: [Python-checkins] reverse osteoporosis Message-ID: <0254E40F.EA35373@jobcatalog.com> coleville^malesherbiaceaebeqaftgniyleb amahler. m^ed-icine from am`_eri,`ca & 0vern-ight shi_ppi^.ng` -~cfjmdquakerly http://ivg.u.tantalizes6507dryg.us/f74/ --Demon, said the boy -----Original Message----- From: Suanne Porter [mailto:wofmown@ri.com] To: ryan mangrum; isaias rocha; harley redder; val ridley Sent: Monday, October, 2004 2:48 PM Subject: Cdhxreverse osteoporosisAawf tnmcu`flbcopy- And this is the Hungry Tiger, the terror of the jungle, who longs to devour fat babies but is prevented by his conscience from doing so What will you give me first? asked the boy, eagerly many people will walk in and out of your life . . . tribulante10teologi`a52gaitero,gordilla matraca. From loewis at users.sourceforge.net Mon Aug 2 00:14:23 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Aug 2 00:14:26 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py, 1.23, 1.24 msilib.py, 1.9, 1.10 sequence.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8863 Modified Files: msi.py msilib.py sequence.py Log Message: Add file hashes to unversioned files. Remove change to sequence; change sequence when generating the database. Add API to support sequence changes. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** msi.py 1 Aug 2004 17:18:15 -0000 1.23 --- msi.py 1 Aug 2004 22:14:19 -0000 1.24 *************** *** 144,147 **** --- 144,153 ---- ProductVersion=current_version, Manufacturer=u"Martin v. L\xf6wis") + # The default sequencing of the RemoveExistingProducts action causes + # removal of files that got just installed. Place it after + # InstallInitialize, so we first uninstall everything, but still roll + # back in case the installation is interrupted + msilib.change_sequence(sequence.InstallExecuteSequence, + "RemoveExistingProducts", 1510) msilib.add_tables(db, sequence) # We cannot set ALLUSERS in the property table, as this cannot be Index: msilib.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msilib.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** msilib.py 27 Jul 2004 16:36:21 -0000 1.9 --- msilib.py 1 Aug 2004 22:14:19 -0000 1.10 *************** *** 241,244 **** --- 241,255 ---- f.close() + class _Unspecified:pass + def change_sequence(seq, action, seqno, cond = _Unspecified): + "Change the sequence number of an action in a sequence list" + for i in range(len(seq)): + if seq[i][0] == action: + if cond is _Unspecified: + cond = seq[i][1] + seq[i] = (action, cond, seqno) + return + raise ValueError, "Action not found in sequence" + def add_data(db, table, values): d = MakeInstaller() *************** *** 494,497 **** --- 505,515 ---- [(logical, self.component, full, filesize, version, language, attributes, sequence)]) + if not version: + # Add hash if the file is not versioned + filehash = MakeInstaller().FileHash(absolute, 0) + add_data(self.db, "MsiFileHash", + [(logical, 0, filehash.IntegerData(1), + filehash.IntegerData(2), filehash.IntegerData(3), + filehash.IntegerData(4))]) # Automatically remove .pyc/.pyo files on uninstall (2) # XXX: adding so many RemoveFile entries makes installer unbelievably *************** *** 523,527 **** if parent: attributes |= 2 # follow parent ! parent = parent.id add_data(db, "Feature", [(id, parent, title, desc, display, --- 541,545 ---- if parent: attributes |= 2 # follow parent ! parent = parent.id add_data(db, "Feature", [(id, parent, title, desc, display, Index: sequence.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/sequence.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sequence.py 1 Aug 2004 17:18:16 -0000 1.2 --- sequence.py 1 Aug 2004 22:14:19 -0000 1.3 *************** *** 77,85 **** (u'RemoveDuplicateFiles', None, 3400), (u'RemoveEnvironmentStrings', None, 3300), ! # Microsoft it is best to run removal after the installation is committed, so ! # that only extra files get removed. However, this appears to delete all installed ! # files, so for the moment, we do what Microsoft says is most inefficient. ! #(u'RemoveExistingProducts', None, 6700), ! (u'RemoveExistingProducts', None, 1450), (u'RemoveFiles', None, 3500), (u'RemoveFolders', None, 3600), --- 77,81 ---- (u'RemoveDuplicateFiles', None, 3400), (u'RemoveEnvironmentStrings', None, 3300), ! (u'RemoveExistingProducts', None, 6700), (u'RemoveFiles', None, 3500), (u'RemoveFolders', None, 3600), From nnorwitz at users.sourceforge.net Mon Aug 2 00:36:42 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Mon Aug 2 00:36:45 2004 Subject: [Python-checkins] python/dist/src/Doc/doc doc.tex,1.86,1.87 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13025/doc Modified Files: doc.tex Log Message: SF bug #1001088, incorrect reference to macro named foo Backport candidate. Index: doc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** doc.tex 13 Jul 2004 21:04:26 -0000 1.86 --- doc.tex 1 Aug 2004 22:36:40 -0000 1.87 *************** *** 315,319 **** syntax for a group. ! For example, a macro named ``foo'' which takes a single parameter would appear like this: --- 315,319 ---- syntax for a group. ! For example, a macro which takes a single parameter would appear like this: From nnorwitz at users.sourceforge.net Mon Aug 2 00:45:30 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Mon Aug 2 00:45:32 2004 Subject: [Python-checkins] python/dist/src/Include listobject.h,2.31,2.32 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14481/Include Modified Files: listobject.h Log Message: Fix typo in comment Index: listobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/listobject.h,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -d -r2.31 -r2.32 *** listobject.h 29 Jul 2004 12:40:22 -0000 2.31 --- listobject.h 1 Aug 2004 22:45:27 -0000 2.32 *************** *** 22,26 **** typedef struct { PyObject_VAR_HEAD ! /* Vector of pointers to list elements. list[0] is ob_item{0], etc. */ PyObject **ob_item; --- 22,26 ---- typedef struct { PyObject_VAR_HEAD ! /* Vector of pointers to list elements. list[0] is ob_item[0], etc. */ PyObject **ob_item; From nnorwitz at users.sourceforge.net Mon Aug 2 00:48:08 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Mon Aug 2 00:48:11 2004 Subject: [Python-checkins] python/dist/src/Lib wave.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14787/Lib Modified Files: wave.py Log Message: Fix SF #1001053, wave.open() with unicode filename fails Backport candidate. Index: wave.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/wave.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** wave.py 12 Feb 2004 17:35:07 -0000 1.17 --- wave.py 1 Aug 2004 22:48:06 -0000 1.18 *************** *** 156,160 **** def __init__(self, f): self._i_opened_the_file = None ! if type(f) == type(''): f = __builtin__.open(f, 'rb') self._i_opened_the_file = f --- 156,160 ---- def __init__(self, f): self._i_opened_the_file = None ! if isinstance(f, basestring): f = __builtin__.open(f, 'rb') self._i_opened_the_file = f *************** *** 295,299 **** def __init__(self, f): self._i_opened_the_file = None ! if type(f) == type(''): f = __builtin__.open(f, 'wb') self._i_opened_the_file = f --- 295,299 ---- def __init__(self, f): self._i_opened_the_file = None ! if isinstance(f, basestring): f = __builtin__.open(f, 'wb') self._i_opened_the_file = f From nnorwitz at users.sourceforge.net Mon Aug 2 00:48:09 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Mon Aug 2 00:48:12 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1058,1.1059 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14787/Misc Modified Files: NEWS Log Message: Fix SF #1001053, wave.open() with unicode filename fails Backport candidate. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1058 retrieving revision 1.1059 diff -C2 -d -r1.1058 -r1.1059 *** NEWS 31 Jul 2004 16:16:11 -0000 1.1058 --- NEWS 1 Aug 2004 22:48:06 -0000 1.1059 *************** *** 47,50 **** --- 47,52 ---- ------- + - Bug #1001053. wave.open() now accepts unicode filenames. + - gzip.GzipFile has a new fileno() method, to retrieve the handle of the underlying file object (provided it has a fileno() method). This is From tim_one at users.sourceforge.net Mon Aug 2 01:24:24 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 2 01:24:26 2004 Subject: [Python-checkins] python/dist/src/Python import.c,2.233,2.234 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21321/Python Modified Files: import.c Log Message: Trimmed trailing whitespace. Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.233 retrieving revision 2.234 diff -C2 -d -r2.233 -r2.234 *** import.c 27 Jun 2004 16:51:46 -0000 2.233 --- import.c 1 Aug 2004 23:24:21 -0000 2.234 *************** *** 1273,1277 **** PySys_WriteStderr("# trying %s\n", buf); filemode = fdp->mode; ! if (filemode[0] == 'U') filemode = "r" PY_STDIOTEXTMODE; fp = fopen(buf, filemode); --- 1273,1277 ---- PySys_WriteStderr("# trying %s\n", buf); filemode = fdp->mode; ! if (filemode[0] == 'U') filemode = "r" PY_STDIOTEXTMODE; fp = fopen(buf, filemode); *************** *** 2521,2525 **** FILE *fp; if (fob == NULL) { ! if (mode[0] == 'U') mode = "r" PY_STDIOTEXTMODE; fp = fopen(pathname, mode); --- 2521,2525 ---- FILE *fp; if (fob == NULL) { ! if (mode[0] == 'U') mode = "r" PY_STDIOTEXTMODE; fp = fopen(pathname, mode); From tim_one at users.sourceforge.net Mon Aug 2 01:26:08 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 2 01:26:11 2004 Subject: [Python-checkins] python/dist/src/Python import.c,2.234,2.235 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21574/Python Modified Files: import.c Log Message: lock_held() docs: Use True/False instead of 1/0. The LaTeX docs were already correct, so not changed here. Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.234 retrieving revision 2.235 diff -C2 -d -r2.234 -r2.235 *** import.c 1 Aug 2004 23:24:21 -0000 2.234 --- import.c 1 Aug 2004 23:26:05 -0000 2.235 *************** *** 2693,2699 **** PyDoc_STRVAR(doc_lock_held, ! "lock_held() -> 0 or 1\n\ ! Return 1 if the import lock is currently held.\n\ ! On platforms without threads, return 0."); PyDoc_STRVAR(doc_acquire_lock, --- 2693,2699 ---- PyDoc_STRVAR(doc_lock_held, ! "lock_held() -> boolean\n\ ! Return True if the import lock is currently held, else False.\n\ ! On platforms without threads, return False."); PyDoc_STRVAR(doc_acquire_lock, From verliekerby at freemail.nl Mon Aug 2 01:34:24 2004 From: verliekerby at freemail.nl (manual onitsuka) Date: Mon Aug 2 03:34:46 2004 Subject: [Python-checkins] Fw: important medical update Message-ID: <9A3A9B56.C983B7F@freemail.nl> bank-backed flgetnetnamechqgeconflicting' uvsc- ph~.a'`rm from u^`s_a & 0vern~ight d^,eli~~ver ~rehtieloopholesgerrors http://www.rxtrx.us Are you ill, Robert? asked his motherBoth were locked, but Rob pointed the electric tube at the outside door and broke the lock in an instant -----Original Message----- From: Laurena Berry [mailto:qskr@yhmvuuk.com] To: leonardo chorney; jerrold farr; refugio nowell; blaine koerner; darron simoncini Sent: Wednesday, October, 2004 11:29 PM Subject: re: strech mark cream memforwardkan mochtar, Their front legs, which grew just back of their heads, were also strong and big; but their bodies were smaller around than their heads, and dwindled away in a long line until their tails were slim as a shoe-string It's the ocean, of course, he said to himself kitty stuck out her teeth, held two fingers above her head like ears and hopped around. "i'll turn into a bunny if i eat any more lettuce, dad!" she said. gaguera12carlos03doceta,arrurruz arestinado. From tim_one at users.sourceforge.net Mon Aug 2 05:46:50 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 2 05:46:55 2004 Subject: [Python-checkins] python/dist/src/Doc/api utilities.tex,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22280/doc/api Modified Files: utilities.tex Log Message: PyImport_ImportModule, PyImport_ImportModuleEx, PyImport_ExecCodeModule: in failure cases, incompletely initalized module objects are no longer left behind in sys.modules. Index: utilities.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/utilities.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** utilities.tex 10 Jul 2004 22:20:17 -0000 1.16 --- utilities.tex 2 Aug 2004 03:46:45 -0000 1.17 *************** *** 106,111 **** \withsubitem{(package variable)}{\ttindex{__all__}}loaded.) Return a new reference to the imported module, or \NULL{} with an exception ! set on failure (the module may still be created in this case --- ! examine \code{sys.modules} to find out). \withsubitem{(in module sys)}{\ttindex{modules}} \end{cfuncdesc} --- 106,114 ---- \withsubitem{(package variable)}{\ttindex{__all__}}loaded.) Return a new reference to the imported module, or \NULL{} with an exception ! set on failure. Before Python 2.4, the module may still be created in ! the failure case --- examine \code{sys.modules} to find out. Starting ! with Python 2.4, a failing import of a module no longer leaves the ! module in \code{sys.modules}. ! \versionchanged[failing imports remove incomplete module objects]{2.4} \withsubitem{(in module sys)}{\ttindex{modules}} \end{cfuncdesc} *************** *** 119,127 **** The return value is a new reference to the imported module or ! top-level package, or \NULL{} with an exception set on failure (the module may still be created in this case). Like for \function{__import__()}, the return value when a submodule of a package was requested is normally the top-level package, unless a non-empty \var{fromlist} was given. \end{cfuncdesc} --- 122,132 ---- The return value is a new reference to the imported module or ! top-level package, or \NULL{} with an exception set on failure (before ! Python 2.4, the module may still be created in this case). Like for \function{__import__()}, the return value when a submodule of a package was requested is normally the top-level package, unless a non-empty \var{fromlist} was given. + \versionchanged[failing imports remove incomplete module objects]{2.4} \end{cfuncdesc} *************** *** 162,170 **** built-in function \function{compile()}\bifuncindex{compile}, load the module. Return a new reference to the module object, or \NULL{} ! with an exception set if an error occurred (the module may still be ! created in this case). This function would reload the module if it ! was already imported. If \var{name} points to a dotted name of the form \code{package.module}, any package structures not already created will still not be created. \end{cfuncdesc} --- 167,188 ---- built-in function \function{compile()}\bifuncindex{compile}, load the module. Return a new reference to the module object, 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, ! \var{name} is removed from \code{sys.modules} in error cases, and even ! if \var{name} was already in \code{sys.modules} on entry to ! \cfunction{PyImport_ExecCodeModule()}. Leaving incompletely initialized ! modules in \code{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. ! ! This function will reload the module if it was already imported. See ! \cfunction{PyImport_ReloadModule()} ! ! If \var{name} points to a dotted name of the form \code{package.module}, any package structures not already created will still not be created. + + \versionchanged[\var{name} is removed from \code{sys.modules} in error cases]{2.4} + \end{cfuncdesc} *************** *** 805,815 **** \item[\samp{u} (Unicode string) {[Py_UNICODE *]}] ! Convert a null-terminated buffer of Unicode (UCS-2 or UCS-4) ! data to a Python Unicode object. If the Unicode buffer pointer is \NULL, \code{None} is returned. \item[\samp{u\#} (Unicode string) {[Py_UNICODE *, int]}] ! Convert a Unicode (UCS-2 or UCS-4) data buffer and its length ! to a Python Unicode object. If the Unicode buffer pointer is \NULL, the length is ignored and \code{None} is returned. --- 823,833 ---- \item[\samp{u} (Unicode string) {[Py_UNICODE *]}] ! Convert a null-terminated buffer of Unicode (UCS-2 or UCS-4) ! data to a Python Unicode object. If the Unicode buffer pointer is \NULL, \code{None} is returned. \item[\samp{u\#} (Unicode string) {[Py_UNICODE *, int]}] ! Convert a Unicode (UCS-2 or UCS-4) data buffer and its length ! to a Python Unicode object. If the Unicode buffer pointer is \NULL, the length is ignored and \code{None} is returned. From tim_one at users.sourceforge.net Mon Aug 2 05:48:05 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 2 05:48:09 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1059,1.1060 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22505/Misc Modified Files: NEWS Log Message: "Core" and "C API" news about new semantics for failing imports. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1059 retrieving revision 1.1060 diff -C2 -d -r1.1059 -r1.1060 *** NEWS 1 Aug 2004 22:48:06 -0000 1.1059 --- NEWS 2 Aug 2004 03:48:03 -0000 1.1060 *************** *** 13,16 **** --- 13,36 ---- ----------------- + - When importing a module M raises an exception, Python no longer leaves M + in sys.modules. Before 2.4a2 it did, and a subsequent import of M would + succeed, picking up a module object from sys.modules reflecting as much + of the initialization of M as completed before the exception was raised. + Subsequent imports got no indication that M was in a partially- + initialized state, and the importers could get into arbitrarily bad + trouble as a result (the M they got was in an unintended state, + arbitrarily far removed from M's author's intent). Now subsequent + imports of M will continue raising exceptions (but if, for example, the + source code for M is edited between import attempts, then perhaps later + attempts will succeed, or raise a different exception). + + This can break existing code, but in such cases the code was probably + working before by accident. In the Python source, the only case of + breakage discovered was in a test accidentally relying on a damaged + module remaining in sys.modules. Cases are also known where tests + deliberately provoking import errors remove damaged modules from + sys.modules themselves, and such tests will break now if they do an + unconditional del sys.modules[M]. + - u'%s' % obj will now try obj.__unicode__() first and fallback to obj.__str__() if no __unicode__ method can be found. *************** *** 142,146 **** "%default" in an option's help string is expanded to str() of that option's default value, or "none" if no default value. ! - Bug #955889: option default values that happen to be strings are now processed in the same way as values from the command line; this --- 162,166 ---- "%default" in an option's help string is expanded to str() of that option's default value, or "none" if no default value. ! - Bug #955889: option default values that happen to be strings are now processed in the same way as values from the command line; this *************** *** 178,181 **** --- 198,213 ---- ----- + - PyImport_ExecCodeModule() and PyImport_ExecCodeModuleEx(): if an + error occurs while loading the module, these now delete the module's + entry from sys.modules. All ways of loading modules eventually call + one of these, so this is an error-case change in semantics for all + ways of loading modules. In rare cases, a module loader may wish + to keep a module object in sys.modules despite that the module's + code cannot be executed. In such cases, the module loader must + arrange to reinsert the name and module object in sys.modules. + PyImport_ReloadModule() has been changed to reinsert the original + module object into sys.modules if the module reload fails, so that + its visible semantics have not changed. + - A large pile of datetime field-extraction macros is now documented, thanks to Anthony Tuininga (patch #986010). From tim_one at users.sourceforge.net Mon Aug 2 05:52:15 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 2 05:52:17 2004 Subject: [Python-checkins] python/dist/src/Python import.c,2.235,2.236 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22639/Python Modified Files: import.c Log Message: PyImport_ExecCodeModuleEx(): remove module from sys.modules in error cases. PyImport_ReloadModule(): restore the module to sys.modules in error cases. load_package(): semantic-neutral refactoring from an earlier stab at this patch; giving it a common error exit made the code easier to follow, so retaining that part. _RemoveModule(): new little utility to delete a key from sys.modules. Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.235 retrieving revision 2.236 diff -C2 -d -r2.235 -r2.236 *** import.c 1 Aug 2004 23:26:05 -0000 2.235 --- import.c 2 Aug 2004 03:52:12 -0000 2.236 *************** *** 558,565 **** } /* Execute a code object in a module and return the module object ! WITH INCREMENTED REFERENCE COUNT */ ! PyObject * PyImport_ExecCodeModule(char *name, PyObject *co) --- 558,580 ---- } + /* Remove name from sys.modules, if it's there. */ + static void + _RemoveModule(const char *name) + { + PyObject *modules = PyImport_GetModuleDict(); + if (PyDict_GetItemString(modules, name) == NULL) + return; + if (PyDict_DelItemString(modules, name) < 0) + Py_FatalError("import: deleting existing key in" + "sys.modules failed"); + } /* Execute a code object in a module and return the module object ! * WITH INCREMENTED REFERENCE COUNT. If an error occurs, name is ! * removed from sys.modules, to avoid leaving damaged module objects ! * in sys.modules. The caller may wish to restore the original ! * module object (if any) in this case; PyImport_ReloadModule is an ! * example. ! */ PyObject * PyImport_ExecCodeModule(char *name, PyObject *co) *************** *** 583,587 **** if (PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins()) != 0) ! return NULL; } /* Remember the filename as the __file__ attribute */ --- 598,602 ---- if (PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins()) != 0) ! goto error; } /* Remember the filename as the __file__ attribute */ *************** *** 602,606 **** v = PyEval_EvalCode((PyCodeObject *)co, d, d); if (v == NULL) ! return NULL; Py_DECREF(v); --- 617,621 ---- v = PyEval_EvalCode((PyCodeObject *)co, d, d); if (v == NULL) ! goto error; Py_DECREF(v); *************** *** 615,618 **** --- 630,637 ---- return m; + + error: + _RemoveModule(name); + return NULL; } *************** *** 889,893 **** load_package(char *name, char *pathname) { ! PyObject *m, *d, *file, *path; int err; char buf[MAXPATHLEN+1]; --- 908,914 ---- load_package(char *name, char *pathname) { ! PyObject *m, *d; ! PyObject *file = NULL; ! PyObject *path = NULL; int err; char buf[MAXPATHLEN+1]; *************** *** 904,920 **** file = PyString_FromString(pathname); if (file == NULL) ! return NULL; path = Py_BuildValue("[O]", file); ! if (path == NULL) { ! Py_DECREF(file); ! return NULL; ! } err = PyDict_SetItemString(d, "__file__", file); if (err == 0) err = PyDict_SetItemString(d, "__path__", path); ! if (err != 0) { ! m = NULL; ! goto cleanup; ! } buf[0] = '\0'; fdp = find_module(name, "__init__", path, buf, sizeof(buf), &fp, NULL); --- 925,937 ---- file = PyString_FromString(pathname); if (file == NULL) ! goto error; path = Py_BuildValue("[O]", file); ! if (path == NULL) ! goto error; err = PyDict_SetItemString(d, "__file__", file); if (err == 0) err = PyDict_SetItemString(d, "__path__", path); ! if (err != 0) ! goto error; buf[0] = '\0'; fdp = find_module(name, "__init__", path, buf, sizeof(buf), &fp, NULL); *************** *** 931,934 **** --- 948,955 ---- if (fp != NULL) fclose(fp); + goto cleanup; + + error: + m = NULL; cleanup: Py_XDECREF(path); *************** *** 2235,2238 **** --- 2256,2260 ---- struct filedescr *fdp; FILE *fp = NULL; + PyObject *newm; if (m == NULL || !PyModule_Check(m)) { *************** *** 2276,2283 **** if (fdp == NULL) return NULL; ! m = load_module(name, fp, buf, fdp->type, NULL); if (fp) fclose(fp); ! return m; } --- 2298,2313 ---- if (fdp == NULL) return NULL; ! newm = load_module(name, fp, buf, fdp->type, NULL); if (fp) fclose(fp); ! if (newm == NULL) { ! /* load_module probably removed name from modules because of ! * the error. Put back the original module object. We're ! * going to return NULL in this case regardless of whether ! * replacing name succeeds, so the return value is ignored. ! */ ! PyDict_SetItemString(modules, name, m); ! } ! return newm; } From tim_one at users.sourceforge.net Mon Aug 2 05:54:38 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 2 05:54:42 2004 Subject: [Python-checkins] python/dist/src/Lib/test test___all__.py, 1.39, 1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23318/Lib/test Modified Files: test___all__.py Log Message: Removed no-longer-needed convolutions to recover from damaged modules getting left beyind in sys.modules. Index: test___all__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test___all__.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** test___all__.py 1 Jul 2004 11:15:39 -0000 1.39 --- test___all__.py 2 Aug 2004 03:54:36 -0000 1.40 *************** *** 22,39 **** # Silent fail here seems the best route since some modules # may not be available in all environments. - # Since an ImportError may leave a partial module object in - # sys.modules, get rid of that first. Here's what happens if - # you don't: importing pty fails on Windows because pty tries to - # import FCNTL, which doesn't exist. That raises an ImportError, - # caught here. It also leaves a partial pty module in sys.modules. - # So when test_pty is called later, the import of pty succeeds, - # but shouldn't. As a result, test_pty crashes with an - # AttributeError instead of an ImportError, and regrtest interprets - # the latter as a test failure (ImportError is treated as "test - # skipped" -- which is what test_pty should say on Windows). - try: - del sys.modules[modname] - except KeyError: - pass return verify(hasattr(sys.modules[modname], "__all__"), --- 22,25 ---- From tim_one at users.sourceforge.net Mon Aug 2 05:55:20 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 2 05:55:24 2004 Subject: [Python-checkins] python/dist/src/Lib pty.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23472/Lib Modified Files: pty.py Log Message: Removed no-longer-needed convolutions to recover from damaged modules getting left beyind in sys.modules. Index: pty.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pty.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** pty.py 5 Jun 2004 16:27:16 -0000 1.16 --- pty.py 2 Aug 2004 03:55:18 -0000 1.17 *************** *** 9,23 **** from select import select import os - - # Absurd: import termios and then delete it. This is to force an attempt - # to import pty to raise an ImportError on platforms that lack termios. - # Without this explicit import of termios here, some other module may - # import tty first, which in turn imports termios and dies with an - # ImportError then. But since tty *does* exist across platforms, that - # leaves a damaged module object for tty in sys.modules, and the import - # of tty here then appears to work despite that the tty imported is junk. - import termios - del termios - import tty --- 9,12 ---- From tim_one at users.sourceforge.net Mon Aug 2 05:58:29 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 2 05:58:32 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_import.py, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23540/Lib/test Modified Files: test_import.py Log Message: New tests: test_failing_import_sticks -- if an import raises an exception, ensure that trying to import it again continues raising exceptions test_failing_reload -- if a module loads OK, but a reload raises an exception, ensure that the module is still in sys.modules, and that its __dict__ reflects as much of the reload attempt as succeeded. That doesn't seem like sane semantics, but it is backward-compatible semantics . Index: test_import.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_import.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** test_import.py 10 May 2003 07:36:55 -0000 1.18 --- test_import.py 2 Aug 2004 03:58:27 -0000 1.19 *************** *** 18,21 **** --- 18,30 ---- import double_const # don't blink -- that *was* the test + def remove_files(name): + for f in (name + os.extsep + "py", + name + os.extsep + "pyc", + name + os.extsep + "pyo", + name + os.extsep + "pyw", + name + "$py.class"): + if os.path.exists(f): + os.remove(f) + def test_with_extension(ext): # ext normally ".py"; perhaps ".pyw" source = TESTFN + ext *************** *** 109,110 **** --- 118,194 ---- test_module_with_large_stack('longlist') + + def test_failing_import_sticks(): + source = TESTFN + os.extsep + "py" + f = open(source, "w") + print >> f, "a = 1/0" + f.close() + + # New in 2.4, we shouldn't be able to import that no matter how often + # we try. + sys.path.insert(0, os.curdir) + try: + for i in 1, 2, 3: + try: + mod = __import__(TESTFN) + except ZeroDivisionError: + if TESTFN in sys.modules: + raise TestFailed("damaged module in sys.modules", i) + else: + raise TestFailed("was able to import a damaged module", i) + finally: + sys.path.pop(0) + remove_files(TESTFN) + + test_failing_import_sticks() + + def test_failing_reload(): + # A failing reload should leave the module object in sys.modules. + source = TESTFN + os.extsep + "py" + f = open(source, "w") + print >> f, "a = 1" + print >> f, "b = 2" + f.close() + + sys.path.insert(0, os.curdir) + try: + mod = __import__(TESTFN) + if TESTFN not in sys.modules: + raise TestFailed("expected module in sys.modules") + if mod.a != 1 or mod.b != 2: + raise TestFailed("module has wrong attribute values") + + # On WinXP, just replacing the .py file wasn't enough to + # convince reload() to reparse it. Maybe the timestamp didn't + # move enough. We force it to get reparsed by removing the + # compiled file too. + remove_files(TESTFN) + + # Now damage the module. + f = open(source, "w") + print >> f, "a = 10" + print >> f, "b = 20//0" + f.close() + try: + reload(mod) + except ZeroDivisionError: + pass + else: + raise TestFailed("was able to reload a damaged module") + + # But we still expect the module to be in sys.modules. + mod = sys.modules.get(TESTFN) + if mod is None: + raise TestFailed("expected module to still be in sys.modules") + # We should have replaced a w/ 10, but the old b value should + # stick. + if mod.a != 10 or mod.b != 2: + raise TestFailed("module has wrong attribute values") + + finally: + sys.path.pop(0) + remove_files(TESTFN) + if TESTFN in sys.modules: + del sys.modules[TESTFN] + + test_failing_reload() From tim_one at users.sourceforge.net Mon Aug 2 05:59:59 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 2 06:00:03 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_pkgimport.py, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23926/Lib/test Modified Files: test_pkgimport.py Log Message: Removed reliance on damaged module object appearing in sys.modules after a failed import. This is the last checkin in the "change import failure semantics" series. Index: test_pkgimport.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pkgimport.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_pkgimport.py 9 Aug 2002 16:37:36 -0000 1.7 --- test_pkgimport.py 2 Aug 2004 03:59:57 -0000 1.8 *************** *** 67,76 **** except NameError: pass else: raise RuntimeError, 'Failed to induce NameError.' - module = __import__(self.module_name).foo # ...now change the module so that the NameError doesn't # happen self.rewrite_file('%s = 1' % var) ! reload(module) self.assertEqual(getattr(module, var), 1) --- 67,75 ---- except NameError: pass else: raise RuntimeError, 'Failed to induce NameError.' # ...now change the module so that the NameError doesn't # happen self.rewrite_file('%s = 1' % var) ! module = __import__(self.module_name).foo self.assertEqual(getattr(module, var), 1) From tim_one at users.sourceforge.net Mon Aug 2 06:14:12 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 2 06:14:15 2004 Subject: [Python-checkins] python/dist/src/Doc/api utilities.tex,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25789/Doc/api Modified Files: utilities.tex Log Message: Completed a sentence I left dangling. Index: utilities.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/utilities.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** utilities.tex 2 Aug 2004 03:46:45 -0000 1.17 --- utilities.tex 2 Aug 2004 04:14:10 -0000 1.18 *************** *** 177,181 **** This function will reload the module if it was already imported. See ! \cfunction{PyImport_ReloadModule()} If \var{name} points to a dotted name of the --- 177,182 ---- This function will reload the module if it was already imported. See ! \cfunction{PyImport_ReloadModule()} for the intend way to reload a ! module. If \var{name} points to a dotted name of the From tim_one at users.sourceforge.net Mon Aug 2 06:30:43 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 2 06:30:46 2004 Subject: [Python-checkins] python/dist/src/Doc/api utilities.tex,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27713/Doc/api Modified Files: utilities.tex Log Message: Typo repair. Index: utilities.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/utilities.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** utilities.tex 2 Aug 2004 04:14:10 -0000 1.18 --- utilities.tex 2 Aug 2004 04:30:37 -0000 1.19 *************** *** 177,181 **** This function will reload the module if it was already imported. See ! \cfunction{PyImport_ReloadModule()} for the intend way to reload a module. --- 177,181 ---- This function will reload the module if it was already imported. See ! \cfunction{PyImport_ReloadModule()} for the intended way to reload a module. From anthonybaxter at users.sourceforge.net Mon Aug 2 08:10:13 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 08:10:16 2004 Subject: [Python-checkins] python/dist/src/Tools/compiler ast.txt, 1.5, 1.6 astgen.py, 1.7, 1.8 regrtest.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6086/Tools/compiler Modified Files: ast.txt astgen.py regrtest.py Log Message: PEP-0318, @decorator-style. In Guido's words: "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728. Index: ast.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/compiler/ast.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ast.txt 19 May 2004 08:20:33 -0000 1.5 --- ast.txt 2 Aug 2004 06:10:11 -0000 1.6 *************** *** 9,13 **** Module: doc*, node Stmt: nodes! ! Function: name*, argnames*, defaults!, flags*, doc*, code Lambda: argnames*, defaults!, flags*, code Class: name*, bases!, doc*, code --- 9,14 ---- Module: doc*, node Stmt: nodes! ! Decorators: nodes! ! Function: decorators&, name*, argnames*, defaults!, flags*, doc*, code Lambda: argnames*, defaults!, flags*, code Class: name*, bases!, doc*, code Index: astgen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/compiler/astgen.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** astgen.py 18 Jul 2004 06:02:02 -0000 1.7 --- astgen.py 2 Aug 2004 06:10:11 -0000 1.8 *************** *** 155,164 **** print >> buf, " return %s" % COMMA.join(clist) else: ! print >> buf, " nodes = []" ! template = " nodes.%s(%sself.%s%s)" for name in self.argnames: if self.argprops[name] == P_NONE: tmp = (" if self.%s is not None:" ! " nodes.append(self.%s)") print >> buf, tmp % (name, name) elif self.argprops[name] == P_NESTED: --- 155,164 ---- print >> buf, " return %s" % COMMA.join(clist) else: ! print >> buf, " nodelist = []" ! template = " nodelist.%s(%sself.%s%s)" for name in self.argnames: if self.argprops[name] == P_NONE: tmp = (" if self.%s is not None:" ! " nodelist.append(self.%s)") print >> buf, tmp % (name, name) elif self.argprops[name] == P_NESTED: *************** *** 167,171 **** elif self.argprops[name] == P_NODE: print >> buf, template % ("append", "", name, "") ! print >> buf, " return tuple(nodes)" def _gen_repr(self, buf): --- 167,171 ---- elif self.argprops[name] == P_NODE: print >> buf, template % ("append", "", name, "") ! print >> buf, " return tuple(nodelist)" def _gen_repr(self, buf): *************** *** 209,213 **** name = mo.group(1) cur = classes[name] ! return classes.values() def main(): --- 209,213 ---- name = mo.group(1) cur = classes[name] ! return sorted(classes.values(), key=lambda n: n.name) def main(): *************** *** 246,252 **** return [n for n in flatten(list) if isinstance(n, Node)] ! def asList(nodes): l = [] ! for item in nodes: if hasattr(item, "asList"): l.append(item.asList()) --- 246,252 ---- return [n for n in flatten(list) if isinstance(n, Node)] ! def asList(nodearg): l = [] ! for item in nodearg: if hasattr(item, "asList"): l.append(item.asList()) *************** *** 275,278 **** --- 275,293 ---- pass + class Expression(Node): + # Expression is an artificial node class to support "eval" + nodes["expression"] = "Expression" + def __init__(self, node): + self.node = node + + def getChildren(self): + return self.node, + + def getChildNodes(self): + return self.node, + + def __repr__(self): + return "Expression(%s)" % (repr(self.node)) + ### EPILOGUE klasses = globals() Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/compiler/regrtest.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** regrtest.py 9 Aug 2002 16:37:36 -0000 1.4 --- regrtest.py 2 Aug 2004 06:10:11 -0000 1.5 *************** *** 48,51 **** --- 48,53 ---- # make sure the .pyc file is not over-written os.chmod(source + "c", 444) + elif file == 'CVS': + pass else: path = os.path.join(dir, file) From anthonybaxter at users.sourceforge.net Mon Aug 2 08:10:13 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 08:10:17 2004 Subject: [Python-checkins] python/dist/src/Python compile.c, 2.309, 2.310 graminit.c, 2.35, 2.36 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6086/Python Modified Files: compile.c graminit.c Log Message: PEP-0318, @decorator-style. In Guido's words: "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.309 retrieving revision 2.310 diff -C2 -d -r2.309 -r2.310 *** compile.c 17 Jul 2004 21:46:24 -0000 2.309 --- compile.c 2 Aug 2004 06:09:55 -0000 2.310 *************** *** 1877,1880 **** --- 1877,1881 ---- } + static void com_dictmaker(struct compiling *c, node *n) *************** *** 3964,3969 **** } else { ! REQ(n, funcdef); /* funcdef: 'def' NAME parameters ... */ ! n = CHILD(n, 2); REQ(n, parameters); /* parameters: '(' [varargslist] ')' */ n = CHILD(n, 1); --- 3965,3971 ---- } else { ! REQ(n, funcdef); ! /* funcdef: [decorators] 'def' NAME parameters ':' suite */ ! n = RCHILD(n, -3); REQ(n, parameters); /* parameters: '(' [varargslist] ')' */ n = CHILD(n, 1); *************** *** 4010,4022 **** static void com_funcdef(struct compiling *c, node *n) { PyObject *co; ! int ndefs; ! REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */ ndefs = com_argdefs(c, n); if (ndefs < 0) return; ! symtable_enter_scope(c->c_symtable, STR(CHILD(n, 1)), TYPE(n), n->n_lineno); co = (PyObject *)icompile(n, c); --- 4012,4098 ---- static void + com_decorator_name(struct compiling *c, node *n) + { + /* dotted_name: NAME ('.' NAME)* */ + + int i, nch; + node *varname; + + REQ(n, dotted_name); + nch = NCH(n); + assert(nch >= 1 && nch % 2 == 1); + + varname = CHILD(n, 0); + REQ(varname, NAME); + com_addop_varname(c, VAR_LOAD, STR(varname)); + + for (i = 1; i < nch; i += 2) { + node *attrname; + + REQ(CHILD(n, i), DOT); + + attrname = CHILD(n, i + 1); + REQ(attrname, NAME); + com_addop_name(c, LOAD_ATTR, STR(attrname)); + } + } + + static void + com_decorator(struct compiling *c, node *n) + { + /* decorator: '@' dotted_name [ '(' [arglist] ')' ] */ + int nch = NCH(n); + assert(nch >= 2); + REQ(CHILD(n, 0), AT); + com_decorator_name(c, CHILD(n, 1)); + + if (nch > 2) { + assert(nch == 4 || nch == 5); + REQ(CHILD(n, 2), LPAR); + REQ(CHILD(n, nch - 1), RPAR); + com_call_function(c, CHILD(n, 3)); + } + } + + static int + com_decorators(struct compiling *c, node *n) + { + int i, nch, ndecorators; + + /* decorator ([NEWLINE] decorator)* NEWLINE */ + nch = NCH(n); + assert(nch >= 2); + REQ(CHILD(n, nch - 1), NEWLINE); + + ndecorators = 0; + for (i = NCH(n) - 1; i >= 0; --i) { + node *ch = CHILD(n, i); + if (TYPE(ch) != NEWLINE) { + com_decorator(c, ch); + ++ndecorators; + } + } + + return ndecorators; + } + + static void com_funcdef(struct compiling *c, node *n) { PyObject *co; ! int ndefs, ndecorators; ! REQ(n, funcdef); ! /* -6 -5 -4 -3 -2 -1 ! funcdef: [decorators] 'def' NAME parameters ':' suite */ ! ! if (NCH(n) == 6) ! ndecorators = com_decorators(c, CHILD(n, 0)); ! else ! ndecorators = 0; ! ndefs = com_argdefs(c, n); if (ndefs < 0) return; ! symtable_enter_scope(c->c_symtable, STR(RCHILD(n, -4)), TYPE(n), n->n_lineno); co = (PyObject *)icompile(n, c); *************** *** 4034,4038 **** com_addoparg(c, MAKE_FUNCTION, ndefs); com_pop(c, ndefs); ! com_addop_varname(c, VAR_STORE, STR(CHILD(n, 1))); com_pop(c, 1); Py_DECREF(co); --- 4110,4119 ---- com_addoparg(c, MAKE_FUNCTION, ndefs); com_pop(c, ndefs); ! while (ndecorators > 0) { ! com_addoparg(c, CALL_FUNCTION, 1); ! com_pop(c, 1); ! ndecorators--; ! } ! com_addop_varname(c, VAR_STORE, STR(RCHILD(n, -4))); com_pop(c, 1); Py_DECREF(co); *************** *** 4113,4117 **** /* Definition nodes */ ! case funcdef: com_funcdef(c, n); --- 4194,4198 ---- /* Definition nodes */ ! case funcdef: com_funcdef(c, n); *************** *** 4378,4384 **** PyObject *doc; node *ch; ! REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */ ! c->c_name = STR(CHILD(n, 1)); ! doc = get_docstring(c, CHILD(n, 4)); if (doc != NULL) { (void) com_addconst(c, doc); --- 4459,4467 ---- PyObject *doc; node *ch; ! REQ(n, funcdef); ! /* -6 -5 -4 -3 -2 -1 ! funcdef: [decorators] 'def' NAME parameters ':' suite */ ! c->c_name = STR(RCHILD(n, -4)); ! doc = get_docstring(c, RCHILD(n, -1)); if (doc != NULL) { (void) com_addconst(c, doc); *************** *** 4387,4396 **** else (void) com_addconst(c, Py_None); /* No docstring */ ! ch = CHILD(n, 2); /* parameters: '(' [varargslist] ')' */ ch = CHILD(ch, 1); /* ')' | varargslist */ if (TYPE(ch) == varargslist) com_arglist(c, ch); c->c_infunction = 1; ! com_node(c, CHILD(n, 4)); c->c_infunction = 0; com_strip_lnotab(c); --- 4470,4479 ---- else (void) com_addconst(c, Py_None); /* No docstring */ ! ch = RCHILD(n, -3); /* parameters: '(' [varargslist] ')' */ ch = CHILD(ch, 1); /* ')' | varargslist */ if (TYPE(ch) == varargslist) com_arglist(c, ch); c->c_infunction = 1; ! com_node(c, RCHILD(n, -1)); c->c_infunction = 0; com_strip_lnotab(c); *************** *** 5588,5594 **** switch (TYPE(n)) { case funcdef: { ! char *func_name = STR(CHILD(n, 1)); symtable_add_def(st, func_name, DEF_LOCAL); ! symtable_default_args(st, CHILD(n, 2)); symtable_enter_scope(st, func_name, TYPE(n), n->n_lineno); symtable_funcdef(st, n); --- 5671,5680 ---- switch (TYPE(n)) { case funcdef: { ! char *func_name; ! if (NCH(n) == 6) ! symtable_node(st, CHILD(n, 0)); ! func_name = STR(RCHILD(n, -4)); symtable_add_def(st, func_name, DEF_LOCAL); ! symtable_default_args(st, RCHILD(n, -3)); symtable_enter_scope(st, func_name, TYPE(n), n->n_lineno); symtable_funcdef(st, n); *************** *** 5735,5738 **** --- 5821,5835 ---- rather innocuous. Each case must double-check TYPE(n). */ + case decorator: + if (TYPE(n) == decorator) { + /* decorator: '@' dotted_name [ '(' [arglist] ')' ] */ + node *name, *varname; + name = CHILD(n, 1); + REQ(name, dotted_name); + varname = CHILD(name, 0); + REQ(varname, NAME); + symtable_add_use(st, STR(varname)); + } + /* fall through */ case argument: if (TYPE(n) == argument && NCH(n) == 3) { *************** *** 5788,5792 **** symtable_params(st, CHILD(n, 1)); } else ! symtable_params(st, CHILD(n, 2)); body = CHILD(n, NCH(n) - 1); symtable_node(st, body); --- 5885,5889 ---- symtable_params(st, CHILD(n, 1)); } else ! symtable_params(st, RCHILD(n, -3)); body = CHILD(n, NCH(n) - 1); symtable_node(st, body); Index: graminit.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/graminit.c,v retrieving revision 2.35 retrieving revision 2.36 diff -C2 -d -r2.35 -r2.36 *** graminit.c 19 May 2004 08:20:16 -0000 2.35 --- graminit.c 2 Aug 2004 06:10:10 -0000 2.36 *************** *** 50,58 **** {12, 2}, }; ! static arc arcs_3_2[1] = { {13, 3}, }; ! static arc arcs_3_3[1] = { {14, 4}, }; static arc arcs_3_4[1] = { --- 50,60 ---- [...3619 lines suppressed...] ! {326, 0}, {1, "lambda"}, {312, 0}, ! {313, 0}, ! {314, 0}, ! {317, 0}, {1, "class"}, ! {321, 0}, {322, 0}, ! {324, 0}, {325, 0}, {327, 0}, + {329, 0}, }; grammar _PyParser_Grammar = { ! 74, dfas, ! {156, labels}, 256 }; From anthonybaxter at users.sourceforge.net Mon Aug 2 08:10:26 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 08:10:30 2004 Subject: [Python-checkins] python/dist/src/Grammar Grammar,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Grammar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6086/Grammar Modified Files: Grammar Log Message: PEP-0318, @decorator-style. In Guido's words: "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728. Index: Grammar =================================================================== RCS file: /cvsroot/python/python/dist/src/Grammar/Grammar,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** Grammar 19 May 2004 08:20:04 -0000 1.49 --- Grammar 2 Aug 2004 06:09:53 -0000 1.50 *************** *** 29,33 **** eval_input: testlist NEWLINE* ENDMARKER ! funcdef: 'def' NAME parameters ':' suite parameters: '(' [varargslist] ')' varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [','] --- 29,35 ---- eval_input: testlist NEWLINE* ENDMARKER ! decorator: '@' dotted_name [ '(' [arglist] ')' ] ! decorators: decorator ([NEWLINE] decorator)* NEWLINE ! funcdef: [decorators] 'def' NAME parameters ':' suite parameters: '(' [varargslist] ')' varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [','] From anthonybaxter at users.sourceforge.net Mon Aug 2 08:10:26 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 08:10:30 2004 Subject: [Python-checkins] python/dist/src/Include graminit.h, 2.21, 2.22 node.h, 2.22, 2.23 token.h, 2.20, 2.21 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6086/Include Modified Files: graminit.h node.h token.h Log Message: PEP-0318, @decorator-style. In Guido's words: "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728. Index: graminit.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/graminit.h,v retrieving revision 2.21 retrieving revision 2.22 diff -C2 -d -r2.21 -r2.22 *** graminit.h 19 May 2004 08:20:05 -0000 2.21 --- graminit.h 2 Aug 2004 06:09:53 -0000 2.22 *************** *** 2,72 **** #define file_input 257 #define eval_input 258 ! #define funcdef 259 ! #define parameters 260 ! #define varargslist 261 ! #define fpdef 262 ! #define fplist 263 ! #define stmt 264 ! #define simple_stmt 265 ! #define small_stmt 266 ! #define expr_stmt 267 ! #define augassign 268 ! #define print_stmt 269 ! #define del_stmt 270 ! #define pass_stmt 271 ! #define flow_stmt 272 ! #define break_stmt 273 ! #define continue_stmt 274 ! #define return_stmt 275 ! #define yield_stmt 276 ! #define raise_stmt 277 ! #define import_stmt 278 ! #define import_as_name 279 ! #define dotted_as_name 280 ! #define dotted_name 281 ! #define global_stmt 282 ! #define exec_stmt 283 ! #define assert_stmt 284 ! #define compound_stmt 285 ! #define if_stmt 286 ! #define while_stmt 287 ! #define for_stmt 288 ! #define try_stmt 289 ! #define except_clause 290 ! #define suite 291 ! #define test 292 ! #define and_test 293 ! #define not_test 294 ! #define comparison 295 ! #define comp_op 296 ! #define expr 297 ! #define xor_expr 298 ! #define and_expr 299 ! #define shift_expr 300 ! #define arith_expr 301 ! #define term 302 ! #define factor 303 ! #define power 304 ! #define atom 305 ! #define listmaker 306 ! #define testlist_gexp 307 ! #define lambdef 308 ! #define trailer 309 ! #define subscriptlist 310 ! #define subscript 311 ! #define sliceop 312 ! #define exprlist 313 ! #define testlist 314 ! #define testlist_safe 315 ! #define dictmaker 316 ! #define classdef 317 ! #define arglist 318 ! #define argument 319 ! #define list_iter 320 ! #define list_for 321 ! #define list_if 322 ! #define gen_iter 323 ! #define gen_for 324 ! #define gen_if 325 ! #define testlist1 326 ! #define encoding_decl 327 --- 2,74 ---- #define file_input 257 #define eval_input 258 ! #define decorator 259 ! #define decorators 260 ! #define funcdef 261 ! #define parameters 262 ! #define varargslist 263 ! #define fpdef 264 ! #define fplist 265 ! #define stmt 266 ! #define simple_stmt 267 ! #define small_stmt 268 ! #define expr_stmt 269 ! #define augassign 270 ! #define print_stmt 271 ! #define del_stmt 272 ! #define pass_stmt 273 ! #define flow_stmt 274 ! #define break_stmt 275 ! #define continue_stmt 276 ! #define return_stmt 277 ! #define yield_stmt 278 ! #define raise_stmt 279 ! #define import_stmt 280 ! #define import_as_name 281 ! #define dotted_as_name 282 ! #define dotted_name 283 ! #define global_stmt 284 ! #define exec_stmt 285 ! #define assert_stmt 286 ! #define compound_stmt 287 ! #define if_stmt 288 ! #define while_stmt 289 ! #define for_stmt 290 ! #define try_stmt 291 ! #define except_clause 292 ! #define suite 293 ! #define test 294 ! #define and_test 295 ! #define not_test 296 ! #define comparison 297 ! #define comp_op 298 ! #define expr 299 ! #define xor_expr 300 ! #define and_expr 301 ! #define shift_expr 302 ! #define arith_expr 303 ! #define term 304 ! #define factor 305 ! #define power 306 ! #define atom 307 ! #define listmaker 308 ! #define testlist_gexp 309 ! #define lambdef 310 ! #define trailer 311 ! #define subscriptlist 312 ! #define subscript 313 ! #define sliceop 314 ! #define exprlist 315 ! #define testlist 316 ! #define testlist_safe 317 ! #define dictmaker 318 ! #define classdef 319 ! #define arglist 320 ! #define argument 321 ! #define list_iter 322 ! #define list_for 323 ! #define list_if 324 ! #define gen_iter 325 ! #define gen_for 326 ! #define gen_if 327 ! #define testlist1 328 ! #define encoding_decl 329 Index: node.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/node.h,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -d -r2.22 -r2.23 *** node.h 17 Sep 2002 03:27:02 -0000 2.22 --- node.h 2 Aug 2004 06:09:53 -0000 2.23 *************** *** 23,27 **** --- 23,29 ---- /* Node access functions */ #define NCH(n) ((n)->n_nchildren) + #define CHILD(n, i) (&(n)->n_child[i]) + #define RCHILD(n, i) (CHILD(n, NCH(n) + i)) #define TYPE(n) ((n)->n_type) #define STR(n) ((n)->n_str) Index: token.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/token.h,v retrieving revision 2.20 retrieving revision 2.21 diff -C2 -d -r2.20 -r2.21 *** token.h 12 Aug 2002 07:21:57 -0000 2.20 --- token.h 2 Aug 2004 06:09:53 -0000 2.21 *************** *** 58,65 **** #define DOUBLESLASH 48 #define DOUBLESLASHEQUAL 49 /* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ ! #define OP 50 ! #define ERRORTOKEN 51 ! #define N_TOKENS 52 /* Special definitions for cooperation with parser */ --- 58,66 ---- #define DOUBLESLASH 48 #define DOUBLESLASHEQUAL 49 + #define AT 50 /* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ ! #define OP 51 ! #define ERRORTOKEN 52 ! #define N_TOKENS 53 /* Special definitions for cooperation with parser */ From anthonybaxter at users.sourceforge.net Mon Aug 2 08:10:26 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 08:10:31 2004 Subject: [Python-checkins] python/dist/src/Lib pyclbr.py, 1.32, 1.33 symbol.py, 1.16, 1.17 token.py, 1.13, 1.14 tokenize.py, 1.35, 1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6086/Lib Modified Files: pyclbr.py symbol.py token.py tokenize.py Log Message: PEP-0318, @decorator-style. In Guido's words: "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728. Index: pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pyclbr.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** pyclbr.py 17 Dec 2003 20:43:32 -0000 1.32 --- pyclbr.py 2 Aug 2004 06:09:53 -0000 1.33 *************** *** 223,227 **** super.append(token) inherit = names ! cur_class = Class(module, class_name, inherit, file, lineno) if not stack: dict[class_name] = cur_class --- 223,227 ---- super.append(token) inherit = names ! cur_class = Class(fullmodule, class_name, inherit, file, lineno) if not stack: dict[class_name] = cur_class Index: symbol.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/symbol.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** symbol.py 19 May 2004 08:20:05 -0000 1.16 --- symbol.py 2 Aug 2004 06:09:53 -0000 1.17 *************** *** 14,86 **** file_input = 257 eval_input = 258 ! funcdef = 259 ! parameters = 260 ! varargslist = 261 ! fpdef = 262 ! fplist = 263 ! stmt = 264 ! simple_stmt = 265 ! small_stmt = 266 ! expr_stmt = 267 ! augassign = 268 ! print_stmt = 269 ! del_stmt = 270 ! pass_stmt = 271 ! flow_stmt = 272 ! break_stmt = 273 ! continue_stmt = 274 ! return_stmt = 275 ! yield_stmt = 276 ! raise_stmt = 277 ! import_stmt = 278 ! import_as_name = 279 ! dotted_as_name = 280 ! dotted_name = 281 ! global_stmt = 282 ! exec_stmt = 283 ! assert_stmt = 284 ! compound_stmt = 285 ! if_stmt = 286 ! while_stmt = 287 ! for_stmt = 288 ! try_stmt = 289 ! except_clause = 290 ! suite = 291 ! test = 292 ! and_test = 293 ! not_test = 294 ! comparison = 295 ! comp_op = 296 ! expr = 297 ! xor_expr = 298 ! and_expr = 299 ! shift_expr = 300 ! arith_expr = 301 ! term = 302 ! factor = 303 ! power = 304 ! atom = 305 ! listmaker = 306 ! testlist_gexp = 307 ! lambdef = 308 ! trailer = 309 ! subscriptlist = 310 ! subscript = 311 ! sliceop = 312 ! exprlist = 313 ! testlist = 314 ! testlist_safe = 315 ! dictmaker = 316 ! classdef = 317 ! arglist = 318 ! argument = 319 ! list_iter = 320 ! list_for = 321 ! list_if = 322 ! gen_iter = 323 ! gen_for = 324 ! gen_if = 325 ! testlist1 = 326 ! encoding_decl = 327 #--end constants-- --- 14,88 ---- file_input = 257 eval_input = 258 ! decorator = 259 ! decorators = 260 ! funcdef = 261 ! parameters = 262 ! varargslist = 263 ! fpdef = 264 ! fplist = 265 ! stmt = 266 ! simple_stmt = 267 ! small_stmt = 268 ! expr_stmt = 269 ! augassign = 270 ! print_stmt = 271 ! del_stmt = 272 ! pass_stmt = 273 ! flow_stmt = 274 ! break_stmt = 275 ! continue_stmt = 276 ! return_stmt = 277 ! yield_stmt = 278 ! raise_stmt = 279 ! import_stmt = 280 ! import_as_name = 281 ! dotted_as_name = 282 ! dotted_name = 283 ! global_stmt = 284 ! exec_stmt = 285 ! assert_stmt = 286 ! compound_stmt = 287 ! if_stmt = 288 ! while_stmt = 289 ! for_stmt = 290 ! try_stmt = 291 ! except_clause = 292 ! suite = 293 ! test = 294 ! and_test = 295 ! not_test = 296 ! comparison = 297 ! comp_op = 298 ! expr = 299 ! xor_expr = 300 ! and_expr = 301 ! shift_expr = 302 ! arith_expr = 303 ! term = 304 ! factor = 305 ! power = 306 ! atom = 307 ! listmaker = 308 ! testlist_gexp = 309 ! lambdef = 310 ! trailer = 311 ! subscriptlist = 312 ! subscript = 313 ! sliceop = 314 ! exprlist = 315 ! testlist = 316 ! testlist_safe = 317 ! dictmaker = 318 ! classdef = 319 ! arglist = 320 ! argument = 321 ! list_iter = 322 ! list_for = 323 ! list_if = 324 ! gen_iter = 325 ! gen_for = 326 ! gen_if = 327 ! testlist1 = 328 ! encoding_decl = 329 #--end constants-- Index: token.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/token.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** token.py 3 Oct 2002 09:42:01 -0000 1.13 --- token.py 2 Aug 2004 06:09:53 -0000 1.14 *************** *** 61,67 **** DOUBLESLASH = 48 DOUBLESLASHEQUAL = 49 ! OP = 50 ! ERRORTOKEN = 51 ! N_TOKENS = 52 NT_OFFSET = 256 #--end constants-- --- 61,68 ---- DOUBLESLASH = 48 DOUBLESLASHEQUAL = 49 ! AT = 50 ! OP = 51 ! ERRORTOKEN = 52 ! N_TOKENS = 53 NT_OFFSET = 256 #--end constants-- Index: tokenize.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tokenize.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** tokenize.py 27 Feb 2003 20:14:42 -0000 1.35 --- tokenize.py 2 Aug 2004 06:09:53 -0000 1.36 *************** *** 84,88 **** Bracket = '[][(){}]' ! Special = group(r'\r?\n', r'[:;.,`]') Funny = group(Operator, Bracket, Special) --- 84,88 ---- Bracket = '[][(){}]' ! Special = group(r'\r?\n', r'[:;.,`@]') Funny = group(Operator, Bracket, Special) From anthonybaxter at users.sourceforge.net Mon Aug 2 08:10:26 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 08:10:32 2004 Subject: [Python-checkins] python/dist/src/Lib/compiler ast.py, 1.23, 1.24 pycodegen.py, 1.68, 1.69 symbols.py, 1.15, 1.16 transformer.py, 1.40, 1.41 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6086/Lib/compiler Modified Files: ast.py pycodegen.py symbols.py transformer.py Log Message: PEP-0318, @decorator-style. In Guido's words: "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728. Index: ast.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/ast.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ast.py 19 May 2004 08:20:06 -0000 1.23 --- ast.py 2 Aug 2004 06:09:53 -0000 1.24 *************** *** 49,85 **** pass ! class Slice(Node): ! nodes["slice"] = "Slice" ! def __init__(self, expr, flags, lower, upper): self.expr = expr self.flags = flags ! self.lower = lower ! self.upper = upper [...2389 lines suppressed...] return tuple(nodelist) def __repr__(self): ! return "While(%s, %s, %s)" % (repr(self.test), repr(self.body), repr(self.else_)) ! class Yield(Node): ! nodes["yield"] = "Yield" ! def __init__(self, value): ! self.value = value def getChildren(self): ! return self.value, def getChildNodes(self): ! return self.value, def __repr__(self): ! return "Yield(%s)" % (repr(self.value),) klasses = globals() Index: pycodegen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/pycodegen.py,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** pycodegen.py 7 Jul 2004 20:54:46 -0000 1.68 --- pycodegen.py 2 Aug 2004 06:09:53 -0000 1.69 *************** *** 367,370 **** --- 367,377 ---- def _visitFuncOrLambda(self, node, isLambda=0): + if not isLambda and node.decorators: + for decorator in reversed(node.decorators.nodes): + self.visit(decorator) + ndecorators = len(node.decorators.nodes) + else: + ndecorators = 0 + gen = self.FunctionGen(node, self.scopes, isLambda, self.class_name, self.get_module()) *************** *** 383,386 **** --- 390,396 ---- self.emit('LOAD_CONST', gen) self.emit('MAKE_FUNCTION', len(node.defaults)) + + for i in range(ndecorators): + self.emit('CALL_FUNCTION', 1) def visitClass(self, node): Index: symbols.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/symbols.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** symbols.py 7 Jul 2004 20:54:47 -0000 1.15 --- symbols.py 2 Aug 2004 06:09:53 -0000 1.16 *************** *** 225,228 **** --- 225,230 ---- def visitFunction(self, node, parent): + if node.decorators: + self.visit(node.decorators, parent) parent.add_def(node.name) for n in node.defaults: Index: transformer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/transformer.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** transformer.py 12 Jul 2004 13:15:56 -0000 1.40 --- transformer.py 2 Aug 2004 06:09:53 -0000 1.41 *************** *** 186,196 **** return Expression(self.com_node(nodelist[0])) def funcdef(self, nodelist): ! # funcdef: 'def' NAME parameters ':' suite # parameters: '(' [varargslist] ')' ! lineno = nodelist[1][2] ! name = nodelist[1][1] ! args = nodelist[2][2] if args[0] == symbol.varargslist: --- 186,248 ---- return Expression(self.com_node(nodelist[0])) + def decorator_name(self, nodelist): + listlen = len(nodelist) + assert listlen >= 1 and listlen % 2 == 1 + + item = self.atom_name(nodelist) + i = 1 + while i < listlen: + assert nodelist[i][0] == token.DOT + assert nodelist[i + 1][0] == token.NAME + item = Getattr(item, nodelist[i + 1][1]) + i += 2 + + return item + + def decorator(self, nodelist): + # '@' dotted_name [ '(' [arglist] ')' ] + assert len(nodelist) in (2, 4, 5) + assert nodelist[0][0] == token.AT + + assert nodelist[1][0] == symbol.dotted_name + funcname = self.decorator_name(nodelist[1][1:]) + + if len(nodelist) > 2: + assert nodelist[2][0] == token.LPAR + expr = self.com_call_function(funcname, nodelist[3]) + else: + expr = funcname + + return expr + + def decorators(self, nodelist): + # decorators: decorator ([NEWLINE] decorator)* NEWLINE + listlen = len(nodelist) + i = 0 + items = [] + while i < listlen: + assert nodelist[i][0] == symbol.decorator + items.append(self.decorator(nodelist[i][1:])) + i += 1 + + if i < listlen and nodelist[i][0] == token.NEWLINE: + i += 1 + return Decorators(items) + def funcdef(self, nodelist): ! # -6 -5 -4 -3 -2 -1 ! # funcdef: [decorators] 'def' NAME parameters ':' suite # parameters: '(' [varargslist] ')' ! if len(nodelist) == 6: ! assert nodelist[0][0] == symbol.decorators ! decorators = self.decorators(nodelist[0][1:]) ! else: ! assert len(nodelist) == 5 ! decorators = None ! ! lineno = nodelist[-4][2] ! name = nodelist[-4][1] ! args = nodelist[-3][2] if args[0] == symbol.varargslist: *************** *** 199,206 **** names = defaults = () flags = 0 ! doc = self.get_docstring(nodelist[4]) # code for function ! code = self.com_node(nodelist[4]) if doc is not None: --- 251,258 ---- names = defaults = () flags = 0 ! doc = self.get_docstring(nodelist[-1]) # code for function ! code = self.com_node(nodelist[-1]) if doc is not None: *************** *** 208,212 **** assert isinstance(code.nodes[0], Discard) del code.nodes[0] ! n = Function(name, names, defaults, flags, doc, code) n.lineno = lineno return n --- 260,264 ---- assert isinstance(code.nodes[0], Discard) del code.nodes[0] ! n = Function(decorators, name, names, defaults, flags, doc, code) n.lineno = lineno return n From anthonybaxter at users.sourceforge.net Mon Aug 2 08:10:25 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 08:10:33 2004 Subject: [Python-checkins] python/dist/src/Doc/ref ref7.tex,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6086/Doc/ref Modified Files: ref7.tex Log Message: PEP-0318, @decorator-style. In Guido's words: "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728. Index: ref7.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref7.tex,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** ref7.tex 2 Jun 2004 12:59:59 -0000 1.38 --- ref7.tex 2 Aug 2004 06:09:52 -0000 1.39 *************** *** 316,321 **** \begin{productionlist} \production{funcdef} ! {"def" \token{funcname} "(" [\token{parameter_list}] ")" ":" \token{suite}} \production{parameter_list} {(\token{defparameter} ",")*} --- 316,325 ---- \begin{productionlist} \production{funcdef} ! {[\token{decorators}] "def" \token{funcname} "(" [\token{parameter_list}] ")" ":" \token{suite}} + \production{decorators} + {\token{decorator} ([NEWLINE] \token{decorator})* NEWLINE} + \production{decorator} + {"@" \token{dotted_name} ["(" [\token{argument_list} [","]] ")"]} \production{parameter_list} {(\token{defparameter} ",")*} *************** *** 344,347 **** --- 348,372 ---- executed only when the function is called. + A function definition may be wrapped by one or more decorator expressions. + Decorator expressions are evaluated when the function is defined, in the scope + that contains the function definition. The result must be a callable, + which is invoked with the function object as the only argument. + The returned value is bound to the function name instead of the function + object. If there are multiple decorators, they are applied in reverse + order. For example, the following code: + + \begin{verbatim} + @f1 + @f2 + def func(): pass + \end{verbatim} + + is equivalent to: + + \begin{verbatim} + def func(): pass + func = f2(f1(func)) + \end{verbatim} + When one or more top-level parameters have the form \var{parameter} \code{=} \var{expression}, the function is said to have ``default From anthonybaxter at users.sourceforge.net Mon Aug 2 08:10:25 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 08:10:34 2004 Subject: [Python-checkins] python/dist/src/Doc/lib asttable.tex, 1.1, 1.2 libfuncs.tex, 1.167, 1.168 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6086/Doc/lib Modified Files: asttable.tex libfuncs.tex Log Message: PEP-0318, @decorator-style. In Guido's words: "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728. Index: asttable.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/asttable.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** asttable.tex 27 Sep 2001 20:06:07 -0000 1.1 --- asttable.tex 2 Aug 2004 06:09:52 -0000 1.2 *************** *** 74,77 **** --- 74,80 ---- \hline + \lineiii{Decorators}{\member{nodes}}{List of function decorator expressions} + \hline + \lineiii{Dict}{\member{items}}{} \hline *************** *** 102,106 **** \hline ! \lineiii{Function}{\member{name}}{name used in def, a string} \lineiii{}{\member{argnames}}{list of argument names, as strings} \lineiii{}{\member{defaults}}{list of default values} --- 105,110 ---- \hline ! \lineiii{Function}{\member{decorators}}{\class{Decorators} or \code{None}} ! \lineiii{}{\member{name}}{name used in def, a string} \lineiii{}{\member{argnames}}{list of argument names, as strings} \lineiii{}{\member{defaults}}{list of default values} Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.167 retrieving revision 1.168 diff -C2 -d -r1.167 -r1.168 *** libfuncs.tex 29 Jul 2004 06:06:34 -0000 1.167 --- libfuncs.tex 2 Aug 2004 06:09:52 -0000 1.168 *************** *** 110,117 **** \begin{verbatim} class C: def f(cls, arg1, arg2, ...): ... - f = classmethod(f) \end{verbatim} It can be called either on the class (such as \code{C.f()}) or on an instance (such as \code{C().f()}). The instance is ignored except for --- 110,121 ---- \begin{verbatim} class C: + @classmethod def f(cls, arg1, arg2, ...): ... \end{verbatim} + The \code{@classmethod} form is a function decorator -- see the description + of function definitions in chapter 7 of the + \citetitle[../ref/ref.html]{Python Reference Manual} for details. + It can be called either on the class (such as \code{C.f()}) or on an instance (such as \code{C().f()}). The instance is ignored except for *************** *** 123,126 **** --- 127,131 ---- If you want those, see \function{staticmethod()} in this section. \versionadded{2.2} + Function decorator syntax added in version 2.4. \end{funcdesc} *************** *** 937,944 **** \begin{verbatim} class C: def f(arg1, arg2, ...): ... - f = staticmethod(f) \end{verbatim} It can be called either on the class (such as \code{C.f()}) or on an instance (such as \code{C().f()}). The instance is ignored except --- 942,953 ---- \begin{verbatim} class C: + @staticmethod def f(arg1, arg2, ...): ... \end{verbatim} + The \code{@staticmethod} form is a function decorator -- see the description + of function definitions in chapter 7 of the + \citetitle[../ref/ref.html]{Python Reference Manual} for details. + It can be called either on the class (such as \code{C.f()}) or on an instance (such as \code{C().f()}). The instance is ignored except From anthonybaxter at users.sourceforge.net Mon Aug 2 08:10:27 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 08:10:35 2004 Subject: [Python-checkins] python/dist/src/Lib/test/output test_tokenize, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6086/Lib/test/output Modified Files: test_tokenize Log Message: PEP-0318, @decorator-style. In Guido's words: "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728. Index: test_tokenize =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_tokenize,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_tokenize 29 Aug 2002 15:10:30 -0000 1.8 --- test_tokenize 2 Aug 2004 06:09:54 -0000 1.9 *************** *** 646,648 **** 174,30-174,31: NEWLINE '\n' 175,0-175,1: NL '\n' ! 176,0-176,0: ENDMARKER '' --- 646,659 ---- 174,30-174,31: NEWLINE '\n' 175,0-175,1: NL '\n' ! 176,0-176,1: OP '@' ! 176,1-176,13: NAME 'staticmethod' ! 176,13-176,14: NEWLINE '\n' ! 177,0-177,3: NAME 'def' ! 177,4-177,7: NAME 'foo' ! 177,7-177,8: OP '(' ! 177,8-177,9: OP ')' ! 177,9-177,10: OP ':' ! 177,11-177,15: NAME 'pass' ! 177,15-177,16: NEWLINE '\n' ! 178,0-178,1: NL '\n' ! 179,0-179,0: ENDMARKER '' From anthonybaxter at users.sourceforge.net Mon Aug 2 08:10:27 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 08:10:35 2004 Subject: [Python-checkins] python/dist/src/Parser tokenizer.c,2.74,2.75 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6086/Parser Modified Files: tokenizer.c Log Message: PEP-0318, @decorator-style. In Guido's words: "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728. Index: tokenizer.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/tokenizer.c,v retrieving revision 2.74 retrieving revision 2.75 diff -C2 -d -r2.74 -r2.75 *** tokenizer.c 20 Nov 2003 01:44:58 -0000 2.74 --- tokenizer.c 2 Aug 2004 06:09:55 -0000 2.75 *************** *** 93,96 **** --- 93,97 ---- "DOUBLESLASH", "DOUBLESLASHEQUAL", + "AT", /* This table must match the #defines in token.h! */ "OP", *************** *** 848,851 **** --- 849,853 ---- case '^': return CIRCUMFLEX; case '~': return TILDE; + case '@': return AT; default: return OP; } From anthonybaxter at users.sourceforge.net Mon Aug 2 08:10:27 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 08:10:35 2004 Subject: [Python-checkins] python/dist/src/Modules parsermodule.c,2.82,2.83 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6086/Modules Modified Files: parsermodule.c Log Message: PEP-0318, @decorator-style. In Guido's words: "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728. Index: parsermodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/parsermodule.c,v retrieving revision 2.82 retrieving revision 2.83 diff -C2 -d -r2.82 -r2.83 *** parsermodule.c 19 May 2004 08:20:13 -0000 2.82 --- parsermodule.c 2 Aug 2004 06:09:55 -0000 2.83 *************** *** 825,828 **** --- 825,829 ---- #define validate_doublestar(ch) validate_terminal(ch, DOUBLESTAR, "**") #define validate_dot(ch) validate_terminal(ch, DOT, ".") + #define validate_at(ch) validate_terminal(ch, AT, "@") #define validate_name(ch, str) validate_terminal(ch, NAME, str) *************** *** 2363,2380 **** } /* funcdef: ! * 'def' NAME parameters ':' suite ! * */ static int validate_funcdef(node *tree) { ! return (validate_ntype(tree, funcdef) ! && validate_numnodes(tree, 5, "funcdef") ! && validate_name(CHILD(tree, 0), "def") ! && validate_ntype(CHILD(tree, 1), NAME) ! && validate_colon(CHILD(tree, 3)) ! && validate_parameters(CHILD(tree, 2)) ! && validate_suite(CHILD(tree, 4))); } --- 2364,2433 ---- } + /* decorator: + * '@' dotted_name [ '(' [arglist] ')' ] + */ + static int + validate_decorator(node *tree) + { + int ok; + int nch = NCH(tree); + ok = (validate_ntype(tree, decorator) && + (nch == 2 || nch == 4 || nch == 5) && + validate_at(CHILD(tree, 0)) && + validate_dotted_name(CHILD(tree, 1))); + + if (ok && nch != 2) { + ok = (validate_lparen(CHILD(tree, 2)) && + validate_rparen(RCHILD(tree, -1))); + + if (ok && nch == 5) + ok = validate_arglist(CHILD(tree, 3)); + } + + return ok; + } + + /* decorators: + * decorator ([NEWLINE] decorator)* NEWLINE + */ + static int + validate_decorators(node *tree) + { + int i, nch, ok; + nch = NCH(tree); + ok = validate_ntype(tree, decorators) && nch >= 2; + + i = 0; + while (ok && i < nch - 1) { + ok = validate_decorator(CHILD(tree, i)); + if (TYPE(CHILD(tree, i + 1)) == NEWLINE) + ++i; + ++i; + } + + return ok; + } + /* funcdef: ! * ! * -6 -5 -4 -3 -2 -1 ! * [decorators] 'def' NAME parameters ':' suite */ static int validate_funcdef(node *tree) { ! int nch = NCH(tree); ! int ok = (validate_ntype(tree, funcdef) ! && ((nch == 5) || (nch == 6)) ! && validate_name(RCHILD(tree, -5), "def") ! && validate_ntype(RCHILD(tree, -4), NAME) ! && validate_colon(RCHILD(tree, -2)) ! && validate_parameters(RCHILD(tree, -3)) ! && validate_suite(RCHILD(tree, -1))); ! ! if (ok && (nch == 6)) ! ok = validate_decorators(CHILD(tree, 0)); ! ! return ok; } From anthonybaxter at users.sourceforge.net Mon Aug 2 08:10:27 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 08:10:36 2004 Subject: [Python-checkins] python/dist/src/Lib/test pyclbr_input.py, NONE, 1.1 test_decorators.py, NONE, 1.1 test_parser.py, 1.18, 1.19 test_pyclbr.py, 1.21, 1.22 tokenize_tests.txt, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6086/Lib/test Modified Files: test_parser.py test_pyclbr.py tokenize_tests.txt Added Files: pyclbr_input.py test_decorators.py Log Message: PEP-0318, @decorator-style. In Guido's words: "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728. --- NEW FILE: pyclbr_input.py --- """Test cases for test_pyclbr.py""" def f(): pass class Other(object): @classmethod def foo(c): pass def om(self): pass class B (object): def bm(self): pass class C (B): foo = Other().foo om = Other.om d = 10 # XXX: This causes test_pyclbr.py to fail, but only because the # introspection-based is_method() code in the test can't # distinguish between this and a geniune method function like m(). # The pyclbr.py module gets this right as it parses the text. # #f = f def m(self): pass @staticmethod def sm(self): pass @classmethod def cm(self): pass --- NEW FILE: test_decorators.py --- import unittest from test import test_support def funcattrs(**kwds): def decorate(func): func.__dict__.update(kwds) return func return decorate class MiscDecorators (object): @staticmethod def author(name): def decorate(func): func.__dict__['author'] = name return func return decorate # ----------------------------------------------- class DbcheckError (Exception): def __init__(self, exprstr, func, args, kwds): # A real version of this would set attributes here Exception.__init__(self, "dbcheck %r failed (func=%s args=%s kwds=%s)" % (exprstr, func, args, kwds)) def dbcheck(exprstr, globals=None, locals=None): "Decorator to implement debugging assertions" def decorate(func): expr = compile(exprstr, "dbcheck-%s" % func.func_name, "eval") def check(*args, **kwds): if not eval(expr, globals, locals): raise DbcheckError(exprstr, func, args, kwds) return func(*args, **kwds) return check return decorate # ----------------------------------------------- def countcalls(counts): "Decorator to count calls to a function" def decorate(func): name = func.func_name counts[name] = 0 def call(*args, **kwds): counts[name] += 1 return func(*args, **kwds) # XXX: Would like to say: call.func_name = func.func_name here # to make nested decorators work in any order, but func_name # is a readonly attribute return call return decorate # ----------------------------------------------- def memoize(func): saved = {} def call(*args): try: return saved[args] except KeyError: res = func(*args) saved[args] = res return res except TypeError: # Unhashable argument return func(*args) return call # ----------------------------------------------- class TestDecorators(unittest.TestCase): def test_single(self): class C(object): @staticmethod def foo(): return 42 self.assertEqual(C.foo(), 42) self.assertEqual(C().foo(), 42) def test_dotted(self): decorators = MiscDecorators() @decorators.author('Cleese') def foo(): return 42 self.assertEqual(foo(), 42) self.assertEqual(foo.author, 'Cleese') def test_argforms(self): # A few tests of argument passing, as we use restricted form # of expressions for decorators. def noteargs(*args, **kwds): def decorate(func): setattr(func, 'dbval', (args, kwds)) return func return decorate args = ( 'Now', 'is', 'the', 'time' ) kwds = dict(one=1, two=2) @noteargs(*args, **kwds) def f1(): return 42 self.assertEqual(f1(), 42) self.assertEqual(f1.dbval, (args, kwds)) @noteargs('terry', 'gilliam', eric='idle', john='cleese') def f2(): return 84 self.assertEqual(f2(), 84) self.assertEqual(f2.dbval, (('terry', 'gilliam'), dict(eric='idle', john='cleese'))) @noteargs(1, 2,) def f3(): pass self.assertEqual(f3.dbval, ((1, 2), {})) def test_dbcheck(self): @dbcheck('args[1] is not None') def f(a, b): return a + b self.assertEqual(f(1, 2), 3) self.assertRaises(DbcheckError, f, 1, None) def test_memoize(self): # XXX: This doesn't work unless memoize is the last decorator - # see the comment in countcalls. counts = {} @countcalls(counts) @memoize def double(x): return x * 2 self.assertEqual(counts, dict(double=0)) # Only the first call with a given argument bumps the call count: # self.assertEqual(double(2), 4) self.assertEqual(counts['double'], 1) self.assertEqual(double(2), 4) self.assertEqual(counts['double'], 1) self.assertEqual(double(3), 6) self.assertEqual(counts['double'], 2) # Unhashable arguments do not get memoized: # self.assertEqual(double([10]), [10, 10]) self.assertEqual(counts['double'], 3) self.assertEqual(double([10]), [10, 10]) self.assertEqual(counts['double'], 4) def test_errors(self): # Test syntax restrictions - these are all compile-time errors: # for expr in [ "1+2", "x[3]", "(1, 2)" ]: # Sanity check: is expr is a valid expression by itself? compile(expr, "testexpr", "exec") codestr = "@%s\ndef f(): pass" % expr self.assertRaises(SyntaxError, compile, codestr, "test", "exec") # Test runtime errors def unimp(func): raise NotImplementedError context = dict(nullval=None, unimp=unimp) for expr, exc in [ ("undef", NameError), ("nullval", TypeError), ("nullval.attr", AttributeError), ("unimp", NotImplementedError)]: codestr = "@%s\ndef f(): pass\nassert f() is None" % expr code = compile(codestr, "test", "exec") self.assertRaises(exc, eval, code, context) def test_double(self): class C(object): @funcattrs(abc=1, xyz="haha") @funcattrs(booh=42) def foo(self): return 42 self.assertEqual(C().foo(), 42) self.assertEqual(C.foo.abc, 1) self.assertEqual(C.foo.xyz, "haha") self.assertEqual(C.foo.booh, 42) def test_order(self): class C(object): @funcattrs(abc=1) @staticmethod def foo(): return 42 # This wouldn't work if staticmethod was called first self.assertEqual(C.foo(), 42) self.assertEqual(C().foo(), 42) def test_main(): test_support.run_unittest(TestDecorators) if __name__=="__main__": test_main() Index: test_parser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_parser.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** test_parser.py 19 May 2004 08:20:09 -0000 1.18 --- test_parser.py 2 Aug 2004 06:09:54 -0000 1.19 *************** *** 16,21 **** try: st2 = parser.sequence2st(t) ! except parser.ParserError: ! self.fail("could not roundtrip %r" % s) self.assertEquals(t, st2.totuple(), --- 16,21 ---- try: st2 = parser.sequence2st(t) ! except parser.ParserError, why: ! self.fail("could not roundtrip %r: %s" % (s, why)) self.assertEquals(t, st2.totuple(), *************** *** 120,123 **** --- 120,131 ---- self.check_suite("def f(a, b, foo=bar, **kw): pass") + self.check_suite("@staticmethod\n" + "def f(): pass") + self.check_suite("@staticmethod\n" + "@funcattrs(x, y)\n" + "def f(): pass") + self.check_suite("@funcattrs()\n" + "def f(): pass") + def test_import_from_statement(self): self.check_suite("from sys.path import *") Index: test_pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyclbr.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** test_pyclbr.py 18 Jul 2004 00:08:11 -0000 1.21 --- test_pyclbr.py 2 Aug 2004 06:09:54 -0000 1.22 *************** *** 9,12 **** --- 9,15 ---- from unittest import TestCase + StaticMethodType = type(staticmethod(lambda: None)) + ClassMethodType = type(classmethod(lambda c: None)) + # This next line triggers an error on old versions of pyclbr. *************** *** 44,52 **** self.failUnless(obj.has_key(key)) ! def assertEquals(self, a, b, ignore=None): ''' succeed iff a == b or a in ignore or b in ignore ''' ! if (ignore == None) or (a in ignore) or (b in ignore): return ! ! unittest.TestCase.assertEquals(self, a, b) def checkModule(self, moduleName, module=None, ignore=()): --- 47,54 ---- self.failUnless(obj.has_key(key)) ! def assertEqualsOrIgnored(self, a, b, ignore): ''' succeed iff a == b or a in ignore or b in ignore ''' ! if a not in ignore and b not in ignore: ! self.assertEquals(a, b) def checkModule(self, moduleName, module=None, ignore=()): *************** *** 63,71 **** dict = pyclbr.readmodule_ex(moduleName) ! def ismethod(obj, name): ! if not isinstance(obj, MethodType): ! return False ! if obj.im_self is not None: ! return False objname = obj.__name__ if objname.startswith("__") and not objname.endswith("__"): --- 65,84 ---- dict = pyclbr.readmodule_ex(moduleName) ! def ismethod(oclass, obj, name): ! classdict = oclass.__dict__ ! if isinstance(obj, FunctionType): ! if not isinstance(classdict[name], StaticMethodType): ! return False ! else: ! if not isinstance(obj, MethodType): ! return False ! if obj.im_self is not None: ! if (not isinstance(classdict[name], ClassMethodType) or ! obj.im_self is not oclass): ! return False ! else: ! if not isinstance(classdict[name], FunctionType): ! return False ! objname = obj.__name__ if objname.startswith("__") and not objname.endswith("__"): *************** *** 82,86 **** self.assertEquals(type(py_item), FunctionType) else: ! self.assertEquals(type(py_item), ClassType) real_bases = [base.__name__ for base in py_item.__bases__] pyclbr_bases = [ getattr(base, 'name', base) --- 95,99 ---- self.assertEquals(type(py_item), FunctionType) else: ! self.failUnless(isinstance(py_item, (ClassType, type))) real_bases = [base.__name__ for base in py_item.__bases__] pyclbr_bases = [ getattr(base, 'name', base) *************** *** 95,99 **** actualMethods = [] for m in py_item.__dict__.keys(): ! if ismethod(getattr(py_item, m), m): actualMethods.append(m) foundMethods = [] --- 108,112 ---- actualMethods = [] for m in py_item.__dict__.keys(): ! if ismethod(py_item, getattr(py_item, m), m): actualMethods.append(m) foundMethods = [] *************** *** 108,112 **** self.assertEquals(py_item.__module__, value.module) ! self.assertEquals(py_item.__name__, value.name, ignore) # can't check file or lineno except: --- 121,126 ---- self.assertEquals(py_item.__module__, value.module) ! self.assertEqualsOrIgnored(py_item.__name__, value.name, ! ignore) # can't check file or lineno except: *************** *** 133,136 **** --- 147,156 ---- self.checkModule('difflib') + def test_decorators(self): + # XXX: See comment in pyclbr_input.py for a test that would fail + # if it were not commented out. + # + self.checkModule('test.pyclbr_input') + def test_others(self): cm = self.checkModule Index: tokenize_tests.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/tokenize_tests.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tokenize_tests.txt 12 May 2003 19:42:04 -0000 1.1 --- tokenize_tests.txt 2 Aug 2004 06:09:54 -0000 1.2 *************** *** 174,175 **** --- 174,178 ---- x = sys.modules['time'].time() + @staticmethod + def foo(): pass + From anthonybaxter at users.sourceforge.net Mon Aug 2 08:25:01 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 08:25:04 2004 Subject: [Python-checkins] python/dist/src/Misc ACKS, 1.275, 1.276 NEWS, 1.1060, 1.1061 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8302/Misc Modified Files: ACKS NEWS Log Message: notes for @decorator Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.275 retrieving revision 1.276 diff -C2 -d -r1.275 -r1.276 *** ACKS 28 Jul 2004 15:37:54 -0000 1.275 --- ACKS 2 Aug 2004 06:24:59 -0000 1.276 *************** *** 496,499 **** --- 496,500 ---- Jeff Rush Sam Rushing + Mark Russell Nick Russo Rich Salz Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1060 retrieving revision 1.1061 diff -C2 -d -r1.1060 -r1.1061 *** NEWS 2 Aug 2004 03:48:03 -0000 1.1060 --- NEWS 2 Aug 2004 06:24:59 -0000 1.1061 *************** *** 13,16 **** --- 13,22 ---- ----------------- + - PEP-0318, Function Decorators have been added to the language. These are + implemented using the Java-style @decorator syntax, like so: + @staticmethod + def foo(bar): + (The PEP needs to be updated to reflect this XXX before 2.4a2) + - When importing a module M raises an exception, Python no longer leaves M in sys.modules. Before 2.4a2 it did, and a subsequent import of M would From rhettinger at users.sourceforge.net Mon Aug 2 10:30:09 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Aug 2 10:30:12 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1061,1.1062 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25880/Misc Modified Files: NEWS Log Message: Completed the patch for Bug #215126. * Fixes an incorrect variable in a PyDict_CheckExact. * Allow general mapping locals arguments for the execfile() function and exec statement. * Add tests. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1061 retrieving revision 1.1062 diff -C2 -d -r1.1061 -r1.1062 *** NEWS 2 Aug 2004 06:24:59 -0000 1.1061 --- NEWS 2 Aug 2004 08:30:06 -0000 1.1062 *************** *** 270,274 **** Windows DLLs. ! - Bug #215126. The locals argument to eval() now accepts any mapping type. - marshal now shares interned strings. This change introduces --- 270,275 ---- Windows DLLs. ! - Bug #215126. The locals argument to eval(), execfile(), and exec now ! accept any mapping type. - marshal now shares interned strings. This change introduces From rhettinger at users.sourceforge.net Mon Aug 2 10:30:10 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Aug 2 10:30:13 2004 Subject: [Python-checkins] python/dist/src/Python ceval.c, 2.410, 2.411 bltinmodule.c, 2.313, 2.314 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25880/Python Modified Files: ceval.c bltinmodule.c Log Message: Completed the patch for Bug #215126. * Fixes an incorrect variable in a PyDict_CheckExact. * Allow general mapping locals arguments for the execfile() function and exec statement. * Add tests. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.410 retrieving revision 2.411 diff -C2 -d -r2.410 -r2.411 *** ceval.c 8 Jul 2004 01:49:00 -0000 2.410 --- ceval.c 2 Aug 2004 08:30:07 -0000 2.411 *************** *** 1644,1648 **** v = POP(); if ((x = f->f_locals) != NULL) { ! if (PyDict_CheckExact(v)) err = PyDict_SetItem(x, w, v); else --- 1644,1648 ---- v = POP(); if ((x = f->f_locals) != NULL) { ! if (PyDict_CheckExact(x)) err = PyDict_SetItem(x, w, v); else *************** *** 4117,4123 **** return -1; } ! if (!PyDict_Check(locals)) { PyErr_SetString(PyExc_TypeError, ! "exec: arg 3 must be a dictionary or None"); return -1; } --- 4117,4123 ---- return -1; } ! if (!PyMapping_Check(locals)) { PyErr_SetString(PyExc_TypeError, ! "exec: arg 3 must be a mapping or None"); return -1; } Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.313 retrieving revision 2.314 diff -C2 -d -r2.313 -r2.314 *** bltinmodule.c 19 Jul 2004 16:29:17 -0000 2.313 --- bltinmodule.c 2 Aug 2004 08:30:07 -0000 2.314 *************** *** 540,548 **** int exists; ! if (!PyArg_ParseTuple(args, "s|O!O!:execfile", &filename, &PyDict_Type, &globals, ! &PyDict_Type, &locals)) return NULL; if (globals == Py_None) { globals = PyEval_GetGlobals(); --- 540,552 ---- int exists; ! if (!PyArg_ParseTuple(args, "s|O!O:execfile", &filename, &PyDict_Type, &globals, ! &locals)) return NULL; + if (locals != Py_None && !PyMapping_Check(locals)) { + PyErr_SetString(PyExc_TypeError, "locals must be a mapping"); + return NULL; + } if (globals == Py_None) { globals = PyEval_GetGlobals(); From rhettinger at users.sourceforge.net Mon Aug 2 10:30:10 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Aug 2 10:30:13 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_builtin.py, 1.31, 1.32 test_compile.py, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25880/Lib/test Modified Files: test_builtin.py test_compile.py Log Message: Completed the patch for Bug #215126. * Fixes an incorrect variable in a PyDict_CheckExact. * Allow general mapping locals arguments for the execfile() function and exec statement. * Add tests. Index: test_builtin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** test_builtin.py 6 Jul 2004 13:44:41 -0000 1.31 --- test_builtin.py 2 Aug 2004 08:30:07 -0000 1.32 *************** *** 283,286 **** --- 283,291 ---- self.assertEqual(eval('locals()', g, m), m) self.assertRaises(TypeError, eval, 'a', m) + class A: + "Non-mapping" + pass + m = A() + self.assertRaises(TypeError, eval, 'a', g, m) # Verify that dict subclasses work as well *************** *** 337,340 **** --- 342,365 ---- execfile(TESTFN, globals, locals) self.assertEqual(locals['z'], 2) + + class M: + "Test mapping interface versus possible calls from execfile()." + def __init__(self): + self.z = 10 + def __getitem__(self, key): + if key == 'z': + return self.z + raise KeyError + def __setitem__(self, key, value): + if key == 'z': + self.z = value + return + raise KeyError + + locals = M() + locals['z'] = 0 + execfile(TESTFN, globals, locals) + self.assertEqual(locals['z'], 2) + unlink(TESTFN) self.assertRaises(TypeError, execfile) Index: test_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_compile.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** test_compile.py 17 Jul 2004 21:46:25 -0000 1.21 --- test_compile.py 2 Aug 2004 08:30:07 -0000 1.22 *************** *** 45,48 **** --- 45,105 ---- pass + def test_exec_with_general_mapping_for_locals(self): + + class M: + "Test mapping interface versus possible calls from eval()." + def __getitem__(self, key): + if key == 'a': + return 12 + raise KeyError + def __setitem__(self, key, value): + self.results = (key, value) + def keys(self): + return list('xyz') + + m = M() + g = globals() + exec 'z = a' in g, m + self.assertEqual(m.results, ('z', 12)) + try: + exec 'z = b' in g, m + except NameError: + pass + else: + self.fail('Did not detect a KeyError') + exec 'z = dir()' in g, m + self.assertEqual(m.results, ('z', list('xyz'))) + exec 'z = globals()' in g, m + self.assertEqual(m.results, ('z', g)) + exec 'z = locals()' in g, m + self.assertEqual(m.results, ('z', m)) + try: + exec 'z = b' in m + except TypeError: + pass + else: + self.fail('Did not validate globals as a real dict') + + class A: + "Non-mapping" + pass + m = A() + try: + exec 'z = a' in g, m + except TypeError: + pass + else: + self.fail('Did not validate locals as a mapping') + + # Verify that dict subclasses work as well + class D(dict): + def __getitem__(self, key): + if key == 'a': + return 12 + return dict.__getitem__(self, key) + d = D() + exec 'z = a' in g, d + self.assertEqual(d['z'], 12) + def test_complex_args(self): From rhettinger at users.sourceforge.net Mon Aug 2 10:36:09 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Aug 2 10:36:13 2004 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.50,1.51 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27018 Modified Files: concrete.tex Log Message: Fix doubled word. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** concrete.tex 29 Jul 2004 02:16:04 -0000 1.50 --- concrete.tex 2 Aug 2004 08:36:07 -0000 1.51 *************** *** 2826,2830 **** \begin{cfuncdesc}{int}{PyDateTime_DATE_GET_HOUR}{PyDateTime_DateTime *o} ! Return the hour, an an int from 0 though 23. \versionadded{2.4} \end{cfuncdesc} --- 2826,2830 ---- \begin{cfuncdesc}{int}{PyDateTime_DATE_GET_HOUR}{PyDateTime_DateTime *o} ! Return the hour, an int from 0 though 23. \versionadded{2.4} \end{cfuncdesc} From anthonybaxter at users.sourceforge.net Mon Aug 2 13:08:18 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 13:08:20 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.310,2.311 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15336/Python Modified Files: compile.c Log Message: fix for @decorators under a debug build. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.310 retrieving revision 2.311 diff -C2 -d -r2.310 -r2.311 *** compile.c 2 Aug 2004 06:09:55 -0000 2.310 --- compile.c 2 Aug 2004 11:08:15 -0000 2.311 *************** *** 4026,4029 **** --- 4026,4030 ---- REQ(varname, NAME); com_addop_varname(c, VAR_LOAD, STR(varname)); + com_push(c, 1); for (i = 1; i < nch; i += 2) { From anthonybaxter at users.sourceforge.net Mon Aug 2 13:34:13 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Aug 2 13:34:15 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decorators.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20038/Lib/test Modified Files: test_decorators.py Log Message: and a unit test for the staticmethod-of-a-non-method failure just fixed Index: test_decorators.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decorators.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_decorators.py 2 Aug 2004 06:09:54 -0000 1.1 --- test_decorators.py 2 Aug 2004 11:34:10 -0000 1.2 *************** *** 79,82 **** --- 79,88 ---- self.assertEqual(C().foo(), 42) + def test_staticmethod_function(self): + @staticmethod + def notamethod(x): + return x + self.assertRaises(TypeError, notamethod, 1) + def test_dotted(self): decorators = MiscDecorators() From akuchling at users.sourceforge.net Mon Aug 2 14:10:00 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Aug 2 14:10:03 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.76, 1.77 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26307 Modified Files: whatsnew24.tex Log Message: Update item Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** whatsnew24.tex 28 Jul 2004 15:29:39 -0000 1.76 --- whatsnew24.tex 2 Aug 2004 12:09:58 -0000 1.77 *************** *** 609,614 **** \item The \function{eval(\var{expr}, \var{globals}, \var{locals})} ! function now accepts any mapping type for the \var{locals} argument. ! Previously this had to be a regular Python dictionary. \item The \function{zip()} built-in function and \function{itertools.izip()} --- 609,616 ---- \item The \function{eval(\var{expr}, \var{globals}, \var{locals})} ! and \function{execfile(\var{filename}, \var{globals}, \var{locals})} ! functions and the \keyword{exec} statement now accept any mapping type ! for the \var{locals} argument. Previously this had to be a regular ! Python dictionary. (Contributed by Raymond Hettinger.) \item The \function{zip()} built-in function and \function{itertools.izip()} From akuchling at users.sourceforge.net Mon Aug 2 14:44:32 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Aug 2 14:44:36 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.77, 1.78 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv417 Modified Files: whatsnew24.tex Log Message: Add import change; add empty section for function decorators Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** whatsnew24.tex 2 Aug 2004 12:09:58 -0000 1.77 --- whatsnew24.tex 2 Aug 2004 12:44:28 -0000 1.78 *************** *** 183,186 **** --- 183,198 ---- %====================================================================== + \section{PEP 318: Decorators for Functions, Methods and Classes} + + % XXX write this section + + \begin{seealso} + \seepep{318}{Decorators for Functions, Methods and Classes}{Written + by Kevin D. Smith, Jim Jewett, and Skip Montanaro. Several people wrote + patches implementing function decorators, but the one that was actually + checked in was patch #979728, written by Mark Russell.} + \end{seealso} + + %====================================================================== \section{PEP 322: Reverse Iteration} *************** *** 630,633 **** --- 642,650 ---- \end{verbatim} + \item Encountering a failure while importing a module no longer leaves + a partially-initialized module object in \code{sys.modules}. The + incomplete module object left behind would fool further imports of the + same module into succeeding, leading to confusing errors. + \item \constant{None} is now a constant; code that binds a new value to the name \samp{None} is now a syntax error. From mwh at users.sourceforge.net Mon Aug 2 15:21:12 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon Aug 2 15:21:15 2004 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.314,2.315 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7350/Python Modified Files: bltinmodule.c Log Message: for some reason, the lack of adherence to Python's C whitespace rules must have annoyed me at some point. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.314 retrieving revision 2.315 diff -C2 -d -r2.314 -r2.315 *** bltinmodule.c 2 Aug 2004 08:30:07 -0000 2.314 --- bltinmodule.c 2 Aug 2004 13:21:09 -0000 2.315 *************** *** 1589,1593 **** return NULL; } ! if (PyFile_Check (fin) && PyFile_Check (fout) && isatty(fileno(PyFile_AsFile(fin))) && isatty(fileno(PyFile_AsFile(fout)))) { --- 1589,1593 ---- return NULL; } ! if (PyFile_Check(fin) && PyFile_Check(fout) && isatty(fileno(PyFile_AsFile(fin))) && isatty(fileno(PyFile_AsFile(fout)))) { *************** *** 1608,1612 **** prompt = ""; } ! s = PyOS_Readline(PyFile_AsFile (fin), PyFile_AsFile (fout), prompt); Py_XDECREF(po); --- 1608,1612 ---- prompt = ""; } ! s = PyOS_Readline(PyFile_AsFile(fin), PyFile_AsFile(fout), prompt); Py_XDECREF(po); From mwh at users.sourceforge.net Mon Aug 2 15:22:04 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon Aug 2 15:22:06 2004 Subject: [Python-checkins] python/dist/src/Objects rangeobject.c,2.50,2.51 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7629/Objects Modified Files: rangeobject.c Log Message: Add a missing decref. Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.50 retrieving revision 2.51 diff -C2 -d -r2.50 -r2.51 *** rangeobject.c 10 Mar 2004 10:10:42 -0000 2.50 --- rangeobject.c 2 Aug 2004 13:22:01 -0000 2.51 *************** *** 37,40 **** --- 37,41 ---- PyErr_SetString(PyExc_OverflowError, "integer addition"); + Py_DECREF(obj); return NULL; } From mwh at users.sourceforge.net Mon Aug 2 15:24:57 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon Aug 2 15:25:00 2004 Subject: [Python-checkins] python/dist/src/Modules _bisectmodule.c,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7849/Modules Modified Files: _bisectmodule.c Log Message: Any call to insort_{left,right} with a non-list leaked a reference to None (or to whatever the 'insert' method chose to return). Index: _bisectmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_bisectmodule.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** _bisectmodule.c 5 Jan 2004 10:13:35 -0000 1.1 --- _bisectmodule.c 2 Aug 2004 13:24:54 -0000 1.2 *************** *** 66,70 **** insort_right(PyObject *self, PyObject *args) { ! PyObject *list, *item; int lo = 0; int hi = -1; --- 66,70 ---- insort_right(PyObject *self, PyObject *args) { ! PyObject *list, *item, *result; int lo = 0; int hi = -1; *************** *** 81,87 **** return NULL; } else { ! if (PyObject_CallMethod(list, "insert", "iO", index, item) ! == NULL) return NULL; } --- 81,89 ---- return NULL; } else { ! result = PyObject_CallMethod(list, "insert", "iO", ! index, item); ! if (result == NULL) return NULL; + Py_DECREF(result); } *************** *** 159,163 **** insort_left(PyObject *self, PyObject *args) { ! PyObject *list, *item; int lo = 0; int hi = -1; --- 161,165 ---- insort_left(PyObject *self, PyObject *args) { ! PyObject *list, *item, *result; int lo = 0; int hi = -1; *************** *** 174,180 **** return NULL; } else { ! if (PyObject_CallMethod(list, "insert", "iO", index, item) ! == NULL) return NULL; } --- 176,184 ---- return NULL; } else { ! result = PyObject_CallMethod(list, "insert", "iO", ! index, item); ! if (result == NULL) return NULL; + Py_DECREF(result); } From akuchling at users.sourceforge.net Mon Aug 2 15:48:21 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Aug 2 15:48:24 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.78, 1.79 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11731 Modified Files: whatsnew24.tex Log Message: Add PEP318 Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** whatsnew24.tex 2 Aug 2004 12:44:28 -0000 1.78 --- whatsnew24.tex 2 Aug 2004 13:48:18 -0000 1.79 *************** *** 185,195 **** \section{PEP 318: Decorators for Functions, Methods and Classes} ! % XXX write this section \begin{seealso} \seepep{318}{Decorators for Functions, Methods and Classes}{Written ! by Kevin D. Smith, Jim Jewett, and Skip Montanaro. Several people wrote ! patches implementing function decorators, but the one that was actually ! checked in was patch #979728, written by Mark Russell.} \end{seealso} --- 185,322 ---- \section{PEP 318: Decorators for Functions, Methods and Classes} ! Python 2.2 extended Python's object model by adding static methods and ! class methods, but it didn't extend Python's syntax to provide any new ! way of defining static or class methods. Instead, you had to write a ! \keyword{def} statement in the usual way, and pass the resulting ! method to a \function{staticmethod()} or \function{classmethod()} ! function that would wrap up the function as a method of the new type. ! Your code would look like this: ! ! \begin{verbatim} ! class C: ! def meth (cls): ! ... ! ! meth = classmethod(meth) # Rebind name to wrapped-up class method ! \end{verbatim} ! ! If the method was very long, it would be easy to miss or forget the ! \function{classmethod()} invocation after the function body. ! ! The intention was always to add some syntax to make such definitions ! more readable, but at the time of 2.2's release a good syntax was not ! obvious. Years later, when Python 2.4 is coming out, a good syntax ! \emph{still} isn't obvious but users are asking for easier access to ! the feature, so a new syntactic feature has been added. ! ! The feature is called ``function decorators''. The name comes from ! the idea that \function{classmethod}, \function{staticmethod}, and ! friends are storing additional information on a function object; they're ! \emph{decorating} functions with more details. ! ! The notation borrows from Java and uses the \samp{@} character as an ! indicator. Using the new syntax, the example above would be written: ! ! \begin{verbatim} ! class C: ! ! @classmethod ! def meth (cls): ! ... ! ! \end{verbatim} ! ! The \code{@classmethod} is shorthand for the ! \code{meth=classmethod(meth} assignment. More generally, if you have ! the following: ! ! \begin{verbatim} ! @A @B @C ! def f (): ! ... ! \end{verbatim} ! ! It's equivalent to: ! ! \begin{verbatim} ! def f(): ... ! f = C(B(A(f))) ! \end{verbatim} ! ! Decorators must come on the line before a function definition, and ! can't be on the same line, meaning that \code{@A def f(): ...} is ! illegal. You can only decorate function definitions, either at the ! module-level or inside a class; you can't decorate class definitions. ! ! A decorator is just a function that takes the function to be decorated ! as an argument and returns either the same function or some new ! callable thing. It's easy to write your own decorators. The ! following simple example just sets an attribute on the function ! object: ! ! \begin{verbatim} ! >>> def deco(func): ! ... func.attr = 'decorated' ! ... return func ! ... ! >>> @deco ! ... def f(): pass ! ... ! >>> f ! ! >>> f.attr ! 'decorated' ! >>> ! \end{verbatim} ! ! As a slightly more realistic example, the following decorator checks ! that the supplied argument is an integer: ! ! \begin{verbatim} ! def require_int (func): ! def wrapper (arg): ! assert isinstance(arg, int) ! return func(arg) ! ! return wrapper ! ! @require_int ! def p1 (arg): ! print arg ! ! @require_int ! def p2(arg): ! print arg*2 ! \end{verbatim} ! ! An example in \pep{318} contains a fancier version of this idea that ! lets you specify the required type and check the returned type as ! well. ! ! Decorator functions can take arguments. If arguments are supplied, ! the decorator function is called with only those arguments and must ! return a new decorator function; this new function must take a single ! function and return a function, as previously described. In other ! words, \code{@A @B @C(args)} becomes: ! ! \begin{verbatim} ! def f(): ... ! _deco = C(args) ! f = _deco(B(A(f))) ! \end{verbatim} ! ! Getting this right can be slightly brain-bending, but it's not too ! difficult. ! ! The new syntax was provisionally added in 2.4alpha2, and is subject to ! change during the 2.4alpha release cycle depending on the Python ! community's reaction. Post-2.4 versions of Python will preserve ! compatibility with whatever syntax is used in 2.4final. \begin{seealso} \seepep{318}{Decorators for Functions, Methods and Classes}{Written ! by Kevin D. Smith, Jim Jewett, and Skip Montanaro. Several people ! wrote patches implementing function decorators, but the one that was ! actually checked in was patch #979728, written by Mark Russell.} \end{seealso} From mwh at users.sourceforge.net Mon Aug 2 16:50:48 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon Aug 2 16:50:52 2004 Subject: [Python-checkins] python/dist/src/Python ceval.c,2.411,2.412 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22346/Python Modified Files: ceval.c Log Message: Fix for the unfortunate fact that PyDict_GetItem and PyObject_GetItem have differing refcount semantics. If anyone sees a prettier way to acheive the same ends, then please go for it. I think this is the first time I've ever used Py_XINCREF. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.411 retrieving revision 2.412 diff -C2 -d -r2.411 -r2.412 *** ceval.c 2 Aug 2004 08:30:07 -0000 2.411 --- ceval.c 2 Aug 2004 14:50:43 -0000 2.412 *************** *** 1743,1748 **** break; } ! if (PyDict_CheckExact(v)) x = PyDict_GetItem(v, w); else { x = PyObject_GetItem(v, w); --- 1743,1750 ---- break; } ! if (PyDict_CheckExact(v)) { x = PyDict_GetItem(v, w); + Py_XINCREF(x); + } else { x = PyObject_GetItem(v, w); *************** *** 1764,1769 **** } } } - Py_INCREF(x); PUSH(x); continue; --- 1766,1771 ---- } } + Py_INCREF(x); } PUSH(x); continue; From akuchling at users.sourceforge.net Mon Aug 2 16:54:19 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Aug 2 16:54:22 2004 Subject: [Python-checkins] python/dist/src/Lib posixpath.py,1.69,1.70 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23145 Modified Files: posixpath.py Log Message: Use isabs() in conditional, not abspath Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** posixpath.py 18 Jul 2004 06:14:41 -0000 1.69 --- posixpath.py 2 Aug 2004 14:54:16 -0000 1.70 *************** *** 432,436 **** # Resolve where the link points to resolved = os.readlink(path) ! if not abspath(resolved): dir = dirname(path) path = normpath(join(dir, resolved)) --- 432,436 ---- # Resolve where the link points to resolved = os.readlink(path) ! if not isabs(resolved): dir = dirname(path) path = normpath(join(dir, resolved)) From akuchling at users.sourceforge.net Mon Aug 2 16:57:49 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Aug 2 16:57:53 2004 Subject: [Python-checkins] python/dist/src/Lib posixpath.py, 1.62.6.3, 1.62.6.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23643 Modified Files: Tag: release23-maint posixpath.py Log Message: Use isabs() in conditional, not abspath Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.62.6.3 retrieving revision 1.62.6.4 diff -C2 -d -r1.62.6.3 -r1.62.6.4 *** posixpath.py 11 Jul 2004 19:17:38 -0000 1.62.6.3 --- posixpath.py 2 Aug 2004 14:57:47 -0000 1.62.6.4 *************** *** 435,439 **** # Resolve where the link points to resolved = os.readlink(path) ! if not abspath(resolved): dir = dirname(path) path = normpath(join(dir, resolved)) --- 435,439 ---- # Resolve where the link points to resolved = os.readlink(path) ! if not isabs(resolved): dir = dirname(path) path = normpath(join(dir, resolved)) From fdrake at users.sourceforge.net Mon Aug 2 19:58:53 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Aug 2 19:58:57 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils fancy_getopt.py, 1.28, 1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24629 Modified Files: fancy_getopt.py Log Message: - fix description of option table entries - fix broken assert statement; should just raise Index: fancy_getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/fancy_getopt.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** fancy_getopt.py 12 Feb 2004 17:35:08 -0000 1.28 --- fancy_getopt.py 2 Aug 2004 17:58:51 -0000 1.29 *************** *** 46,51 **** def __init__ (self, option_table=None): ! # The option table is (currently) a list of 3-tuples: ! # (long_option, short_option, help_string) # if an option takes an argument, its long_option should have '=' # appended; short_option should just be a single character, no ':' --- 46,52 ---- def __init__ (self, option_table=None): ! # The option table is (currently) a list of tuples. The ! # tuples may have 3 or four values: ! # (long_option, short_option, help_string [, repeatable]) # if an option takes an argument, its long_option should have '=' # appended; short_option should just be a single character, no ':' *************** *** 163,167 **** # the option table is part of the code, so simply # assert that it is correct ! assert "invalid option tuple: %r" % (option,) # Type- and value-check the option names --- 164,168 ---- # the option table is part of the code, so simply # assert that it is correct ! raise ValueError, "invalid option tuple: %r" % (option,) # Type- and value-check the option names From fdrake at users.sourceforge.net Mon Aug 2 23:39:14 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Aug 2 23:39:17 2004 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.78,1.79 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9863 Modified Files: dist.tex Log Message: start filling in documentation on extending distutils Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** dist.tex 18 Jun 2004 17:31:23 -0000 1.78 --- dist.tex 2 Aug 2004 21:39:11 -0000 1.79 *************** *** 1888,1893 **** ! %\chapter{Extending the Distutils} ! %\label{extending} --- 1888,1911 ---- ! \chapter{Extending Distutils \label{extending}} ! ! Distutils can be extended in various ways. Most extensions take the ! form of new commands or replacements for existing commands. New ! commands may be written to support new types of platform-specific ! packaging, for example, while replacements for existing commands may ! be made to modify details of how the command operates on a package. ! ! Most extensions of the distutils are made within \file{setup.py} ! scripts that want to modify existing commands; many simply add a few ! file extensions that should be copied into packages in addition to ! \file{.py} files as a convenience. ! ! Most distutils command implementations are subclasses of the ! \class{Command} class from \refmodule{distutils.cmd}. New commands ! may directly inherit from \class{Command}, while replacements often ! derive from \class{Command} indirectly, directly subclassing the ! command they are replacing. Commands are not required to derive from ! \class{Command}, but must implement the interface documented as part ! of that class. *************** *** 1901,1904 **** --- 1919,1950 ---- %\XXX{Would an uninstall command be a good example here?} + \section{Integrating new commands} + + There are different ways to integrate new command implementations into + distutils. The most difficult is to lobby for the inclusion of the + new features in distutils itself, and wait for (and require) a version + of Python that provides that support. This is really hard for many + reasons. + + The most common, and possibly the most reasonable for most needs, is + to include the new implementations with your \file{setup.py} script, + and cause the \function{distutils.core.setup()} function use them: + + \begin{verbatim} + from distutils.command.build_py import build_py as _build_py + from distutils.core import setup + + class build_py(_build_py): + """Specialized Python source builder.""" + + # implement whatever needs to be different... + + setup(cmdclass={'build_py': build_py}, + ...) + \end{verbatim} + + This approach is most valuable if the new implementations must be used + to use a particular package, as everyone interested in the package + will need to have the new command implementation. From fdrake at users.sourceforge.net Mon Aug 2 23:50:29 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Aug 2 23:50:31 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.79, 1.80 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11906 Modified Files: whatsnew24.tex Log Message: fix markup error Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** whatsnew24.tex 2 Aug 2004 13:48:18 -0000 1.79 --- whatsnew24.tex 2 Aug 2004 21:50:26 -0000 1.80 *************** *** 318,322 **** by Kevin D. Smith, Jim Jewett, and Skip Montanaro. Several people wrote patches implementing function decorators, but the one that was ! actually checked in was patch #979728, written by Mark Russell.} \end{seealso} --- 318,322 ---- by Kevin D. Smith, Jim Jewett, and Skip Montanaro. Several people wrote patches implementing function decorators, but the one that was ! actually checked in was patch \#979728, written by Mark Russell.} \end{seealso} From nnorwitz at users.sourceforge.net Mon Aug 2 23:56:35 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Mon Aug 2 23:56:38 2004 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.51,1.52 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12735/Doc/api Modified Files: concrete.tex Log Message: Fix typo though Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** concrete.tex 2 Aug 2004 08:36:07 -0000 1.51 --- concrete.tex 2 Aug 2004 21:56:33 -0000 1.52 *************** *** 2826,2830 **** \begin{cfuncdesc}{int}{PyDateTime_DATE_GET_HOUR}{PyDateTime_DateTime *o} ! Return the hour, an int from 0 though 23. \versionadded{2.4} \end{cfuncdesc} --- 2826,2830 ---- \begin{cfuncdesc}{int}{PyDateTime_DATE_GET_HOUR}{PyDateTime_DateTime *o} ! Return the hour, as an int from 0 through 23. \versionadded{2.4} \end{cfuncdesc} *************** *** 2850,2854 **** \begin{cfuncdesc}{int}{PyDateTime_TIME_GET_HOUR}{PyDateTime_Time *o} ! Return the hour, as an int from 0 though 23. \versionadded{2.4} \end{cfuncdesc} --- 2850,2854 ---- \begin{cfuncdesc}{int}{PyDateTime_TIME_GET_HOUR}{PyDateTime_Time *o} ! Return the hour, as an int from 0 through 23. \versionadded{2.4} \end{cfuncdesc} From edloper at users.sourceforge.net Tue Aug 3 00:07:15 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Tue Aug 3 00:07:19 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.36,1.36.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14877 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Reorganization of doctest module, to give a more pluggable architecture: - Defined 4 new classes: - Example: a pair, plus an intra-docstring line number. - DocTest: a collection of examples, parsed from a docstring, plus info about where the docstring came from (name, filename, lineno). - DocTestFinder: extracts DocTests from a given object's docstring and its contained objects' docstrings. - DocTestRunner: runs DocTest cases, and accumulates statistics. - Removed code duplication - Redefined Tester, testmod(), and run_docstring_examples(), to use the 4 new classes - Added several new options for comparison & output - When looking for objects to test, don't explore the same object twice - Better exception handling: handle output that occurs before the exception, and handle multi-line exception messages. - Support for running tests on text files Note: the debugging code is currently broken. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36 retrieving revision 1.36.2.1 diff -C2 -d -r1.36 -r1.36.2.1 *** doctest.py 14 Jul 2004 19:06:50 -0000 1.36 --- doctest.py 2 Aug 2004 22:07:11 -0000 1.36.2.1 *************** *** 5,8 **** --- 5,9 ---- # Provided as-is; use at your own risk; no warranty; no promises; enjoy! + # [XX] This docstring is out-of-date: r"""Module doctest -- a framework for running examples in docstrings. *************** *** 286,564 **** __all__ = [ [...2508 lines suppressed...] + x + Traceback (most recent call last): + [...] + ValueError: + foo + + """ + + def _test(): + #import doctest + #doctest.testmod(doctest, verbose=False, + # optionflags=ELLIPSIS | NORMALIZE_WHITESPACE | + # UNIFIED_DIFF) + #print '~'*70 + r = unittest.TextTestRunner() + r.run(DocTestSuite())#optionflags=ELLIPSIS | NORMALIZE_WHITESPACE | + # UNIFIED_DIFF)) + if __name__ == "__main__": _test() From edloper at users.sourceforge.net Tue Aug 3 00:08:56 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Tue Aug 3 00:08:59 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.5, 1.5.18.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15164/test Modified Files: Tag: tim-doctest-branch test_doctest.py Log Message: - Added test cases for Example - Added test cases for DocTest - Added test cases for DocTestFinder Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.5 retrieving revision 1.5.18.1 diff -C2 -d -r1.5 -r1.5.18.1 *** test_doctest.py 23 Jul 2002 19:03:50 -0000 1.5 --- test_doctest.py 2 Aug 2004 22:08:53 -0000 1.5.18.1 *************** *** 1,3 **** ! import doctest from test import test_support ! test_support.run_doctest(doctest) --- 1,332 ---- ! """ ! Test script for doctest. ! """ ! from test import test_support ! import doctest ! ! def test_Example(): r""" ! Unit tests for the `Example` class. ! ! Example is a simple container class that holds a source code string, ! an expected output string, and a line number (within the docstring): ! ! >>> example = doctest.Example('print 1', '1\n', 0) ! >>> (example.source, example.want, example.lineno) ! ('print 1', '1\n', 0) ! ! The `source` string should end in a newline iff the source spans more ! than one line: ! ! >>> # Source spans a single line: no terminating newline. ! >>> e = doctest.Example('print 1', '1\n', 0) ! >>> e = doctest.Example('print 1\n', '1\n', 0) ! Traceback (most recent call last): ! AssertionError ! ! >>> # Source spans multiple lines: require terminating newline. ! >>> e = doctest.Example('print 1;\nprint 2\n', '1\n2\n', 0) ! >>> e = doctest.Example('print 1;\nprint 2', '1\n2\n', 0) ! Traceback (most recent call last): ! AssertionError ! ! The `want` string should be terminated by a newline, unless it's the ! empty string: ! ! >>> e = doctest.Example('print 1', '1\n', 0) ! >>> e = doctest.Example('print 1', '1', 0) ! Traceback (most recent call last): ! AssertionError ! >>> e = doctest.Example('print', '', 0) ! """ ! ! def test_DocTest(): r""" ! Unit tests for the `DocTest` class. ! ! DocTest is a collection of examples, extracted from a docstring, along ! with information about where the docstring comes from (a name, ! filename, and line number). The docstring is parsed by the `DocTest` ! constructor: ! ! >>> docstring = ''' ! ... >>> print 12 ! ... 12 ! ... ! ... Non-example text. ! ... ! ... >>> print 'another\example' ! ... another ! ... example ! ... ''' ! >>> test = doctest.DocTest(docstring, 'some_test', 'some_file', 20) ! >>> print test ! ! >>> len(test.examples) ! 2 ! >>> e1, e2 = test.examples ! >>> (e1.source, e1.want, e1.lineno) ! ('print 12', '12\n', 1) ! >>> (e2.source, e2.want, e2.lineno) ! ("print 'another\\example'", 'another\nexample\n', 6) ! ! Source information (name, filename, and line number) is available as ! attributes on the doctest object: ! ! >>> (test.name, test.filename, test.lineno) ! ('some_test', 'some_file', 20) ! ! The line number of an example within its containing file is found by ! adding the line number of the example and the line number of its ! containing test: ! ! >>> test.lineno + e1.lineno ! 21 ! >>> test.lineno + e2.lineno ! 26 ! ! If the docstring contains inconsistant leading whitespace in the ! expected output of an example, then `DocTest` will raise a ValueError: ! ! >>> docstring = r''' ! ... >>> print 'bad\nindentation' ! ... bad ! ... indentation ! ... ''' ! >>> doctest.DocTest(docstring, 'some_test', 'filename', 0) ! Traceback (most recent call last): ! ValueError: line 3 of the docstring for some_test has inconsistent leading whitespace: ' indentation' ! ! If the docstring contains inconsistent leading whitespace on ! continuation lines, then `DocTest` will raise a ValueError: ! ! >>> docstring = r''' ! ... >>> print ('bad indentation', ! ... ... 2) ! ... ('bad', 'indentation') ! ... ''' ! >>> doctest.DocTest(docstring, 'some_test', 'filename', 0) ! Traceback (most recent call last): ! ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: ' ... 2)' ! ! If there's no blnak space after a PS1 prompt ('>>>'), then `DocTest` ! will raise a ValueError: ! ! >>> docstring = '>>>print 1\n1' ! >>> doctest.DocTest(docstring, 'some_test', 'filename', 0) ! Traceback (most recent call last): ! ValueError: line 0 of the docstring for some_test lacks blanks after >>>: '>>>print 1' ! """ ! ! def test_DocTestFinder(): r""" ! Unit tests for the `DocTestFinder` class. ! ! DocTestFinder is used to extract DocTests from an object's docstring ! and the docstrings of its contained objects. It can be used with ! modules, functions, classes, methods, staticmethods, classmethods, and ! properties. ! ! For a function whose docstring contains examples, DocTestFinder.find() ! will return a single test (for that function's docstring): ! ! >>> # Functions: ! >>> def double(v): ! ... ''' ! ... >>> print double(22) ! ... 44 ! ... ''' ! ... return v+v ! ! >>> finder = doctest.DocTestFinder() ! >>> tests = finder.find(double) ! >>> print tests ! [] ! >>> e = tests[0].examples[0] ! >>> print (e.source, e.want, e.lineno) ! ('print double(22)', '44\n', 1) ! ! If an object has no docstring, then a test is not created for it: ! ! >>> def no_docstring(v): ! ... pass ! >>> finder.find(no_docstring) ! [] ! ! If the function has a docstring with no examples, then a test with no ! examples is returned. (This lets `DocTestRunner` collect statistics ! about which functions have no tests -- but is that useful? And should ! an empty test also be created when there's no docstring?) ! ! >>> def no_examples(v): ! ... ''' no doctest examples ''' ! >>> finder.find(no_examples) ! [] ! ! For a class, DocTestFinder will create a test for the class's ! docstring, and will recursively explore its contents, including ! methods, classmethods, staticmethods, properties, and nested classes. ! ! >>> # A class: ! >>> class X: ! ... ''' ! ... >>> print 1 ! ... 1 ! ... ''' ! ... def __init__(self, val): ! ... ''' ! ... >>> print X(12).get() ! ... 12 ! ... ''' ! ... self.val = val ! ... ! ... def double(self): ! ... ''' ! ... >>> print X(12).double().get() ! ... 24 ! ... ''' ! ... return X(self.val + self.val) ! ... ! ... def get(self): ! ... ''' ! ... >>> print X(-5).get() ! ... -5 ! ... ''' ! ... return self.val ! ... ! ... def a_staticmethod(v): ! ... ''' ! ... >>> print X.a_staticmethod(10) ! ... 11 ! ... ''' ! ... return v+1 ! ... a_staticmethod = staticmethod(a_staticmethod) ! ... ! ... def a_classmethod(cls, v): ! ... ''' ! ... >>> print X.a_classmethod(10) ! ... 12 ! ... >>> print X(0).a_classmethod(10) ! ... 12 ! ... ''' ! ... return v+2 ! ... a_classmethod = classmethod(a_classmethod) ! ... ! ... a_property = property(get, doc=''' ! ... >>> print x(22).a_property ! ... 22 ! ... ''') ! ... ! ... class NestedClass: ! ... ''' ! ... >>> x = X.NestedClass(5) ! ... >>> y = x.square() ! ... >>> print y.get() ! ... 25 ! ... ''' ! ... def __init__(self, val=0): ! ... ''' ! ... >>> print X.NestedClass().get() ! ... 0 ! ... ''' ! ... self.val = val ! ... def square(self): ! ... X.NestedClass(self.val*self.val) ! ... def get(self): ! ... return self.val ! ! >>> finder = doctest.DocTestFinder() ! >>> tests = finder.find(X) ! >>> tests.sort() ! >>> for t in tests: ! ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) ! None 1 X ! None 3 X.NestedClass ! 96 1 X.NestedClass.__init__ ! 7 1 X.__init__ ! 40 2 X.a_classmethod ! None 1 X.a_property ! 40 1 X.a_staticmethod ! 40 1 X.double ! 40 1 X.get ! ! For a module, DocTestFinder will create a test for the class's ! docstring, and will recursively explore its contents, including ! functions, classes, and the `__test__` dictionary, if it exists: ! ! >>> # A module ! >>> import new ! >>> m = new.module('some_module') ! >>> def triple(val): ! ... ''' ! ... >>> print tripple(11) ! ... 33 ! ... ''' ! ... return val*3 ! >>> m.__dict__.update({ ! ... 'double': double, ! ... 'X': X, ! ... '__doc__': ''' ! ... Module docstring. ! ... >>> print 'module' ! ... module ! ... ''', ! ... '__test__': { ! ... 'd': '>>> print 6\n6\n>>> print 7\n7\n', ! ... 'c': triple}}) ! ! >>> finder = doctest.DocTestFinder() ! >>> # The '(None)' is to prevent it from filtering out objects ! >>> # that were not defined in module m. ! >>> tests = finder.find(m, module='(None)') ! >>> tests.sort() ! >>> for t in tests: ! ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) ! 1 1 some_module ! None 1 some_module.X ! None 3 some_module.X.NestedClass ! 57 1 some_module.X.NestedClass.__init__ ! 6 1 some_module.X.__init__ ! 35 2 some_module.X.a_classmethod ! None 1 some_module.X.a_property ! 27 1 some_module.X.a_staticmethod ! 13 1 some_module.X.double ! 20 1 some_module.X.get ! 1 1 some_module.c ! None 2 some_module.d ! 1 1 some_module.double ! ! If a single object is listed twice (under different names), then tests ! will only be generated for it once: ! ! >>> class TwoNames: ! ... def f(self): ! ... ''' ! ... >>> print TwoNames().f() ! ... f ! ... ''' ! ... return 'f' ! ... ! ... g = f # define an alias for f. ! ! >>> finder = doctest.DocTestFinder() ! >>> tests = finder.find(TwoNames) ! >>> print len(tests) ! 1 ! >>> print tests[0].name in ('TwoNames.f', 'TwoNames.g') ! True ! ! ! ! ! """ ! ! def test_main(): ! # Check the doctest cases in doctest itself: ! test_support.run_doctest(doctest) ! # Check the doctest cases defined here: ! from test import test_doctest ! test_support.run_doctest(test_doctest, verbosity=0) ! ! if __name__ == '__main__': ! test_main() ! ! From fdrake at users.sourceforge.net Tue Aug 3 01:05:27 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 01:05:30 2004 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.79,1.80 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26193 Modified Files: dist.tex Log Message: fix a little lie ;-( Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** dist.tex 2 Aug 2004 21:39:11 -0000 1.79 --- dist.tex 2 Aug 2004 23:05:25 -0000 1.80 *************** *** 1905,1911 **** may directly inherit from \class{Command}, while replacements often derive from \class{Command} indirectly, directly subclassing the ! command they are replacing. Commands are not required to derive from ! \class{Command}, but must implement the interface documented as part ! of that class. --- 1905,1910 ---- may directly inherit from \class{Command}, while replacements often derive from \class{Command} indirectly, directly subclassing the ! command they are replacing. Commands are required to derive from ! \class{Command}. From kenny at selectcomputer.net Tue Aug 3 02:05:28 2004 From: kenny at selectcomputer.net (Sales) Date: Tue Aug 3 02:05:29 2004 Subject: [Python-checkins] re: Disk Drives Message-ID: <20040803000528.776E21E4002@bag.python.org> 16n We specialize in HP 9000 Drives, Seagate scsi and Fiber Channel drives. We also carry a wide variety of Dlt, LTO and tape drives. We stock a large inventory of drives and other storage related products. We have many end of life and hard to find products in stock. If you don't see something on our web page please email us or call us. We probably have it in stock. -At Select Computer Technology we strive for excellence in customer relations. We service a variety of customers ranging from the home user to government and fortune 500 companies. We will always beat competitor prices. We encourage you to price match us. We specialize in SCSI, IDE and Tape Backup storage. Are you trying to find a drive that is not made anymore (we can help) We deal in old and new technology. Check out our products page for current pricing and then see if our pricing stacks up against the rest. Please let us know if you have any disk drives or tape drives for sale. We are always looking to purchase storage components. Our prices will not be beat for scsi or ide disk drives or tape drives. Please let us know if we can help you with any storage quotes. We carry a wide variety of drives for HP, SUN, IBM, DELL, and Macs. CURRENT SPECIALS SEAGATE ST150176LC 50.1GB 7200 RPM 80 PIN DRIVE $48.00 EACH 2 YEAR WARRANTY SEAGATE ST118202LC 18.2GB 10,000 RPM 80 PIN DRIVE $14.00 EACH 90 DAY WARRANTY SEAGATE FIBER CHANNEL 36GB NEW 5 YEAR WARRANTY $42.00 EACH Ask about are drives for macs and HP systems We are authorized resellers of the following brands HP, SEAGATE, QUANTUM, IBM, A3629A, HP, HP , HP SEAGATE, SEAGATE, HP ,SEAGATE, HP, SEAGATE, HP 9000, HPUX, SEAGATE SCSI, SEAGATE, CHEAP DRIVES, CHEAP DRIVES, #1 SCSI SOURCE. Contact info Kenny Becker Select Computer Technlogy, 774 Charcot ave, San Jose, CA, 95131 Tel 425-443-8062 Fax 408-944-9476 If you wish to be removed please put remove in the subject line and reply back. It is not our intent to spam anyone -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20040802/5944c5fa/attachment.htm From pennycaffrey at gotpaintball.com Tue Aug 3 01:50:37 2004 From: pennycaffrey at gotpaintball.com (eduardo dickhaut) Date: Tue Aug 3 02:59:49 2004 Subject: [Python-checkins] Sub: news today...fountain of youth Message-ID: <4e7501c478eb$823d9c60$a8616d5a@pennycaffrey> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20040803/81ac0e3c/attachment.html From tim_one at users.sourceforge.net Tue Aug 3 05:38:02 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 3 05:38:06 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.5.18.1, 1.5.18.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2145/Lib/test Modified Files: Tag: tim-doctest-branch test_doctest.py Log Message: Update attributions; whitespace normalization. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.5.18.1 retrieving revision 1.5.18.2 diff -C2 -d -r1.5.18.1 -r1.5.18.2 *** test_doctest.py 2 Aug 2004 22:08:53 -0000 1.5.18.1 --- test_doctest.py 3 Aug 2004 03:37:59 -0000 1.5.18.2 *************** *** 24,28 **** Traceback (most recent call last): AssertionError ! >>> # Source spans multiple lines: require terminating newline. >>> e = doctest.Example('print 1;\nprint 2\n', '1\n2\n', 0) --- 24,28 ---- Traceback (most recent call last): AssertionError ! >>> # Source spans multiple lines: require terminating newline. >>> e = doctest.Example('print 1;\nprint 2\n', '1\n2\n', 0) *************** *** 136,140 **** ... ''' ... return v+v ! >>> finder = doctest.DocTestFinder() >>> tests = finder.find(double) --- 136,140 ---- ... ''' ... return v+v ! >>> finder = doctest.DocTestFinder() >>> tests = finder.find(double) *************** *** 151,160 **** >>> finder.find(no_docstring) [] ! If the function has a docstring with no examples, then a test with no examples is returned. (This lets `DocTestRunner` collect statistics about which functions have no tests -- but is that useful? And should an empty test also be created when there's no docstring?) ! >>> def no_examples(v): ... ''' no doctest examples ''' --- 151,160 ---- >>> finder.find(no_docstring) [] ! If the function has a docstring with no examples, then a test with no examples is returned. (This lets `DocTestRunner` collect statistics about which functions have no tests -- but is that useful? And should an empty test also be created when there's no docstring?) ! >>> def no_examples(v): ... ''' no doctest examples ''' *************** *** 273,277 **** ... 'd': '>>> print 6\n6\n>>> print 7\n7\n', ... 'c': triple}}) ! >>> finder = doctest.DocTestFinder() >>> # The '(None)' is to prevent it from filtering out objects --- 273,277 ---- ... 'd': '>>> print 6\n6\n>>> print 7\n7\n', ... 'c': triple}}) ! >>> finder = doctest.DocTestFinder() >>> # The '(None)' is to prevent it from filtering out objects *************** *** 316,320 **** ! """ --- 316,320 ---- ! """ *************** *** 329,332 **** if __name__ == '__main__': test_main() - - --- 329,330 ---- From tim_one at users.sourceforge.net Tue Aug 3 05:38:02 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 3 05:38:07 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.36.2.1,1.36.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2145/Lib Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Update attributions; whitespace normalization. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.1 retrieving revision 1.36.2.2 diff -C2 -d -r1.36.2.1 -r1.36.2.2 *** doctest.py 2 Aug 2004 22:07:11 -0000 1.36.2.1 --- doctest.py 3 Aug 2004 03:37:59 -0000 1.36.2.2 *************** *** 1,5 **** # Module doctest. ! # Released to the public domain 16-Jan-2001, ! # by Tim Peters (tim.one@home.com). # Provided as-is; use at your own risk; no warranty; no promises; enjoy! --- 1,7 ---- # Module doctest. ! # Released to the public domain 16-Jan-2001, by Tim Peters (tim@python.org). ! # Significant enhancements by: ! # Jim Fulton ! # Edward Loper # Provided as-is; use at your own risk; no warranty; no promises; enjoy! *************** *** 403,407 **** # What string should we use to indent contents? INDENT = ' ' ! # If the message doesn't end in a newline, then add one. if msg[-1:] != '\n': --- 405,409 ---- # What string should we use to indent contents? INDENT = ' ' ! # If the message doesn't end in a newline, then add one. if msg[-1:] != '\n': *************** *** 435,445 **** A single doctest example, consisting of source code and expected output. Example defines the following attributes: ! - source: The source code that should be run. It ends with a newline iff the source spans more than one line. ! - want: The expected output from running the source code. If not empty, then this string ends with a newline. ! - lineno: The line number within the DocTest string containing this Example where the Example begins. This line number is --- 437,447 ---- A single doctest example, consisting of source code and expected output. Example defines the following attributes: ! - source: The source code that should be run. It ends with a newline iff the source spans more than one line. ! - want: The expected output from running the source code. If not empty, then this string ends with a newline. ! - lineno: The line number within the DocTest string containing this Example where the Example begins. This line number is *************** *** 459,471 **** A collection of doctest examples that should be run in a single namespace. Each DocTest defines the following attributes: ! - examples: the list of examples. ! - name: A name identifying the DocTest (typically, the name of the object whose docstring this DocTest was extracted from). ! - filename: The name of the file that this DocTest was extracted from. ! - lineno: The line number within filename where this DocTest begins. This line number is zero-based, with respect to the --- 461,473 ---- A collection of doctest examples that should be run in a single namespace. Each DocTest defines the following attributes: ! - examples: the list of examples. ! - name: A name identifying the DocTest (typically, the name of the object whose docstring this DocTest was extracted from). ! - filename: The name of the file that this DocTest was extracted from. ! - lineno: The line number within filename where this DocTest begins. This line number is zero-based, with respect to the *************** *** 513,517 **** 'blanks after %s: %r' % (lineno, self.name, self._PS1, line)) ! j = j + 1 blanks = m.group(1) --- 515,519 ---- 'blanks after %s: %r' % (lineno, self.name, self._PS1, line)) ! j = j + 1 blanks = m.group(1) *************** *** 556,560 **** examples.append(Example(source, want, lineno)) return examples ! def __repr__(self): if len(self.examples) == 0: --- 558,562 ---- examples.append(Example(source, want, lineno)) return examples ! def __repr__(self): if len(self.examples) == 0: *************** *** 566,570 **** return ('' % (self.name, self.filename, self.lineno, examples)) ! # This lets us sort tests by name: --- 568,572 ---- return ('' % (self.name, self.filename, self.lineno, examples)) ! # This lets us sort tests by name: *************** *** 573,583 **** return cmp((self.name, self.filename, self.lineno, id(self)), (other.name, other.filename, other.lineno, id(other))) ! ###################################################################### ## 3. DocTest Finder ###################################################################### ! class DocTestFinder: ! """ A class used to extract the DocTests that are relevant to a given object, from its docstring and the docstrings of its contained --- 575,585 ---- return cmp((self.name, self.filename, self.lineno, id(self)), (other.name, other.filename, other.lineno, id(other))) ! ###################################################################### ## 3. DocTest Finder ###################################################################### ! class DocTestFinder: ! """ A class used to extract the DocTests that are relevant to a given object, from its docstring and the docstrings of its contained *************** *** 599,603 **** `__test__` dictionary. By default, no objects are ignored. """ ! def __init__(self, verbose=False, namefilter=None, objfilter=None, recurse=True): --- 601,605 ---- `__test__` dictionary. By default, no objects are ignored. """ ! def __init__(self, verbose=False, namefilter=None, objfilter=None, recurse=True): *************** *** 612,616 **** self._objfilter = objfilter self._recurse = recurse ! def find(self, obj, name=None, module=None): """ --- 614,618 ---- self._objfilter = objfilter self._recurse = recurse ! def find(self, obj, name=None, module=None): """ *************** *** 644,648 **** if module == '(None)': module = None ! # Read the module's source code. This is used by # DocTestFinder._find_lineno to find the line number for a --- 646,650 ---- if module == '(None)': module = None ! # Read the module's source code. This is used by # DocTestFinder._find_lineno to find the line number for a *************** *** 697,701 **** if id(obj) in seen: return seen[id(obj)] = 1 ! # Find a test for this object, and add it to the list of tests. test = self._get_test(obj, name, module, source_lines) --- 699,703 ---- if id(obj) in seen: return seen[id(obj)] = 1 ! # Find a test for this object, and add it to the list of tests. test = self._get_test(obj, name, module, source_lines) *************** *** 731,735 **** valname = '%s.%s' % (name, valname) self._find(tests, val, valname, module, source_lines, seen) ! # Look for tests in a class's contained objects. if inspect.isclass(obj) and self._recurse: --- 733,737 ---- valname = '%s.%s' % (name, valname) self._find(tests, val, valname, module, source_lines, seen) ! # Look for tests in a class's contained objects. if inspect.isclass(obj) and self._recurse: *************** *** 790,794 **** if inspect.ismodule(obj): lineno = 0 ! # Find the line number for classes. # Note: this could be fooled if a class is defined multiple --- 792,796 ---- if inspect.ismodule(obj): lineno = 0 ! # Find the line number for classes. # Note: this could be fooled if a class is defined multiple *************** *** 825,829 **** # We couldn't find the line number. return None ! ###################################################################### ## 4. DocTest Runner --- 827,831 ---- # We couldn't find the line number. return None ! ###################################################################### ## 4. DocTest Runner *************** *** 852,856 **** have been run by the runner, and returns an aggregated `(f, t)` tuple: ! >>> runner.summarize(verbose=1) 4 items passed all tests: --- 854,858 ---- have been run by the runner, and returns an aggregated `(f, t)` tuple: ! >>> runner.summarize(verbose=1) 4 items passed all tests: *************** *** 935,942 **** information about option flags. """ ! # Handle the common case first, for efficiency: # if they're string-identical, always return true. if got == want: return True ! # The values True and False replaced 1 and 0 as the return # value for boolean comparisons in Python 2.3. --- 937,944 ---- information about option flags. """ ! # Handle the common case first, for efficiency: # if they're string-identical, always return true. if got == want: return True ! # The values True and False replaced 1 and 0 as the return # value for boolean comparisons in Python 2.3. *************** *** 951,955 **** '', want) if got == want: return True ! # This flag causes doctest to ignore any differences in the # contents of whitespace strings. Note that this can be used --- 953,957 ---- '', want) if got == want: return True ! # This flag causes doctest to ignore any differences in the # contents of whitespace strings. Note that this can be used *************** *** 959,963 **** want = ' '.join(want.split()) if got == want: return True ! # The ELLIPSIS flag says to let the sequence "..." in `want` # match any substring in `got`. We implement this by --- 961,965 ---- want = ' '.join(want.split()) if got == want: return True ! # The ELLIPSIS flag says to let the sequence "..." in `want` # match any substring in `got`. We implement this by *************** *** 973,977 **** # Check if the `want_re` regexp matches got. if re.match(want_re, got): return True ! # We didn't find any match; return false. return False --- 975,979 ---- # Check if the `want_re` regexp matches got. if re.match(want_re, got): return True ! # We didn't find any match; return false. return False *************** *** 981,985 **** Return a string describing the differences between the expected output (`want`) and the actual output (`got`). ! """ # Check if we should use diff. Don't use diff if the actual # or expected outputs are too short, or if the expected output --- 983,987 ---- Return a string describing the differences between the expected output (`want`) and the actual output (`got`). ! """ # Check if we should use diff. Don't use diff if the actual # or expected outputs are too short, or if the expected output *************** *** 1057,1061 **** def __failure_header(self, test, example): ! s = (self.DIVIDER + "\n" + _tag_msg("Failure in example", example.source)) if test.filename is None: --- 1059,1063 ---- def __failure_header(self, test, example): ! s = (self.DIVIDER + "\n" + _tag_msg("Failure in example", example.source)) if test.filename is None: *************** *** 1120,1124 **** # Extract the example's actual output from fakeout, and # write it to `got`. Add a terminating newline if it ! # doesn't have already one. got = self._fakeout.getvalue() self._fakeout.truncate(0) --- 1122,1126 ---- # Extract the example's actual output from fakeout, and # write it to `got`. Add a terminating newline if it ! # doesn't have already one. got = self._fakeout.getvalue() self._fakeout.truncate(0) *************** *** 1361,1365 **** using a context diff. """ ! """ [XX] This is no longer true: Advanced tomfoolery: testmod runs methods of a local instance of --- 1363,1367 ---- using a context diff. """ ! """ [XX] This is no longer true: Advanced tomfoolery: testmod runs methods of a local instance of *************** *** 1385,1389 **** if name is None: name = m.__name__ ! # If globals were not specified, then default to the module. if globs is None: --- 1387,1391 ---- if name is None: name = m.__name__ ! # If globals were not specified, then default to the module. if globs is None: *************** *** 1470,1474 **** if module is None: module = '(None)' return self.rundoc(m, name, module) ! def run__test__(self, d, name): import new --- 1472,1476 ---- if module is None: module = '(None)' return self.rundoc(m, name, module) ! def run__test__(self, d, name): import new *************** *** 1572,1576 **** if module is not None and filename is not None: raise ValueError('Specify module or filename, not both.') ! if test_finder is None: test_finder = DocTestFinder() --- 1574,1578 ---- if module is not None and filename is not None: raise ValueError('Specify module or filename, not both.') ! if test_finder is None: test_finder = DocTestFinder() *************** *** 1602,1606 **** filename = filename[:-1] test.filename = filename ! suite.addTest(DocTestTestCase(test_runner, test, globs, extraglobs, setUp, tearDown)) --- 1604,1608 ---- filename = filename[:-1] test.filename = filename ! suite.addTest(DocTestTestCase(test_runner, test, globs, extraglobs, setUp, tearDown)) *************** *** 1779,1783 **** # """, # "whitespace normalization": r""" ! # If the whitespace normalization flag is used, then # differences in whitespace are ignored. # >>> print range(30) --- 1781,1785 ---- # """, # "whitespace normalization": r""" ! # If the whitespace normalization flag is used, then # differences in whitespace are ignored. # >>> print range(30) *************** *** 1910,1914 **** Traceback (most recent call last): [...] ! ValueError: foo --- 1912,1916 ---- Traceback (most recent call last): [...] ! ValueError: foo *************** *** 1924,1928 **** r.run(DocTestSuite())#optionflags=ELLIPSIS | NORMALIZE_WHITESPACE | # UNIFIED_DIFF)) ! if __name__ == "__main__": _test() --- 1926,1930 ---- r.run(DocTestSuite())#optionflags=ELLIPSIS | NORMALIZE_WHITESPACE | # UNIFIED_DIFF)) ! if __name__ == "__main__": _test() From edloper at users.sourceforge.net Tue Aug 3 06:08:55 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Tue Aug 3 06:08:58 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.36.2.2,1.36.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5702 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: - Added support for "option directives", which can be used to control a doctest option from within a DocTest test case. - Removed a debug printf - Fixed blankline gimick to handle actual-output blank lines that contain only whitespace. - When displaying output differences, don't display in the output if the DONT_ACCEPT_BLANKLINE flag was used. - When displaying output differences for exceptions, include the exception header ("Traceback (...):") Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.2 retrieving revision 1.36.2.3 diff -C2 -d -r1.36.2.2 -r1.36.2.3 *** doctest.py 3 Aug 2004 03:37:59 -0000 1.36.2.2 --- doctest.py 3 Aug 2004 04:08:52 -0000 1.36.2.3 *************** *** 318,321 **** --- 318,330 ---- CONTEXT_DIFF = 1 << 5 + OPTIONFLAGS_BY_NAME = { + 'DONT_ACCEPT_TRUE_FOR_1': DONT_ACCEPT_TRUE_FOR_1, + 'DONT_ACCEPT_BLANKLINE': DONT_ACCEPT_BLANKLINE, + 'NORMALIZE_WHITESPACE': NORMALIZE_WHITESPACE, + 'ELLIPSIS': ELLIPSIS, + 'UNIFIED_DIFF': UNIFIED_DIFF, + 'CONTEXT_DIFF': CONTEXT_DIFF, + } + # Special string markers for use in `want` strings: BLANKLINE_MARKER = '' *************** *** 597,603 **** if the given object should be ignored. ! These filter functions are applied when examining the contents of ! a module or of a class, but not when examining a module's ! `__test__` dictionary. By default, no objects are ignored. """ --- 606,614 ---- if the given object should be ignored. ! Each object is ignored if either filter function returns true for ! that object. These filter functions are applied when examining ! the contents of a module or of a class, but not when examining a ! module's `__test__` dictionary. By default, no objects are ! ignored. """ *************** *** 694,698 **** if self._verbose: print 'Finding tests in %s' % name - print >>sys.stderr, 'Finding tests in %s' % name # If we've already processed this object, then ignore it. --- 705,708 ---- *************** *** 950,955 **** # blank line, unless the DONT_ACCEPT_BLANKLINE flag is used. if not (self._optionflags & DONT_ACCEPT_BLANKLINE): ! want = re.sub('(?m)^%s$' % re.escape(BLANKLINE_MARKER), '', want) if got == want: return True --- 960,969 ---- # blank line, unless the DONT_ACCEPT_BLANKLINE flag is used. if not (self._optionflags & DONT_ACCEPT_BLANKLINE): ! # Replace in want with a blank line. ! want = re.sub('(?m)^%s\s*?$' % re.escape(BLANKLINE_MARKER), '', want) + # If a line in got contains only spaces, then remove the + # spaces. + got = re.sub('(?m)^\s*?$', '', got) if got == want: return True *************** *** 1012,1016 **** # output followed by the actual output. But explicitly mark # blank lines in the actual output. ! got = re.sub('(?m)^$(?!\Z)', '', got) return (_tag_msg("Expected", want or "Nothing") + _tag_msg("Got", got)) --- 1026,1031 ---- # output followed by the actual output. But explicitly mark # blank lines in the actual output. ! if not (self._optionflags & DONT_ACCEPT_BLANKLINE): ! got = re.sub('(?m)^$(?!\Z)', '', got) return (_tag_msg("Expected", want or "Nothing") + _tag_msg("Got", got)) *************** *** 1085,1093 **** # starting with word characters after the "Traceback ...".) _EXCEPTION_RE = re.compile(('^(?P.*)' ! '^Traceback \((?:%s|%s)\):\s*$.*?' '^(?P\w+.*)') % ('most recent call last', 'innermost last'), re.MULTILINE | re.DOTALL) def __run(self, test, globs, compileflags, out): """ --- 1100,1132 ---- # starting with word characters after the "Traceback ...".) _EXCEPTION_RE = re.compile(('^(?P.*)' ! '^(?PTraceback \((?:%s|%s)\):)\s*$.*?' '^(?P\w+.*)') % ('most recent call last', 'innermost last'), re.MULTILINE | re.DOTALL) + _OPTION_DIRECTIVE_RE = re.compile('\s*doctest:\s*(?P[^#]*)') + + def __handle_directive(self, example): + """ + Check if the given example is actually a directive to doctest + (to turn an optionflag on or off; and if it is, then handle + the directive. + + Return true iff the example is actually a directive (and so + should not be executed). + """ + m = self._OPTION_DIRECTIVE_RE.match(example.source) + if m is None: return False + + for flag in m.group('flags').upper().split(): + if (flag[:1] not in '+-' or + flag[1:] not in OPTIONFLAGS_BY_NAME): + raise ValueError('Bad doctest option directive: '+flag) + if flag[0] == '+': + self._optionflags |= OPTIONFLAGS_BY_NAME[flag[1:]] + else: + self._optionflags &= ~OPTIONFLAGS_BY_NAME[flag[1:]] + return True + def __run(self, test, globs, compileflags, out): """ *************** *** 1103,1108 **** --- 1142,1157 ---- failures = tries = 0 + # Save the option flags (since doctest directives can be used + # to modify them). + original_optionflags = self._optionflags + # Process each example. for example in test.examples: + # Check if it's an option directive. If it is, then handle + # it, and go on to the next example. + if self.__handle_directive(example): + continue + + # Record that we started this example. tries += 1 self.report_start(out, test, example) *************** *** 1150,1153 **** --- 1199,1203 ---- failures += 1 else: + exc_hdr = m.group('hdr')+'\n' # Exception header # The test passes iff the pre-exception output and # the exception description match the values given *************** *** 1156,1164 **** self.check_output(m.group('exc'), exc_msg)): # Is +exc_msg the right thing here?? ! self.report_success(out, test, example, got+exc_msg) else: ! self.report_failure(out, test, example, got+exc_msg) failures += 1 # Record and return the number of failures and tries. self.__record_outcome(test, failures, tries) --- 1206,1219 ---- self.check_output(m.group('exc'), exc_msg)): # Is +exc_msg the right thing here?? ! self.report_success(out, test, example, ! got+exc_hdr+exc_msg) else: ! self.report_failure(out, test, example, ! got+exc_hdr+exc_msg) failures += 1 + # Restore the option flags (in case they were modified) + self._optionflags = original_optionflags + # Record and return the number of failures and tries. self.__record_outcome(test, failures, tries) *************** *** 1912,1916 **** Traceback (most recent call last): [...] ! ValueError: foo --- 1967,1971 ---- Traceback (most recent call last): [...] ! ValueError: foo *************** *** 1924,1929 **** #print '~'*70 r = unittest.TextTestRunner() ! r.run(DocTestSuite())#optionflags=ELLIPSIS | NORMALIZE_WHITESPACE | ! # UNIFIED_DIFF)) if __name__ == "__main__": --- 1979,1983 ---- #print '~'*70 r = unittest.TextTestRunner() ! r.run(DocTestSuite()) if __name__ == "__main__": From edloper at users.sourceforge.net Tue Aug 3 06:09:54 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Tue Aug 3 06:09:57 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.5.18.2, 1.5.18.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5898/test Modified Files: Tag: tim-doctest-branch test_doctest.py Log Message: Added new test cases for DocTestFinder and DocTestRunner. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.5.18.2 retrieving revision 1.5.18.3 diff -C2 -d -r1.5.18.2 -r1.5.18.3 *** test_doctest.py 3 Aug 2004 03:37:59 -0000 1.5.18.2 --- test_doctest.py 3 Aug 2004 04:09:51 -0000 1.5.18.3 *************** *** 126,129 **** --- 126,131 ---- properties. + Finding Tests in Functions + ~~~~~~~~~~~~~~~~~~~~~~~~~~ For a function whose docstring contains examples, DocTestFinder.find() will return a single test (for that function's docstring): *************** *** 162,165 **** --- 164,169 ---- [] + Finding Tests in Classes + ~~~~~~~~~~~~~~~~~~~~~~~~ For a class, DocTestFinder will create a test for the class's docstring, and will recursively explore its contents, including *************** *** 167,171 **** >>> # A class: ! >>> class X: ... ''' ... >>> print 1 --- 171,175 ---- >>> # A class: ! >>> class A: ... ''' ... >>> print 1 *************** *** 174,178 **** ... def __init__(self, val): ... ''' ! ... >>> print X(12).get() ... 12 ... ''' --- 178,182 ---- ... def __init__(self, val): ... ''' ! ... >>> print A(12).get() ... 12 ... ''' *************** *** 181,192 **** ... def double(self): ... ''' ! ... >>> print X(12).double().get() ... 24 ... ''' ! ... return X(self.val + self.val) ... ... def get(self): ... ''' ! ... >>> print X(-5).get() ... -5 ... ''' --- 185,196 ---- ... def double(self): ... ''' ! ... >>> print A(12).double().get() ... 24 ... ''' ! ... return A(self.val + self.val) ... ... def get(self): ... ''' ! ... >>> print A(-5).get() ... -5 ... ''' *************** *** 195,199 **** ... def a_staticmethod(v): ... ''' ! ... >>> print X.a_staticmethod(10) ... 11 ... ''' --- 199,203 ---- ... def a_staticmethod(v): ... ''' ! ... >>> print A.a_staticmethod(10) ... 11 ... ''' *************** *** 203,209 **** ... def a_classmethod(cls, v): ... ''' ! ... >>> print X.a_classmethod(10) ... 12 ! ... >>> print X(0).a_classmethod(10) ... 12 ... ''' --- 207,213 ---- ... def a_classmethod(cls, v): ... ''' ! ... >>> print A.a_classmethod(10) ... 12 ! ... >>> print A(0).a_classmethod(10) ... 12 ... ''' *************** *** 218,222 **** ... class NestedClass: ... ''' ! ... >>> x = X.NestedClass(5) ... >>> y = x.square() ... >>> print y.get() --- 222,226 ---- ... class NestedClass: ... ''' ! ... >>> x = A.NestedClass(5) ... >>> y = x.square() ... >>> print y.get() *************** *** 225,252 **** ... def __init__(self, val=0): ... ''' ! ... >>> print X.NestedClass().get() ... 0 ... ''' ... self.val = val ... def square(self): ! ... X.NestedClass(self.val*self.val) ... def get(self): ... return self.val >>> finder = doctest.DocTestFinder() ! >>> tests = finder.find(X) >>> tests.sort() >>> for t in tests: ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) ! None 1 X ! None 3 X.NestedClass ! 96 1 X.NestedClass.__init__ ! 7 1 X.__init__ ! 40 2 X.a_classmethod ! None 1 X.a_property ! 40 1 X.a_staticmethod ! 40 1 X.double ! 40 1 X.get For a module, DocTestFinder will create a test for the class's docstring, and will recursively explore its contents, including --- 229,295 ---- ... def __init__(self, val=0): ... ''' ! ... >>> print A.NestedClass().get() ... 0 ... ''' ... self.val = val ... def square(self): ! ... A.NestedClass(self.val*self.val) ... def get(self): ... return self.val >>> finder = doctest.DocTestFinder() ! >>> tests = finder.find(A) >>> tests.sort() >>> for t in tests: ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) ! None 1 A ! None 3 A.NestedClass ! 96 1 A.NestedClass.__init__ ! 7 1 A.__init__ ! 40 2 A.a_classmethod ! None 1 A.a_property ! 40 1 A.a_staticmethod ! 40 1 A.double ! 40 1 A.get ! ! New-style classes are also supported: ! ! >>> class B(object): ! ... ''' ! ... >>> print 1 ! ... 1 ! ... ''' ! ... def __init__(self, val): ! ... ''' ! ... >>> print B(12).get() ! ... 12 ! ... ''' ! ... self.val = val ! ... ! ... def double(self): ! ... ''' ! ... >>> print B(12).double().get() ! ... 24 ! ... ''' ! ... return B(self.val + self.val) ! ... ! ... def get(self): ! ... ''' ! ... >>> print B(-5).get() ! ... -5 ! ... ''' ! ... return self.val + >>> tests = finder.find(B) + >>> tests.sort() + >>> for t in tests: + ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) + None 1 B + 7 1 B.__init__ + 40 1 B.double + 40 1 B.get + + Finding Tests in Modules + ~~~~~~~~~~~~~~~~~~~~~~~~ For a module, DocTestFinder will create a test for the class's docstring, and will recursively explore its contents, including *************** *** 264,268 **** >>> m.__dict__.update({ ... 'double': double, ! ... 'X': X, ... '__doc__': ''' ... Module docstring. --- 307,311 ---- >>> m.__dict__.update({ ... 'double': double, ! ... 'A': A, ... '__doc__': ''' ... Module docstring. *************** *** 282,302 **** ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) 1 1 some_module ! None 1 some_module.X ! None 3 some_module.X.NestedClass ! 57 1 some_module.X.NestedClass.__init__ ! 6 1 some_module.X.__init__ ! 35 2 some_module.X.a_classmethod ! None 1 some_module.X.a_property ! 27 1 some_module.X.a_staticmethod ! 13 1 some_module.X.double ! 20 1 some_module.X.get 1 1 some_module.c None 2 some_module.d 1 1 some_module.double If a single object is listed twice (under different names), then tests will only be generated for it once: >>> class TwoNames: ... def f(self): ... ''' --- 325,349 ---- ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) 1 1 some_module ! None 1 some_module.A ! None 3 some_module.A.NestedClass ! 57 1 some_module.A.NestedClass.__init__ ! 6 1 some_module.A.__init__ ! 35 2 some_module.A.a_classmethod ! None 1 some_module.A.a_property ! 27 1 some_module.A.a_staticmethod ! 13 1 some_module.A.double ! 20 1 some_module.A.get 1 1 some_module.c None 2 some_module.d 1 1 some_module.double + Duplicate Removal + ~~~~~~~~~~~~~~~~~ If a single object is listed twice (under different names), then tests will only be generated for it once: >>> class TwoNames: + ... '''f() and g() are two names for the same method''' + ... ... def f(self): ... ''' *************** *** 310,320 **** >>> finder = doctest.DocTestFinder() >>> tests = finder.find(TwoNames) >>> print len(tests) ! 1 ! >>> print tests[0].name in ('TwoNames.f', 'TwoNames.g') True """ --- 357,855 ---- >>> finder = doctest.DocTestFinder() >>> tests = finder.find(TwoNames) + >>> tests.sort() >>> print len(tests) ! 2 ! >>> print tests[0].name ! TwoNames ! >>> print tests[1].name in ('TwoNames.f', 'TwoNames.g') True + Filter Functions + ~~~~~~~~~~~~~~~~ + Two filter functions can be used to restrict which objects get + examined: a name-based filter and an object-based filter. + + >>> def namefilter(prefix, base): + ... return base.startswith('a_') + >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(A) + >>> tests.sort() + >>> for t in tests: + ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) + None 1 A + None 3 A.NestedClass + 96 1 A.NestedClass.__init__ + 7 1 A.__init__ + 40 1 A.double + 40 1 A.get + + >>> def objfilter(obj): + ... return isinstance(obj, (staticmethod, classmethod)) + >>> tests = doctest.DocTestFinder(objfilter=objfilter).find(A) + >>> tests.sort() + >>> for t in tests: + ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) + None 1 A + None 3 A.NestedClass + 96 1 A.NestedClass.__init__ + 7 1 A.__init__ + None 1 A.a_property + 40 1 A.double + 40 1 A.get + + If a given object is filtered out, then none of the objects that it + contains will be added either: + + >>> def namefilter(prefix, base): + ... return base == 'NestedClass' + >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(A) + >>> tests.sort() + >>> for t in tests: + ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) + None 1 A + 7 1 A.__init__ + 40 2 A.a_classmethod + None 1 A.a_property + 40 1 A.a_staticmethod + 40 1 A.double + 40 1 A.get + The filter functions apply to contained objects, and *not* to the + object explicitly passed to DocTestFinder: + + >>> def namefilter(prefix, base): + ... return base == 'A' + >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(A) + >>> len(tests) + 9 + Turning off Recursion + ~~~~~~~~~~~~~~~~~~~~~ + DocTestFinder can be told not to look for tests in contained objects + using the `recurse` flag: + + >>> tests = doctest.DocTestFinder(recurse=False).find(A) + >>> tests.sort() + >>> for t in tests: + ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) + None 1 A + """ + + class test_DocTestRunner: + def basics(): r""" + Unit tests for the `DocTestRunner` class. + + DocTestRunner is used to run DocTest test cases, and to accumulate + statistics. Here's a simple DocTest case we can use: + + >>> def f(x): + ... ''' + ... >>> x = 12 + ... >>> print x + ... 12 + ... >>> x/2 + ... 6 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + + The main DocTestRunner interface is the `run` method, which runs a + given DocTest case in a given namespace (globs). It returns a tuple + `(f,t)`, where `f` is the number of failed tests and `t` is the number + of tried tests. + + >>> doctest.DocTestRunner().run(test, {}) + (0, 3) + + The `verbose` flag makes the test runner generate more detailed + output: + + >>> doctest.DocTestRunner(verbose=True).run(test, {}) + Trying: x = 12 + Expecting: nothing + ok + Trying: print x + Expecting: 12 + ok + Trying: x/2 + Expecting: 6 + ok + (0, 3) + + If any example produces incorrect output, then the test runner reports + the failure and proceeds to the next example: + + >>> def f(x): + ... ''' + ... >>> x = 12 + ... >>> print x + ... 14 + ... >>> x/2 + ... 6 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=True).run(test, {}) + Trying: x = 12 + Expecting: nothing + ok + Trying: print x + Expecting: 14 + ********************************************************************** + Failure in example: print x + from line #2 of f + Expected: 14 + Got: 12 + Trying: x/2 + Expecting: 6 + ok + (1, 3) + """ + def exceptions(): r""" + Tests of `DocTestRunner`'s exception handling. + + An expected exception is specified with a traceback message. The + lines between the first line and the type/value may be omitted or + replaced with any other string: + + >>> def f(x): + ... ''' + ... >>> x = 12 + ... >>> print x/0 + ... Traceback (most recent call last): + ... ZeroDivisionError: integer division or modulo by zero + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner().run(test, {}) + (0, 2) + + An example may generate output before it raises an exception; if it + does, then the output must match the expected output: + + >>> def f(x): + ... ''' + ... >>> x = 12 + ... >>> print 'pre-exception output', x/0 + ... pre-exception output + ... Traceback (most recent call last): + ... ZeroDivisionError: integer division or modulo by zero + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner().run(test, {}) + (0, 2) + + Exception messages may contain newlines: + + >>> def f(x): + ... r''' + ... >>> raise ValueError, 'multi\nline\nmessage' + ... Traceback (most recent call last): + ... ValueError: multi + ... line + ... message + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner().run(test, {}) + (0, 1) + + If an exception is expected, but an exception with the wrong type or + message is raised, then it is reported as a failure: + + >>> def f(x): + ... r''' + ... >>> raise ValueError, 'message' + ... Traceback (most recent call last): + ... ValueError: wrong message + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner().run(test, {}) + ********************************************************************** + Failure in example: raise ValueError, 'message' + from line #1 of f + Expected: + Traceback (most recent call last): + ValueError: wrong message + Got: + Traceback (most recent call last): + ValueError: message + (1, 1) + + If an exception is raised but not expected, then it is reported as an + unexpected exception: + + >>> # Allow ellipsis in the following examples (since the filename + >>> # and line number in the traceback can vary): + >>> doctest: +ELLIPSIS + + >>> def f(x): + ... r''' + ... >>> 1/0 + ... 0 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner().run(test, {}) + ********************************************************************** + Failure in example: 1/0 + from line #1 of f + Exception raised: + Traceback (most recent call last): + File "...", line ..., in __run + compileflags, 1) in globs + File "", line 1, in ? + ZeroDivisionError: integer division or modulo by zero + (1, 1) + + >>> # Turn ellipsis back off: + >>> doctest: -ELLIPSIS + """ + def optionflags(): r""" + Tests of `DocTestRunner`'s option flag handling. + + Several option flags can be used to customize the behavior of the test + runner. These are defined as module constants in doctest, and passed + to the DocTestRunner constructor (multiple constants should be or-ed + together). + + The DONT_ACCEPT_TRUE_FOR_1 flag disables matches between True/False + and 1/0: + + >>> def f(x): + ... '>>> True\n1\n' + + >>> # Without the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner().run(test, {}) + (0, 1) + + >>> # With the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.DONT_ACCEPT_TRUE_FOR_1 + >>> doctest.DocTestRunner(optionflags=flags).run(test, {}) + ********************************************************************** + Failure in example: True + from line #0 of f + Expected: 1 + Got: True + (1, 1) + + The DONT_ACCEPT_BLANKLINE flag disables the match between blank lines + and the '' marker: + + >>> def f(x): + ... '>>> print "a\\n\\nb"\na\n\nb\n' + + >>> # Without the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner().run(test, {}) + (0, 1) + + >>> # With the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.DONT_ACCEPT_BLANKLINE + >>> doctest.DocTestRunner(optionflags=flags).run(test, {}) + ********************************************************************** + Failure in example: print "a\n\nb" + from line #0 of f + Expected: + a + + b + Got: + a + + b + (1, 1) + + The NORMALIZE_WHITESPACE flag causes all sequences of whitespace to be + treated as equal: + + >>> def f(x): + ... '>>> print 1, 2, 3\n 1 2 \n 3' + + >>> # Without the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner().run(test, {}) + ********************************************************************** + Failure in example: print 1, 2, 3 + from line #0 of f + Expected: + 1 2 + 3 + Got: 1 2 3 + (1, 1) + + >>> # With the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.NORMALIZE_WHITESPACE + >>> doctest.DocTestRunner(optionflags=flags).run(test, {}) + (0, 1) + + The ELLIPSIS flag causes ellipsis marker ("...") in the expected + output to match any substring in the actual output: + + >>> def f(x): + ... '>>> print range(15)\n[0, 1, 2, ..., 14]\n' + + >>> # Without the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner().run(test, {}) + ********************************************************************** + Failure in example: print range(15) + from line #0 of f + Expected: [0, 1, 2, ..., 14] + Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] + (1, 1) + + >>> # With the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.ELLIPSIS + >>> doctest.DocTestRunner(optionflags=flags).run(test, {}) + (0, 1) + + The UNIFIED_DIFF flag causes failures that involve multi-line expected + and actual outputs to be displayed using a unified diff: + + >>> def f(x): + ... r''' + ... >>> print '\n'.join('abcdefg') + ... a + ... B + ... c + ... d + ... f + ... g + ... h + ... ''' + + >>> # Without the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner().run(test, {}) + ********************************************************************** + Failure in example: print '\n'.join('abcdefg') + from line #1 of f + Expected: + a + B + c + d + f + g + h + Got: + a + b + c + d + e + f + g + (1, 1) + + >>> # With the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.UNIFIED_DIFF + >>> doctest.DocTestRunner(optionflags=flags).run(test, {}) + ********************************************************************** + Failure in example: print '\n'.join('abcdefg') + from line #1 of f + Differences (unified diff): + --- Expected + +++ Got + @@ -1,8 +1,8 @@ + a + -B + +b + c + d + +e + f + g + -h + + (1, 1) + + The CONTEXT_DIFF flag causes failures that involve multi-line expected + and actual outputs to be displayed using a context diff: + + >>> # Reuse f() from the UNIFIED_DIFF example, above. + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.CONTEXT_DIFF + >>> doctest.DocTestRunner(optionflags=flags).run(test, {}) + ********************************************************************** + Failure in example: print '\n'.join('abcdefg') + from line #1 of f + Differences (unified diff): + *** Expected + --- Got + *************** + *** 1,8 **** + a + ! B + c + d + f + g + - h + + --- 1,8 ---- + a + ! b + c + d + + e + f + g + + (1, 1) + """ + + def option_directives(): r""" + Tests of `DocTestRunner`'s option directive mechanism. + + Option directives can be used to turn option flags on or off from + within a DocTest case. The following example shows how a flag can be + turned on and off. Note that comments on the same line as the option + directive are ignored. + + >>> def f(x): r''' + ... >>> print range(10) # Should fail: no ellipsis + ... [0, 1, ..., 9] + ... + ... >>> doctest: +ELLIPSIS # turn ellipsis on. + ... >>> print range(10) # Should succeed + ... [0, 1, ..., 9] + ... + ... >>> doctest: -ELLIPSIS # turn ellipsis back off. + ... >>> print range(10) # Should fail: no ellipsis + ... [0, 1, ..., 9] + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner().run(test, {}) + ********************************************************************** + Failure in example: print range(10) # Should fail: no ellipsis + from line #1 of f + Expected: [0, 1, ..., 9] + Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + ********************************************************************** + Failure in example: print range(10) # Should fail: no ellipsis + from line #9 of f + Expected: [0, 1, ..., 9] + Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + (2, 3) + + Multiple flags can be toggled by a single option directive: + + >>> def f(x): r''' + ... >>> print range(10) # Should fail + ... [0, 1, ..., 9] + ... >>> doctest: +ELLIPSIS +NORMALIZE_WHITESPACE + ... >>> print range(10) # Should succeed + ... [0, 1, ..., 9] + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner().run(test, {}) + ********************************************************************** + Failure in example: print range(10) # Should fail + from line #1 of f + Expected: [0, 1, ..., 9] + Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + (1, 2) """ *************** *** 322,326 **** def test_main(): # Check the doctest cases in doctest itself: ! test_support.run_doctest(doctest) # Check the doctest cases defined here: from test import test_doctest --- 857,861 ---- def test_main(): # Check the doctest cases in doctest itself: ! #test_support.run_doctest(doctest) # Check the doctest cases defined here: from test import test_doctest From bcannon at users.sourceforge.net Tue Aug 3 06:53:32 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Tue Aug 3 06:53:35 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.218,2.219 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10617/Objects Modified Files: listobject.c Log Message: Tweak previous patch to silence a warning about the unused left value in the comma expression in listpop() that was being returned. Still essentially unused (as it is meant to be), but now the compiler thinks it is worth *something* by having it incremented. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.218 retrieving revision 2.219 diff -C2 -d -r2.218 -r2.219 *** listobject.c 31 Jul 2004 21:53:19 -0000 2.218 --- listobject.c 3 Aug 2004 04:53:29 -0000 2.219 *************** *** 863,867 **** * complain about the unused name. */ ! return status, v; } --- 863,867 ---- * complain about the unused name. */ ! return status++, v; } From mhammond at users.sourceforge.net Tue Aug 3 07:06:28 2004 From: mhammond at users.sourceforge.net (mhammond@users.sourceforge.net) Date: Tue Aug 3 07:06:31 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.296, 1.297 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12067 Modified Files: socketmodule.c Log Message: Fix [ 1001018 ]: Windows: setdefaulttimeout causes unnecessary timeouts on connect error Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.296 retrieving revision 1.297 diff -C2 -d -r1.296 -r1.297 *** socketmodule.c 19 Jul 2004 17:01:20 -0000 1.296 --- socketmodule.c 3 Aug 2004 05:06:26 -0000 1.297 *************** *** 1695,1698 **** --- 1695,1699 ---- /* This is a mess. Best solution: trust select */ fd_set fds; + fd_set fds_exc; struct timeval tv; tv.tv_sec = (int)s->sock_timeout; *************** *** 1700,1709 **** FD_ZERO(&fds); FD_SET(s->sock_fd, &fds); ! res = select(s->sock_fd+1, NULL, &fds, NULL, &tv); if (res == 0) { res = WSAEWOULDBLOCK; timeout = 1; ! } else if (res > 0) ! res = 0; /* else if (res < 0) an error occurred */ } --- 1701,1730 ---- FD_ZERO(&fds); FD_SET(s->sock_fd, &fds); ! FD_ZERO(&fds_exc); ! FD_SET(s->sock_fd, &fds_exc); ! res = select(s->sock_fd+1, NULL, &fds, &fds_exc, &tv); if (res == 0) { res = WSAEWOULDBLOCK; timeout = 1; ! } else if (res > 0) { ! if (FD_ISSET(s->sock_fd, &fds)) ! /* The socket is in the writeable set - this ! means connected */ ! res = 0; ! else { ! /* As per MS docs, we need to call getsockopt() ! to get the underlying error */ ! int res_size = sizeof res; ! /* It must be in the exception set */ ! assert(FD_ISSET(s->sock_fd, &fds_exc)); ! if (0 == getsockopt(s->sock_fd, SOL_SOCKET, SO_ERROR, ! (char *)&res, &res_size)) ! /* getsockopt also clears WSAGetLastError, ! so reset it back. */ ! WSASetLastError(res); ! else ! res = WSAGetLastError(); ! } ! } /* else if (res < 0) an error occurred */ } From love at anan.servehalflife.com Tue Aug 3 07:10:44 2004 From: love at anan.servehalflife.com (love@anan.servehalflife.com) Date: Tue Aug 3 07:10:46 2004 Subject: [Python-checkins] =?utf-8?b?wpBswo3DiMKDQcKDaMKDwozCg1jCksKg?= Message-ID: mag20040802223919 *:??,??'?:*:??,? ?????? ?17??*:??,??'?:*:??,? ???????????(???)? ?????????? =========================================================== =====================???==???======================== ================????==???????=================== =========================================================== ???????????????????????? ??????????????????? ??????????????????????????????? ??????????????????????????????? ????????????????????????????????? ???1????????????10?20????????????????????????? ??????????????????????????????? ??????????????????????????? ?????????????????????????????????????? ?????????????????????????????????????? ?????????????????????????????????????? ?????????????????????????????????????? ?????????????????????????????????????????? ???????????????????????????????????? ???? ????????????????????????????????????? ??????????????????????????????????? ?????????????????????????????????? ??-------------------------------------------------???PR???-------?? ?????????????????????????????????????? ???????OK???????????????????????????????????? ????? ???????http://gannba.servepics.com/?g02 ??-------???PR???-------------------------------------------------?? ???????????????????????????? ???????????????????????? ???????http://zxcvb.servepics.com/?g02 ??------------------------------????---------------------------------???? ?????????????????????????????????????? ????????????????????????? ?????????????????????? From rhettinger at users.sourceforge.net Tue Aug 3 07:18:00 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 3 07:18:05 2004 Subject: [Python-checkins] python/dist/src/Doc/ref ref6.tex,1.70,1.71 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13411/ref Modified Files: ref6.tex Log Message: Document general mappings for the locals argument for exec and execfile(). Index: ref6.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref6.tex,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** ref6.tex 1 Jan 2004 05:43:53 -0000 1.70 --- ref6.tex 3 Aug 2004 05:17:57 -0000 1.71 *************** *** 874,879 **** is specified, it should be a dictionary, which will be used for both the global and the local variables. If two expressions are given, ! both must be dictionaries and they are used for the global and local ! variables, respectively. As a side effect, an implementation may insert additional keys into --- 874,880 ---- 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, \var{locals} can be any mapping object. ! \versionchanged[formerly \var{locals} was required to be a dictionary]{2.4} As a side effect, an implementation may insert additional keys into From rhettinger at users.sourceforge.net Tue Aug 3 07:18:01 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 3 07:18:06 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.168,1.169 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13411/lib Modified Files: libfuncs.tex Log Message: Document general mappings for the locals argument for exec and execfile(). Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.168 retrieving revision 1.169 diff -C2 -d -r1.168 -r1.169 *** libfuncs.tex 2 Aug 2004 06:09:52 -0000 1.168 --- libfuncs.tex 3 Aug 2004 05:17:58 -0000 1.169 *************** *** 344,354 **** rarely so does not warrant being made into a statement.} ! 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 \var{globals} and \var{locals} ! dictionaries as global and local namespace. If the \var{locals} ! dictionary is omitted it defaults to the \var{globals} dictionary. ! If both dictionaries are omitted, the expression is executed in the ! environment where \function{execfile()} is called. The return value is \code{None}. --- 344,355 ---- rarely so does not warrant being made into a statement.} ! 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 \var{globals} and \var{locals} dictionaries as global and ! local namespace. If provided, \var{locals} can be any mapping object. ! \versionchanged[formerly \var{locals} was required to be a dictionary]{2.4} ! If the \var{locals} dictionary is omitted it defaults to the \var{globals} ! dictionary. If both dictionaries are omitted, the expression is executed in ! the environment where \function{execfile()} is called. The return value is \code{None}. From fdrake at users.sourceforge.net Tue Aug 3 09:06:25 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 09:06:29 2004 Subject: [Python-checkins] python/dist/src/Modules/expat expat_external.h, NONE, 1.1 expat.h, 1.6, 1.7 macconfig.h, 1.2, 1.3 xmlparse.c, 1.6, 1.7 xmlrole.c, 1.6, 1.7 xmltok.c, 1.4, 1.5 xmltok.h, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules/expat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25991 Modified Files: expat.h macconfig.h xmlparse.c xmlrole.c xmltok.c xmltok.h Added Files: expat_external.h Log Message: update to Expat 1.95.8 --- NEW FILE: expat_external.h --- /* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd See the file COPYING for copying permission. */ /* External API definitions */ #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) #define XML_USE_MSC_EXTENSIONS 1 #endif /* Expat tries very hard to make the API boundary very specifically defined. There are two macros defined to control this boundary; each of these can be defined before including this header to achieve some different behavior, but doing so it not recommended or tested frequently. XMLCALL - The calling convention to use for all calls across the "library boundary." This will default to cdecl, and try really hard to tell the compiler that's what we want. XMLIMPORT - Whatever magic is needed to note that a function is to be imported from a dynamically loaded library (.dll, .so, or .sl, depending on your platform). The XMLCALL macro was added in Expat 1.95.7. The only one which is expected to be directly useful in client code is XMLCALL. Note that on at least some Unix versions, the Expat library must be compiled with the cdecl calling convention as the default since system headers may assume the cdecl convention. */ #ifndef XMLCALL #if defined(XML_USE_MSC_EXTENSIONS) #define XMLCALL __cdecl #elif defined(__GNUC__) && defined(__i386) #define XMLCALL __attribute__((cdecl)) #else /* For any platform which uses this definition and supports more than one calling convention, we need to extend this definition to declare the convention used on that platform, if it's possible to do so. If this is the case for your platform, please file a bug report with information on how to identify your platform via the C pre-processor and how to specify the same calling convention as the platform's malloc() implementation. */ #define XMLCALL #endif #endif /* not defined XMLCALL */ #if !defined(XML_STATIC) && !defined(XMLIMPORT) #ifndef XML_BUILDING_EXPAT /* using Expat from an application */ #ifdef XML_USE_MSC_EXTENSIONS #define XMLIMPORT __declspec(dllimport) #endif #endif #endif /* not defined XML_STATIC */ /* If we didn't define it above, define it away: */ #ifndef XMLIMPORT #define XMLIMPORT #endif #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL #ifdef __cplusplus extern "C" { #endif #ifdef XML_UNICODE_WCHAR_T #define XML_UNICODE #endif #ifdef XML_UNICODE /* Information is UTF-16 encoded. */ #ifdef XML_UNICODE_WCHAR_T typedef wchar_t XML_Char; typedef wchar_t XML_LChar; #else typedef unsigned short XML_Char; typedef char XML_LChar; #endif /* XML_UNICODE_WCHAR_T */ #else /* Information is UTF-8 encoded. */ typedef char XML_Char; typedef char XML_LChar; #endif /* XML_UNICODE */ Index: expat.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/expat.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** expat.h 21 Oct 2003 15:38:55 -0000 1.6 --- expat.h 3 Aug 2004 07:06:22 -0000 1.7 *************** *** 16,110 **** #include ! ! #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) ! #define XML_USE_MSC_EXTENSIONS 1 ! #endif ! ! /* Expat tries very hard to make the API boundary very specifically ! defined. There are two macros defined to control this boundary; ! each of these can be defined before including this header to ! achieve some different behavior, but doing so it not recommended or ! tested frequently. ! ! XMLCALL - The calling convention to use for all calls across the ! "library boundary." This will default to cdecl, and ! try really hard to tell the compiler that's what we ! want. ! ! XMLIMPORT - Whatever magic is needed to note that a function is ! to be imported from a dynamically loaded library ! (.dll, .so, or .sl, depending on your platform). ! ! The XMLCALL macro was added in Expat 1.95.7. The only one which is ! expected to be directly useful in client code is XMLCALL. ! ! Note that on at least some Unix versions, the Expat library must be ! compiled with the cdecl calling convention as the default since ! system headers may assume the cdecl convention. ! */ ! #ifndef XMLCALL ! #if defined(XML_USE_MSC_EXTENSIONS) ! #define XMLCALL __cdecl ! #elif defined(__GNUC__) ! #define XMLCALL __attribute__((cdecl)) ! #else ! /* For any platform which uses this definition and supports more than ! one calling convention, we need to extend this definition to ! declare the convention used on that platform, if it's possible to ! do so. ! ! If this is the case for your platform, please file a bug report ! with information on how to identify your platform via the C ! pre-processor and how to specify the same calling convention as the ! platform's malloc() implementation. ! */ ! #define XMLCALL ! #endif ! #endif /* not defined XMLCALL */ ! ! ! #if !defined(XML_STATIC) && !defined(XMLIMPORT) ! #ifndef XML_BUILDING_EXPAT ! /* using Expat from an application */ ! ! #ifdef XML_USE_MSC_EXTENSIONS ! #define XMLIMPORT __declspec(dllimport) ! #endif ! ! #endif ! #endif /* not defined XML_STATIC */ ! ! /* If we didn't define it above, define it away: */ ! #ifndef XMLIMPORT ! #define XMLIMPORT ! #endif ! ! ! #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL ! ! #ifdef __cplusplus ! extern "C" { ! #endif ! ! #ifdef XML_UNICODE_WCHAR_T ! #define XML_UNICODE ! #endif struct XML_ParserStruct; typedef struct XML_ParserStruct *XML_Parser; - #ifdef XML_UNICODE /* Information is UTF-16 encoded. */ - #ifdef XML_UNICODE_WCHAR_T - typedef wchar_t XML_Char; - typedef wchar_t XML_LChar; - #else - typedef unsigned short XML_Char; - typedef char XML_LChar; - #endif /* XML_UNICODE_WCHAR_T */ - #else /* Information is UTF-8 encoded. */ - typedef char XML_Char; - typedef char XML_LChar; - #endif /* XML_UNICODE */ - /* Should this be defined using stdbool.h when C99 is available? */ typedef unsigned char XML_Bool; --- 16,24 ---- #include ! #include "expat_external.h" struct XML_ParserStruct; typedef struct XML_ParserStruct *XML_Parser; /* Should this be defined using stdbool.h when C99 is available? */ typedef unsigned char XML_Bool; *************** *** 128,133 **** XML_STATUS_ERROR = 0, #define XML_STATUS_ERROR XML_STATUS_ERROR ! XML_STATUS_OK = 1 #define XML_STATUS_OK XML_STATUS_OK }; --- 42,49 ---- XML_STATUS_ERROR = 0, #define XML_STATUS_ERROR XML_STATUS_ERROR ! XML_STATUS_OK = 1, #define XML_STATUS_OK XML_STATUS_OK + XML_STATUS_SUSPENDED = 2, + #define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED }; *************** *** 160,164 **** XML_ERROR_FEATURE_REQUIRES_XML_DTD, XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING, ! XML_ERROR_UNBOUND_PREFIX }; --- 76,92 ---- XML_ERROR_FEATURE_REQUIRES_XML_DTD, XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING, ! /* Added in 1.95.7. */ ! XML_ERROR_UNBOUND_PREFIX, ! /* Added in 1.95.8. */ ! XML_ERROR_UNDECLARING_PREFIX, ! XML_ERROR_INCOMPLETE_PE, ! XML_ERROR_XML_DECL, ! XML_ERROR_TEXT_DECL, ! XML_ERROR_PUBLICID, ! XML_ERROR_SUSPENDED, ! XML_ERROR_NOT_SUSPENDED, ! XML_ERROR_ABORTED, ! XML_ERROR_FINISHED, ! XML_ERROR_SUSPEND_PE }; *************** *** 259,265 **** typedef struct { ! void *(XMLCALL *malloc_fcn)(size_t size); ! void *(XMLCALL *realloc_fcn)(void *ptr, size_t size); ! void (XMLCALL *free_fcn)(void *ptr); } XML_Memory_Handling_Suite; --- 187,193 ---- typedef struct { ! void *(*malloc_fcn)(size_t size); ! void *(*realloc_fcn)(void *ptr, size_t size); ! void (*free_fcn)(void *ptr); } XML_Memory_Handling_Suite; *************** *** 601,608 **** XMLPARSEAPI(void) ! XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler); XMLPARSEAPI(void) ! XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler); XMLPARSEAPI(void) --- 529,538 ---- XMLPARSEAPI(void) ! XML_SetStartElementHandler(XML_Parser parser, ! XML_StartElementHandler handler); XMLPARSEAPI(void) ! XML_SetEndElementHandler(XML_Parser parser, ! XML_EndElementHandler handler); XMLPARSEAPI(void) *************** *** 693,697 **** */ XMLPARSEAPI(void) ! XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg); XMLPARSEAPI(void) --- 623,628 ---- */ XMLPARSEAPI(void) ! XML_SetExternalEntityRefHandlerArg(XML_Parser parser, ! void *arg); XMLPARSEAPI(void) *************** *** 756,759 **** --- 687,693 ---- externalEntityRefHandler with a value of NULL for the systemId argument (the publicId and context arguments will be NULL as well). + Note: For the purpose of checking WFC: Entity Declared, passing + useDTD == XML_TRUE will make the parser behave as if the document + had a DTD with an external subset. Note: If this function is called, then this must be done before the first call to XML_Parse or XML_ParseBuffer, since it will *************** *** 819,822 **** --- 753,825 ---- XML_ParseBuffer(XML_Parser parser, int len, int isFinal); + /* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return. + Must be called from within a call-back handler, except when aborting + (resumable = 0) an already suspended parser. Some call-backs may + still follow because they would otherwise get lost. Examples: + - endElementHandler() for empty elements when stopped in + startElementHandler(), + - endNameSpaceDeclHandler() when stopped in endElementHandler(), + and possibly others. + + Can be called from most handlers, including DTD related call-backs, + except when parsing an external parameter entity and resumable != 0. + Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise. + Possible error codes: + - XML_ERROR_SUSPENDED: when suspending an already suspended parser. + - XML_ERROR_FINISHED: when the parser has already finished. + - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE. + + When resumable != 0 (true) then parsing is suspended, that is, + XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED. + Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer() + return XML_STATUS_ERROR with error code XML_ERROR_ABORTED. + + *Note*: + This will be applied to the current parser instance only, that is, if + there is a parent parser then it will continue parsing when the + externalEntityRefHandler() returns. It is up to the implementation of + the externalEntityRefHandler() to call XML_StopParser() on the parent + parser (recursively), if one wants to stop parsing altogether. + + When suspended, parsing can be resumed by calling XML_ResumeParser(). + */ + XMLPARSEAPI(enum XML_Status) + XML_StopParser(XML_Parser parser, XML_Bool resumable); + + /* Resumes parsing after it has been suspended with XML_StopParser(). + Must not be called from within a handler call-back. Returns same + status codes as XML_Parse() or XML_ParseBuffer(). + Additional error code XML_ERROR_NOT_SUSPENDED possible. + + *Note*: + This must be called on the most deeply nested child parser instance + first, and on its parent parser only after the child parser has finished, + to be applied recursively until the document entity's parser is restarted. + That is, the parent parser will not resume by itself and it is up to the + application to call XML_ResumeParser() on it at the appropriate moment. + */ + XMLPARSEAPI(enum XML_Status) + XML_ResumeParser(XML_Parser parser); + + enum XML_Parsing { + XML_INITIALIZED, + XML_PARSING, + XML_FINISHED, + XML_SUSPENDED + }; + + typedef struct { + enum XML_Parsing parsing; + XML_Bool finalBuffer; + } XML_ParsingStatus; + + /* Returns status of parser with respect to being initialized, parsing, + finished, or suspended and processing the final buffer. + XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus, + XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED + */ + XMLPARSEAPI(void) + XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status); + /* Creates an XML_Parser object that can parse an external general entity; context is a '\0'-terminated string specifying the parse *************** *** 993,997 **** #define XML_MAJOR_VERSION 1 #define XML_MINOR_VERSION 95 ! #define XML_MICRO_VERSION 7 #ifdef __cplusplus --- 996,1000 ---- #define XML_MAJOR_VERSION 1 #define XML_MINOR_VERSION 95 ! #define XML_MICRO_VERSION 8 #ifdef __cplusplus Index: macconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/macconfig.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** macconfig.h 10 Feb 2004 16:50:19 -0000 1.2 --- macconfig.h 3 Aug 2004 07:06:22 -0000 1.3 *************** *** 19,76 **** #undef HAVE_BCOPY - /* Define to 1 if you have the header file. */ - #undef HAVE_DLFCN_H - - /* Define to 1 if you have the header file. */ - #undef HAVE_FCNTL_H - - /* Define to 1 if you have the `getpagesize' function. */ - #undef HAVE_GETPAGESIZE - - /* Define to 1 if you have the header file. */ - #undef HAVE_INTTYPES_H - /* Define to 1 if you have the `memmove' function. */ #define HAVE_MEMMOVE - /* 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. */ - #undef HAVE_STDINT_H - - /* Define to 1 if you have the header file. */ - #undef HAVE_STRINGS_H - - /* Define to 1 if you have the header file. */ - #undef HAVE_SYS_STAT_H - - /* Define to 1 if you have the header file. */ - #undef HAVE_SYS_TYPES_H - /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H - /* Define to the address where bug reports for this package should be sent. */ - #undef PACKAGE_BUGREPORT - - /* Define to the full name of this package. */ - #undef PACKAGE_NAME - - /* Define to the full name and version of this package. */ - #undef PACKAGE_STRING - - /* Define to the one symbol short name of this package. */ - #undef PACKAGE_TARNAME - - /* Define to the version of this package. */ - #undef PACKAGE_VERSION - - /* Define to 1 if you have the ANSI C header files. */ - #define STDC_HEADERS - /* whether byteorder is bigendian */ #define WORDS_BIGENDIAN --- 19,31 ---- Index: xmlparse.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/xmlparse.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** xmlparse.c 21 Oct 2003 15:38:55 -0000 1.6 --- xmlparse.c 3 Aug 2004 07:06:22 -0000 1.7 *************** *** 5,8 **** --- 5,9 ---- #include #include /* memset(), memcpy() */ + #include #define XML_BUILDING_EXPAT 1 *************** *** 12,19 **** #elif defined(MACOS_CLASSIC) #include "macconfig.h" [...1989 lines suppressed...] if (isDocEntity) { ms->free_fcn(p->scaffIndex); --- 5521,5525 ---- *************** *** 5394,5399 **** tsize = table->size * sizeof(NAMED *); table->v = (NAMED **)table->mem->malloc_fcn(tsize); ! if (!table->v) return NULL; memset(table->v, 0, tsize); i = hash(name) & ((unsigned long)table->size - 1); --- 5761,5768 ---- tsize = table->size * sizeof(NAMED *); table->v = (NAMED **)table->mem->malloc_fcn(tsize); ! if (!table->v) { ! table->size = 0; return NULL; + } memset(table->v, 0, tsize); i = hash(name) & ((unsigned long)table->size - 1); Index: xmlrole.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/xmlrole.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** xmlrole.c 21 Oct 2003 15:38:55 -0000 1.6 --- xmlrole.c 3 Aug 2004 07:06:22 -0000 1.7 *************** *** 3,6 **** --- 3,8 ---- */ + #include + #ifdef COMPILED_FROM_DSP #include "winconfig.h" *************** *** 13,16 **** --- 15,19 ---- #endif /* ndef COMPILED_FROM_DSP */ + #include "expat_external.h" #include "internal.h" #include "xmlrole.h" *************** *** 371,374 **** --- 374,379 ---- state->handler = doctype5; return XML_ROLE_DOCTYPE_NONE; + case XML_TOK_NONE: + return XML_ROLE_NONE; } return common(state, tok); Index: xmltok.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/xmltok.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** xmltok.c 21 Oct 2003 15:38:55 -0000 1.4 --- xmltok.c 3 Aug 2004 07:06:22 -0000 1.5 *************** *** 3,6 **** --- 3,8 ---- */ + #include + #ifdef COMPILED_FROM_DSP #include "winconfig.h" *************** *** 13,16 **** --- 15,19 ---- #endif /* ndef COMPILED_FROM_DSP */ + #include "expat_external.h" #include "internal.h" #include "xmltok.h" *************** *** 1234,1238 **** struct unknown_encoding { struct normal_encoding normal; ! int (*convert)(void *userData, const char *p); void *userData; unsigned short utf16[256]; --- 1237,1241 ---- struct unknown_encoding { struct normal_encoding normal; ! CONVERTER convert; void *userData; unsigned short utf16[256]; Index: xmltok.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/xmltok.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** xmltok.h 25 Jan 2003 22:41:29 -0000 1.2 --- xmltok.h 3 Aug 2004 07:06:22 -0000 1.3 *************** *** 282,286 **** int XmlSizeOfUnknownEncoding(void); ! typedef int (*CONVERTER)(void *userData, const char *p); ENCODING * --- 282,287 ---- int XmlSizeOfUnknownEncoding(void); ! ! typedef int (XMLCALL *CONVERTER) (void *userData, const char *p); ENCODING * From arigo at users.sourceforge.net Tue Aug 3 10:33:58 2004 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Tue Aug 3 10:34:01 2004 Subject: [Python-checkins] python/dist/src/Modules _hotshot.c,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7247 Modified Files: _hotshot.c Log Message: SF bug #808756: refleaks in _hotshot.c. Index: _hotshot.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_hotshot.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** _hotshot.c 13 Jun 2004 20:45:11 -0000 1.36 --- _hotshot.c 3 Aug 2004 08:33:55 -0000 1.37 *************** *** 348,354 **** --- 348,356 ---- } if (PyDict_SetItem(self->info, key, list)) { + Py_DECREF(list); err = ERR_EXCEPTION; goto finally; } + Py_DECREF(list); } if (PyList_Append(list, value)) *************** *** 520,523 **** --- 522,526 ---- self->logfp = NULL; } + Py_XDECREF(self->info); PyObject_Del(self); } *************** *** 796,804 **** if (name == NULL) { if (pack_define_func(self, fileno, fcode->co_firstlineno, ! PyString_AS_STRING(fcode->co_name)) < 0) return -1; ! if (PyDict_SetItem(dict, obj, fcode->co_name)) return -1; } } return fileno; --- 799,812 ---- if (name == NULL) { if (pack_define_func(self, fileno, fcode->co_firstlineno, ! PyString_AS_STRING(fcode->co_name)) < 0) { ! Py_DECREF(obj); return -1; ! } ! if (PyDict_SetItem(dict, obj, fcode->co_name)) { ! Py_DECREF(obj); return -1; + } } + Py_DECREF(obj); } return fileno; From rhettinger at users.sourceforge.net Tue Aug 3 10:52:48 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 3 10:52:51 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.297, 1.298 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10000/Modules Modified Files: socketmodule.c Log Message: Restore compilation on MSVC++ 6.0 Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.297 retrieving revision 1.298 diff -C2 -d -r1.297 -r1.298 *** socketmodule.c 3 Aug 2004 05:06:26 -0000 1.297 --- socketmodule.c 3 Aug 2004 08:52:45 -0000 1.298 *************** *** 282,285 **** --- 282,289 ---- #endif + #if defined(_MSC_VER) && _MSC_VER == 1200 + #include "addrinfo.h" + #endif + #ifndef HAVE_INET_PTON int inet_pton(int af, const char *src, void *dst); From rhettinger at users.sourceforge.net Tue Aug 3 10:52:48 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 3 10:52:51 2004 Subject: [Python-checkins] python/dist/src/PC pyconfig.h,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10000/PC Modified Files: pyconfig.h Log Message: Restore compilation on MSVC++ 6.0 Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/pyconfig.h,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** pyconfig.h 27 Jul 2004 15:57:24 -0000 1.28 --- pyconfig.h 3 Aug 2004 08:52:46 -0000 1.29 *************** *** 268,275 **** #define SIZEOF_LONG_LONG 8 ! /* Atleast VC 7.1 has them. If some compiler does not provide them, ! #ifdef appropriately .*/ #define HAVE_UINTPTR_T 1 #define HAVE_INTPTR_T 1 #endif --- 268,277 ---- #define SIZEOF_LONG_LONG 8 ! /* VC 7.1 has them and VC 6.0 does not. VC 6.0 has a version number of 1200. ! If some compiler does not provide them, modify the #if appropriately. */ ! #if _MSC_VER != 1200 #define HAVE_UINTPTR_T 1 #define HAVE_INTPTR_T 1 + #endif #endif From arigo at users.sourceforge.net Tue Aug 3 11:02:35 2004 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Tue Aug 3 11:02:37 2004 Subject: [Python-checkins] python/dist/src/Modules _hotshot.c, 1.34, 1.34.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11156 Modified Files: Tag: release23-maint _hotshot.c Log Message: back-ported SF bug #808756: refleaks Index: _hotshot.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_hotshot.c,v retrieving revision 1.34 retrieving revision 1.34.10.1 diff -C2 -d -r1.34 -r1.34.10.1 *** _hotshot.c 17 Mar 2003 19:46:07 -0000 1.34 --- _hotshot.c 3 Aug 2004 09:02:32 -0000 1.34.10.1 *************** *** 352,358 **** --- 352,360 ---- } if (PyDict_SetItem(self->info, key, list)) { + Py_DECREF(list); err = ERR_EXCEPTION; goto finally; } + Py_DECREF(list); } if (PyList_Append(list, value)) *************** *** 524,527 **** --- 526,530 ---- self->logfp = NULL; } + Py_XDECREF(self->info); PyObject_Del(self); } *************** *** 800,808 **** if (name == NULL) { if (pack_define_func(self, fileno, fcode->co_firstlineno, ! PyString_AS_STRING(fcode->co_name)) < 0) return -1; ! if (PyDict_SetItem(dict, obj, fcode->co_name)) return -1; } } return fileno; --- 803,816 ---- if (name == NULL) { if (pack_define_func(self, fileno, fcode->co_firstlineno, ! PyString_AS_STRING(fcode->co_name)) < 0) { ! Py_DECREF(obj); return -1; ! } ! if (PyDict_SetItem(dict, obj, fcode->co_name)) { ! Py_DECREF(obj); return -1; + } } + Py_DECREF(obj); } return fileno; From mwh at users.sourceforge.net Tue Aug 3 12:17:37 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 3 12:17:40 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_sax.py,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21233/Lib/test Modified Files: test_sax.py Log Message: Delete the items variable (and explain why). Index: test_sax.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sax.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** test_sax.py 1 Jun 2004 12:48:19 -0000 1.26 --- test_sax.py 3 Aug 2004 10:17:34 -0000 1.27 *************** *** 688,691 **** --- 688,695 ---- if name[ : 5] == "test_": confirm(value(), name) + # We delete the items variable so that the assignment to items above + # doesn't pick up the old value of items (which messes with attempts + # to find reference leaks). + del items if verbose: From mwh at users.sourceforge.net Tue Aug 3 12:21:05 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 3 12:21:09 2004 Subject: [Python-checkins] python/dist/src/Objects typeobject.c, 2.261, 2.262 classobject.c, 2.174, 2.175 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21515/Objects Modified Files: typeobject.c classobject.c Log Message: Repair the same thinko in two places about handling of _Py_RefTotal in the case of __del__ resurrecting an object. This makes the apparent reference leaks in test_descr go away (which I expected) and also kills off those in test_gc (which is more surprising but less so once you actually think about it a bit). Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.261 retrieving revision 2.262 diff -C2 -d -r2.261 -r2.262 *** typeobject.c 25 Jun 2004 22:24:35 -0000 2.261 --- typeobject.c 3 Aug 2004 10:21:02 -0000 2.262 *************** *** 4838,4845 **** assert(!PyType_IS_GC(self->ob_type) || _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); ! /* If Py_REF_DEBUG, the original decref dropped _Py_RefTotal, but ! * _Py_NewReference bumped it again, so that's a wash. ! * If Py_TRACE_REFS, _Py_NewReference re-added self to the object ! * chain, so no more to do there either. * If COUNT_ALLOCS, the original decref bumped tp_frees, and * _Py_NewReference bumped tp_allocs: both of those need to be --- 4838,4846 ---- assert(!PyType_IS_GC(self->ob_type) || _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); ! /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so ! * we need to undo that. */ ! _Py_DEC_REFTOTAL; ! /* If Py_TRACE_REFS, _Py_NewReference re-added self to the object ! * chain, so no more to do there. * If COUNT_ALLOCS, the original decref bumped tp_frees, and * _Py_NewReference bumped tp_allocs: both of those need to be Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.174 retrieving revision 2.175 diff -C2 -d -r2.174 -r2.175 *** classobject.c 22 Nov 2003 23:55:50 -0000 2.174 --- classobject.c 3 Aug 2004 10:21:03 -0000 2.175 *************** *** 671,681 **** inst->ob_refcnt = refcnt; _PyObject_GC_TRACK(inst); ! /* If Py_REF_DEBUG, the original decref dropped _Py_RefTotal, ! * but _Py_NewReference bumped it again, so that's a wash. ! * If Py_TRACE_REFS, _Py_NewReference re-added self to the ! * object chain, so no more to do there either. * If COUNT_ALLOCS, the original decref bumped tp_frees, and ! * _Py_NewReference bumped tp_allocs: both of those need to ! * be undone. */ #ifdef COUNT_ALLOCS --- 671,682 ---- inst->ob_refcnt = refcnt; _PyObject_GC_TRACK(inst); ! /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so ! * we need to undo that. */ ! _Py_DEC_REFTOTAL; ! /* If Py_TRACE_REFS, _Py_NewReference re-added self to the ! * object chain, so no more to do there. * If COUNT_ALLOCS, the original decref bumped tp_frees, and ! * _Py_NewReference bumped tp_allocs: both of those need to be ! * undone. */ #ifdef COUNT_ALLOCS From mwh at users.sourceforge.net Tue Aug 3 12:24:07 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 3 12:24:09 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.311,2.312 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22096/Python Modified Files: compile.c Log Message: Don't intern the filename of a file being compiled. Hard to believe it ever helped anything, and it hurts finding reference leaks. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.311 retrieving revision 2.312 diff -C2 -d -r2.311 -r2.312 *** compile.c 2 Aug 2004 11:08:15 -0000 2.311 --- compile.c 3 Aug 2004 10:24:03 -0000 2.312 *************** *** 4732,4736 **** freevars = dict_keys_inorder(sc.c_freevars, PyTuple_GET_SIZE(cellvars)); ! filename = PyString_InternFromString(sc.c_filename); name = PyString_InternFromString(sc.c_name); if (!PyErr_Occurred()) --- 4732,4736 ---- freevars = dict_keys_inorder(sc.c_freevars, PyTuple_GET_SIZE(cellvars)); ! filename = PyString_FromString(sc.c_filename); name = PyString_InternFromString(sc.c_name); if (!PyErr_Occurred()) From mwh at users.sourceforge.net Tue Aug 3 12:46:02 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 3 12:46:05 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_threaded_import.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24692 Modified Files: test_threaded_import.py Log Message: Don't exit test_main() with the lock 'done' held -- there's no cleaner way to guarantee a deadlock on the next call! If I've inadvertently done some damage to this test, sorry (but I don't think I have). Index: test_threaded_import.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_threaded_import.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_threaded_import.py 23 Jul 2002 19:04:06 -0000 1.6 --- test_threaded_import.py 3 Aug 2004 10:45:59 -0000 1.7 *************** *** 52,55 **** --- 52,56 ---- if verbose: print "OK." + done.release() if __name__ == "__main__": From anthonybaxter at users.sourceforge.net Tue Aug 3 13:05:06 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Aug 3 13:05:10 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_cgi.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27271/Lib/test Modified Files: test_cgi.py Log Message: Removed use of 'cgi.initlog()' - the first call to cgi.log is actually an initlog() (and initlog()'s docstring says "don't use this"!) This allows test_cgi to be run repeatedly in a single run of the interpreter. Index: test_cgi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cgi.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_cgi.py 19 Jul 2004 15:37:40 -0000 1.8 --- test_cgi.py 3 Aug 2004 11:05:04 -0000 1.9 *************** *** 194,198 **** print "Testing log" - cgi.initlog() cgi.log("Testing") cgi.logfp = sys.stdout --- 194,197 ---- From mwh at users.sourceforge.net Tue Aug 3 13:08:34 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 3 13:08:36 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_dircache.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27984/Lib/test Modified Files: test_dircache.py Log Message: make this test work when run repeatedly. Index: test_dircache.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_dircache.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_dircache.py 20 Sep 2003 15:52:21 -0000 1.6 --- test_dircache.py 3 Aug 2004 11:08:32 -0000 1.7 *************** *** 6,16 **** import unittest from test.test_support import run_unittest, TESTFN ! import dircache, os, time, sys class DircacheTests(unittest.TestCase): def setUp(self): ! self.tempdir = TESTFN+"_dir" ! os.mkdir(self.tempdir) def tearDown(self): --- 6,15 ---- import unittest from test.test_support import run_unittest, TESTFN ! import dircache, os, time, sys, tempfile class DircacheTests(unittest.TestCase): def setUp(self): ! self.tempdir = tempfile.mkdtemp() def tearDown(self): From mwh at users.sourceforge.net Tue Aug 3 13:14:11 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 3 13:14:15 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_multifile.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28909 Modified Files: test_multifile.py Log Message: More "noone expected this to run twice"ness removal. Index: test_multifile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_multifile.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_multifile.py 17 Feb 2003 14:51:41 -0000 1.3 --- test_multifile.py 3 Aug 2004 11:14:09 -0000 1.4 *************** *** 37,43 **** """ - boundaries = 0 - linecount = 0 - def getMIMEMsg(mf): global boundaries, linecount --- 37,40 ---- *************** *** 58,61 **** --- 55,61 ---- def test_main(): + global boundaries, linecount + boundaries = 0 + linecount = 0 f = cStringIO.StringIO(msg) getMIMEMsg(multifile.MultiFile(f)) From anthonybaxter at users.sourceforge.net Tue Aug 3 13:14:22 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Aug 3 13:14:24 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_getopt.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29006/Lib/test Modified Files: test_getopt.py Log Message: nice tests dont leave little suprises in the environ Index: test_getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_getopt.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_getopt.py 17 May 2003 01:08:35 -0000 1.8 --- test_getopt.py 3 Aug 2004 11:14:19 -0000 1.9 *************** *** 125,128 **** --- 125,129 ---- verify(opts == [('-a', '')]) verify(args == ['arg1', '-b', '1', '--alpha', '--beta=2']) + del os.environ["POSIXLY_CORRECT"] #------------------------------------------------------------------------------ From mwh at users.sourceforge.net Tue Aug 3 13:31:34 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 3 13:31:38 2004 Subject: [Python-checkins] python/dist/src/Modules pyexpat.c,2.84,2.85 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32443 Modified Files: pyexpat.c Log Message: Fix the reference count errors revealed by the test suite... Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.84 retrieving revision 2.85 diff -C2 -d -r2.84 -r2.85 *** pyexpat.c 12 Oct 2003 19:09:37 -0000 2.84 --- pyexpat.c 3 Aug 2004 11:31:31 -0000 2.85 *************** *** 110,113 **** --- 110,114 ---- return 0; } + Py_DECREF(v); return 1; } *************** *** 136,139 **** --- 137,141 ---- PyErr_SetObject(ErrorObject, err); } + Py_DECREF(err); return NULL; } *************** *** 749,753 **** goto finally; } ! args = Py_BuildValue("NN", string_intern(self, name), modelobj); if (args == NULL) { Py_DECREF(modelobj); --- 751,755 ---- goto finally; } ! args = Py_BuildValue("NN", nameobj, modelobj); if (args == NULL) { Py_DECREF(modelobj); From mwh at users.sourceforge.net Tue Aug 3 13:33:31 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 3 13:33:35 2004 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py,1.156,1.157 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32643 Modified Files: regrtest.py Log Message: Check in my refleak hunting code. It's not the 100% solution -- it may not even be the 90% solution -- but it does seem to help. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.156 retrieving revision 1.157 diff -C2 -d -r1.156 -r1.157 *** regrtest.py 26 Jul 2004 12:09:13 -0000 1.156 --- regrtest.py 3 Aug 2004 11:33:28 -0000 1.157 *************** *** 9,25 **** Command line options: ! -v: verbose -- run tests in verbose mode with output to stdout ! -q: quiet -- don't print anything except if a test fails ! -g: generate -- write the output file for a test instead of comparing it ! -x: exclude -- arguments are tests to *exclude* ! -s: single -- run only a single test (see below) ! -r: random -- randomize test execution order ! -f: fromfile -- read names of tests to run from a file (see below) ! -l: findleaks -- if GC is available detect tests that leak memory ! -u: use -- specify which special resource intensive tests to run ! -h: help -- print this text and exit ! -t: threshold -- call gc.set_threshold(N) ! -T: coverage -- turn on code coverage using the trace module ! -L: runleaks -- run the leaks(1) command just before exit If non-option arguments are present, they are names for tests to run, --- 9,26 ---- Command line options: ! -v: verbose -- run tests in verbose mode with output to stdout ! -q: quiet -- don't print anything except if a test fails ! -g: generate -- write the output file for a test instead of comparing it ! -x: exclude -- arguments are tests to *exclude* ! -s: single -- run only a single test (see below) ! -r: random -- randomize test execution order ! -f: fromfile -- read names of tests to run from a file (see below) ! -l: findleaks -- if GC is available detect tests that leak memory ! -u: use -- specify which special resource intensive tests to run ! -h: help -- print this text and exit ! -t: threshold -- call gc.set_threshold(N) ! -T: coverage -- turn on code coverage using the trace module ! -L: runleaks -- run the leaks(1) command just before exit ! -R: huntrleaks -- search for reference leaks (needs debug build, v. slow) If non-option arguments are present, they are names for tests to run, *************** *** 48,51 **** --- 49,60 ---- FreeBSD-derived systems. + -R runs each test several times and examines sys.gettotalrefcount() to + see if the test appears to be leaking references. The argument should + be of the form stab:run:fname where 'stab' is the number of times the + test is run to let gettotalrefcount settle down, 'run' is the number + of times further it is run and 'fname' is the name of the file the + reports are written to. These parameters all have defaults (5, 4 and + "reflog.txt" respectively), so the minimal invocation is '-R ::'. + -u is used to specify which special resource intensive tests to run, such as those requiring large file support or network connectivity. *************** *** 85,88 **** --- 94,98 ---- import random import warnings + import sre import cStringIO import traceback *************** *** 128,132 **** def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, exclude=False, single=False, randomize=False, fromfile=None, ! findleaks=False, use_resources=None, trace=False, runleaks=False): """Execute a test suite. --- 138,143 ---- def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, exclude=False, single=False, randomize=False, fromfile=None, ! findleaks=False, use_resources=None, trace=False, runleaks=False, ! huntrleaks=False): """Execute a test suite. *************** *** 153,161 **** test_support.record_original_stdout(sys.stdout) try: ! opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:TL', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=', 'trace', ! 'runleaks' ]) except getopt.error, msg: --- 164,172 ---- test_support.record_original_stdout(sys.stdout) try: ! opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:TLR:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=', 'trace', ! 'runleaks', 'huntrleaks=' ]) except getopt.error, msg: *************** *** 192,195 **** --- 203,221 ---- elif o in ('-T', '--coverage'): trace = True + elif o in ('-R', '--huntrleaks'): + huntrleaks = a.split(':') + if len(huntrleaks) != 3: + print a, huntrleaks + usage(2, '-R takes three colon-separated arguments') + if len(huntrleaks[0]) == 0: + huntrleaks[0] = 5 + else: + huntrleaks[0] = int(huntrleaks[0]) + if len(huntrleaks[1]) == 0: + huntrleaks[1] = 4 + else: + huntrleaks[1] = int(huntrleaks[1]) + if len(huntrleaks[2]) == 0: + huntrleaks[2] = "reflog.txt" elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] *************** *** 289,293 **** globals=globals(), locals=vars()) else: ! ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) --- 315,319 ---- globals=globals(), locals=vars()) else: ! ok = runtest(test, generate, verbose, quiet, testdir, huntrleaks) if ok > 0: good.append(test) *************** *** 398,402 **** return stdtests + tests ! def runtest(test, generate, verbose, quiet, testdir=None): """Run a single test. test -- the name of the test --- 424,428 ---- return stdtests + tests ! def runtest(test, generate, verbose, quiet, testdir=None, huntrleaks=False): """Run a single test. test -- the name of the test *************** *** 416,419 **** --- 442,447 ---- else: cfp = cStringIO.StringIO() + if huntrleaks: + refrep = open(huntrleaks[2], "a") try: save_stdout = sys.stdout *************** *** 436,439 **** --- 464,511 ---- if indirect_test is not None: indirect_test() + if huntrleaks: + # This code *is* hackish and inelegant, yes. + # But it seems to do the job. + import copy_reg + fs = warnings.filters[:] + ps = copy_reg.dispatch_table.copy() + pic = sys.path_importer_cache.copy() + import gc + def cleanup(): + import _strptime, urlparse, warnings, dircache + from distutils.dir_util import _path_created + _path_created.clear() + warnings.filters[:] = fs + gc.collect() + sre.purge() + _strptime._regex_cache.clear() + urlparse.clear_cache() + copy_reg.dispatch_table.clear() + copy_reg.dispatch_table.update(ps) + sys.path_importer_cache.clear() + sys.path_importer_cache.update(pic) + dircache.reset() + if indirect_test: + def run_the_test(): + indirect_test() + else: + def run_the_test(): + reload(the_module) + deltas = [] + repcount = huntrleaks[0] + huntrleaks[1] + print >> sys.stderr, "beginning", repcount, "repetitions" + print >> sys.stderr, \ + ("1234567890"*(repcount//10 + 1))[:repcount] + for i in range(repcount): + rc = sys.gettotalrefcount() + run_the_test() + sys.stderr.write('.') + cleanup() + deltas.append(sys.gettotalrefcount() - rc - 2) + print >>sys.stderr + if max(map(abs, deltas[-huntrleaks[1]:])) > 0: + print >>refrep, test, 'leaked', \ + deltas[-huntrleaks[1]:], 'references' + # The end of the huntrleaks hackishness. finally: sys.stdout = save_stdout *************** *** 487,491 **** else: expected = test + "\n" ! if output == expected: return 1 print "test", test, "produced unexpected output:" --- 559,563 ---- else: expected = test + "\n" ! if output == expected or huntrleaks: return 1 print "test", test, "produced unexpected output:" From loewis at users.sourceforge.net Tue Aug 3 14:41:45 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 14:41:47 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils cygwinccompiler.py, 1.26, 1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11874 Modified Files: cygwinccompiler.py Log Message: Patch #870382: Automatically add msvcr71 to the list of libraries if Python was built with VC 7.1. Index: cygwinccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cygwinccompiler.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** cygwinccompiler.py 18 Jul 2004 06:14:42 -0000 1.26 --- cygwinccompiler.py 3 Aug 2004 12:41:42 -0000 1.27 *************** *** 123,126 **** --- 123,137 ---- else: self.dll_libraries=[] + # Include the appropriate MSVC runtime library if Python was built + # with MSVC 7.0 or 7.1. + msc_pos = sys.version.find('MSC v.') + if msc_pos != -1: + msc_ver = sys.version[msc_pos+6:msc_pos+10] + if msc_ver == '1300': + # MSVC 7.0 + self.dll_libraries = ['msvcr70'] + elif msc_ver == '1310': + # MSVC 7.1 + self.dll_libraries = ['msvcr71'] # __init__ () *************** *** 309,312 **** --- 320,335 ---- self.dll_libraries=[] + # Include the appropriate MSVC runtime library if Python was built + # with MSVC 7.0 or 7.1. + msc_pos = sys.version.find('MSC v.') + if msc_pos != -1: + msc_ver = sys.version[msc_pos+6:msc_pos+10] + if msc_ver == '1300': + # MSVC 7.0 + self.dll_libraries = ['msvcr70'] + elif msc_ver == '1310': + # MSVC 7.1 + self.dll_libraries = ['msvcr71'] + # __init__ () From loewis at users.sourceforge.net Tue Aug 3 14:59:58 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 15:00:01 2004 Subject: [Python-checkins] python/dist/src/Lib urllib2.py,1.72,1.73 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14620/Lib Modified Files: urllib2.py Log Message: Patch #994595: Recognize Basic auth even if other schemes are offered. Will backport to 2.3. Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** urllib2.py 11 Jul 2004 17:14:12 -0000 1.72 --- urllib2.py 3 Aug 2004 12:59:41 -0000 1.73 *************** *** 715,719 **** authreq = headers.get(authreq, None) if authreq: ! mo = AbstractBasicAuthHandler.rx.match(authreq) if mo: scheme, realm = mo.groups() --- 715,719 ---- authreq = headers.get(authreq, None) if authreq: ! mo = AbstractBasicAuthHandler.rx.search(authreq) if mo: scheme, realm = mo.groups() From loewis at users.sourceforge.net Tue Aug 3 14:59:59 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 15:00:02 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1062,1.1063 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14620/Misc Modified Files: NEWS Log Message: Patch #994595: Recognize Basic auth even if other schemes are offered. Will backport to 2.3. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1062 retrieving revision 1.1063 diff -C2 -d -r1.1062 -r1.1063 *** NEWS 2 Aug 2004 08:30:06 -0000 1.1062 --- NEWS 3 Aug 2004 12:59:55 -0000 1.1063 *************** *** 73,76 **** --- 73,79 ---- ------- + - urllib2 now recognizes Basic authentication even if other authentication + schemes are offered. + - Bug #1001053. wave.open() now accepts unicode filenames. From loewis at users.sourceforge.net Tue Aug 3 15:00:54 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 15:00:56 2004 Subject: [Python-checkins] python/dist/src/Lib urllib2.py,1.53.6.6,1.53.6.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14764/Lib Modified Files: Tag: release23-maint urllib2.py Log Message: Patch #994595: Recognize Basic auth even if other schemes are offered. Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.53.6.6 retrieving revision 1.53.6.7 diff -C2 -d -r1.53.6.6 -r1.53.6.7 *** urllib2.py 10 May 2004 00:32:34 -0000 1.53.6.6 --- urllib2.py 3 Aug 2004 13:00:51 -0000 1.53.6.7 *************** *** 632,636 **** authreq = headers.get(authreq, None) if authreq: ! mo = AbstractBasicAuthHandler.rx.match(authreq) if mo: scheme, realm = mo.groups() --- 632,636 ---- authreq = headers.get(authreq, None) if authreq: ! mo = AbstractBasicAuthHandler.rx.search(authreq) if mo: scheme, realm = mo.groups() From loewis at users.sourceforge.net Tue Aug 3 15:00:54 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 15:00:57 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.134, 1.831.4.135 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14764/Misc Modified Files: Tag: release23-maint NEWS Log Message: Patch #994595: Recognize Basic auth even if other schemes are offered. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.134 retrieving revision 1.831.4.135 diff -C2 -d -r1.831.4.134 -r1.831.4.135 *** NEWS 21 Jul 2004 02:55:54 -0000 1.831.4.134 --- NEWS 3 Aug 2004 13:00:52 -0000 1.831.4.135 *************** *** 44,47 **** --- 44,50 ---- ------- + - Patch #994595: urllib2 now recognizes Basic authentication even if + other authentication schemes are offered. + - Bug #993394. A KeyError was being raised by Thread.__delete() for dummy_threading when called by atexit if an instance of Thread was created in From loewis at users.sourceforge.net Tue Aug 3 15:08:11 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 15:08:14 2004 Subject: [Python-checkins] python/dist/src/Modules md5c.c,2.8,2.9 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15887/Modules Modified Files: md5c.c Log Message: Patch #977074: Move Encode/Decode to the top so gcc can inline them. Index: md5c.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/md5c.c,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -d -r2.8 -r2.9 *** md5c.c 20 Oct 2003 14:01:53 -0000 2.8 --- md5c.c 3 Aug 2004 13:08:07 -0000 2.9 *************** *** 47,52 **** static void MD5Transform(UINT4[4], unsigned char[64]); ! static void Encode(unsigned char *, UINT4 *, unsigned int); ! static void Decode(UINT4 *, unsigned char *, unsigned int); static unsigned char PADDING[64] = { --- 47,83 ---- static void MD5Transform(UINT4[4], unsigned char[64]); ! ! ! /* Encodes input (UINT4) into output (unsigned char). Assumes len is ! a multiple of 4. ! */ ! static void ! Encode(unsigned char *output, UINT4 *input, unsigned int len) ! { ! unsigned int i, j; ! ! for (i = 0, j = 0; j < len; i++, j += 4) { ! output[j] = (unsigned char)(input[i] & 0xff); ! output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); ! output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); ! output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); ! } ! } ! ! ! /* Decodes input (unsigned char) into output (UINT4). Assumes len is ! a multiple of 4. ! */ ! static void ! Decode(UINT4 *output, unsigned char *input, unsigned int len) ! { ! unsigned int i, j; ! ! for (i = 0, j = 0; j < len; i++, j += 4) { ! output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | ! (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); ! } ! } ! static unsigned char PADDING[64] = { *************** *** 257,290 **** memset((POINTER)x, 0, sizeof (x)); } - - - /* Encodes input (UINT4) into output (unsigned char). Assumes len is - a multiple of 4. - */ - static void - Encode(unsigned char *output, UINT4 *input, unsigned int len) - { - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) { - output[j] = (unsigned char)(input[i] & 0xff); - output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); - output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); - output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); - } - } - - - /* Decodes input (unsigned char) into output (UINT4). Assumes len is - a multiple of 4. - */ - static void - Decode(UINT4 *output, unsigned char *input, unsigned int len) - { - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) { - output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | - (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); - } - } --- 288,289 ---- From goodger at users.sourceforge.net Tue Aug 3 15:13:59 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Tue Aug 3 15:14:02 2004 Subject: [Python-checkins] python/nondist/peps pep-0324.txt, 1.1, 1.2 pep-0000.txt, 1.275, 1.276 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16990 Modified Files: pep-0324.txt pep-0000.txt Log Message: update from Peter Astrand Index: pep-0324.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0324.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pep-0324.txt 2 Jan 2004 20:53:01 -0000 1.1 --- pep-0324.txt 3 Aug 2004 13:13:43 -0000 1.2 *************** *** 1,4 **** PEP: 324 ! Title: popen5 - New POSIX process module Version: $Revision$ Last-Modified: $Date$ --- 1,4 ---- PEP: 324 ! Title: process - New POSIX process module Version: $Revision$ Last-Modified: $Date$ *************** *** 34,38 **** process creation. This makes it hard for developers to choose. ! The popen5 modules provides the following enhancements over previous functions: --- 34,38 ---- process creation. This makes it hard for developers to choose. ! The process module provides the following enhancements over previous functions: *************** *** 57,62 **** current functions, without using temporary files. ! - With popen5, it's possible to control if all open file ! descriptors should be closed before the new program is executed. --- 57,62 ---- current functions, without using temporary files. ! - With the process module, it's possible to control if all open ! file descriptors should be closed before the new program is executed. *************** *** 79,83 **** The following points summarizes the design: ! - popen5 was based on popen2, which is tried-and-tested. - The factory functions in popen2 have been removed, because I --- 79,83 ---- The following points summarizes the design: ! - process was based on popen2, which is tried-and-tested. - The factory functions in popen2 have been removed, because I *************** *** 85,99 **** - popen2 contains several factory functions and classes for ! different combinations of redirection. popen5, however, ! contains one single class. Since popen5 supports 12 different ! combinations of redirection, providing a class or function for ! each of them would be cumbersome and not very intuitive. Even ! with popen2, this is a readability problem. For example, many ! people cannot tell the difference between popen2.popen2 and ! popen2.popen4 without using the documentation. ! - One small utility function is provided: popen5.run(). It aims ! to be an enhancement over os.system(), while still very easy to ! use: - It does not use the Standard C function system(), which has --- 85,99 ---- - popen2 contains several factory functions and classes for ! different combinations of redirection. process, however, ! contains one single class. Since the process module supports 12 ! different combinations of redirection, providing a class or ! function for each of them would be cumbersome and not very ! intuitive. Even with popen2, this is a readability problem. ! For example, many people cannot tell the difference between ! popen2.popen2 and popen2.popen4 without using the documentation. ! - Two small utility functions are provided: process.call() and ! process.callv(). These aims to be an enhancement over ! os.system(), while still very easy to use: - It does not use the Standard C function system(), which has *************** *** 106,109 **** --- 106,146 ---- - The return value is easier to work with. + The call() utility function accepts an 'args' argument, just + like the Popen class constructor. It waits for the command to + complete, then returns the returncode attribute. The + implementation is very simple: + + def call(*args, **kwargs): + return Popen(*args, **kwargs).wait() + + The motivation behind the call() function is simple: Starting a + process and wait for it to finish is a common task. + + The callv() function is identical to call(), except that each + non-keyword argument is treated as a program argument. This + gives a slightly nicer syntax. The drawback is that callv() does + not allow specifying the program and it's arguments as a + whitespace-separated string: The entire (first) string would be + intepreted as the executable. The implementation of callv() is + also very simple: + + def callv(*args, **kwargs): + return Popen(args, **kwargs).wait() + + While Popen supports a wide range of options, many users have + simple needs. Many people are using os.system() today, mainly + because it provides a simple interface. Consider this example: + + os.system("stty sane -F " + device) + + With process.call(), this would look like: + + process.call(["stty", "sane", "-F", device]) + + Some people feel that the list brackets are clumsy. With + callv(), they are not needed: + + process.callv("stty", "sane", "-F", device) + - The "preexec" functionality makes it possible to run arbitrary code between fork and exec. One might ask why there are special *************** *** 120,127 **** sense even on Windows. - - No MS Windows support is available, currently. To be able to - provide more functionality than what is already available from - the popen2 module, help from C modules is required. - Specification --- 157,160 ---- *************** *** 129,144 **** This module defines one class called Popen: ! class Popen(args, bufsize=0, argv0=None, stdin=None, stdout=None, stderr=None, ! preexec_fn=None, preexec_args=(), close_fds=0, ! cwd=None, env=None, universal_newlines=0) ! ! Arguments are: ! - args should be a sequence of program arguments. The program to execute is normally the first item in the args sequence, but can ! be explicitly set by using the argv0 argument. The Popen class ! uses os.execvp() to execute the child program. ! - bufsize, if given, has the same meaning as the corresponding argument to the built-in open() function: 0 means unbuffered, 1 --- 162,193 ---- This module defines one class called Popen: ! class Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, ! preexec_fn=None, close_fds=False, ! cwd=None, env=None, universal_newlines=False, ! startupinfo=None, creationflags=0): ! ! ! Arguments are: ! - args should be a sequence of program arguments. The program to execute is normally the first item in the args sequence, but can ! be explicitly set by using the executable argument. ! ! - On UNIX: the Popen class uses os.execvp() to execute the child ! program, which operates on sequences. If args is a string, it ! will be converted to a sequence using the cmdline2list method. ! Please note that syntax for quoting arguments is different from ! a typical UNIX shell. See the documentation of the cmdline2list ! method for more information. ! ! - On Windows: the Popen class uses CreateProcess() to execute the ! child program, which operates on strings. If args is a ! sequence, it will be converted to a string using the ! list2cmdline method. Please note that not all MS Windows ! applications interpret the command line the same way: The ! list2cmdline is designed for applications using the same rules ! as the MS C runtime. ! - bufsize, if given, has the same meaning as the corresponding argument to the built-in open() function: 0 means unbuffered, 1 *************** *** 160,165 **** - If preexec_fn is set to a callable object, this object will be ! called in the child process just before the child is executed, ! with arguments preexec_args. - If close_fds is true, all file descriptors except 0, 1 and 2 --- 209,213 ---- - If preexec_fn is set to a callable object, this object will be ! called in the child process just before the child is executed. - If close_fds is true, all file descriptors except 0, 1 and 2 *************** *** 172,177 **** new process. ! - If universal_newlines is true, the file objects fromchild and ! childerr are opened as a text files, but lines may be terminated by any of '\n', the Unix end-of-line convention, '\r', the Macintosh convention or '\r\n', the Windows convention. All of --- 220,225 ---- new process. ! - If universal_newlines is true, the file objects stdout and ! stderr are opened as a text files, but lines may be terminated by any of '\n', the Unix end-of-line convention, '\r', the Macintosh convention or '\r\n', the Windows convention. All of *************** *** 179,217 **** program. Note: This feature is only available if Python is built with universal newline support (the default). Also, the ! newlines attribute of the file objects fromchild, tochild and ! childerr are not updated by the communicate() method. ! ! The module also defines one shortcut function: ! ! run(*args): ! Run command with arguments. Wait for command to complete, ! then return the returncode attribute. Example: ! ! retcode = popen5.run("stty", "sane") ! Exceptions ---------- Exceptions raised in the child process, before the new program has ! started to execute, will be re-raised in the parent. Additionally, ! the exception object will have one extra attribute called ! 'child_traceback', which is a string containing traceback ! information from the child's point of view. ! The most common exception raised is OSError. This occurs, for example, when trying to execute a non-existent file. Applications should prepare for OSErrors. ! ! A PopenException will also be raised if Popen is called with ! invalid arguments. ! ! Security -------- ! popen5 will never call /bin/sh implicitly. This means that all ! characters, including shell metacharacters, can safely be passed ! to child processes. ! ! Popen objects ------------- --- 227,286 ---- program. Note: This feature is only available if Python is built with universal newline support (the default). Also, the ! newlines attribute of the file objects stdout, stdin and stderr ! are not updated by the communicate() method. + - The startupinfo and creationflags, if given, will be passed to + the underlying CreateProcess() function. They can specify + things such as appearance of the main window and priority for + the new process. (Windows only) + + + This module also defines two shortcut functions: + + - call(*args, **kwargs): + Run command with arguments. Wait for command to complete, then + return the returncode attribute. + + The arguments are the same as for the Popen constructor. Example: + + retcode = call(["ls", "-l"]) + + + - callv(*args, **kwargs): + Run command with arguments. Wait for command to complete, then + return the returncode attribute. + + This function is identical to call(), except that each non-keyword + argument is treated as a program argument. Example: + + retcode = callv("ls", "-l") + + This is equivalent to: + + retcode = call(["ls", "-l"]) + + Exceptions ---------- Exceptions raised in the child process, before the new program has ! started to execute, will be re-raised in the parent. ! Additionally, the exception object will have one extra attribute ! called 'child_traceback', which is a string containing traceback ! information from the childs point of view. ! The most common exception raised is OSError. This occurs, for example, when trying to execute a non-existent file. Applications should prepare for OSErrors. ! ! A ValueError will be raised if Popen is called with invalid arguments. ! ! Security -------- ! Unlike some other popen functions, this implementation will never call ! /bin/sh implicitly. This means that all characters, including shell ! metacharacters, can safely be passed to child processes. ! ! Popen objects ------------- *************** *** 219,234 **** poll() ! Returns -1 if child process hasn't completed yet, or its exit ! status otherwise. See below for a description of how the exit ! status is encoded. ! wait() ! Waits for and returns the exit status of the child process. ! The exit status encodes both the return code of the process ! and information about whether it exited using the exit() ! system call or died due to a signal. Functions to help ! interpret the status code are defined in the os module (the ! W*() family of functions). ! communicate(input=None) Interact with process: Send data to stdin. Read data from --- 288,297 ---- poll() ! Check if child process has terminated. Returns returncode ! attribute. ! wait() ! Wait for child process to terminate. Returns returncode attribute. ! communicate(input=None) Interact with process: Send data to stdin. Read data from *************** *** 244,258 **** The following attributes are also available: ! ! fromchild ! A file object that provides output from the child process. ! ! tochild ! A file object that provides input to the child process. ! ! childerr ! A file object that provides error output from the child ! process. ! pid The process ID of the child process. --- 307,325 ---- The following attributes are also available: ! ! stdin ! If the stdin argument is PIPE, this attribute is a file object ! that provides input to the child process. Otherwise, it is None. ! ! stdout ! If the stdout argument is PIPE, this attribute is a file object ! that provides output from the child process. Otherwise, it is ! None. ! ! stderr ! If the stderr argument is PIPE, this attribute is file object that ! provides error output from the child process. Otherwise, it is ! None. ! pid The process ID of the child process. *************** *** 260,272 **** returncode The child return code. A None value indicates that the ! process hasn't terminated yet. A negative value means that ! the process was terminated by a signal with number ! -returncode. ! ! Open Issues ! Perhaps the module should be called something like "process", ! instead of "popen5". --- 327,340 ---- returncode The child return code. A None value indicates that the ! process hasn't terminated yet. A negative value -N indicates ! that the child was terminated by signal N (UNIX only). ! ! Open Issues ! Currently, the reference implementation requires the "win32all" ! extensions when running on the Windows platform. This dependency ! could probably be eliminated by providing a small "glue" module ! written in C, just like the _winreg module. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.275 retrieving revision 1.276 diff -C2 -d -r1.275 -r1.276 *** pep-0000.txt 19 Jul 2004 18:08:56 -0000 1.275 --- pep-0000.txt 3 Aug 2004 13:13:43 -0000 1.276 *************** *** 120,124 **** S 321 Date/Time Parsing and Formatting Kuchling S 323 Copyable Iterators Martelli ! S 324 popen5 - New POSIX process module Astrand S 325 Resource-Release Support for Generators Pedroni S 330 Python Bytecode Verification Pelletier --- 120,124 ---- S 321 Date/Time Parsing and Formatting Kuchling S 323 Copyable Iterators Martelli ! S 324 process - New POSIX process module Astrand S 325 Resource-Release Support for Generators Pedroni S 330 Python Bytecode Verification Pelletier *************** *** 348,352 **** SF 322 Reverse Iteration Hettinger S 323 Copyable Iterators Martelli ! S 324 popen5 - New POSIX process module Astrand S 325 Resource-Release Support for Generators Pedroni SR 326 A Case for Top and Bottom Values Carlson, Reedy --- 348,352 ---- SF 322 Reverse Iteration Hettinger S 323 Copyable Iterators Martelli ! S 324 process - New POSIX process module Astrand S 325 Resource-Release Support for Generators Pedroni SR 326 A Case for Top and Bottom Values Carlson, Reedy From loewis at users.sourceforge.net Tue Aug 3 16:36:34 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 16:36:37 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libnntplib.tex,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30893/Doc/lib Modified Files: libnntplib.tex Log Message: Patch #823072: add option to NOT use ~/.netrc in nntplib.NNTP(). Index: libnntplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libnntplib.tex,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** libnntplib.tex 30 Jul 2004 16:08:49 -0000 1.31 --- libnntplib.tex 3 Aug 2004 14:36:32 -0000 1.32 *************** *** 55,64 **** \begin{classdesc}{NNTP}{host\optional{, port \optional{, user\optional{, password ! \optional{, readermode}}}}} Return a new instance of the \class{NNTP} class, representing a connection to the NNTP server running on host \var{host}, listening at port \var{port}. The default \var{port} is 119. If the optional \var{user} and \var{password} are provided, ! or if suitable credentials are present in \file{~/.netrc}, the \samp{AUTHINFO USER} and \samp{AUTHINFO PASS} commands are used to identify and authenticate the user to the server. If the optional --- 55,66 ---- \begin{classdesc}{NNTP}{host\optional{, port \optional{, user\optional{, password ! \optional{, readermode} ! \optional{, usenetrc}}}}} Return a new instance of the \class{NNTP} class, representing a connection to the NNTP server running on host \var{host}, listening at port \var{port}. The default \var{port} is 119. If the optional \var{user} and \var{password} are provided, ! or if suitable credentials are present in \file{~/.netrc} and the ! optional flag \var{usenetrc} is true (the default), the \samp{AUTHINFO USER} and \samp{AUTHINFO PASS} commands are used to identify and authenticate the user to the server. If the optional *************** *** 69,72 **** --- 71,77 ---- you get unexpected \code{NNTPPermanentError}s, you might need to set \var{readermode}. \var{readermode} defaults to \code{None}. + \var{usenetrc} defaults to \code{True}. + + \versionchanged[\var{usenetrc} argument added]{2.4} \end{classdesc} From loewis at users.sourceforge.net Tue Aug 3 16:36:34 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 16:36:38 2004 Subject: [Python-checkins] python/dist/src/Lib nntplib.py,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30893/Lib Modified Files: nntplib.py Log Message: Patch #823072: add option to NOT use ~/.netrc in nntplib.NNTP(). Index: nntplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/nntplib.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** nntplib.py 26 Jul 2004 12:40:50 -0000 1.38 --- nntplib.py 3 Aug 2004 14:36:32 -0000 1.39 *************** *** 93,97 **** class NNTP: def __init__(self, host, port=NNTP_PORT, user=None, password=None, ! readermode=None): """Initialize an instance. Arguments: - host: hostname to connect to --- 93,97 ---- class NNTP: def __init__(self, host, port=NNTP_PORT, user=None, password=None, ! readermode=None, usenetrc=True): """Initialize an instance. Arguments: - host: hostname to connect to *************** *** 137,141 **** # Presume that if .netc has an entry, NNRP authentication is required. try: ! if not user: import netrc credentials = netrc.netrc() --- 137,141 ---- # Presume that if .netc has an entry, NNRP authentication is required. try: ! if usenetrc and not user: import netrc credentials = netrc.netrc() From loewis at users.sourceforge.net Tue Aug 3 16:36:35 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 16:36:39 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1063,1.1064 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30893/Misc Modified Files: NEWS Log Message: Patch #823072: add option to NOT use ~/.netrc in nntplib.NNTP(). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1063 retrieving revision 1.1064 diff -C2 -d -r1.1063 -r1.1064 *** NEWS 3 Aug 2004 12:59:55 -0000 1.1063 --- NEWS 3 Aug 2004 14:36:32 -0000 1.1064 *************** *** 73,76 **** --- 73,78 ---- ------- + - nntplib does now allow to ignore a .netrc file. + - urllib2 now recognizes Basic authentication even if other authentication schemes are offered. From mwh at users.sourceforge.net Tue Aug 3 16:37:17 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 3 16:37:20 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_threadsignals.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31073/Lib/test Added Files: test_threadsignals.py Log Message: Argh! This was meant to be part of patch #960406. --- NEW FILE: test_threadsignals.py --- """PyUnit testing that threads honor our signal semantics""" import unittest import thread import signal import os from test import test_support signal_blackboard = { signal.SIGUSR1 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGALRM : {'tripped': 0, 'tripped_by': 0 } } process_pid = os.getpid() signalled_all=thread.allocate_lock() def registerSignals((for_usr1, for_usr2, for_alrm)): usr1 = signal.signal(signal.SIGUSR1, for_usr1) usr2 = signal.signal(signal.SIGUSR2, for_usr2) alrm = signal.signal(signal.SIGALRM, for_alrm) return usr1, usr2, alrm # The signal handler. Just note that the signal occured and # from who. def handle_signals(sig,frame): signal_blackboard[sig]['tripped'] += 1 signal_blackboard[sig]['tripped_by'] = thread.get_ident() # a function that will be spawned as a separate thread. def send_signals(): os.kill(process_pid, signal.SIGUSR1) os.kill(process_pid, signal.SIGUSR2) signalled_all.release() class ThreadSignals(unittest.TestCase): """Test signal handling semantics of threads. We spawn a thread, have the thread send two signals, and wait for it to finish. Check that we got both signals and that they were run by the main thread. """ def test_signals(self): signalled_all.acquire() self.spawnSignallingThread() signalled_all.acquire() # the signals that we asked the kernel to send # will come back, but we don't know when. # (it might even be after the thread exits # and might be out of order.) If we haven't seen # the signals yet, send yet another signal and # wait for it return. if signal_blackboard[signal.SIGUSR2]['tripped'] == 0 \ or signal_blackboard[signal.SIGUSR2]['tripped'] == 0: signal.alarm(1) signal.pause() signal.alarm(0) self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped'], 1) self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped_by'], thread.get_ident()) self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped'], 1) self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped_by'], thread.get_ident()) def spawnSignallingThread(self): thread.start_new_thread(send_signals, ()) def test_main(): oldsigs = registerSignals((handle_signals, handle_signals, handle_signals)) try: test_support.run_unittest(ThreadSignals) finally: registerSignals(oldsigs) if __name__ == '__main__': test_main() From fdrake at users.sourceforge.net Tue Aug 3 16:46:59 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 16:47:01 2004 Subject: [Python-checkins] python/dist/src/Objects weakrefobject.c, 1.13.6.3, 1.13.6.4 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv776/Objects Modified Files: Tag: release23-maint weakrefobject.c Log Message: Be more careful about maintaining the invariants; it was actually possible that the callback-less flavors of the ref or proxy could have been added during GC, so we don't want to replace them. Index: weakrefobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/weakrefobject.c,v retrieving revision 1.13.6.3 retrieving revision 1.13.6.4 diff -C2 -d -r1.13.6.3 -r1.13.6.4 *** weakrefobject.c 4 Feb 2004 23:13:43 -0000 1.13.6.3 --- weakrefobject.c 3 Aug 2004 14:46:57 -0000 1.13.6.4 *************** *** 640,650 **** result = new_weakref(ob, callback); if (result != NULL) { if (callback == NULL) { ! insert_head(result, list); } else { PyWeakReference *prev; - get_basic_refs(*list, &ref, &proxy); prev = (proxy == NULL) ? ref : proxy; if (prev == NULL) --- 640,660 ---- result = new_weakref(ob, callback); if (result != NULL) { + get_basic_refs(*list, &ref, &proxy); if (callback == NULL) { ! if (ref == NULL) ! insert_head(result, list); ! else { ! /* Someone else added a ref without a callback ! during GC. Return that one instead of this one ! to avoid violating the invariants of the list ! of weakrefs for ob. */ ! Py_DECREF(result); ! Py_INCREF(ref); ! result = ref; ! } } else { PyWeakReference *prev; prev = (proxy == NULL) ? ref : proxy; if (prev == NULL) *************** *** 696,701 **** result->ob_type = &_PyWeakref_ProxyType; get_basic_refs(*list, &ref, &proxy); ! if (callback == NULL) prev = ref; else prev = (proxy == NULL) ? ref : proxy; --- 706,721 ---- result->ob_type = &_PyWeakref_ProxyType; get_basic_refs(*list, &ref, &proxy); ! if (callback == NULL) { ! if (proxy != NULL) { ! /* Someone else added a proxy without a callback ! during GC. Return that one instead of this one ! to avoid violating the invariants of the list ! of weakrefs for ob. */ ! Py_DECREF(result); ! Py_INCREF(result = proxy); ! goto skip_insert; ! } prev = ref; + } else prev = (proxy == NULL) ? ref : proxy; *************** *** 705,708 **** --- 725,730 ---- else insert_after(result, prev); + skip_insert: + ; } } From fdrake at users.sourceforge.net Tue Aug 3 16:47:28 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 16:47:31 2004 Subject: [Python-checkins] python/dist/src/Objects weakrefobject.c, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv924/Objects Modified Files: weakrefobject.c Log Message: Be more careful about maintaining the invariants; it was actually possible that the callback-less flavors of the ref or proxy could have been added during GC, so we don't want to replace them. Index: weakrefobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/weakrefobject.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** weakrefobject.c 8 Jul 2004 01:22:31 -0000 1.18 --- weakrefobject.c 3 Aug 2004 14:47:25 -0000 1.19 *************** *** 748,758 **** result = new_weakref(ob, callback); if (result != NULL) { if (callback == NULL) { ! insert_head(result, list); } else { PyWeakReference *prev; - get_basic_refs(*list, &ref, &proxy); prev = (proxy == NULL) ? ref : proxy; if (prev == NULL) --- 748,768 ---- result = new_weakref(ob, callback); if (result != NULL) { + get_basic_refs(*list, &ref, &proxy); if (callback == NULL) { ! if (ref == NULL) ! insert_head(result, list); ! else { ! /* Someone else added a ref without a callback ! during GC. Return that one instead of this one ! to avoid violating the invariants of the list ! of weakrefs for ob. */ ! Py_DECREF(result); ! Py_INCREF(ref); ! result = ref; ! } } else { PyWeakReference *prev; prev = (proxy == NULL) ? ref : proxy; if (prev == NULL) *************** *** 804,809 **** result->ob_type = &_PyWeakref_ProxyType; get_basic_refs(*list, &ref, &proxy); ! if (callback == NULL) prev = ref; else prev = (proxy == NULL) ? ref : proxy; --- 814,829 ---- result->ob_type = &_PyWeakref_ProxyType; get_basic_refs(*list, &ref, &proxy); ! if (callback == NULL) { ! if (proxy != NULL) { ! /* Someone else added a proxy without a callback ! during GC. Return that one instead of this one ! to avoid violating the invariants of the list ! of weakrefs for ob. */ ! Py_DECREF(result); ! Py_INCREF(result = proxy); ! goto skip_insert; ! } prev = ref; + } else prev = (proxy == NULL) ? ref : proxy; *************** *** 813,816 **** --- 833,838 ---- else insert_after(result, prev); + skip_insert: + ; } } From mwh at users.sourceforge.net Tue Aug 3 17:35:31 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 3 17:35:34 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_threadsignals.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9878 Modified Files: test_threadsignals.py Log Message: Add the same guard as test_signal. Index: test_threadsignals.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_threadsignals.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_threadsignals.py 3 Aug 2004 14:37:14 -0000 1.1 --- test_threadsignals.py 3 Aug 2004 15:35:29 -0000 1.2 *************** *** 7,10 **** --- 7,13 ---- from test import test_support + if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos': + raise TestSkipped, "Can't test signal on %s" % sys.platform + signal_blackboard = { signal.SIGUSR1 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 }, From fdrake at users.sourceforge.net Tue Aug 3 17:54:48 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 17:54:51 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_getopt.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13814 Modified Files: test_getopt.py Log Message: avoid fragility: make sure POSIXLY_CORRECT is completely controlled for the tests, and restored properly when done Index: test_getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_getopt.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_getopt.py 3 Aug 2004 11:14:19 -0000 1.9 --- test_getopt.py 3 Aug 2004 15:54:45 -0000 1.10 *************** *** 17,20 **** --- 17,24 ---- raise failure + old_posixly_correct = os.environ.get("POSIXLY_CORRECT") + if old_posixly_correct is not None: + del os.environ["POSIXLY_CORRECT"] + if verbose: print 'Running tests on getopt.short_has_arg' *************** *** 125,129 **** verify(opts == [('-a', '')]) verify(args == ['arg1', '-b', '1', '--alpha', '--beta=2']) ! del os.environ["POSIXLY_CORRECT"] #------------------------------------------------------------------------------ --- 129,138 ---- verify(opts == [('-a', '')]) verify(args == ['arg1', '-b', '1', '--alpha', '--beta=2']) ! ! ! if old_posixly_correct is None: ! del os.environ["POSIXLY_CORRECT"] ! else: ! os.environ["POSIXLY_CORRECT"] = old_posixly_correct #------------------------------------------------------------------------------ From tim_one at users.sourceforge.net Tue Aug 3 17:55:47 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 3 17:55:51 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.36.2.3,1.36.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12755/Lib Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Repair failure of test_difflib. difflib has a nasty one: >>> for line in results: print repr(line) ... [results go here] That managed to break the intent (of doctest's parsing) that an example would end with a newline iff it was a multi-line example. That example really isn't multiline, but ended up with a trailing newline anyway. Edward's new code asserted this invariant, which the old difflib code did not do. So fixed the parsing to get rid of the trailing newline in this case. But then it turned out that compile(... "single") doesn't accept a "block opener: body" statement *without* a trailing newline, raising SyntaxError if you try. So changed compilation to always append a newline. test_difflib passes now. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.3 retrieving revision 1.36.2.4 diff -C2 -d -r1.36.2.3 -r1.36.2.4 *** doctest.py 3 Aug 2004 04:08:52 -0000 1.36.2.3 --- doctest.py 3 Aug 2004 15:55:29 -0000 1.36.2.4 *************** *** 510,513 **** --- 510,514 ---- i, n = 0, len(lines) while i < n: + # Search for an example (a PS1 line). line = lines[i] i = i + 1 *************** *** 515,526 **** if m is None: continue j = m.end(0) # beyond the prompt if isEmpty(line, j) or isComment(line, j): # a bare prompt or comment -- not interesting continue lineno = i - 1 if line[j] != " ": raise ValueError('line %r of the docstring for %s lacks ' ! 'blanks after %s: %r' % (lineno, self.name, self._PS1, line)) --- 516,529 ---- if m is None: continue + # line is a PS1 line. j = m.end(0) # beyond the prompt if isEmpty(line, j) or isComment(line, j): # a bare prompt or comment -- not interesting continue + # line is a non-trivial PS1 line. lineno = i - 1 if line[j] != " ": raise ValueError('line %r of the docstring for %s lacks ' ! 'blank after %s: %r' % (lineno, self.name, self._PS1, line)) *************** *** 542,551 **** else: break if len(source) == 1: source = source[0] else: - # get rid of useless null line from trailing empty "..." - if source[-1] == "": - del source[-1] source = "\n".join(source) + "\n" # suck up response --- 545,555 ---- else: break + # get rid of useless null line from trailing empty "..." + if source[-1] == "": + assert len(source) > 1 + del source[-1] if len(source) == 1: source = source[0] else: source = "\n".join(source) + "\n" # suck up response *************** *** 1161,1165 **** # keyboard interrupts.) try: ! exec compile(example.source, "", "single", compileflags, 1) in globs exception = None --- 1165,1173 ---- # keyboard interrupts.) try: ! # If the example is a compound statement on one line, ! # like "if 1: print 2", then compile() requires a ! # trailing newline. Rather than analyze that, always ! # append one (it never hurts). ! exec compile(example.source + '\n', "", "single", compileflags, 1) in globs exception = None *************** *** 1967,1971 **** Traceback (most recent call last): [...] ! ValueError: foo --- 1975,1979 ---- Traceback (most recent call last): [...] ! ValueError: foo From anthonybaxter at users.sourceforge.net Tue Aug 3 17:57:41 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Aug 3 17:57:45 2004 Subject: [Python-checkins] python/dist/src/Include patchlevel.h,2.77,2.78 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14430 Modified Files: patchlevel.h Log Message: on to a2! Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.77 retrieving revision 2.78 diff -C2 -d -r2.77 -r2.78 *** patchlevel.h 9 Jul 2004 07:19:21 -0000 2.77 --- patchlevel.h 3 Aug 2004 15:57:39 -0000 2.78 *************** *** 24,31 **** #define PY_MICRO_VERSION 0 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA ! #define PY_RELEASE_SERIAL 1 /* Version as a string */ ! #define PY_VERSION "2.4a1+" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. --- 24,31 ---- #define PY_MICRO_VERSION 0 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA ! #define PY_RELEASE_SERIAL 2 /* Version as a string */ ! #define PY_VERSION "2.4a2" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. From tim_one at users.sourceforge.net Tue Aug 3 17:58:11 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 3 17:58:14 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.36.2.4,1.36.2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14425/Lib Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Use augmented assignment where appropriate. That feature didn't exist when doctest was first written, and it aids readability. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.4 retrieving revision 1.36.2.5 diff -C2 -d -r1.36.2.4 -r1.36.2.5 *** doctest.py 3 Aug 2004 15:55:29 -0000 1.36.2.4 --- doctest.py 3 Aug 2004 15:58:09 -0000 1.36.2.5 *************** *** 512,516 **** # Search for an example (a PS1 line). line = lines[i] ! i = i + 1 m = isPS1(line) if m is None: --- 512,516 ---- # Search for an example (a PS1 line). line = lines[i] ! i += 1 m = isPS1(line) if m is None: *************** *** 528,532 **** (lineno, self.name, self._PS1, line)) ! j = j + 1 blanks = m.group(1) nblanks = len(blanks) --- 528,532 ---- (lineno, self.name, self._PS1, line)) ! j += 1 blanks = m.group(1) nblanks = len(blanks) *************** *** 542,546 **** 'has inconsistent leading whitespace: %r' % (i, self.name, line)) ! i = i + 1 else: break --- 542,546 ---- 'has inconsistent leading whitespace: %r' % (i, self.name, line)) ! i += 1 else: break *************** *** 564,568 **** (i, self.name, line)) want.append(line[nblanks:]) ! i = i + 1 line = lines[i] if isPS1(line) or isEmpty(line): --- 564,568 ---- (i, self.name, line)) want.append(line[nblanks:]) ! i += 1 line = lines[i] if isPS1(line) or isEmpty(line): *************** *** 1305,1310 **** name, (f, t) = x assert f <= t ! totalt = totalt + t ! totalf = totalf + f if t == 0: notests.append(name) --- 1305,1310 ---- name, (f, t) = x assert f <= t ! totalt += t ! totalf += f if t == 0: notests.append(name) From fdrake at users.sourceforge.net Tue Aug 3 18:02:38 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 18:02:40 2004 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.52,1.53 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15262 Modified Files: concrete.tex Log Message: let's avoid the extra nesting where reasonable Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** concrete.tex 2 Aug 2004 21:56:33 -0000 1.52 --- concrete.tex 3 Aug 2004 16:02:35 -0000 1.53 *************** *** 193,197 **** \end{cfuncdesc} ! \subsubsection{Boolean Objects \label{boolObjects}} Booleans in Python are implemented as a subclass of integers. There --- 193,197 ---- \end{cfuncdesc} ! \subsection{Boolean Objects \label{boolObjects}} Booleans in Python are implemented as a subclass of integers. There From tim_one at users.sourceforge.net Tue Aug 3 18:07:36 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 3 18:07:38 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.5.18.3, 1.5.18.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15983/Lib/test Modified Files: Tag: tim-doctest-branch test_doctest.py Log Message: I changed an error msg, so now change the test of it to match. ("blanks" aren't required after PS1, only (a -- singular) blank is.) Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.5.18.3 retrieving revision 1.5.18.4 diff -C2 -d -r1.5.18.3 -r1.5.18.4 *** test_doctest.py 3 Aug 2004 04:09:51 -0000 1.5.18.3 --- test_doctest.py 3 Aug 2004 16:07:33 -0000 1.5.18.4 *************** *** 115,119 **** >>> doctest.DocTest(docstring, 'some_test', 'filename', 0) Traceback (most recent call last): ! ValueError: line 0 of the docstring for some_test lacks blanks after >>>: '>>>print 1' """ --- 115,119 ---- >>> doctest.DocTest(docstring, 'some_test', 'filename', 0) Traceback (most recent call last): ! ValueError: line 0 of the docstring for some_test lacks blank after >>>: '>>>print 1' """ *************** *** 382,386 **** 40 1 A.double 40 1 A.get ! >>> def objfilter(obj): ... return isinstance(obj, (staticmethod, classmethod)) --- 382,386 ---- 40 1 A.double 40 1 A.get ! >>> def objfilter(obj): ... return isinstance(obj, (staticmethod, classmethod)) *************** *** 671,675 **** from line #0 of f Expected: ! 1 2 3 Got: 1 2 3 --- 671,675 ---- from line #0 of f Expected: ! 1 2 3 Got: 1 2 3 *************** *** 751,756 **** from line #1 of f Differences (unified diff): ! --- Expected ! +++ Got @@ -1,8 +1,8 @@ a --- 751,756 ---- from line #1 of f Differences (unified diff): ! --- Expected ! +++ Got @@ -1,8 +1,8 @@ a *************** *** 777,782 **** from line #1 of f Differences (unified diff): ! *** Expected ! --- Got *************** *** 1,8 **** --- 777,782 ---- from line #1 of f Differences (unified diff): ! *** Expected ! --- Got *************** *** 1,8 **** *************** *** 840,844 **** ... >>> print range(10) # Should fail ... [0, 1, ..., 9] ! ... >>> doctest: +ELLIPSIS +NORMALIZE_WHITESPACE ... >>> print range(10) # Should succeed ... [0, 1, ..., 9] --- 840,844 ---- ... >>> print range(10) # Should fail ... [0, 1, ..., 9] ! ... >>> doctest: +ELLIPSIS +NORMALIZE_WHITESPACE ... >>> print range(10) # Should succeed ... [0, 1, ..., 9] From fdrake at users.sourceforge.net Tue Aug 3 18:14:16 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 18:14:18 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_threadsignals.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18587 Modified Files: test_threadsignals.py Log Message: add missing import! Index: test_threadsignals.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_threadsignals.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_threadsignals.py 3 Aug 2004 15:35:29 -0000 1.2 --- test_threadsignals.py 3 Aug 2004 16:14:13 -0000 1.3 *************** *** 5,8 **** --- 5,9 ---- import signal import os + import sys from test import test_support From fdrake at users.sourceforge.net Tue Aug 3 18:37:42 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 18:37:45 2004 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.80,1.81 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23612/Doc/dist Modified Files: dist.tex Log Message: This allows additional commands to be provided for existing setup.py scripts without modifying either the distutils installation or the setup.py scripts of packages with which the new commands will be used. Specifically, an option is added to distutils that allows additional packages to be searched for command implementations in addition to distutils.command. The additional packages can be specified on the command line or via the installation or personal configuration files already loaded by distutils. For discussion, see the thread starting with: http://mail.python.org/pipermail/distutils-sig/2004-August/004112.html This closes SF patch #102241. Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** dist.tex 2 Aug 2004 23:05:25 -0000 1.80 --- dist.tex 3 Aug 2004 16:37:39 -0000 1.81 *************** *** 1947,1950 **** --- 1947,1981 ---- will need to have the new command implementation. + Beginning with Python 2.4, a third option is available, intended to + allow new commands to be added which can support existing + \file{setup.py} scripts without requiring modifications to the Python + installation. This is expected to allow third-party extensions to + provide support for additional packaging systems, but the commands can + be used for anything distutils commands can be used for. A new + configuration option, \option{command\_packages} (command-line option + \longprogramopt{command-packages}), can be used to specify additional + packages to be searched for modules implementing commands. Like all + distutils options, this can be specified on the command line or in a + configuration file. This option can only be set in the + \code{[global]} section of a configuration file, or before any + commands on the command line. If set in a configuration file, it can + be overridden from the command line; setting it to an empty string on + the command line causes the default to be used. This should never be + set in a configuration file provided with a package. + + This new option can be used to add any number of packages to the list + of packages searched for command implementations; multiple package + names should be separated by commas. When not specified, the search + is only performed in the \module{distutils.command} package. When + \file{setup.py} is run with the option + \longprogramopt{command-packages} \programopt{distcmds,buildcmds}, + however, the packages \module{distutils.command}, \module{distcmds}, + and \module{buildcmds} will be searched in that order. New commands + are expected to be implemented in modules of the same name as the + command by classes sharing the same name. Given the example command + line option above, the command \command{bdist\_openpkg} could be + implemented by the class \class{distcmds.bdist_openpkg.bdist_openpkg} + or \class{buildcmds.bdist_openpkg.bdist_openpkg}. + \chapter{Command Reference} From fdrake at users.sourceforge.net Tue Aug 3 18:37:43 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 18:37:47 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils dist.py,1.68,1.69 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23612/Lib/distutils Modified Files: dist.py Log Message: This allows additional commands to be provided for existing setup.py scripts without modifying either the distutils installation or the setup.py scripts of packages with which the new commands will be used. Specifically, an option is added to distutils that allows additional packages to be searched for command implementations in addition to distutils.command. The additional packages can be specified on the command line or via the installation or personal configuration files already loaded by distutils. For discussion, see the thread starting with: http://mail.python.org/pipermail/distutils-sig/2004-August/004112.html This closes SF patch #102241. Index: dist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/dist.py,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** dist.py 18 Jul 2004 06:14:42 -0000 1.68 --- dist.py 3 Aug 2004 16:37:39 -0000 1.69 *************** *** 142,145 **** --- 142,153 ---- self.cmdclass = {} + # 'command_packages' is a list of packages in which commands + # are searched for. The factory for command 'foo' is expected + # to be named 'foo' in the module 'foo' in one of the packages + # named here. This list is searched from the left; an error + # is raised if no named package provides the command being + # searched for. (Always access using get_command_packages().) + self.command_packages = None + # 'script_name' and 'script_args' are usually set to sys.argv[0] # and sys.argv[1:], but they can be overridden when the caller is *************** *** 407,410 **** --- 415,420 ---- elif opt in ('verbose', 'dry_run'): # ugh! setattr(self, opt, strtobool(val)) + else: + setattr(self, opt, val) except ValueError, msg: raise DistutilsOptionError, msg *************** *** 438,446 **** # that allows the user to interactively specify the "command line". # if sys.platform == 'mac': import EasyDialogs cmdlist = self.get_command_list() self.script_args = EasyDialogs.GetArgv( ! self.global_options + self.display_options, cmdlist) # We have to parse the command line a bit at a time -- global --- 448,457 ---- # that allows the user to interactively specify the "command line". # + toplevel_options = self._get_toplevel_options() if sys.platform == 'mac': import EasyDialogs cmdlist = self.get_command_list() self.script_args = EasyDialogs.GetArgv( ! toplevel_options + self.display_options, cmdlist) # We have to parse the command line a bit at a time -- global *************** *** 452,456 **** self.commands = [] ! parser = FancyGetopt(self.global_options + self.display_options) parser.set_negative_aliases(self.negative_opt) parser.set_aliases({'licence': 'license'}) --- 463,467 ---- self.commands = [] ! parser = FancyGetopt(toplevel_options + self.display_options) parser.set_negative_aliases(self.negative_opt) parser.set_aliases({'licence': 'license'}) *************** *** 489,492 **** --- 500,514 ---- # parse_command_line() + def _get_toplevel_options (self): + """Return the non-display options recognized at the top level. + + This includes options that are recognized *only* at the top + level as well as options recognized for commands. + """ + return self.global_options + [ + ("command-packages=", None, + "list of packages that provide distutils commands"), + ] + def _parse_command_opts (self, parser, args): """Parse the command-line options for a single command. *************** *** 587,591 **** # _parse_command_opts () - def finalize_options (self): """Set final values for all the options on the Distribution --- 609,612 ---- *************** *** 628,632 **** if global_options: ! parser.set_option_table(self.global_options) parser.print_help("Global options:") print --- 649,657 ---- if global_options: ! if display_options: ! options = self._get_toplevel_options() ! else: ! options = self.global_options ! parser.set_option_table(options) parser.print_help("Global options:") print *************** *** 792,795 **** --- 817,833 ---- # -- Command class/object methods ---------------------------------- + def get_command_packages (self): + """Return a list of packages from which commands are loaded.""" + pkgs = self.command_packages + if not isinstance(pkgs, type([])): + pkgs = string.split(pkgs or "", ",") + for i in range(len(pkgs)): + pkgs[i] = string.strip(pkgs[i]) + pkgs = filter(None, pkgs) + if "distutils.command" not in pkgs: + pkgs.insert(0, "distutils.command") + self.command_packages = pkgs + return pkgs + def get_command_class (self, command): """Return the class that implements the Distutils command named by *************** *** 808,831 **** return klass ! module_name = 'distutils.command.' + command ! klass_name = command ! try: ! __import__ (module_name) ! module = sys.modules[module_name] ! except ImportError: ! raise DistutilsModuleError, \ ! "invalid command '%s' (no module named '%s')" % \ ! (command, module_name) ! try: ! klass = getattr(module, klass_name) ! except AttributeError: ! raise DistutilsModuleError, \ ! "invalid command '%s' (no class '%s' in module '%s')" \ ! % (command, klass_name, module_name) - self.cmdclass[command] = klass - return klass # get_command_class () --- 846,871 ---- return klass ! for pkgname in self.get_command_packages(): ! module_name = "%s.%s" % (pkgname, command) ! klass_name = command ! try: ! __import__ (module_name) ! module = sys.modules[module_name] ! except ImportError: ! continue ! try: ! klass = getattr(module, klass_name) ! except AttributeError: ! raise DistutilsModuleError, \ ! "invalid command '%s' (no class '%s' in module '%s')" \ ! % (command, klass_name, module_name) ! ! self.cmdclass[command] = klass ! return klass ! ! raise DistutilsModuleError("invalid command '%s'" % command) # get_command_class () From fdrake at users.sourceforge.net Tue Aug 3 18:37:42 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 18:37:47 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/tests test_dist.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23612/Lib/distutils/tests Added Files: test_dist.py Log Message: This allows additional commands to be provided for existing setup.py scripts without modifying either the distutils installation or the setup.py scripts of packages with which the new commands will be used. Specifically, an option is added to distutils that allows additional packages to be searched for command implementations in addition to distutils.command. The additional packages can be specified on the command line or via the installation or personal configuration files already loaded by distutils. For discussion, see the thread starting with: http://mail.python.org/pipermail/distutils-sig/2004-August/004112.html This closes SF patch #102241. --- NEW FILE: test_dist.py --- """Tests for distutils.dist.""" import distutils.cmd import distutils.dist import os import shutil import sys import tempfile import unittest from test.test_support import TESTFN class test_dist(distutils.cmd.Command): """Sample distutils extension command.""" user_options = [ ("sample-option=", "S", "help text"), ] def initialize_options(self): self.sample_option = None class TestDistribution(distutils.dist.Distribution): """Distribution subclasses that avoids the default search for configuration files. The ._config_files attribute must be set before .parse_config_files() is called. """ def find_config_files(self): return self._config_files class DistributionTestCase(unittest.TestCase): def setUp(self): self.argv = sys.argv[:] del sys.argv[1:] def tearDown(self): sys.argv[:] = self.argv def create_distribution(self, configfiles=()): d = TestDistribution() d._config_files = configfiles d.parse_config_files() d.parse_command_line() return d def test_command_packages_unspecified(self): sys.argv.append("build") d = self.create_distribution() self.assertEqual(d.get_command_packages(), ["distutils.command"]) def test_command_packages_cmdline(self): sys.argv.extend(["--command-packages", "foo.bar,distutils.tests", "test_dist", "-Ssometext", ]) d = self.create_distribution() # let's actually try to load our test command: self.assertEqual(d.get_command_packages(), ["distutils.command", "foo.bar", "distutils.tests"]) cmd = d.get_command_obj("test_dist") self.assert_(isinstance(cmd, test_dist)) self.assertEqual(cmd.sample_option, "sometext") def test_command_packages_configfile(self): sys.argv.append("build") f = open(TESTFN, "w") try: print >>f, "[global]" print >>f, "command_packages = foo.bar, splat" f.close() d = self.create_distribution([TESTFN]) self.assertEqual(d.get_command_packages(), ["distutils.command", "foo.bar", "splat"]) # ensure command line overrides config: sys.argv[1:] = ["--command-packages", "spork", "build"] d = self.create_distribution([TESTFN]) self.assertEqual(d.get_command_packages(), ["distutils.command", "spork"]) # Setting --command-packages to '' should cause the default to # be used even if a config file specified something else: sys.argv[1:] = ["--command-packages", "", "build"] d = self.create_distribution([TESTFN]) self.assertEqual(d.get_command_packages(), ["distutils.command"]) finally: os.unlink(TESTFN) def test_suite(): return unittest.makeSuite(DistributionTestCase) From tim_one at users.sourceforge.net Tue Aug 3 18:45:49 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 3 18:45:52 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.5.18.4, 1.5.18.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24804/Lib/test Modified Files: Tag: tim-doctest-branch test_doctest.py Log Message: The NORMALIZE_WHITESPACE test relied on preserving trailing blanks in Python source code. That's too brittle, so changed the test. If it's really required, it has to be tricked via an \x20 escape or string interpolation. Don't think it's worth the pain. Two of the diff-option tests still fail here. They're a bit mind- boggling . Still unsure why. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.5.18.4 retrieving revision 1.5.18.5 diff -C2 -d -r1.5.18.4 -r1.5.18.5 *** test_doctest.py 3 Aug 2004 16:07:33 -0000 1.5.18.4 --- test_doctest.py 3 Aug 2004 16:45:46 -0000 1.5.18.5 *************** *** 662,666 **** >>> def f(x): ! ... '>>> print 1, 2, 3\n 1 2 \n 3' >>> # Without the flag: --- 662,666 ---- >>> def f(x): ! ... '>>> print 1, 2, 3\n 1 2\n 3' >>> # Without the flag: From fdrake at users.sourceforge.net Tue Aug 3 19:58:56 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 19:59:00 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_time.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7177/Lib/test Modified Files: test_time.py Log Message: allow ctime(), gmtime(), and localtime() to take None as equivalent to an omitted arg (closes SF bug #658254, patch #663482) Index: test_time.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_time.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** test_time.py 20 Jun 2004 02:50:15 -0000 1.17 --- test_time.py 3 Aug 2004 17:58:54 -0000 1.18 *************** *** 186,189 **** --- 186,206 ---- self.assertRaises(ValueError, func, unreasonable) + def test_ctime_without_arg(self): + # Not sure how to check the values, since the clock could tick + # at any time. Make sure these are at least accepted and + # don't raise errors. + time.ctime() + time.ctime(None) + + def test_gmtime_without_arg(self): + t0 = time.mktime(time.gmtime()) + t1 = time.mktime(time.gmtime(None)) + self.assert_(0 <= (t1-t0) < 0.2) + + def test_localtime_without_arg(self): + t0 = time.mktime(time.localtime()) + t1 = time.mktime(time.localtime(None)) + self.assert_(0 <= (t1-t0) < 0.2) + def test_main(): test_support.run_unittest(TimeTestCase) From fdrake at users.sourceforge.net Tue Aug 3 19:58:56 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 19:59:01 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libtime.tex,1.64,1.65 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7177/Doc/lib Modified Files: libtime.tex Log Message: allow ctime(), gmtime(), and localtime() to take None as equivalent to an omitted arg (closes SF bug #658254, patch #663482) Index: libtime.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtime.tex,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** libtime.tex 10 May 2004 18:53:00 -0000 1.64 --- libtime.tex 3 Aug 2004 17:58:54 -0000 1.65 *************** *** 158,166 **** \begin{funcdesc}{ctime}{\optional{secs}} Convert a time expressed in seconds since the epoch to a string ! representing local time. If \var{secs} is not provided, the current time ! as returned by \function{time()} is used. \code{ctime(\var{secs})} ! is equivalent to \code{asctime(localtime(\var{secs}))}. Locale information is not used by \function{ctime()}. \versionchanged[Allowed \var{secs} to be omitted]{2.1} \end{funcdesc} --- 158,169 ---- \begin{funcdesc}{ctime}{\optional{secs}} Convert a time expressed in seconds since the epoch to a string ! representing local time. If \var{secs} is not provided or ! \constant{None}, the current time as returned by \function{time()} is ! used. \code{ctime(\var{secs})} is equivalent to ! \code{asctime(localtime(\var{secs}))}. Locale information is not used by \function{ctime()}. \versionchanged[Allowed \var{secs} to be omitted]{2.1} + \versionchanged[If \var{secs} is \constant{None}, the current time is + used]{2.3} \end{funcdesc} *************** *** 172,185 **** 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 \var{secs} is not ! provided, the current time as returned by \function{time()} is used. ! Fractions of a second are ignored. See above for a description of the ! \class{struct_time} object. \versionchanged[Allowed \var{secs} to be omitted]{2.1} \end{funcdesc} \begin{funcdesc}{localtime}{\optional{secs}} ! Like \function{gmtime()} but converts to local time. The dst flag is ! set to \code{1} when DST applies to the given time. \versionchanged[Allowed \var{secs} to be omitted]{2.1} \end{funcdesc} --- 175,194 ---- 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 \var{secs} is not ! provided or \constant{None}, the current time as returned by ! \function{time()} is used. Fractions of a second are ignored. See ! above for a description of the \class{struct_time} object. \versionchanged[Allowed \var{secs} to be omitted]{2.1} + \versionchanged[If \var{secs} is \constant{None}, the current time is + used]{2.3} \end{funcdesc} \begin{funcdesc}{localtime}{\optional{secs}} ! Like \function{gmtime()} but converts to local time. If \var{secs} is ! not provided or \constant{None}, the current time as returned by ! \function{time()} is used. The dst flag is set to \code{1} when DST ! applies to the given time. \versionchanged[Allowed \var{secs} to be omitted]{2.1} + \versionchanged[If \var{secs} is \constant{None}, the current time is + used]{2.3} \end{funcdesc} From fdrake at users.sourceforge.net Tue Aug 3 19:59:12 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 19:59:15 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1064,1.1065 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7177/Misc Modified Files: NEWS Log Message: allow ctime(), gmtime(), and localtime() to take None as equivalent to an omitted arg (closes SF bug #658254, patch #663482) Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1064 retrieving revision 1.1065 diff -C2 -d -r1.1064 -r1.1065 *** NEWS 3 Aug 2004 14:36:32 -0000 1.1064 --- NEWS 3 Aug 2004 17:58:54 -0000 1.1065 *************** *** 73,76 **** --- 73,81 ---- ------- + - The following methods in time support passing of None: ctime(), gmtime(), + and localtime(). If None is provided, the current time is used (the + same as when the argument is omitted). + [SF bug 658254, patch 663482] + - nntplib does now allow to ignore a .netrc file. From fdrake at users.sourceforge.net Tue Aug 3 19:59:12 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 19:59:16 2004 Subject: [Python-checkins] python/dist/src/Modules timemodule.c,2.143,2.144 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7177/Modules Modified Files: timemodule.c Log Message: allow ctime(), gmtime(), and localtime() to take None as equivalent to an omitted arg (closes SF bug #658254, patch #663482) Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.143 retrieving revision 2.144 diff -C2 -d -r2.143 -r2.144 *** timemodule.c 20 Jul 2004 22:34:37 -0000 2.143 --- timemodule.c 3 Aug 2004 17:58:55 -0000 2.144 *************** *** 278,288 **** } static PyObject * time_gmtime(PyObject *self, PyObject *args) { double when; ! if (PyTuple_Size(args) == 0) ! when = floattime(); ! if (!PyArg_ParseTuple(args, "|d:gmtime", &when)) return NULL; return time_convert(when, gmtime); --- 278,308 ---- } + /* Parse arg tuple that can contain an optional float-or-None value; + format needs to be "|O:name". + Returns non-zero on success (parallels PyArg_ParseTuple). + */ + static int + parse_time_double_args(PyObject *args, char *format, double *pwhen) + { + PyObject *ot = NULL; + + if (!PyArg_ParseTuple(args, format, &ot)) + return 0; + if (ot == NULL || ot == Py_None) + *pwhen = floattime(); + else { + double when = PyFloat_AsDouble(ot); + if (PyErr_Occurred()) + return 0; + *pwhen = when; + } + return 1; + } + static PyObject * time_gmtime(PyObject *self, PyObject *args) { double when; ! if (!parse_time_double_args(args, "|O:gmtime", &when)) return NULL; return time_convert(when, gmtime); *************** *** 300,306 **** { double when; ! if (PyTuple_Size(args) == 0) ! when = floattime(); ! if (!PyArg_ParseTuple(args, "|d:localtime", &when)) return NULL; return time_convert(when, localtime); --- 320,324 ---- { double when; ! if (!parse_time_double_args(args, "|O:localtime", &when)) return NULL; return time_convert(when, localtime); *************** *** 503,514 **** time_ctime(PyObject *self, PyObject *args) { ! double dt; time_t tt; char *p; ! if (PyTuple_Size(args) == 0) tt = time(NULL); else { ! if (!PyArg_ParseTuple(args, "|d:ctime", &dt)) return NULL; tt = _PyTime_DoubleToTimet(dt); --- 521,535 ---- time_ctime(PyObject *self, PyObject *args) { ! PyObject *ot = NULL; time_t tt; char *p; ! if (!PyArg_ParseTuple(args, "|O:ctime", &ot)) ! return NULL; ! if (ot == NULL || ot == Py_None) tt = time(NULL); else { ! double dt = PyFloat_AsDouble(ot); ! if (PyErr_Occurred()) return NULL; tt = _PyTime_DoubleToTimet(dt); From loewis at users.sourceforge.net Tue Aug 3 20:36:28 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 20:36:30 2004 Subject: [Python-checkins] python/dist/src/Lib/lib-tk FileDialog.py, 1.10, 1.11 SimpleDialog.py, 1.5, 1.6 Tkinter.py, 1.180, 1.181 tkSimpleDialog.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14004 Modified Files: FileDialog.py SimpleDialog.py Tkinter.py tkSimpleDialog.py Log Message: Wait for visibility before setting a grab. Fixes #946153. Index: FileDialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/FileDialog.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** FileDialog.py 12 Feb 2004 17:35:09 -0000 1.10 --- FileDialog.py 3 Aug 2004 18:36:25 -0000 1.11 *************** *** 120,123 **** --- 120,124 ---- self.filter_command() self.selection.focus_set() + self.top.wait_visibility() # window needs to be visible for the grab self.top.grab_set() self.how = None Index: SimpleDialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/SimpleDialog.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SimpleDialog.py 22 Mar 2004 21:49:47 -0000 1.5 --- SimpleDialog.py 3 Aug 2004 18:36:25 -0000 1.6 *************** *** 65,68 **** --- 65,69 ---- def go(self): + self.root.wait_visibility() self.root.grab_set() self.root.mainloop() Index: Tkinter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v retrieving revision 1.180 retrieving revision 1.181 diff -C2 -d -r1.180 -r1.181 *** Tkinter.py 18 Jul 2004 06:14:44 -0000 1.180 --- Tkinter.py 3 Aug 2004 18:36:25 -0000 1.181 *************** *** 1547,1551 **** of an appliation. It has an associated Tcl interpreter.""" _w = '.' ! def __init__(self, screenName=None, baseName=None, className='Tk', useTk=1): """Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see --- 1547,1552 ---- of an appliation. It has an associated Tcl interpreter.""" _w = '.' ! def __init__(self, screenName=None, baseName=None, className='Tk', ! useTk=1, sync=0, use=None): """Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see *************** *** 1566,1570 **** baseName = baseName + ext interactive = 0 ! self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk) if useTk: self._loadtk() --- 1567,1571 ---- baseName = baseName + ext interactive = 0 ! self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) if useTk: self._loadtk() Index: tkSimpleDialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/tkSimpleDialog.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tkSimpleDialog.py 6 Apr 2003 09:00:54 -0000 1.9 --- tkSimpleDialog.py 3 Aug 2004 18:36:25 -0000 1.10 *************** *** 62,65 **** --- 62,66 ---- self.buttonbox() + self.wait_visibility() # window needs to be visible for the grab self.grab_set() From tim_one at users.sourceforge.net Tue Aug 3 20:45:27 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 3 20:45:30 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.36.2.5,1.36.2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14570 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Rehabilitate the old _SpoofOut class, but this time as a subclass of StringIO. It's necessary that doctest fight with Python's "softspace" gimmick, and hiding that fight in methods of the output-capturing class is the only robust way to do it (softspace is always a potential problem, and when it bites it causes an earlier test to screw up a later test). test_generators passes now. Miserably enough, the way softspace screwed it spread across two distinct __test__ entries, with a bunch of tests raising exceptions "in the middle" of the two. Whittled down, this was enough to fail: >>> print 1, 1 >>> [12, 666] [12, 666] Ironically enough, the only test that still fails is test_doctest . Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.5 retrieving revision 1.36.2.6 diff -C2 -d -r1.36.2.5 -r1.36.2.6 *** doctest.py 3 Aug 2004 15:58:09 -0000 1.36.2.5 --- doctest.py 3 Aug 2004 18:45:24 -0000 1.36.2.6 *************** *** 430,433 **** --- 430,453 ---- return '%s:\n%s' % (tag, msg) + # Override some StringIO methods. + class _SpoofOut(StringIO): + def getvalue(self): + result = StringIO.getvalue(self) + # If anything at all was written, make sure there's a trailing + # newline. There's no way for the expected output to indicate + # that a trailing newline is missing. + if result and not result.endswith("\n"): + result += "\n" + # Prevent softspace from screwing up the next test case, in + # case they used print with a trailing comma in an example. + if hasattr(self, "softspace"): + del self.softspace + return result + + def truncate(self, size=None): + StringIO.truncate(self, size) + if hasattr(self, "softspace"): + del self.softspace + ###################################################################### ## 2. Example & DocTest *************** *** 933,937 **** # Create a fake output target for capturing doctest output. ! self._fakeout = StringIO() #///////////////////////////////////////////////////////////////// --- 953,957 ---- # Create a fake output target for capturing doctest output. ! self._fakeout = _SpoofOut() #///////////////////////////////////////////////////////////////// *************** *** 1182,1186 **** got = self._fakeout.getvalue() self._fakeout.truncate(0) - if got and got[-1:] != '\n': got += '\n' # If the example executed without raising any exceptions, --- 1202,1205 ---- From loewis at users.sourceforge.net Tue Aug 3 20:45:34 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 20:45:37 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1065,1.1066 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15817/Misc Modified Files: NEWS Log Message: Patch #986929: Add support for wish -sync and -use options. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1065 retrieving revision 1.1066 diff -C2 -d -r1.1065 -r1.1066 *** NEWS 3 Aug 2004 17:58:54 -0000 1.1065 --- NEWS 3 Aug 2004 18:45:31 -0000 1.1066 *************** *** 73,76 **** --- 73,78 ---- ------- + - Tkinter now supports the wish -sync and -use options. + - The following methods in time support passing of None: ctime(), gmtime(), and localtime(). If None is provided, the current time is used (the From loewis at users.sourceforge.net Tue Aug 3 20:45:34 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 20:45:38 2004 Subject: [Python-checkins] python/dist/src/Modules _tkinter.c,1.165,1.166 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15817/Modules Modified Files: _tkinter.c Log Message: Patch #986929: Add support for wish -sync and -use options. Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.165 retrieving revision 1.166 diff -C2 -d -r1.165 -r1.166 *** _tkinter.c 19 Feb 2004 02:44:22 -0000 1.165 --- _tkinter.c 3 Aug 2004 18:45:31 -0000 1.166 *************** *** 577,581 **** static TkappObject * Tkapp_New(char *screenName, char *baseName, char *className, ! int interactive, int wantobjects, int wantTk) { TkappObject *v; --- 577,581 ---- static TkappObject * Tkapp_New(char *screenName, char *baseName, char *className, ! int interactive, int wantobjects, int wantTk, int sync, char *use) { TkappObject *v; *************** *** 645,648 **** --- 645,677 ---- } + /* some initial arguments need to be in argv */ + if (sync || use) { + int len = 0; + if (sync) + len += sizeof "-sync"; + if (use) + len += strlen(use) + sizeof "-use "; + + char *args = (char*)ckalloc(len); + if (!args) { + PyErr_NoMemory(); + Py_DECREF(v); + return NULL; + } + + args[0] = '\0'; + if (sync) + strcat(args, "-sync"); + if (use) { + if (sync) + strcat(args, " "); + strcat(args, "-use "); + strcat(args, use); + } + + Tcl_SetVar(v->interp, "argv", args, TCL_GLOBAL_ONLY); + ckfree(args); + } + if (Tcl_AppInit(v->interp) != TCL_OK) return (TkappObject *)Tkinter_Error((PyObject *)v); *************** *** 2836,2839 **** --- 2865,2870 ---- int wantobjects = 0; int wantTk = 1; /* If false, then Tk_Init() doesn't get called */ + int sync = 0; /* pass -sync to wish */ + char *use = NULL; /* pass -use to wish */ baseName = strrchr(Py_GetProgramName(), '/'); *************** *** 2844,2854 **** className = "Tk"; ! if (!PyArg_ParseTuple(args, "|zssiii:create", &screenName, &baseName, &className, ! &interactive, &wantobjects, &wantTk)) return NULL; return (PyObject *) Tkapp_New(screenName, baseName, className, ! interactive, wantobjects, wantTk); } --- 2875,2887 ---- className = "Tk"; ! if (!PyArg_ParseTuple(args, "|zssiiiiz:create", &screenName, &baseName, &className, ! &interactive, &wantobjects, &wantTk, ! &sync, &use)) return NULL; return (PyObject *) Tkapp_New(screenName, baseName, className, ! interactive, wantobjects, wantTk, ! sync, use); } From fdrake at users.sourceforge.net Tue Aug 3 20:53:09 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 20:53:13 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils log.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17319/Lib/distutils Modified Files: log.py Log Message: make sure distutils logging is shut off in tests to avoid spurious output Index: log.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/log.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** log.py 18 Jul 2004 06:14:42 -0000 1.5 --- log.py 3 Aug 2004 18:53:07 -0000 1.6 *************** *** 51,55 **** --- 51,58 ---- def set_threshold(level): + # return the old threshold for use from tests + old = _global_log.threshold _global_log.threshold = level + return old def set_verbosity(v): From fdrake at users.sourceforge.net Tue Aug 3 20:53:10 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 3 20:53:15 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/tests support.py, 1.1, 1.2 test_build_py.py, 1.3, 1.4 test_build_scripts.py, 1.2, 1.3 test_install_scripts.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17319/Lib/distutils/tests Modified Files: support.py test_build_py.py test_build_scripts.py test_install_scripts.py Log Message: make sure distutils logging is shut off in tests to avoid spurious output Index: support.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/tests/support.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** support.py 17 Jun 2004 20:14:50 -0000 1.1 --- support.py 3 Aug 2004 18:53:07 -0000 1.2 *************** *** 4,7 **** --- 4,20 ---- import tempfile + from distutils import log + + + class LoggingSilencer(object): + + def setUp(self): + super(LoggingSilencer, self).setUp() + self.threshold = log.set_threshold(log.FATAL) + + def tearDown(self): + log.set_threshold(self.threshold) + super(LoggingSilencer, self).tearDown() + class TempdirManager(object): Index: test_build_py.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/tests/test_build_py.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_build_py.py 21 Jul 2004 18:53:06 -0000 1.3 --- test_build_py.py 3 Aug 2004 18:53:07 -0000 1.4 *************** *** 10,14 **** ! class BuildPyTestCase(support.TempdirManager, unittest.TestCase): def test_package_data(self): --- 10,16 ---- ! class BuildPyTestCase(support.TempdirManager, ! support.LoggingSilencer, ! unittest.TestCase): def test_package_data(self): Index: test_build_scripts.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/tests/test_build_scripts.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_build_scripts.py 25 Jun 2004 19:04:21 -0000 1.2 --- test_build_scripts.py 3 Aug 2004 18:53:07 -0000 1.3 *************** *** 10,14 **** ! class BuildScriptsTestCase(support.TempdirManager, unittest.TestCase): def test_default_settings(self): --- 10,16 ---- ! class BuildScriptsTestCase(support.TempdirManager, ! support.LoggingSilencer, ! unittest.TestCase): def test_default_settings(self): Index: test_install_scripts.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/tests/test_install_scripts.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_install_scripts.py 25 Jun 2004 19:04:21 -0000 1.4 --- test_install_scripts.py 3 Aug 2004 18:53:07 -0000 1.5 *************** *** 10,14 **** ! class InstallScriptsTestCase(support.TempdirManager, unittest.TestCase): def test_default_settings(self): --- 10,16 ---- ! class InstallScriptsTestCase(support.TempdirManager, ! support.LoggingSilencer, ! unittest.TestCase): def test_default_settings(self): From tim_one at users.sourceforge.net Tue Aug 3 21:12:14 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 3 21:12:18 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.36.2.6,1.36.2.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21250/Lib Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Put all 'return' statements on their own line. The control flow is harder to see otherwise, and you can't set a breakpoint on the 'return' otherwise. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.6 retrieving revision 1.36.2.7 diff -C2 -d -r1.36.2.6 -r1.36.2.7 *** doctest.py 3 Aug 2004 18:45:24 -0000 1.36.2.6 --- doctest.py 3 Aug 2004 19:12:09 -0000 1.36.2.7 *************** *** 605,609 **** # This lets us sort tests by name: def __cmp__(self, other): ! if not isinstance(other, DocTest): return -1 return cmp((self.name, self.filename, self.lineno, id(self)), (other.name, other.filename, other.lineno, id(other))) --- 605,610 ---- # This lets us sort tests by name: def __cmp__(self, other): ! if not isinstance(other, DocTest): ! return -1 return cmp((self.name, self.filename, self.lineno, id(self)), (other.name, other.filename, other.lineno, id(other))) *************** *** 688,692 **** file = inspect.getsourcefile(obj) or inspect.getfile(obj) source_lines = linecache.getlines(file) ! if not source_lines: source_lines = None except TypeError: source_lines = None --- 689,694 ---- file = inspect.getsourcefile(obj) or inspect.getfile(obj) source_lines = linecache.getlines(file) ! if not source_lines: ! source_lines = None except TypeError: source_lines = None *************** *** 731,740 **** # If we've already processed this object, then ignore it. ! if id(obj) in seen: return seen[id(obj)] = 1 # Find a test for this object, and add it to the list of tests. test = self._get_test(obj, name, module, source_lines) ! if test is not None: tests.append(test) # Look for tests in a module's contained objects. --- 733,744 ---- # If we've already processed this object, then ignore it. ! if id(obj) in seen: ! return seen[id(obj)] = 1 # Find a test for this object, and add it to the list of tests. test = self._get_test(obj, name, module, source_lines) ! if test is not None: ! tests.append(test) # Look for tests in a module's contained objects. *************** *** 798,802 **** else: try: ! if obj.__doc__ is None: return None docstring = str(obj.__doc__) except (TypeError, AttributeError): --- 802,807 ---- else: try: ! if obj.__doc__ is None: ! return None docstring = str(obj.__doc__) except (TypeError, AttributeError): *************** *** 804,808 **** # Don't bother if the docstring is empty. ! if not docstring: return None # Find the docstring's location in the file. --- 809,814 ---- # Don't bother if the docstring is empty. ! if not docstring: ! return None # Find the docstring's location in the file. *************** *** 831,835 **** # times in a single file. if inspect.isclass(obj): ! if source_lines is None: return None pat = re.compile(r'^\s*class\s*%s\b' % getattr(obj, '__name__', '-')) --- 837,842 ---- # times in a single file. if inspect.isclass(obj): ! if source_lines is None: ! return None pat = re.compile(r'^\s*class\s*%s\b' % getattr(obj, '__name__', '-')) *************** *** 853,857 **** # mark. if lineno is not None: ! if source_lines is None: return lineno+1 pat = re.compile('(^|.*:)\s*\w*("|\')') for lineno in range(lineno, len(source_lines)): --- 860,865 ---- # mark. if lineno is not None: ! if source_lines is None: ! return lineno+1 pat = re.compile('(^|.*:)\s*\w*("|\')') for lineno in range(lineno, len(source_lines)): *************** *** 973,983 **** # Handle the common case first, for efficiency: # if they're string-identical, always return true. ! if got == want: return True # The values True and False replaced 1 and 0 as the return # value for boolean comparisons in Python 2.3. if not (self._optionflags & DONT_ACCEPT_TRUE_FOR_1): ! if (got,want) == ("True\n", "1\n"): return True ! if (got,want) == ("False\n", "0\n"): return True # can be used as a special sequence to signify a --- 981,994 ---- # Handle the common case first, for efficiency: # if they're string-identical, always return true. ! if got == want: ! return True # The values True and False replaced 1 and 0 as the return # value for boolean comparisons in Python 2.3. if not (self._optionflags & DONT_ACCEPT_TRUE_FOR_1): ! if (got,want) == ("True\n", "1\n"): ! return True ! if (got,want) == ("False\n", "0\n"): ! return True # can be used as a special sequence to signify a *************** *** 990,994 **** # spaces. got = re.sub('(?m)^\s*?$', '', got) ! if got == want: return True # This flag causes doctest to ignore any differences in the --- 1001,1006 ---- # spaces. got = re.sub('(?m)^\s*?$', '', got) ! if got == want: ! return True # This flag causes doctest to ignore any differences in the *************** *** 998,1002 **** got = ' '.join(got.split()) want = ' '.join(want.split()) ! if got == want: return True # The ELLIPSIS flag says to let the sequence "..." in `want` --- 1010,1015 ---- got = ' '.join(got.split()) want = ' '.join(want.split()) ! if got == want: ! return True # The ELLIPSIS flag says to let the sequence "..." in `want` *************** *** 1012,1016 **** want_re = '(?s)^%s$' % want_re # Check if the `want_re` regexp matches got. ! if re.match(want_re, got): return True # We didn't find any match; return false. --- 1025,1030 ---- want_re = '(?s)^%s$' % want_re # Check if the `want_re` regexp matches got. ! if re.match(want_re, got): ! return True # We didn't find any match; return false. *************** *** 1141,1145 **** """ m = self._OPTION_DIRECTIVE_RE.match(example.source) ! if m is None: return False for flag in m.group('flags').upper().split(): --- 1155,1160 ---- """ m = self._OPTION_DIRECTIVE_RE.match(example.source) ! if m is None: ! return False for flag in m.group('flags').upper().split(): From loewis at users.sourceforge.net Tue Aug 3 21:13:23 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 21:13:26 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.135, 1.831.4.136 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21647/Misc Modified Files: Tag: release23-maint NEWS Log Message: Add wait_visibility before grab_set. Fixes #946153. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.135 retrieving revision 1.831.4.136 diff -C2 -d -r1.831.4.135 -r1.831.4.136 *** NEWS 3 Aug 2004 13:00:52 -0000 1.831.4.135 --- NEWS 3 Aug 2004 19:13:18 -0000 1.831.4.136 *************** *** 44,47 **** --- 44,49 ---- ------- + - Patch #946153: Add wait_visibility before grab_set. + - Patch #994595: urllib2 now recognizes Basic authentication even if other authentication schemes are offered. From loewis at users.sourceforge.net Tue Aug 3 21:13:24 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 3 21:13:27 2004 Subject: [Python-checkins] python/dist/src/Lib/lib-tk FileDialog.py, 1.9, 1.9.12.1 SimpleDialog.py, 1.4, 1.4.46.1 tkSimpleDialog.py, 1.9, 1.9.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21647/Lib/lib-tk Modified Files: Tag: release23-maint FileDialog.py SimpleDialog.py tkSimpleDialog.py Log Message: Add wait_visibility before grab_set. Fixes #946153. Index: FileDialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/FileDialog.py,v retrieving revision 1.9 retrieving revision 1.9.12.1 diff -C2 -d -r1.9 -r1.9.12.1 *** FileDialog.py 21 Jan 2003 14:19:21 -0000 1.9 --- FileDialog.py 3 Aug 2004 19:13:18 -0000 1.9.12.1 *************** *** 120,123 **** --- 120,124 ---- self.filter_command() self.selection.focus_set() + self.top.wait_visibility() # window needs to be visible for the grab self.top.grab_set() self.how = None Index: SimpleDialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/SimpleDialog.py,v retrieving revision 1.4 retrieving revision 1.4.46.1 diff -C2 -d -r1.4 -r1.4.46.1 *** SimpleDialog.py 20 Mar 1998 20:45:43 -0000 1.4 --- SimpleDialog.py 3 Aug 2004 19:13:18 -0000 1.4.46.1 *************** *** 65,68 **** --- 65,69 ---- def go(self): + self.root.wait_visibility() self.root.grab_set() self.root.mainloop() Index: tkSimpleDialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/tkSimpleDialog.py,v retrieving revision 1.9 retrieving revision 1.9.10.1 diff -C2 -d -r1.9 -r1.9.10.1 *** tkSimpleDialog.py 6 Apr 2003 09:00:54 -0000 1.9 --- tkSimpleDialog.py 3 Aug 2004 19:13:18 -0000 1.9.10.1 *************** *** 62,65 **** --- 62,66 ---- self.buttonbox() + self.wait_visibility() # window needs to be visible for the grab self.grab_set() From tim_one at users.sourceforge.net Tue Aug 3 21:35:15 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 3 21:35:19 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.36.2.7,1.36.2.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26804 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: output_difference(): Remove trailing whitespace on diff output lines. Now test_doctest passes. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.7 retrieving revision 1.36.2.8 diff -C2 -d -r1.36.2.7 -r1.36.2.8 *** doctest.py 3 Aug 2004 19:12:09 -0000 1.36.2.7 --- doctest.py 3 Aug 2004 19:35:13 -0000 1.36.2.8 *************** *** 1059,1062 **** --- 1059,1064 ---- else: assert 0, 'Bad diff option' + # Remove trailing whitespace on diff output. + diff = [line.rstrip() + '\n' for line in diff] return _tag_msg("Differences (unified diff)", ''.join(diff)) From tim_one at users.sourceforge.net Tue Aug 3 21:52:51 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 3 21:52:55 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.36.2.8,1.36.2.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30340/Lib Modified Files: Tag: tim-doctest-branch doctest.py Log Message: output_difference: This was identifying both context and unified diffs as unified diffs in the output. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.8 retrieving revision 1.36.2.9 diff -C2 -d -r1.36.2.8 -r1.36.2.9 *** doctest.py 3 Aug 2004 19:35:13 -0000 1.36.2.8 --- doctest.py 3 Aug 2004 19:52:48 -0000 1.36.2.9 *************** *** 1054,1065 **** diff = difflib.unified_diff(want_lines, got_lines, n=2, fromfile='Expected', tofile='Got') elif self._optionflags & CONTEXT_DIFF: diff = difflib.context_diff(want_lines, got_lines, n=2, fromfile='Expected', tofile='Got') else: assert 0, 'Bad diff option' # Remove trailing whitespace on diff output. diff = [line.rstrip() + '\n' for line in diff] ! return _tag_msg("Differences (unified diff)", ''.join(diff)) # If we're not using diff, then simply list the expected --- 1054,1068 ---- diff = difflib.unified_diff(want_lines, got_lines, n=2, fromfile='Expected', tofile='Got') + kind = 'unified' elif self._optionflags & CONTEXT_DIFF: diff = difflib.context_diff(want_lines, got_lines, n=2, fromfile='Expected', tofile='Got') + kind = 'context' else: assert 0, 'Bad diff option' # Remove trailing whitespace on diff output. diff = [line.rstrip() + '\n' for line in diff] ! return _tag_msg("Differences (" + kind + " diff)", ! ''.join(diff)) # If we're not using diff, then simply list the expected From tim_one at users.sourceforge.net Tue Aug 3 21:52:52 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 3 21:52:55 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.5.18.5, 1.5.18.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30340/Lib/test Modified Files: Tag: tim-doctest-branch test_doctest.py Log Message: output_difference: This was identifying both context and unified diffs as unified diffs in the output. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.5.18.5 retrieving revision 1.5.18.6 diff -C2 -d -r1.5.18.5 -r1.5.18.6 *** test_doctest.py 3 Aug 2004 16:45:46 -0000 1.5.18.5 --- test_doctest.py 3 Aug 2004 19:52:49 -0000 1.5.18.6 *************** *** 776,780 **** Failure in example: print '\n'.join('abcdefg') from line #1 of f ! Differences (unified diff): *** Expected --- Got --- 776,780 ---- Failure in example: print '\n'.join('abcdefg') from line #1 of f ! Differences (context diff): *** Expected --- Got From edloper at users.sourceforge.net Tue Aug 3 22:09:57 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Tue Aug 3 22:10:01 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.9, 1.36.2.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1323 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: - Explicitly set verbose=False when running test cases for DocTestRunner (so that it doesn't pick up the verbosity from sys.argv) - Simplified blankline handling in TestRunner.output_difference() - Fixed the debugging support code - Removed tests5() (now tested in test.test_doctest) Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.9 retrieving revision 1.36.2.10 diff -C2 -d -r1.36.2.9 -r1.36.2.10 *** doctest.py 3 Aug 2004 19:52:48 -0000 1.36.2.9 --- doctest.py 3 Aug 2004 20:09:51 -0000 1.36.2.10 *************** *** 307,311 **** import sys, traceback, inspect, linecache, re, types ! import unittest, difflib from StringIO import StringIO --- 307,311 ---- import sys, traceback, inspect, linecache, re, types ! import unittest, difflib, tempfile from StringIO import StringIO *************** *** 885,889 **** >>> tests = DocTestFinder().find(_TestClass) ! >>> runner = DocTestRunner() >>> for test in tests: ... print runner.run(test, globals()) --- 885,889 ---- >>> tests = DocTestFinder().find(_TestClass) ! >>> runner = DocTestRunner(verbose=False) >>> for test in tests: ... print runner.run(test, globals()) *************** *** 1036,1039 **** --- 1036,1044 ---- expected output (`want`) and the actual output (`got`). """ + # If s are being used, then replace + # with blank lines in the expected output string. + if not (self._optionflags & DONT_ACCEPT_BLANKLINE): + want = re.sub('(?m)^%s$' % re.escape(BLANKLINE_MARKER), '', want) + # Check if we should use diff. Don't use diff if the actual # or expected outputs are too short, or if the expected output *************** *** 1042,1050 **** want.count('\n') > 2 and got.count('\n') > 2 and not (self._optionflags & ELLIPSIS and '...' in want)): - # Replace with blank lines in the expected - # output string (so they don't confuse difflib). - if not (self._optionflags & DONT_ACCEPT_BLANKLINE): - want = re.sub('(?m)^%s$' % re.escape(BLANKLINE_MARKER), - '', want) # Split want & got into lines. want_lines = [l+'\n' for l in want.split('\n')] --- 1047,1050 ---- *************** *** 1067,1074 **** # If we're not using diff, then simply list the expected ! # output followed by the actual output. But explicitly mark ! # blank lines in the actual output. ! if not (self._optionflags & DONT_ACCEPT_BLANKLINE): ! got = re.sub('(?m)^$(?!\Z)', '', got) return (_tag_msg("Expected", want or "Nothing") + _tag_msg("Got", got)) --- 1067,1071 ---- # If we're not using diff, then simply list the expected ! # output followed by the actual output. return (_tag_msg("Expected", want or "Nothing") + _tag_msg("Got", got)) *************** *** 1531,1534 **** --- 1528,1533 ---- ## 6. Tester ###################################################################### + # This is provided only for backwards compatibility. It's not + # actually used in any way. class Tester: *************** *** 1714,1725 **** ## 8. Debugging Support ###################################################################### - # [XX] This is currently broken: ! def _expect(expect): # Return the expected output, if any ! if expect: ! expect = "\n# ".join(expect.split("\n")) ! expect = "\n# Expect:\n# %s" % expect ! return expect def testsource(module, name): --- 1713,1729 ---- ## 8. Debugging Support ###################################################################### ! def _want_comment(example): ! """ ! Return a comment containing the expected output for the given ! example. ! """ # Return the expected output, if any ! want = example.want ! if want: ! if want[-1] == '\n': want = want[:-1] ! want = "\n# ".join(want.split("\n")) ! want = "\n# Expected:\n# %s" % want ! return want def testsource(module, name): *************** *** 1731,1745 **** """ ! module = _normalizeModule(module) ! tests = _findTests(module, "") ! test = [doc for (tname, doc, f, l) in tests if tname == name] if not test: raise ValueError(name, "not found in tests") test = test[0] - # XXX we rely on an internal doctest function: - examples = _extract_examples(test) testsrc = '\n'.join([ ! "%s%s" % (source, _expect(expect)) ! for (source, expect, lineno) in examples ]) return testsrc --- 1735,1747 ---- """ ! module = _normalize_module(module) ! tests = DocTestFinder().find(module) ! test = [t for t in tests if t.name == name] if not test: raise ValueError(name, "not found in tests") test = test[0] testsrc = '\n'.join([ ! "%s%s" % (example.source, _want_comment(example)) ! for example in test.examples ]) return testsrc *************** *** 1750,1760 **** The string is provided directly """ ! # XXX we rely on an internal doctest function: ! examples = _extract_examples(src) ! src = '\n'.join([ ! "%s%s" % (source, _expect(expect)) ! for (source, expect, lineno) in examples ]) ! debug_script(src, pm, globs) def debug_script(src, pm=False, globs=None): --- 1752,1762 ---- The string is provided directly """ ! test = DocTest(src, 'debug', None, None) ! ! testsrc = '\n'.join([ ! "%s%s" % (example.source, _want_comment(example)) ! for example in test.examples ]) ! debug_script(testsrc, pm, globs) def debug_script(src, pm=False, globs=None): *************** *** 1762,1767 **** import pdb ! srcfilename = tempfile.mktemp("doctestdebug.py") ! open(srcfilename, 'w').write(src) if globs: globs = globs.copy() --- 1764,1771 ---- import pdb ! srcfile = tempfile.NamedTemporaryFile(prefix='doctestdebug-', ! suffix='.py', mode="w") ! srcfile.write(src) ! srcfile.flush() if globs: globs = globs.copy() *************** *** 1772,1776 **** if pm: try: ! execfile(srcfilename, globs, globs) except: print sys.exc_info()[1] --- 1776,1780 ---- if pm: try: ! execfile(srcfile.name, globs, globs) except: print sys.exc_info()[1] *************** *** 1779,1785 **** # Note that %r is vital here. '%s' instead can, e.g., cause # backslashes to get treated as metacharacters on Windows. ! pdb.run("execfile(%r)" % srcfilename, globs, globs) finally: ! os.remove(srcfilename) def debug(module, name, pm=False): --- 1783,1789 ---- # Note that %r is vital here. '%s' instead can, e.g., cause # backslashes to get treated as metacharacters on Windows. ! pdb.run("execfile(%r)" % srcfile.name, globs, globs) finally: ! srcfile.close() # Automatically deletes the file. def debug(module, name, pm=False): *************** *** 1791,1801 **** """ ! module = _normalizeModule(module) testsrc = testsource(module, name) debug_script(testsrc, pm, module.__dict__) - - - ###################################################################### ## 9. Example Usage --- 1795,1802 ---- """ ! module = _normalize_module(module) testsrc = testsource(module, name) debug_script(testsrc, pm, module.__dict__) ###################################################################### ## 9. Example Usage *************** *** 1999,2022 **** meant to be invoked automagically by testmod. ! >>> testmod(m1, isprivate=is_private) (0, 3) """ - def test5(): r""" - - >>> raise ValueError('x') - Traceback (most recent call last): - [...] - ValueError: x - - >>> print 'x'; raise ValueError('\nfoo') - x - Traceback (most recent call last): - [...] - ValueError: - foo - - """ - def _test(): #import doctest --- 2000,2007 ---- meant to be invoked automagically by testmod. ! >>> testmod(m1, isprivate=is_private, verbose=False) (0, 3) """ def _test(): #import doctest From edloper at users.sourceforge.net Tue Aug 3 22:13:15 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Tue Aug 3 22:13:18 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.5.18.6, 1.5.18.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2128/test Modified Files: Tag: tim-doctest-branch test_doctest.py Log Message: - Added sample objects, defined in the module, that can be used by test cases. - Removed line numbers from test cases (they change too easily) - Explicitly set verbose=False when running test cases for DocTestRunner (so that it doesn't pick up the verbosity from sys.argv) - Added a couple tests for the debugger - Added support for computing coverage Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.5.18.6 retrieving revision 1.5.18.7 diff -C2 -d -r1.5.18.6 -r1.5.18.7 *** test_doctest.py 3 Aug 2004 19:52:49 -0000 1.5.18.6 --- test_doctest.py 3 Aug 2004 20:13:12 -0000 1.5.18.7 *************** *** 6,9 **** --- 6,119 ---- import doctest + ###################################################################### + ## Sample Objects (used by test cases) + ###################################################################### + + def sample_func(v): + """ + >>> print sample_func(22) + 44 + """ + return v+v + + class SampleClass: + """ + >>> print 1 + 1 + """ + def __init__(self, val): + """ + >>> print SampleClass(12).get() + 12 + """ + self.val = val + + def double(self): + """ + >>> print SampleClass(12).double().get() + 24 + """ + return SampleClass(self.val + self.val) + + def get(self): + """ + >>> print SampleClass(-5).get() + -5 + """ + return self.val + + def a_staticmethod(v): + """ + >>> print SampleClass.a_staticmethod(10) + 11 + """ + return v+1 + a_staticmethod = staticmethod(a_staticmethod) + + def a_classmethod(cls, v): + """ + >>> print SampleClass.a_classmethod(10) + 12 + >>> print SampleClass(0).a_classmethod(10) + 12 + """ + return v+2 + a_classmethod = classmethod(a_classmethod) + + a_property = property(get, doc=""" + >>> print SampleClass(22).a_property + 22 + """) + + class NestedClass: + """ + >>> x = SampleClass.NestedClass(5) + >>> y = x.square() + >>> print y.get() + 25 + """ + def __init__(self, val=0): + """ + >>> print SampleClass.NestedClass().get() + 0 + """ + self.val = val + def square(self): + return SampleClass.NestedClass(self.val*self.val) + def get(self): + return self.val + + class SampleNewStyleClass(object): + r""" + >>> print '1\n2\n3' + 1 + 2 + 3 + """ + def __init__(self, val): + """ + >>> print SampleNewStyleClass(12).get() + 12 + """ + self.val = val + + def double(self): + """ + >>> print SampleNewStyleClass(12).double().get() + 24 + """ + return SampleNewStyleClass(self.val + self.val) + + def get(self): + """ + >>> print SampleNewStyleClass(-5).get() + -5 + """ + return self.val + + ###################################################################### + ## Test Cases + ###################################################################### + def test_Example(): r""" Unit tests for the `Example` class. *************** *** 118,121 **** --- 228,232 ---- """ + # [XX] test that it's getting line numbers right. def test_DocTestFinder(): r""" Unit tests for the `DocTestFinder` class. *************** *** 131,149 **** will return a single test (for that function's docstring): ! >>> # Functions: ! >>> def double(v): ! ... ''' ! ... >>> print double(22) ! ... 44 ! ... ''' ! ... return v+v >>> finder = doctest.DocTestFinder() ! >>> tests = finder.find(double) >>> print tests ! [] >>> e = tests[0].examples[0] >>> print (e.source, e.want, e.lineno) ! ('print double(22)', '44\n', 1) If an object has no docstring, then a test is not created for it: --- 242,258 ---- will return a single test (for that function's docstring): ! >>> # Allow ellipsis in the following examples (since the filename ! >>> # and line number in the traceback can vary): ! >>> doctest: +ELLIPSIS >>> finder = doctest.DocTestFinder() ! >>> tests = finder.find(sample_func) >>> print tests ! [] >>> e = tests[0].examples[0] >>> print (e.source, e.want, e.lineno) ! ('print sample_func(22)', '44\n', 1) ! ! >>> doctest: -ELLIPSIS # Turn ellipsis back off If an object has no docstring, then a test is not created for it: *************** *** 170,292 **** methods, classmethods, staticmethods, properties, and nested classes. - >>> # A class: - >>> class A: - ... ''' - ... >>> print 1 - ... 1 - ... ''' - ... def __init__(self, val): - ... ''' - ... >>> print A(12).get() - ... 12 - ... ''' - ... self.val = val - ... - ... def double(self): - ... ''' - ... >>> print A(12).double().get() - ... 24 - ... ''' - ... return A(self.val + self.val) - ... - ... def get(self): - ... ''' - ... >>> print A(-5).get() - ... -5 - ... ''' - ... return self.val - ... - ... def a_staticmethod(v): - ... ''' - ... >>> print A.a_staticmethod(10) - ... 11 - ... ''' - ... return v+1 - ... a_staticmethod = staticmethod(a_staticmethod) - ... - ... def a_classmethod(cls, v): - ... ''' - ... >>> print A.a_classmethod(10) - ... 12 - ... >>> print A(0).a_classmethod(10) - ... 12 - ... ''' - ... return v+2 - ... a_classmethod = classmethod(a_classmethod) - ... - ... a_property = property(get, doc=''' - ... >>> print x(22).a_property - ... 22 - ... ''') - ... - ... class NestedClass: - ... ''' - ... >>> x = A.NestedClass(5) - ... >>> y = x.square() - ... >>> print y.get() - ... 25 - ... ''' - ... def __init__(self, val=0): - ... ''' - ... >>> print A.NestedClass().get() - ... 0 - ... ''' - ... self.val = val - ... def square(self): - ... A.NestedClass(self.val*self.val) - ... def get(self): - ... return self.val - >>> finder = doctest.DocTestFinder() ! >>> tests = finder.find(A) >>> tests.sort() >>> for t in tests: ! ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) ! None 1 A ! None 3 A.NestedClass ! 96 1 A.NestedClass.__init__ ! 7 1 A.__init__ ! 40 2 A.a_classmethod ! None 1 A.a_property ! 40 1 A.a_staticmethod ! 40 1 A.double ! 40 1 A.get New-style classes are also supported: ! >>> class B(object): ! ... ''' ! ... >>> print 1 ! ... 1 ! ... ''' ! ... def __init__(self, val): ! ... ''' ! ... >>> print B(12).get() ! ... 12 ! ... ''' ! ... self.val = val ! ... ! ... def double(self): ! ... ''' ! ... >>> print B(12).double().get() ! ... 24 ! ... ''' ! ... return B(self.val + self.val) ! ... ! ... def get(self): ! ... ''' ! ... >>> print B(-5).get() ! ... -5 ! ... ''' ! ... return self.val ! ! >>> tests = finder.find(B) >>> tests.sort() >>> for t in tests: ! ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) ! None 1 B ! 7 1 B.__init__ ! 40 1 B.double ! 40 1 B.get Finding Tests in Modules --- 279,307 ---- methods, classmethods, staticmethods, properties, and nested classes. >>> finder = doctest.DocTestFinder() ! >>> tests = finder.find(SampleClass) >>> tests.sort() >>> for t in tests: ! ... print '%2s %s' % (len(t.examples), t.name) ! 1 SampleClass ! 3 SampleClass.NestedClass ! 1 SampleClass.NestedClass.__init__ ! 1 SampleClass.__init__ ! 2 SampleClass.a_classmethod ! 1 SampleClass.a_property ! 1 SampleClass.a_staticmethod ! 1 SampleClass.double ! 1 SampleClass.get New-style classes are also supported: ! >>> tests = finder.find(SampleNewStyleClass) >>> tests.sort() >>> for t in tests: ! ... print '%2s %s' % (len(t.examples), t.name) ! 1 SampleNewStyleClass ! 1 SampleNewStyleClass.__init__ ! 1 SampleNewStyleClass.double ! 1 SampleNewStyleClass.get Finding Tests in Modules *************** *** 306,311 **** ... return val*3 >>> m.__dict__.update({ ! ... 'double': double, ! ... 'A': A, ... '__doc__': ''' ... Module docstring. --- 321,326 ---- ... return val*3 >>> m.__dict__.update({ ! ... 'sample_func': sample_func, ! ... 'SampleClass': SampleClass, ... '__doc__': ''' ... Module docstring. *************** *** 318,340 **** >>> finder = doctest.DocTestFinder() ! >>> # The '(None)' is to prevent it from filtering out objects ! >>> # that were not defined in module m. ! >>> tests = finder.find(m, module='(None)') >>> tests.sort() >>> for t in tests: ! ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) ! 1 1 some_module ! None 1 some_module.A ! None 3 some_module.A.NestedClass ! 57 1 some_module.A.NestedClass.__init__ ! 6 1 some_module.A.__init__ ! 35 2 some_module.A.a_classmethod ! None 1 some_module.A.a_property ! 27 1 some_module.A.a_staticmethod ! 13 1 some_module.A.double ! 20 1 some_module.A.get ! 1 1 some_module.c ! None 2 some_module.d ! 1 1 some_module.double Duplicate Removal --- 333,356 ---- >>> finder = doctest.DocTestFinder() ! >>> # Use module=test.test_doctest, to prevent doctest from ! >>> # ignoring the objects since they weren't defined in m. ! >>> import test.test_doctest ! >>> tests = finder.find(m, module=test.test_doctest) >>> tests.sort() >>> for t in tests: ! ... print '%2s %s' % (len(t.examples), t.name) ! 1 some_module ! 1 some_module.SampleClass ! 3 some_module.SampleClass.NestedClass ! 1 some_module.SampleClass.NestedClass.__init__ ! 1 some_module.SampleClass.__init__ ! 2 some_module.SampleClass.a_classmethod ! 1 some_module.SampleClass.a_property ! 1 some_module.SampleClass.a_staticmethod ! 1 some_module.SampleClass.double ! 1 some_module.SampleClass.get ! 1 some_module.c ! 2 some_module.d ! 1 some_module.sample_func Duplicate Removal *************** *** 372,399 **** >>> def namefilter(prefix, base): ... return base.startswith('a_') ! >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(A) >>> tests.sort() >>> for t in tests: ! ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) ! None 1 A ! None 3 A.NestedClass ! 96 1 A.NestedClass.__init__ ! 7 1 A.__init__ ! 40 1 A.double ! 40 1 A.get >>> def objfilter(obj): ... return isinstance(obj, (staticmethod, classmethod)) ! >>> tests = doctest.DocTestFinder(objfilter=objfilter).find(A) >>> tests.sort() >>> for t in tests: ! ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) ! None 1 A ! None 3 A.NestedClass ! 96 1 A.NestedClass.__init__ ! 7 1 A.__init__ ! None 1 A.a_property ! 40 1 A.double ! 40 1 A.get If a given object is filtered out, then none of the objects that it --- 388,415 ---- >>> def namefilter(prefix, base): ... return base.startswith('a_') ! >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(SampleClass) >>> tests.sort() >>> for t in tests: ! ... print '%2s %s' % (len(t.examples), t.name) ! 1 SampleClass ! 3 SampleClass.NestedClass ! 1 SampleClass.NestedClass.__init__ ! 1 SampleClass.__init__ ! 1 SampleClass.double ! 1 SampleClass.get >>> def objfilter(obj): ... return isinstance(obj, (staticmethod, classmethod)) ! >>> tests = doctest.DocTestFinder(objfilter=objfilter).find(SampleClass) >>> tests.sort() >>> for t in tests: ! ... print '%2s %s' % (len(t.examples), t.name) ! 1 SampleClass ! 3 SampleClass.NestedClass ! 1 SampleClass.NestedClass.__init__ ! 1 SampleClass.__init__ ! 1 SampleClass.a_property ! 1 SampleClass.double ! 1 SampleClass.get If a given object is filtered out, then none of the objects that it *************** *** 402,416 **** >>> def namefilter(prefix, base): ... return base == 'NestedClass' ! >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(A) >>> tests.sort() >>> for t in tests: ! ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) ! None 1 A ! 7 1 A.__init__ ! 40 2 A.a_classmethod ! None 1 A.a_property ! 40 1 A.a_staticmethod ! 40 1 A.double ! 40 1 A.get The filter functions apply to contained objects, and *not* to the --- 418,432 ---- >>> def namefilter(prefix, base): ... return base == 'NestedClass' ! >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(SampleClass) >>> tests.sort() >>> for t in tests: ! ... print '%2s %s' % (len(t.examples), t.name) ! 1 SampleClass ! 1 SampleClass.__init__ ! 2 SampleClass.a_classmethod ! 1 SampleClass.a_property ! 1 SampleClass.a_staticmethod ! 1 SampleClass.double ! 1 SampleClass.get The filter functions apply to contained objects, and *not* to the *************** *** 418,423 **** >>> def namefilter(prefix, base): ! ... return base == 'A' ! >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(A) >>> len(tests) 9 --- 434,439 ---- >>> def namefilter(prefix, base): ! ... return base == 'SampleClass' ! >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(SampleClass) >>> len(tests) 9 *************** *** 428,436 **** using the `recurse` flag: ! >>> tests = doctest.DocTestFinder(recurse=False).find(A) >>> tests.sort() >>> for t in tests: ! ... print '%4s %2s %s' % (t.lineno, len(t.examples), t.name) ! None 1 A """ --- 444,452 ---- using the `recurse` flag: ! >>> tests = doctest.DocTestFinder(recurse=False).find(SampleClass) >>> tests.sort() >>> for t in tests: ! ... print '%2s %s' % (len(t.examples), t.name) ! 1 SampleClass """ *************** *** 457,476 **** of tried tests. ! >>> doctest.DocTestRunner().run(test, {}) ! (0, 3) ! ! The `verbose` flag makes the test runner generate more detailed ! output: ! ! >>> doctest.DocTestRunner(verbose=True).run(test, {}) ! Trying: x = 12 ! Expecting: nothing ! ok ! Trying: print x ! Expecting: 12 ! ok ! Trying: x/2 ! Expecting: 6 ! ok (0, 3) --- 473,477 ---- of tried tests. ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) (0, 3) *************** *** 503,506 **** --- 504,564 ---- (1, 3) """ + def verbose_flag(): r""" + The `verbose` flag makes the test runner generate more detailed + output: + + >>> def f(x): + ... ''' + ... >>> x = 12 + ... >>> print x + ... 12 + ... >>> x/2 + ... 6 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + + >>> doctest.DocTestRunner(verbose=True).run(test, {}) + Trying: x = 12 + Expecting: nothing + ok + Trying: print x + Expecting: 12 + ok + Trying: x/2 + Expecting: 6 + ok + (0, 3) + + If the `verbose` flag is unspecified, then the output will be verbose + iff `-v` appears in sys.argv: + + >>> # Save the real sys.argv list. + >>> old_argv = sys.argv + + >>> # If -v does not appear in sys.argv, then output isn't verbose. + >>> sys.argv = ['test'] + >>> doctest.DocTestRunner().run(test, {}) + (0, 3) + + >>> # If -v does appear in sys.argv, then output is verbose. + >>> sys.argv = ['test', '-v'] + >>> doctest.DocTestRunner().run(test, {}) + Trying: x = 12 + Expecting: nothing + ok + Trying: print x + Expecting: 12 + ok + Trying: x/2 + Expecting: 6 + ok + (0, 3) + + >>> # Restore sys.argv + >>> sys.argv = old_argv + + In the remaining examples, the test runner's verbosity will be + explicitly set, to ensure that the test behavior is consistent. + """ def exceptions(): r""" Tests of `DocTestRunner`'s exception handling. *************** *** 518,522 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner().run(test, {}) (0, 2) --- 576,580 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) (0, 2) *************** *** 533,537 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner().run(test, {}) (0, 2) --- 591,595 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) (0, 2) *************** *** 547,551 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner().run(test, {}) (0, 1) --- 605,609 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) (0, 1) *************** *** 560,564 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner().run(test, {}) ********************************************************************** Failure in example: raise ValueError, 'message' --- 618,622 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: raise ValueError, 'message' *************** *** 585,589 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner().run(test, {}) ********************************************************************** Failure in example: 1/0 --- 643,647 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: 1/0 *************** *** 597,602 **** (1, 1) ! >>> # Turn ellipsis back off: ! >>> doctest: -ELLIPSIS """ def optionflags(): r""" --- 655,659 ---- (1, 1) ! >>> doctest: -ELLIPSIS # Turn ellipsis back off: """ def optionflags(): r""" *************** *** 616,620 **** >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner().run(test, {}) (0, 1) --- 673,677 ---- >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) (0, 1) *************** *** 622,626 **** >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.DONT_ACCEPT_TRUE_FOR_1 ! >>> doctest.DocTestRunner(optionflags=flags).run(test, {}) ********************************************************************** Failure in example: True --- 679,683 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.DONT_ACCEPT_TRUE_FOR_1 ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test, {}) ********************************************************************** Failure in example: True *************** *** 638,642 **** >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner().run(test, {}) (0, 1) --- 695,699 ---- >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) (0, 1) *************** *** 644,648 **** >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.DONT_ACCEPT_BLANKLINE ! >>> doctest.DocTestRunner(optionflags=flags).run(test, {}) ********************************************************************** Failure in example: print "a\n\nb" --- 701,705 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.DONT_ACCEPT_BLANKLINE ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test, {}) ********************************************************************** Failure in example: print "a\n\nb" *************** *** 666,670 **** >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner().run(test, {}) ********************************************************************** Failure in example: print 1, 2, 3 --- 723,727 ---- >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: print 1, 2, 3 *************** *** 679,683 **** >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.NORMALIZE_WHITESPACE ! >>> doctest.DocTestRunner(optionflags=flags).run(test, {}) (0, 1) --- 736,740 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.NORMALIZE_WHITESPACE ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test, {}) (0, 1) *************** *** 690,694 **** >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner().run(test, {}) ********************************************************************** Failure in example: print range(15) --- 747,751 ---- >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: print range(15) *************** *** 701,705 **** >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.ELLIPSIS ! >>> doctest.DocTestRunner(optionflags=flags).run(test, {}) (0, 1) --- 758,762 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.ELLIPSIS ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test, {}) (0, 1) *************** *** 721,725 **** >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner().run(test, {}) ********************************************************************** Failure in example: print '\n'.join('abcdefg') --- 778,782 ---- >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: print '\n'.join('abcdefg') *************** *** 746,750 **** >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.UNIFIED_DIFF ! >>> doctest.DocTestRunner(optionflags=flags).run(test, {}) ********************************************************************** Failure in example: print '\n'.join('abcdefg') --- 803,807 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.UNIFIED_DIFF ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test, {}) ********************************************************************** Failure in example: print '\n'.join('abcdefg') *************** *** 772,776 **** >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.CONTEXT_DIFF ! >>> doctest.DocTestRunner(optionflags=flags).run(test, {}) ********************************************************************** Failure in example: print '\n'.join('abcdefg') --- 829,833 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.CONTEXT_DIFF ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test, {}) ********************************************************************** Failure in example: print '\n'.join('abcdefg') *************** *** 800,804 **** (1, 1) """ - def option_directives(): r""" Tests of `DocTestRunner`'s option directive mechanism. --- 857,860 ---- *************** *** 822,826 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner().run(test, {}) ********************************************************************** Failure in example: print range(10) # Should fail: no ellipsis --- 878,882 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: print range(10) # Should fail: no ellipsis *************** *** 845,849 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner().run(test, {}) ********************************************************************** Failure in example: print range(10) # Should fail --- 901,905 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: print range(10) # Should fail *************** *** 852,865 **** Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (1, 2) """ def test_main(): # Check the doctest cases in doctest itself: ! #test_support.run_doctest(doctest) # Check the doctest cases defined here: from test import test_doctest ! test_support.run_doctest(test_doctest, verbosity=0) if __name__ == '__main__': ! test_main() --- 908,999 ---- Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (1, 2) + """ + def test_testsource(): r""" + >>> import test.test_doctest + >>> name = 'test.test_doctest.sample_func' + >>> print doctest.testsource(test.test_doctest, name) + print sample_func(22) + # Expected: + # 44 + + >>> name = 'test.test_doctest.SampleNewStyleClass' + >>> print doctest.testsource(test.test_doctest, name) + print '1\n2\n3' + # Expected: + # 1 + # 2 + # 3 + + >>> name = 'test.test_doctest.SampleClass.a_classmethod' + >>> print doctest.testsource(test.test_doctest, name) + print SampleClass.a_classmethod(10) + # Expected: + # 12 + print SampleClass(0).a_classmethod(10) + # Expected: + # 12 """ + def test_debug(): r""" + + Create a docstring that we want to debug: + + >>> s = ''' + ... >>> x = 12 + ... >>> print x + ... 12 + ... ''' + + Create some fake stdin input, to feed to the debugger: + + >>> import tempfile + >>> fake_stdin = tempfile.TemporaryFile(mode='w+') + >>> fake_stdin.write('\n'.join(['next', 'print x', 'continue', ''])) + >>> fake_stdin.seek(0) + >>> real_stdin = sys.stdin + >>> sys.stdin = fake_stdin + + Run the debugger on the docstring, and then restore sys.stdin. + + >>> doctest: +NORMALIZE_WHITESPACE + >>> try: + ... doctest.debug_src(s) + ... finally: + ... sys.stdin = real_stdin + ... fake_stdin.close() + > (1)?() + (Pdb) 12 + --Return-- + > (1)?()->None + (Pdb) 12 + (Pdb) + + """ + + ###################################################################### + ## Main + ###################################################################### + def test_main(): # Check the doctest cases in doctest itself: ! test_support.run_doctest(doctest, verbosity=True) # Check the doctest cases defined here: from test import test_doctest ! test_support.run_doctest(test_doctest, verbosity=True) ! ! import trace, sys, re, StringIO ! def test_coverage(coverdir): ! tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], ! trace=0, count=1) ! tracer.run('reload(doctest); test_main()') ! r = tracer.results() ! print 'Writing coverage results...' ! r.write_results(show_missing=True, summary=True, ! coverdir=coverdir) if __name__ == '__main__': ! if '-c' in sys.argv: ! test_coverage('/tmp/doctest.cover') ! else: ! test_main() From tim_one at users.sourceforge.net Tue Aug 3 23:22:44 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 3 23:22:47 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.10, 1.36.2.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15491/Lib Modified Files: Tag: tim-doctest-branch doctest.py Log Message: debug_script(): Reverted the change to use a fancy tempfile class. It was "a feature" that the debugging script was left behind, and the semantics of the Windows-specific O_TEMPORARY are such that test_doctest failed with a filesystem permission error when it tried to test this. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.10 retrieving revision 1.36.2.11 diff -C2 -d -r1.36.2.10 -r1.36.2.11 *** doctest.py 3 Aug 2004 20:09:51 -0000 1.36.2.10 --- doctest.py 3 Aug 2004 21:22:41 -0000 1.36.2.11 *************** *** 739,743 **** # Find a test for this object, and add it to the list of tests. test = self._get_test(obj, name, module, source_lines) ! if test is not None: tests.append(test) --- 739,743 ---- # Find a test for this object, and add it to the list of tests. test = self._get_test(obj, name, module, source_lines) ! if test is not None: tests.append(test) *************** *** 981,985 **** # Handle the common case first, for efficiency: # if they're string-identical, always return true. ! if got == want: return True --- 981,985 ---- # Handle the common case first, for efficiency: # if they're string-identical, always return true. ! if got == want: return True *************** *** 1010,1014 **** got = ' '.join(got.split()) want = ' '.join(want.split()) ! if got == want: return True --- 1010,1014 ---- got = ' '.join(got.split()) want = ' '.join(want.split()) ! if got == want: return True *************** *** 1040,1044 **** if not (self._optionflags & DONT_ACCEPT_BLANKLINE): want = re.sub('(?m)^%s$' % re.escape(BLANKLINE_MARKER), '', want) ! # Check if we should use diff. Don't use diff if the actual # or expected outputs are too short, or if the expected output --- 1040,1044 ---- if not (self._optionflags & DONT_ACCEPT_BLANKLINE): want = re.sub('(?m)^%s$' % re.escape(BLANKLINE_MARKER), '', want) ! # Check if we should use diff. Don't use diff if the actual # or expected outputs are too short, or if the expected output *************** *** 1764,1771 **** import pdb ! srcfile = tempfile.NamedTemporaryFile(prefix='doctestdebug-', ! suffix='.py', mode="w") ! srcfile.write(src) ! srcfile.flush() if globs: globs = globs.copy() --- 1764,1772 ---- import pdb ! srcfilename = tempfile.mktemp("doctestdebug.py") ! f = open(srcfilename, 'w') ! f.write(src) ! f.close() ! if globs: globs = globs.copy() *************** *** 1773,1789 **** globs = {} ! try: ! if pm: ! try: ! execfile(srcfile.name, globs, globs) ! except: ! print sys.exc_info()[1] ! pdb.post_mortem(sys.exc_info()[2]) ! else: ! # Note that %r is vital here. '%s' instead can, e.g., cause ! # backslashes to get treated as metacharacters on Windows. ! pdb.run("execfile(%r)" % srcfile.name, globs, globs) ! finally: ! srcfile.close() # Automatically deletes the file. def debug(module, name, pm=False): --- 1774,1787 ---- globs = {} ! if pm: ! try: ! execfile(srcfilename, globs, globs) ! except: ! print sys.exc_info()[1] ! pdb.post_mortem(sys.exc_info()[2]) ! else: ! # Note that %r is vital here. '%s' instead can, e.g., cause ! # backslashes to get treated as metacharacters on Windows. ! pdb.run("execfile(%r)" % srcfilename, globs, globs) def debug(module, name, pm=False): From Glenna at bag.python.org Wed Aug 4 00:40:51 2004 From: Glenna at bag.python.org (Glenna@bag.python.org) Date: Wed Aug 4 00:40:53 2004 Subject: [Python-checkins] Information about rejected payment: P212682668940 Message-ID: <5580555.DG63@nytera.com> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20040804/1577c12b/attachment.html From edloper at users.sourceforge.net Wed Aug 4 03:06:43 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Wed Aug 4 03:06:47 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.11, 1.36.2.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19199 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: - Added "globs" as an instance variable of DocTest. - Added globs and extraglobs arguments to DocTestFinder.find() - Removed globs and extraglobs arguments to DocTestRunner.run() - Renamed DocTestRunner._optionflags to DocTestRunner.optionflags Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.11 retrieving revision 1.36.2.12 diff -C2 -d -r1.36.2.11 -r1.36.2.12 *** doctest.py 3 Aug 2004 21:22:41 -0000 1.36.2.11 --- doctest.py 4 Aug 2004 01:06:40 -0000 1.36.2.12 *************** *** 493,496 **** --- 493,499 ---- - examples: the list of examples. + - globs: The namespace (aka globals) that the examples should + be run in. + - name: A name identifying the DocTest (typically, the name of the object whose docstring this DocTest was extracted from). *************** *** 503,510 **** beginning of the file. """ ! def __init__(self, docstring, name, filename, lineno): """ Create a new DocTest, by extracting examples from `docstring`. """ # Store identifying information self.name = name --- 506,516 ---- beginning of the file. """ ! def __init__(self, docstring, globs, name, filename, lineno): """ Create a new DocTest, by extracting examples from `docstring`. + The DocTest's globals are initialized with a copy of `globs`. """ + # Store a copy of the globals + self.globs = globs.copy() # Store identifying information self.name = name *************** *** 651,659 **** self._recurse = recurse ! def find(self, obj, name=None, module=None): """ Return a list of the DocTests that are defined by the given object's docstring, or by any of its contained objects' docstrings. """ # If name was not specified, then extract it from the object. --- 657,674 ---- self._recurse = recurse ! def find(self, obj, name=None, module=None, globs=None, ! extraglobs=None): """ Return a list of the DocTests that are defined by the given object's docstring, or by any of its contained objects' docstrings. + + The globals for each DocTest is formed by combining `globs` + and `extraglobs` (bindings in `extraglobs` override bindings + in `globs`). A new copy of the globals dictionary is created + for each DocTest. If `globs` is not specified, then it + defaults to the module's `__dict__`, if specified, or {} + otherwise. If `extraglobs` is not specified, then it defaults + to {}. """ # If name was not specified, then extract it from the object. *************** *** 671,675 **** module = inspect.getmodule(obj) - # This is a hack to help Tester.rundict. Setting module=None # in Tester.rundict should make the tester ignore which module --- 686,689 ---- *************** *** 694,700 **** source_lines = None # Recursively expore `obj`, extracting DocTests. tests = [] ! self._find(tests, obj, name, module, source_lines, {}) return tests --- 708,725 ---- source_lines = None + # Initialize globals, and merge in extraglobs. + if globs is None: + if module is None: + globs = {} + else: + globs = module.__dict__.copy() + else: + globs = globs.copy() + if extraglobs is not None: + globs.update(extraglobs) + # Recursively expore `obj`, extracting DocTests. tests = [] ! self._find(tests, obj, name, module, source_lines, globs, {}) return tests *************** *** 724,728 **** raise ValueError("object must be a class or function") ! def _find(self, tests, obj, name, module, source_lines, seen): """ Find tests for the given object and any contained objects, and --- 749,753 ---- raise ValueError("object must be a class or function") ! def _find(self, tests, obj, name, module, source_lines, globs, seen): """ Find tests for the given object and any contained objects, and *************** *** 738,742 **** # Find a test for this object, and add it to the list of tests. ! test = self._get_test(obj, name, module, source_lines) if test is not None: tests.append(test) --- 763,767 ---- # Find a test for this object, and add it to the list of tests. ! test = self._get_test(obj, name, module, globs, source_lines) if test is not None: tests.append(test) *************** *** 753,757 **** and self._from_module(module, val)): self._find(tests, val, valname, module, ! source_lines, seen) # Look for tests in a module's __test__ dictionary. --- 778,782 ---- and self._from_module(module, val)): self._find(tests, val, valname, module, ! source_lines, globs, seen) # Look for tests in a module's __test__ dictionary. *************** *** 770,774 **** (type(val),)) valname = '%s.%s' % (name, valname) ! self._find(tests, val, valname, module, source_lines, seen) # Look for tests in a class's contained objects. --- 795,800 ---- (type(val),)) valname = '%s.%s' % (name, valname) ! self._find(tests, val, valname, module, ! source_lines, globs, seen) # Look for tests in a class's contained objects. *************** *** 789,795 **** valname = '%s.%s' % (name, valname) self._find(tests, val, valname, module, ! source_lines, seen) ! def _get_test(self, obj, name, module, source_lines): """ Return a DocTest for the given object, if it defines a docstring; --- 815,821 ---- valname = '%s.%s' % (name, valname) self._find(tests, val, valname, module, ! source_lines, globs, seen) ! def _get_test(self, obj, name, module, globs, source_lines): """ Return a DocTest for the given object, if it defines a docstring; *************** *** 820,824 **** else: filename = getattr(module, '__file__', module.__name__) ! return DocTest(docstring, name, filename, lineno) def _find_lineno(self, obj, source_lines): --- 846,850 ---- else: filename = getattr(module, '__file__', module.__name__) ! return DocTest(docstring, globs, name, filename, lineno) def _find_lineno(self, obj, source_lines): *************** *** 887,891 **** >>> runner = DocTestRunner(verbose=False) >>> for test in tests: ! ... print runner.run(test, globals()) (0, 2) (0, 1) --- 913,917 ---- >>> runner = DocTestRunner(verbose=False) >>> for test in tests: ! ... print runner.run(test) (0, 2) (0, 1) *************** *** 953,957 **** verbose = '-v' in sys.argv self._verbose = verbose ! self._optionflags = optionflags # Keep track of the examples we've run. --- 979,983 ---- verbose = '-v' in sys.argv self._verbose = verbose ! self.optionflags = optionflags # Keep track of the examples we've run. *************** *** 986,990 **** # The values True and False replaced 1 and 0 as the return # value for boolean comparisons in Python 2.3. ! if not (self._optionflags & DONT_ACCEPT_TRUE_FOR_1): if (got,want) == ("True\n", "1\n"): return True --- 1012,1016 ---- # The values True and False replaced 1 and 0 as the return # value for boolean comparisons in Python 2.3. ! if not (self.optionflags & DONT_ACCEPT_TRUE_FOR_1): if (got,want) == ("True\n", "1\n"): return True *************** *** 994,998 **** # can be used as a special sequence to signify a # blank line, unless the DONT_ACCEPT_BLANKLINE flag is used. ! if not (self._optionflags & DONT_ACCEPT_BLANKLINE): # Replace in want with a blank line. want = re.sub('(?m)^%s\s*?$' % re.escape(BLANKLINE_MARKER), --- 1020,1024 ---- # can be used as a special sequence to signify a # blank line, unless the DONT_ACCEPT_BLANKLINE flag is used. ! if not (self.optionflags & DONT_ACCEPT_BLANKLINE): # Replace in want with a blank line. want = re.sub('(?m)^%s\s*?$' % re.escape(BLANKLINE_MARKER), *************** *** 1007,1011 **** # contents of whitespace strings. Note that this can be used # in conjunction with the ELLISPIS flag. ! if (self._optionflags & NORMALIZE_WHITESPACE): got = ' '.join(got.split()) want = ' '.join(want.split()) --- 1033,1037 ---- # contents of whitespace strings. Note that this can be used # in conjunction with the ELLISPIS flag. ! if (self.optionflags & NORMALIZE_WHITESPACE): got = ' '.join(got.split()) want = ' '.join(want.split()) *************** *** 1016,1020 **** # match any substring in `got`. We implement this by # transforming `want` into a regular expression. ! if (self._optionflags & ELLIPSIS): # Escape any special regexp characters want_re = re.escape(want) --- 1042,1046 ---- # match any substring in `got`. We implement this by # transforming `want` into a regular expression. ! if (self.optionflags & ELLIPSIS): # Escape any special regexp characters want_re = re.escape(want) *************** *** 1038,1042 **** # If s are being used, then replace # with blank lines in the expected output string. ! if not (self._optionflags & DONT_ACCEPT_BLANKLINE): want = re.sub('(?m)^%s$' % re.escape(BLANKLINE_MARKER), '', want) --- 1064,1068 ---- # If s are being used, then replace # with blank lines in the expected output string. ! if not (self.optionflags & DONT_ACCEPT_BLANKLINE): want = re.sub('(?m)^%s$' % re.escape(BLANKLINE_MARKER), '', want) *************** *** 1044,1059 **** # or expected outputs are too short, or if the expected output # contains an ellipsis marker. ! if ((self._optionflags & (UNIFIED_DIFF | CONTEXT_DIFF)) and want.count('\n') > 2 and got.count('\n') > 2 and ! not (self._optionflags & ELLIPSIS and '...' in want)): # Split want & got into lines. want_lines = [l+'\n' for l in want.split('\n')] got_lines = [l+'\n' for l in got.split('\n')] # Use difflib to find their differences. ! if self._optionflags & UNIFIED_DIFF: diff = difflib.unified_diff(want_lines, got_lines, n=2, fromfile='Expected', tofile='Got') kind = 'unified' ! elif self._optionflags & CONTEXT_DIFF: diff = difflib.context_diff(want_lines, got_lines, n=2, fromfile='Expected', tofile='Got') --- 1070,1085 ---- # or expected outputs are too short, or if the expected output # contains an ellipsis marker. ! if ((self.optionflags & (UNIFIED_DIFF | CONTEXT_DIFF)) and want.count('\n') > 2 and got.count('\n') > 2 and ! not (self.optionflags & ELLIPSIS and '...' in want)): # Split want & got into lines. want_lines = [l+'\n' for l in want.split('\n')] got_lines = [l+'\n' for l in got.split('\n')] # Use difflib to find their differences. ! if self.optionflags & UNIFIED_DIFF: diff = difflib.unified_diff(want_lines, got_lines, n=2, fromfile='Expected', tofile='Got') kind = 'unified' ! elif self.optionflags & CONTEXT_DIFF: diff = difflib.context_diff(want_lines, got_lines, n=2, fromfile='Expected', tofile='Got') *************** *** 1165,1182 **** raise ValueError('Bad doctest option directive: '+flag) if flag[0] == '+': ! self._optionflags |= OPTIONFLAGS_BY_NAME[flag[1:]] else: ! self._optionflags &= ~OPTIONFLAGS_BY_NAME[flag[1:]] return True ! def __run(self, test, globs, compileflags, out): """ ! Run the examples in `test`, in the namespace `globs`. Write ! the outcome of each example with one of the ! `DocTestRunnre.report_*` methods, using the writer function ! `out`. `compileflags` is the set of compiler flags that ! should be used to execute examples. Return a tuple `(f, t)`, ! where `t` is the number of examples tried, and `f` is the ! number of examples that failed. """ # Keep track of the number of failures and tries. --- 1191,1208 ---- raise ValueError('Bad doctest option directive: '+flag) if flag[0] == '+': ! self.optionflags |= OPTIONFLAGS_BY_NAME[flag[1:]] else: ! self.optionflags &= ~OPTIONFLAGS_BY_NAME[flag[1:]] return True ! def __run(self, test, compileflags, out): """ ! Run the examples in `test`. Write the outcome of each example ! with one of the `DocTestRunner.report_*` methods, using the ! writer function `out`. `compileflags` is the set of compiler ! flags that should be used to execute examples. Return a tuple ! `(f, t)`, where `t` is the number of examples tried, and `f` ! is the number of examples that failed. The examples are run ! in the namespace `test.globs`. """ # Keep track of the number of failures and tries. *************** *** 1185,1189 **** # Save the option flags (since doctest directives can be used # to modify them). ! original_optionflags = self._optionflags # Process each example. --- 1211,1215 ---- # Save the option flags (since doctest directives can be used # to modify them). ! original_optionflags = self.optionflags # Process each example. *************** *** 1207,1211 **** # append one (it never hurts). exec compile(example.source + '\n', "", "single", ! compileflags, 1) in globs exception = None except KeyboardInterrupt: --- 1233,1237 ---- # append one (it never hurts). exec compile(example.source + '\n', "", "single", ! compileflags, 1) in test.globs exception = None except KeyboardInterrupt: *************** *** 1258,1262 **** # Restore the option flags (in case they were modified) ! self._optionflags = original_optionflags # Record and return the number of failures and tries. --- 1284,1288 ---- # Restore the option flags (in case they were modified) ! self.optionflags = original_optionflags # Record and return the number of failures and tries. *************** *** 1274,1288 **** self.tries += t ! def run(self, test, globs, extraglobs=None, compileflags=None, out=None): """ Run the examples in `test`, and display the results using the writer function `out`. ! The examples are all run in a single namespace, which is ! created by combining `globs` and `extraglobs` (bindings in ! `extraglobs` override bindings in `globs`). Shallow changes ! to this namespace by the examples will not affect `globs` or ! `extraglobs`; but changes to objects contained in `globs` or ! extraglobs` will be visible. `compileflags` gives the set of flags that should be used by --- 1300,1313 ---- self.tries += t ! def run(self, test, compileflags=None, out=None, clear_globs=True): """ Run the examples in `test`, and display the results using the writer function `out`. ! The examples are run in the namespace `test.globs`. If ! `clear_globs` is true (the default), then this namespace will ! be cleared after the test runs, to help with garbage ! collection. If you would like to examine the namespace after ! the test completes, then use `clear_globs=False`. `compileflags` gives the set of flags that should be used by *************** *** 1296,1309 **** """ if compileflags is None: ! compileflags = _extract_future_flags(globs) if out is None: out = sys.stdout.write saveout = sys.stdout ! globs = globs.copy() ! if extraglobs is not None: ! globs.update(extraglobs) try: sys.stdout = self._fakeout ! return self.__run(test, globs, compileflags, out) finally: sys.stdout = saveout --- 1321,1332 ---- """ if compileflags is None: ! compileflags = _extract_future_flags(test.globs) if out is None: out = sys.stdout.write saveout = sys.stdout ! try: sys.stdout = self._fakeout ! return self.__run(test, compileflags, out) finally: sys.stdout = saveout *************** *** 1316,1320 **** # help to break other kinds of cycles, and even for cycles that # gc can break itself it's better to break them ASAP. ! globs.clear() #///////////////////////////////////////////////////////////////// --- 1339,1344 ---- # help to break other kinds of cycles, and even for cycles that # gc can break itself it's better to break them ASAP. ! if clear_globs: ! test.globs.clear() #///////////////////////////////////////////////////////////////// *************** *** 1487,1499 **** name = m.__name__ - # If globals were not specified, then default to the module. - if globs is None: - globs = m.__dict__ - # Find, parse, and run all tests in the given module. finder = DocTestFinder(namefilter=isprivate) runner = DocTestRunner(verbose=verbose, optionflags=optionflags) ! for test in finder.find(m, name): ! runner.run(test, globs=m.__dict__, extraglobs=extraglobs) if report: --- 1511,1519 ---- name = m.__name__ # Find, parse, and run all tests in the given module. finder = DocTestFinder(namefilter=isprivate) runner = DocTestRunner(verbose=verbose, optionflags=optionflags) ! for test in finder.find(m, name, globs=globs, extraglobs=extraglobs): ! runner.run(test) if report: *************** *** 1522,1527 **** finder = DocTestFinder(verbose=verbose, recurse=False) runner = DocTestRunner(verbose=verbose, optionflags=optionflags) ! for test in finder.find(f, name): ! runner.run(test, globs=globs, compileflags=compileflags) ###################################################################### --- 1542,1547 ---- finder = DocTestFinder(verbose=verbose, recurse=False) runner = DocTestRunner(verbose=verbose, optionflags=optionflags) ! for test in finder.find(f, name, globs=globs): ! runner.run(test, compileflags=compileflags) ###################################################################### *************** *** 1551,1558 **** def runstring(self, s, name): ! test = DocTest(s, name, None, None) if self.verbose: print "Running string", name ! (f,t) = self.testrunner.run(test, globs=self.globs) if self.verbose: print f, "of", t, "examples failed in string", name --- 1571,1578 ---- def runstring(self, s, name): ! test = DocTest(s, self.globs, name, None, None) if self.verbose: print "Running string", name ! (f,t) = self.testrunner.run(test) if self.verbose: print f, "of", t, "examples failed in string", name *************** *** 1561,1567 **** def rundoc(self, object, name=None, module=None): f = t = 0 ! tests = self.testfinder.find(object, name, module=module) for test in tests: ! (f2, t2) = self.testrunner.run(test, globs=self.globs) (f,t) = (f+f2, t+t2) return (f,t) --- 1581,1588 ---- def rundoc(self, object, name=None, module=None): f = t = 0 ! tests = self.testfinder.find(object, name, module=module, ! globs=self.globs) for test in tests: ! (f2, t2) = self.testrunner.run(test) (f,t) = (f+f2, t+t2) return (f,t) *************** *** 1599,1609 **** """ ! def __init__(self, test_runner, test, globs, extraglobs=None, setUp=None, tearDown=None): unittest.TestCase.__init__(self) self.__test_runner = test_runner self.__test = test - self.__globs = globs - self.__extraglobs = extraglobs self.__setUp = setUp self.__tearDown = tearDown --- 1620,1628 ---- """ ! def __init__(self, test_runner, test, setUp=None, tearDown=None): unittest.TestCase.__init__(self) self.__test_runner = test_runner self.__test = test self.__setUp = setUp self.__tearDown = tearDown *************** *** 1623,1629 **** try: self.__test_runner.DIVIDER = "-"*70 ! failures, tries = self.__test_runner.run(test, self.__globs, ! self.__extraglobs, ! out=new.write) finally: sys.stdout = old --- 1642,1646 ---- try: self.__test_runner.DIVIDER = "-"*70 ! failures, tries = self.__test_runner.run(test, out=new.write) finally: sys.stdout = old *************** *** 1688,1692 **** else: module = _normalize_module(module) ! tests = test_finder.find(module) if globs is None: globs = module.__dict__ --- 1705,1709 ---- else: module = _normalize_module(module) ! tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) if globs is None: globs = module.__dict__ *************** *** 1705,1710 **** filename = filename[:-1] test.filename = filename ! suite.addTest(DocTestTestCase(test_runner, test, globs, ! extraglobs, setUp, tearDown)) return suite --- 1722,1727 ---- filename = filename[:-1] test.filename = filename ! suite.addTest(DocTestTestCase(test_runner, test, ! setUp, tearDown)) return suite *************** *** 1752,1756 **** The string is provided directly """ ! test = DocTest(src, 'debug', None, None) testsrc = '\n'.join([ --- 1769,1773 ---- The string is provided directly """ ! test = DocTest(src, globs or {}, 'debug', None, None) testsrc = '\n'.join([ From edloper at users.sourceforge.net Wed Aug 4 03:07:27 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Wed Aug 4 03:07:30 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.5.18.7, 1.5.18.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19299/test Modified Files: Tag: tim-doctest-branch test_doctest.py Log Message: - Pass globals to DocTest/DocTestFinder, not DocTestRunner Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.5.18.7 retrieving revision 1.5.18.8 diff -C2 -d -r1.5.18.7 -r1.5.18.8 *** test_doctest.py 3 Aug 2004 20:13:12 -0000 1.5.18.7 --- test_doctest.py 4 Aug 2004 01:07:22 -0000 1.5.18.8 *************** *** 169,173 **** ... example ... ''' ! >>> test = doctest.DocTest(docstring, 'some_test', 'some_file', 20) >>> print test --- 169,174 ---- ... example ... ''' ! >>> globs = {} # globals to run the test in. ! >>> test = doctest.DocTest(docstring, globs, 'some_test', 'some_file', 20) >>> print test *************** *** 203,207 **** ... indentation ... ''' ! >>> doctest.DocTest(docstring, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 3 of the docstring for some_test has inconsistent leading whitespace: ' indentation' --- 204,208 ---- ... indentation ... ''' ! >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 3 of the docstring for some_test has inconsistent leading whitespace: ' indentation' *************** *** 215,219 **** ... ('bad', 'indentation') ... ''' ! >>> doctest.DocTest(docstring, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: ' ... 2)' --- 216,220 ---- ... ('bad', 'indentation') ... ''' ! >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: ' ... 2)' *************** *** 223,227 **** >>> docstring = '>>>print 1\n1' ! >>> doctest.DocTest(docstring, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 0 of the docstring for some_test lacks blank after >>>: '>>>print 1' --- 224,228 ---- >>> docstring = '>>>print 1\n1' ! >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 0 of the docstring for some_test lacks blank after >>>: '>>>print 1' *************** *** 473,477 **** of tried tests. ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) (0, 3) --- 474,478 ---- of tried tests. ! >>> doctest.DocTestRunner(verbose=False).run(test) (0, 3) *************** *** 488,492 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=True).run(test, {}) Trying: x = 12 Expecting: nothing --- 489,493 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=True).run(test) Trying: x = 12 Expecting: nothing *************** *** 518,522 **** >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=True).run(test, {}) Trying: x = 12 Expecting: nothing --- 519,523 ---- >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=True).run(test) Trying: x = 12 Expecting: nothing *************** *** 538,547 **** >>> # If -v does not appear in sys.argv, then output isn't verbose. >>> sys.argv = ['test'] ! >>> doctest.DocTestRunner().run(test, {}) (0, 3) >>> # If -v does appear in sys.argv, then output is verbose. >>> sys.argv = ['test', '-v'] ! >>> doctest.DocTestRunner().run(test, {}) Trying: x = 12 Expecting: nothing --- 539,548 ---- >>> # If -v does not appear in sys.argv, then output isn't verbose. >>> sys.argv = ['test'] ! >>> doctest.DocTestRunner().run(test) (0, 3) >>> # If -v does appear in sys.argv, then output is verbose. >>> sys.argv = ['test', '-v'] ! >>> doctest.DocTestRunner().run(test) Trying: x = 12 Expecting: nothing *************** *** 576,580 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) (0, 2) --- 577,581 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) (0, 2) *************** *** 591,595 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) (0, 2) --- 592,596 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) (0, 2) *************** *** 605,609 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) (0, 1) --- 606,610 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) (0, 1) *************** *** 618,622 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: raise ValueError, 'message' --- 619,623 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** Failure in example: raise ValueError, 'message' *************** *** 643,647 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: 1/0 --- 644,648 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** Failure in example: 1/0 *************** *** 649,655 **** Exception raised: Traceback (most recent call last): ! File "...", line ..., in __run ! compileflags, 1) in globs ! File "", line 1, in ? ZeroDivisionError: integer division or modulo by zero (1, 1) --- 650,654 ---- Exception raised: Traceback (most recent call last): ! ... ZeroDivisionError: integer division or modulo by zero (1, 1) *************** *** 673,677 **** >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) (0, 1) --- 672,676 ---- >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) (0, 1) *************** *** 679,683 **** >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.DONT_ACCEPT_TRUE_FOR_1 ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test, {}) ********************************************************************** Failure in example: True --- 678,682 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.DONT_ACCEPT_TRUE_FOR_1 ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ********************************************************************** Failure in example: True *************** *** 695,699 **** >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) (0, 1) --- 694,698 ---- >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) (0, 1) *************** *** 701,705 **** >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.DONT_ACCEPT_BLANKLINE ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test, {}) ********************************************************************** Failure in example: print "a\n\nb" --- 700,704 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.DONT_ACCEPT_BLANKLINE ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ********************************************************************** Failure in example: print "a\n\nb" *************** *** 723,727 **** >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: print 1, 2, 3 --- 722,726 ---- >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** Failure in example: print 1, 2, 3 *************** *** 736,740 **** >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.NORMALIZE_WHITESPACE ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test, {}) (0, 1) --- 735,739 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.NORMALIZE_WHITESPACE ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) (0, 1) *************** *** 747,751 **** >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: print range(15) --- 746,750 ---- >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** Failure in example: print range(15) *************** *** 758,762 **** >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.ELLIPSIS ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test, {}) (0, 1) --- 757,761 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.ELLIPSIS ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) (0, 1) *************** *** 778,782 **** >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: print '\n'.join('abcdefg') --- 777,781 ---- >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** Failure in example: print '\n'.join('abcdefg') *************** *** 803,807 **** >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.UNIFIED_DIFF ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test, {}) ********************************************************************** Failure in example: print '\n'.join('abcdefg') --- 802,806 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.UNIFIED_DIFF ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ********************************************************************** Failure in example: print '\n'.join('abcdefg') *************** *** 829,833 **** >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.CONTEXT_DIFF ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test, {}) ********************************************************************** Failure in example: print '\n'.join('abcdefg') --- 828,832 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.CONTEXT_DIFF ! >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ********************************************************************** Failure in example: print '\n'.join('abcdefg') *************** *** 878,882 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: print range(10) # Should fail: no ellipsis --- 877,881 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** Failure in example: print range(10) # Should fail: no ellipsis *************** *** 901,905 **** ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test, {}) ********************************************************************** Failure in example: print range(10) # Should fail --- 900,904 ---- ... ''' >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** Failure in example: print range(10) # Should fail From tim_one at users.sourceforge.net Wed Aug 4 04:16:51 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 4 04:16:54 2004 Subject: [Python-checkins] python/dist/src/Modules _tkinter.c,1.166,1.167 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28069/Modules Modified Files: _tkinter.c Log Message: Tkapp_New(): Rewrite in C so it compiles again. Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.166 retrieving revision 1.167 diff -C2 -d -r1.166 -r1.167 *** _tkinter.c 3 Aug 2004 18:45:31 -0000 1.166 --- _tkinter.c 4 Aug 2004 02:16:48 -0000 1.167 *************** *** 581,584 **** --- 581,585 ---- TkappObject *v; char *argv0; + v = PyObject_New(TkappObject, &Tkapp_Type); if (v == NULL) *************** *** 647,651 **** --- 648,654 ---- /* some initial arguments need to be in argv */ if (sync || use) { + char *args; int len = 0; + if (sync) len += sizeof "-sync"; *************** *** 653,657 **** len += strlen(use) + sizeof "-use "; ! char *args = (char*)ckalloc(len); if (!args) { PyErr_NoMemory(); --- 656,660 ---- len += strlen(use) + sizeof "-use "; ! args = (char*)ckalloc(len); if (!args) { PyErr_NoMemory(); From tim_one at users.sourceforge.net Wed Aug 4 04:29:15 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 4 04:29:18 2004 Subject: [Python-checkins] python/dist/src/Lib ihooks.py, 1.18, 1.19 imputil.py, 1.26, 1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29168/Lib Modified Files: ihooks.py imputil.py Log Message: ihooks FancyModuleLoader.load_module() imputils Importer._process_result(): remove name from modules dict if exec fails. This is what all the builtin importers do now, new in 2.4. Index: ihooks.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ihooks.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ihooks.py 12 Feb 2004 17:35:06 -0000 1.18 --- ihooks.py 4 Aug 2004 02:29:12 -0000 1.19 *************** *** 323,327 **** m.__path__ = path m.__file__ = filename ! exec code in m.__dict__ return m --- 323,333 ---- m.__path__ = path m.__file__ = filename ! try: ! exec code in m.__dict__ ! except: ! d = self.hooks.modules_dict() ! if name in d: ! del d[name] ! raise return m Index: imputil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imputil.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** imputil.py 28 Jun 2002 23:32:51 -0000 1.26 --- imputil.py 4 Aug 2004 02:29:12 -0000 1.27 *************** *** 298,302 **** # execute the code within the module's namespace if not is_module: ! exec code in module.__dict__ # fetch from sys.modules instead of returning module directly. --- 298,307 ---- # execute the code within the module's namespace if not is_module: ! try: ! exec code in module.__dict__ ! except: ! if fqname in sys.modules: ! del sys.modules[fqname] ! raise # fetch from sys.modules instead of returning module directly. From tim_one at users.sourceforge.net Wed Aug 4 04:30:47 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 4 04:30:50 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_threadsignals.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29431/Lib/test Modified Files: test_threadsignals.py Log Message: To raise TestSkipped, you must import TestSkipped. Index: test_threadsignals.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_threadsignals.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_threadsignals.py 3 Aug 2004 16:14:13 -0000 1.3 --- test_threadsignals.py 4 Aug 2004 02:30:45 -0000 1.4 *************** *** 6,10 **** import os import sys ! from test import test_support if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos': --- 6,10 ---- import os import sys ! from test import test_support, TestSkipped if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos': From tim_one at users.sourceforge.net Wed Aug 4 04:32:05 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 4 04:32:08 2004 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py,1.157,1.158 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29591/Lib/test Modified Files: regrtest.py Log Message: test_threadsignals is an expected skip on win32. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.157 retrieving revision 1.158 diff -C2 -d -r1.157 -r1.158 *** regrtest.py 3 Aug 2004 11:33:28 -0000 1.157 --- regrtest.py 4 Aug 2004 02:32:03 -0000 1.158 *************** *** 699,702 **** --- 699,703 ---- test_signal test_sunaudiodev + test_threadsignals test_timing """, From tim_one at users.sourceforge.net Wed Aug 4 04:36:20 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 4 04:36:23 2004 Subject: [Python-checkins] python/dist/src/Lib/compiler ast.py, 1.24, 1.25 pycodegen.py, 1.69, 1.70 transformer.py, 1.41, 1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30068/Lib/compiler Modified Files: ast.py pycodegen.py transformer.py Log Message: Whitespace normalization. Index: ast.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/ast.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** ast.py 2 Aug 2004 06:09:53 -0000 1.24 --- ast.py 4 Aug 2004 02:36:17 -0000 1.25 *************** *** 608,612 **** self.argnames = ['[outmost-iterable]'] self.varargs = self.kwargs = None ! --- 608,612 ---- self.argnames = ['[outmost-iterable]'] self.varargs = self.kwargs = None ! *************** *** 786,790 **** if flags & CO_VARKEYWORDS: self.kwargs = 1 ! --- 786,790 ---- if flags & CO_VARKEYWORDS: self.kwargs = 1 ! Index: pycodegen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/pycodegen.py,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** pycodegen.py 2 Aug 2004 06:09:53 -0000 1.69 --- pycodegen.py 4 Aug 2004 02:36:17 -0000 1.70 *************** *** 373,377 **** else: ndecorators = 0 ! gen = self.FunctionGen(node, self.scopes, isLambda, self.class_name, self.get_module()) --- 373,377 ---- else: ndecorators = 0 ! gen = self.FunctionGen(node, self.scopes, isLambda, self.class_name, self.get_module()) *************** *** 390,394 **** self.emit('LOAD_CONST', gen) self.emit('MAKE_FUNCTION', len(node.defaults)) ! for i in range(ndecorators): self.emit('CALL_FUNCTION', 1) --- 390,394 ---- self.emit('LOAD_CONST', gen) self.emit('MAKE_FUNCTION', len(node.defaults)) ! for i in range(ndecorators): self.emit('CALL_FUNCTION', 1) Index: transformer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/transformer.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** transformer.py 2 Aug 2004 06:09:53 -0000 1.41 --- transformer.py 4 Aug 2004 02:36:18 -0000 1.42 *************** *** 199,203 **** return item ! def decorator(self, nodelist): # '@' dotted_name [ '(' [arglist] ')' ] --- 199,203 ---- return item ! def decorator(self, nodelist): # '@' dotted_name [ '(' [arglist] ')' ] *************** *** 213,219 **** else: expr = funcname ! return expr ! def decorators(self, nodelist): # decorators: decorator ([NEWLINE] decorator)* NEWLINE --- 213,219 ---- else: expr = funcname ! return expr ! def decorators(self, nodelist): # decorators: decorator ([NEWLINE] decorator)* NEWLINE *************** *** 229,233 **** i += 1 return Decorators(items) ! def funcdef(self, nodelist): # -6 -5 -4 -3 -2 -1 --- 229,233 ---- i += 1 return Decorators(items) ! def funcdef(self, nodelist): # -6 -5 -4 -3 -2 -1 *************** *** 241,245 **** assert len(nodelist) == 5 decorators = None ! lineno = nodelist[-4][2] name = nodelist[-4][1] --- 241,245 ---- assert len(nodelist) == 5 decorators = None ! lineno = nodelist[-4][2] name = nodelist[-4][1] From tim_one at users.sourceforge.net Wed Aug 4 04:36:20 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 4 04:36:24 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils cygwinccompiler.py, 1.27, 1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30068/Lib/distutils Modified Files: cygwinccompiler.py Log Message: Whitespace normalization. Index: cygwinccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cygwinccompiler.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** cygwinccompiler.py 3 Aug 2004 12:41:42 -0000 1.27 --- cygwinccompiler.py 4 Aug 2004 02:36:18 -0000 1.28 *************** *** 123,137 **** else: self.dll_libraries=[] ! # Include the appropriate MSVC runtime library if Python was built ! # with MSVC 7.0 or 7.1. ! msc_pos = sys.version.find('MSC v.') ! if msc_pos != -1: ! msc_ver = sys.version[msc_pos+6:msc_pos+10] ! if msc_ver == '1300': ! # MSVC 7.0 ! self.dll_libraries = ['msvcr70'] ! elif msc_ver == '1310': ! # MSVC 7.1 ! self.dll_libraries = ['msvcr71'] # __init__ () --- 123,137 ---- else: self.dll_libraries=[] ! # Include the appropriate MSVC runtime library if Python was built ! # with MSVC 7.0 or 7.1. ! msc_pos = sys.version.find('MSC v.') ! if msc_pos != -1: ! msc_ver = sys.version[msc_pos+6:msc_pos+10] ! if msc_ver == '1300': ! # MSVC 7.0 ! self.dll_libraries = ['msvcr70'] ! elif msc_ver == '1310': ! # MSVC 7.1 ! self.dll_libraries = ['msvcr71'] # __init__ () *************** *** 320,334 **** self.dll_libraries=[] ! # Include the appropriate MSVC runtime library if Python was built ! # with MSVC 7.0 or 7.1. ! msc_pos = sys.version.find('MSC v.') ! if msc_pos != -1: ! msc_ver = sys.version[msc_pos+6:msc_pos+10] ! if msc_ver == '1300': ! # MSVC 7.0 ! self.dll_libraries = ['msvcr70'] ! elif msc_ver == '1310': ! # MSVC 7.1 ! self.dll_libraries = ['msvcr71'] # __init__ () --- 320,334 ---- self.dll_libraries=[] ! # Include the appropriate MSVC runtime library if Python was built ! # with MSVC 7.0 or 7.1. ! msc_pos = sys.version.find('MSC v.') ! if msc_pos != -1: ! msc_ver = sys.version[msc_pos+6:msc_pos+10] ! if msc_ver == '1300': ! # MSVC 7.0 ! self.dll_libraries = ['msvcr70'] ! elif msc_ver == '1310': ! # MSVC 7.1 ! self.dll_libraries = ['msvcr71'] # __init__ () From tim_one at users.sourceforge.net Wed Aug 4 04:36:21 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 4 04:36:24 2004 Subject: [Python-checkins] python/dist/src/Lib/test pyclbr_input.py, 1.1, 1.2 test_decorators.py, 1.2, 1.3 test_pyclbr.py, 1.22, 1.23 test_threadsignals.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30068/Lib/test Modified Files: pyclbr_input.py test_decorators.py test_pyclbr.py test_threadsignals.py Log Message: Whitespace normalization. Index: pyclbr_input.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/pyclbr_input.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pyclbr_input.py 2 Aug 2004 06:09:54 -0000 1.1 --- pyclbr_input.py 4 Aug 2004 02:36:18 -0000 1.2 *************** *** 11,19 **** class B (object): def bm(self): pass ! class C (B): foo = Other().foo om = Other.om ! d = 10 --- 11,19 ---- class B (object): def bm(self): pass ! class C (B): foo = Other().foo om = Other.om ! d = 10 *************** *** 24,30 **** # #f = f ! def m(self): pass ! @staticmethod def sm(self): pass --- 24,30 ---- # #f = f ! def m(self): pass ! @staticmethod def sm(self): pass Index: test_decorators.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decorators.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_decorators.py 2 Aug 2004 11:34:10 -0000 1.2 --- test_decorators.py 4 Aug 2004 02:36:18 -0000 1.3 *************** *** 23,28 **** Exception.__init__(self, "dbcheck %r failed (func=%s args=%s kwds=%s)" % (exprstr, func, args, kwds)) ! ! def dbcheck(exprstr, globals=None, locals=None): "Decorator to implement debugging assertions" --- 23,28 ---- Exception.__init__(self, "dbcheck %r failed (func=%s args=%s kwds=%s)" % (exprstr, func, args, kwds)) ! ! def dbcheck(exprstr, globals=None, locals=None): "Decorator to implement debugging assertions" *************** *** 67,71 **** return func(*args) return call ! # ----------------------------------------------- --- 67,71 ---- return func(*args) return call ! # ----------------------------------------------- *************** *** 81,85 **** def test_staticmethod_function(self): @staticmethod ! def notamethod(x): return x self.assertRaises(TypeError, notamethod, 1) --- 81,85 ---- def test_staticmethod_function(self): @staticmethod ! def notamethod(x): return x self.assertRaises(TypeError, notamethod, 1) *************** *** 95,99 **** # A few tests of argument passing, as we use restricted form # of expressions for decorators. ! def noteargs(*args, **kwds): def decorate(func): --- 95,99 ---- # A few tests of argument passing, as we use restricted form # of expressions for decorators. ! def noteargs(*args, **kwds): def decorate(func): *************** *** 130,134 **** # see the comment in countcalls. counts = {} ! @countcalls(counts) @memoize def double(x): return x * 2 --- 130,134 ---- # see the comment in countcalls. counts = {} ! @countcalls(counts) @memoize def double(x): return x * 2 *************** *** 158,162 **** # Sanity check: is expr is a valid expression by itself? compile(expr, "testexpr", "exec") ! codestr = "@%s\ndef f(): pass" % expr self.assertRaises(SyntaxError, compile, codestr, "test", "exec") --- 158,162 ---- # Sanity check: is expr is a valid expression by itself? compile(expr, "testexpr", "exec") ! codestr = "@%s\ndef f(): pass" % expr self.assertRaises(SyntaxError, compile, codestr, "test", "exec") *************** *** 167,171 **** raise NotImplementedError context = dict(nullval=None, unimp=unimp) ! for expr, exc in [ ("undef", NameError), ("nullval", TypeError), --- 167,171 ---- raise NotImplementedError context = dict(nullval=None, unimp=unimp) ! for expr, exc in [ ("undef", NameError), ("nullval", TypeError), Index: test_pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyclbr.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** test_pyclbr.py 2 Aug 2004 06:09:54 -0000 1.22 --- test_pyclbr.py 4 Aug 2004 02:36:18 -0000 1.23 *************** *** 152,156 **** # self.checkModule('test.pyclbr_input') ! def test_others(self): cm = self.checkModule --- 152,156 ---- # self.checkModule('test.pyclbr_input') ! def test_others(self): cm = self.checkModule Index: test_threadsignals.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_threadsignals.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_threadsignals.py 4 Aug 2004 02:30:45 -0000 1.4 --- test_threadsignals.py 4 Aug 2004 02:36:18 -0000 1.5 *************** *** 11,15 **** raise TestSkipped, "Can't test signal on %s" % sys.platform ! signal_blackboard = { signal.SIGUSR1 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGALRM : {'tripped': 0, 'tripped_by': 0 } } --- 11,15 ---- raise TestSkipped, "Can't test signal on %s" % sys.platform ! signal_blackboard = { signal.SIGUSR1 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGALRM : {'tripped': 0, 'tripped_by': 0 } } *************** *** 29,33 **** # from who. def handle_signals(sig,frame): ! signal_blackboard[sig]['tripped'] += 1 signal_blackboard[sig]['tripped_by'] = thread.get_ident() --- 29,33 ---- # from who. def handle_signals(sig,frame): ! signal_blackboard[sig]['tripped'] += 1 signal_blackboard[sig]['tripped_by'] = thread.get_ident() *************** *** 56,73 **** if signal_blackboard[signal.SIGUSR2]['tripped'] == 0 \ or signal_blackboard[signal.SIGUSR2]['tripped'] == 0: ! signal.alarm(1) ! signal.pause() ! signal.alarm(0) self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped'], 1) ! self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped_by'], thread.get_ident()) self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped'], 1) ! self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped_by'], thread.get_ident()) def spawnSignallingThread(self): thread.start_new_thread(send_signals, ()) ! def test_main(): --- 56,73 ---- if signal_blackboard[signal.SIGUSR2]['tripped'] == 0 \ or signal_blackboard[signal.SIGUSR2]['tripped'] == 0: ! signal.alarm(1) ! signal.pause() ! signal.alarm(0) self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped'], 1) ! self.assertEqual( signal_blackboard[signal.SIGUSR1]['tripped_by'], thread.get_ident()) self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped'], 1) ! self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped_by'], thread.get_ident()) def spawnSignallingThread(self): thread.start_new_thread(send_signals, ()) ! def test_main(): From perky at users.sourceforge.net Wed Aug 4 08:33:53 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 08:33:56 2004 Subject: [Python-checkins] python/dist/src/Include pyport.h,2.68,2.69 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25741/Include Modified Files: pyport.h Log Message: Add a workaround for a problem that UTF-8 strings can be corrupted or broken by basic ctype functions in 4.4BSD descendants. This will be fixed in their future development branches but they'll keep the POSIX-incompatibility for their backward-compatiblities in near future. Index: pyport.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pyport.h,v retrieving revision 2.68 retrieving revision 2.69 diff -C2 -d -r2.68 -r2.69 *** pyport.h 15 Jul 2004 15:54:03 -0000 2.68 --- pyport.h 4 Aug 2004 06:33:50 -0000 2.69 *************** *** 412,415 **** --- 412,448 ---- #endif + + /******************************************************************* + On 4.4BSD-descendants, ctype functions serves the whole range of + wchar_t character set rather than single byte code points only. + This characteristic can break some operations of string object + including str.upper() and str.split() on UTF-8 locales. This + workaround was provided by Tim Robbins of FreeBSD project. He said + the incompatibility will be fixed in FreeBSD 6. + ********************************************************************/ + + #ifdef __FreeBSD__ + #include + #if __FreeBSD_version > 500039 + #include + #include + #undef isalnum + #define isalnum(c) iswalnum(btowc(c)) + #undef isalpha + #define isalpha(c) iswalpha(btowc(c)) + #undef islower + #define islower(c) iswlower(btowc(c)) + #undef isspace + #define isspace(c) iswspace(btowc(c)) + #undef isupper + #define isupper(c) iswupper(btowc(c)) + #undef tolower + #define tolower(c) towlower(btowc(c)) + #undef toupper + #define toupper(c) towupper(btowc(c)) + #endif + #endif + + /* Declarations for symbol visibility. From perky at users.sourceforge.net Wed Aug 4 08:33:54 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 08:33:57 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1066,1.1067 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25741/Misc Modified Files: NEWS Log Message: Add a workaround for a problem that UTF-8 strings can be corrupted or broken by basic ctype functions in 4.4BSD descendants. This will be fixed in their future development branches but they'll keep the POSIX-incompatibility for their backward-compatiblities in near future. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1066 retrieving revision 1.1067 diff -C2 -d -r1.1066 -r1.1067 *** NEWS 3 Aug 2004 18:45:31 -0000 1.1066 --- NEWS 4 Aug 2004 06:33:50 -0000 1.1067 *************** *** 65,68 **** --- 65,71 ---- - Implemented bind_textdomain_codeset() in locale module. + - Added a workaround for proper string operations in BSDs. str.split + and str.is* methods can now work correctly with UTF-8 locales. + Extension modules ----------------- From perky at users.sourceforge.net Wed Aug 4 08:33:54 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 08:33:57 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_locale.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25741/Lib/test Modified Files: test_locale.py Log Message: Add a workaround for a problem that UTF-8 strings can be corrupted or broken by basic ctype functions in 4.4BSD descendants. This will be fixed in their future development branches but they'll keep the POSIX-incompatibility for their backward-compatiblities in near future. Index: test_locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_locale.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_locale.py 19 Dec 2003 01:16:03 -0000 1.8 --- test_locale.py 4 Aug 2004 06:33:51 -0000 1.9 *************** *** 48,49 **** --- 48,84 ---- finally: locale.setlocale(locale.LC_NUMERIC, oldlocale) + + + # Test BSD Rune locale's bug for isctype functions. + def teststrop(s, method, output): + if verbose: + print "%s.%s() =? %s ..." % (repr(s), method, repr(output)), + result = getattr(s, method)() + if result != output: + if verbose: + print "no" + print "%s.%s() == %s != %s" % (repr(s), method, repr(result), + repr(output)) + elif verbose: + print "yes" + + try: + oldlocale = locale.setlocale(locale.LC_CTYPE) + locale.setlocale(locale.LC_CTYPE, 'en_US.UTF-8') + except locale.Error: + pass + else: + try: + teststrop('\x20', 'isspace', True) + teststrop('\xa0', 'isspace', False) + teststrop('\xa1', 'isspace', False) + teststrop('\xc0', 'isalpha', False) + teststrop('\xc0', 'isalnum', False) + teststrop('\xc0', 'isupper', False) + teststrop('\xc0', 'islower', False) + teststrop('\xec\xa0\xbc', 'split', ['\xec\xa0\xbc']) + teststrop('\xed\x95\xa0', 'strip', '\xed\x95\xa0') + teststrop('\xcc\x85', 'lower', '\xcc\x85') + teststrop('\xed\x95\xa0', 'upper', '\xed\x95\xa0') + finally: + locale.setlocale(locale.LC_CTYPE, oldlocale) From perky at users.sourceforge.net Wed Aug 4 09:38:36 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 09:38:38 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.158, 1.159 libunicodedata.tex, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1744/Doc/lib Modified Files: libstdtypes.tex libunicodedata.tex Log Message: SF #989185: Drop unicode.iswide() and unicode.width() and add unicodedata.east_asian_width(). You can still implement your own simple width() function using it like this: def width(u): w = 0 for c in unicodedata.normalize('NFC', u): cwidth = unicodedata.east_asian_width(c) if cwidth in ('W', 'F'): w += 2 else: w += 1 return w Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.158 retrieving revision 1.159 diff -C2 -d -r1.158 -r1.159 *** libstdtypes.tex 22 Jul 2004 19:33:53 -0000 1.158 --- libstdtypes.tex 4 Aug 2004 07:38:33 -0000 1.159 *************** *** 665,674 **** \end{methoddesc} - \begin{methoddesc}[string]{iswide}{} - Return true if all characters in the string are wide or full width and - there is at least one wide or full width character, false otherwise. - This method is supported by unicode type only. - \end{methoddesc} - \begin{methoddesc}[string]{join}{seq} Return a string which is the concatenation of the strings in the --- 665,668 ---- *************** *** 811,819 **** \end{methoddesc} - \begin{methoddesc}[string]{width}{} - Return length of fixed-width representation of the string. This method - is supported by unicode type only. - \end{methoddesc} - \begin{methoddesc}[string]{zfill}{width} Return the numeric string left filled with zeros in a string --- 805,808 ---- Index: libunicodedata.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libunicodedata.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** libunicodedata.tex 25 Nov 2002 09:13:35 -0000 1.5 --- libunicodedata.tex 4 Aug 2004 07:38:33 -0000 1.6 *************** *** 72,75 **** --- 72,80 ---- \end{funcdesc} + \begin{funcdesc}{east_asian_width}{unichr} + Returns the east asian width of assigned to the Unicode character + \var{unichr} as string. + \end{funcdesc} + \begin{funcdesc}{mirrored}{unichr} Returns the mirrored property of assigned to the Unicode character *************** *** 124,126 **** \versionadded{2.3} ! \end{datadesc} \ No newline at end of file --- 129,131 ---- \versionadded{2.3} ! \end{datadesc} From perky at users.sourceforge.net Wed Aug 4 09:38:36 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 09:38:39 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1067,1.1068 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1744/Misc Modified Files: NEWS Log Message: SF #989185: Drop unicode.iswide() and unicode.width() and add unicodedata.east_asian_width(). You can still implement your own simple width() function using it like this: def width(u): w = 0 for c in unicodedata.normalize('NFC', u): cwidth = unicodedata.east_asian_width(c) if cwidth in ('W', 'F'): w += 2 else: w += 1 return w Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1067 retrieving revision 1.1068 diff -C2 -d -r1.1067 -r1.1068 *** NEWS 4 Aug 2004 06:33:50 -0000 1.1067 --- NEWS 4 Aug 2004 07:38:34 -0000 1.1068 *************** *** 68,71 **** --- 68,74 ---- and str.is* methods can now work correctly with UTF-8 locales. + - unicode.iswide() and unicode.width() is dropped and the East Asian + Width support is moved to unicodedata extension module. + Extension modules ----------------- From perky at users.sourceforge.net Wed Aug 4 09:38:36 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 09:38:40 2004 Subject: [Python-checkins] python/dist/src/Include unicodeobject.h, 2.44, 2.45 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1744/Include Modified Files: unicodeobject.h Log Message: SF #989185: Drop unicode.iswide() and unicode.width() and add unicodedata.east_asian_width(). You can still implement your own simple width() function using it like this: def width(u): w = 0 for c in unicodedata.normalize('NFC', u): cwidth = unicodedata.east_asian_width(c) if cwidth in ('W', 'F'): w += 2 else: w += 1 return w Index: unicodeobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/unicodeobject.h,v retrieving revision 2.44 retrieving revision 2.45 diff -C2 -d -r2.44 -r2.45 *** unicodeobject.h 8 Jul 2004 17:57:30 -0000 2.44 --- unicodeobject.h 4 Aug 2004 07:38:33 -0000 2.45 *************** *** 182,186 **** # define PyUnicode_GetMax PyUnicodeUCS2_GetMax # define PyUnicode_GetSize PyUnicodeUCS2_GetSize - # define PyUnicode_GetWidth PyUnicodeUCS2_GetWidth # define PyUnicode_Join PyUnicodeUCS2_Join # define PyUnicode_Replace PyUnicodeUCS2_Replace --- 182,185 ---- *************** *** 202,206 **** # define _PyUnicode_IsLowercase _PyUnicodeUCS2_IsLowercase # define _PyUnicode_IsNumeric _PyUnicodeUCS2_IsNumeric - # define _PyUnicode_IsWide _PyUnicodeUCS2_IsWide # define _PyUnicode_IsTitlecase _PyUnicodeUCS2_IsTitlecase # define _PyUnicode_IsUppercase _PyUnicodeUCS2_IsUppercase --- 201,204 ---- *************** *** 257,261 **** # define PyUnicode_GetMax PyUnicodeUCS4_GetMax # define PyUnicode_GetSize PyUnicodeUCS4_GetSize - # define PyUnicode_GetWidth PyUnicodeUCS4_GetWidth # define PyUnicode_Join PyUnicodeUCS4_Join # define PyUnicode_Replace PyUnicodeUCS4_Replace --- 255,258 ---- *************** *** 276,280 **** # define _PyUnicode_IsLowercase _PyUnicodeUCS4_IsLowercase # define _PyUnicode_IsNumeric _PyUnicodeUCS4_IsNumeric - # define _PyUnicode_IsWide _PyUnicodeUCS4_IsWide # define _PyUnicode_IsTitlecase _PyUnicodeUCS4_IsTitlecase # define _PyUnicode_IsUppercase _PyUnicodeUCS4_IsUppercase --- 273,276 ---- *************** *** 322,327 **** #define Py_UNICODE_ISALPHA(ch) iswalpha(ch) - #define Py_UNICODE_ISWIDE(ch) _PyUnicode_IsWide(ch) - #else --- 318,321 ---- *************** *** 347,352 **** #define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch) - #define Py_UNICODE_ISWIDE(ch) _PyUnicode_IsWide(ch) - #endif --- 341,344 ---- *************** *** 441,450 **** ); - /* Get the fixed-width representation length of the Unicode object */ - - PyAPI_FUNC(int) PyUnicode_GetWidth( - PyObject *unicode /* Unicode object */ - ); - /* Get the maximum ordinal for a Unicode character. */ PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void); --- 433,436 ---- *************** *** 1177,1184 **** ); - PyAPI_FUNC(int) _PyUnicode_IsWide( - Py_UNICODE ch /* Unicode character */ - ); - #ifdef __cplusplus } --- 1163,1166 ---- From perky at users.sourceforge.net Wed Aug 4 09:38:36 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 09:38:41 2004 Subject: [Python-checkins] python/dist/src/Lib/test string_tests.py, 1.38, 1.39 test_unicode.py, 1.91, 1.92 test_unicodedata.py, 1.10, 1.11 test_userstring.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1744/Lib/test Modified Files: string_tests.py test_unicode.py test_unicodedata.py test_userstring.py Log Message: SF #989185: Drop unicode.iswide() and unicode.width() and add unicodedata.east_asian_width(). You can still implement your own simple width() function using it like this: def width(u): w = 0 for c in unicodedata.normalize('NFC', u): cwidth = unicodedata.east_asian_width(c) if cwidth in ('W', 'F'): w += 2 else: w += 1 return w Index: string_tests.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** string_tests.py 4 Jun 2004 03:18:12 -0000 1.38 --- string_tests.py 4 Aug 2004 07:38:33 -0000 1.39 *************** *** 696,722 **** self.checkraises(TypeError, 'xyz', 'decode', 42) self.checkraises(TypeError, 'xyz', 'encode', 42) - - - class MixinUnicodeUserStringTest: - # Additional tests that only work with - # unicode compatible object, i.e. unicode and UserString - - def test_iswide(self): - self.checkequal(False, u'', 'iswide') - self.checkequal(False, u'\x1f', 'iswide') # Neutral - self.checkequal(False, u'\x20', 'iswide') # Narrow - self.checkequal(True, u'\u2329', 'iswide') # Wide - self.checkequal(False, u'\uff64', 'iswide') # Half - self.checkequal(True, u'\u3000', 'iswide') # Full - self.checkequal(False, u'\u2460', 'iswide') # Ambiguous - self.checkequal(True, u'\ud55c\uae00', 'iswide') - self.checkequal(False, u'\ud55c\u2606\uae00', 'iswide') - - def test_width(self): - self.checkequal(0, u'', 'width') - self.checkequal(4, u'abcd', 'width') - self.checkequal(2, u'\u0187\u01c9', 'width') - self.checkequal(3, u'\u2460\u2329', 'width') - self.checkequal(3, u'\u2329\u2460', 'width') - self.checkequal(4, u'\ud55c\uae00', 'width') - self.checkequal(5, u'\ud55c\u2606\uae00', 'width') --- 696,697 ---- Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** test_unicode.py 23 Jul 2004 16:13:25 -0000 1.91 --- test_unicode.py 4 Aug 2004 07:38:33 -0000 1.92 *************** *** 12,17 **** class UnicodeTest( string_tests.CommonTest, ! string_tests.MixinStrUnicodeUserStringTest, ! string_tests.MixinUnicodeUserStringTest ): type2test = unicode --- 12,16 ---- class UnicodeTest( string_tests.CommonTest, ! string_tests.MixinStrUnicodeUserStringTest ): type2test = unicode Index: test_unicodedata.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicodedata.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_unicodedata.py 17 Apr 2004 19:36:48 -0000 1.10 --- test_unicodedata.py 4 Aug 2004 07:38:33 -0000 1.11 *************** *** 175,178 **** --- 175,189 ---- # which requires an external file. + def test_east_asian_width(self): + eaw = self.db.east_asian_width + self.assertRaises(TypeError, eaw, 'a') + self.assertRaises(TypeError, eaw, u'') + self.assertRaises(TypeError, eaw, u'ra') + self.assertEqual(eaw(u'\x1e'), 'N') + self.assertEqual(eaw(u'\x20'), 'Na') + self.assertEqual(eaw(u'\uC894'), 'W') + self.assertEqual(eaw(u'\uFF66'), 'H') + self.assertEqual(eaw(u'\uFF1F'), 'F') + self.assertEqual(eaw(u'\u2010'), 'A') class UnicodeMiscTest(UnicodeDatabaseTest): Index: test_userstring.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userstring.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_userstring.py 4 Jun 2004 03:18:12 -0000 1.12 --- test_userstring.py 4 Aug 2004 07:38:33 -0000 1.13 *************** *** 12,17 **** string_tests.MixinStrUnicodeUserStringTest, string_tests.MixinStrStringUserStringTest, ! string_tests.MixinStrUserStringTest, ! string_tests.MixinUnicodeUserStringTest ): --- 12,16 ---- string_tests.MixinStrUnicodeUserStringTest, string_tests.MixinStrStringUserStringTest, ! string_tests.MixinStrUserStringTest ): From perky at users.sourceforge.net Wed Aug 4 09:38:37 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 09:38:42 2004 Subject: [Python-checkins] python/dist/src/Modules unicodedata.c, 2.31, 2.32 unicodedata_db.h, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1744/Modules Modified Files: unicodedata.c unicodedata_db.h Log Message: SF #989185: Drop unicode.iswide() and unicode.width() and add unicodedata.east_asian_width(). You can still implement your own simple width() function using it like this: def width(u): w = 0 for c in unicodedata.normalize('NFC', u): cwidth = unicodedata.east_asian_width(c) if cwidth in ('W', 'F'): w += 2 else: w += 1 return w Index: unicodedata.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/unicodedata.c,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -d -r2.31 -r2.32 *** unicodedata.c 15 Jul 2004 04:30:25 -0000 2.31 --- unicodedata.c 4 Aug 2004 07:38:34 -0000 2.32 *************** *** 25,28 **** --- 25,30 ---- _PyUnicode_BidirectionalNames */ const unsigned char mirrored; /* true if mirrored in bidir mode */ + const unsigned char east_asian_width; /* index into + _PyUnicode_EastAsianWidth */ } _PyUnicode_DatabaseRecord; *************** *** 206,209 **** --- 208,229 ---- static PyObject * + unicodedata_east_asian_width(PyObject *self, PyObject *args) + { + PyUnicodeObject *v; + int index; + + if (!PyArg_ParseTuple(args, "O!:east_asian_width", + &PyUnicode_Type, &v)) + return NULL; + if (PyUnicode_GET_SIZE(v) != 1) { + PyErr_SetString(PyExc_TypeError, + "need a single Unicode character as parameter"); + return NULL; + } + index = (int) _getrecord(v)->east_asian_width; + return PyString_FromString(_PyUnicode_EastAsianWidthNames[index]); + } + + static PyObject * unicodedata_decomposition(PyObject *self, PyObject *args) { *************** *** 872,875 **** --- 892,896 ---- {"combining", unicodedata_combining, METH_VARARGS}, {"mirrored", unicodedata_mirrored, METH_VARARGS}, + {"east_asian_width", unicodedata_east_asian_width, METH_VARARGS}, {"decomposition",unicodedata_decomposition, METH_VARARGS}, {"name", unicodedata_name, METH_VARARGS}, Index: unicodedata_db.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/unicodedata_db.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** unicodedata_db.h 2 Jun 2004 16:49:12 -0000 1.10 --- unicodedata_db.h 4 Aug 2004 07:38:34 -0000 1.11 *************** *** 4,130 **** /* a list of unique database records */ const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = { ! {0, 0, 0, 0}, ! {13, 0, 15, 0}, ! {13, 0, 17, 0}, ! {13, 0, 16, 0}, ! {13, 0, 18, 0}, ! {10, 0, 18, 0}, ! {26, 0, 19, 0}, ! {26, 0, 11, 0}, [...2394 lines suppressed...] ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, ! 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 0, 0, }; From perky at users.sourceforge.net Wed Aug 4 09:38:38 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 09:38:43 2004 Subject: [Python-checkins] python/dist/src/Tools/unicode makeunicodedata.py, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1744/Tools/unicode Modified Files: makeunicodedata.py Log Message: SF #989185: Drop unicode.iswide() and unicode.width() and add unicodedata.east_asian_width(). You can still implement your own simple width() function using it like this: def width(u): w = 0 for c in unicodedata.normalize('NFC', u): cwidth = unicodedata.east_asian_width(c) if cwidth in ('W', 'F'): w += 2 else: w += 1 return w Index: makeunicodedata.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/unicode/makeunicodedata.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** makeunicodedata.py 2 Jun 2004 16:49:17 -0000 1.18 --- makeunicodedata.py 4 Aug 2004 07:38:35 -0000 1.19 *************** *** 44,47 **** --- 44,49 ---- "ON" ] + EASTASIANWIDTH_NAMES = [ "F", "H", "W", "Na", "A", "N" ] + # note: should match definitions in Objects/unicodectype.c ALPHA_MASK = 0x01 *************** *** 53,57 **** TITLE_MASK = 0x40 UPPER_MASK = 0x80 - WIDE_MASK = 0x100 def maketables(trace=0): --- 55,58 ---- *************** *** 73,77 **** def makeunicodedata(unicode, trace): ! dummy = (0, 0, 0, 0) table = [dummy] cache = {0: dummy} --- 74,78 ---- def makeunicodedata(unicode, trace): ! dummy = (0, 0, 0, 0, 0) table = [dummy] cache = {0: dummy} *************** *** 92,97 **** bidirectional = BIDIRECTIONAL_NAMES.index(record[4]) mirrored = record[9] == "Y" item = ( ! category, combining, bidirectional, mirrored ) # add entry to index and item tables --- 93,99 ---- bidirectional = BIDIRECTIONAL_NAMES.index(record[4]) mirrored = record[9] == "Y" + eastasianwidth = EASTASIANWIDTH_NAMES.index(record[15]) item = ( ! category, combining, bidirectional, mirrored, eastasianwidth ) # add entry to index and item tables *************** *** 205,209 **** "const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = {" for item in table: ! print >>fp, " {%d, %d, %d, %d}," % item print >>fp, "};" print >>fp --- 207,211 ---- "const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = {" for item in table: ! print >>fp, " {%d, %d, %d, %d, %d}," % item print >>fp, "};" print >>fp *************** *** 240,243 **** --- 242,251 ---- print >>fp, "};" + print >>fp, "const char *_PyUnicode_EastAsianWidthNames[] = {" + for name in EASTASIANWIDTH_NAMES: + print >>fp, " \"%s\"," % name + print >>fp, " NULL" + print >>fp, "};" + print >>fp, "static const char *decomp_prefix[] = {" for name in decomp_prefix: *************** *** 335,340 **** flags |= DIGIT_MASK digit = int(record[7]) - if record[15] in ('W', 'F'): # Wide or Full width - flags |= WIDE_MASK item = ( upper, lower, title, decimal, digit, flags --- 343,346 ---- From perky at users.sourceforge.net Wed Aug 4 09:38:38 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 09:38:44 2004 Subject: [Python-checkins] python/dist/src/Objects unicodectype.c, 2.15, 2.16 unicodeobject.c, 2.218, 2.219 unicodetype_db.h, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1744/Objects Modified Files: unicodectype.c unicodeobject.c unicodetype_db.h Log Message: SF #989185: Drop unicode.iswide() and unicode.width() and add unicodedata.east_asian_width(). You can still implement your own simple width() function using it like this: def width(u): w = 0 for c in unicodedata.normalize('NFC', u): cwidth = unicodedata.east_asian_width(c) if cwidth in ('W', 'F'): w += 2 else: w += 1 return w Index: unicodectype.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodectype.c,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -d -r2.15 -r2.16 *** unicodectype.c 2 Jun 2004 16:49:16 -0000 2.15 --- unicodectype.c 4 Aug 2004 07:38:34 -0000 2.16 *************** *** 20,24 **** #define TITLE_MASK 0x40 #define UPPER_MASK 0x80 - #define WIDE_MASK 0x100 typedef struct { --- 20,23 ---- *************** *** 324,336 **** } - /* Returns 1 for Unicode characters having Full or Wide width, 0 otherwise */ - - int _PyUnicode_IsWide(Py_UNICODE ch) - { - const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); - - return (ctype->flags & WIDE_MASK) != 0; - } - #ifndef WANT_WCTYPE_FUNCTIONS --- 323,326 ---- Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.218 retrieving revision 2.219 diff -C2 -d -r2.218 -r2.219 *** unicodeobject.c 23 Jul 2004 16:13:25 -0000 2.218 --- unicodeobject.c 4 Aug 2004 07:38:35 -0000 2.219 *************** *** 703,727 **** } - int PyUnicode_GetWidth(PyObject *unicode) - { - const Py_UNICODE *p, *e; - int width; - - if (!PyUnicode_Check(unicode)) { - PyErr_BadArgument(); - return -1; - } - - p = PyUnicode_AS_UNICODE(unicode); - e = p + PyUnicode_GET_SIZE(unicode); - for (width = 0; p < e; p++) - if (Py_UNICODE_ISWIDE(*p)) - width += 2; - else - width++; - - return width; - } - const char *PyUnicode_GetDefaultEncoding(void) { --- 703,706 ---- *************** *** 5437,5469 **** } - PyDoc_STRVAR(iswide__doc__, - "S.iswide() -> bool\n\ - \n\ - Return True if all characters in S are wide width\n\ - and there is at least one character in S, False otherwise."); - - static PyObject* - unicode_iswide(PyUnicodeObject *self) - { - register const Py_UNICODE *p = PyUnicode_AS_UNICODE(self); - register const Py_UNICODE *e; - - /* Shortcut for single character strings */ - if (PyUnicode_GET_SIZE(self) == 1 && - Py_UNICODE_ISWIDE(*p)) - Py_RETURN_TRUE; - - /* Special case for empty strings */ - if (PyString_GET_SIZE(self) == 0) - Py_RETURN_FALSE; - - e = p + PyUnicode_GET_SIZE(self); - for (; p < e; p++) { - if (!Py_UNICODE_ISWIDE(*p)) - Py_RETURN_FALSE; - } - Py_RETURN_TRUE; - } - PyDoc_STRVAR(join__doc__, "S.join(sequence) -> unicode\n\ --- 5416,5419 ---- *************** *** 6077,6095 **** } - PyDoc_STRVAR(width__doc__, - "S.width() -> unicode\n\ - \n\ - Return a fixed-width representation length of S."); - - static PyObject* - unicode_width(PyObject *self) - { - int width = PyUnicode_GetWidth(self); - if (width == -1) - return NULL; - else - return PyInt_FromLong((long)width); - } - PyDoc_STRVAR(zfill__doc__, "S.zfill(width) -> unicode\n\ --- 6027,6030 ---- *************** *** 6256,6261 **** {"isalpha", (PyCFunction) unicode_isalpha, METH_NOARGS, isalpha__doc__}, {"isalnum", (PyCFunction) unicode_isalnum, METH_NOARGS, isalnum__doc__}, - {"iswide", (PyCFunction) unicode_iswide, METH_NOARGS, iswide__doc__}, - {"width", (PyCFunction) unicode_width, METH_NOARGS, width__doc__}, {"zfill", (PyCFunction) unicode_zfill, METH_VARARGS, zfill__doc__}, #if 0 --- 6191,6194 ---- Index: unicodetype_db.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodetype_db.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** unicodetype_db.h 2 Jun 2004 16:49:16 -0000 1.8 --- unicodetype_db.h 4 Aug 2004 07:38:35 -0000 1.9 *************** *** 88,92 **** {0, 48, 0, 0, 0, 129}, {65488, 0, 65488, 0, 0, 9}, - {0, 0, 0, 0, 0, 257}, {65477, 0, 65477, 0, 0, 9}, {8, 0, 8, 0, 0, 9}, --- 88,91 ---- *************** *** 115,119 **** {0, 16, 0, 0, 0, 0}, {65520, 0, 65520, 0, 0, 0}, [...978 lines suppressed...] 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, *************** *** 1147,1151 **** 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, 0, 0, }; --- 1086,1090 ---- 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, 0, 0, }; From perky at users.sourceforge.net Wed Aug 4 09:39:05 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 09:39:08 2004 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.53,1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1744/Doc/api Modified Files: concrete.tex Log Message: SF #989185: Drop unicode.iswide() and unicode.width() and add unicodedata.east_asian_width(). You can still implement your own simple width() function using it like this: def width(u): w = 0 for c in unicodedata.normalize('NFC', u): cwidth = unicodedata.east_asian_width(c) if cwidth in ('W', 'F'): w += 2 else: w += 1 return w Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** concrete.tex 3 Aug 2004 16:02:35 -0000 1.53 --- concrete.tex 4 Aug 2004 07:38:33 -0000 1.54 *************** *** 895,903 **** \end{cfuncdesc} - \begin{cfuncdesc}{int}{Py_UNICODE_ISWIDE}{Py_UNICODE ch} - Returns 1/0 depending on whether \var{ch} is a wide or full-width - character. - \end{cfuncdesc} - These APIs can be used for fast direct character conversions: --- 895,898 ---- *************** *** 958,965 **** \end{cfuncdesc} - \begin{cfuncdesc}{int}{PyUnicode_GetWidth}{PyObject *unicode} - Return the fixed-width representation length of the Unicode object. - \end{cfuncdesc} - \begin{cfuncdesc}{PyObject*}{PyUnicode_FromEncodedObject}{PyObject *obj, const char *encoding, --- 953,956 ---- From perky at users.sourceforge.net Wed Aug 4 10:01:09 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 10:01:11 2004 Subject: [Python-checkins] python/dist/src/Lib UserString.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5767/Lib Modified Files: UserString.py Log Message: Remove .width() and .iswide() from UserString as well. Index: UserString.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/UserString.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** UserString.py 4 Jun 2004 04:23:29 -0000 1.22 --- UserString.py 4 Aug 2004 08:01:06 -0000 1.23 *************** *** 127,134 **** def zfill(self, width): return self.__class__(self.data.zfill(width)) - # the following methods are defined for unicode objects only: - def iswide(self): return self.data.iswide() # unicode only - def width(self): return self.data.width() # unicode only - class MutableString(UserString): """mutable string objects --- 127,130 ---- From vsajip at users.sourceforge.net Wed Aug 4 10:29:16 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Wed Aug 4 10:29:20 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_logging.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10176 Modified Files: test_logging.py Log Message: Close handlers and tidy up loggers by removing closed handlers - to avoid problems when run twice (SF #1002537) Index: test_logging.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_logging.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** test_logging.py 2 Jun 2004 10:51:05 -0000 1.14 --- test_logging.py 4 Aug 2004 08:29:14 -0000 1.15 *************** *** 412,416 **** #receiver (logrecv). #The handler will only be added to the rootLogger for some of the tests ! hdlr = logging.handlers.SocketHandler('localhost', logging.handlers.DEFAULT_TCP_LOGGING_PORT) --- 412,416 ---- #receiver (logrecv). #The handler will only be added to the rootLogger for some of the tests ! shdlr = logging.handlers.SocketHandler('localhost', logging.handlers.DEFAULT_TCP_LOGGING_PORT) *************** *** 438,445 **** banner("log_test0", "begin") ! rootLogger.addHandler(hdlr) test0() ! hdlr.close() ! rootLogger.removeHandler(hdlr) banner("log_test0", "end") --- 438,445 ---- banner("log_test0", "begin") ! rootLogger.addHandler(shdlr) test0() ! shdlr.close() ! rootLogger.removeHandler(shdlr) banner("log_test0", "end") *************** *** 464,471 **** banner("logrecv output", "begin") sys.stdout.write(sockOut.getvalue()) - sockhdlr.close() sockOut.close() banner("logrecv output", "end") sys.stdout.flush() def test_main(): --- 464,477 ---- banner("logrecv output", "begin") sys.stdout.write(sockOut.getvalue()) sockOut.close() + sockLogger.removeHandler(sockhdlr) + sockhdlr.close() banner("logrecv output", "end") sys.stdout.flush() + try: + hdlr.close() + except: + pass + rootLogger.removeHandler(hdlr) def test_main(): From vsajip at users.sourceforge.net Wed Aug 4 10:36:46 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Wed Aug 4 10:36:49 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liblogging.tex,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11119 Modified Files: liblogging.tex Log Message: Updated Logger.log() documentation to clarify that lvl parameter should be an integer. Index: liblogging.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblogging.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** liblogging.tex 21 Jul 2004 14:40:11 -0000 1.22 --- liblogging.tex 4 Aug 2004 08:36:44 -0000 1.23 *************** *** 315,319 **** \begin{methoddesc}{log}{lvl, msg\optional{, *args\optional{, **kwargs}}} ! Logs a message with level \var{lvl} on this logger. The other arguments are interpreted as for \method{debug()}. \end{methoddesc} --- 315,319 ---- \begin{methoddesc}{log}{lvl, msg\optional{, *args\optional{, **kwargs}}} ! Logs a message with integer level \var{lvl} on this logger. The other arguments are interpreted as for \method{debug()}. \end{methoddesc} From vsajip at users.sourceforge.net Wed Aug 4 10:38:10 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Wed Aug 4 10:38:14 2004 Subject: [Python-checkins] python/dist/src/Lib/logging __init__.py, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11294 Modified Files: __init__.py Log Message: Updated Logger.log() docstring to clarify that lvl parameter should be an integer. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** __init__.py 29 Jul 2004 09:19:30 -0000 1.18 --- __init__.py 4 Aug 2004 08:38:08 -0000 1.19 *************** *** 968,972 **** def log(self, level, msg, *args, **kwargs): """ ! Log 'msg % args' with the severity 'level'. To pass exception information, use the keyword argument exc_info with --- 968,972 ---- def log(self, level, msg, *args, **kwargs): """ ! Log 'msg % args' with the integer severity 'level'. To pass exception information, use the keyword argument exc_info with From mwh at users.sourceforge.net Wed Aug 4 12:26:11 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Aug 4 12:26:14 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.312,2.313 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25254 Modified Files: compile.c Log Message: Revert 2.312; turns out interning the file name did do some good (reducing .pyc size) after all. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.312 retrieving revision 2.313 diff -C2 -d -r2.312 -r2.313 *** compile.c 3 Aug 2004 10:24:03 -0000 2.312 --- compile.c 4 Aug 2004 10:26:08 -0000 2.313 *************** *** 4732,4736 **** freevars = dict_keys_inorder(sc.c_freevars, PyTuple_GET_SIZE(cellvars)); ! filename = PyString_FromString(sc.c_filename); name = PyString_InternFromString(sc.c_name); if (!PyErr_Occurred()) --- 4732,4736 ---- freevars = dict_keys_inorder(sc.c_freevars, PyTuple_GET_SIZE(cellvars)); ! filename = PyString_InternFromString(sc.c_filename); name = PyString_InternFromString(sc.c_name); if (!PyErr_Occurred()) From loewis at users.sourceforge.net Wed Aug 4 15:42:47 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 4 15:42:49 2004 Subject: [Python-checkins] python/dist/src/PCbuild BUILDno.txt, 1.59, 1.60 pythoncore.vcproj, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24007 Modified Files: BUILDno.txt pythoncore.vcproj Log Message: Bump buildno for 2.4a2 Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** BUILDno.txt 8 Jul 2004 07:11:33 -0000 1.59 --- BUILDno.txt 4 Aug 2004 13:42:43 -0000 1.60 *************** *** 34,37 **** --- 34,39 ---- Windows Python BUILD numbers ---------------------------- + 55 2.4.0a2 + 4-Aug-2004 54 2.4.0a1 8-Jul-2004 Index: pythoncore.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.vcproj,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** pythoncore.vcproj 28 Jul 2004 09:45:20 -0000 1.17 --- pythoncore.vcproj 4 Aug 2004 13:42:43 -0000 1.18 *************** *** 1383,1387 **** Optimization="2" AdditionalIncludeDirectories="" ! PreprocessorDefinitions="BUILD=54"/> --- 1399,1403 ---- Optimization="2" AdditionalIncludeDirectories="" ! PreprocessorDefinitions="BUILD=55"/> From edloper at users.sourceforge.net Wed Aug 4 16:05:17 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Wed Aug 4 16:05:20 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.12, 1.36.2.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27639 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: - In DocTestFinder: - When exploring a class's contents, check that they're not imported (this should fix the Zope3 bug with __provides__). - Added parameter ignore_imports (default=True). Use this to replace the '(None)' hack. - Describe `module` in the DocTestFinder.find docstring - _from_module, assume that properties are always from their class's module. - Added an implementation of Tester.merge() Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.12 retrieving revision 1.36.2.13 diff -C2 -d -r1.36.2.12 -r1.36.2.13 *** doctest.py 4 Aug 2004 01:06:40 -0000 1.36.2.12 --- doctest.py 4 Aug 2004 14:05:14 -0000 1.36.2.13 *************** *** 299,304 **** 'DocTestTestCase', 'DocTestSuite', ! # 'testsource', ! # 'debug', # 'master', ] --- 299,304 ---- 'DocTestTestCase', 'DocTestSuite', ! 'testsource', ! 'debug', # 'master', ] *************** *** 658,662 **** def find(self, obj, name=None, module=None, globs=None, ! extraglobs=None): """ Return a list of the DocTests that are defined by the given --- 658,662 ---- def find(self, obj, name=None, module=None, globs=None, ! extraglobs=None, ignore_imports=True): """ Return a list of the DocTests that are defined by the given *************** *** 664,667 **** --- 664,680 ---- docstrings. + The optional parameter `module` is the module that contains + the given object. If the module is not specified, then the + test finder will attempt to automatically determine the + correct module. The object's module is used: + + - As a default namespace, if `globs` is not specified. + - To prevent the DocTestFinder from extracting DocTests + from objects that are imported from other modules + (as long as `ignore_imports` is true). + - To find the name of the file containing the object. + - To help find the line number of the object within its + file. + The globals for each DocTest is formed by combining `globs` and `extraglobs` (bindings in `extraglobs` override bindings *************** *** 671,674 **** --- 684,692 ---- otherwise. If `extraglobs` is not specified, then it defaults to {}. + + If the optional flag `ignore_imports` is true, then the + doctest finder will ignore any contained objects whose module + does not match `module`. Otherwise, it will extract tests + from all contained objects, including imported objects. """ # If name was not specified, then extract it from the object. *************** *** 682,700 **** # Find the module that contains the given object (if obj is # a module, then module=obj.). Note: this may fail, in which ! # case, module will be None. if module is None: module = inspect.getmodule(obj) - # This is a hack to help Tester.rundict. Setting module=None - # in Tester.rundict should make the tester ignore which module - # a function comes from; but DocTestFinder.find will attempt - # to derive the correct module if one isn't specified. So - # Tester.rundict can explicitly request that no module be - # found by using module='(None)'. Note that this means that - # DocTestFinder will be unable to find the test examples' - # filenames and line numbers, so they will be set to None. - if module == '(None)': - module = None - # Read the module's source code. This is used by # DocTestFinder._find_lineno to find the line number for a --- 700,707 ---- # Find the module that contains the given object (if obj is # a module, then module=obj.). Note: this may fail, in which ! # case module will be None. if module is None: module = inspect.getmodule(obj) # Read the module's source code. This is used by # DocTestFinder._find_lineno to find the line number for a *************** *** 721,725 **** # Recursively expore `obj`, extracting DocTests. tests = [] ! self._find(tests, obj, name, module, source_lines, globs, {}) return tests --- 728,733 ---- # Recursively expore `obj`, extracting DocTests. tests = [] ! self._find(tests, obj, name, module, source_lines, ! globs, ignore_imports, {}) return tests *************** *** 746,753 **** elif inspect.getmodule(object) is not None: return module is inspect.getmodule(object) else: raise ValueError("object must be a class or function") ! def _find(self, tests, obj, name, module, source_lines, globs, seen): """ Find tests for the given object and any contained objects, and --- 754,766 ---- elif inspect.getmodule(object) is not None: return module is inspect.getmodule(object) + elif hasattr(object, '__module__'): + return module.__name__ == object.__module__ + elif isinstance(object, property): + return True # [XX] no way not be sure. else: raise ValueError("object must be a class or function") ! def _find(self, tests, obj, name, module, source_lines, ! globs, ignore_imports, seen): """ Find tests for the given object and any contained objects, and *************** *** 775,782 **** valname = '%s.%s' % (name, valname) # Recurse to functions & classes. ! if ((inspect.isfunction(val) or inspect.isclass(val)) ! and self._from_module(module, val)): ! self._find(tests, val, valname, module, ! source_lines, globs, seen) # Look for tests in a module's __test__ dictionary. --- 788,795 ---- valname = '%s.%s' % (name, valname) # Recurse to functions & classes. ! if ((inspect.isfunction(val) or inspect.isclass(val)) and ! (self._from_module(module, val) or not ignore_imports)): ! self._find(tests, val, valname, module, source_lines, ! globs, ignore_imports, seen) # Look for tests in a module's __test__ dictionary. *************** *** 795,800 **** (type(val),)) valname = '%s.%s' % (name, valname) ! self._find(tests, val, valname, module, ! source_lines, globs, seen) # Look for tests in a class's contained objects. --- 808,813 ---- (type(val),)) valname = '%s.%s' % (name, valname) ! self._find(tests, val, valname, module, source_lines, ! globs, ignore_imports, seen) # Look for tests in a class's contained objects. *************** *** 811,819 **** # Recurse to methods, properties, and nested classes. ! if (inspect.isfunction(val) or inspect.isclass(val) or ! isinstance(val, property)): valname = '%s.%s' % (name, valname) ! self._find(tests, val, valname, module, ! source_lines, globs, seen) def _get_test(self, obj, name, module, globs, source_lines): --- 824,833 ---- # Recurse to methods, properties, and nested classes. ! if ((inspect.isfunction(val) or inspect.isclass(val) or ! isinstance(val, property)) and ! (self._from_module(module, val) or not ignore_imports)): valname = '%s.%s' % (name, valname) ! self._find(tests, val, valname, module, source_lines, ! globs, ignore_imports, seen) def _get_test(self, obj, name, module, globs, source_lines): *************** *** 1171,1184 **** re.MULTILINE | re.DOTALL) ! _OPTION_DIRECTIVE_RE = re.compile('\s*doctest:\s*(?P[^#]*)') def __handle_directive(self, example): """ Check if the given example is actually a directive to doctest ! (to turn an optionflag on or off; and if it is, then handle the directive. Return true iff the example is actually a directive (and so should not be executed). """ m = self._OPTION_DIRECTIVE_RE.match(example.source) --- 1185,1199 ---- re.MULTILINE | re.DOTALL) ! _OPTION_DIRECTIVE_RE = re.compile('\s*doctest:\s*(?P[^#\n]*)') def __handle_directive(self, example): """ Check if the given example is actually a directive to doctest ! (to turn an optionflag on or off); and if it is, then handle the directive. Return true iff the example is actually a directive (and so should not be executed). + """ m = self._OPTION_DIRECTIVE_RE.match(example.source) *************** *** 1209,1213 **** failures = tries = 0 ! # Save the option flags (since doctest directives can be used # to modify them). original_optionflags = self.optionflags --- 1224,1228 ---- failures = tries = 0 ! # Save the option flags (since option directives can be used # to modify them). original_optionflags = self.optionflags *************** *** 1579,1586 **** return (f,t) ! def rundoc(self, object, name=None, module=None): f = t = 0 tests = self.testfinder.find(object, name, module=module, ! globs=self.globs) for test in tests: (f2, t2) = self.testrunner.run(test) --- 1594,1602 ---- return (f,t) ! def rundoc(self, object, name=None, module=None, ignore_imports=True): f = t = 0 tests = self.testfinder.find(object, name, module=module, ! globs=self.globs, ! ignore_imports=ignore_imports) for test in tests: (f2, t2) = self.testrunner.run(test) *************** *** 1592,1597 **** m = new.module(name) m.__dict__.update(d) ! if module is None: module = '(None)' ! return self.rundoc(m, name, module) def run__test__(self, d, name): --- 1608,1613 ---- m = new.module(name) m.__dict__.update(d) ! ignore_imports = (module is not None) ! return self.rundoc(m, name, module, ignore_imports) def run__test__(self, d, name): *************** *** 1605,1609 **** def merge(self, other): ! pass # [XX] not implemented yet. ###################################################################### --- 1621,1633 ---- def merge(self, other): ! d = self.testrunner._name2ft ! for name, (f, t) in other.testrunner._name2ft.items(): ! if name in d: ! print "*** Tester.merge: '" + name + "' in both" \ ! " testers; summing outcomes." ! f2, t2 = d[name] ! f = f + f2 ! t = t + t2 ! d[name] = f, t ###################################################################### From edloper at users.sourceforge.net Wed Aug 4 16:06:29 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Wed Aug 4 16:06:32 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.5.18.8, 1.5.18.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27828/test Modified Files: Tag: tim-doctest-branch test_doctest.py Log Message: - Use ignore_imports=False to prevent doctest from excluding an object whose module doesn't match. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.5.18.8 retrieving revision 1.5.18.9 diff -C2 -d -r1.5.18.8 -r1.5.18.9 *** test_doctest.py 4 Aug 2004 01:07:22 -0000 1.5.18.8 --- test_doctest.py 4 Aug 2004 14:06:27 -0000 1.5.18.9 *************** *** 220,224 **** ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: ' ... 2)' ! If there's no blnak space after a PS1 prompt ('>>>'), then `DocTest` will raise a ValueError: --- 220,224 ---- ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: ' ... 2)' ! If there's no blank space after a PS1 prompt ('>>>'), then `DocTest` will raise a ValueError: *************** *** 373,377 **** >>> finder = doctest.DocTestFinder() ! >>> tests = finder.find(TwoNames) >>> tests.sort() >>> print len(tests) --- 373,377 ---- >>> finder = doctest.DocTestFinder() ! >>> tests = finder.find(TwoNames, ignore_imports=False) >>> tests.sort() >>> print len(tests) *************** *** 910,913 **** --- 910,918 ---- def test_testsource(): r""" + Unit tests for `testsource()`. + + The testsource() function takes a module and a name, finds the (first) + test with that name in that module, and converts it to an + >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' From mwh at users.sourceforge.net Wed Aug 4 16:22:59 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Aug 4 16:23:02 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_threadsignals.py, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30871 Modified Files: test_threadsignals.py Log Message: To ever run this test "you must import TestSkipped" from the right place! (can that please be it for silly mistakes in this file? :-) I know I started it, but...). Also, rearrangements to run repeatedly. Index: test_threadsignals.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_threadsignals.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_threadsignals.py 4 Aug 2004 02:36:18 -0000 1.5 --- test_threadsignals.py 4 Aug 2004 14:22:56 -0000 1.6 *************** *** 6,18 **** import os import sys ! from test import test_support, TestSkipped if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos': raise TestSkipped, "Can't test signal on %s" % sys.platform - signal_blackboard = { signal.SIGUSR1 : {'tripped': 0, 'tripped_by': 0 }, - signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 }, - signal.SIGALRM : {'tripped': 0, 'tripped_by': 0 } } - process_pid = os.getpid() signalled_all=thread.allocate_lock() --- 6,14 ---- import os import sys ! from test.test_support import run_unittest, TestSkipped if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos': raise TestSkipped, "Can't test signal on %s" % sys.platform process_pid = os.getpid() signalled_all=thread.allocate_lock() *************** *** 66,69 **** --- 62,66 ---- self.assertEqual( signal_blackboard[signal.SIGUSR2]['tripped_by'], thread.get_ident()) + signalled_all.release() def spawnSignallingThread(self): *************** *** 72,78 **** def test_main(): oldsigs = registerSignals((handle_signals, handle_signals, handle_signals)) try: ! test_support.run_unittest(ThreadSignals) finally: registerSignals(oldsigs) --- 69,81 ---- def test_main(): + global signal_blackboard + + signal_blackboard = { signal.SIGUSR1 : {'tripped': 0, 'tripped_by': 0 }, + signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 }, + signal.SIGALRM : {'tripped': 0, 'tripped_by': 0 } } + oldsigs = registerSignals((handle_signals, handle_signals, handle_signals)) try: ! run_unittest(ThreadSignals) finally: registerSignals(oldsigs) From mwh at users.sourceforge.net Wed Aug 4 16:33:30 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Aug 4 16:33:33 2004 Subject: [Python-checkins] python/dist/src/Modules _cursesmodule.c, 2.72, 2.73 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32760 Modified Files: _cursesmodule.c Log Message: Fix a leak of a reference on None. Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.72 retrieving revision 2.73 diff -C2 -d -r2.72 -r2.73 *** _cursesmodule.c 13 Aug 2003 23:08:11 -0000 2.72 --- _cursesmodule.c 4 Aug 2004 14:33:28 -0000 2.73 *************** *** 2285,2291 **** if (!PyArg_ParseTuple(args,"i;fd",&fd)) return NULL; ! PyCursesCheckERR(typeahead( fd ), "typeahead"); ! Py_INCREF(Py_None); ! return Py_None; } --- 2285,2289 ---- if (!PyArg_ParseTuple(args,"i;fd",&fd)) return NULL; ! return PyCursesCheckERR(typeahead( fd ), "typeahead"); } From mwh at users.sourceforge.net Wed Aug 4 16:59:03 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Aug 4 16:59:07 2004 Subject: [Python-checkins] python/dist/src/Modules _ssl.c,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5362 Modified Files: _ssl.c Log Message: Add a missing decref -- PyErr_SetObject increfs the 'object'! Index: _ssl.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_ssl.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** _ssl.c 10 Jul 2004 21:36:55 -0000 1.18 --- _ssl.c 4 Aug 2004 14:59:00 -0000 1.19 *************** *** 170,173 **** --- 170,174 ---- PyTuple_SET_ITEM(v, 1, s); PyErr_SetObject(PySSLErrorObject, v); + Py_DECREF(v); return NULL; } From perky at users.sourceforge.net Wed Aug 4 19:36:43 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 19:36:45 2004 Subject: [Python-checkins] python/dist/src/Parser tokenizer.c,2.75,2.76 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3131/Parser Modified Files: tokenizer.c Log Message: SF #941229: Decode source code with sys.stdin.encoding in interactive modes like non-interactive modes. This allows for non-latin-1 users to write unicode strings directly and sets Japanese users free from weird manual escaping in shift_jis environments. (Reviewed by Martin v. Loewis) Index: tokenizer.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/tokenizer.c,v retrieving revision 2.75 retrieving revision 2.76 diff -C2 -d -r2.75 -r2.76 *** tokenizer.c 2 Aug 2004 06:09:55 -0000 2.75 --- tokenizer.c 4 Aug 2004 17:36:41 -0000 2.76 *************** *** 652,655 **** --- 652,712 ---- } + #if !defined(PGEN) && defined(Py_USING_UNICODE) + static int + tok_stdin_decode(struct tok_state *tok, char **inp) + { + PyObject *enc, *sysstdin, *decoded, *utf8; + const char *encoding; + char *converted; + + if (PySys_GetFile((char *)"stdin", NULL) != stdin) + return 0; + sysstdin = PySys_GetObject("stdin"); + if (sysstdin == NULL || !PyFile_Check(sysstdin)) + return 0; + + enc = ((PyFileObject *)sysstdin)->f_encoding; + if (enc == NULL || !PyString_Check(enc)) + return 0; + Py_INCREF(enc); + + encoding = PyString_AsString(enc); + decoded = PyUnicode_Decode(*inp, strlen(*inp), encoding, NULL); + if (decoded == NULL) + goto error_clear; + + utf8 = PyUnicode_AsEncodedString(decoded, "utf-8", NULL); + Py_DECREF(decoded); + if (utf8 == NULL) + goto error_clear; + + converted = new_string(PyString_AsString(utf8), PyString_Size(utf8)); + Py_DECREF(utf8); + if (converted == NULL) + goto error_nomem; + + PyMem_FREE(*inp); + *inp = converted; + if (tok->encoding != NULL) + PyMem_DEL(tok->encoding); + tok->encoding = new_string(encoding, strlen(encoding)); + if (tok->encoding == NULL) + goto error_nomem; + + Py_DECREF(enc); + return 0; + + error_nomem: + Py_DECREF(enc); + tok->done = E_NOMEM; + return -1; + + error_clear: + /* Fallback to iso-8859-1: for backward compatibility */ + Py_DECREF(enc); + PyErr_Clear(); + return 0; + } + #endif /* Get next char, updating state; error code goes into tok->done */ *************** *** 691,694 **** --- 748,755 ---- tok->done = E_EOF; } + #if !defined(PGEN) && defined(Py_USING_UNICODE) + else if (tok_stdin_decode(tok, &new) != 0) + PyMem_FREE(new); + #endif else if (tok->start != NULL) { size_t start = tok->start - tok->buf; From perky at users.sourceforge.net Wed Aug 4 19:36:43 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 19:36:47 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1068,1.1069 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3131/Misc Modified Files: NEWS Log Message: SF #941229: Decode source code with sys.stdin.encoding in interactive modes like non-interactive modes. This allows for non-latin-1 users to write unicode strings directly and sets Japanese users free from weird manual escaping in shift_jis environments. (Reviewed by Martin v. Loewis) Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1068 retrieving revision 1.1069 diff -C2 -d -r1.1068 -r1.1069 *** NEWS 4 Aug 2004 07:38:34 -0000 1.1068 --- NEWS 4 Aug 2004 17:36:39 -0000 1.1069 *************** *** 71,74 **** --- 71,78 ---- Width support is moved to unicodedata extension module. + - Patch #941229: The source code encoding in interactive mode + now refers sys.stdin.encoding not just ISO-8859-1 anymore. This + allows for non-latin-1 users to write unicode strings directly. + Extension modules ----------------- From perky at users.sourceforge.net Wed Aug 4 19:40:41 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 4 19:40:44 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1069,1.1070 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4256/Misc Modified Files: NEWS Log Message: Add a proper pointer to SF bug item. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1069 retrieving revision 1.1070 diff -C2 -d -r1.1069 -r1.1070 *** NEWS 4 Aug 2004 17:36:39 -0000 1.1069 --- NEWS 4 Aug 2004 17:40:38 -0000 1.1070 *************** *** 68,73 **** and str.is* methods can now work correctly with UTF-8 locales. ! - unicode.iswide() and unicode.width() is dropped and the East Asian ! Width support is moved to unicodedata extension module. - Patch #941229: The source code encoding in interactive mode --- 68,74 ---- and str.is* methods can now work correctly with UTF-8 locales. ! - Bug #989185: unicode.iswide() and unicode.width() is dropped and ! the East Asian Width support is moved to unicodedata extension ! module. - Patch #941229: The source code encoding in interactive mode From tim_one at users.sourceforge.net Wed Aug 4 20:46:44 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 4 20:46:48 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1070,1.1071 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16195/Misc Modified Files: NEWS Log Message: Edward Loper's cool and massive refactoring of doctest.py, merged from the tim-doctest-merge-24a2 tag on the the tim-doctest-branch branch. We did development on the branch in case it wouldn't land in time for 2.4a2, but the branch looked good: Edward's tests passed there, ditto Python's tests, and ditto the Zope3 tests. Together, those hit doctest heavily. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1070 retrieving revision 1.1071 diff -C2 -d -r1.1070 -r1.1071 *** NEWS 4 Aug 2004 17:40:38 -0000 1.1070 --- NEWS 4 Aug 2004 18:46:34 -0000 1.1071 *************** *** 84,87 **** --- 84,98 ---- ------- + - Thanks to Edward Loper, doctest has been massively refactored, and + many new features were added. Full docs will appear later. For now + the doctest module comments and new test cases give good coverage. + The refactoring provides many hook points for customizing behavior + (such as how to report errors, and how to compare expected to actual + output). New features include a marker for expected + output containing blank lines, options to produce unified or context + diffs when actual output doesn't match expectations, an option to + normalize whitespace before comparing, and an option to use an + ellipsis to signify "don't care" regions of output. + - Tkinter now supports the wish -sync and -use options. From tim_one at users.sourceforge.net Wed Aug 4 20:47:06 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 4 20:47:11 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16195/Lib/test Modified Files: test_doctest.py Log Message: Edward Loper's cool and massive refactoring of doctest.py, merged from the tim-doctest-merge-24a2 tag on the the tim-doctest-branch branch. We did development on the branch in case it wouldn't land in time for 2.4a2, but the branch looked good: Edward's tests passed there, ditto Python's tests, and ditto the Zope3 tests. Together, those hit doctest heavily. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_doctest.py 23 Jul 2002 19:03:50 -0000 1.5 --- test_doctest.py 4 Aug 2004 18:46:33 -0000 1.6 *************** *** 1,3 **** ! import doctest from test import test_support ! test_support.run_doctest(doctest) --- 1,1003 ---- ! """ ! Test script for doctest. ! """ ! from test import test_support ! import doctest [...977 lines suppressed...] ! test_support.run_doctest(doctest, verbosity=True) ! # Check the doctest cases defined here: ! from test import test_doctest ! test_support.run_doctest(test_doctest, verbosity=True) ! ! import trace, sys, re, StringIO ! def test_coverage(coverdir): ! tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], ! trace=0, count=1) ! tracer.run('reload(doctest); test_main()') ! r = tracer.results() ! print 'Writing coverage results...' ! r.write_results(show_missing=True, summary=True, ! coverdir=coverdir) ! ! if __name__ == '__main__': ! if '-c' in sys.argv: ! test_coverage('/tmp/doctest.cover') ! else: ! test_main() From tim_one at users.sourceforge.net Wed Aug 4 20:47:06 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 4 20:47:12 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16195/Lib Modified Files: doctest.py Log Message: Edward Loper's cool and massive refactoring of doctest.py, merged from the tim-doctest-merge-24a2 tag on the the tim-doctest-branch branch. We did development on the branch in case it wouldn't land in time for 2.4a2, but the branch looked good: Edward's tests passed there, ditto Python's tests, and ditto the Zope3 tests. Together, those hit doctest heavily. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** doctest.py 14 Jul 2004 19:06:50 -0000 1.36 --- doctest.py 4 Aug 2004 18:46:33 -0000 1.37 *************** *** 1,8 **** # Module doctest. ! # Released to the public domain 16-Jan-2001, ! # by Tim Peters (tim.one@home.com). # Provided as-is; use at your own risk; no warranty; no promises; enjoy! r"""Module doctest -- a framework for running examples in docstrings. --- 1,11 ---- # Module doctest. [...2822 lines suppressed...] ! >>> t.rundict(m1.__dict__, "rundict_test_pvt") # None are skipped. ! (0, 8) ! ! The exclusion of objects from outside the designated module is ! meant to be invoked automagically by testmod. ! ! >>> testmod(m1, isprivate=is_private, verbose=False) ! (0, 3) ! """ def _test(): ! #import doctest ! #doctest.testmod(doctest, verbose=False, ! # optionflags=ELLIPSIS | NORMALIZE_WHITESPACE | ! # UNIFIED_DIFF) ! #print '~'*70 ! r = unittest.TextTestRunner() ! r.run(DocTestSuite()) if __name__ == "__main__": From tim_one at users.sourceforge.net Wed Aug 4 22:04:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 4 22:04:43 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31160/Lib/test Modified Files: test_doctest.py Log Message: Example.__init__: this cannot use assert, because that fails to trigger in a -O run, and so test_doctest was failing under -O. Simple cause, simple cure. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_doctest.py 4 Aug 2004 18:46:33 -0000 1.6 --- test_doctest.py 4 Aug 2004 20:04:32 -0000 1.7 *************** *** 133,137 **** >>> e = doctest.Example('print 1\n', '1\n', 0) Traceback (most recent call last): ! AssertionError >>> # Source spans multiple lines: require terminating newline. --- 133,137 ---- >>> e = doctest.Example('print 1\n', '1\n', 0) Traceback (most recent call last): ! AssertionError: source must end with newline iff source contains more than one line >>> # Source spans multiple lines: require terminating newline. *************** *** 139,143 **** >>> e = doctest.Example('print 1;\nprint 2', '1\n2\n', 0) Traceback (most recent call last): ! AssertionError The `want` string should be terminated by a newline, unless it's the --- 139,143 ---- >>> e = doctest.Example('print 1;\nprint 2', '1\n2\n', 0) Traceback (most recent call last): ! AssertionError: source must end with newline iff source contains more than one line The `want` string should be terminated by a newline, unless it's the *************** *** 147,151 **** >>> e = doctest.Example('print 1', '1', 0) Traceback (most recent call last): ! AssertionError >>> e = doctest.Example('print', '', 0) """ --- 147,151 ---- >>> e = doctest.Example('print 1', '1', 0) Traceback (most recent call last): ! AssertionError: non-empty want must end with newline >>> e = doctest.Example('print', '', 0) """ From tim_one at users.sourceforge.net Wed Aug 4 22:05:04 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 4 22:05:07 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31160/Lib Modified Files: doctest.py Log Message: Example.__init__: this cannot use assert, because that fails to trigger in a -O run, and so test_doctest was failing under -O. Simple cause, simple cure. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** doctest.py 4 Aug 2004 18:46:33 -0000 1.37 --- doctest.py 4 Aug 2004 20:04:31 -0000 1.38 *************** *** 479,484 **** def __init__(self, source, want, lineno): # Check invariants. ! assert (source[-1:] == '\n') == ('\n' in source[:-1]) ! assert want == '' or want[-1] == '\n' # Store properties. self.source = source --- 479,487 ---- def __init__(self, source, want, lineno): # Check invariants. ! if (source[-1:] == '\n') != ('\n' in source[:-1]): ! raise AssertionError("source must end with newline iff " ! "source contains more than one line") ! if want and want[-1] != '\n': ! raise AssertionError("non-empty want must end with newline") # Store properties. self.source = source From fdrake at users.sourceforge.net Thu Aug 5 00:28:18 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Aug 5 00:28:21 2004 Subject: [Python-checkins] python/dist/src/Modules pyexpat.c,2.85,2.86 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25679 Modified Files: pyexpat.c Log Message: add constants for many error values added over the past couple of years Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.85 retrieving revision 2.86 diff -C2 -d -r2.85 -r2.86 *** pyexpat.c 3 Aug 2004 11:31:31 -0000 2.85 --- pyexpat.c 4 Aug 2004 22:28:16 -0000 2.86 *************** *** 1938,1941 **** --- 1938,1958 ---- MYCONST(XML_ERROR_EXTERNAL_ENTITY_HANDLING); MYCONST(XML_ERROR_NOT_STANDALONE); + MYCONST(XML_ERROR_UNEXPECTED_STATE); + MYCONST(XML_ERROR_ENTITY_DECLARED_IN_PE); + MYCONST(XML_ERROR_FEATURE_REQUIRES_XML_DTD); + MYCONST(XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING); + /* Added in Expat 1.95.7. */ + MYCONST(XML_ERROR_UNBOUND_PREFIX); + /* Added in Expat 1.95.8. */ + MYCONST(XML_ERROR_UNDECLARING_PREFIX); + MYCONST(XML_ERROR_INCOMPLETE_PE); + MYCONST(XML_ERROR_XML_DECL); + MYCONST(XML_ERROR_TEXT_DECL); + MYCONST(XML_ERROR_PUBLICID); + MYCONST(XML_ERROR_SUSPENDED); + MYCONST(XML_ERROR_NOT_SUSPENDED); + MYCONST(XML_ERROR_ABORTED); + MYCONST(XML_ERROR_FINISHED); + MYCONST(XML_ERROR_SUSPEND_PE); PyModule_AddStringConstant(errors_module, "__doc__", From doko at users.sourceforge.net Thu Aug 5 01:18:51 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Thu Aug 5 01:18:55 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.169,1.170 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1679/Doc/lib Modified Files: libfuncs.tex Log Message: Doc/lib/libfuncs.tex: correct items in itemize Doc/dist/dist.tex: avoid uncommenting the verbose environment (by the py2texi tool) Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.169 retrieving revision 1.170 diff -C2 -d -r1.169 -r1.170 *** libfuncs.tex 3 Aug 2004 05:17:58 -0000 1.169 --- libfuncs.tex 4 Aug 2004 23:18:49 -0000 1.170 *************** *** 807,825 **** \begin{itemize} ! \item{Python modules' code is recompiled and the module-level code reexecuted, defining a new set of objects which are bound to names in the module's dictionary. The \code{init} function of extension ! modules is not called a second time.} ! \item{As with all other objects in Python the old objects are only ! reclaimed after their reference counts drop to zero.} ! \item{The names in the module namespace are updated to point to ! any new or changed objects.} ! \item{Other references to the old objects (such as names external to the module) are not rebound to refer to the new objects and must be updated in each namespace where they occur if that is ! desired.} \end{itemize} --- 807,825 ---- \begin{itemize} ! \item Python modules' code is recompiled and the module-level code reexecuted, defining a new set of objects which are bound to names in the module's dictionary. The \code{init} function of extension ! modules is not called a second time. ! \item As with all other objects in Python the old objects are only ! reclaimed after their reference counts drop to zero. ! \item The names in the module namespace are updated to point to ! any new or changed objects. ! \item Other references to the old objects (such as names external to the module) are not rebound to refer to the new objects and must be updated in each namespace where they occur if that is ! desired. \end{itemize} From doko at users.sourceforge.net Thu Aug 5 01:18:52 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Thu Aug 5 01:18:55 2004 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.81,1.82 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1679/Doc/dist Modified Files: dist.tex Log Message: Doc/lib/libfuncs.tex: correct items in itemize Doc/dist/dist.tex: avoid uncommenting the verbose environment (by the py2texi tool) Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** dist.tex 3 Aug 2004 16:37:39 -0000 1.81 --- dist.tex 4 Aug 2004 23:18:49 -0000 1.82 *************** *** 1445,1453 **** % the \file{.spec} file manually: % ! % \begin{verbatim} % > python setup.py bdist_rpm --spec-only % # ...edit dist/FooBar-1.0.spec % > python setup.py bdist_rpm --spec-file=dist/FooBar-1.0.spec ! % \end{verbatim} % % (Although a better way to do this is probably to override the standard --- 1445,1453 ---- % the \file{.spec} file manually: % ! % \ begin{verbatim} % > python setup.py bdist_rpm --spec-only % # ...edit dist/FooBar-1.0.spec % > python setup.py bdist_rpm --spec-file=dist/FooBar-1.0.spec ! % \ end{verbatim} % % (Although a better way to do this is probably to override the standard From anthonybaxter at users.sourceforge.net Thu Aug 5 09:21:19 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Aug 5 09:21:22 2004 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2299/Lib/idlelib Modified Files: NEWS.txt Log Message: release date Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** NEWS.txt 15 Jul 2004 04:54:57 -0000 1.38 --- NEWS.txt 5 Aug 2004 07:21:01 -0000 1.39 *************** *** 2,6 **** ========================= ! *Release date: XX-JUL-2004* - checking sys.platform for substring 'win' was breaking IDLE docs on Mac --- 2,6 ---- ========================= ! *Release date: 05-AUG-2004* - checking sys.platform for substring 'win' was breaking IDLE docs on Mac From anthonybaxter at users.sourceforge.net Thu Aug 5 09:21:34 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Aug 5 09:21:36 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1071,1.1072 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2299/Misc Modified Files: NEWS Log Message: release date Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1071 retrieving revision 1.1072 diff -C2 -d -r1.1071 -r1.1072 *** NEWS 4 Aug 2004 18:46:34 -0000 1.1071 --- NEWS 5 Aug 2004 07:21:00 -0000 1.1072 *************** *** 8,12 **** ================================= ! *Release date: XX-XXX-2004* Core and builtins --- 8,12 ---- ================================= ! *Release date: 05-AUG-2004* Core and builtins *************** *** 17,21 **** @staticmethod def foo(bar): ! (The PEP needs to be updated to reflect this XXX before 2.4a2) - When importing a module M raises an exception, Python no longer leaves M --- 17,21 ---- @staticmethod def foo(bar): ! (The PEP needs to be updated to reflect the current state) - When importing a module M raises an exception, Python no longer leaves M From loewis at users.sourceforge.net Thu Aug 5 12:02:05 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 5 12:02:08 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24311 Modified Files: msi.py Log Message: Add dash into file name. Add ia64 suffix if necessary Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** msi.py 1 Aug 2004 22:14:19 -0000 1.24 --- msi.py 5 Aug 2004 10:02:02 -0000 1.25 *************** *** 139,144 **** # sequence is the set of standard sequences # (ui/execute, admin/advt/install) ! db = msilib.init_database("python%s.msi" % full_current_version, schema, ! ProductName="Python "+full_current_version, ProductCode=product_code, ProductVersion=current_version, --- 139,148 ---- # sequence is the set of standard sequences # (ui/execute, admin/advt/install) ! if msilib.Win64: ! w64 = ".ia64" ! else: ! w64 = "" ! db = msilib.init_database("python-%s%s.msi" % (full_current_version, w64), ! schema, ProductName="Python "+full_current_version, ProductCode=product_code, ProductVersion=current_version, From pje at users.sourceforge.net Thu Aug 5 14:13:54 2004 From: pje at users.sourceforge.net (pje@users.sourceforge.net) Date: Thu Aug 5 14:13:57 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libsys.tex,1.72,1.73 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12384/Doc/lib Modified Files: libsys.tex Log Message: Warn that settrace() is implementation rather than language definition, per Guido's request in off-list email. Index: libsys.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsys.tex,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** libsys.tex 16 Jun 2004 04:53:46 -0000 1.72 --- libsys.tex 5 Aug 2004 12:13:46 -0000 1.73 *************** *** 476,480 **** thread-specific; for a debugger to support multiple threads, it must be registered using \function{settrace()} for each thread being ! debugged. \end{funcdesc} --- 476,484 ---- thread-specific; for a debugger to support multiple threads, it must be registered using \function{settrace()} for each thread being ! debugged. \note{The \function{settrace()} function is intended only ! for implementing debuggers, profilers, coverage tools and the like. ! Its behavior is part of the implementation platform, rather than ! part of the language definition, and thus may not be available in ! all Python implementations.} \end{funcdesc} From lemburg at users.sourceforge.net Thu Aug 5 14:43:33 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Thu Aug 5 14:43:36 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1072,1.1073 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17412/Misc Modified Files: NEWS Log Message: Added new codecs and aliases for ISO_8859-11, ISO_8859-16 and TIS-620. Closes SF bug #1001895: Adding missing ISO 8859 codecs, especially Thai. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1072 retrieving revision 1.1073 diff -C2 -d -r1.1072 -r1.1073 *** NEWS 5 Aug 2004 07:21:00 -0000 1.1072 --- NEWS 5 Aug 2004 12:43:29 -0000 1.1073 *************** *** 84,87 **** --- 84,90 ---- ------- + - Added new codecs and aliases for ISO_8859-11, ISO_8859-16 and + TIS-620 + - Thanks to Edward Loper, doctest has been massively refactored, and many new features were added. Full docs will appear later. For now From lemburg at users.sourceforge.net Thu Aug 5 14:43:33 2004 From: lemburg at users.sourceforge.net (lemburg@users.sourceforge.net) Date: Thu Aug 5 14:43:38 2004 Subject: [Python-checkins] python/dist/src/Lib/encodings iso8859_11.py, NONE, 1.1 iso8859_16.py, NONE, 1.1 tis_620.py, NONE, 1.1 aliases.py, 1.26, 1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/encodings In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17412/Lib/encodings Modified Files: aliases.py Added Files: iso8859_11.py iso8859_16.py tis_620.py Log Message: Added new codecs and aliases for ISO_8859-11, ISO_8859-16 and TIS-620. Closes SF bug #1001895: Adding missing ISO 8859 codecs, especially Thai. --- NEW FILE: iso8859_11.py --- """ Python Character Mapping Codec generated from '8859-11.TXT' with gencodec.py. Generated from mapping found in ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-11.TXT """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_map) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_map) class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) ### Decoding Map decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ 0x00a1: 0x0e01, # THAI CHARACTER KO KAI 0x00a2: 0x0e02, # THAI CHARACTER KHO KHAI 0x00a3: 0x0e03, # THAI CHARACTER KHO KHUAT 0x00a4: 0x0e04, # THAI CHARACTER KHO KHWAI 0x00a5: 0x0e05, # THAI CHARACTER KHO KHON 0x00a6: 0x0e06, # THAI CHARACTER KHO RAKHANG 0x00a7: 0x0e07, # THAI CHARACTER NGO NGU 0x00a8: 0x0e08, # THAI CHARACTER CHO CHAN 0x00a9: 0x0e09, # THAI CHARACTER CHO CHING 0x00aa: 0x0e0a, # THAI CHARACTER CHO CHANG 0x00ab: 0x0e0b, # THAI CHARACTER SO SO 0x00ac: 0x0e0c, # THAI CHARACTER CHO CHOE 0x00ad: 0x0e0d, # THAI CHARACTER YO YING 0x00ae: 0x0e0e, # THAI CHARACTER DO CHADA 0x00af: 0x0e0f, # THAI CHARACTER TO PATAK 0x00b0: 0x0e10, # THAI CHARACTER THO THAN 0x00b1: 0x0e11, # THAI CHARACTER THO NANGMONTHO 0x00b2: 0x0e12, # THAI CHARACTER THO PHUTHAO 0x00b3: 0x0e13, # THAI CHARACTER NO NEN 0x00b4: 0x0e14, # THAI CHARACTER DO DEK 0x00b5: 0x0e15, # THAI CHARACTER TO TAO 0x00b6: 0x0e16, # THAI CHARACTER THO THUNG 0x00b7: 0x0e17, # THAI CHARACTER THO THAHAN 0x00b8: 0x0e18, # THAI CHARACTER THO THONG 0x00b9: 0x0e19, # THAI CHARACTER NO NU 0x00ba: 0x0e1a, # THAI CHARACTER BO BAIMAI 0x00bb: 0x0e1b, # THAI CHARACTER PO PLA 0x00bc: 0x0e1c, # THAI CHARACTER PHO PHUNG 0x00bd: 0x0e1d, # THAI CHARACTER FO FA 0x00be: 0x0e1e, # THAI CHARACTER PHO PHAN 0x00bf: 0x0e1f, # THAI CHARACTER FO FAN 0x00c0: 0x0e20, # THAI CHARACTER PHO SAMPHAO 0x00c1: 0x0e21, # THAI CHARACTER MO MA 0x00c2: 0x0e22, # THAI CHARACTER YO YAK 0x00c3: 0x0e23, # THAI CHARACTER RO RUA 0x00c4: 0x0e24, # THAI CHARACTER RU 0x00c5: 0x0e25, # THAI CHARACTER LO LING 0x00c6: 0x0e26, # THAI CHARACTER LU 0x00c7: 0x0e27, # THAI CHARACTER WO WAEN 0x00c8: 0x0e28, # THAI CHARACTER SO SALA 0x00c9: 0x0e29, # THAI CHARACTER SO RUSI 0x00ca: 0x0e2a, # THAI CHARACTER SO SUA 0x00cb: 0x0e2b, # THAI CHARACTER HO HIP 0x00cc: 0x0e2c, # THAI CHARACTER LO CHULA 0x00cd: 0x0e2d, # THAI CHARACTER O ANG 0x00ce: 0x0e2e, # THAI CHARACTER HO NOKHUK 0x00cf: 0x0e2f, # THAI CHARACTER PAIYANNOI 0x00d0: 0x0e30, # THAI CHARACTER SARA A 0x00d1: 0x0e31, # THAI CHARACTER MAI HAN-AKAT 0x00d2: 0x0e32, # THAI CHARACTER SARA AA 0x00d3: 0x0e33, # THAI CHARACTER SARA AM 0x00d4: 0x0e34, # THAI CHARACTER SARA I 0x00d5: 0x0e35, # THAI CHARACTER SARA II 0x00d6: 0x0e36, # THAI CHARACTER SARA UE 0x00d7: 0x0e37, # THAI CHARACTER SARA UEE 0x00d8: 0x0e38, # THAI CHARACTER SARA U 0x00d9: 0x0e39, # THAI CHARACTER SARA UU 0x00da: 0x0e3a, # THAI CHARACTER PHINTHU 0x00db: None, 0x00dc: None, 0x00dd: None, 0x00de: None, 0x00df: 0x0e3f, # THAI CURRENCY SYMBOL BAHT 0x00e0: 0x0e40, # THAI CHARACTER SARA E 0x00e1: 0x0e41, # THAI CHARACTER SARA AE 0x00e2: 0x0e42, # THAI CHARACTER SARA O 0x00e3: 0x0e43, # THAI CHARACTER SARA AI MAIMUAN 0x00e4: 0x0e44, # THAI CHARACTER SARA AI MAIMALAI 0x00e5: 0x0e45, # THAI CHARACTER LAKKHANGYAO 0x00e6: 0x0e46, # THAI CHARACTER MAIYAMOK 0x00e7: 0x0e47, # THAI CHARACTER MAITAIKHU 0x00e8: 0x0e48, # THAI CHARACTER MAI EK 0x00e9: 0x0e49, # THAI CHARACTER MAI THO 0x00ea: 0x0e4a, # THAI CHARACTER MAI TRI 0x00eb: 0x0e4b, # THAI CHARACTER MAI CHATTAWA 0x00ec: 0x0e4c, # THAI CHARACTER THANTHAKHAT 0x00ed: 0x0e4d, # THAI CHARACTER NIKHAHIT 0x00ee: 0x0e4e, # THAI CHARACTER YAMAKKAN 0x00ef: 0x0e4f, # THAI CHARACTER FONGMAN 0x00f0: 0x0e50, # THAI DIGIT ZERO 0x00f1: 0x0e51, # THAI DIGIT ONE 0x00f2: 0x0e52, # THAI DIGIT TWO 0x00f3: 0x0e53, # THAI DIGIT THREE 0x00f4: 0x0e54, # THAI DIGIT FOUR 0x00f5: 0x0e55, # THAI DIGIT FIVE 0x00f6: 0x0e56, # THAI DIGIT SIX 0x00f7: 0x0e57, # THAI DIGIT SEVEN 0x00f8: 0x0e58, # THAI DIGIT EIGHT 0x00f9: 0x0e59, # THAI DIGIT NINE 0x00fa: 0x0e5a, # THAI CHARACTER ANGKHANKHU 0x00fb: 0x0e5b, # THAI CHARACTER KHOMUT 0x00fc: None, 0x00fd: None, 0x00fe: None, 0x00ff: None, }) ### Encoding Map encoding_map = codecs.make_encoding_map(decoding_map) --- NEW FILE: iso8859_16.py --- """ Python Character Mapping Codec generated from '8859-16.TXT' with gencodec.py. Generated from mapping found in ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-16.TXT """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_map) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_map) class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) ### Decoding Map decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ 0x00a1: 0x0104, # LATIN CAPITAL LETTER A WITH OGONEK 0x00a2: 0x0105, # LATIN SMALL LETTER A WITH OGONEK 0x00a3: 0x0141, # LATIN CAPITAL LETTER L WITH STROKE 0x00a4: 0x20ac, # EURO SIGN 0x00a5: 0x201e, # DOUBLE LOW-9 QUOTATION MARK 0x00a6: 0x0160, # LATIN CAPITAL LETTER S WITH CARON 0x00a8: 0x0161, # LATIN SMALL LETTER S WITH CARON 0x00aa: 0x0218, # LATIN CAPITAL LETTER S WITH COMMA BELOW 0x00ac: 0x0179, # LATIN CAPITAL LETTER Z WITH ACUTE 0x00ae: 0x017a, # LATIN SMALL LETTER Z WITH ACUTE 0x00af: 0x017b, # LATIN CAPITAL LETTER Z WITH DOT ABOVE 0x00b2: 0x010c, # LATIN CAPITAL LETTER C WITH CARON 0x00b3: 0x0142, # LATIN SMALL LETTER L WITH STROKE 0x00b4: 0x017d, # LATIN CAPITAL LETTER Z WITH CARON 0x00b5: 0x201d, # RIGHT DOUBLE QUOTATION MARK 0x00b8: 0x017e, # LATIN SMALL LETTER Z WITH CARON 0x00b9: 0x010d, # LATIN SMALL LETTER C WITH CARON 0x00ba: 0x0219, # LATIN SMALL LETTER S WITH COMMA BELOW 0x00bc: 0x0152, # LATIN CAPITAL LIGATURE OE 0x00bd: 0x0153, # LATIN SMALL LIGATURE OE 0x00be: 0x0178, # LATIN CAPITAL LETTER Y WITH DIAERESIS 0x00bf: 0x017c, # LATIN SMALL LETTER Z WITH DOT ABOVE 0x00c3: 0x0102, # LATIN CAPITAL LETTER A WITH BREVE 0x00c5: 0x0106, # LATIN CAPITAL LETTER C WITH ACUTE 0x00d0: 0x0110, # LATIN CAPITAL LETTER D WITH STROKE 0x00d1: 0x0143, # LATIN CAPITAL LETTER N WITH ACUTE 0x00d5: 0x0150, # LATIN CAPITAL LETTER O WITH DOUBLE ACUTE 0x00d7: 0x015a, # LATIN CAPITAL LETTER S WITH ACUTE 0x00d8: 0x0170, # LATIN CAPITAL LETTER U WITH DOUBLE ACUTE 0x00dd: 0x0118, # LATIN CAPITAL LETTER E WITH OGONEK 0x00de: 0x021a, # LATIN CAPITAL LETTER T WITH COMMA BELOW 0x00e3: 0x0103, # LATIN SMALL LETTER A WITH BREVE 0x00e5: 0x0107, # LATIN SMALL LETTER C WITH ACUTE 0x00f0: 0x0111, # LATIN SMALL LETTER D WITH STROKE 0x00f1: 0x0144, # LATIN SMALL LETTER N WITH ACUTE 0x00f5: 0x0151, # LATIN SMALL LETTER O WITH DOUBLE ACUTE 0x00f7: 0x015b, # LATIN SMALL LETTER S WITH ACUTE 0x00f8: 0x0171, # LATIN SMALL LETTER U WITH DOUBLE ACUTE 0x00fd: 0x0119, # LATIN SMALL LETTER E WITH OGONEK 0x00fe: 0x021b, # LATIN SMALL LETTER T WITH COMMA BELOW }) ### Encoding Map encoding_map = codecs.make_encoding_map(decoding_map) --- NEW FILE: tis_620.py --- """ Python Character Mapping Codec for TIS-620. According to ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-11.TXT the TIS-620 is the identical to ISO_8859-11 with the 0xA0 (no-break space) mapping removed. """#" import codecs from encodings.iso8859_11 import decoding_map ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_map) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_map) class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return (Codec().encode,Codec().decode,StreamReader,StreamWriter) ### Decoding Map decoding_map = decoding_map.copy() decoding_map.update({ 0x00a0: None, }) ### Encoding Map encoding_map = codecs.make_encoding_map(decoding_map) Index: aliases.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/aliases.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** aliases.py 28 Jul 2004 15:35:29 -0000 1.26 --- aliases.py 5 Aug 2004 12:43:30 -0000 1.27 *************** *** 18,22 **** aliases = { ! # Please keep this list sorted alphabetically ! # ascii codec --- 18,22 ---- aliases = { ! # Please keep this list sorted alphabetically by value ! # ascii codec *************** *** 374,377 **** --- 374,389 ---- 'latin5' : 'iso8859_9', + # iso8859_11 codec + 'thai' : 'iso8859_11', + 'iso_8859_11' : 'iso8859_11', + 'iso_8859_11_2001' : 'iso8859_11', + + # iso8859_16 codec + 'iso_8859_16' : 'iso8859_16', + 'iso_8859_16_2001' : 'iso8859_16', + 'iso_ir_226' : 'iso8859_16', + 'l10' : 'iso8859_16', + 'latin10' : 'iso8859_16', + # johab codec 'cp1361' : 'johab', *************** *** 449,452 **** --- 461,471 ---- 'tis260' : 'tactis', + # tis_620 codec + 'tis620' : 'tis_620', + 'tis_620_0' : 'tis_620', + 'tis_620_2529_0' : 'tis_620', + 'tis_620_2529_1' : 'tis_620', + 'iso_ir_166' : 'tis_620', + # utf_16 codec 'u16' : 'utf_16', From loewis at users.sourceforge.net Thu Aug 5 22:29:08 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 5 22:29:13 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16570 Modified Files: msi.py Log Message: Don't install python24.dll into system32 if the user chose a per-user installation. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** msi.py 5 Aug 2004 10:02:02 -0000 1.25 --- msi.py 5 Aug 2004 20:29:05 -0000 1.26 *************** *** 129,132 **** --- 129,138 ---- msilib.reset() + # condition in which to install pythonxy.dll in system32: + # a) it is Windows 9x or + # b) it is NT, the user is privileged, and has chosen per-machine installation + sys32cond = "(Windows9x or (Privileged and ALLUSERS))" + + def build_database(): """Generate an empty database, with just the schema and the *************** *** 333,338 **** ("InitialTargetDir", 'TARGETDIR=""', 750), # In the user interface, assume all-users installation if privileged. ! ("SetDLLDirToSystem32", 'DLLDIR="" and Privileged', 751), ! ("SetDLLDirToTarget", 'DLLDIR="" and not Privileged', 752), ("SelectDirectoryDlg", "Not Installed", 1230), # XXX no support for resume installations yet --- 339,344 ---- ("InitialTargetDir", 'TARGETDIR=""', 750), # In the user interface, assume all-users installation if privileged. ! ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751), ! ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752), ("SelectDirectoryDlg", "Not Installed", 1230), # XXX no support for resume installations yet *************** *** 348,353 **** add_data(db, "InstallExecuteSequence", [("InitialTargetDir", 'TARGETDIR=""', 750), ! ("SetDLLDirToSystem32", 'DLLDIR="" and (ALLUSERS and Privileged)', 751), ! ("SetDLLDirToTarget", 'DLLDIR="" and not (ALLUSERS and Privileged)', 752), ]) add_data(db, "AdminExecuteSequence", --- 354,359 ---- add_data(db, "InstallExecuteSequence", [("InitialTargetDir", 'TARGETDIR=""', 750), ! ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751), ! ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752), ]) add_data(db, "AdminExecuteSequence", From fdrake at users.sourceforge.net Thu Aug 5 23:11:29 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Aug 5 23:11:32 2004 Subject: [Python-checkins] python/dist/src/Doc/ref ref2.tex,1.52,1.53 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24042 Modified Files: ref2.tex Log Message: update to reflect the new significance of the "@" character Index: ref2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref2.tex,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** ref2.tex 2 Jun 2004 12:48:20 -0000 1.52 --- ref2.tex 5 Aug 2004 21:11:27 -0000 1.53 *************** *** 680,684 **** \begin{verbatim} ! ( ) [ ] { } , : . ` = ; += -= *= /= //= %= --- 680,684 ---- \begin{verbatim} ! ( ) [ ] { } @ , : . ` = ; += -= *= /= //= %= *************** *** 704,707 **** \begin{verbatim} ! @ $ ? \end{verbatim} --- 704,707 ---- \begin{verbatim} ! $ ? \end{verbatim} From dcjim at users.sourceforge.net Thu Aug 5 23:38:53 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Thu Aug 5 23:38:57 2004 Subject: [Python-checkins] python/dist/src/Lib/test sample_doctest.py, NONE, 1.1.2.1 test_doctest.txt, NONE, 1.1.2.1 test_doctest2.txt, NONE, 1.1.2.1 test_doctest.py, 1.5.18.9, 1.5.18.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28896/test Modified Files: Tag: tim-doctest-branch test_doctest.py Added Files: Tag: tim-doctest-branch sample_doctest.py test_doctest.txt test_doctest2.txt Log Message: - Added DocFileSuite - Added a script_from_examples method to convert examples to a script. - Changed the way the debugger works to include all of the text around the exaples. Having the explanatory text can make debugging a lot easier. - Added a DebugRunner for that raises an error on the first unexpected error or failure. - Wrote tests for DocTestSuite, DocFileSuite, script_from_examples, and DebugRunner. - Added a debug method to DocTestCase that uses the DebugRunner to raise an error on the first failure, to support post-mortem debugging. --- NEW FILE: sample_doctest.py --- """This is a sample module that doesn't really test anything all that interesting It simply has a few tests, some of which suceed and some of which fail. It's important that the numbers remain constance, as another test is testing the running of these tests. >>> 2+2 4 """ def foo(): """ >>> 2+2 5 >>> 2+2 4 """ def bar(): """ >>> 2+2 4 """ def test_silly_setup(): """ >>> import test.test_doctest >>> test.test_doctest.sillySetup True """ def w_blank(): """ >>> if 1: ... print 'a' ... print ... print 'b' a b """ x = 1 def x_is_one(): """ >>> x 1 """ def y_is_one(): """ >>> y 1 """ def test_suite(): import doctest return doctest.DocTestSuite() --- NEW FILE: test_doctest.txt --- This is a sample doctest in a text file. In this example, we'll rely on a global variable being set for us already: >>> favorite_color 'blue' We can make this fail by disabling the blank-line feature. >>> if 1: ... print 'a' ... print ... print 'b' a b --- NEW FILE: test_doctest2.txt --- This is a sample doctest in a text file. In this example, we'll rely on some silly setup: >>> import test.test_doctest >>> test.test_doctest.sillySetup True Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.5.18.9 retrieving revision 1.5.18.10 diff -C2 -d -r1.5.18.9 -r1.5.18.10 *** test_doctest.py 4 Aug 2004 14:06:27 -0000 1.5.18.9 --- test_doctest.py 5 Aug 2004 21:38:50 -0000 1.5.18.10 *************** *** 12,17 **** --- 12,21 ---- def sample_func(v): """ + Blah blah + >>> print sample_func(22) 44 + + Yee ha! """ return v+v *************** *** 253,257 **** >>> e = tests[0].examples[0] >>> print (e.source, e.want, e.lineno) ! ('print sample_func(22)', '44\n', 1) >>> doctest: -ELLIPSIS # Turn ellipsis back off --- 257,261 ---- >>> e = tests[0].examples[0] >>> print (e.source, e.want, e.lineno) ! ('print sample_func(22)', '44\n', 3) >>> doctest: -ELLIPSIS # Turn ellipsis back off *************** *** 913,927 **** The testsource() function takes a module and a name, finds the (first) ! test with that name in that module, and converts it to an >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) print sample_func(22) # Expected: # 44 >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print doctest.testsource(test.test_doctest, name) print '1\n2\n3' # Expected: --- 917,940 ---- The testsource() function takes a module and a name, finds the (first) ! test with that name in that module, and converts it to a script. The ! example code is converted to regular Python code. The surrounding ! words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) + # + # Blah blah + # print sample_func(22) # Expected: # 44 + # + # Yee ha! + # >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print doctest.testsource(test.test_doctest, name) + # print '1\n2\n3' # Expected: *************** *** 929,935 **** --- 942,950 ---- # 2 # 3 + # >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print doctest.testsource(test.test_doctest, name) + # print SampleClass.a_classmethod(10) # Expected: *************** *** 938,941 **** --- 953,957 ---- # Expected: # 12 + # """ *************** *** 976,979 **** --- 992,1160 ---- """ + def test_DocTestSuite(): + """DocTestSuite creates a unittest test suite into a doctest. + + We create a Suite by providing a module. A module can be provided + by passing a module object: + + >>> import unittest + >>> import test.sample_doctest + >>> suite = doctest.DocTestSuite(test.sample_doctest) + >>> suite.run(unittest.TestResult()) + + + We can also supply the module by name: + + >>> suite = doctest.DocTestSuite('test.sample_doctest') + >>> suite.run(unittest.TestResult()) + + + We can use the current module: + + >>> suite = test.sample_doctest.test_suite() + >>> suite.run(unittest.TestResult()) + + + We can supply global variables. If we pass globs, they will be + used instead of the module globals. Here we'll pass an empty + globals, triggering an extra error: + + >>> suite = doctest.DocTestSuite('test.sample_doctest', globs={}) + >>> suite.run(unittest.TestResult()) + + + Alternatively, we can provide extra globals. Here we'll make an + error go away by providing an extra global variable: + + >>> suite = doctest.DocTestSuite('test.sample_doctest', + ... extraglobs={'y': 1}) + >>> suite.run(unittest.TestResult()) + + + You can pass option flags. Here we'll cause an extra error + by disabling the blank-line feature: + + >>> suite = doctest.DocTestSuite('test.sample_doctest', + ... optionflags=doctest.DONT_ACCEPT_BLANKLINE) + >>> suite.run(unittest.TestResult()) + + + You can supply setUp and teatDoen functions: + + >>> def setUp(): + ... import test.test_doctest + ... test.test_doctest.sillySetup = True + + >>> def tearDown(): + ... import test.test_doctest + ... del test.test_doctest.sillySetup + + Here, we installed a silly variable that the test expects: + + >>> suite = doctest.DocTestSuite('test.sample_doctest', + ... setUp=setUp, tearDown=tearDown) + >>> suite.run(unittest.TestResult()) + + + But the tearDown restores sanity: + + >>> import test.test_doctest + >>> test.test_doctest.sillySetup + Traceback (most recent call last): + ... + AttributeError: 'module' object has no attribute 'sillySetup' + + Finally, you can provide an alternate test finder. Here we'll + use a custom test_finder to to run just the test named bar: + + >>> finder = doctest.DocTestFinder( + ... namefilter=lambda prefix, base: base!='bar') + >>> suite = doctest.DocTestSuite('test.sample_doctest', + ... test_finder=finder) + >>> suite.run(unittest.TestResult()) + + + """ + + def test_DocFileSuite(): + """We can test tests found in text files using a DocFileSuite. + + We create a suite by providing the names of one or more text + files that include examples: + + >>> import unittest + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt') + >>> suite.run(unittest.TestResult()) + + + The test files are looked for in the directory containing the + calling module. A package keyword argument can be provided to + specify a different relative location. + + >>> import unittest + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt', + ... package='test') + >>> suite.run(unittest.TestResult()) + + + Note that '/' should be used as a path separator. It will be + converted to a native separator at run time: + + + >>> suite = doctest.DocFileSuite('../test/test_doctest.txt') + >>> suite.run(unittest.TestResult()) + + + You can specify initial global variables: + + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt', + ... globs={'favorite_color': 'blue'}) + >>> suite.run(unittest.TestResult()) + + + In this case, we supplied a missing favorite color. You can + provide doctest options: + + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt', + ... optionflags=doctest.DONT_ACCEPT_BLANKLINE, + ... globs={'favorite_color': 'blue'}) + >>> suite.run(unittest.TestResult()) + + + And, you can provide setUp and tearDown functions: + + You can supply setUp and teatDoen functions: + + >>> def setUp(): + ... import test.test_doctest + ... test.test_doctest.sillySetup = True + + >>> def tearDown(): + ... import test.test_doctest + ... del test.test_doctest.sillySetup + + Here, we installed a silly variable that the test expects: + + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt', + ... setUp=setUp, tearDown=tearDown) + >>> suite.run(unittest.TestResult()) + + + But the tearDown restores sanity: + + >>> import test.test_doctest + >>> test.test_doctest.sillySetup + Traceback (most recent call last): + ... + AttributeError: 'module' object has no attribute 'sillySetup' + + """ + + ###################################################################### ## Main From dcjim at users.sourceforge.net Thu Aug 5 23:38:54 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Thu Aug 5 23:38:58 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.13, 1.36.2.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28896 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: - Added DocFileSuite - Added a script_from_examples method to convert examples to a script. - Changed the way the debugger works to include all of the text around the exaples. Having the explanatory text can make debugging a lot easier. - Added a DebugRunner for that raises an error on the first unexpected error or failure. - Wrote tests for DocTestSuite, DocFileSuite, script_from_examples, and DebugRunner. - Added a debug method to DocTestCase that uses the DebugRunner to raise an error on the first failure, to support post-mortem debugging. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.13 retrieving revision 1.36.2.14 diff -C2 -d -r1.36.2.13 -r1.36.2.14 *** doctest.py 4 Aug 2004 14:05:14 -0000 1.36.2.13 --- doctest.py 5 Aug 2004 21:38:50 -0000 1.36.2.14 *************** *** 306,310 **** import __future__ ! import sys, traceback, inspect, linecache, re, types import unittest, difflib, tempfile from StringIO import StringIO --- 306,310 ---- import __future__ ! import sys, traceback, inspect, linecache, os, re, types import unittest, difflib, tempfile from StringIO import StringIO *************** *** 499,502 **** --- 499,504 ---- the object whose docstring this DocTest was extracted from). + - docstring: The docstring being tested + - filename: The name of the file that this DocTest was extracted from. *************** *** 518,521 **** --- 520,524 ---- self.lineno = lineno # Parse the docstring. + self.docstring = docstring self.examples = self._parse(docstring) *************** *** 1414,1417 **** --- 1417,1484 ---- return totalf, totalt + class DocTestFailure(Exception): + """A DocTest example has failed in debugging mode + + The exeption instance has variables: + + - test: The DocTest object being run + + - excample: The Example object that failed + + - got: the actual output + """ + def __init__(self, test, example, got): + self.test = test + self.example = example + self.got = got + + class DebugRunner(DocTestRunner): + r"""Run doc tests but raie an exception as soon as there is a failure + + If an unexpected exception occurs, the exception is merely propigated + to the caller: + + >>> runner = DebugRunner(verbose=False) + >>> test = DocTest('>>> raise KeyError', {}, 'foo', 'foo.py', 0) + >>> runner.run(test) + Traceback (most recent call last): + ... + KeyError + + If the output doesn't match, then a DocTestFailure is raised: + + >>> try: + ... test = DocTest(''' + ... >>> x = 1 + ... >>> x + ... 2 + ... ''', {}, 'foo', 'foo.py', 0) + ... runner.run(test) + ... except DocTestFailure, failure: + ... pass + + DocTestFailure objects provide access to the test: + + >>> failure.test is test + True + + As well as to the example: + + >>> failure.example.want + '2\n' + + and the actual output: + + >>> failure.got + '1\n' + + """ + + def report_unexpected_exception(self, out, test, example, exc_info): + raise exc_info[0], exc_info[1], exc_info[2] + + def report_failure(self, out, test, example, got): + raise DocTestFailure(test, example, got) + ###################################################################### ## 5. Test Functions *************** *** 1420,1424 **** def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None, ! report=True, optionflags=0, extraglobs=None): """m=None, name=None, globs=None, verbose=None, isprivate=None, report=True, optionflags=0, extraglobs=None --- 1487,1492 ---- def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None, ! report=True, optionflags=0, extraglobs=None, ! raise_on_error=False): """m=None, name=None, globs=None, verbose=None, isprivate=None, report=True, optionflags=0, extraglobs=None *************** *** 1500,1503 **** --- 1568,1576 ---- multi-line expected and actual outputs will be displayed using a context diff. + + Optional keyword arg "raise_on_error" raises an exception on the + first unexpected exception or failure. This allows failures to be + post-mortem debugged. + """ *************** *** 1528,1532 **** # Find, parse, and run all tests in the given module. finder = DocTestFinder(namefilter=isprivate) ! runner = DocTestRunner(verbose=verbose, optionflags=optionflags) for test in finder.find(m, name, globs=globs, extraglobs=extraglobs): runner.run(test) --- 1601,1610 ---- # Find, parse, and run all tests in the given module. finder = DocTestFinder(namefilter=isprivate) ! ! if raise_on_error: ! runner = DebugRunner(verbose=verbose, optionflags=optionflags) ! else: ! runner = DocTestRunner(verbose=verbose, optionflags=optionflags) ! for test in finder.find(m, name, globs=globs, extraglobs=extraglobs): runner.run(test) *************** *** 1648,1652 **** unittest.TestCase.__init__(self) self.__test_runner = test_runner ! self.__test = test self.__setUp = setUp self.__tearDown = tearDown --- 1726,1730 ---- unittest.TestCase.__init__(self) self.__test_runner = test_runner ! self._dt_test = test self.__setUp = setUp self.__tearDown = tearDown *************** *** 1661,1665 **** def runTest(self): ! test = self.__test old = sys.stdout new = StringIO() --- 1739,1743 ---- def runTest(self): ! test = self._dt_test old = sys.stdout new = StringIO() *************** *** 1671,1691 **** if failures: ! lname = '.'.join(test.name.split('.')[-1:]) ! if test.lineno is None: ! lineno = 'unknown line number' ! else: ! lineno = 'line %s' % test.lineno ! err = new.getvalue() ! raise self.failureException( ! 'Failed doctest test for %s\n' ! ' File "%s", %s, in %s\n\n%s' ! % (test.name, test.filename, lineno, lname, err)) def id(self): ! return self.__test.name def __repr__(self): ! name = self.__test.name.split('.') return "%s (%s)" % (name[-1], '.'.join(name[:-1])) --- 1749,1776 ---- if failures: ! raise self.failureException(self.format_failure(new.getvalue())) ! def format_failure(self, err): ! test = self._dt_test ! if test.lineno is None: ! lineno = 'unknown line number' ! else: ! lineno = 'line %s' % test.lineno ! lname = '.'.join(test.name.split('.')[-1:]) ! return ('Failed doctest test for %s\n' ! ' File "%s", line %s, in %s\n\n%s' ! % (test.name, test.filename, lineno, lname, err) ! ) ! ! def debug(self): ! runner = DebugRunner(verbose = False, ! optionflags=self.__test_runner.optionflags) ! runner.run(self._dt_test, nooutput) def id(self): ! return self._dt_test.name def __repr__(self): ! name = self._dt_test.name.split('.') return "%s (%s)" % (name[-1], '.'.join(name[:-1])) *************** *** 1693,1702 **** def shortDescription(self): ! return "Doctest: " + self.__test.name ! def DocTestSuite(module=None, filename=None, globs=None, extraglobs=None, ! optionflags=0, ! test_finder=None, test_runner=None, setUp=lambda: None, tearDown=lambda: None): """ --- 1778,1788 ---- def shortDescription(self): ! return "Doctest: " + self._dt_test.name + def nooutput(*args): + pass ! def DocTestSuite(module=None, globs=None, extraglobs=None, ! optionflags=0, test_finder=None, setUp=lambda: None, tearDown=lambda: None): """ *************** *** 1714,1737 **** If no argument is given, the calling module is used. """ - if module is not None and filename is not None: - raise ValueError('Specify module or filename, not both.') if test_finder is None: test_finder = DocTestFinder() ! if test_runner is None: ! test_runner = DocTestRunner(optionflags=optionflags) ! if filename is not None: ! name = os.path.basename(filename) ! test = Test(open(filename).read(),name,filename,0) ! if globs is None: ! globs = {} ! else: ! module = _normalize_module(module) ! tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) ! if globs is None: ! globs = module.__dict__ ! if not tests: # [XX] why do we want to do this? ! raise ValueError(module, "has no tests") tests.sort() --- 1800,1814 ---- If no argument is given, the calling module is used. """ if test_finder is None: test_finder = DocTestFinder() ! test_runner = DocTestRunner(optionflags=optionflags, verbose=False) ! module = _normalize_module(module) ! tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) ! if globs is None: ! globs = module.__dict__ ! if not tests: # [XX] why do we want to do this? ! raise ValueError(module, "has no tests") tests.sort() *************** *** 1751,1758 **** --- 1828,2022 ---- return suite + class DocTestFileTestCase(DocTestTestCase): + + def id(self): + return '_'.join(self._dt_test.name.split('.')) + + def __repr__(self): + return self._dt_test.filename + __str__ = __repr__ + + def format_failure(self, err): + return ('Failed doctest test for %s\n File "%s", line 0\n\n%s' + % (self._dt_test.name, self._dt_test.filename, err) + ) + + def DocFileTest(path, package=None, globs=None, + setUp=None, tearDown=None, + optionflags=0): + package = _normalize_module(package) + name = path.split('/')[-1] + dir = os.path.split(package.__file__)[0] + path = os.path.join(dir, *(path.split('/'))) + doc = open(path).read() + + if globs is None: + globs = {} + + test_runner = DocTestRunner(optionflags=optionflags, verbose=False) + test = DocTest(doc, globs, name, path, 0) + + return DocTestFileTestCase(test_runner, test, setUp, tearDown) + + def DocFileSuite(*paths, **kw): + """Creates a suite of doctest files. + + One or more text file paths are given as strings. These should + use "/" characters to separate path segments. Paths are relative + to the directory of the calling module, or relative to the package + passed as a keyword argument. + + A number of options may be provided as keyword arguments: + + package + The name of a Python package. Text-file paths will be + interpreted relative to the directory containing this package. + The package may be supplied as a package object or as a dotted + package name. + + setUp + The name of a set-up function. This is called before running the + tests in each file. + + tearDown + The name of a tear-down function. This is called after running the + tests in each file. + + globs + A dictionary containing initial global variables for the tests. + """ + suite = unittest.TestSuite() + + # We do this here so that _normalize_module is called at the right + # level. If it were called in DocFileTest, then this function + # would be the caller and we might guess the package incorrectly. + kw['package'] = _normalize_module(kw.get('package')) + + for path in paths: + suite.addTest(DocFileTest(path, **kw)) + + return suite + ###################################################################### ## 8. Debugging Support ###################################################################### + def script_from_examples(s): + r"""Extract script from text with examples + + The script_from_examples function converts text with examples + into a Python script. Example input is converted to regular + code. Example output and all other words are converted to + comments: + + >>> text = ''' + ... Here are examples of simple math. + ... + ... Python has super accurate integer addition + ... + ... >>> 2 + 2 + ... 5 + ... + ... And very friendly error messages: + ... + ... >>> 1/0 + ... To Infinity + ... And + ... Beyond + ... + ... You can use logic if you want: + ... + ... >>> if 0: + ... ... blah + ... ... blah + ... ... + ... + ... Ho hum + ... ''' + + >>> print script_from_examples(text) + # + # Here are examples of simple math. + # + # Python has super accurate integer addition + # + 2 + 2 + # Expected: + # 5 + # + # And very friendly error messages: + # + 1/0 + # Expected: + # To Infinity + # And + # Beyond + # + # You can use logic if you want: + # + if 0: + blah + blah + + # + # Ho hum + # + """ + isPS1, isPS2 = DocTest._isPS1, DocTest._isPS2 + isEmpty, isComment = DocTest._isEmpty, DocTest._isComment + output = [] + lines = s.split("\n") + i, n = 0, len(lines) + while i < n: + line = lines[i] + i = i + 1 + m = isPS1(line) + if m is None: + line = line.rstrip() + if line: + line = ' ' + line + output.append('#'+line) + continue + j = m.end(0) # beyond the prompt + if isEmpty(line, j) or isComment(line, j): + # a bare prompt or comment -- not interesting + output.append('# '+line[j:]) + + lineno = i - 1 + if line[j] != " ": + raise ValueError("line %r of docstring lacks blank after %s: %s" % + (lineno, PS1, line)) + j = j + 1 + blanks = m.group(1) + nblanks = len(blanks) + # suck up this and following PS2 lines + while 1: + output.append(line[j:]) + line = lines[i] + m = isPS2(line) + if m: + if m.group(1) != blanks: + raise ValueError("inconsistent leading whitespace " + "in line %r of docstring: %s" % (i, line)) + i = i + 1 + else: + break + + # suck up response + if not (isPS1(line) or isEmpty(line)): + output.append('# Expected:') + while 1: + if line[:nblanks] != blanks: + raise ValueError("inconsistent leading whitespace " + "in line %r of docstring: %s" % (i, line)) + output.append('# '+line[nblanks:]) + i = i + 1 + line = lines[i] + if isPS1(line) or isEmpty(line): + break + + return '\n'.join(output) + + def _want_comment(example): """ *************** *** 1782,1789 **** raise ValueError(name, "not found in tests") test = test[0] ! testsrc = '\n'.join([ ! "%s%s" % (example.source, _want_comment(example)) ! for example in test.examples ! ]) return testsrc --- 2046,2050 ---- raise ValueError(name, "not found in tests") test = test[0] ! testsrc = script_from_examples(test.docstring) return testsrc *************** *** 1793,1802 **** The string is provided directly """ ! test = DocTest(src, globs or {}, 'debug', None, None) ! ! testsrc = '\n'.join([ ! "%s%s" % (example.source, _want_comment(example)) ! for example in test.examples ! ]) debug_script(testsrc, pm, globs) --- 2054,2058 ---- The string is provided directly """ ! testsrc = script_from_examples(src) debug_script(testsrc, pm, globs) From tim_one at users.sourceforge.net Fri Aug 6 01:11:23 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 6 01:11:26 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.14, 1.36.2.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10969 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Whitespace normalization. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.14 retrieving revision 1.36.2.15 diff -C2 -d -r1.36.2.14 -r1.36.2.15 *** doctest.py 5 Aug 2004 21:38:50 -0000 1.36.2.14 --- doctest.py 5 Aug 2004 23:11:21 -0000 1.36.2.15 *************** *** 1472,1478 **** >>> failure.got '1\n' ! """ ! def report_unexpected_exception(self, out, test, example, exc_info): raise exc_info[0], exc_info[1], exc_info[2] --- 1472,1478 ---- >>> failure.got '1\n' ! """ ! def report_unexpected_exception(self, out, test, example, exc_info): raise exc_info[0], exc_info[1], exc_info[2] *************** *** 1572,1576 **** first unexpected exception or failure. This allows failures to be post-mortem debugged. ! """ --- 1572,1576 ---- first unexpected exception or failure. This allows failures to be post-mortem debugged. ! """ *************** *** 1834,1838 **** def __repr__(self): ! return self._dt_test.filename __str__ = __repr__ --- 1834,1838 ---- def __repr__(self): ! return self._dt_test.filename __str__ = __repr__ *************** *** 1856,1860 **** test_runner = DocTestRunner(optionflags=optionflags, verbose=False) test = DocTest(doc, globs, name, path, 0) ! return DocTestFileTestCase(test_runner, test, setUp, tearDown) --- 1856,1860 ---- test_runner = DocTestRunner(optionflags=optionflags, verbose=False) test = DocTest(doc, globs, name, path, 0) ! return DocTestFileTestCase(test_runner, test, setUp, tearDown) *************** *** 1892,1896 **** # would be the caller and we might guess the package incorrectly. kw['package'] = _normalize_module(kw.get('package')) ! for path in paths: suite.addTest(DocFileTest(path, **kw)) --- 1892,1896 ---- # would be the caller and we might guess the package incorrectly. kw['package'] = _normalize_module(kw.get('package')) ! for path in paths: suite.addTest(DocFileTest(path, **kw)) *************** *** 1931,1935 **** ... ... blah ... ... ! ... ... Ho hum ... ''' --- 1931,1935 ---- ... ... blah ... ... ! ... ... Ho hum ... ''' *************** *** 1958,1962 **** blah blah ! # # Ho hum --- 1958,1962 ---- blah blah ! # # Ho hum From tim_one at users.sourceforge.net Fri Aug 6 01:11:24 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 6 01:11:27 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.5.18.10, 1.5.18.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10969/test Modified Files: Tag: tim-doctest-branch test_doctest.py Log Message: Whitespace normalization. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.5.18.10 retrieving revision 1.5.18.11 diff -C2 -d -r1.5.18.10 -r1.5.18.11 *** test_doctest.py 5 Aug 2004 21:38:50 -0000 1.5.18.10 --- test_doctest.py 5 Aug 2004 23:11:21 -0000 1.5.18.11 *************** *** 13,17 **** """ Blah blah ! >>> print sample_func(22) 44 --- 13,17 ---- """ Blah blah ! >>> print sample_func(22) 44 *************** *** 1102,1106 **** Note that '/' should be used as a path separator. It will be converted to a native separator at run time: ! >>> suite = doctest.DocFileSuite('../test/test_doctest.txt') --- 1102,1106 ---- Note that '/' should be used as a path separator. It will be converted to a native separator at run time: ! >>> suite = doctest.DocFileSuite('../test/test_doctest.txt') *************** *** 1153,1159 **** ... AttributeError: 'module' object has no attribute 'sillySetup' ! """ ! ###################################################################### --- 1153,1159 ---- ... AttributeError: 'module' object has no attribute 'sillySetup' ! """ ! ###################################################################### From bwarsaw at users.sourceforge.net Fri Aug 6 01:16:27 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri Aug 6 01:16:29 2004 Subject: [Python-checkins] python/nondist/peps pep-0207.txt,1.10,1.11 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11822 Modified Files: pep-0207.txt Log Message: Repaired a few places where the PEP was incorrect or out of touch with reality. Specifically, the third argument to PyObject_RichCompare* is an int, not an enum. Also, when the tp_richcompare function cannot compare the combination of objects, it needs to return Py_NotImplemented, not PyExc_NotImplemented (and a new reference to that object at that). Index: pep-0207.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0207.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pep-0207.txt 5 Feb 2001 15:56:04 -0000 1.10 --- pep-0207.txt 5 Aug 2004 23:16:25 -0000 1.11 *************** *** 141,145 **** - New functions: ! PyObject *PyObject_RichCompare(PyObject *, PyObject *, enum cmp_op) This performs the requested rich comparison, returning a Python --- 141,145 ---- - New functions: ! PyObject *PyObject_RichCompare(PyObject *, PyObject *, int) This performs the requested rich comparison, returning a Python *************** *** 147,151 **** Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT or Py_GE. ! int PyObject_RichCompareBool(PyObject *, PyObject *, enum cmp_op) This performs the requested rich comparison, returning a --- 147,151 ---- Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT or Py_GE. ! int PyObject_RichCompareBool(PyObject *, PyObject *, int) This performs the requested rich comparison, returning a *************** *** 169,173 **** tp_richcompare slot is being used, but the other may have a different type. If the function cannot compare the particular ! combination of objects, it should return PyExc_NotImplemented. - PyObject_Compare() is changed to try rich comparisons if they --- 169,174 ---- tp_richcompare slot is being used, but the other may have a different type. If the function cannot compare the particular ! combination of objects, it should return a new reference to ! Py_NotImplemented. - PyObject_Compare() is changed to try rich comparisons if they From tim_one at users.sourceforge.net Fri Aug 6 01:23:29 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 6 01:23:32 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.15, 1.36.2.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13070 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Format nits. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.15 retrieving revision 1.36.2.16 diff -C2 -d -r1.36.2.15 -r1.36.2.16 *** doctest.py 5 Aug 2004 23:11:21 -0000 1.36.2.15 --- doctest.py 5 Aug 2004 23:23:26 -0000 1.36.2.16 *************** *** 1764,1768 **** def debug(self): ! runner = DebugRunner(verbose = False, optionflags=self.__test_runner.optionflags) runner.run(self._dt_test, nooutput) --- 1764,1768 ---- def debug(self): ! runner = DebugRunner(verbose=False, optionflags=self.__test_runner.optionflags) runner.run(self._dt_test, nooutput) *************** *** 1815,1819 **** suite = unittest.TestSuite() for test in tests: ! if len(test.examples) == 0: continue if not test.filename: filename = module.__file__ --- 1815,1820 ---- suite = unittest.TestSuite() for test in tests: ! if len(test.examples) == 0: ! continue if not test.filename: filename = module.__file__ From tim_one at users.sourceforge.net Fri Aug 6 03:01:58 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 6 03:02:02 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.5.18.11, 1.5.18.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26272/Lib/test Modified Files: Tag: tim-doctest-branch test_doctest.py Log Message: Moved the parsing into a new utility Parser class. This was primarily to squash massive code duplication in script_from_examples(), which is now a 1-liner. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.5.18.11 retrieving revision 1.5.18.12 diff -C2 -d -r1.5.18.11 -r1.5.18.12 *** test_doctest.py 5 Aug 2004 23:11:21 -0000 1.5.18.11 --- test_doctest.py 6 Aug 2004 01:01:56 -0000 1.5.18.12 *************** *** 924,928 **** >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) - # # Blah blah # --- 924,927 ---- *************** *** 932,940 **** # # Yee ha! - # >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print doctest.testsource(test.test_doctest, name) - # print '1\n2\n3' # Expected: --- 931,937 ---- *************** *** 942,950 **** # 2 # 3 - # >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print doctest.testsource(test.test_doctest, name) - # print SampleClass.a_classmethod(10) # Expected: --- 939,945 ---- *************** *** 953,957 **** # Expected: # 12 - # """ --- 948,951 ---- From tim_one at users.sourceforge.net Fri Aug 6 03:01:58 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 6 03:02:02 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.16, 1.36.2.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26272/Lib Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Moved the parsing into a new utility Parser class. This was primarily to squash massive code duplication in script_from_examples(), which is now a 1-liner. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.16 retrieving revision 1.36.2.17 diff -C2 -d -r1.36.2.16 -r1.36.2.17 *** doctest.py 5 Aug 2004 23:23:26 -0000 1.36.2.16 --- doctest.py 6 Aug 2004 01:01:55 -0000 1.36.2.17 *************** *** 450,453 **** --- 450,655 ---- del self.softspace + class Parser: + """ + Extract doctests from a string. + """ + + _PS1 = ">>>" + _PS2 = "..." + _isPS1 = re.compile(r"(\s*)" + re.escape(_PS1)).match + _isPS2 = re.compile(r"(\s*)" + re.escape(_PS2)).match + _isEmpty = re.compile(r"\s*$").match + _isComment = re.compile(r"\s*#").match + + def __init__(self, name, string): + """ + Prepare to extract doctests from string `string`. + + `name` is an arbitrary (string) name associated with the string, + and is used only in error messages. + """ + self.name = name + self.source = string + + def get_examples(self): + """ + Return the doctest examples from the string. + + This is a list of doctest.Example instances, one Example + per doctest test in the string. + + >>> text = ''' + ... >>> x, y = 2, 3 # no output expected + ... >>> if 1: + ... ... print x + ... ... print y + ... 2 + ... 3 + ... + ... Some text. + ... >>> x+y + ... 5 + ... ''' + >>> for x in Parser('', text).get_examples(): + ... x.source + ... x.want + ... x.lineno + 'x, y = 2, 3 # no output expected' + '' + 1 + 'if 1:\\n print x\\n print y\\n' + '2\\n3\\n' + 2 + 'x+y' + '5\\n' + 9 + """ + return self._parse(kind='examples') + + def get_program(self): + """ + Return an executable program from the string, as a string. + + The format of this isn't rigidly defined. In general, doctest + examples become the executable statements in the result, and + and their expected outputs become comments, preceded by an + "#Expected:" comment. Everything else (text, comments, + everything not part of a doctest test) is also placed in comments. + + >>> text = ''' + ... >>> x, y = 2, 3 # no output expected + ... >>> if 1: + ... ... print x + ... ... print y + ... 2 + ... 3 + ... + ... Some text. + ... >>> x+y + ... 5 + ... ''' + >>> print Parser('', text).get_program() + x, y = 2, 3 # no output expected + if 1: + print x + print y + # Expected: + # 2 + # 3 + # + # Some text. + x+y + # Expected: + # 5 + """ + return self._parse(kind='program') + + def _parse(self, kind): + assert kind in ('examples', 'program') + do_program = kind == 'program' + output = [] + push = output.append + + string = self.source + if not string.endswith('\n'): + string += '\n' + + isPS1, isPS2 = self._isPS1, self._isPS2 + isEmpty, isComment = self._isEmpty, self._isComment + lines = string.split("\n") + i, n = 0, len(lines) + while i < n: + # Search for an example (a PS1 line). + line = lines[i] + i += 1 + m = isPS1(line) + if m is None: + if do_program: + line = line.rstrip() + if line: + line = ' ' + line + push('#' + line) + continue + # line is a PS1 line. + j = m.end(0) # beyond the prompt + if isEmpty(line, j) or isComment(line, j): + # a bare prompt or comment -- not interesting + if do_program: + push("# " + line[j:]) + continue + # line is a non-trivial PS1 line. + lineno = i - 1 + if line[j] != " ": + raise ValueError('line %r of the docstring for %s lacks ' + 'blank after %s: %r' % + (lineno, self.name, self._PS1, line)) + + j += 1 + blanks = m.group(1) + nblanks = len(blanks) + # suck up this and following PS2 lines + source = [] + while 1: + source.append(line[j:]) + line = lines[i] + m = isPS2(line) + if m: + if m.group(1) != blanks: + raise ValueError('line %r of the docstring for %s ' + 'has inconsistent leading whitespace: %r' % + (i, self.name, line)) + i += 1 + else: + break + + if do_program: + output.extend(source) + else: + # get rid of useless null line from trailing empty "..." + if source[-1] == "": + assert len(source) > 1 + del source[-1] + if len(source) == 1: + source = source[0] + else: + source = "\n".join(source) + "\n" + + # suck up response + if isPS1(line) or isEmpty(line): + if not do_program: + push(Example(source, "", lineno)) + continue + + # There is a response. + want = [] + if do_program: + push("# Expected:") + while 1: + if line[:nblanks] != blanks: + raise ValueError('line %r of the docstring for %s ' + 'has inconsistent leading whitespace: %r' % + (i, self.name, line)) + want.append(line[nblanks:]) + i += 1 + line = lines[i] + if isPS1(line) or isEmpty(line): + break + + if do_program: + output.extend(['# ' + x for x in want]) + else: + want = "\n".join(want) + "\n" + push(Example(source, want, lineno)) + + if do_program: + # Trim junk on both ends. + while output and output[-1] == '#': + output.pop() + while output and output[0] == '#': + output.pop(0) + output = '\n'.join(output) + + return output + ###################################################################### ## 2. Example & DocTest *************** *** 521,603 **** # Parse the docstring. self.docstring = docstring ! self.examples = self._parse(docstring) ! ! _PS1 = ">>>" ! _PS2 = "..." ! _isPS1 = re.compile(r"(\s*)" + re.escape(_PS1)).match ! _isPS2 = re.compile(r"(\s*)" + re.escape(_PS2)).match ! _isEmpty = re.compile(r"\s*$").match ! _isComment = re.compile(r"\s*#").match ! ! def _parse(self, string): ! if not string.endswith('\n'): ! string += '\n' ! examples = [] ! isPS1, isPS2 = self._isPS1, self._isPS2 ! isEmpty, isComment = self._isEmpty, self._isComment ! lines = string.split("\n") ! i, n = 0, len(lines) ! while i < n: ! # Search for an example (a PS1 line). ! line = lines[i] ! i += 1 ! m = isPS1(line) ! if m is None: ! continue ! # line is a PS1 line. ! j = m.end(0) # beyond the prompt ! if isEmpty(line, j) or isComment(line, j): ! # a bare prompt or comment -- not interesting ! continue ! # line is a non-trivial PS1 line. ! lineno = i - 1 ! if line[j] != " ": ! raise ValueError('line %r of the docstring for %s lacks ' ! 'blank after %s: %r' % ! (lineno, self.name, self._PS1, line)) ! ! j += 1 ! blanks = m.group(1) ! nblanks = len(blanks) ! # suck up this and following PS2 lines ! source = [] ! while 1: ! source.append(line[j:]) ! line = lines[i] ! m = isPS2(line) ! if m: ! if m.group(1) != blanks: ! raise ValueError('line %r of the docstring for %s ' ! 'has inconsistent leading whitespace: %r' % ! (i, self.name, line)) ! i += 1 ! else: ! break ! # get rid of useless null line from trailing empty "..." ! if source[-1] == "": ! assert len(source) > 1 ! del source[-1] ! if len(source) == 1: ! source = source[0] ! else: ! source = "\n".join(source) + "\n" ! # suck up response ! if isPS1(line) or isEmpty(line): ! want = "" ! else: ! want = [] ! while 1: ! if line[:nblanks] != blanks: ! raise ValueError('line %r of the docstring for %s ' ! 'has inconsistent leading whitespace: %r' % ! (i, self.name, line)) ! want.append(line[nblanks:]) ! i += 1 ! line = lines[i] ! if isPS1(line) or isEmpty(line): ! break ! want = "\n".join(want) + "\n" ! examples.append(Example(source, want, lineno)) ! return examples def __repr__(self): --- 723,727 ---- # Parse the docstring. self.docstring = docstring ! self.examples = Parser(name, docstring).get_examples() def __repr__(self): *************** *** 1937,1941 **** >>> print script_from_examples(text) - # # Here are examples of simple math. # --- 2061,2064 ---- *************** *** 1962,2022 **** # # Ho hum - # """ - isPS1, isPS2 = DocTest._isPS1, DocTest._isPS2 - isEmpty, isComment = DocTest._isEmpty, DocTest._isComment - output = [] - lines = s.split("\n") - i, n = 0, len(lines) - while i < n: - line = lines[i] - i = i + 1 - m = isPS1(line) - if m is None: - line = line.rstrip() - if line: - line = ' ' + line - output.append('#'+line) - continue - j = m.end(0) # beyond the prompt - if isEmpty(line, j) or isComment(line, j): - # a bare prompt or comment -- not interesting - output.append('# '+line[j:]) - - lineno = i - 1 - if line[j] != " ": - raise ValueError("line %r of docstring lacks blank after %s: %s" % - (lineno, PS1, line)) - j = j + 1 - blanks = m.group(1) - nblanks = len(blanks) - # suck up this and following PS2 lines - while 1: - output.append(line[j:]) - line = lines[i] - m = isPS2(line) - if m: - if m.group(1) != blanks: - raise ValueError("inconsistent leading whitespace " - "in line %r of docstring: %s" % (i, line)) - i = i + 1 - else: - break - - # suck up response - if not (isPS1(line) or isEmpty(line)): - output.append('# Expected:') - while 1: - if line[:nblanks] != blanks: - raise ValueError("inconsistent leading whitespace " - "in line %r of docstring: %s" % (i, line)) - output.append('# '+line[nblanks:]) - i = i + 1 - line = lines[i] - if isPS1(line) or isEmpty(line): - break - - return '\n'.join(output) def _want_comment(example): --- 2085,2091 ---- # # Ho hum """ + return Parser('', s).get_program() def _want_comment(example): From tim_one at users.sourceforge.net Fri Aug 6 03:28:56 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 6 03:28:59 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.17, 1.36.2.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30284/Lib Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Added Edward's very helpful 30-second overview and class-flow diagram from early email. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.17 retrieving revision 1.36.2.18 diff -C2 -d -r1.36.2.17 -r1.36.2.18 *** doctest.py 6 Aug 2004 01:01:55 -0000 1.36.2.17 --- doctest.py 6 Aug 2004 01:28:54 -0000 1.36.2.18 *************** *** 1,5 **** # Module doctest. # Released to the public domain 16-Jan-2001, by Tim Peters (tim@python.org). ! # Significant enhancements by: # Jim Fulton # Edward Loper --- 1,5 ---- # Module doctest. # Released to the public domain 16-Jan-2001, by Tim Peters (tim@python.org). ! # Major enhancements and refactoring by: # Jim Fulton # Edward Loper *************** *** 331,334 **** --- 331,354 ---- ELLIPSIS_MARKER = '...' + + # There are 4 basic classes: + # - Example: a pair, plus an intra-docstring line number. + # - DocTest: a collection of examples, parsed from a docstring, plus + # info about where the docstring came from (name, filename, lineno). + # - DocTestFinder: extracts DocTests from a given object's docstring and + # its contained objects' docstrings. + # - DocTestRunner: runs DocTest cases, and accumulates statistics. + # + # So the basic picture is: + # + # list of: + # +------+ +---------+ +-------+ + # |object| --DocTestFinder-> | DocTest | --DocTestRunner-> |results| + # +------+ +---------+ +-------+ + # | Example | + # | ... | + # | Example | + # +---------+ + ###################################################################### ## Table of Contents From tim_one at users.sourceforge.net Fri Aug 6 04:11:55 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 6 04:11:57 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.18, 1.36.2.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3691/Lib Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Changed Parser to work purely with strings, and Doctest.__init__ to change them into Examples. Cleaner separation of concerns. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.18 retrieving revision 1.36.2.19 diff -C2 -d -r1.36.2.18 -r1.36.2.19 *** doctest.py 6 Aug 2004 01:28:54 -0000 1.36.2.18 --- doctest.py 6 Aug 2004 02:11:52 -0000 1.36.2.19 *************** *** 496,501 **** Return the doctest examples from the string. ! This is a list of doctest.Example instances, one Example ! per doctest test in the string. >>> text = ''' --- 496,510 ---- Return the doctest examples from the string. ! This is a list of (source, want, lineno) triples, one per example ! in the string. "source" is a single Python statement; it ends ! with a newline iff the statement contains more than one ! physical line. "want" is the expected output from running the ! example (either from stdout, or a traceback in case of exception). ! "want" always ends with a newline, unless no output is expected, ! in which case "want" is an empty string. "lineno" is the 0-based ! line number of the first line of "source" within the string. It's ! 0-based because it's most common in doctests that nothing ! interesting appears on the same line as opening triple-quote, ! and so the first interesting line is called "line 1" then. >>> text = ''' *************** *** 512,527 **** ... ''' >>> for x in Parser('', text).get_examples(): ! ... x.source ! ... x.want ! ... x.lineno ! 'x, y = 2, 3 # no output expected' ! '' ! 1 ! 'if 1:\\n print x\\n print y\\n' ! '2\\n3\\n' ! 2 ! 'x+y' ! '5\\n' ! 9 """ return self._parse(kind='examples') --- 521,528 ---- ... ''' >>> for x in Parser('', text).get_examples(): ! ... print x ! ('x, y = 2, 3 # no output expected', '', 1) ! ('if 1:\\n print x\\n print y\\n', '2\\n3\\n', 2) ! ('x+y', '5\\n', 9) """ return self._parse(kind='examples') *************** *** 638,642 **** if isPS1(line) or isEmpty(line): if not do_program: ! push(Example(source, "", lineno)) continue --- 639,643 ---- if isPS1(line) or isEmpty(line): if not do_program: ! push((source, "", lineno)) continue *************** *** 660,664 **** else: want = "\n".join(want) + "\n" ! push(Example(source, want, lineno)) if do_program: --- 661,665 ---- else: want = "\n".join(want) + "\n" ! push((source, want, lineno)) if do_program: *************** *** 743,747 **** # Parse the docstring. self.docstring = docstring ! self.examples = Parser(name, docstring).get_examples() def __repr__(self): --- 744,749 ---- # Parse the docstring. self.docstring = docstring ! examples = Parser(name, docstring).get_examples() ! self.examples = [Example(*example) for example in examples] def __repr__(self): From tim_one at users.sourceforge.net Fri Aug 6 04:13:44 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 6 04:13:46 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.19, 1.36.2.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4006/Lib Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Repaired typo in docstring. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.19 retrieving revision 1.36.2.20 diff -C2 -d -r1.36.2.19 -r1.36.2.20 *** doctest.py 6 Aug 2004 02:11:52 -0000 1.36.2.19 --- doctest.py 6 Aug 2004 02:13:41 -0000 1.36.2.20 *************** *** 534,540 **** The format of this isn't rigidly defined. In general, doctest examples become the executable statements in the result, and ! and their expected outputs become comments, preceded by an ! "#Expected:" comment. Everything else (text, comments, ! everything not part of a doctest test) is also placed in comments. >>> text = ''' --- 534,540 ---- The format of this isn't rigidly defined. In general, doctest examples become the executable statements in the result, and ! their expected outputs become comments, preceded by an "#Expected:" ! comment. Everything else (text, comments, everything not part of ! a doctest test) is also placed in comments. >>> text = ''' From fdrake at users.sourceforge.net Fri Aug 6 05:34:22 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Aug 6 05:34:25 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.80, 1.81 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13046 Modified Files: whatsnew24.tex Log Message: fix markup nit, typo Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** whatsnew24.tex 2 Aug 2004 21:50:26 -0000 1.80 --- whatsnew24.tex 6 Aug 2004 03:34:20 -0000 1.81 *************** *** 215,219 **** \emph{decorating} functions with more details. ! The notation borrows from Java and uses the \samp{@} character as an indicator. Using the new syntax, the example above would be written: --- 215,219 ---- \emph{decorating} functions with more details. ! The notation borrows from Java and uses the \character{@} character as an indicator. Using the new syntax, the example above would be written: *************** *** 228,232 **** The \code{@classmethod} is shorthand for the ! \code{meth=classmethod(meth} assignment. More generally, if you have the following: --- 228,232 ---- The \code{@classmethod} is shorthand for the ! \code{meth=classmethod(meth)} assignment. More generally, if you have the following: From montanaro at users.sourceforge.net Fri Aug 6 05:36:13 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Fri Aug 6 05:36:17 2004 Subject: [Python-checkins] python/nondist/peps pep-0318.txt,1.14,1.15 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13244 Modified Files: pep-0318.txt Log Message: Factor in Anthony's text regarding the @ syntax and toss in a couple other odd bits. Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pep-0318.txt 8 Apr 2004 21:14:34 -0000 1.14 --- pep-0318.txt 6 Aug 2004 03:36:09 -0000 1.15 *************** *** 52,56 **** declaration:: ! def foo(cls) using [synchronized(lock), classmethod]: pass --- 52,58 ---- declaration:: ! @classmethod ! @synchronized(lock) ! def foo(cls): pass *************** *** 60,64 **** metaclasses, but using metaclasses is sufficiently obscure that there is some attraction to having an easier way to make simple ! modifications to classes. --- 62,67 ---- metaclasses, but using metaclasses is sufficiently obscure that there is some attraction to having an easier way to make simple ! modifications to classes. For Python 2.4, only function decorators ! are being added. *************** *** 89,92 **** --- 92,115 ---- definition and function definition are syntactically similar. + The discussion continued on and off on python-dev from February 2002 + through July 2004. Many hundreds of posts were made, with people + proposing many possible syntax variations. Guido took a list of + proposals to `EuroPython 2004`_, where a discussion took place. + Subsequent to this, he decided that for 2.4a2 we'd have the Java-style + @decorator syntax. Barry Warsaw named this the 'pie-decorator' + syntax, in honor of the Pie-thon Parrot shootout which was announced + about the same time as the decorator syntax, and because the @ looks a + little like a pie. Guido `outlined his case`_ on Python-dev, + including `this piece`_ on the various rejected forms. + + .. EuroPython 2004: + http://www.python.org/doc/essays/ppt/euro2004/euro2004.pdf + + .. outlined his case: + http://mail.python.org/pipermail/python-dev/2004-August/authors.html + + .. this piece: + http://mail.python.org/pipermail/python-dev/2004-August/046672.html + Design Goals *************** *** 96,100 **** * work for arbitrary wrappers, including user-defined callables and ! the existing builtins ``classmethod()`` and ``staticmethod`` * work with multiple wrappers per definition --- 119,123 ---- * work for arbitrary wrappers, including user-defined callables and ! the existing builtins ``classmethod()`` and ``staticmethod()`` * work with multiple wrappers per definition *************** *** 120,140 **** http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=mailman.1010809396.32158.python-list%40python.org Proposed Syntax =============== ! The currently proposed syntax for function decorators is:: ! def func(arg1, arg2, ...) [dec1, dec2, ...]: pass The decorators are near the declaration of the function's API but are ! clearly secondary. The square brackets make it possible to fairly ! easily break long lists of decorators across multiple lines. ! Class decorators are defined in an analogous fashion:: ! class MyClass(base1, base2) [dec1, dec2, ...]: ! pass --- 143,178 ---- http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=mailman.1010809396.32158.python-list%40python.org + Andrew Kuchling has links to a bunch of the discussions about motivations + `in his blog`_. + + .. in his blog: + http://www.amk.ca/diary/archives/cat_python.html#003255 Proposed Syntax =============== ! The current syntax for function decorators as implemented in Python ! 2.4a2 is:: ! @dec2 ! @dec1 ! def func(arg1, arg2, ...): ! pass ! ! This is equivalent to:: ! ! def func(arg1, arg2, ...): pass + func = dec2(dec1(func)) The decorators are near the declaration of the function's API but are ! clearly secondary. The @ sign makes it clear that something new is ! going on here. ! The decorator statement is limited in what it can accept - arbitrary ! expressions will not work. Guido preferred this because of a `gut feeling`_ ! .. gut feeling: ! http://mail.python.org/pipermail/python-dev/2004-August/046711.html *************** *** 199,203 **** pass ! This appears to be his current favorite, but negative sentiment runs high, mostly because that syntax, though useless except for side effects of the list, is already legal and thus creates a special case. --- 237,241 ---- pass ! For a while this was Guido's preferred solution, but negative sentiment ran high, mostly because that syntax, though useless except for side effects of the list, is already legal and thus creates a special case. *************** *** 206,217 **** http://python.org/sf/926860 ! Why [...]? ! ---------- ! For syntax options which use a list-like syntax to specify the ! decorators a few alternatives have been proposed: ``[|...|]``, ! ``*[...]*``, and ``<...>``. None have gained traction. The ! alternatives which involve square brackets only serve to make it obvious that the decorator construct is not a list. They do nothing to make parsing any easier. The '<...>' alternative presents parsing --- 244,287 ---- http://python.org/sf/926860 + Another variant on the list syntax that was initially favored was:: ! def func(arg1, arg2, ...) [dec1, dec2]: ! pass ! Guido decided `he preferred`_ having the decorators on the line before ! the 'def', because it was felt that a long argument list would mean ! that the decorators would be 'hidden' ! ! .. he preferred: ! http://mail.python.org/pipermail/python-dev/2004-March/043756.html ! ! Phillip Eby and Jp Calderone both proposed variants that required ! no new syntax, but instead used some fairly advanced introspection ! to provide decorator-like behavoiur, but Guido was unimpressed by ! these, stating:: ! ! Using functions with "action-at-a-distance" through ! sys.settraceback may be okay for an obscure feature that can't be ! had any other way yet doesn't merit changes to the language, but ! that's not the situation for decorators. The widely held view ! here is that decorators need to be added as a syntactic feature to ! avoid the problems with the postfix notation used in 2.2 and 2.3. ! Decorators are slated to be an important new language feature and ! their design needs to be forward-looking, not constrained by what ! can be implemented in 2.3. ! ! Why @? ! ------ ! ! There is some history in Java using @ initially as a marker in ! `Javadoc comments`_ and later in ... mumble mumble ... The fact that ! @ was previously unused as a token in Python also means it's clear ! there is no possibility of such code being parsed by an earlier ! version of Python, leading to possibly subtle semantic bugs. ! ! For syntax options which use a list-like syntax (no matter where it ! appears) to specify the decorators a few alternatives were proposed: ! ``[|...|]``, ``*[...]*``, and ``<...>``. None gained much traction. ! The alternatives which involve square brackets only serve to make it obvious that the decorator construct is not a list. They do nothing to make parsing any easier. The '<...>' alternative presents parsing *************** *** 220,232 **** greater than symbol instead of a closer for the decorators. Current Implementation ====================== ! Michael Hudson posted a `patch`_ at Starship, which implements the ! proposed syntax changes for both functions and classes and left-first ! application of decorators:: ! def func(arg1, arg2, ...) [dec1, dec2]: pass --- 290,307 ---- greater than symbol instead of a closer for the decorators. + .. Javadoc comments: + http://java.sun.com/j2se/javadoc/writingdoccomments/ Current Implementation ====================== ! Guido asked for a voluteer to implement his preferred syntax, and Mark ! Russell stepped up and posted a `patch`_ to SF. The syntax accepted ! for 2.4a2 is:: ! ! @dec2 ! @dec1 ! def func(arg1, arg2, ...): pass *************** *** 239,243 **** though without the intermediate creation of a variable named ``func``. ! .. _patch: http://starship.python.net/crew/mwh/hacks/meth-syntax-sugar-3.diff --- 314,323 ---- though without the intermediate creation of a variable named ``func``. ! .. _patch: http://www.python.org/sf/979728 ! ! A `previous patch`_ from Michael Hudson which implements the ! list-after-def syntax is also still kicking around. ! ! .. _previous patch: http://starship.python.net/crew/mwh/hacks/meth-syntax-sugar-3.diff From tim_one at users.sourceforge.net Fri Aug 6 05:38:21 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 6 05:38:25 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.20, 1.36.2.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13474/Lib Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Spelling, punctuation, parallelism. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.20 retrieving revision 1.36.2.21 diff -C2 -d -r1.36.2.20 -r1.36.2.21 *** doctest.py 6 Aug 2004 02:13:41 -0000 1.36.2.20 --- doctest.py 6 Aug 2004 03:38:18 -0000 1.36.2.21 *************** *** 1564,1574 **** class DocTestFailure(Exception): ! """A DocTest example has failed in debugging mode ! The exeption instance has variables: ! - test: The DocTest object being run ! - excample: The Example object that failed - got: the actual output --- 1564,1574 ---- class DocTestFailure(Exception): ! """A DocTest example has failed in debugging mode. ! The exception instance has variables: ! - test: the DocTest object being run ! - excample: the Example object that failed - got: the actual output *************** *** 1580,1586 **** class DebugRunner(DocTestRunner): ! r"""Run doc tests but raie an exception as soon as there is a failure ! If an unexpected exception occurs, the exception is merely propigated to the caller: --- 1580,1586 ---- class DebugRunner(DocTestRunner): ! r"""Run doc tests but raise an exception as soon as there is a failure. ! If an unexpected exception occurs, the exception is merely propagated to the caller: *************** *** 1618,1622 **** >>> failure.got '1\n' - """ --- 1618,1621 ---- *************** *** 1863,1868 **** This is useful for slipping pre-existing test functions into the ! PyUnit framework. Optionally, set-up and tidy-up functions can be ! supplied. As with TestCase, the tidy-up ('tearDown') function will always be called if the set-up ('setUp') function ran successfully. """ --- 1862,1867 ---- This is useful for slipping pre-existing test functions into the ! PyUnit framework. Optionally, set-up and tidy-up functions can be ! supplied. As with TestCase, the tidy-up ('tearDown') function will always be called if the set-up ('setUp') function ran successfully. """ *************** *** 1933,1945 **** setUp=lambda: None, tearDown=lambda: None): """ ! Convert doctest tests for a mudule to a unittest test suite ! This tests convers each documentation string in a module that ! contains doctest tests to a unittest test case. If any of the ! tests in a doc string fail, then the test case fails. An error is ! raised showing the name of the file containing the test and a (sometimes approximate) line number. ! A module argument provides the module to be tested. The argument can be either a module or a module name. --- 1932,1944 ---- setUp=lambda: None, tearDown=lambda: None): """ ! Convert doctest tests for a mudule to a unittest test suite. ! This converts each documentation string in a module that ! contains doctest tests to a unittest test case. If any of the ! tests in a doc string fail, then the test case fails. An exception ! is raised showing the name of the file containing the test and a (sometimes approximate) line number. ! The `module` argument provides the module to be tested. The argument can be either a module or a module name. *************** *** 2017,2021 **** package ! The name of a Python package. Text-file paths will be interpreted relative to the directory containing this package. The package may be supplied as a package object or as a dotted --- 2016,2020 ---- package ! The name of a Python package. Text-file paths will be interpreted relative to the directory containing this package. The package may be supplied as a package object or as a dotted *************** *** 2023,2031 **** setUp ! The name of a set-up function. This is called before running the tests in each file. tearDown ! The name of a tear-down function. This is called after running the tests in each file. --- 2022,2030 ---- setUp ! The name of a set-up function. This is called before running the tests in each file. tearDown ! The name of a tear-down function. This is called after running the tests in each file. *************** *** 2050,2059 **** def script_from_examples(s): ! r"""Extract script from text with examples ! The script_from_examples function converts text with examples ! into a Python script. Example input is converted to regular ! code. Example output and all other words are converted to ! comments: >>> text = ''' --- 2049,2057 ---- def script_from_examples(s): ! r"""Extract script from text with examples. ! Converts text with examples to a Python script. Example input is ! converted to regular code. Example output and all other words ! are converted to comments: >>> text = ''' *************** *** 2113,2123 **** def _want_comment(example): """ ! Return a comment containing the expected output for the given ! example. """ # Return the expected output, if any want = example.want if want: ! if want[-1] == '\n': want = want[:-1] want = "\n# ".join(want.split("\n")) want = "\n# Expected:\n# %s" % want --- 2111,2121 ---- def _want_comment(example): """ ! Return a comment containing the expected output for the given example. """ # Return the expected output, if any want = example.want if want: ! if want[-1] == '\n': ! want = want[:-1] want = "\n# ".join(want.split("\n")) want = "\n# Expected:\n# %s" % want *************** *** 2125,2134 **** def testsource(module, name): ! """Extract the test sources from a doctest test docstring as a script Provide the module (or dotted name of the module) containing the test to be debugged and the name (within the module) of the object with the doc string with tests to be debugged. - """ module = _normalize_module(module) --- 2123,2131 ---- def testsource(module, name): ! """Extract the test sources from a doctest docstring as a script. Provide the module (or dotted name of the module) containing the test to be debugged and the name (within the module) of the object with the doc string with tests to be debugged. """ module = _normalize_module(module) *************** *** 2142,2154 **** def debug_src(src, pm=False, globs=None): ! """Debug a single doctest test doc string ! ! The string is provided directly ! """ testsrc = script_from_examples(src) debug_script(testsrc, pm, globs) def debug_script(src, pm=False, globs=None): ! "Debug a test script" import pdb --- 2139,2148 ---- def debug_src(src, pm=False, globs=None): ! """Debug a single doctest docstring, in argument `src`'""" testsrc = script_from_examples(src) debug_script(testsrc, pm, globs) def debug_script(src, pm=False, globs=None): ! "Debug a test script. `src` is the script, as a string." import pdb *************** *** 2175,2184 **** def debug(module, name, pm=False): ! """Debug a single doctest test doc string Provide the module (or dotted name of the module) containing the test to be debugged and the name (within the module) of the object ! with the doc string with tests to be debugged. ! """ module = _normalize_module(module) --- 2169,2177 ---- def debug(module, name, pm=False): ! """Debug a single doctest docstring. Provide the module (or dotted name of the module) containing the test to be debugged and the name (within the module) of the object ! with the docstring with tests to be debugged. """ module = _normalize_module(module) From montanaro at users.sourceforge.net Fri Aug 6 05:53:23 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Fri Aug 6 05:53:26 2004 Subject: [Python-checkins] python/nondist/peps pep-0318.txt,1.15,1.16 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15035 Modified Files: pep-0318.txt Log Message: some other minor updates Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** pep-0318.txt 6 Aug 2004 03:36:09 -0000 1.15 --- pep-0318.txt 6 Aug 2004 03:53:20 -0000 1.16 *************** *** 166,172 **** func = dec2(dec1(func)) ! The decorators are near the declaration of the function's API but are ! clearly secondary. The @ sign makes it clear that something new is ! going on here. The decorator statement is limited in what it can accept - arbitrary --- 166,172 ---- func = dec2(dec1(func)) ! without the intermediate assignment to the variable ``func``. The ! decorators are near the function declaration. The @ sign makes it ! clear that something new is going on here. The decorator statement is limited in what it can accept - arbitrary *************** *** 271,274 **** --- 271,282 ---- can be implemented in 2.3. + A `page on the Python Wiki`_ was created to summarize a number of the + proposals. Once it stabilizes perhaps someone would care to + incorporate its content into this PEP (hint, hint). + + .. page on the Python Wiki: + http://www.python.org/moin/PythonDecorators + + Why @? ------ *************** *** 341,345 **** return f ! def func() [onexit]: ... --- 349,354 ---- return f ! @onexit ! def func(): ... *************** *** 358,362 **** return getinstance ! class MyClass [singleton]: ... --- 367,372 ---- return getinstance ! @singleton ! class MyClass: ... *************** *** 373,378 **** return decorate ! def mymethod(f) [attrs(versionadded="2.2", ! author="Guido van Rossum")]: ... --- 383,389 ---- return decorate ! @attrs(versionadded="2.2", ! author="Guido van Rossum") ! def mymethod(f): ... *************** *** 404,409 **** return check_returns ! def func(arg1, arg2) [accepts(int, (int,float)), ! returns((int,float))]: return arg1 * arg2 --- 415,421 ---- return check_returns ! @accepts(int, (int,float)) ! @returns((int,float)) ! def func(arg1, arg2): return arg1 * arg2 *************** *** 430,437 **** """Declare something about IBar here""" ! class Foo(object) [provides(IBar)]: """Implement something here...""" ! Of course, all these examples are possible today, though without the syntactic support. --- 442,450 ---- """Declare something about IBar here""" ! @provides(IBar) ! class Foo(object): """Implement something here...""" ! Of course, all these examples are possible today, though without syntactic support. From bcannon at users.sourceforge.net Fri Aug 6 06:30:49 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Aug 6 06:30:55 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_timeout.py, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18522/Lib/test Modified Files: test_timeout.py Log Message: Changes the remote address used for tests in TimeoutTestCase from google.com to python.org . This way the delay should be great enough for testConnectTimeout() to pass even when one has a really fast Net connection that allows connections faster than .001 seconds. Index: test_timeout.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_timeout.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_timeout.py 11 Jun 2004 15:57:49 -0000 1.15 --- test_timeout.py 6 Aug 2004 04:30:46 -0000 1.16 *************** *** 101,105 **** def setUp(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! self.addr_remote = ('www.google.com', 80) self.addr_local = ('127.0.0.1', 25339) --- 101,105 ---- def setUp(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! self.addr_remote = ('www.python.org', 80) self.addr_local = ('127.0.0.1', 25339) From edloper at users.sourceforge.net Fri Aug 6 08:30:24 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Fri Aug 6 08:30:27 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.21, 1.36.2.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32501 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: - Added doctest_factory argument to DocTestFinder Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.21 retrieving revision 1.36.2.22 diff -C2 -d -r1.36.2.21 -r1.36.2.22 *** doctest.py 6 Aug 2004 03:38:18 -0000 1.36.2.21 --- doctest.py 6 Aug 2004 06:30:21 -0000 1.36.2.22 *************** *** 793,804 **** """ ! def __init__(self, verbose=False, namefilter=None, objfilter=None, ! recurse=True): """ Create a new doctest finder. If the optional argument `recurse` is false, then `find` will only examine the given object, and not any contained objects. """ self._verbose = verbose self._namefilter = namefilter --- 793,811 ---- """ ! def __init__(self, verbose=False, doctest_factory=DocTest, ! namefilter=None, objfilter=None, recurse=True): """ Create a new doctest finder. + The optional argument `doctest_factory` specifies a class or + function that should be used to create new DocTest objects (or + objects that implement the same interface as DocTest). This + signature for this factory function should match the signature + of the DocTest constructor. + If the optional argument `recurse` is false, then `find` will only examine the given object, and not any contained objects. """ + self._doctest_factory = doctest_factory self._verbose = verbose self._namefilter = namefilter *************** *** 1009,1013 **** else: filename = getattr(module, '__file__', module.__name__) ! return DocTest(docstring, globs, name, filename, lineno) def _find_lineno(self, obj, source_lines): --- 1016,1020 ---- else: filename = getattr(module, '__file__', module.__name__) ! return self._doctest_factory(docstring, globs, name, filename, lineno) def _find_lineno(self, obj, source_lines): From gvanrossum at users.sourceforge.net Fri Aug 6 16:27:56 2004 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri Aug 6 16:27:59 2004 Subject: [Python-checkins] python/nondist/peps pep-0318.txt,1.16,1.17 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6058 Modified Files: pep-0318.txt Log Message: Fix errors in references. Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** pep-0318.txt 6 Aug 2004 03:53:20 -0000 1.16 --- pep-0318.txt 6 Aug 2004 14:27:38 -0000 1.17 *************** *** 103,113 **** including `this piece`_ on the various rejected forms. ! .. EuroPython 2004: http://www.python.org/doc/essays/ppt/euro2004/euro2004.pdf ! .. outlined his case: http://mail.python.org/pipermail/python-dev/2004-August/authors.html ! .. this piece: http://mail.python.org/pipermail/python-dev/2004-August/046672.html --- 103,113 ---- including `this piece`_ on the various rejected forms. ! .. _EuroPython 2004: http://www.python.org/doc/essays/ppt/euro2004/euro2004.pdf ! .. _outlined his case: http://mail.python.org/pipermail/python-dev/2004-August/authors.html ! .. _this piece: http://mail.python.org/pipermail/python-dev/2004-August/046672.html *************** *** 146,150 **** `in his blog`_. ! .. in his blog: http://www.amk.ca/diary/archives/cat_python.html#003255 --- 146,150 ---- `in his blog`_. ! .. _in his blog: http://www.amk.ca/diary/archives/cat_python.html#003255 *************** *** 173,177 **** expressions will not work. Guido preferred this because of a `gut feeling`_ ! .. gut feeling: http://mail.python.org/pipermail/python-dev/2004-August/046711.html --- 173,177 ---- expressions will not work. Guido preferred this because of a `gut feeling`_ ! .. _gut feeling: http://mail.python.org/pipermail/python-dev/2004-August/046711.html *************** *** 253,257 **** that the decorators would be 'hidden' ! .. he preferred: http://mail.python.org/pipermail/python-dev/2004-March/043756.html --- 253,257 ---- that the decorators would be 'hidden' ! .. _he preferred: http://mail.python.org/pipermail/python-dev/2004-March/043756.html *************** *** 275,279 **** incorporate its content into this PEP (hint, hint). ! .. page on the Python Wiki: http://www.python.org/moin/PythonDecorators --- 275,279 ---- incorporate its content into this PEP (hint, hint). ! .. _page on the Python Wiki: http://www.python.org/moin/PythonDecorators *************** *** 298,302 **** greater than symbol instead of a closer for the decorators. ! .. Javadoc comments: http://java.sun.com/j2se/javadoc/writingdoccomments/ --- 298,302 ---- greater than symbol instead of a closer for the decorators. ! .. _Javadoc comments: http://java.sun.com/j2se/javadoc/writingdoccomments/ From dcjim at users.sourceforge.net Fri Aug 6 16:32:53 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Fri Aug 6 16:32:56 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.22, 1.36.2.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6902 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Shortened some class names. Added a test for the DocTestCase debug method, and debugged the resulting failure. :) Also changed the signature to DocTestCase.__init__ so it accepts optionflags rather than a runner. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.22 retrieving revision 1.36.2.23 diff -C2 -d -r1.36.2.22 -r1.36.2.23 *** doctest.py 6 Aug 2004 06:30:21 -0000 1.36.2.22 --- doctest.py 6 Aug 2004 14:32:50 -0000 1.36.2.23 *************** *** 297,301 **** 'run_docstring_examples', 'Tester', ! 'DocTestTestCase', 'DocTestSuite', 'testsource', --- 297,301 ---- 'run_docstring_examples', 'Tester', ! 'DocTestCase', 'DocTestSuite', 'testsource', *************** *** 1601,1610 **** If the output doesn't match, then a DocTestFailure is raised: ! >>> try: ! ... test = DocTest(''' ... >>> x = 1 ... >>> x ... 2 ... ''', {}, 'foo', 'foo.py', 0) ... runner.run(test) ... except DocTestFailure, failure: --- 1601,1611 ---- If the output doesn't match, then a DocTestFailure is raised: ! >>> test = DocTest(''' ... >>> x = 1 ... >>> x ... 2 ... ''', {}, 'foo', 'foo.py', 0) + + >>> try: ... runner.run(test) ... except DocTestFailure, failure: *************** *** 1865,1892 **** ###################################################################### ! class DocTestTestCase(unittest.TestCase): ! """A test case that wraps a test function. ! ! This is useful for slipping pre-existing test functions into the ! PyUnit framework. Optionally, set-up and tidy-up functions can be ! supplied. As with TestCase, the tidy-up ('tearDown') function will ! always be called if the set-up ('setUp') function ran successfully. ! """ ! def __init__(self, test_runner, test, ! setUp=None, tearDown=None): unittest.TestCase.__init__(self) ! self.__test_runner = test_runner self._dt_test = test ! self.__setUp = setUp ! self.__tearDown = tearDown def setUp(self): ! if self.__setUp is not None: ! self.__setUp() def tearDown(self): ! if self.__tearDown is not None: ! self.__tearDown() def runTest(self): --- 1866,1885 ---- ###################################################################### ! class DocTestCase(unittest.TestCase): ! def __init__(self, test, optionflags=0, setUp=None, tearDown=None): unittest.TestCase.__init__(self) ! self._dt_optionflags = optionflags self._dt_test = test ! self._dt_setUp = setUp ! self._dt_tearDown = tearDown def setUp(self): ! if self._dt_setUp is not None: ! self._dt_setUp() def tearDown(self): ! if self._dt_tearDown is not None: ! self._dt_tearDown() def runTest(self): *************** *** 1894,1900 **** old = sys.stdout new = StringIO() try: ! self.__test_runner.DIVIDER = "-"*70 ! failures, tries = self.__test_runner.run(test, out=new.write) finally: sys.stdout = old --- 1887,1895 ---- old = sys.stdout new = StringIO() + runner = DocTestRunner(optionflags=self._dt_optionflags, verbose=False) + try: ! runner.DIVIDER = "-"*70 ! failures, tries = runner.run(test, out=new.write) finally: sys.stdout = old *************** *** 1916,1922 **** def debug(self): ! runner = DebugRunner(verbose=False, ! optionflags=self.__test_runner.optionflags) ! runner.run(self._dt_test, nooutput) def id(self): --- 1911,1961 ---- def debug(self): ! r"""Run the test case without results and without catching exceptions ! ! The unit test framework includes a debug method on test cases ! and test suites to support post-mortem debugging. The test code ! is run in such a way that errors are not caught. This way a ! caller can catch the errors and initiate post-mortem debugging: ! ! >>> test = DocTest('>>> raise KeyError', {}, 'foo', 'foo.py', 0) ! >>> case = DocTestCase(test) ! >>> case.debug() ! Traceback (most recent call last): ! ... ! KeyError ! ! If the output doesn't match, then a DocTestFailure is raised: ! ! >>> test = DocTest(''' ! ... >>> x = 1 ! ... >>> x ! ... 2 ! ... ''', {}, 'foo', 'foo.py', 0) ! >>> case = DocTestCase(test) ! ! >>> try: ! ... case.debug() ! ... except DocTestFailure, failure: ! ... pass ! ! DocTestFailure objects provide access to the test: ! ! >>> failure.test is test ! True ! ! As well as to the example: ! ! >>> failure.example.want ! '2\n' ! ! and the actual output: ! ! >>> failure.got ! '1\n' ! ! """ ! ! runner = DebugRunner(verbose = False, optionflags=self._dt_optionflags) ! runner.run(self._dt_test, out=nooutput) def id(self): *************** *** 1955,1959 **** if test_finder is None: test_finder = DocTestFinder() - test_runner = DocTestRunner(optionflags=optionflags, verbose=False) module = _normalize_module(module) --- 1994,1997 ---- *************** *** 1976,1985 **** filename = filename[:-1] test.filename = filename ! suite.addTest(DocTestTestCase(test_runner, test, ! setUp, tearDown)) return suite ! class DocTestFileTestCase(DocTestTestCase): def id(self): --- 2014,2022 ---- filename = filename[:-1] test.filename = filename ! suite.addTest(DocTestCase(test, optionflags, setUp, tearDown)) return suite ! class DocFileCase(DocTestCase): def id(self): *************** *** 2007,2014 **** globs = {} - test_runner = DocTestRunner(optionflags=optionflags, verbose=False) test = DocTest(doc, globs, name, path, 0) ! ! return DocTestFileTestCase(test_runner, test, setUp, tearDown) def DocFileSuite(*paths, **kw): --- 2044,2050 ---- globs = {} test = DocTest(doc, globs, name, path, 0) ! ! return DocFileCase(test, optionflags, setUp, tearDown) def DocFileSuite(*paths, **kw): From anthonybaxter at users.sourceforge.net Fri Aug 6 18:02:45 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Fri Aug 6 18:03:06 2004 Subject: [Python-checkins] python/nondist/peps pep-0318.txt, 1.17, 1.18 pep-0000.txt, 1.276, 1.277 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24637 Modified Files: pep-0318.txt pep-0000.txt Log Message: classes, no, functions yes Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** pep-0318.txt 6 Aug 2004 14:27:38 -0000 1.17 --- pep-0318.txt 6 Aug 2004 16:02:42 -0000 1.18 *************** *** 1,4 **** PEP: 318 ! Title: Decorators for Functions, Methods and Classes Version: $Revision$ Last-Modified: $Date$ --- 1,4 ---- PEP: 318 ! Title: Decorators for Functions and Methods Version: $Revision$ Last-Modified: $Date$ Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.276 retrieving revision 1.277 diff -C2 -d -r1.276 -r1.277 *** pep-0000.txt 3 Aug 2004 13:13:43 -0000 1.276 --- pep-0000.txt 6 Aug 2004 16:02:42 -0000 1.277 *************** *** 116,120 **** S 314 Metadata for Python Software Packages v1.1 Kuchling S 315 Enhanced While Loop Carroll ! S 318 Decorators for Functions, Methods & Classes Smith, et al S 319 Python Synchronize/Asynchronize Block Pelletier S 321 Date/Time Parsing and Formatting Kuchling --- 116,120 ---- S 314 Metadata for Python Software Packages v1.1 Kuchling S 315 Enhanced While Loop Carroll ! S 318 Decorators for Functions and Methods Smith, et al S 319 Python Synchronize/Asynchronize Block Pelletier S 321 Date/Time Parsing and Formatting Kuchling From montanaro at users.sourceforge.net Fri Aug 6 20:34:17 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Fri Aug 6 20:34:19 2004 Subject: [Python-checkins] python/nondist/peps pep-0318.txt,1.18,1.19 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21415 Modified Files: pep-0318.txt Log Message: add Guido's comment about nested decorator problems Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** pep-0318.txt 6 Aug 2004 16:02:42 -0000 1.18 --- pep-0318.txt 6 Aug 2004 18:34:15 -0000 1.19 *************** *** 230,233 **** --- 230,251 ---- it would require the introduction of a new keyword. + The obvious alternative that nests the function within the block + + :: + + using: + dec1 + dec2 + ... + def foo(arg1, arg2, ...): + pass + + has its own set of drawbacks. Having the minimal indent level be + three deep for methods is painful for those using limited-width + windows. The inconsistent indentation between methods of the same + class with and without decorators would be a readability problem. + Finally, adding or removing decorators would require reindenting the + entire function/method body. + Guido proposed and implementated a patch to support interpretation of a `list of decorators`_ as a prefix to function definitions :: *************** *** 286,290 **** @ was previously unused as a token in Python also means it's clear there is no possibility of such code being parsed by an earlier ! version of Python, leading to possibly subtle semantic bugs. For syntax options which use a list-like syntax (no matter where it --- 304,310 ---- @ was previously unused as a token in Python also means it's clear there is no possibility of such code being parsed by an earlier ! version of Python, leading to possibly subtle semantic bugs. That ! said, @ is still a fairly arbitrary choice. Some have suggested using ! | instead. For syntax options which use a list-like syntax (no matter where it From rhettinger at users.sourceforge.net Fri Aug 6 20:43:11 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Aug 6 20:43:14 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1073,1.1074 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23183/Misc Modified Files: NEWS Log Message: SF patch #980695: efficient string concatenation (Original patch by Armin Rigo). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1073 retrieving revision 1.1074 diff -C2 -d -r1.1073 -r1.1074 *** NEWS 5 Aug 2004 12:43:29 -0000 1.1073 --- NEWS 6 Aug 2004 18:43:08 -0000 1.1074 *************** *** 13,16 **** --- 13,21 ---- ----------------- + - Patch #980695: Implements efficient string concatenation for statements + of the form s=s+t and s+=t. This will vary across implementations. + Accordingly, the str.join() method is strongly preferred for performance + sensitive code. + - PEP-0318, Function Decorators have been added to the language. These are implemented using the Java-style @decorator syntax, like so: From rhettinger at users.sourceforge.net Fri Aug 6 20:43:12 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Aug 6 20:43:15 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.159, 1.160 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23183/Doc/lib Modified Files: libstdtypes.tex Log Message: SF patch #980695: efficient string concatenation (Original patch by Armin Rigo). Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.159 retrieving revision 1.160 diff -C2 -d -r1.159 -r1.160 *** libstdtypes.tex 4 Aug 2004 07:38:33 -0000 1.159 --- libstdtypes.tex 6 Aug 2004 18:43:09 -0000 1.160 *************** *** 456,460 **** equal to \var{x}, else \code{1}}{(1)} \hline ! \lineiii{\var{s} + \var{t}}{the concatenation of \var{s} and \var{t}}{} \lineiii{\var{s} * \var{n}\textrm{,} \var{n} * \var{s}}{\var{n} shallow copies of \var{s} concatenated}{(2)} \hline --- 456,460 ---- equal to \var{x}, else \code{1}}{(1)} \hline ! \lineiii{\var{s} + \var{t}}{the concatenation of \var{s} and \var{t}}{(6)} \lineiii{\var{s} * \var{n}\textrm{,} \var{n} * \var{s}}{\var{n} shallow copies of \var{s} concatenated}{(2)} \hline *************** *** 537,540 **** --- 537,550 ---- be zero. + \item[(6)] If \var{s} and \var{t} are both strings, some Python + implementations such as CPython can usally perform an inplace optimization + for assignments of the form \code{\var{s}=\var{s}+\var{t}} or + \code{\var{s}+=\var{t}}. When applicable, this optimization makes + quadratic run-time much less likely. This optimization is both version + and implementation dependent. For performance sensitive code, it is + preferrable to use the \method{str.join()} method which assures consistent + linear concatenation performance across versions and implementations. + \versionchanged[Formerly, string concatenation never occurred inplace]{2.4} + \end{description} From rhettinger at users.sourceforge.net Fri Aug 6 20:43:12 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Aug 6 20:43:17 2004 Subject: [Python-checkins] python/dist/src/Python ceval.c,2.412,2.413 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23183/Python Modified Files: ceval.c Log Message: SF patch #980695: efficient string concatenation (Original patch by Armin Rigo). Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.412 retrieving revision 2.413 diff -C2 -d -r2.412 -r2.413 *** ceval.c 2 Aug 2004 14:50:43 -0000 2.412 --- ceval.c 6 Aug 2004 18:43:09 -0000 2.413 *************** *** 86,89 **** --- 86,91 ---- static void reset_exc_info(PyThreadState *); static void format_exc_check_arg(PyObject *, char *, PyObject *); + static PyObject *string_concatenate(PyObject *, PyObject *, + PyFrameObject *, unsigned char *); #define NAME_ERROR_MSG \ *************** *** 551,554 **** --- 553,557 ---- #define NEXTOP() (*next_instr++) #define NEXTARG() (next_instr += 2, (next_instr[-1]<<8) + next_instr[-2]) + #define PEEKARG() ((next_instr[2]<<8) + next_instr[1]) #define JUMPTO(x) (next_instr = first_instr + (x)) #define JUMPBY(x) (next_instr += (x)) *************** *** 581,586 **** #define PREDICTED(op) PRED_##op: next_instr++ ! #define PREDICTED_WITH_ARG(op) PRED_##op: oparg = (next_instr[2]<<8) + \ ! next_instr[1]; next_instr += 3 /* Stack manipulation macros */ --- 584,588 ---- #define PREDICTED(op) PRED_##op: next_instr++ ! #define PREDICTED_WITH_ARG(op) PRED_##op: oparg = PEEKARG(); next_instr += 3 /* Stack manipulation macros */ *************** *** 1067,1070 **** --- 1069,1078 ---- x = PyInt_FromLong(i); } + else if (PyString_CheckExact(v) && + PyString_CheckExact(w)) { + x = string_concatenate(v, w, f, next_instr); + /* string_concatenate consumed the ref to v */ + goto skip_decref_vx; + } else { slow_add: *************** *** 1072,1075 **** --- 1080,1084 ---- } Py_DECREF(v); + skip_decref_vx: Py_DECREF(w); SET_TOP(x); *************** *** 1262,1265 **** --- 1271,1280 ---- x = PyInt_FromLong(i); } + else if (PyString_CheckExact(v) && + PyString_CheckExact(w)) { + x = string_concatenate(v, w, f, next_instr); + /* string_concatenate consumed the ref to v */ + goto skip_decref_v; + } else { slow_iadd: *************** *** 1267,1270 **** --- 1282,1286 ---- } Py_DECREF(v); + skip_decref_v: Py_DECREF(w); SET_TOP(x); *************** *** 4192,4195 **** --- 4208,4284 ---- } + static PyObject * + string_concatenate(PyObject *v, PyObject *w, + PyFrameObject *f, unsigned char *next_instr) + { + /* This function implements 'variable += expr' when both arguments + are strings. */ + + if (v->ob_refcnt == 2) { + /* In the common case, there are 2 references to the value + * stored in 'variable' when the += is performed: one on the + * value stack (in 'v') and one still stored in the 'variable'. + * We try to delete the variable now to reduce the refcnt to 1. + */ + switch (*next_instr) { + case STORE_FAST: + { + int oparg = PEEKARG(); + PyObject **fastlocals = f->f_localsplus; + if (GETLOCAL(oparg) == v) + SETLOCAL(oparg, NULL); + break; + } + case STORE_DEREF: + { + PyObject **freevars = f->f_localsplus + f->f_nlocals; + PyObject *c = freevars[PEEKARG()]; + if (PyCell_GET(c) == v) + PyCell_Set(c, NULL); + break; + } + case STORE_NAME: + { + PyObject *names = f->f_code->co_names; + PyObject *name = GETITEM(names, PEEKARG()); + PyObject *locals = f->f_locals; + if (PyDict_CheckExact(locals) && + PyDict_GetItem(locals, name) == v) { + if (PyDict_DelItem(locals, name) != 0) { + PyErr_Clear(); + } + } + break; + } + } + } + + if (v->ob_refcnt == 1) { + /* Now we own the last reference to 'v', so we can resize it + * in-place. + */ + int v_len = PyString_GET_SIZE(v); + int w_len = PyString_GET_SIZE(w); + if (_PyString_Resize(&v, v_len + w_len) != 0) { + /* XXX if _PyString_Resize() fails, 'v' has been + * deallocated so it cannot be put back into 'variable'. + * The MemoryError is raised when there is no value in + * 'variable', which might (very remotely) be a cause + * of incompatibilities. + */ + return NULL; + } + /* copy 'w' into the newly allocated area of 'v' */ + memcpy(PyString_AS_STRING(v) + v_len, + PyString_AS_STRING(w), w_len); + return v; + } + else { + /* When in-place resizing is not an option. */ + PyString_Concat(&v, w); + return v; + } + } + #ifdef DYNAMIC_EXECUTION_PROFILE From rhettinger at users.sourceforge.net Fri Aug 6 20:47:28 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Aug 6 20:47:31 2004 Subject: [Python-checkins] python/nondist/peps pep-0008.txt,1.24,1.25 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24377 Modified Files: pep-0008.txt Log Message: SF patch #980695: efficient string concatenation (Original patch by Armin Rigo). Index: pep-0008.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0008.txt,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** pep-0008.txt 30 Mar 2004 01:12:22 -0000 1.24 --- pep-0008.txt 6 Aug 2004 18:47:26 -0000 1.25 *************** *** 522,525 **** --- 522,534 ---- Programming Recommendations + - Code should be written in a way that does not disadvantage other + implementations of Python (PyPy, Jython, IronPython, Pyrex, Psyco, + and such). For example, do not rely on CPython's efficient + implementation of in-place string concatenation for statements in + the form a+=b or a=a+b. Those statements run more slowly in + Jython. In performance sensitive parts of the library, the + ''.join() form should be used instead. This will assure that + concatenation occurs in linear time across various implementations. + - Comparisons to singletons like None should always be done with 'is' or 'is not'. Also, beware of writing "if x" when you From dcjim at users.sourceforge.net Fri Aug 6 20:48:46 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Fri Aug 6 20:48:48 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.23, 1.36.2.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24744 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: The debug runer was always clearing the test globs. We need to keep them around if there is an error. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.23 retrieving revision 1.36.2.24 diff -C2 -d -r1.36.2.23 -r1.36.2.24 *** doctest.py 6 Aug 2004 14:32:50 -0000 1.36.2.23 --- doctest.py 6 Aug 2004 18:48:43 -0000 1.36.2.24 *************** *** 1586,1589 **** --- 1586,1594 ---- self.got = got + def __str__(self): + return str(self.test) + + + class DebugRunner(DocTestRunner): r"""Run doc tests but raise an exception as soon as there is a failure. *************** *** 1626,1631 **** --- 1631,1676 ---- >>> failure.got '1\n' + + If a failure or error occurs, the globals are left intact: + + >>> del test.globs['__builtins__'] + >>> test.globs + {'x': 1} + + >>> test = DocTest(''' + ... >>> x = 2 + ... >>> raise KeyError + ... ''', {}, 'foo', 'foo.py', 0) + + >>> runner.run(test) + Traceback (most recent call last): + ... + KeyError + + >>> del test.globs['__builtins__'] + >>> test.globs + {'x': 2} + + But the globals are cleared if there is no error: + + >>> test = DocTest(''' + ... >>> x = 2 + ... ''', {}, 'foo', 'foo.py', 0) + + >>> runner.run(test) + (0, 1) + + >>> test.globs + {} + + """ + def run(self, test, compileflags=None, out=None, clear_globs=True): + r = DocTestRunner.run(self, test, compileflags, out, False) + if clear_globs: + test.globs.clear() + return r + def report_unexpected_exception(self, out, test, example, exc_info): raise exc_info[0], exc_info[1], exc_info[2] From akuchling at users.sourceforge.net Fri Aug 6 20:55:12 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Fri Aug 6 20:55:15 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.160, 1.161 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25966 Modified Files: libstdtypes.tex Log Message: Typo fix; use 'in-place' instead of 'inplace' Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.160 retrieving revision 1.161 diff -C2 -d -r1.160 -r1.161 *** libstdtypes.tex 6 Aug 2004 18:43:09 -0000 1.160 --- libstdtypes.tex 6 Aug 2004 18:55:09 -0000 1.161 *************** *** 538,542 **** \item[(6)] If \var{s} and \var{t} are both strings, some Python ! implementations such as CPython can usally perform an inplace optimization for assignments of the form \code{\var{s}=\var{s}+\var{t}} or \code{\var{s}+=\var{t}}. When applicable, this optimization makes --- 538,542 ---- \item[(6)] If \var{s} and \var{t} are both strings, some Python ! implementations such as CPython can usually perform an in-place optimization for assignments of the form \code{\var{s}=\var{s}+\var{t}} or \code{\var{s}+=\var{t}}. When applicable, this optimization makes *************** *** 545,549 **** preferrable to use the \method{str.join()} method which assures consistent linear concatenation performance across versions and implementations. ! \versionchanged[Formerly, string concatenation never occurred inplace]{2.4} \end{description} --- 545,549 ---- preferrable to use the \method{str.join()} method which assures consistent linear concatenation performance across versions and implementations. ! \versionchanged[Formerly, string concatenation never occurred in-place]{2.4} \end{description} From akuchling at users.sourceforge.net Fri Aug 6 20:55:59 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Fri Aug 6 20:56:01 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.81, 1.82 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26079 Modified Files: whatsnew24.tex Log Message: Bump version Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** whatsnew24.tex 6 Aug 2004 03:34:20 -0000 1.81 --- whatsnew24.tex 6 Aug 2004 18:55:48 -0000 1.82 *************** *** 11,15 **** \title{What's New in Python 2.4} ! \release{0.2} \author{A.M.\ Kuchling} \authoraddress{ --- 11,15 ---- \title{What's New in Python 2.4} ! \release{0.3} \author{A.M.\ Kuchling} \authoraddress{ From rhettinger at users.sourceforge.net Fri Aug 6 21:46:38 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Aug 6 21:46:41 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.313,2.314 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1586 Modified Files: compile.c Log Message: SF bug #1004088: big code objects (>64K) may be optimized incorrectly Will backport. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.313 retrieving revision 2.314 diff -C2 -d -r2.313 -r2.314 *** compile.c 4 Aug 2004 10:26:08 -0000 2.313 --- compile.c 6 Aug 2004 19:46:34 -0000 2.314 *************** *** 380,383 **** --- 380,388 ---- goto exitUnchanged; codestr = memcpy(codestr, PyString_AS_STRING(code), codelen); + + /* Avoid situations where jump retargeting could overflow */ + if (codelen > 65000) + goto exitUnchanged; + blocks = markblocks(codestr, codelen); if (blocks == NULL) { From tim_one at users.sourceforge.net Fri Aug 6 21:53:03 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 6 21:53:07 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.24, 1.36.2.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2308/Lib Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Removed the comment before globs.clear(). It's no longer true that Python gc doesn't chase frame objects. Plus accidental trailing-whitespace trimming (my editor does this). Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.24 retrieving revision 1.36.2.25 diff -C2 -d -r1.36.2.24 -r1.36.2.25 *** doctest.py 6 Aug 2004 18:48:43 -0000 1.36.2.24 --- doctest.py 6 Aug 2004 19:53:00 -0000 1.36.2.25 *************** *** 793,797 **** """ ! def __init__(self, verbose=False, doctest_factory=DocTest, namefilter=None, objfilter=None, recurse=True): """ --- 793,797 ---- """ ! def __init__(self, verbose=False, doctest_factory=DocTest, namefilter=None, objfilter=None, recurse=True): """ *************** *** 1502,1513 **** finally: sys.stdout = saveout - # While Python gc can clean up most cycles on its own, it doesn't - # chase frame objects. This is especially irksome when running - # generator tests that raise exceptions, because a named generator- - # iterator gets an entry in globs, and the generator-iterator - # object's frame's traceback info points back to globs. This is - # easy to break just by clearing the namespace. This can also - # help to break other kinds of cycles, and even for cycles that - # gc can break itself it's better to break them ASAP. if clear_globs: test.globs.clear() --- 1502,1505 ---- *************** *** 1589,1594 **** return str(self.test) ! ! class DebugRunner(DocTestRunner): r"""Run doc tests but raise an exception as soon as there is a failure. --- 1581,1586 ---- return str(self.test) ! ! class DebugRunner(DocTestRunner): r"""Run doc tests but raise an exception as soon as there is a failure. *************** *** 1637,1641 **** >>> test.globs {'x': 1} ! >>> test = DocTest(''' ... >>> x = 2 --- 1629,1633 ---- >>> test.globs {'x': 1} ! >>> test = DocTest(''' ... >>> x = 2 *************** *** 1660,1667 **** >>> runner.run(test) (0, 1) ! >>> test.globs {} ! """ --- 1652,1659 ---- >>> runner.run(test) (0, 1) ! >>> test.globs {} ! """ *************** *** 2090,2094 **** test = DocTest(doc, globs, name, path, 0) ! return DocFileCase(test, optionflags, setUp, tearDown) --- 2082,2086 ---- test = DocTest(doc, globs, name, path, 0) ! return DocFileCase(test, optionflags, setUp, tearDown) From dcjim at users.sourceforge.net Fri Aug 6 22:26:49 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Fri Aug 6 22:26:52 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py, 1.36.2.25, 1.36.2.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7551 Modified Files: Tag: tim-doctest-branch doctest.py Log Message: Changed the way the debug runner handes unexpected exceptions. Now wrap the original exception in an UnexpectedException, which gives the caller access to test and example data. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.36.2.25 retrieving revision 1.36.2.26 diff -C2 -d -r1.36.2.25 -r1.36.2.26 *** doctest.py 6 Aug 2004 19:53:00 -0000 1.36.2.25 --- doctest.py 6 Aug 2004 20:26:46 -0000 1.36.2.26 *************** *** 1581,1599 **** return str(self.test) class DebugRunner(DocTestRunner): r"""Run doc tests but raise an exception as soon as there is a failure. ! If an unexpected exception occurs, the exception is merely propagated ! to the caller: >>> runner = DebugRunner(verbose=False) ! >>> test = DocTest('>>> raise KeyError', {}, 'foo', 'foo.py', 0) ! >>> runner.run(test) Traceback (most recent call last): ... KeyError If the output doesn't match, then a DocTestFailure is raised: --- 1581,1631 ---- return str(self.test) + class UnexpectedException(Exception): + """A DocTest example has encountered an unexpected exception + + The exception instance has variables: + + - test: the DocTest object being run + - excample: the Example object that failed + - exc_info: the exception info + """ + def __init__(self, test, example, exc_info): + self.test = test + self.example = example + self.exc_info = exc_info + + def __str__(self): + return str(self.test) + class DebugRunner(DocTestRunner): r"""Run doc tests but raise an exception as soon as there is a failure. ! If an unexpected exception occurs, an UnexpectedException is raised. ! It contains the test, the example, and the original exception: >>> runner = DebugRunner(verbose=False) ! >>> test = DocTest('>>> raise KeyError\n42', {}, 'foo', 'foo.py', 0) ! >>> try: ! ... runner.run(test) ! ... except UnexpectedException, failure: ! ... pass ! ! >>> failure.test is test ! True ! ! >>> failure.example.want ! '42\n' ! ! >>> exc_info = failure.exc_info ! >>> raise exc_info[0], exc_info[1], exc_info[2] Traceback (most recent call last): ... KeyError + We wrap the original exception to give the calling application + access to the test and example information. + If the output doesn't match, then a DocTestFailure is raised: *************** *** 1638,1643 **** Traceback (most recent call last): ... ! KeyError ! >>> del test.globs['__builtins__'] >>> test.globs --- 1670,1675 ---- Traceback (most recent call last): ... ! UnexpectedException: ! >>> del test.globs['__builtins__'] >>> test.globs *************** *** 1656,1660 **** {} - """ --- 1688,1691 ---- *************** *** 1666,1670 **** def report_unexpected_exception(self, out, test, example, exc_info): ! raise exc_info[0], exc_info[1], exc_info[2] def report_failure(self, out, test, example, got): --- 1697,1701 ---- def report_unexpected_exception(self, out, test, example, exc_info): ! raise UnexpectedException(test, example, exc_info) def report_failure(self, out, test, example, got): *************** *** 1953,1961 **** and test suites to support post-mortem debugging. The test code is run in such a way that errors are not caught. This way a ! caller can catch the errors and initiate post-mortem debugging: ! >>> test = DocTest('>>> raise KeyError', {}, 'foo', 'foo.py', 0) >>> case = DocTestCase(test) ! >>> case.debug() Traceback (most recent call last): ... --- 1984,2012 ---- and test suites to support post-mortem debugging. The test code is run in such a way that errors are not caught. This way a ! caller can catch the errors and initiate post-mortem debugging. ! The DocTestCase provides a debug method that raises ! UnexpectedException errors if there is an unexepcted ! exception: ! ! >>> test = DocTest('>>> raise KeyError\n42', ! ... {}, 'foo', 'foo.py', 0) >>> case = DocTestCase(test) ! >>> try: ! ... case.debug() ! ... except UnexpectedException, failure: ! ... pass ! ! The UnexpectedException contains the test, the example, and ! the original exception: ! ! >>> failure.test is test ! True ! ! >>> failure.example.want ! '42\n' ! ! >>> exc_info = failure.exc_info ! >>> raise exc_info[0], exc_info[1], exc_info[2] Traceback (most recent call last): ... From rhettinger at users.sourceforge.net Fri Aug 6 23:29:25 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Aug 6 23:29:29 2004 Subject: [Python-checkins] python/dist/src/Python compile.c, 2.291.6.2, 2.291.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18434 Modified Files: Tag: release23-maint compile.c Log Message: Backport SF bug #1004088: big code objects (>64K) may be optimized incorrectly Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.291.6.2 retrieving revision 2.291.6.3 diff -C2 -d -r2.291.6.2 -r2.291.6.3 *** compile.c 22 Sep 2003 04:41:21 -0000 2.291.6.2 --- compile.c 6 Aug 2004 21:29:22 -0000 2.291.6.3 *************** *** 346,349 **** --- 346,353 ---- assert(PyTuple_Check(consts)); + /* Avoid situations where jump retargeting could overflow */ + if (codelen > 65000) + goto exitUnchanged; + for (i=0 ; i Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23152/Lib Modified Files: doctest.py Log Message: Merging from tim-doctest-branch, which is now closed. This primarily adds more powerful ways to work with unittest, including spiffy support for building suites out of doctests in non-Python "text files". Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** doctest.py 4 Aug 2004 20:04:31 -0000 1.38 --- doctest.py 6 Aug 2004 22:02:59 -0000 1.39 *************** *** 1,5 **** # Module doctest. # Released to the public domain 16-Jan-2001, by Tim Peters (tim@python.org). ! # Significant enhancements by: # Jim Fulton # Edward Loper --- 1,5 ---- # Module doctest. # Released to the public domain 16-Jan-2001, by Tim Peters (tim@python.org). ! # Major enhancements and refactoring by: # Jim Fulton [...1135 lines suppressed...] def debug(module, name, pm=False): ! """Debug a single doctest test doc string Provide the module (or dotted name of the module) containing the test to be debugged and the name (within the module) of the object ! with the doc string with tests to be debugged. ! """ module = _normalize_module(module) --- 2303,2311 ---- def debug(module, name, pm=False): ! """Debug a single doctest docstring. Provide the module (or dotted name of the module) containing the test to be debugged and the name (within the module) of the object ! with the docstring with tests to be debugged. """ module = _normalize_module(module) From tim_one at users.sourceforge.net Sat Aug 7 00:03:03 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Aug 7 00:03:07 2004 Subject: [Python-checkins] python/dist/src/Lib/test sample_doctest.py, 1.1, 1.2 test_doctest.txt, 1.1, 1.2 test_doctest2.txt, 1.1, 1.2 test_doctest.py, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23152/Lib/test Modified Files: test_doctest.py Added Files: sample_doctest.py test_doctest.txt test_doctest2.txt Log Message: Merging from tim-doctest-branch, which is now closed. This primarily adds more powerful ways to work with unittest, including spiffy support for building suites out of doctests in non-Python "text files". Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_doctest.py 4 Aug 2004 20:04:32 -0000 1.7 --- test_doctest.py 6 Aug 2004 22:02:59 -0000 1.8 *************** *** 12,17 **** --- 12,21 ---- def sample_func(v): """ + Blah blah + >>> print sample_func(22) 44 + + Yee ha! """ return v+v *************** *** 253,257 **** >>> e = tests[0].examples[0] >>> print (e.source, e.want, e.lineno) ! ('print sample_func(22)', '44\n', 1) >>> doctest: -ELLIPSIS # Turn ellipsis back off --- 257,261 ---- >>> e = tests[0].examples[0] >>> print (e.source, e.want, e.lineno) ! ('print sample_func(22)', '44\n', 3) >>> doctest: -ELLIPSIS # Turn ellipsis back off *************** *** 913,924 **** The testsource() function takes a module and a name, finds the (first) ! test with that name in that module, and converts it to an >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) print sample_func(22) # Expected: # 44 >>> name = 'test.test_doctest.SampleNewStyleClass' --- 917,934 ---- The testsource() function takes a module and a name, finds the (first) ! test with that name in that module, and converts it to a script. The ! example code is converted to regular Python code. The surrounding ! words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) + # Blah blah + # print sample_func(22) # Expected: # 44 + # + # Yee ha! >>> name = 'test.test_doctest.SampleNewStyleClass' *************** *** 976,979 **** --- 986,1154 ---- """ + def test_DocTestSuite(): + """DocTestSuite creates a unittest test suite into a doctest. + + We create a Suite by providing a module. A module can be provided + by passing a module object: + + >>> import unittest + >>> import test.sample_doctest + >>> suite = doctest.DocTestSuite(test.sample_doctest) + >>> suite.run(unittest.TestResult()) + + + We can also supply the module by name: + + >>> suite = doctest.DocTestSuite('test.sample_doctest') + >>> suite.run(unittest.TestResult()) + + + We can use the current module: + + >>> suite = test.sample_doctest.test_suite() + >>> suite.run(unittest.TestResult()) + + + We can supply global variables. If we pass globs, they will be + used instead of the module globals. Here we'll pass an empty + globals, triggering an extra error: + + >>> suite = doctest.DocTestSuite('test.sample_doctest', globs={}) + >>> suite.run(unittest.TestResult()) + + + Alternatively, we can provide extra globals. Here we'll make an + error go away by providing an extra global variable: + + >>> suite = doctest.DocTestSuite('test.sample_doctest', + ... extraglobs={'y': 1}) + >>> suite.run(unittest.TestResult()) + + + You can pass option flags. Here we'll cause an extra error + by disabling the blank-line feature: + + >>> suite = doctest.DocTestSuite('test.sample_doctest', + ... optionflags=doctest.DONT_ACCEPT_BLANKLINE) + >>> suite.run(unittest.TestResult()) + + + You can supply setUp and teatDoen functions: + + >>> def setUp(): + ... import test.test_doctest + ... test.test_doctest.sillySetup = True + + >>> def tearDown(): + ... import test.test_doctest + ... del test.test_doctest.sillySetup + + Here, we installed a silly variable that the test expects: + + >>> suite = doctest.DocTestSuite('test.sample_doctest', + ... setUp=setUp, tearDown=tearDown) + >>> suite.run(unittest.TestResult()) + + + But the tearDown restores sanity: + + >>> import test.test_doctest + >>> test.test_doctest.sillySetup + Traceback (most recent call last): + ... + AttributeError: 'module' object has no attribute 'sillySetup' + + Finally, you can provide an alternate test finder. Here we'll + use a custom test_finder to to run just the test named bar: + + >>> finder = doctest.DocTestFinder( + ... namefilter=lambda prefix, base: base!='bar') + >>> suite = doctest.DocTestSuite('test.sample_doctest', + ... test_finder=finder) + >>> suite.run(unittest.TestResult()) + + + """ + + def test_DocFileSuite(): + """We can test tests found in text files using a DocFileSuite. + + We create a suite by providing the names of one or more text + files that include examples: + + >>> import unittest + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt') + >>> suite.run(unittest.TestResult()) + + + The test files are looked for in the directory containing the + calling module. A package keyword argument can be provided to + specify a different relative location. + + >>> import unittest + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt', + ... package='test') + >>> suite.run(unittest.TestResult()) + + + Note that '/' should be used as a path separator. It will be + converted to a native separator at run time: + + + >>> suite = doctest.DocFileSuite('../test/test_doctest.txt') + >>> suite.run(unittest.TestResult()) + + + You can specify initial global variables: + + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt', + ... globs={'favorite_color': 'blue'}) + >>> suite.run(unittest.TestResult()) + + + In this case, we supplied a missing favorite color. You can + provide doctest options: + + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt', + ... optionflags=doctest.DONT_ACCEPT_BLANKLINE, + ... globs={'favorite_color': 'blue'}) + >>> suite.run(unittest.TestResult()) + + + And, you can provide setUp and tearDown functions: + + You can supply setUp and teatDoen functions: + + >>> def setUp(): + ... import test.test_doctest + ... test.test_doctest.sillySetup = True + + >>> def tearDown(): + ... import test.test_doctest + ... del test.test_doctest.sillySetup + + Here, we installed a silly variable that the test expects: + + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt', + ... setUp=setUp, tearDown=tearDown) + >>> suite.run(unittest.TestResult()) + + + But the tearDown restores sanity: + + >>> import test.test_doctest + >>> test.test_doctest.sillySetup + Traceback (most recent call last): + ... + AttributeError: 'module' object has no attribute 'sillySetup' + + """ + + ###################################################################### ## Main From rhettinger at users.sourceforge.net Sat Aug 7 01:42:20 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Aug 7 01:42:24 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5609 Modified Files: decimal.py Log Message: SF bug #1002530: test_decimal fails if repeated * Protect the pre-defined contexts by using a deepcopy() instead of copy(). * Micro-optimization: prefer x&1 over x%2 Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** decimal.py 14 Jul 2004 21:04:27 -0000 1.19 --- decimal.py 6 Aug 2004 23:42:16 -0000 1.20 *************** *** 393,397 **** """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): ! context = context.copy() threading.currentThread().__decimal_context__ = context --- 393,398 ---- """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): ! context = copy.deepcopy(context) ! context.clear_flags() threading.currentThread().__decimal_context__ = context *************** *** 431,435 **** """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): ! context = context.copy() _local.__decimal_context__ = context --- 432,437 ---- """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): ! context = copy.deepcopy(context) ! context.clear_flags() _local.__decimal_context__ = context *************** *** 1635,1639 **** break if half: ! if self._int[prec-1] %2 == 0: return tmp return self._round_half_up(prec, expdiff, context, tmp) --- 1637,1641 ---- break if half: ! if self._int[prec-1] & 1 == 0: return tmp return self._round_half_up(prec, expdiff, context, tmp) *************** *** 1931,1935 **** expadd = tmp._exp / 2 ! if tmp._exp % 2 == 1: tmp._int += (0,) tmp._exp = 0 --- 1933,1937 ---- expadd = tmp._exp / 2 ! if tmp._exp & 1: tmp._int += (0,) tmp._exp = 0 *************** *** 1941,1945 **** firstprec = context.prec context.prec = 3 ! if tmp.adjusted() % 2 == 0: ans = Decimal( (0, (8,1,9), tmp.adjusted() - 2) ) ans = ans.__add__(tmp.__mul__(Decimal((0, (2,5,9), -2)), --- 1943,1947 ---- firstprec = context.prec context.prec = 3 ! if tmp.adjusted() & 1 == 0: ans = Decimal( (0, (8,1,9), tmp.adjusted() - 2) ) ans = ans.__add__(tmp.__mul__(Decimal((0, (2,5,9), -2)), *************** *** 2076,2080 **** if self._exp > 0: return 1 ! return self._int[-1+self._exp] % 2 == 0 def adjusted(self): --- 2078,2082 ---- if self._exp > 0: return 1 ! return self._int[-1+self._exp] & 1 == 0 def adjusted(self): From rhettinger at users.sourceforge.net Sat Aug 7 06:55:32 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Aug 7 06:55:36 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_builtin.py, 1.32, 1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16012/Lib/test Modified Files: test_builtin.py Log Message: SF bug #1004669: Type returned from .keys() is not checked Index: test_builtin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** test_builtin.py 2 Aug 2004 08:30:07 -0000 1.32 --- test_builtin.py 7 Aug 2004 04:55:30 -0000 1.33 *************** *** 323,326 **** --- 323,335 ---- self.assertEqual(ss['a3'], 210) + # Verify that dir() catches a non-list returned by eval + # SF bug #1004669 + class C: + def __getitem__(self, item): + raise KeyError(item) + def keys(self): + return 'a' + self.assertRaises(TypeError, eval, 'dir()', globals(), C()) + # Done outside of the method test_z to get the correct scope z = 0 From rhettinger at users.sourceforge.net Sat Aug 7 06:55:32 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Aug 7 06:55:39 2004 Subject: [Python-checkins] python/dist/src/Objects object.c,2.220,2.221 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16012/Objects Modified Files: object.c Log Message: SF bug #1004669: Type returned from .keys() is not checked Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.220 retrieving revision 2.221 diff -C2 -d -r2.220 -r2.221 *** object.c 8 Jul 2004 01:48:59 -0000 2.220 --- object.c 7 Aug 2004 04:55:30 -0000 2.221 *************** *** 1703,1706 **** --- 1703,1711 ---- assert(result); + if (!PyList_Check(result)) { + PyErr_SetString(PyExc_TypeError, + "Expected keys() to be a list."); + goto error; + } if (PyList_Sort(result) != 0) goto error; From tim_one at users.sourceforge.net Sat Aug 7 07:37:55 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Aug 7 07:37:58 2004 Subject: [Python-checkins] python/dist/src/Lib/test sample_doctest.py, 1.2, 1.3 test_doctest.py, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21134/Lib/test Modified Files: sample_doctest.py test_doctest.py Log Message: Bug 772091: doctest.DocTestSuite does not support __test__ This got fixed "by magic" as part of the refactoring, but wasn't tested as such. Now it is. Index: sample_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/sample_doctest.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sample_doctest.py 6 Aug 2004 22:02:59 -0000 1.2 --- sample_doctest.py 7 Aug 2004 05:37:52 -0000 1.3 *************** *** 1,8 **** """This is a sample module that doesn't really test anything all that ! interesting ! It simply has a few tests, some of which suceed and some of which fail. ! It's important that the numbers remain constance, as another test is testing the running of these tests. --- 1,8 ---- """This is a sample module that doesn't really test anything all that ! interesting. ! It simply has a few tests, some of which succeed and some of which fail. ! It's important that the numbers remain constant as another test is testing the running of these tests. *************** *** 62,65 **** --- 62,75 ---- """ + __test__ = {'good': """ + >>> 42 + 42 + """, + 'bad': """ + >>> 42 + 666 + """, + } + def test_suite(): import doctest Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_doctest.py 6 Aug 2004 22:02:59 -0000 1.8 --- test_doctest.py 7 Aug 2004 05:37:52 -0000 1.9 *************** *** 987,991 **** def test_DocTestSuite(): ! """DocTestSuite creates a unittest test suite into a doctest. We create a Suite by providing a module. A module can be provided --- 987,991 ---- def test_DocTestSuite(): ! """DocTestSuite creates a unittest test suite from a doctest. We create a Suite by providing a module. A module can be provided *************** *** 996,1000 **** >>> suite = doctest.DocTestSuite(test.sample_doctest) >>> suite.run(unittest.TestResult()) ! We can also supply the module by name: --- 996,1000 ---- >>> suite = doctest.DocTestSuite(test.sample_doctest) >>> suite.run(unittest.TestResult()) ! We can also supply the module by name: *************** *** 1002,1006 **** >>> suite = doctest.DocTestSuite('test.sample_doctest') >>> suite.run(unittest.TestResult()) ! We can use the current module: --- 1002,1006 ---- >>> suite = doctest.DocTestSuite('test.sample_doctest') >>> suite.run(unittest.TestResult()) ! We can use the current module: *************** *** 1008,1012 **** >>> suite = test.sample_doctest.test_suite() >>> suite.run(unittest.TestResult()) ! We can supply global variables. If we pass globs, they will be --- 1008,1012 ---- >>> suite = test.sample_doctest.test_suite() >>> suite.run(unittest.TestResult()) ! We can supply global variables. If we pass globs, they will be *************** *** 1016,1020 **** >>> suite = doctest.DocTestSuite('test.sample_doctest', globs={}) >>> suite.run(unittest.TestResult()) ! Alternatively, we can provide extra globals. Here we'll make an --- 1016,1020 ---- >>> suite = doctest.DocTestSuite('test.sample_doctest', globs={}) >>> suite.run(unittest.TestResult()) ! Alternatively, we can provide extra globals. Here we'll make an *************** *** 1024,1028 **** ... extraglobs={'y': 1}) >>> suite.run(unittest.TestResult()) ! You can pass option flags. Here we'll cause an extra error --- 1024,1028 ---- ... extraglobs={'y': 1}) >>> suite.run(unittest.TestResult()) ! You can pass option flags. Here we'll cause an extra error *************** *** 1030,1038 **** >>> suite = doctest.DocTestSuite('test.sample_doctest', ! ... optionflags=doctest.DONT_ACCEPT_BLANKLINE) >>> suite.run(unittest.TestResult()) ! ! You can supply setUp and teatDoen functions: >>> def setUp(): --- 1030,1038 ---- >>> suite = doctest.DocTestSuite('test.sample_doctest', ! ... optionflags=doctest.DONT_ACCEPT_BLANKLINE) >>> suite.run(unittest.TestResult()) ! ! You can supply setUp and tearDown functions: >>> def setUp(): *************** *** 1049,1053 **** ... setUp=setUp, tearDown=tearDown) >>> suite.run(unittest.TestResult()) ! But the tearDown restores sanity: --- 1049,1053 ---- ... setUp=setUp, tearDown=tearDown) >>> suite.run(unittest.TestResult()) ! But the tearDown restores sanity: *************** *** 1060,1064 **** Finally, you can provide an alternate test finder. Here we'll ! use a custom test_finder to to run just the test named bar: >>> finder = doctest.DocTestFinder( --- 1060,1068 ---- Finally, you can provide an alternate test finder. Here we'll ! use a custom test_finder to to run just the test named bar. ! However, the test in the module docstring, and the two tests ! in the module __test__ dict, aren't filtered, so we actually ! run three tests besides bar's. The filtering mechanisms are ! poorly conceived, and will go away someday. >>> finder = doctest.DocTestFinder( *************** *** 1067,1072 **** ... test_finder=finder) >>> suite.run(unittest.TestResult()) ! ! """ --- 1071,1075 ---- ... test_finder=finder) >>> suite.run(unittest.TestResult()) ! """ From tim_one at users.sourceforge.net Sat Aug 7 08:03:10 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Aug 7 08:03:13 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.39,1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25161/Lib Modified Files: doctest.py Log Message: Whitespace normalization. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** doctest.py 6 Aug 2004 22:02:59 -0000 1.39 --- doctest.py 7 Aug 2004 06:03:08 -0000 1.40 *************** *** 1602,1606 **** def __str__(self): return str(self.test) ! class DebugRunner(DocTestRunner): r"""Run doc tests but raise an exception as soon as there is a failure. --- 1602,1606 ---- def __str__(self): return str(self.test) ! class DebugRunner(DocTestRunner): r"""Run doc tests but raise an exception as soon as there is a failure. *************** *** 1674,1678 **** ... UnexpectedException: ! >>> del test.globs['__builtins__'] >>> test.globs --- 1674,1678 ---- ... UnexpectedException: ! >>> del test.globs['__builtins__'] >>> test.globs From tim_one at users.sourceforge.net Sat Aug 7 08:03:12 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Aug 7 08:03:15 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_threadsignals.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25161/Lib/test Modified Files: test_threadsignals.py Log Message: Whitespace normalization. Index: test_threadsignals.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_threadsignals.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_threadsignals.py 4 Aug 2004 14:22:56 -0000 1.6 --- test_threadsignals.py 7 Aug 2004 06:03:09 -0000 1.7 *************** *** 70,74 **** def test_main(): global signal_blackboard ! signal_blackboard = { signal.SIGUSR1 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 }, --- 70,74 ---- def test_main(): global signal_blackboard ! signal_blackboard = { signal.SIGUSR1 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 }, From tim_one at users.sourceforge.net Sat Aug 7 08:03:12 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Aug 7 08:03:18 2004 Subject: [Python-checkins] python/dist/src/Lib/encodings iso8859_11.py, 1.1, 1.2 iso8859_16.py, 1.1, 1.2 tis_620.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/encodings In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25161/Lib/encodings Modified Files: iso8859_11.py iso8859_16.py tis_620.py Log Message: Whitespace normalization. Index: iso8859_11.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso8859_11.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** iso8859_11.py 5 Aug 2004 12:43:30 -0000 1.1 --- iso8859_11.py 7 Aug 2004 06:03:08 -0000 1.2 *************** *** 36,134 **** decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ ! 0x00a1: 0x0e01, # THAI CHARACTER KO KAI ! 0x00a2: 0x0e02, # THAI CHARACTER KHO KHAI ! 0x00a3: 0x0e03, # THAI CHARACTER KHO KHUAT ! 0x00a4: 0x0e04, # THAI CHARACTER KHO KHWAI ! 0x00a5: 0x0e05, # THAI CHARACTER KHO KHON ! 0x00a6: 0x0e06, # THAI CHARACTER KHO RAKHANG ! 0x00a7: 0x0e07, # THAI CHARACTER NGO NGU ! 0x00a8: 0x0e08, # THAI CHARACTER CHO CHAN ! 0x00a9: 0x0e09, # THAI CHARACTER CHO CHING ! 0x00aa: 0x0e0a, # THAI CHARACTER CHO CHANG ! 0x00ab: 0x0e0b, # THAI CHARACTER SO SO ! 0x00ac: 0x0e0c, # THAI CHARACTER CHO CHOE ! 0x00ad: 0x0e0d, # THAI CHARACTER YO YING ! 0x00ae: 0x0e0e, # THAI CHARACTER DO CHADA ! 0x00af: 0x0e0f, # THAI CHARACTER TO PATAK ! 0x00b0: 0x0e10, # THAI CHARACTER THO THAN ! 0x00b1: 0x0e11, # THAI CHARACTER THO NANGMONTHO ! 0x00b2: 0x0e12, # THAI CHARACTER THO PHUTHAO ! 0x00b3: 0x0e13, # THAI CHARACTER NO NEN ! 0x00b4: 0x0e14, # THAI CHARACTER DO DEK ! 0x00b5: 0x0e15, # THAI CHARACTER TO TAO ! 0x00b6: 0x0e16, # THAI CHARACTER THO THUNG ! 0x00b7: 0x0e17, # THAI CHARACTER THO THAHAN ! 0x00b8: 0x0e18, # THAI CHARACTER THO THONG ! 0x00b9: 0x0e19, # THAI CHARACTER NO NU ! 0x00ba: 0x0e1a, # THAI CHARACTER BO BAIMAI ! 0x00bb: 0x0e1b, # THAI CHARACTER PO PLA ! 0x00bc: 0x0e1c, # THAI CHARACTER PHO PHUNG ! 0x00bd: 0x0e1d, # THAI CHARACTER FO FA ! 0x00be: 0x0e1e, # THAI CHARACTER PHO PHAN ! 0x00bf: 0x0e1f, # THAI CHARACTER FO FAN ! 0x00c0: 0x0e20, # THAI CHARACTER PHO SAMPHAO ! 0x00c1: 0x0e21, # THAI CHARACTER MO MA ! 0x00c2: 0x0e22, # THAI CHARACTER YO YAK ! 0x00c3: 0x0e23, # THAI CHARACTER RO RUA ! 0x00c4: 0x0e24, # THAI CHARACTER RU ! 0x00c5: 0x0e25, # THAI CHARACTER LO LING ! 0x00c6: 0x0e26, # THAI CHARACTER LU ! 0x00c7: 0x0e27, # THAI CHARACTER WO WAEN ! 0x00c8: 0x0e28, # THAI CHARACTER SO SALA ! 0x00c9: 0x0e29, # THAI CHARACTER SO RUSI ! 0x00ca: 0x0e2a, # THAI CHARACTER SO SUA ! 0x00cb: 0x0e2b, # THAI CHARACTER HO HIP ! 0x00cc: 0x0e2c, # THAI CHARACTER LO CHULA ! 0x00cd: 0x0e2d, # THAI CHARACTER O ANG ! 0x00ce: 0x0e2e, # THAI CHARACTER HO NOKHUK ! 0x00cf: 0x0e2f, # THAI CHARACTER PAIYANNOI ! 0x00d0: 0x0e30, # THAI CHARACTER SARA A ! 0x00d1: 0x0e31, # THAI CHARACTER MAI HAN-AKAT ! 0x00d2: 0x0e32, # THAI CHARACTER SARA AA ! 0x00d3: 0x0e33, # THAI CHARACTER SARA AM ! 0x00d4: 0x0e34, # THAI CHARACTER SARA I ! 0x00d5: 0x0e35, # THAI CHARACTER SARA II ! 0x00d6: 0x0e36, # THAI CHARACTER SARA UE ! 0x00d7: 0x0e37, # THAI CHARACTER SARA UEE ! 0x00d8: 0x0e38, # THAI CHARACTER SARA U ! 0x00d9: 0x0e39, # THAI CHARACTER SARA UU ! 0x00da: 0x0e3a, # THAI CHARACTER PHINTHU ! 0x00db: None, ! 0x00dc: None, ! 0x00dd: None, ! 0x00de: None, ! 0x00df: 0x0e3f, # THAI CURRENCY SYMBOL BAHT ! 0x00e0: 0x0e40, # THAI CHARACTER SARA E ! 0x00e1: 0x0e41, # THAI CHARACTER SARA AE ! 0x00e2: 0x0e42, # THAI CHARACTER SARA O ! 0x00e3: 0x0e43, # THAI CHARACTER SARA AI MAIMUAN ! 0x00e4: 0x0e44, # THAI CHARACTER SARA AI MAIMALAI ! 0x00e5: 0x0e45, # THAI CHARACTER LAKKHANGYAO ! 0x00e6: 0x0e46, # THAI CHARACTER MAIYAMOK ! 0x00e7: 0x0e47, # THAI CHARACTER MAITAIKHU ! 0x00e8: 0x0e48, # THAI CHARACTER MAI EK ! 0x00e9: 0x0e49, # THAI CHARACTER MAI THO ! 0x00ea: 0x0e4a, # THAI CHARACTER MAI TRI ! 0x00eb: 0x0e4b, # THAI CHARACTER MAI CHATTAWA ! 0x00ec: 0x0e4c, # THAI CHARACTER THANTHAKHAT ! 0x00ed: 0x0e4d, # THAI CHARACTER NIKHAHIT ! 0x00ee: 0x0e4e, # THAI CHARACTER YAMAKKAN ! 0x00ef: 0x0e4f, # THAI CHARACTER FONGMAN ! 0x00f0: 0x0e50, # THAI DIGIT ZERO ! 0x00f1: 0x0e51, # THAI DIGIT ONE ! 0x00f2: 0x0e52, # THAI DIGIT TWO ! 0x00f3: 0x0e53, # THAI DIGIT THREE ! 0x00f4: 0x0e54, # THAI DIGIT FOUR ! 0x00f5: 0x0e55, # THAI DIGIT FIVE ! 0x00f6: 0x0e56, # THAI DIGIT SIX ! 0x00f7: 0x0e57, # THAI DIGIT SEVEN ! 0x00f8: 0x0e58, # THAI DIGIT EIGHT ! 0x00f9: 0x0e59, # THAI DIGIT NINE ! 0x00fa: 0x0e5a, # THAI CHARACTER ANGKHANKHU ! 0x00fb: 0x0e5b, # THAI CHARACTER KHOMUT ! 0x00fc: None, ! 0x00fd: None, ! 0x00fe: None, ! 0x00ff: None, }) --- 36,134 ---- decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ ! 0x00a1: 0x0e01, # THAI CHARACTER KO KAI ! 0x00a2: 0x0e02, # THAI CHARACTER KHO KHAI ! 0x00a3: 0x0e03, # THAI CHARACTER KHO KHUAT ! 0x00a4: 0x0e04, # THAI CHARACTER KHO KHWAI ! 0x00a5: 0x0e05, # THAI CHARACTER KHO KHON ! 0x00a6: 0x0e06, # THAI CHARACTER KHO RAKHANG ! 0x00a7: 0x0e07, # THAI CHARACTER NGO NGU ! 0x00a8: 0x0e08, # THAI CHARACTER CHO CHAN ! 0x00a9: 0x0e09, # THAI CHARACTER CHO CHING ! 0x00aa: 0x0e0a, # THAI CHARACTER CHO CHANG ! 0x00ab: 0x0e0b, # THAI CHARACTER SO SO ! 0x00ac: 0x0e0c, # THAI CHARACTER CHO CHOE ! 0x00ad: 0x0e0d, # THAI CHARACTER YO YING ! 0x00ae: 0x0e0e, # THAI CHARACTER DO CHADA ! 0x00af: 0x0e0f, # THAI CHARACTER TO PATAK ! 0x00b0: 0x0e10, # THAI CHARACTER THO THAN ! 0x00b1: 0x0e11, # THAI CHARACTER THO NANGMONTHO ! 0x00b2: 0x0e12, # THAI CHARACTER THO PHUTHAO ! 0x00b3: 0x0e13, # THAI CHARACTER NO NEN ! 0x00b4: 0x0e14, # THAI CHARACTER DO DEK ! 0x00b5: 0x0e15, # THAI CHARACTER TO TAO ! 0x00b6: 0x0e16, # THAI CHARACTER THO THUNG ! 0x00b7: 0x0e17, # THAI CHARACTER THO THAHAN ! 0x00b8: 0x0e18, # THAI CHARACTER THO THONG ! 0x00b9: 0x0e19, # THAI CHARACTER NO NU ! 0x00ba: 0x0e1a, # THAI CHARACTER BO BAIMAI ! 0x00bb: 0x0e1b, # THAI CHARACTER PO PLA ! 0x00bc: 0x0e1c, # THAI CHARACTER PHO PHUNG ! 0x00bd: 0x0e1d, # THAI CHARACTER FO FA ! 0x00be: 0x0e1e, # THAI CHARACTER PHO PHAN ! 0x00bf: 0x0e1f, # THAI CHARACTER FO FAN ! 0x00c0: 0x0e20, # THAI CHARACTER PHO SAMPHAO ! 0x00c1: 0x0e21, # THAI CHARACTER MO MA ! 0x00c2: 0x0e22, # THAI CHARACTER YO YAK ! 0x00c3: 0x0e23, # THAI CHARACTER RO RUA ! 0x00c4: 0x0e24, # THAI CHARACTER RU ! 0x00c5: 0x0e25, # THAI CHARACTER LO LING ! 0x00c6: 0x0e26, # THAI CHARACTER LU ! 0x00c7: 0x0e27, # THAI CHARACTER WO WAEN ! 0x00c8: 0x0e28, # THAI CHARACTER SO SALA ! 0x00c9: 0x0e29, # THAI CHARACTER SO RUSI ! 0x00ca: 0x0e2a, # THAI CHARACTER SO SUA ! 0x00cb: 0x0e2b, # THAI CHARACTER HO HIP ! 0x00cc: 0x0e2c, # THAI CHARACTER LO CHULA ! 0x00cd: 0x0e2d, # THAI CHARACTER O ANG ! 0x00ce: 0x0e2e, # THAI CHARACTER HO NOKHUK ! 0x00cf: 0x0e2f, # THAI CHARACTER PAIYANNOI ! 0x00d0: 0x0e30, # THAI CHARACTER SARA A ! 0x00d1: 0x0e31, # THAI CHARACTER MAI HAN-AKAT ! 0x00d2: 0x0e32, # THAI CHARACTER SARA AA ! 0x00d3: 0x0e33, # THAI CHARACTER SARA AM ! 0x00d4: 0x0e34, # THAI CHARACTER SARA I ! 0x00d5: 0x0e35, # THAI CHARACTER SARA II ! 0x00d6: 0x0e36, # THAI CHARACTER SARA UE ! 0x00d7: 0x0e37, # THAI CHARACTER SARA UEE ! 0x00d8: 0x0e38, # THAI CHARACTER SARA U ! 0x00d9: 0x0e39, # THAI CHARACTER SARA UU ! 0x00da: 0x0e3a, # THAI CHARACTER PHINTHU ! 0x00db: None, ! 0x00dc: None, ! 0x00dd: None, ! 0x00de: None, ! 0x00df: 0x0e3f, # THAI CURRENCY SYMBOL BAHT ! 0x00e0: 0x0e40, # THAI CHARACTER SARA E ! 0x00e1: 0x0e41, # THAI CHARACTER SARA AE ! 0x00e2: 0x0e42, # THAI CHARACTER SARA O ! 0x00e3: 0x0e43, # THAI CHARACTER SARA AI MAIMUAN ! 0x00e4: 0x0e44, # THAI CHARACTER SARA AI MAIMALAI ! 0x00e5: 0x0e45, # THAI CHARACTER LAKKHANGYAO ! 0x00e6: 0x0e46, # THAI CHARACTER MAIYAMOK ! 0x00e7: 0x0e47, # THAI CHARACTER MAITAIKHU ! 0x00e8: 0x0e48, # THAI CHARACTER MAI EK ! 0x00e9: 0x0e49, # THAI CHARACTER MAI THO ! 0x00ea: 0x0e4a, # THAI CHARACTER MAI TRI ! 0x00eb: 0x0e4b, # THAI CHARACTER MAI CHATTAWA ! 0x00ec: 0x0e4c, # THAI CHARACTER THANTHAKHAT ! 0x00ed: 0x0e4d, # THAI CHARACTER NIKHAHIT ! 0x00ee: 0x0e4e, # THAI CHARACTER YAMAKKAN ! 0x00ef: 0x0e4f, # THAI CHARACTER FONGMAN ! 0x00f0: 0x0e50, # THAI DIGIT ZERO ! 0x00f1: 0x0e51, # THAI DIGIT ONE ! 0x00f2: 0x0e52, # THAI DIGIT TWO ! 0x00f3: 0x0e53, # THAI DIGIT THREE ! 0x00f4: 0x0e54, # THAI DIGIT FOUR ! 0x00f5: 0x0e55, # THAI DIGIT FIVE ! 0x00f6: 0x0e56, # THAI DIGIT SIX ! 0x00f7: 0x0e57, # THAI DIGIT SEVEN ! 0x00f8: 0x0e58, # THAI DIGIT EIGHT ! 0x00f9: 0x0e59, # THAI DIGIT NINE ! 0x00fa: 0x0e5a, # THAI CHARACTER ANGKHANKHU ! 0x00fb: 0x0e5b, # THAI CHARACTER KHOMUT ! 0x00fc: None, ! 0x00fd: None, ! 0x00fe: None, ! 0x00ff: None, }) Index: iso8859_16.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/iso8859_16.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** iso8859_16.py 5 Aug 2004 12:43:30 -0000 1.1 --- iso8859_16.py 7 Aug 2004 06:03:09 -0000 1.2 *************** *** 36,79 **** decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ ! 0x00a1: 0x0104, # LATIN CAPITAL LETTER A WITH OGONEK ! 0x00a2: 0x0105, # LATIN SMALL LETTER A WITH OGONEK ! 0x00a3: 0x0141, # LATIN CAPITAL LETTER L WITH STROKE ! 0x00a4: 0x20ac, # EURO SIGN ! 0x00a5: 0x201e, # DOUBLE LOW-9 QUOTATION MARK ! 0x00a6: 0x0160, # LATIN CAPITAL LETTER S WITH CARON ! 0x00a8: 0x0161, # LATIN SMALL LETTER S WITH CARON ! 0x00aa: 0x0218, # LATIN CAPITAL LETTER S WITH COMMA BELOW ! 0x00ac: 0x0179, # LATIN CAPITAL LETTER Z WITH ACUTE ! 0x00ae: 0x017a, # LATIN SMALL LETTER Z WITH ACUTE ! 0x00af: 0x017b, # LATIN CAPITAL LETTER Z WITH DOT ABOVE ! 0x00b2: 0x010c, # LATIN CAPITAL LETTER C WITH CARON ! 0x00b3: 0x0142, # LATIN SMALL LETTER L WITH STROKE ! 0x00b4: 0x017d, # LATIN CAPITAL LETTER Z WITH CARON ! 0x00b5: 0x201d, # RIGHT DOUBLE QUOTATION MARK ! 0x00b8: 0x017e, # LATIN SMALL LETTER Z WITH CARON ! 0x00b9: 0x010d, # LATIN SMALL LETTER C WITH CARON ! 0x00ba: 0x0219, # LATIN SMALL LETTER S WITH COMMA BELOW ! 0x00bc: 0x0152, # LATIN CAPITAL LIGATURE OE ! 0x00bd: 0x0153, # LATIN SMALL LIGATURE OE ! 0x00be: 0x0178, # LATIN CAPITAL LETTER Y WITH DIAERESIS ! 0x00bf: 0x017c, # LATIN SMALL LETTER Z WITH DOT ABOVE ! 0x00c3: 0x0102, # LATIN CAPITAL LETTER A WITH BREVE ! 0x00c5: 0x0106, # LATIN CAPITAL LETTER C WITH ACUTE ! 0x00d0: 0x0110, # LATIN CAPITAL LETTER D WITH STROKE ! 0x00d1: 0x0143, # LATIN CAPITAL LETTER N WITH ACUTE ! 0x00d5: 0x0150, # LATIN CAPITAL LETTER O WITH DOUBLE ACUTE ! 0x00d7: 0x015a, # LATIN CAPITAL LETTER S WITH ACUTE ! 0x00d8: 0x0170, # LATIN CAPITAL LETTER U WITH DOUBLE ACUTE ! 0x00dd: 0x0118, # LATIN CAPITAL LETTER E WITH OGONEK ! 0x00de: 0x021a, # LATIN CAPITAL LETTER T WITH COMMA BELOW ! 0x00e3: 0x0103, # LATIN SMALL LETTER A WITH BREVE ! 0x00e5: 0x0107, # LATIN SMALL LETTER C WITH ACUTE ! 0x00f0: 0x0111, # LATIN SMALL LETTER D WITH STROKE ! 0x00f1: 0x0144, # LATIN SMALL LETTER N WITH ACUTE ! 0x00f5: 0x0151, # LATIN SMALL LETTER O WITH DOUBLE ACUTE ! 0x00f7: 0x015b, # LATIN SMALL LETTER S WITH ACUTE ! 0x00f8: 0x0171, # LATIN SMALL LETTER U WITH DOUBLE ACUTE ! 0x00fd: 0x0119, # LATIN SMALL LETTER E WITH OGONEK ! 0x00fe: 0x021b, # LATIN SMALL LETTER T WITH COMMA BELOW }) --- 36,79 ---- decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ ! 0x00a1: 0x0104, # LATIN CAPITAL LETTER A WITH OGONEK ! 0x00a2: 0x0105, # LATIN SMALL LETTER A WITH OGONEK ! 0x00a3: 0x0141, # LATIN CAPITAL LETTER L WITH STROKE ! 0x00a4: 0x20ac, # EURO SIGN ! 0x00a5: 0x201e, # DOUBLE LOW-9 QUOTATION MARK ! 0x00a6: 0x0160, # LATIN CAPITAL LETTER S WITH CARON ! 0x00a8: 0x0161, # LATIN SMALL LETTER S WITH CARON ! 0x00aa: 0x0218, # LATIN CAPITAL LETTER S WITH COMMA BELOW ! 0x00ac: 0x0179, # LATIN CAPITAL LETTER Z WITH ACUTE ! 0x00ae: 0x017a, # LATIN SMALL LETTER Z WITH ACUTE ! 0x00af: 0x017b, # LATIN CAPITAL LETTER Z WITH DOT ABOVE ! 0x00b2: 0x010c, # LATIN CAPITAL LETTER C WITH CARON ! 0x00b3: 0x0142, # LATIN SMALL LETTER L WITH STROKE ! 0x00b4: 0x017d, # LATIN CAPITAL LETTER Z WITH CARON ! 0x00b5: 0x201d, # RIGHT DOUBLE QUOTATION MARK ! 0x00b8: 0x017e, # LATIN SMALL LETTER Z WITH CARON ! 0x00b9: 0x010d, # LATIN SMALL LETTER C WITH CARON ! 0x00ba: 0x0219, # LATIN SMALL LETTER S WITH COMMA BELOW ! 0x00bc: 0x0152, # LATIN CAPITAL LIGATURE OE ! 0x00bd: 0x0153, # LATIN SMALL LIGATURE OE ! 0x00be: 0x0178, # LATIN CAPITAL LETTER Y WITH DIAERESIS ! 0x00bf: 0x017c, # LATIN SMALL LETTER Z WITH DOT ABOVE ! 0x00c3: 0x0102, # LATIN CAPITAL LETTER A WITH BREVE ! 0x00c5: 0x0106, # LATIN CAPITAL LETTER C WITH ACUTE ! 0x00d0: 0x0110, # LATIN CAPITAL LETTER D WITH STROKE ! 0x00d1: 0x0143, # LATIN CAPITAL LETTER N WITH ACUTE ! 0x00d5: 0x0150, # LATIN CAPITAL LETTER O WITH DOUBLE ACUTE ! 0x00d7: 0x015a, # LATIN CAPITAL LETTER S WITH ACUTE ! 0x00d8: 0x0170, # LATIN CAPITAL LETTER U WITH DOUBLE ACUTE ! 0x00dd: 0x0118, # LATIN CAPITAL LETTER E WITH OGONEK ! 0x00de: 0x021a, # LATIN CAPITAL LETTER T WITH COMMA BELOW ! 0x00e3: 0x0103, # LATIN SMALL LETTER A WITH BREVE ! 0x00e5: 0x0107, # LATIN SMALL LETTER C WITH ACUTE ! 0x00f0: 0x0111, # LATIN SMALL LETTER D WITH STROKE ! 0x00f1: 0x0144, # LATIN SMALL LETTER N WITH ACUTE ! 0x00f5: 0x0151, # LATIN SMALL LETTER O WITH DOUBLE ACUTE ! 0x00f7: 0x015b, # LATIN SMALL LETTER S WITH ACUTE ! 0x00f8: 0x0171, # LATIN SMALL LETTER U WITH DOUBLE ACUTE ! 0x00fd: 0x0119, # LATIN SMALL LETTER E WITH OGONEK ! 0x00fe: 0x021b, # LATIN SMALL LETTER T WITH COMMA BELOW }) Index: tis_620.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/tis_620.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tis_620.py 5 Aug 2004 12:43:30 -0000 1.1 --- tis_620.py 7 Aug 2004 06:03:09 -0000 1.2 *************** *** 39,43 **** decoding_map = decoding_map.copy() decoding_map.update({ ! 0x00a0: None, }) --- 39,43 ---- decoding_map = decoding_map.copy() decoding_map.update({ ! 0x00a0: None, }) From rhettinger at users.sourceforge.net Sat Aug 7 08:15:14 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Aug 7 08:15:16 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_sets.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27013 Modified Files: test_sets.py Log Message: Exercise DocTestSuite's search for __test__. Index: test_sets.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sets.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** test_sets.py 12 Feb 2004 17:35:11 -0000 1.30 --- test_sets.py 7 Aug 2004 06:15:12 -0000 1.31 *************** *** 807,811 **** def test_main(verbose=None): ! from test import test_sets test_support.run_unittest( TestSetOfSets, --- 807,811 ---- def test_main(verbose=None): ! import test_sets, doctest test_support.run_unittest( TestSetOfSets, *************** *** 836,841 **** TestCopyingNested, TestIdentities, ) - test_support.run_doctest(test_sets, verbose) if __name__ == "__main__": --- 836,841 ---- TestCopyingNested, TestIdentities, + doctest.DocTestSuite(test_sets), ) if __name__ == "__main__": From akuchling at users.sourceforge.net Sat Aug 7 15:13:34 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 15:13:37 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.82, 1.83 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17920 Modified Files: whatsnew24.tex Log Message: Add string concat item Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** whatsnew24.tex 6 Aug 2004 18:55:48 -0000 1.82 --- whatsnew24.tex 7 Aug 2004 13:13:31 -0000 1.83 *************** *** 816,819 **** --- 816,826 ---- by about a third. + \item String concatenations in statements of the form \code{s = s + + "abc"} and \code{s += "abc"} are now performed more efficiently in + certain circumstances. This optimization won't be present in other + Python implementations such as Jython, so you shouldn't rely on it; + using the \method{join()} method of strings is still recommended when + you want to efficiently glue a large number of strings together. + \end{itemize} From akuchling at users.sourceforge.net Sat Aug 7 15:24:14 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 15:24:17 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.83, 1.84 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19284 Modified Files: whatsnew24.tex Log Message: Simplify language Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** whatsnew24.tex 7 Aug 2004 13:13:31 -0000 1.83 --- whatsnew24.tex 7 Aug 2004 13:24:12 -0000 1.84 *************** *** 120,133 **** \section{PEP 289: Generator Expressions} ! The iterator feature introduced in Python 2.2 makes it easier to write ! programs that loop through large data sets without having the entire ! data set in memory at one time. Programmers can use iterators and the ! \module{itertools} module to write code in a fairly functional style. ! ! % XXX avoid metaphor ! List comprehensions have been the fly in the ointment because they ! produce a Python list object containing all of the items, unavoidably ! pulling them all into memory. When trying to write a ! functionally-styled program, it would be natural to write something like: --- 120,130 ---- \section{PEP 289: Generator Expressions} ! The iterator feature introduced in Python 2.2 and the ! \module{itertools} module make it easier to write programs that loop ! through large data sets without having the entire data set in memory ! at one time. List comprehensions don't fit into this picture very ! well because they produce a Python list object containing all of the ! items, unavoidably pulling them all into memory. When trying to write ! a functionally-styled program, it would be natural to write something like: *************** *** 149,153 **** The first form is more concise and perhaps more readable, but if you're dealing with a large number of link objects the second form ! would have to be used. Generator expressions work similarly to list comprehensions but don't --- 146,151 ---- The first form is more concise and perhaps more readable, but if you're dealing with a large number of link objects the second form ! would have to be used to avoid having all link objects in memory at ! the same time. Generator expressions work similarly to list comprehensions but don't From akuchling at users.sourceforge.net Sat Aug 7 15:58:19 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 15:58:22 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.84, 1.85 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23936 Modified Files: whatsnew24.tex Log Message: Add recent items Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** whatsnew24.tex 7 Aug 2004 13:24:12 -0000 1.84 --- whatsnew24.tex 7 Aug 2004 13:58:02 -0000 1.85 *************** *** 870,873 **** --- 870,876 ---- \end{itemize} + item Some other new encodings were added: ISO_8859-11, ISO_8859-16, PCTP-154, + and TIS-620. + \item There is a new \module{collections} module for various specialized collection datatypes. *************** *** 1040,1043 **** --- 1043,1052 ---- \end{verbatim} + \item The \module{optparse} module was updated. The module now passes + its messages through \function{gettext.gettext()}, making it possible + to internationalize Optik's help and error messages. Help messages + for options can now include the string \code{'%default'}, which will + be replaced by the option's default value. + \item A new \function{getsid()} function was added to the \module{posix} module that underlies the \module{os} module. *************** *** 1136,1139 **** --- 1145,1153 ---- during the look-up process. + \item A new function, \cfunction{PyArg_VaParseTupleAndKeywords()}, + is the same as \cfunction{PyArg_ParseTupleAndKeywords()} but takes a + \ctype{va_list} instead of a number of arguments. + (Contributed by Greg Chapman.) + \item A new method flag, \constant{METH_COEXISTS}, allows a function defined in slots to co-exist with a \ctype{PyCFunction} having the From akuchling at users.sourceforge.net Sat Aug 7 15:59:26 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 15:59:29 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1074,1.1075 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24099 Modified Files: NEWS Log Message: Typo fix Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1074 retrieving revision 1.1075 diff -C2 -d -r1.1074 -r1.1075 *** NEWS 6 Aug 2004 18:43:08 -0000 1.1074 --- NEWS 7 Aug 2004 13:59:22 -0000 1.1075 *************** *** 269,273 **** assigning thier values ! - correct my missconception about return values from visitprocs. Sigh. - mention the labor saving Py_VISIT and Py_CLEAR macros. --- 269,273 ---- assigning thier values ! - correct my misconception about return values from visitprocs. Sigh. - mention the labor saving Py_VISIT and Py_CLEAR macros. From akuchling at users.sourceforge.net Sat Aug 7 16:00:42 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 16:00:44 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1075,1.1076 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24360 Modified Files: NEWS Log Message: Another typo Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1075 retrieving revision 1.1076 diff -C2 -d -r1.1075 -r1.1076 *** NEWS 7 Aug 2004 13:59:22 -0000 1.1075 --- NEWS 7 Aug 2004 14:00:39 -0000 1.1076 *************** *** 267,271 **** - point out the importance of reassigning data members before ! assigning thier values - correct my misconception about return values from visitprocs. Sigh. --- 267,271 ---- - point out the importance of reassigning data members before ! assigning their values - correct my misconception about return values from visitprocs. Sigh. From akuchling at users.sourceforge.net Sat Aug 7 16:03:36 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 16:03:38 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1076,1.1077 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24886 Modified Files: NEWS Log Message: Create section for 2.4a3; remove empty sections in 2.4a2 Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1076 retrieving revision 1.1077 diff -C2 -d -r1.1076 -r1.1077 *** NEWS 7 Aug 2004 14:00:39 -0000 1.1076 --- NEWS 7 Aug 2004 14:03:33 -0000 1.1077 *************** *** 5,8 **** --- 5,47 ---- (editors: check NEWS.help for information about editing NEWS using ReST.) + What's New in Python 2.4 alpha 3? + ================================= + + *Release date: XX-XXX-2004* + + Core and builtins + ----------------- + + Extension modules + ----------------- + + Library + ------- + + Tools/Demos + ----------- + + Build + ----- + + C API + ----- + + Documentation + ------------- + + New platforms + ------------- + + Tests + ----- + + Windows + ------- + + Mac + --- + + What's New in Python 2.4 alpha 2? ================================= *************** *** 237,246 **** (This is *not* done in the 'description' passed to OptionGroup.) - Tools/Demos - ----------- - - Build - ----- - C API ----- --- 276,279 ---- *************** *** 275,281 **** - Major rewrite of the math module docs, to address common confusions. - New platforms - ------------- - Tests ----- --- 308,311 ---- *************** *** 288,298 **** test_tarfile.py depending on how the test file was checked out. - Windows - ------- - - Mac - --- - - What's New in Python 2.4 alpha 1? --- 318,321 ---- From akuchling at users.sourceforge.net Sat Aug 7 16:17:53 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 16:17:56 2004 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.276,1.277 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27372 Modified Files: ACKS Log Message: Add name Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.276 retrieving revision 1.277 diff -C2 -d -r1.276 -r1.277 *** ACKS 2 Aug 2004 06:24:59 -0000 1.276 --- ACKS 7 Aug 2004 14:17:50 -0000 1.277 *************** *** 407,410 **** --- 407,411 ---- Max Neunhöffer George Neville-Neil + Samuel Nicolary Gustavo Niemeyer Oscar Nierstrasz From fdrake at users.sourceforge.net Sat Aug 7 16:28:39 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sat Aug 7 16:28:42 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.85, 1.86 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28780/whatsnew Modified Files: whatsnew24.tex Log Message: fix two typos in markup Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** whatsnew24.tex 7 Aug 2004 13:58:02 -0000 1.85 --- whatsnew24.tex 7 Aug 2004 14:28:37 -0000 1.86 *************** *** 870,874 **** \end{itemize} ! item Some other new encodings were added: ISO_8859-11, ISO_8859-16, PCTP-154, and TIS-620. --- 870,874 ---- \end{itemize} ! \item Some other new encodings were added: ISO_8859-11, ISO_8859-16, PCTP-154, and TIS-620. *************** *** 1046,1050 **** its messages through \function{gettext.gettext()}, making it possible to internationalize Optik's help and error messages. Help messages ! for options can now include the string \code{'%default'}, which will be replaced by the option's default value. --- 1046,1050 ---- its messages through \function{gettext.gettext()}, making it possible to internationalize Optik's help and error messages. Help messages ! for options can now include the string \code{'\%default'}, which will be replaced by the option's default value. From akuchling at users.sourceforge.net Sat Aug 7 17:11:27 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 17:11:30 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcsv.tex,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2952 Modified Files: libcsv.tex Log Message: [Bug #998307] Use open() instead of file() in docs Index: libcsv.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcsv.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** libcsv.tex 8 Jul 2004 19:49:10 -0000 1.15 --- libcsv.tex 7 Aug 2004 15:11:24 -0000 1.16 *************** *** 315,319 **** \begin{verbatim} import csv ! reader = csv.reader(file("some.csv", "rb")) for row in reader: print row --- 315,319 ---- \begin{verbatim} import csv ! reader = csv.reader(open("some.csv", "rb")) for row in reader: print row *************** *** 324,328 **** \begin{verbatim} import csv ! reader = csv.reader(file("some.csv", "rb")) for row in reader: print row[0], row[-1] --- 324,328 ---- \begin{verbatim} import csv ! reader = csv.reader(open("some.csv", "rb")) for row in reader: print row[0], row[-1] *************** *** 333,337 **** \begin{verbatim} import csv ! writer = csv.writer(file("some.csv", "wb")) for row in someiterable: writer.writerow(row) --- 333,337 ---- \begin{verbatim} import csv ! writer = csv.writer(open("some.csv", "wb")) for row in someiterable: writer.writerow(row) From akuchling at users.sourceforge.net Sat Aug 7 17:13:09 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 17:13:14 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcsv.tex,1.7,1.7.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3143 Modified Files: Tag: release23-branch libcsv.tex Log Message: [Bug #998307] Use open() instead of file() in docs Index: libcsv.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcsv.tex,v retrieving revision 1.7 retrieving revision 1.7.6.1 diff -C2 -d -r1.7 -r1.7.6.1 *** libcsv.tex 2 Jul 2003 15:32:48 -0000 1.7 --- libcsv.tex 7 Aug 2004 15:13:06 -0000 1.7.6.1 *************** *** 295,299 **** \begin{verbatim} import csv ! reader = csv.reader(file("some.csv")) for row in reader: print row --- 295,299 ---- \begin{verbatim} import csv ! reader = csv.reader(open("some.csv")) for row in reader: print row *************** *** 304,308 **** \begin{verbatim} import csv ! writer = csv.writer(file("some.csv", "w")) for row in someiterable: writer.writerow(row) --- 304,308 ---- \begin{verbatim} import csv ! writer = csv.writer(open("some.csv", "w")) for row in someiterable: writer.writerow(row) From mwh at users.sourceforge.net Sat Aug 7 17:18:10 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Sat Aug 7 17:18:13 2004 Subject: [Python-checkins] python/dist/src/Lib/curses wrapper.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/curses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3856 Modified Files: wrapper.py Log Message: This is patch [ 1005008 ] curses.wrapper should also forward keyword args Plus my rewrite to use finally as opposed to painfully doing the equivalent by hand. Index: wrapper.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/wrapper.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** wrapper.py 6 Apr 2003 09:00:47 -0000 1.7 --- wrapper.py 7 Aug 2004 15:18:07 -0000 1.8 *************** *** 10,14 **** import sys, curses ! def wrapper(func, *rest): """Wrapper function that initializes curses and calls another function, restoring normal keyboard/screen behavior on error. --- 10,14 ---- import sys, curses ! def wrapper(func, *args, **kwds): """Wrapper function that initializes curses and calls another function, restoring normal keyboard/screen behavior on error. *************** *** 42,63 **** pass ! res = func(stdscr, *rest) ! except: ! # In the event of an error, restore the terminal ! # to a sane state. ! stdscr.keypad(0) ! curses.echo() ! curses.nocbreak() ! curses.endwin() ! ! # Pass the exception upwards ! (exc_type, exc_value, exc_traceback) = sys.exc_info() ! raise exc_type, exc_value, exc_traceback ! else: # Set everything back to normal stdscr.keypad(0) curses.echo() curses.nocbreak() ! curses.endwin() # Terminate curses ! ! return res --- 42,50 ---- pass ! return func(stdscr, *rest) ! finally: # Set everything back to normal stdscr.keypad(0) curses.echo() curses.nocbreak() ! curses.endwin() From mwh at users.sourceforge.net Sat Aug 7 17:20:18 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Sat Aug 7 17:20:20 2004 Subject: [Python-checkins] python/dist/src/Lib/curses wrapper.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/curses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4174 Modified Files: wrapper.py Log Message: Somehow (no idea how!) I missed half of patch #1005008. Sorry about that. Index: wrapper.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/wrapper.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** wrapper.py 7 Aug 2004 15:18:07 -0000 1.8 --- wrapper.py 7 Aug 2004 15:20:15 -0000 1.9 *************** *** 42,46 **** pass ! return func(stdscr, *rest) finally: # Set everything back to normal --- 42,46 ---- pass ! return func(stdscr, *args, **kwds) finally: # Set everything back to normal From mwh at users.sourceforge.net Sat Aug 7 17:27:19 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Sat Aug 7 17:27:22 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_curses.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5080 Modified Files: test_curses.py Log Message: This is more-or-less: [ 1005123 ] test_curses fails on MacOS X 10.3 Be a bit more guarded about what we expect a terminal to be capable of. Index: test_curses.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_curses.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_curses.py 18 Jan 2004 20:29:55 -0000 1.7 --- test_curses.py 7 Aug 2004 15:27:16 -0000 1.8 *************** *** 141,145 **** # Functions that actually need arguments ! curses.curs_set(1) curses.delay_output(1) curses.echo() ; curses.echo(1) --- 141,146 ---- # Functions that actually need arguments ! if curses.tigetstr("cnorm"): ! curses.curs_set(1) curses.delay_output(1) curses.echo() ; curses.echo(1) *************** *** 182,187 **** curses.pair_number(0) ! if hasattr(curses, 'use_default_colors'): ! curses.use_default_colors() if hasattr(curses, 'keyname'): --- 183,188 ---- curses.pair_number(0) ! if hasattr(curses, 'use_default_colors'): ! curses.use_default_colors() if hasattr(curses, 'keyname'): From akuchling at users.sourceforge.net Sat Aug 7 17:49:26 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 17:49:30 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libpickle.tex,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8896 Modified Files: libpickle.tex Log Message: [Bug #984952] Include some material from PEP 307 Index: libpickle.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpickle.tex,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** libpickle.tex 5 May 2004 04:56:06 -0000 1.49 --- libpickle.tex 7 Aug 2004 15:49:24 -0000 1.50 *************** *** 516,521 **** If a string is returned, it names a global variable whose contents are ! pickled as normal. When a tuple is returned, it must be of length two ! or three, with the following semantics: \begin{itemize} --- 516,521 ---- If a string is returned, it names a global variable whose contents are ! pickled as normal. When a tuple is returned, it must be between two ! and five elements long, with the following semantics: \begin{itemize} *************** *** 531,535 **** \item A tuple of arguments for the callable object, or \code{None}. \deprecated{2.3}{Use the tuple of arguments instead} - \item Optionally, the object's state, which will be passed to the object's \method{__setstate__()} method as described in --- 531,534 ---- *************** *** 539,542 **** --- 538,558 ---- \member{__dict__}. + \item Optionally, an iterator (and not a sequence) yielding successive + list items. These list items will be pickled, and appended to the + object using either \code{obj.append(\var{item})} or + \code{obj.extend(\var{list_of_items})}. This is primarily used for + list subclasses, but may be used by other classes as long as they have + \method{append()} and \method{extend()} methods with the appropriate + signature. (Whether \method{append()} or \method{extend()} is used + depends on which pickle protocol version is used as well as the number + of items to append, so both must be supported.) + + \item Optionally, an iterator (not a sequence) + yielding successive dictionary items, which should be tuples of the + form \code{(\var{key}, \var{value})}. These items will be pickled + and stored to the object using \code{obj[\var{key}] = \var{value}}. + This is primarily used for dictionary subclasses, but may be used by + other classes as long as they implement \method{__setitem__}. + \end{itemize} *************** *** 560,564 **** The registered constructor is deemed a ``safe constructor'' for purposes ! of unpickling as described above. \subsubsection{Pickling and unpickling external objects} --- 576,595 ---- The registered constructor is deemed a ``safe constructor'' for purposes ! ! It is sometimes useful to know the protocol version when implementing ! \method{__reduce__}. This can be done by implementing a method named ! \method{__reduce_ex__} instead of \method{__reduce__}. ! \method{__reduce_ex__}, when it exists, is called in preference over ! \method{__reduce__} (you may still provide \method{__reduce__} for ! backwards compatibility). The \method{__reduce_ex__} method will be ! called with a single integer argument, the protocol version. ! ! The \class{object} class implements both \method{__reduce__} and ! \method{__reduce_ex__}; however, if a subclass overrides ! \method{__reduce__} but not \method{__reduce_ex__}, the ! \method{__reduce_ex__} implementation detects this and calls ! \method{__reduce__}. ! ! \subsubsection{Pickling and unpickling external objects} From bwarsaw at users.sourceforge.net Sat Aug 7 17:57:54 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sat Aug 7 17:57:57 2004 Subject: [Python-checkins] python/dist/src/Lib/email FeedParser.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10203/Lib/email Modified Files: FeedParser.py Log Message: Resolution of SF bug #1002475 and patch #1003693; Header lines that end in \r\n only get the \n stripped, not the \r (unless it's the last header which does get the \r stripped). Patch by Tony Meyer. test_whitespace_continuation_last_header(), test_strip_line_feed_and_carriage_return_in_headers(): New tests. _parse_headers(): Be sure to strip \r\n from the right side of header lines. Index: FeedParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/FeedParser.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FeedParser.py 15 May 2004 16:26:28 -0000 1.8 --- FeedParser.py 7 Aug 2004 15:57:51 -0000 1.9 *************** *** 416,420 **** if lastheader: # XXX reconsider the joining of folded lines ! self._cur[lastheader] = EMPTYSTRING.join(lastvalue)[:-1] lastheader, lastvalue = '', [] # Check for envelope header, i.e. unix-from --- 416,421 ---- if lastheader: # XXX reconsider the joining of folded lines ! lhdr = EMPTYSTRING.join(lastvalue)[:-1].rstrip('\r\n') ! self._cur[lastheader] = lhdr lastheader, lastvalue = '', [] # Check for envelope header, i.e. unix-from *************** *** 450,452 **** if lastheader: # XXX reconsider the joining of folded lines ! self._cur[lastheader] = EMPTYSTRING.join(lastvalue).rstrip() --- 451,453 ---- if lastheader: # XXX reconsider the joining of folded lines ! self._cur[lastheader] = EMPTYSTRING.join(lastvalue).rstrip('\r\n') From bwarsaw at users.sourceforge.net Sat Aug 7 17:57:54 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sat Aug 7 17:57:58 2004 Subject: [Python-checkins] python/dist/src/Lib/email/test test_email.py, 1.58, 1.59 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10203/Lib/email/test Modified Files: test_email.py Log Message: Resolution of SF bug #1002475 and patch #1003693; Header lines that end in \r\n only get the \n stripped, not the \r (unless it's the last header which does get the \r stripped). Patch by Tony Meyer. test_whitespace_continuation_last_header(), test_strip_line_feed_and_carriage_return_in_headers(): New tests. _parse_headers(): Be sure to strip \r\n from the right side of header lines. Index: test_email.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/test/test_email.py,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** test_email.py 13 May 2004 23:17:04 -0000 1.58 --- test_email.py 7 Aug 2004 15:57:52 -0000 1.59 *************** *** 2308,2312 **** self.failUnless(isinstance(msg.get_payload(), str)) ! def test_whitespace_continuaton(self): eq = self.assertEqual # This message contains a line after the Subject: header that has only --- 2308,2312 ---- self.failUnless(isinstance(msg.get_payload(), str)) ! def test_whitespace_continuation(self): eq = self.assertEqual # This message contains a line after the Subject: header that has only *************** *** 2326,2329 **** --- 2326,2347 ---- eq(msg.get_payload(), "Here's the message body\n") + def test_whitespace_continuation_last_header(self): + eq = self.assertEqual + # Like the previous test, but the subject line is the last + # header. + msg = email.message_from_string("""\ + From: aperson@dom.ain + To: bperson@dom.ain + Date: Mon, 8 Apr 2002 15:09:19 -0400 + Message-ID: spam + Subject: the next line has a space on it + \x20 + + Here's the message body + """) + eq(msg['subject'], 'the next line has a space on it\n ') + eq(msg['message-id'], 'spam') + eq(msg.get_payload(), "Here's the message body\n") + def test_crlf_separation(self): eq = self.assertEqual *************** *** 2382,2385 **** --- 2400,2414 ---- self.assertEqual(msg['date'], 'Tue, 20 Aug 2002 16:43:45 +1000') + def test_strip_line_feed_and_carriage_return_in_headers(self): + eq = self.assertEqual + # For [ 1002475 ] email message parser doesn't handle \r\n correctly + value1 = 'text' + value2 = 'more text' + m = 'Header: %s\r\nNext-Header: %s\r\n\r\nBody\r\n\r\n' % ( + value1, value2) + msg = email.message_from_string(m) + eq(msg.get('Header'), value1) + eq(msg.get('Next-Header'), value2) + From akuchling at users.sourceforge.net Sat Aug 7 17:59:59 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 18:00:03 2004 Subject: [Python-checkins] python/nondist/peps pep-0307.txt, 1.31, 1.32 pep-0000.txt, 1.277, 1.278 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10497 Modified Files: pep-0307.txt pep-0000.txt Log Message: Mark PEP 307 as final; fix a typo in PEP 307 Index: pep-0307.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0307.txt,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** pep-0307.txt 4 Aug 2003 19:08:57 -0000 1.31 --- pep-0307.txt 7 Aug 2004 15:59:56 -0000 1.32 *************** *** 4,8 **** Last-Modified: $Date$ Author: Guido van Rossum, Tim Peters ! Status: Draft Type: Standards Track Content-Type: text/plain --- 4,8 ---- Last-Modified: $Date$ Author: Guido van Rossum, Tim Peters ! Status: Final Type: Standards Track Content-Type: text/plain *************** *** 217,221 **** be used by other classes as long as they have append() and extend() methods with the appropriate signature. ! (Whether append() or extend() is used depend on which pickle protocol version is used as well as the number of items to append, so both must be supported.) --- 217,221 ---- be used by other classes as long as they have append() and extend() methods with the appropriate signature. ! (Whether append() or extend() is used depends on which pickle protocol version is used as well as the number of items to append, so both must be supported.) Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.277 retrieving revision 1.278 diff -C2 -d -r1.277 -r1.278 *** pep-0000.txt 6 Aug 2004 16:02:42 -0000 1.277 --- pep-0000.txt 7 Aug 2004 15:59:56 -0000 1.278 *************** *** 110,114 **** S 304 Controlling Generation of Bytecode Files Montanaro S 305 CSV File API Montanaro, et al - S 307 Extensions to the pickle protocol GvR, Peters S 310 Reliable Acquisition/Release Pairs Hudson, Moore S 312 Simple Implicit Lambda Suzi, Martelli --- 110,113 ---- *************** *** 164,167 **** --- 163,167 ---- SF 289 Generator Expressions Hettinger SF 293 Codec Error Handling Callbacks Dörwald + SF 307 Extensions to the pickle protocol GvR, Peters SF 311 Simplified GIL Acquisition for Extensions Hammond SF 322 Reverse Iteration Hettinger *************** *** 331,335 **** S 305 CSV File API Montanaro, et al I 306 How to Change Python's Grammar Hudson ! S 307 Extensions to the pickle protocol GvR, Peters SR 308 If-then-else expression GvR, Hettinger SA 309 Partial Function Application Harris --- 331,335 ---- S 305 CSV File API Montanaro, et al I 306 How to Change Python's Grammar Hudson ! SF 307 Extensions to the pickle protocol GvR, Peters SR 308 If-then-else expression GvR, Hettinger SA 309 Partial Function Application Harris From akuchling at users.sourceforge.net Sat Aug 7 18:24:21 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 18:24:24 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libpickle.tex,1.50,1.51 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14464 Modified Files: libpickle.tex Log Message: [Bug #984952] Include more material from PEP 307. I haven't tried to include all the material on old-style classes using protocols 0,1. The details are lengthy; someone who knows more about the pickle module should decide if they're important enough to be in the docs or not. Index: libpickle.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpickle.tex,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** libpickle.tex 7 Aug 2004 15:49:24 -0000 1.50 --- libpickle.tex 7 Aug 2004 16:24:18 -0000 1.51 *************** *** 516,534 **** If a string is returned, it names a global variable whose contents are ! pickled as normal. When a tuple is returned, it must be between two ! and five elements long, with the following semantics: \begin{itemize} ! \item A callable object, which in the unpickling environment must be ! either a class, a callable registered as a ``safe constructor'' ! (see below), or it must have an attribute ! \member{__safe_for_unpickling__} with a true value. Otherwise, ! an \exception{UnpicklingError} will be raised in the unpickling ! environment. Note that as usual, the callable itself is pickled ! by name. \item A tuple of arguments for the callable object, or \code{None}. ! \deprecated{2.3}{Use the tuple of arguments instead} \item Optionally, the object's state, which will be passed to the object's \method{__setstate__()} method as described in --- 516,549 ---- If a string is returned, it names a global variable whose contents are ! pickled as normal. The string returned by \method{__reduce__} should ! be the object's local name relative to its module; the pickle module ! searches the module namespace to determine the object's module. ! ! When a tuple is returned, it must be between two and five elements ! long. Optional elements can either be omitted, or \code{None} can be provided ! as their value. The semantics of each element are: \begin{itemize} ! \item A callable object that will be called to create the initial ! version of the object. The next element of the tuple will provide ! arguments for this callable, and later elements provide additional ! state information that will subsequently be used to fully reconstruct ! the pickled date. ! ! In the unpickling environment this object must be either a class, a ! callable registered as a ``safe constructor'' (see below), or it must ! have an attribute \member{__safe_for_unpickling__} with a true value. ! Otherwise, an \exception{UnpicklingError} will be raised in the ! unpickling environment. Note that as usual, the callable itself is ! pickled by name. \item A tuple of arguments for the callable object, or \code{None}. ! \deprecated{2.3}{If this item is \code{None}, then instead of calling ! the callable directly, its \method{__basicnew__()} method is called ! without arguments; this method should also return the unpickled ! object. Providing \code{None} is deprecated, however; return a ! tuple of arguments instead.} ! \item Optionally, the object's state, which will be passed to the object's \method{__setstate__()} method as described in *************** *** 557,580 **** \end{itemize} - Upon unpickling, the callable will be called (provided that it meets - the above criteria), passing in the tuple of arguments; it should - return the unpickled object. - - If the second item was \code{None}, then instead of calling the - callable directly, its \method{__basicnew__()} method is called - without arguments. It should also return the unpickled object. - - \deprecated{2.3}{Use the tuple of arguments instead} - - An alternative to implementing a \method{__reduce__()} method on the - object to be pickled, is to register the callable with the - \refmodule[copyreg]{copy_reg} module. This module provides a way - for programs to register ``reduction functions'' and constructors for - user-defined types. Reduction functions have the same semantics and - interface as the \method{__reduce__()} method described above, except - that they are called with a single argument, the object to be pickled. - - The registered constructor is deemed a ``safe constructor'' for purposes - It is sometimes useful to know the protocol version when implementing \method{__reduce__}. This can be done by implementing a method named --- 572,575 ---- *************** *** 591,594 **** --- 586,599 ---- \method{__reduce__}. + An alternative to implementing a \method{__reduce__()} method on the + object to be pickled, is to register the callable with the + \refmodule[copyreg]{copy_reg} module. This module provides a way + for programs to register ``reduction functions'' and constructors for + user-defined types. Reduction functions have the same semantics and + interface as the \method{__reduce__()} method described above, except + that they are called with a single argument, the object to be pickled. + + The registered constructor is deemed a ``safe constructor'' for purposes + of unpickling as described above. From akuchling at users.sourceforge.net Sat Aug 7 18:27:27 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 18:27:29 2004 Subject: [Python-checkins] python/dist/src/Lib pickle.py,1.157,1.158 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14953 Modified Files: pickle.py Log Message: Make 'bin' argument trigger DeprecationWarning Index: pickle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v retrieving revision 1.157 retrieving revision 1.158 diff -C2 -d -r1.157 -r1.158 *** pickle.py 12 Feb 2004 17:35:06 -0000 1.157 --- pickle.py 7 Aug 2004 16:27:24 -0000 1.158 *************** *** 200,204 **** if bin is not None: warnings.warn("The 'bin' argument to Pickler() is deprecated", ! PendingDeprecationWarning) protocol = bin if protocol is None: --- 200,204 ---- if bin is not None: warnings.warn("The 'bin' argument to Pickler() is deprecated", ! DeprecationWarning) protocol = bin if protocol is None: From jhylton at users.sourceforge.net Sat Aug 7 18:28:16 2004 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Sat Aug 7 18:28:20 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_httplib.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15119/test Modified Files: test_httplib.py Log Message: SF bug 874842 and patch 997626: httplib bugs Hack httplib to work with broken Akamai proxies. Make sure that httplib doesn't add extract Accept-Encoding or Content-Length headers if the client has already set them. Index: test_httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_httplib.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_httplib.py 8 Jul 2003 12:36:58 -0000 1.12 --- test_httplib.py 7 Aug 2004 16:28:14 -0000 1.13 *************** *** 3,7 **** import sys ! from test.test_support import verify,verbose class FakeSocket: --- 3,9 ---- import sys ! from unittest import TestCase ! ! from test import test_support class FakeSocket: *************** *** 10,13 **** --- 12,18 ---- self.fileclass = fileclass + def sendall(self, data): + self.data = data + def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': *************** *** 33,36 **** --- 38,74 ---- return data + + class HeaderTests(TestCase): + def test_auto_headers(self): + # Some headers are added automatically, but should not be added by + # .request() if they are explicitly set. + + import httplib + + class HeaderCountingBuffer(list): + def __init__(self): + self.count = {} + def append(self, item): + kv = item.split(':') + if len(kv) > 1: + # item is a 'Key: Value' header string + lcKey = kv[0].lower() + self.count.setdefault(lcKey, 0) + self.count[lcKey] += 1 + list.append(self, item) + + for explicit_header in True, False: + for header in 'Content-length', 'Host', 'Accept-encoding': + conn = httplib.HTTPConnection('example.com') + conn.sock = FakeSocket('blahblahblah') + conn._buffer = HeaderCountingBuffer() + + body = 'spamspamspam' + headers = {} + if explicit_header: + headers[header] = str(len(body)) + conn.request('POST', '/', body, headers) + self.assertEqual(conn._buffer.count[header.lower()], 1) + # Collect output to a buffer so that we don't have to cope with line-ending # issues across platforms. Specifically, the headers will have \r\n pairs *************** *** 111,113 **** --- 149,156 ---- resp.close() + + def test_main(verbose=None): + tests = [HeaderTests,] + test_support.run_unittest(*tests) + test() From jhylton at users.sourceforge.net Sat Aug 7 18:28:16 2004 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Sat Aug 7 18:28:21 2004 Subject: [Python-checkins] python/dist/src/Lib httplib.py,1.85,1.86 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15119 Modified Files: httplib.py Log Message: SF bug 874842 and patch 997626: httplib bugs Hack httplib to work with broken Akamai proxies. Make sure that httplib doesn't add extract Accept-Encoding or Content-Length headers if the client has already set them. Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** httplib.py 5 Jun 2004 13:30:56 -0000 1.85 --- httplib.py 7 Aug 2004 16:28:13 -0000 1.86 *************** *** 345,348 **** --- 345,349 ---- def _check_close(self): + conn = self.msg.getheader('connection') if self.version == 11: # An HTTP/1.1 proxy is assumed to stay open unless *************** *** 353,358 **** return False ! # An HTTP/1.0 response with a Connection header is probably ! # the result of a confused proxy. Ignore it. # For older HTTP, Keep-Alive indiciates persistent connection. --- 354,359 ---- return False ! # Some HTTP/1.0 implementations have support for persistent ! # connections, using rules different than HTTP/1.1. # For older HTTP, Keep-Alive indiciates persistent connection. *************** *** 360,363 **** --- 361,369 ---- return False + # At least Akamai returns a "Connection: Keep-Alive" header, + # which was supposed to be sent by the client. + if conn and "keep-alive" in conn.lower(): + return False + # Proxy-Connection is a netscape hack. pconn = self.msg.getheader('proxy-connection') *************** *** 382,385 **** --- 388,393 ---- return self.fp is None + # XXX It would be nice to have readline and __iter__ for this, too. + def read(self, amt=None): if self.fp is None: *************** *** 729,741 **** def _send_request(self, method, url, body, headers): ! # If headers already contains a host header, then define the ! # optional skip_host argument to putrequest(). The check is ! # harder because field names are case insensitive. ! if 'host' in [k.lower() for k in headers]: ! self.putrequest(method, url, skip_host=1) ! else: ! self.putrequest(method, url) ! if body: self.putheader('Content-Length', str(len(body))) for hdr, value in headers.iteritems(): --- 737,751 ---- def _send_request(self, method, url, body, headers): ! # honour explicitly requested Host: and Accept-Encoding headers ! header_names = dict.fromkeys([k.lower() for k in headers]) ! skips = {} ! if 'host' in header_names: ! skips['skip_host'] = 1 ! if 'accept-encoding' in header_names: ! skips['skip_accept_encoding'] = 1 ! self.putrequest(method, url, **skips) ! ! if body and ('content-length' not in header_names): self.putheader('Content-Length', str(len(body))) for hdr, value in headers.iteritems(): From bwarsaw at users.sourceforge.net Sat Aug 7 18:38:51 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sat Aug 7 18:38:54 2004 Subject: [Python-checkins] python/dist/src/Lib rfc822.py,1.76,1.77 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16756/Lib Modified Files: rfc822.py Log Message: Resolution of bug #997368, "strftime() backward compatibility". Specifically, time.strftime() no longer accepts a 0 in the yday position of a time tuple, since that can crash some platform strftime() implementations. parsedate_tz(): Change the return value to return 1 in the yday position. Update tests in test_rfc822.py and test_email.py Index: rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rfc822.py,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** rfc822.py 11 Nov 2003 19:39:17 -0000 1.76 --- rfc822.py 7 Aug 2004 16:38:38 -0000 1.77 *************** *** 928,932 **** tzsign = 1 tzoffset = tzsign * ( (tzoffset//100)*3600 + (tzoffset % 100)*60) ! tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset) return tuple --- 928,932 ---- tzsign = 1 tzoffset = tzsign * ( (tzoffset//100)*3600 + (tzoffset % 100)*60) ! tuple = (yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset) return tuple From bwarsaw at users.sourceforge.net Sat Aug 7 18:38:52 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sat Aug 7 18:38:55 2004 Subject: [Python-checkins] python/dist/src/Lib/email _parseaddr.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16756/Lib/email Modified Files: _parseaddr.py Log Message: Resolution of bug #997368, "strftime() backward compatibility". Specifically, time.strftime() no longer accepts a 0 in the yday position of a time tuple, since that can crash some platform strftime() implementations. parsedate_tz(): Change the return value to return 1 in the yday position. Update tests in test_rfc822.py and test_email.py Index: _parseaddr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/_parseaddr.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** _parseaddr.py 9 May 2004 03:52:40 -0000 1.8 --- _parseaddr.py 7 Aug 2004 16:38:39 -0000 1.9 *************** *** 117,121 **** tzsign = 1 tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60) ! tuple = (yy, mm, dd, thh, tmm, tss, 0, 0, 0, tzoffset) return tuple --- 117,121 ---- tzsign = 1 tzoffset = tzsign * ( (tzoffset/100)*3600 + (tzoffset % 100)*60) ! tuple = (yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset) return tuple From bwarsaw at users.sourceforge.net Sat Aug 7 18:38:51 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sat Aug 7 18:38:56 2004 Subject: [Python-checkins] python/dist/src/Lib/email/test test_email.py, 1.59, 1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16756/Lib/email/test Modified Files: test_email.py Log Message: Resolution of bug #997368, "strftime() backward compatibility". Specifically, time.strftime() no longer accepts a 0 in the yday position of a time tuple, since that can crash some platform strftime() implementations. parsedate_tz(): Change the return value to return 1 in the yday position. Update tests in test_rfc822.py and test_email.py Index: test_email.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/test/test_email.py,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** test_email.py 7 Aug 2004 15:57:52 -0000 1.59 --- test_email.py 7 Aug 2004 16:38:39 -0000 1.60 *************** *** 2099,2108 **** eq = self.assertEqual eq(Utils.parsedate_tz('25 Feb 2003 13:47:26 -0800'), ! (2003, 2, 25, 13, 47, 26, 0, 0, 0, -28800)) def test_parsedate_compact_no_dayofweek(self): eq = self.assertEqual eq(Utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'), ! (2003, 2, 5, 13, 47, 26, 0, 0, 0, -28800)) def test_parseaddr_empty(self): --- 2099,2108 ---- eq = self.assertEqual eq(Utils.parsedate_tz('25 Feb 2003 13:47:26 -0800'), ! (2003, 2, 25, 13, 47, 26, 0, 1, 0, -28800)) def test_parsedate_compact_no_dayofweek(self): eq = self.assertEqual eq(Utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'), ! (2003, 2, 5, 13, 47, 26, 0, 1, 0, -28800)) def test_parseaddr_empty(self): From bwarsaw at users.sourceforge.net Sat Aug 7 18:39:13 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sat Aug 7 18:39:15 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_rfc822.py, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16756/Lib/test Modified Files: test_rfc822.py Log Message: Resolution of bug #997368, "strftime() backward compatibility". Specifically, time.strftime() no longer accepts a 0 in the yday position of a time tuple, since that can crash some platform strftime() implementations. parsedate_tz(): Change the return value to return 1 in the yday position. Update tests in test_rfc822.py and test_email.py Index: test_rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_rfc822.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** test_rfc822.py 11 Sep 2002 02:32:57 -0000 1.20 --- test_rfc822.py 7 Aug 2004 16:38:40 -0000 1.21 *************** *** 54,58 **** if out: self.assertEqual(out, ! (1999, 1, 13, 23, 57, 35, 0, 0, 0), "date conversion failed") --- 54,58 ---- if out: self.assertEqual(out, ! (1999, 1, 13, 23, 57, 35, 0, 1, 0), "date conversion failed") From mwh at users.sourceforge.net Sat Aug 7 18:41:38 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Sat Aug 7 18:41:43 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.161, 1.162 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17263 Modified Files: libstdtypes.tex Log Message: Point out that the setdefault defaults the value to None. Inspired by Michael Chermside's thinking about patch #748126 (the chief upshot of which thinking was "reject it!"). Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.161 retrieving revision 1.162 diff -C2 -d -r1.161 -r1.162 *** libstdtypes.tex 6 Aug 2004 18:55:09 -0000 1.161 --- libstdtypes.tex 7 Aug 2004 16:41:34 -0000 1.162 *************** *** 1369,1373 **** \item[(5)] \function{setdefault()} is like \function{get()}, except that if \var{k} is missing, \var{x} is both returned and inserted into ! the dictionary as the value of \var{k}. \item[(6)] \function{popitem()} is useful to destructively iterate --- 1369,1373 ---- \item[(5)] \function{setdefault()} is like \function{get()}, except that if \var{k} is missing, \var{x} is both returned and inserted into ! the dictionary as the value of \var{k}. \var{x} defaults to \var{None}. \item[(6)] \function{popitem()} is useful to destructively iterate From akuchling at users.sourceforge.net Sat Aug 7 18:51:33 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 18:51:35 2004 Subject: [Python-checkins] python/dist/src/Lib pickletools.py,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18874 Modified Files: pickletools.py Log Message: Add argument to docstring Index: pickletools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickletools.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** pickletools.py 5 Feb 2003 19:55:53 -0000 1.26 --- pickletools.py 7 Aug 2004 16:51:30 -0000 1.27 *************** *** 7,11 **** Generate all the opcodes in a pickle, as (opcode, arg, position) triples. ! dis(pickle, out=None, indentlevel=4) Print a symbolic disassembly of a pickle. ''' --- 7,11 ---- Generate all the opcodes in a pickle, as (opcode, arg, position) triples. ! dis(pickle, out=None, memo=None, indentlevel=4) Print a symbolic disassembly of a pickle. ''' From akuchling at users.sourceforge.net Sat Aug 7 18:54:01 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 18:54:05 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libpickletools.tex, NONE, 1.1 lib.tex, 1.228, 1.229 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19323 Modified Files: lib.tex Added Files: libpickletools.tex Log Message: [Bug #873146] Document pickletools module (haven't tested the LaTeX yet) --- NEW FILE: libpickletools.tex --- \section{\module{pickletools} --- Tools for pickle developers.} \declaremodule{standard}{pickletools} \modulesynopsis{Contains extensive comments about the pickle protocols and pickle-machine opcodes, as well as some useful functions.} This module contains various constants relating to the intimate details of the \refmodule{pickle} module, some lengthy comments about the implementation, and a few useful functions for analyzing pickled data. The contents of this module are useful for Python core developers who are working on the \module{pickle} and \module{cPickle} implementations; ordinary users of the \module{pickle} module probably won't find the \module{pickletools} module relevant. \begin{funcdesc}{dis}{pickle\optional{, out=None, memo=None, indentlevel=4}} Outputs a symbolic disassembly of the pickle to the file-like object \var{out}, defaulting to \code{sys.stdout}. \var{pickle} can be a string or a file-like object. \var{memo} can be a Python dictionary that will be used as the pickle's memo; it can be used to perform disassemblies across multiple pickles created by the same pickler. Successive levels, indicated by \code{MARK} opcodes in the stream, are indented by \var{indentlevel} spaces. \end{funcdesc} \begin{funcdesc}{genops}{pickle} Provides an iterator over all of the opcodes in a pickle, returning a sequence of \code{(\var{opcode}, \var{arg}, \var{pos})} triples. \var{opcode} is an instance of an \class{OpcodeInfo} class; \var{arg} is the decoded value, as a Python object, of the opcode's argument; \var{pos} is the position at which this opcode is located. \var{pickle} can be a string or a file-like object. \end{funcdesc} Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.228 retrieving revision 1.229 diff -C2 -d -r1.228 -r1.229 *** lib.tex 11 Jul 2004 16:25:25 -0000 1.228 --- lib.tex 7 Aug 2004 16:53:59 -0000 1.229 *************** *** 323,326 **** --- 323,327 ---- \input{libcompileall} \input{libdis} + \input{libpickletools} \input{distutils} From mwh at users.sourceforge.net Sat Aug 7 19:05:45 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Sat Aug 7 19:05:48 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.243,1.244 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21441 Modified Files: tut.tex Log Message: Patch: [ 1003863 ] adds an index entry for __all__ to the tutorial Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.243 retrieving revision 1.244 diff -C2 -d -r1.243 -r1.244 *** tut.tex 21 Jul 2004 17:36:47 -0000 1.243 --- tut.tex 7 Aug 2004 17:05:42 -0000 1.244 *************** *** 2768,2772 **** \subsection{Importing * From a Package \label{pkg-import-star}} %The \code{__all__} Attribute ! Now what happens when the user writes \code{from Sound.Effects import *}? Ideally, one would hope that this somehow goes out to the --- 2768,2772 ---- \subsection{Importing * From a Package \label{pkg-import-star}} %The \code{__all__} Attribute ! \index{__all__} Now what happens when the user writes \code{from Sound.Effects import *}? Ideally, one would hope that this somehow goes out to the From akuchling at users.sourceforge.net Sat Aug 7 19:21:29 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 19:21:32 2004 Subject: [Python-checkins] python/dist/src/Modules selectmodule.c,2.76,2.77 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24297 Modified Files: selectmodule.c Log Message: [Bug #923315] Produce correct result on AIX Index: selectmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/selectmodule.c,v retrieving revision 2.76 retrieving revision 2.77 diff -C2 -d -r2.76 -r2.77 *** selectmodule.c 21 Mar 2004 23:45:42 -0000 2.76 --- selectmodule.c 7 Aug 2004 17:21:27 -0000 2.77 *************** *** 512,516 **** PyTuple_SET_ITEM(value, 0, num); ! num = PyInt_FromLong(self->ufds[i].revents); if (num == NULL) { Py_DECREF(value); --- 512,520 ---- PyTuple_SET_ITEM(value, 0, num); ! /* The &0xffff is a workaround for AIX. 'revents' ! is a 16-bit short, and IBM assigned POLLNVAL ! to be 0x8000, so the conversion to int results ! in a negative number. See SF bug #923315. */ ! num = PyInt_FromLong(self->ufds[i].revents & 0xffff); if (num == NULL) { Py_DECREF(value); From akuchling at users.sourceforge.net Sat Aug 7 19:28:19 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 19:28:22 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libpopen2.tex,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25419 Modified Files: libpopen2.tex Log Message: [Bug #998066] Mention result mismatch Index: libpopen2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpopen2.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** libpopen2.tex 23 Dec 2003 17:01:38 -0000 1.20 --- libpopen2.tex 7 Aug 2004 17:28:17 -0000 1.21 *************** *** 31,34 **** --- 31,36 ---- \function{popen2()}, \function{popen3()}, and \function{popen4()} functions, or the equivalent functions in the \refmodule{os} module. + (Note that the tuples returned by the \module{os} module's functions + are in a different order from the ones returned by the \module{popen2} module.) \begin{funcdesc}{popen2}{cmd\optional{, bufsize\optional{, mode}}} From mwh at users.sourceforge.net Sat Aug 7 19:39:37 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Sat Aug 7 19:39:40 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libxmlrpclib.tex, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26918/lib Modified Files: libxmlrpclib.tex Log Message: Fix [ 1000841 ] "make pdf" failure w/ 2.4 docs in the suggested way, by uglifying a URL. Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** libxmlrpclib.tex 12 May 2004 03:07:27 -0000 1.16 --- libxmlrpclib.tex 7 Aug 2004 17:39:35 -0000 1.17 *************** *** 257,263 **** \versionadded{2.4} ! In \url{http://www.xmlrpc.com/discuss/msgReader\$1208}, an approach ! is presented to encapsulate multiple calls to a remote server into ! a single request. \begin{classdesc}{MultiCall}{server} --- 257,263 ---- \versionadded{2.4} ! In \url{http://www.xmlrpc.com/discuss/msgReader\%241208}, an approach ! is presented to encapsulate multiple calls to a remote server into a ! single request. \begin{classdesc}{MultiCall}{server} From jhylton at users.sourceforge.net Sat Aug 7 19:40:52 2004 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Sat Aug 7 19:40:55 2004 Subject: [Python-checkins] python/dist/src/Lib urllib2.py,1.73,1.74 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27132 Modified Files: urllib2.py Log Message: Fix urllib2.urlopen() handling of chunked content encoding. The change to use the newer httplib interface admitted the possibility that we'd get an HTTP/1.1 chunked response, but the code didn't handle it correctly. The raw socket object can't be pass to addinfourl(), because it would read the undecoded response. Instead, addinfourl() must call HTTPResponse.read(), which will handle the decoding. One extra wrinkle is that the HTTPReponse object can't be passed to addinfourl() either, because it doesn't implement readline() or readlines(). As a quick hack, use socket._fileobject(), which implements those methods on top of a read buffer. (suggested by mwh) Finally, add some tests based on test_urllibnet. Thanks to Andrew Sawyers for originally reporting the chunked problem. Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** urllib2.py 3 Aug 2004 12:59:41 -0000 1.73 --- urllib2.py 7 Aug 2004 17:40:50 -0000 1.74 *************** *** 998,1003 **** # Pick apart the HTTPResponse object to get the addinfourl ! # object initialized properly ! resp = addinfourl(r.fp, r.msg, req.get_full_url()) resp.code = r.status resp.msg = r.reason --- 998,1015 ---- # Pick apart the HTTPResponse object to get the addinfourl ! # object initialized properly. ! ! # Wrap the HTTPResponse object in socket's file object adapter ! # for Windows. That adapter calls recv(), so delegate recv() ! # to read(). This weird wrapping allows the returned object to ! # have readline() and readlines() methods. ! ! # XXX It might be better to extract the read buffering code ! # out of socket._fileobject() and into a base class. ! ! r.recv = r.read ! fp = socket._fileobject(r) ! ! resp = addinfourl(fp, r.msg, req.get_full_url()) resp.code = r.status resp.msg = r.reason From jhylton at users.sourceforge.net Sat Aug 7 19:40:52 2004 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Sat Aug 7 19:40:56 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_urllib2net.py, NONE, 1.1 test_urllib2.py, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27132/test Modified Files: test_urllib2.py Added Files: test_urllib2net.py Log Message: Fix urllib2.urlopen() handling of chunked content encoding. The change to use the newer httplib interface admitted the possibility that we'd get an HTTP/1.1 chunked response, but the code didn't handle it correctly. The raw socket object can't be pass to addinfourl(), because it would read the undecoded response. Instead, addinfourl() must call HTTPResponse.read(), which will handle the decoding. One extra wrinkle is that the HTTPReponse object can't be passed to addinfourl() either, because it doesn't implement readline() or readlines(). As a quick hack, use socket._fileobject(), which implements those methods on top of a read buffer. (suggested by mwh) Finally, add some tests based on test_urllibnet. Thanks to Andrew Sawyers for originally reporting the chunked problem. --- NEW FILE: test_urllib2net.py --- #!/usr/bin/env python import unittest from test import test_support import socket import urllib2 import sys import os import mimetools class URLTimeoutTest(unittest.TestCase): TIMEOUT = 10.0 def setUp(self): socket.setdefaulttimeout(self.TIMEOUT) def tearDown(self): socket.setdefaulttimeout(None) def testURLread(self): f = urllib2.urlopen("http://www.python.org/") x = f.read() class urlopenNetworkTests(unittest.TestCase): """Tests urllib2.urlopen using the network. These tests are not exhaustive. Assuming that testing using files does a good job overall of some of the basic interface features. There are no tests exercising the optional 'data' and 'proxies' arguments. No tests for transparent redirection have been written. setUp is not used for always constructing a connection to 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. """ def test_basic(self): # Simple test expected to pass. open_url = urllib2.urlopen("http://www.python.org/") for attr in ("read", "close", "info", "geturl"): self.assert_(hasattr(open_url, attr), "object returned from " "urlopen lacks the %s attribute" % attr) try: self.assert_(open_url.read(), "calling 'read' failed") finally: open_url.close() def test_info(self): # Test 'info'. open_url = urllib2.urlopen("http://www.python.org/") try: info_obj = open_url.info() finally: open_url.close() self.assert_(isinstance(info_obj, mimetools.Message), "object returned by 'info' is not an instance of " "mimetools.Message") self.assertEqual(info_obj.getsubtype(), "html") def test_geturl(self): # Make sure same URL as opened is returned by geturl. URL = "http://www.python.org/" open_url = urllib2.urlopen(URL) try: gotten_url = open_url.geturl() finally: open_url.close() self.assertEqual(gotten_url, URL) def test_bad_address(self): # Make sure proper exception is raised when connecting to a bogus # address. self.assertRaises(IOError, # SF patch 809915: In Sep 2003, VeriSign started # highjacking invalid .com and .net addresses to # boost traffic to their own site. This test # started failing then. One hopes the .invalid # domain will be spared to serve its defined # purpose. # urllib2.urlopen, "http://www.sadflkjsasadf.com/") urllib2.urlopen, "http://www.python.invalid/") def test_main(): test_support.requires("network") test_support.run_unittest(URLTimeoutTest, urlopenNetworkTests) if __name__ == "__main__": test_main() Index: test_urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_urllib2.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** test_urllib2.py 11 Jul 2004 17:14:13 -0000 1.18 --- test_urllib2.py 7 Aug 2004 17:40:50 -0000 1.19 *************** *** 424,427 **** --- 424,429 ---- self.status = status self.reason = reason + def read(self): + return '' class MockHTTPClass: def __init__(self): From akuchling at users.sourceforge.net Sat Aug 7 19:41:56 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 19:41:59 2004 Subject: [Python-checkins] python/dist/src/Lib sre.py,1.48,1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27345 Modified Files: sre.py Log Message: [Bug #990792] Mention that repl can be a callable Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** sre.py 20 Apr 2004 21:11:11 -0000 1.48 --- sre.py 7 Aug 2004 17:41:54 -0000 1.49 *************** *** 140,144 **** """Return the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in string by the ! replacement repl""" return _compile(pattern, 0).sub(repl, string, count) --- 140,146 ---- """Return the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in string by the ! replacement repl. repl can be either a string or a callable; ! if a callable, it's passed the match object and must return ! a replacement string to be used.""" return _compile(pattern, 0).sub(repl, string, count) *************** *** 148,152 **** non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of ! substitutions that were made.""" return _compile(pattern, 0).subn(repl, string, count) --- 150,156 ---- non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of ! substitutions that were made. repl can be either a string or a ! callable; if a callable, it's passed the match object and must ! return a replacement string to be used.""" return _compile(pattern, 0).subn(repl, string, count) From akuchling at users.sourceforge.net Sat Aug 7 19:53:08 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 19:53:11 2004 Subject: [Python-checkins] python/dist/src/Doc/api abstract.tex,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29139 Modified Files: abstract.tex Log Message: [Bug #991883] Document calling condition Index: abstract.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/abstract.tex,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** abstract.tex 7 Jul 2004 13:07:47 -0000 1.34 --- abstract.tex 7 Aug 2004 17:53:05 -0000 1.35 *************** *** 270,274 **** Call the method named \var{method} of object \var{o} with a variable number of C arguments. The C arguments are described by a ! \cfunction{Py_BuildValue()} 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 --- 270,275 ---- Call the method named \var{method} of object \var{o} with a variable number of C arguments. The C arguments are described by a ! \cfunction{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 From mwh at users.sourceforge.net Sat Aug 7 19:57:19 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Sat Aug 7 19:57:22 2004 Subject: [Python-checkins] python/dist/src/Python getargs.c,2.101,2.102 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29636 Modified Files: getargs.c Log Message: Fix [ 991812 ] PyArg_ParseTuple can miss errors with warnings as exceptions as suggested in the report. This is definitely a 2.3 candidate (as are most of the checkins I've made in the last month...) Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.101 retrieving revision 2.102 diff -C2 -d -r2.101 -r2.102 *** getargs.c 10 Jul 2004 22:20:16 -0000 2.101 --- getargs.c 7 Aug 2004 17:57:16 -0000 2.102 *************** *** 473,477 **** long ival; if (float_argument_error(arg)) ! return NULL; ival = PyInt_AsLong(arg); if (ival == -1 && PyErr_Occurred()) --- 473,477 ---- long ival; if (float_argument_error(arg)) ! return converterr("integer", arg, msgbuf, bufsize); ival = PyInt_AsLong(arg); if (ival == -1 && PyErr_Occurred()) *************** *** 497,501 **** long ival; if (float_argument_error(arg)) ! return NULL; ival = PyInt_AsUnsignedLongMask(arg); if (ival == -1 && PyErr_Occurred()) --- 497,501 ---- long ival; if (float_argument_error(arg)) ! return converterr("integer", arg, msgbuf, bufsize); ival = PyInt_AsUnsignedLongMask(arg); if (ival == -1 && PyErr_Occurred()) *************** *** 510,514 **** long ival; if (float_argument_error(arg)) ! return NULL; ival = PyInt_AsLong(arg); if (ival == -1 && PyErr_Occurred()) --- 510,514 ---- long ival; if (float_argument_error(arg)) ! return converterr("integer", arg, msgbuf, bufsize); ival = PyInt_AsLong(arg); if (ival == -1 && PyErr_Occurred()) *************** *** 534,538 **** long ival; if (float_argument_error(arg)) ! return NULL; ival = PyInt_AsUnsignedLongMask(arg); if (ival == -1 && PyErr_Occurred()) --- 534,538 ---- long ival; if (float_argument_error(arg)) ! return converterr("integer", arg, msgbuf, bufsize); ival = PyInt_AsUnsignedLongMask(arg); if (ival == -1 && PyErr_Occurred()) *************** *** 547,551 **** long ival; if (float_argument_error(arg)) ! return NULL; ival = PyInt_AsLong(arg); if (ival == -1 && PyErr_Occurred()) --- 547,551 ---- long ival; if (float_argument_error(arg)) ! return converterr("integer", arg, msgbuf, bufsize); ival = PyInt_AsLong(arg); if (ival == -1 && PyErr_Occurred()) *************** *** 571,575 **** unsigned int ival; if (float_argument_error(arg)) ! return NULL; ival = PyInt_AsUnsignedLongMask(arg); if (ival == -1 && PyErr_Occurred()) --- 571,575 ---- unsigned int ival; if (float_argument_error(arg)) ! return converterr("integer", arg, msgbuf, bufsize); ival = PyInt_AsUnsignedLongMask(arg); if (ival == -1 && PyErr_Occurred()) *************** *** 584,588 **** long ival; if (float_argument_error(arg)) ! return NULL; ival = PyInt_AsLong(arg); if (ival == -1 && PyErr_Occurred()) --- 584,588 ---- long ival; if (float_argument_error(arg)) ! return converterr("integer", arg, msgbuf, bufsize); ival = PyInt_AsLong(arg); if (ival == -1 && PyErr_Occurred()) *************** *** 621,626 **** unsigned PY_LONG_LONG *p = va_arg(*p_va, unsigned PY_LONG_LONG *); unsigned PY_LONG_LONG ival; - if (float_argument_error(arg)) - return NULL; if (PyInt_Check(arg)) ival = PyInt_AsUnsignedLongMask(arg); --- 621,624 ---- From akuchling at users.sourceforge.net Sat Aug 7 21:02:23 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 21:02:28 2004 Subject: [Python-checkins] python/dist/src/Lib SimpleHTTPServer.py, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7098 Modified Files: SimpleHTTPServer.py Log Message: [Bug #866222] Update docstrings. Index: SimpleHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/SimpleHTTPServer.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** SimpleHTTPServer.py 16 Oct 2003 05:53:16 -0000 1.20 --- SimpleHTTPServer.py 7 Aug 2004 19:02:19 -0000 1.21 *************** *** 26,32 **** This serves files from the current directory and any of its ! subdirectories. It assumes that all files are plain text files ! unless they have the extension ".html" in which case it assumes ! they are HTML files. The GET and HEAD requests are identical except that the HEAD --- 26,31 ---- This serves files from the current directory and any of its ! subdirectories. The MIME type for files is determined by ! calling the .guess_type() method. The GET and HEAD requests are identical except that the HEAD *************** *** 169,173 **** The default implementation looks the file's extension ! up in the table self.extensions_map, using text/plain as a default; however it would be permissible (if slow) to look inside the data to make a better guess. --- 168,172 ---- The default implementation looks the file's extension ! up in the table self.extensions_map, using application/octet-stream as a default; however it would be permissible (if slow) to look inside the data to make a better guess. From akuchling at users.sourceforge.net Sat Aug 7 21:04:21 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 21:04:25 2004 Subject: [Python-checkins] python/dist/src/Lib SimpleHTTPServer.py, 1.19, 1.19.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7338 Modified Files: Tag: release23-branch SimpleHTTPServer.py Log Message: [Bug #866222] Update docstrings. Index: SimpleHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/SimpleHTTPServer.py,v retrieving revision 1.19 retrieving revision 1.19.14.1 diff -C2 -d -r1.19 -r1.19.14.1 *** SimpleHTTPServer.py 1 Jun 2002 14:18:45 -0000 1.19 --- SimpleHTTPServer.py 7 Aug 2004 19:04:19 -0000 1.19.14.1 *************** *** 26,32 **** This serves files from the current directory and any of its ! subdirectories. It assumes that all files are plain text files ! unless they have the extension ".html" in which case it assumes ! they are HTML files. The GET and HEAD requests are identical except that the HEAD --- 26,31 ---- This serves files from the current directory and any of its ! subdirectories. The MIME type for files is determined by ! calling the .guess_type() method. The GET and HEAD requests are identical except that the HEAD *************** *** 169,173 **** The default implementation looks the file's extension ! up in the table self.extensions_map, using text/plain as a default; however it would be permissible (if slow) to look inside the data to make a better guess. --- 168,172 ---- The default implementation looks the file's extension ! up in the table self.extensions_map, using application/octet-stream as a default; however it would be permissible (if slow) to look inside the data to make a better guess. From akuchling at users.sourceforge.net Sat Aug 7 21:06:50 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 21:06:53 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libsimplehttp.tex, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7612 Modified Files: libsimplehttp.tex Log Message: [Bug #866222] Update docs to match the module Index: libsimplehttp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsimplehttp.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** libsimplehttp.tex 1 Dec 2000 15:25:23 -0000 1.3 --- libsimplehttp.tex 7 Aug 2004 19:06:48 -0000 1.4 *************** *** 34,38 **** \begin{memberdesc}{extensions_map} A dictionary mapping suffixes into MIME types. Default is signified ! by an empty string, and is considered to be \code{text/plain}. The mapping is used case-insensitively, and so should contain only lower-cased keys. --- 34,38 ---- \begin{memberdesc}{extensions_map} A dictionary mapping suffixes into MIME types. Default is signified ! by an empty string, and is considered to be \code{application/octet-stream}. The mapping is used case-insensitively, and so should contain only lower-cased keys. *************** *** 52,64 **** a path relative to the current working directory. ! If the request was mapped to a directory, a \code{403} respond is output, ! followed by the explanation \code{'Directory listing not supported'}. ! Any \exception{IOError} exception in opening the requested file, is mapped ! to a \code{404}, \code{'File not found'} error. Otherwise, the content ! type is guessed using the \var{extensions_map} variable. A \code{'Content-type:'} with the guessed content type is output, and then a blank line, signifying end of headers, and then the contents of ! the file. The file is always opened in binary mode. For example usage, see the implementation of the \function{test()} --- 52,72 ---- a path relative to the current working directory. ! If the request was mapped to a directory, the directory is checked for ! a file named \code{index.html} or \code{index.htm} (in that order). ! If found, the file's contents are returned; otherwise a directory ! listing is generated by calling the \method{list_directory()} method. ! This method uses \function{os.listdir()} to scan the directory, and ! returns a \code{404} error response if the \function{listdir()} fails. ! ! If the request was mapped to a file, it is opened and the contents are ! returned. Any \exception{IOError} exception in opening the requested ! file is mapped to a \code{404}, \code{'File not found'} ! error. Otherwise, the content type is guessed using the ! \var{extensions_map} variable. A \code{'Content-type:'} with the guessed content type is output, and then a blank line, signifying end of headers, and then the contents of ! the file. If the file's MIME type starts with \code{text/} the file is ! opened in text mode; otherwise binary mode is used. For example usage, see the implementation of the \function{test()} From akuchling at users.sourceforge.net Sat Aug 7 21:10:39 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 21:10:41 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libsimplehttp.tex, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8104 Modified Files: libsimplehttp.tex Log Message: Various minor edits Index: libsimplehttp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsimplehttp.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** libsimplehttp.tex 7 Aug 2004 19:06:48 -0000 1.4 --- libsimplehttp.tex 7 Aug 2004 19:10:36 -0000 1.5 *************** *** 9,25 **** The \module{SimpleHTTPServer} module defines a request-handler class, ! interface compatible with \class{BaseHTTPServer.BaseHTTPRequestHandler} ! which serves files only from a base directory. The \module{SimpleHTTPServer} module defines the following class: \begin{classdesc}{SimpleHTTPRequestHandler}{request, client_address, server} ! This class is used, to serve files from current directory and below, directly mapping the directory structure to HTTP requests. ! A lot of the work is done by the base class ! \class{BaseHTTPServer.BaseHTTPRequestHandler}, such as parsing the ! request. This class implements the \function{do_GET()} and ! \function{do_HEAD()} functions. \end{classdesc} --- 9,24 ---- The \module{SimpleHTTPServer} module defines a request-handler class, ! interface-compatible with \class{BaseHTTPServer.BaseHTTPRequestHandler}, ! that serves files only from a base directory. The \module{SimpleHTTPServer} module defines the following class: \begin{classdesc}{SimpleHTTPRequestHandler}{request, client_address, server} ! This class is used to serve files from the current directory and below, directly mapping the directory structure to HTTP requests. ! A lot of the work, such as parsing the request, is done by the base ! class \class{BaseHTTPServer.BaseHTTPRequestHandler}. This class ! implements the \function{do_GET()} and \function{do_HEAD()} functions. \end{classdesc} *************** *** 33,37 **** \begin{memberdesc}{extensions_map} ! A dictionary mapping suffixes into MIME types. Default is signified by an empty string, and is considered to be \code{application/octet-stream}. The mapping is used case-insensitively, and so should contain only --- 32,36 ---- \begin{memberdesc}{extensions_map} ! A dictionary mapping suffixes into MIME types. The default is signified by an empty string, and is considered to be \code{application/octet-stream}. The mapping is used case-insensitively, and so should contain only *************** *** 44,48 **** This method serves the \code{'HEAD'} request type: it sends the headers it would send for the equivalent \code{GET} request. See the ! \method{do_GET()} method for more complete explanation of the possible headers. \end{methoddesc} --- 43,47 ---- This method serves the \code{'HEAD'} request type: it sends the headers it would send for the equivalent \code{GET} request. See the ! \method{do_GET()} method for a more complete explanation of the possible headers. \end{methoddesc} *************** *** 62,72 **** returned. Any \exception{IOError} exception in opening the requested file is mapped to a \code{404}, \code{'File not found'} ! error. Otherwise, the content type is guessed using the \var{extensions_map} variable. ! A \code{'Content-type:'} with the guessed content type is output, and ! then a blank line, signifying end of headers, and then the contents of ! the file. If the file's MIME type starts with \code{text/} the file is ! opened in text mode; otherwise binary mode is used. For example usage, see the implementation of the \function{test()} --- 61,73 ---- returned. Any \exception{IOError} exception in opening the requested file is mapped to a \code{404}, \code{'File not found'} ! error. Otherwise, the content type is guessed by calling the ! \method{guess_type()} method, which in turn uses the \var{extensions_map} variable. ! A \code{'Content-type:'} header with the guessed content type is ! output, followed by a blank line signifying the end of the headers, ! and then the contents of the file are output. If the file's MIME type ! starts with \code{text/} the file is opened in text mode; otherwise ! binary mode is used. For example usage, see the implementation of the \function{test()} From tim_one at users.sourceforge.net Sat Aug 7 21:12:29 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Aug 7 21:12:32 2004 Subject: [Python-checkins] python/dist/src/PC getpathp.c,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7480/PC Modified Files: getpathp.c Log Message: SF bug 1003471: Python 1.5.2 security vulnerability This was probably fixed in rev 1.32 of getpath.c, but there are so many paths thru the code that invoke joinpath() it's not at all obvious that it *is* fixed. It doesn't help confidence that a crucial precondition for calling joinpath() was neither documented nor verified. It is now, and joinpath() will barf with a fatal error now rather than overrun the buffer, if the precondition isn't met. Note that this patch only changes the Windows flavor. I attached another patch to the bug report for the POSIX flavor (which I can't test conveniently). Index: getpathp.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/getpathp.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** getpathp.c 18 Aug 2003 17:53:33 -0000 1.32 --- getpathp.c 7 Aug 2004 19:12:27 -0000 1.33 *************** *** 134,138 **** } ! /* guarantees buffer will never overflow MAXPATHLEN+1 bytes */ static void join(char *buffer, char *stuff) --- 134,146 ---- } ! /* Add a path component, by appending stuff to buffer. ! buffer must have at least MAXPATHLEN + 1 bytes allocated, and contain a ! NUL-terminated string with no more than MAXPATHLEN characters (not counting ! the trailing NUL). It's a fatal error if it contains a string longer than ! that (callers must be careful!). If these requirements are met, it's ! guaranteed that buffer will still be a NUL-terminated string with no more ! than MAXPATHLEN characters at exit. If stuff is too long, only as much of ! stuff as fits will be appended. ! */ static void join(char *buffer, char *stuff) *************** *** 146,149 **** --- 154,159 ---- buffer[n++] = SEP; } + if (n > MAXPATHLEN) + Py_FatalError("buffer overflow in getpathp.c's joinpath()"); k = strlen(stuff); if (n + k > MAXPATHLEN) From akuchling at users.sourceforge.net Sat Aug 7 21:13:13 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 21:13:16 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libsimplehttp.tex, 1.3, 1.3.38.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8452 Modified Files: Tag: release23-branch libsimplehttp.tex Log Message: Update docs to match module; various minor edits (copy of rev. 1.5) Index: libsimplehttp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsimplehttp.tex,v retrieving revision 1.3 retrieving revision 1.3.38.1 diff -C2 -d -r1.3 -r1.3.38.1 *** libsimplehttp.tex 1 Dec 2000 15:25:23 -0000 1.3 --- libsimplehttp.tex 7 Aug 2004 19:12:54 -0000 1.3.38.1 *************** *** 9,25 **** The \module{SimpleHTTPServer} module defines a request-handler class, ! interface compatible with \class{BaseHTTPServer.BaseHTTPRequestHandler} ! which serves files only from a base directory. The \module{SimpleHTTPServer} module defines the following class: \begin{classdesc}{SimpleHTTPRequestHandler}{request, client_address, server} ! This class is used, to serve files from current directory and below, directly mapping the directory structure to HTTP requests. ! A lot of the work is done by the base class ! \class{BaseHTTPServer.BaseHTTPRequestHandler}, such as parsing the ! request. This class implements the \function{do_GET()} and ! \function{do_HEAD()} functions. \end{classdesc} --- 9,24 ---- The \module{SimpleHTTPServer} module defines a request-handler class, ! interface-compatible with \class{BaseHTTPServer.BaseHTTPRequestHandler}, ! that serves files only from a base directory. The \module{SimpleHTTPServer} module defines the following class: \begin{classdesc}{SimpleHTTPRequestHandler}{request, client_address, server} ! This class is used to serve files from the current directory and below, directly mapping the directory structure to HTTP requests. ! A lot of the work, such as parsing the request, is done by the base ! class \class{BaseHTTPServer.BaseHTTPRequestHandler}. This class ! implements the \function{do_GET()} and \function{do_HEAD()} functions. \end{classdesc} *************** *** 33,38 **** \begin{memberdesc}{extensions_map} ! A dictionary mapping suffixes into MIME types. Default is signified ! by an empty string, and is considered to be \code{text/plain}. The mapping is used case-insensitively, and so should contain only lower-cased keys. --- 32,37 ---- \begin{memberdesc}{extensions_map} ! A dictionary mapping suffixes into MIME types. The default is signified ! by an empty string, and is considered to be \code{application/octet-stream}. The mapping is used case-insensitively, and so should contain only lower-cased keys. *************** *** 44,48 **** This method serves the \code{'HEAD'} request type: it sends the headers it would send for the equivalent \code{GET} request. See the ! \method{do_GET()} method for more complete explanation of the possible headers. \end{methoddesc} --- 43,47 ---- This method serves the \code{'HEAD'} request type: it sends the headers it would send for the equivalent \code{GET} request. See the ! \method{do_GET()} method for a more complete explanation of the possible headers. \end{methoddesc} *************** *** 52,64 **** a path relative to the current working directory. ! If the request was mapped to a directory, a \code{403} respond is output, ! followed by the explanation \code{'Directory listing not supported'}. ! Any \exception{IOError} exception in opening the requested file, is mapped ! to a \code{404}, \code{'File not found'} error. Otherwise, the content ! type is guessed using the \var{extensions_map} variable. ! A \code{'Content-type:'} with the guessed content type is output, and ! then a blank line, signifying end of headers, and then the contents of ! the file. The file is always opened in binary mode. For example usage, see the implementation of the \function{test()} --- 51,73 ---- a path relative to the current working directory. ! If the request was mapped to a directory, the directory is checked for ! a file named \code{index.html} or \code{index.htm} (in that order). ! If found, the file's contents are returned; otherwise a directory ! listing is generated by calling the \method{list_directory()} method. ! This method uses \function{os.listdir()} to scan the directory, and ! returns a \code{404} error response if the \function{listdir()} fails. ! If the request was mapped to a file, it is opened and the contents are ! returned. Any \exception{IOError} exception in opening the requested ! file is mapped to a \code{404}, \code{'File not found'} ! error. Otherwise, the content type is guessed by calling the ! \method{guess_type()} method, which in turn uses the ! \var{extensions_map} variable. ! ! A \code{'Content-type:'} header with the guessed content type is ! output, followed by a blank line signifying the end of the headers, ! and then the contents of the file are output. If the file's MIME type ! starts with \code{text/} the file is opened in text mode; otherwise ! binary mode is used. For example usage, see the implementation of the \function{test()} From akuchling at users.sourceforge.net Sat Aug 7 21:16:35 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 21:16:38 2004 Subject: [Python-checkins] python/dist/src/Doc/ref ref5.tex,1.81,1.82 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8867 Modified Files: ref5.tex Log Message: [Bug #827209] Add footnote from Alex M. about listcomps leaking their index variables Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** ref5.tex 2 Jun 2004 12:54:33 -0000 1.81 --- ref5.tex 7 Aug 2004 19:16:32 -0000 1.82 *************** *** 185,189 **** nesting from left to right, and evaluating the expression to produce a list element ! each time the innermost block is reached. \obindex{list} \indexii{empty}{list} --- 185,193 ---- nesting from left to right, and evaluating the expression to produce a list element ! each time the innermost block is reached\footnote{In Python 2.3, a ! list comprehension "leaks" the control variables of each ! \samp{for} it contains into the containing scope. However, this ! behavior is deprecated, and relying on it will not work once this ! bug is fixed in a future release}. \obindex{list} \indexii{empty}{list} From jhylton at users.sourceforge.net Sat Aug 7 21:20:07 2004 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Sat Aug 7 21:20:10 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_builtin.py, 1.33, 1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9225/Lib/test Modified Files: test_builtin.py Log Message: Subclasses of string can no longer be interned. The semantics of interning were not clear here -- a subclass could be mutable, for example -- and had bugs. Explicitly interning a subclass of string via intern() will raise a TypeError. Internal operations that attempt to intern a string subclass will have no effect. Added a few tests to test_builtin that includes the old buggy code and verifies that calls like PyObject_SetAttr() don't fail. Perhaps these tests should have gone in test_string. Index: test_builtin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** test_builtin.py 7 Aug 2004 04:55:30 -0000 1.33 --- test_builtin.py 7 Aug 2004 19:20:05 -0000 1.34 *************** *** 609,612 **** --- 609,629 ---- self.assert_(intern(s2) is s) + # Subclasses of string can't be interned, because they + # provide too much opportunity for insane things to happen. + # We don't want them in the interned dict and if they aren't + # actually interned, we don't want to create the appearance + # that they are by allowing intern() to succeeed. + class S(str): + def __hash__(self): + return 123 + + self.assertRaises(TypeError, intern, S("abc")) + + # It's still safe to pass these strings to routines that + # call intern internally, e.g. PyObject_SetAttr(). + s = S("abc") + setattr(s, s, s) + self.assertEqual(getattr(s, s), s) + def test_iter(self): self.assertRaises(TypeError, iter) From jhylton at users.sourceforge.net Sat Aug 7 21:20:08 2004 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Sat Aug 7 21:20:11 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1077,1.1078 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9225/Misc Modified Files: NEWS Log Message: Subclasses of string can no longer be interned. The semantics of interning were not clear here -- a subclass could be mutable, for example -- and had bugs. Explicitly interning a subclass of string via intern() will raise a TypeError. Internal operations that attempt to intern a string subclass will have no effect. Added a few tests to test_builtin that includes the old buggy code and verifies that calls like PyObject_SetAttr() don't fail. Perhaps these tests should have gone in test_string. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1077 retrieving revision 1.1078 diff -C2 -d -r1.1077 -r1.1078 *** NEWS 7 Aug 2004 14:03:33 -0000 1.1077 --- NEWS 7 Aug 2004 19:20:05 -0000 1.1078 *************** *** 13,16 **** --- 13,22 ---- ----------------- + Subclasses of string can no longer be interned. The semantics of + interning were not clear here -- a subclass could be mutable, for + example -- and had bugs. Explicitly interning a subclass of string + via intern() will raise a TypeError. Internal operations that attempt + to intern a string subclass will have no effect. + Extension modules ----------------- From jhylton at users.sourceforge.net Sat Aug 7 21:20:08 2004 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Sat Aug 7 21:20:13 2004 Subject: [Python-checkins] python/dist/src/Objects stringobject.c, 2.221, 2.222 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9225/Objects Modified Files: stringobject.c Log Message: Subclasses of string can no longer be interned. The semantics of interning were not clear here -- a subclass could be mutable, for example -- and had bugs. Explicitly interning a subclass of string via intern() will raise a TypeError. Internal operations that attempt to intern a string subclass will have no effect. Added a few tests to test_builtin that includes the old buggy code and verifies that calls like PyObject_SetAttr() don't fail. Perhaps these tests should have gone in test_string. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.221 retrieving revision 2.222 diff -C2 -d -r2.221 -r2.222 *** stringobject.c 8 Jul 2004 19:13:55 -0000 2.221 --- stringobject.c 7 Aug 2004 19:20:05 -0000 2.222 *************** *** 4314,4317 **** --- 4314,4321 ---- if (s == NULL || !PyString_Check(s)) Py_FatalError("PyString_InternInPlace: strings only please!"); + /* If it's a string subclass, we don't really know what putting + it in the interned dict might do. */ + if (!PyString_CheckExact(s)) + return; if (PyString_CHECK_INTERNED(s)) return; *************** *** 4323,4327 **** } } ! if ((t = PyDict_GetItem(interned, (PyObject *)s)) != NULL) { Py_INCREF(t); Py_DECREF(*p); --- 4327,4332 ---- } } ! t = PyDict_GetItem(interned, (PyObject *)s); ! if (t) { Py_INCREF(t); Py_DECREF(*p); *************** *** 4329,4356 **** return; } - /* Ensure that only true string objects appear in the intern dict */ - if (!PyString_CheckExact(s)) { - t = PyString_FromStringAndSize(PyString_AS_STRING(s), - PyString_GET_SIZE(s)); - if (t == NULL) { - PyErr_Clear(); - return; - } - } else { - t = (PyObject*) s; - Py_INCREF(t); - } ! if (PyDict_SetItem(interned, t, t) == 0) { ! /* The two references in interned are not counted by ! refcnt. The string deallocator will take care of this */ ! ((PyObject *)t)->ob_refcnt-=2; ! PyString_CHECK_INTERNED(t) = SSTATE_INTERNED_MORTAL; ! Py_DECREF(*p); ! *p = t; return; } ! Py_DECREF(t); ! PyErr_Clear(); } --- 4334,4346 ---- return; } ! if (PyDict_SetItem(interned, s, s) < 0) { ! PyErr_Clear(); return; } ! /* The two references in interned are not counted by refcnt. ! The string deallocator will take care of this */ ! (*p)->ob_refcnt -= 2; ! PyString_CHECK_INTERNED(s) = SSTATE_INTERNED_MORTAL; } From jhylton at users.sourceforge.net Sat Aug 7 21:20:08 2004 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Sat Aug 7 21:20:14 2004 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.315,2.316 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9225/Python Modified Files: bltinmodule.c Log Message: Subclasses of string can no longer be interned. The semantics of interning were not clear here -- a subclass could be mutable, for example -- and had bugs. Explicitly interning a subclass of string via intern() will raise a TypeError. Internal operations that attempt to intern a string subclass will have no effect. Added a few tests to test_builtin that includes the old buggy code and verifies that calls like PyObject_SetAttr() don't fail. Perhaps these tests should have gone in test_string. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.315 retrieving revision 2.316 diff -C2 -d -r2.315 -r2.316 *** bltinmodule.c 2 Aug 2004 13:21:09 -0000 2.315 --- bltinmodule.c 7 Aug 2004 19:20:05 -0000 2.316 *************** *** 1036,1039 **** --- 1036,1044 ---- if (!PyArg_ParseTuple(args, "S:intern", &s)) return NULL; + if (!PyString_CheckExact(s)) { + PyErr_SetString(PyExc_TypeError, + "can't intern subclass of string"); + return NULL; + } Py_INCREF(s); PyString_InternInPlace(&s); From jhylton at users.sourceforge.net Sat Aug 7 21:21:58 2004 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Sat Aug 7 21:22:01 2004 Subject: [Python-checkins] python/dist/src/Lib/compiler pycodegen.py, 1.70, 1.71 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9546/Lib/compiler Modified Files: pycodegen.py Log Message: SF patch 836879. Don't generate code for asserts in -O mode. Index: pycodegen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/pycodegen.py,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** pycodegen.py 4 Aug 2004 02:36:17 -0000 1.70 --- pycodegen.py 7 Aug 2004 19:21:56 -0000 1.71 *************** *** 708,732 **** # XXX would be interesting to implement this via a # transformation of the AST before this stage ! end = self.newBlock() ! self.set_lineno(node) ! # XXX __debug__ and AssertionError appear to be special cases ! # -- they are always loaded as globals even if there are local ! # names. I guess this is a sort of renaming op. ! self.emit('LOAD_GLOBAL', '__debug__') ! self.emit('JUMP_IF_FALSE', end) ! self.nextBlock() ! self.emit('POP_TOP') ! self.visit(node.test) ! self.emit('JUMP_IF_TRUE', end) ! self.nextBlock() ! self.emit('POP_TOP') ! self.emit('LOAD_GLOBAL', 'AssertionError') ! if node.fail: ! self.visit(node.fail) ! self.emit('RAISE_VARARGS', 2) ! else: ! self.emit('RAISE_VARARGS', 1) ! self.nextBlock(end) ! self.emit('POP_TOP') def visitRaise(self, node): --- 708,730 ---- # XXX would be interesting to implement this via a # transformation of the AST before this stage ! if __debug__: ! end = self.newBlock() ! self.set_lineno(node) ! # XXX AssertionError appears to be special case -- it is always ! # loaded as a global even if there is a local name. I guess this ! # is a sort of renaming op. ! self.nextBlock() ! self.visit(node.test) ! self.emit('JUMP_IF_TRUE', end) ! self.nextBlock() ! self.emit('POP_TOP') ! self.emit('LOAD_GLOBAL', 'AssertionError') ! if node.fail: ! self.visit(node.fail) ! self.emit('RAISE_VARARGS', 2) ! else: ! self.emit('RAISE_VARARGS', 1) ! self.nextBlock(end) ! self.emit('POP_TOP') def visitRaise(self, node): From akuchling at users.sourceforge.net Sat Aug 7 21:22:02 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 21:22:04 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libundoc.tex,1.87,1.88 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9561 Modified Files: libundoc.tex Log Message: Remove various modules that have been documented Index: libundoc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libundoc.tex,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** libundoc.tex 30 Jul 2003 02:55:27 -0000 1.87 --- libundoc.tex 7 Aug 2004 19:21:59 -0000 1.88 *************** *** 16,23 **** \begin{description} ! \item[\module{test}] ! --- Regression testing framework. This is used for the Python ! regression test, but is useful for other Python libraries as well. ! This is a package rather than a single module. \end{description} --- 16,20 ---- \begin{description} ! \item None at this time. \end{description} *************** *** 33,51 **** \item[\module{ihooks}] --- Import hook support (for \refmodule{rexec}; may become obsolete). - - \item[\module{platform}] - --- This module tries to retrieve as much platform identifying data as - possible. It makes this information available via function APIs. - If called from the command line, it prints the platform information - concatenated as single string to \code{sys.stdout}. The output format - is useable as part of a filename. - \versionadded{2.3} - - \item[\module{smtpd}] - --- An SMTP daemon implementation which meets the minimum requirements - for \rfc{821} conformance. \end{description} \section{Platform specific modules} --- 30,37 ---- \item[\module{ihooks}] --- Import hook support (for \refmodule{rexec}; may become obsolete). \end{description} + \section{Platform specific modules} From jhylton at users.sourceforge.net Sat Aug 7 21:25:37 2004 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Sat Aug 7 21:25:40 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_compiler.py, NONE, 1.1 regrtest.py, 1.158, 1.159 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10095/Lib/test Modified Files: regrtest.py Added Files: test_compiler.py Log Message: Add a trivial test for the compiler package, guarded by compiler resource. This test is insanely slow, so it requires a resource. On my machine, it also appears to dump core. I think the problem is a stack overflow, but haven't been able to confirm. --- NEW FILE: test_compiler.py --- import compiler import os import test.test_support import unittest class CompilerTest(unittest.TestCase): def testCompileLibrary(self): # A simple but large test. Compile all the code in the # standard library and its test suite. This doesn't verify # that any of the code is correct, merely the compiler is able # to generate some kind of code for it. libdir = os.path.dirname(unittest.__file__) testdir = os.path.dirname(test.test_support.__file__) for dir in [libdir, testdir]: for path in os.listdir(dir): if not path.endswith(".py"): continue f = open(os.path.join(dir, path), "r") buf = f.read() f.close() compiler.compile(buf, path, "exec") def test_main(): test.test_support.requires("compiler") test.test_support.run_unittest(CompilerTest) if __name__ == "__main__": test_main() Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.158 retrieving revision 1.159 diff -C2 -d -r1.158 -r1.159 *** regrtest.py 4 Aug 2004 02:32:03 -0000 1.158 --- regrtest.py 7 Aug 2004 19:25:33 -0000 1.159 *************** *** 84,87 **** --- 84,91 ---- verifies compliance with standards. + compiler - Test the compiler package by compiling all the source + in the standard library and test suite. This takes + a long time. + To enable all resources except one, use '-uall,-'. For example, to run all the tests except for the bsddb tests, give the *************** *** 127,131 **** RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb', ! 'decimal') --- 131,135 ---- RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb', ! 'decimal', 'compiler') From arigo at users.sourceforge.net Sat Aug 7 21:27:41 2004 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Sat Aug 7 21:27:44 2004 Subject: [Python-checkins] python/dist/src/Objects stringobject.c, 2.222, 2.223 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10229 Modified Files: stringobject.c Log Message: Fixed some compiler warnings. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.222 retrieving revision 2.223 diff -C2 -d -r2.222 -r2.223 *** stringobject.c 7 Aug 2004 19:20:05 -0000 2.222 --- stringobject.c 7 Aug 2004 19:27:39 -0000 2.223 *************** *** 4335,4339 **** } ! if (PyDict_SetItem(interned, s, s) < 0) { PyErr_Clear(); return; --- 4335,4339 ---- } ! if (PyDict_SetItem(interned, (PyObject *)s, (PyObject *)s) < 0) { PyErr_Clear(); return; *************** *** 4341,4345 **** /* The two references in interned are not counted by refcnt. The string deallocator will take care of this */ ! (*p)->ob_refcnt -= 2; PyString_CHECK_INTERNED(s) = SSTATE_INTERNED_MORTAL; } --- 4341,4345 ---- /* The two references in interned are not counted by refcnt. The string deallocator will take care of this */ ! s->ob_refcnt -= 2; PyString_CHECK_INTERNED(s) = SSTATE_INTERNED_MORTAL; } From mwh at users.sourceforge.net Sat Aug 7 22:11:34 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Sat Aug 7 22:11:37 2004 Subject: [Python-checkins] python/dist/src/Misc gdbinit,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16391 Modified Files: gdbinit Log Message: eval_frame now has a PyAPI-style name Index: gdbinit =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/gdbinit,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** gdbinit 2 Apr 2004 14:53:55 -0000 1.6 --- gdbinit 7 Aug 2004 20:11:22 -0000 1.7 *************** *** 66,70 **** define pystack while $pc < Py_Main || $pc > Py_GetArgcArgv ! if $pc > eval_frame && $pc < PyEval_EvalCodeEx pyframe end --- 66,70 ---- define pystack while $pc < Py_Main || $pc > Py_GetArgcArgv ! if $pc > PyEval_EvalFrame && $pc < PyEval_EvalCodeEx pyframe end From akuchling at users.sourceforge.net Sat Aug 7 22:13:36 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 22:13:39 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libmodulefinder.tex, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16654 Added Files: libmodulefinder.tex Log Message: [Bug #914375] Crude modulefinder docs, but the module's code is very hard to read and it's not clear which bits are public and which aren't. The module's author should really be doing this (and using docstrings in the code, too) --- NEW FILE: libmodulefinder.tex --- \section{\module{modulefinder} --- Find modules used by a script} \sectionauthor{A.M. Kuchling}{amk@amk.ca} \declaremodule{standard}{modulefinder} \modulesynopsis{Find modules used by a script.} This module provides a \class{ModuleFinder} class that can be used to determine the set of modules imported by a script. \code{modulefinder.py} can also be run as a script, giving the filename of a Python script as its argument, after which a report of the imported modules will be printed. \begin{funcdesc}{AddPackagePath}{pkg_name, path} Record that the package named \var{pkg_name} can be found in the specified \var{path}. \end{funcdesc} \begin{funcdesc}{ReplacePackage}{oldname, newname} Allows specifying that the module named \var{oldname} is in fact the package named \var{newname}. The most common usage would be to handle how the \module{_xmlplus} package replaces the \module{xml} package. \end{funcdesc} \begin{classdesc}{ModuleFinder}{\optional{path=None, debug=0, excludes=[], replace_paths=[]}} This class provides \method{run_script()} and \method{report()} methods to determine the set of modules imported by a script. \var{path} can be a list of directories to search for modules; if not specified, \code{sys.path} is used. \var{debug} sets the debugging level; higher values make the class print debugging messages about what it's doing. \var{excludes} is a list of module names to exclude from the analysis. \var{replace_paths} is a list of \code{(\var{oldpath}, \var{newpath})} tuples that will be replaced in module paths. \end{classdesc} \begin{methoddesc}[ModuleFinder]{report}{} Print a report to standard output that lists the modules imported by the script and their paths, as well as modules that are missing or seem to be missing. \end{methoddesc} \begin{methoddesc}[ModuleFinder]{run_script}{pathname} Analyze the contents of the \var{pathname} file, which must contain Python code. \end{methoddesc} From akuchling at users.sourceforge.net Sat Aug 7 22:17:52 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 22:17:54 2004 Subject: [Python-checkins] python/dist/src/Doc/api newtypes.tex,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17117 Modified Files: newtypes.tex Log Message: Use LaTeX markup Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/newtypes.tex,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** newtypes.tex 15 Jul 2004 04:05:59 -0000 1.33 --- newtypes.tex 7 Aug 2004 20:17:48 -0000 1.34 *************** *** 1131,1135 **** If the value of this field is greater than zero, it specifies the offset from the start of the instance structure. If the value is ! less than zero, it specifies the offset from the *end* of the instance structure. A negative offset is more expensive to use, and should only be used when the instance structure contains a --- 1131,1135 ---- If the value of this field is greater than zero, it specifies the offset from the start of the instance structure. If the value is ! less than zero, it specifies the offset from the \emph{end} of the instance structure. A negative offset is more expensive to use, and should only be used when the instance structure contains a From akuchling at users.sourceforge.net Sat Aug 7 22:19:27 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 22:19:30 2004 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.54,1.55 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17308 Modified Files: concrete.tex Log Message: [Patch #1003861 from Dima Dorfman] Fix markup in concrete.tex: PyObject* o -> PyObject *o to be consistent with the rest of the file - Correct markup for Py_True - Remove duplicate description of PyBool_Check Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** concrete.tex 4 Aug 2004 07:38:33 -0000 1.54 --- concrete.tex 7 Aug 2004 20:19:24 -0000 1.55 *************** *** 122,126 **** \end{cvardesc} ! \begin{cfuncdesc}{int}{PyInt_Check}{PyObject* o} Returns true if \var{o} is of type \cdata{PyInt_Type} or a subtype of \cdata{PyInt_Type}. --- 122,126 ---- \end{cvardesc} ! \begin{cfuncdesc}{int}{PyInt_Check}{PyObject *o} Returns true if \var{o} is of type \cdata{PyInt_Type} or a subtype of \cdata{PyInt_Type}. *************** *** 128,132 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyInt_CheckExact}{PyObject* o} Returns true if \var{o} is of type \cdata{PyInt_Type}, but not a subtype of \cdata{PyInt_Type}. --- 128,132 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyInt_CheckExact}{PyObject *o} Returns true if \var{o} is of type \cdata{PyInt_Type}, but not a subtype of \cdata{PyInt_Type}. *************** *** 200,204 **** booleans. The following macros are available, however. ! \begin{cfuncdesc}{int}{PyBool_Check}{PyObject* o} Returns true if \var{o} is of type \cdata{PyBool_Type}. \versionadded{2.3} --- 200,204 ---- booleans. The following macros are available, however. ! \begin{cfuncdesc}{int}{PyBool_Check}{PyObject *o} Returns true if \var{o} is of type \cdata{PyBool_Type}. \versionadded{2.3} *************** *** 222,235 **** \begin{csimplemacrodesc}{Py_RETURN_TRUE} ! Return Py_True from a function, properly incrementing its reference ! count. \versionadded{2.4} \end{csimplemacrodesc} - \begin{cfuncdesc}{int}{PyBool_Check}{PyObject* o} - Returns true if \var{o} is of type \cdata{PyBool_Type}. - \versionadded{2.3} - \end{cfuncdesc} - \begin{cfuncdesc}{int}{PyBool_FromLong}{long v} Returns \constant{Py_True} or \constant{Py_False} depending on the --- 222,230 ---- \begin{csimplemacrodesc}{Py_RETURN_TRUE} ! Return \constant{Py_True} from a function, properly incrementing its ! reference count. \versionadded{2.4} \end{csimplemacrodesc} \begin{cfuncdesc}{int}{PyBool_FromLong}{long v} Returns \constant{Py_True} or \constant{Py_False} depending on the From akuchling at users.sourceforge.net Sat Aug 7 22:25:58 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 22:26:02 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libpickle.tex,1.51,1.52 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18103 Modified Files: libpickle.tex Log Message: [Patch #999280 ] Update kwargs in pickle docs to match implementations Index: libpickle.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpickle.tex,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** libpickle.tex 7 Aug 2004 16:24:18 -0000 1.51 --- libpickle.tex 7 Aug 2004 20:25:55 -0000 1.52 *************** *** 171,180 **** following functions to make this process more convenient: ! \begin{funcdesc}{dump}{object, file\optional{, protocol\optional{, bin}}} ! Write a pickled representation of \var{object} to the open file object \var{file}. This is equivalent to ! \code{Pickler(\var{file}, \var{protocol}, \var{bin}).dump(\var{object})}. ! If the \var{protocol} parameter is ommitted, protocol 0 is used. If \var{protocol} is specified as a negative value or \constant{HIGHEST_PROTOCOL}, --- 171,180 ---- following functions to make this process more convenient: ! \begin{funcdesc}{dump}{obj, file\optional{, protocol\optional{, bin}}} ! Write a pickled representation of \var{obj} to the open file object \var{file}. This is equivalent to ! \code{Pickler(\var{file}, \var{protocol}, \var{bin}).dump(\var{obj})}. ! If the \var{protocol} parameter is omitted, protocol 0 is used. If \var{protocol} is specified as a negative value or \constant{HIGHEST_PROTOCOL}, *************** *** 212,220 **** \end{funcdesc} ! \begin{funcdesc}{dumps}{object\optional{, protocol\optional{, bin}}} Return the pickled representation of the object as a string, instead of writing it to a file. ! If the \var{protocol} parameter is ommitted, protocol 0 is used. If \var{protocol} is specified as a negative value or \constant{HIGHEST_PROTOCOL}, --- 212,220 ---- \end{funcdesc} ! \begin{funcdesc}{dumps}{obj\optional{, protocol\optional{, bin}}} Return the pickled representation of the object as a string, instead of writing it to a file. ! If the \var{protocol} parameter is omitted, protocol 0 is used. If \var{protocol} is specified as a negative value or \constant{HIGHEST_PROTOCOL}, *************** *** 267,271 **** stream. ! If the \var{protocol} parameter is ommitted, protocol 0 is used. If \var{protocol} is specified as a negative value, the highest protocol version will be used. --- 267,271 ---- stream. ! If the \var{protocol} parameter is omitted, protocol 0 is used. If \var{protocol} is specified as a negative value, the highest protocol version will be used. *************** *** 287,292 **** \class{Pickler} objects define one (or two) public methods: ! \begin{methoddesc}[Pickler]{dump}{object} ! Write a pickled representation of \var{object} to the open file object given in the constructor. Either the binary or \ASCII{} format will be used, depending on the value of the \var{bin} flag passed to the --- 287,292 ---- \class{Pickler} objects define one (or two) public methods: ! \begin{methoddesc}[Pickler]{dump}{obj} ! Write a pickled representation of \var{obj} to the open file object given in the constructor. Either the binary or \ASCII{} format will be used, depending on the value of the \var{bin} flag passed to the From arigo at users.sourceforge.net Sat Aug 7 22:30:06 2004 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Sat Aug 7 22:30:09 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py, 1.201, 1.202 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18490 Modified Files: test_descr.py Log Message: Removing tests that fail because of changes in PyString_InternInPlace(), as discussed on IRC. The equivalent tests for the new behavior are in test_builtin.py. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.201 retrieving revision 1.202 diff -C2 -d -r1.201 -r1.202 *** test_descr.py 25 Mar 2004 02:19:34 -0000 1.201 --- test_descr.py 7 Aug 2004 20:30:03 -0000 1.202 *************** *** 2294,2313 **** vereq(s.lower(), base) - s = madstring("x y") - vereq(s, "x y") - verify(intern(s).__class__ is str) - verify(intern(s) is intern("x y")) - vereq(intern(s), "x y") - - i = intern("y x") - s = madstring("y x") - vereq(s, i) - verify(intern(s).__class__ is str) - verify(intern(s) is i) - - s = madstring(i) - verify(intern(s).__class__ is str) - verify(intern(s) is i) - class madunicode(unicode): _rev = None --- 2294,2297 ---- From arigo at users.sourceforge.net Sat Aug 7 22:58:34 2004 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Sat Aug 7 22:58:38 2004 Subject: [Python-checkins] python/dist/src/Python ceval.c,2.413,2.414 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21715/Python Modified Files: ceval.c Log Message: This was quite a dark bug in my recent in-place string concatenation hack: it would resize *interned* strings in-place! This occurred because their reference counts do not have their expected value -- stringobject.c hacks them. Mea culpa. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.413 retrieving revision 2.414 diff -C2 -d -r2.413 -r2.414 *** ceval.c 6 Aug 2004 18:43:09 -0000 2.413 --- ceval.c 7 Aug 2004 20:58:32 -0000 2.414 *************** *** 4254,4258 **** } ! if (v->ob_refcnt == 1) { /* Now we own the last reference to 'v', so we can resize it * in-place. --- 4254,4258 ---- } ! if (v->ob_refcnt == 1 && !PyString_CHECK_INTERNED(v)) { /* Now we own the last reference to 'v', so we can resize it * in-place. From arigo at users.sourceforge.net Sat Aug 7 22:58:34 2004 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Sat Aug 7 22:58:39 2004 Subject: [Python-checkins] python/dist/src/Objects stringobject.c, 2.223, 2.224 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21715/Objects Modified Files: stringobject.c Log Message: This was quite a dark bug in my recent in-place string concatenation hack: it would resize *interned* strings in-place! This occurred because their reference counts do not have their expected value -- stringobject.c hacks them. Mea culpa. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.223 retrieving revision 2.224 diff -C2 -d -r2.223 -r2.224 *** stringobject.c 7 Aug 2004 19:27:39 -0000 2.223 --- stringobject.c 7 Aug 2004 20:58:32 -0000 2.224 *************** *** 3514,3518 **** register PyStringObject *sv; v = *pv; ! if (!PyString_Check(v) || v->ob_refcnt != 1 || newsize < 0) { *pv = 0; Py_DECREF(v); --- 3514,3519 ---- register PyStringObject *sv; v = *pv; ! if (!PyString_Check(v) || v->ob_refcnt != 1 || newsize < 0 || ! PyString_CHECK_INTERNED(v)) { *pv = 0; Py_DECREF(v); From mwh at users.sourceforge.net Sat Aug 7 23:13:49 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Sat Aug 7 23:13:52 2004 Subject: [Python-checkins] python/dist/src/Tools/faqwiz faqwiz.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/faqwiz In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24243 Modified Files: faqwiz.py Log Message: Fix [ 777659 ] Uninitialized variable used in Tools/faqwiz/faqwiz.py with help from jlgijsbers on #python-dev IRC. Index: faqwiz.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/faqwiz/faqwiz.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** faqwiz.py 18 Jul 2004 06:02:02 -0000 1.30 --- faqwiz.py 7 Aug 2004 21:13:46 -0000 1.31 *************** *** 809,813 **** import tempfile tf = tempfile.NamedTemporaryFile() ! emit(LOGHEADER, self.ui, os.environ, date=date, _file=tfn) tf.flush() tf.seek(0) --- 809,813 ---- import tempfile tf = tempfile.NamedTemporaryFile() ! emit(LOGHEADER, self.ui, os.environ, date=date, _file=tf) tf.flush() tf.seek(0) *************** *** 831,835 **** try: ! os.unlink(tfn) except os.error: pass --- 831,835 ---- try: ! os.unlink(tf.name) except os.error: pass From arigo at users.sourceforge.net Sat Aug 7 23:27:45 2004 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Sat Aug 7 23:27:48 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_signal.py, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26391 Modified Files: test_signal.py Log Message: Let's not use string exceptions any more. Index: test_signal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_signal.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_signal.py 11 Jun 2004 18:09:28 -0000 1.15 --- test_signal.py 7 Aug 2004 21:27:43 -0000 1.16 *************** *** 30,34 **** print "handlerA", args ! HandlerBCalled = "HandlerBCalled" # Exception def handlerB(*args): --- 30,35 ---- print "handlerA", args ! class HandlerBCalled(Exception): ! pass def handlerB(*args): From akuchling at users.sourceforge.net Sat Aug 7 23:30:22 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 23:30:25 2004 Subject: [Python-checkins] python/dist/src/Doc/inst inst.tex,1.55,1.56 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/inst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26861 Modified Files: inst.tex Log Message: [Patch #862531] Update version numbers. Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** inst.tex 10 Jul 2004 11:11:15 -0000 1.55 --- inst.tex 7 Aug 2004 21:30:13 -0000 1.56 *************** *** 274,283 **** {Platform}{Standard installation location}{Default value}{Notes} \lineiv{\UNIX{} (pure)} ! {\filenq{\filevar{prefix}/lib/python2.0/site-packages}} ! {\filenq{/usr/local/lib/python2.0/site-packages}} {(1)} \lineiv{\UNIX{} (non-pure)} ! {\filenq{\filevar{exec-prefix}/lib/python2.0/site-packages}} ! {\filenq{/usr/local/lib/python2.0/site-packages}} {(1)} \lineiv{Windows} --- 274,283 ---- {Platform}{Standard installation location}{Default value}{Notes} \lineiv{\UNIX{} (pure)} ! {\filenq{\filevar{prefix}/lib/python2.4/site-packages}} ! {\filenq{/usr/local/lib/python2.4/site-packages}} {(1)} \lineiv{\UNIX{} (non-pure)} ! {\filenq{\filevar{exec-prefix}/lib/python2.4/site-packages}} ! {\filenq{/usr/local/lib/python2.4/site-packages}} {(1)} \lineiv{Windows} *************** *** 315,319 **** Under \UNIX, just type \code{python} at the shell prompt. Under Windows, choose \menuselection{Start \sub Programs \sub Python ! 2.1 \sub Python (command line)}. Under Mac OS 9, start \file{PythonInterpreter}. Once the interpreter is started, you type Python code at the prompt. For example, on my Linux system, I type the three Python --- 315,319 ---- Under \UNIX, just type \code{python} at the shell prompt. Under Windows, choose \menuselection{Start \sub Programs \sub Python ! 2.4 \sub Python (command line)}. Under Mac OS 9, start \file{PythonInterpreter}. Once the interpreter is started, you type Python code at the prompt. For example, on my Linux system, I type the three Python *************** *** 322,327 **** \begin{verbatim} ! Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60] on linux2 ! Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys >>> sys.prefix --- 322,327 ---- \begin{verbatim} ! Python 2.4 (#26, Aug 7 2004, 17:19:02) ! Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.prefix *************** *** 1024,1036 **** Microsoft Visual \Cpp, which uses COFF as the object file format.) For this reason you have to convert Python's library ! \file{python20.lib} into the Borland format. You can do this as follows: \begin{verbatim} ! coff2omf python20.lib python20_bcpp.lib \end{verbatim} The \file{coff2omf} program comes with the Borland compiler. The file ! \file{python20.lib} is in the \file{Libs} directory of your Python installation. If your extension uses other libraries (zlib,...) you have to convert them too. --- 1024,1036 ---- Microsoft Visual \Cpp, which uses COFF as the object file format.) For this reason you have to convert Python's library ! \file{python24.lib} into the Borland format. You can do this as follows: \begin{verbatim} ! coff2omf python24.lib python24_bcpp.lib \end{verbatim} The \file{coff2omf} program comes with the Borland compiler. The file ! \file{python24.lib} is in the \file{Libs} directory of your Python installation. If your extension uses other libraries (zlib,...) you have to convert them too. *************** *** 1093,1097 **** \begin{verbatim} ! pexports python20.dll >python20.def \end{verbatim} --- 1093,1097 ---- \begin{verbatim} ! pexports python24.dll >python24.def \end{verbatim} *************** *** 1099,1107 **** \begin{verbatim} ! dlltool --dllname python20.dll --def python20.def --output-lib libpython20.a \end{verbatim} The resulting library has to be placed in the same directory as ! \file{python20.lib}. (Should be the \file{libs} directory under your Python installation directory.) --- 1099,1107 ---- \begin{verbatim} ! dlltool --dllname python24.dll --def python24.def --output-lib libpython24.a \end{verbatim} The resulting library has to be placed in the same directory as ! \file{python24.lib}. (Should be the \file{libs} directory under your Python installation directory.) From akuchling at users.sourceforge.net Sat Aug 7 23:33:47 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 23:33:50 2004 Subject: [Python-checkins] python/dist/src/Doc/inst inst.tex,1.56,1.57 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/inst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27252 Modified Files: inst.tex Log Message: Remove MacOS 9 refs Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** inst.tex 7 Aug 2004 21:30:13 -0000 1.56 --- inst.tex 7 Aug 2004 21:33:44 -0000 1.57 *************** *** 174,183 **** \end{verbatim} - On Mac OS 9, you double-click the \file{setup.py} script. It will bring - up a dialog where you can select the \command{install} command. Then - selecting the \command{run} button will install your distribution. - The dialog is built dynamically, so all commands and options for this - specific distribution are listed. - \subsection{Splitting the job up} \label{splitting-up} --- 174,177 ---- *************** *** 315,319 **** Under \UNIX, just type \code{python} at the shell prompt. Under Windows, choose \menuselection{Start \sub Programs \sub Python ! 2.4 \sub Python (command line)}. Under Mac OS 9, start \file{PythonInterpreter}. Once the interpreter is started, you type Python code at the prompt. For example, on my Linux system, I type the three Python --- 309,313 ---- Under \UNIX, just type \code{python} at the shell prompt. Under Windows, choose \menuselection{Start \sub Programs \sub Python ! 2.4 \sub Python (command line)}. Once the interpreter is started, you type Python code at the prompt. For example, on my Linux system, I type the three Python *************** *** 522,543 **** - \subsection{Alternate installation: Mac OS 9} - \label{alt-install-macos} - - % XXX Mac OS X? - - Like Windows, Mac OS has no notion of home directories (or even of - users), and a fairly simple standard Python installation. Thus, only a - \longprogramopt{prefix} option is needed. It defines the installation - base, and files are installed under it as follows: - - \installscheme{prefix}{:Lib:site-packages} - {prefix}{:Lib:site-packages} - {prefix}{:Scripts} - {prefix}{:Data} - - See section~\ref{platform-variations} for information on supplying - command-line arguments to the setup script with MacPython. - \section{Custom Installation} --- 516,519 ---- From akuchling at users.sourceforge.net Sat Aug 7 23:35:09 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 23:35:12 2004 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.82,1.83 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27441 Modified Files: dist.tex Log Message: Remove MacOS 9 ref Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** dist.tex 4 Aug 2004 23:18:49 -0000 1.82 --- dist.tex 7 Aug 2004 21:35:06 -0000 1.83 *************** *** 2927,2934 **** files are copied. Don't set \var{link} on systems that don't support it: \function{copy_file()} doesn't check if hard or symbolic linking is ! available. ! ! Under Mac OS 9, uses the native file copy function in \module{macostools}; ! on other systems, uses \var{_copy_file_contents()} to copy file contents. Return a tuple \samp{(dest_name, copied)}: \var{dest_name} is the actual --- 2927,2931 ---- files are copied. Don't set \var{link} on systems that don't support it: \function{copy_file()} doesn't check if hard or symbolic linking is ! available. It uses \var{_copy_file_contents()} to copy file contents. Return a tuple \samp{(dest_name, copied)}: \var{dest_name} is the actual From akuchling at users.sourceforge.net Sat Aug 7 23:36:30 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 23:36:33 2004 Subject: [Python-checkins] python/dist/src/Doc/inst inst.tex,1.49,1.49.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/inst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27595 Modified Files: Tag: release23-branch inst.tex Log Message: [Patch #862531] Update version numbers. Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.49 retrieving revision 1.49.6.1 diff -C2 -d -r1.49 -r1.49.6.1 *** inst.tex 2 Jul 2003 14:33:11 -0000 1.49 --- inst.tex 7 Aug 2004 21:36:28 -0000 1.49.6.1 *************** *** 269,278 **** {Platform}{Standard installation location}{Default value}{Notes} \lineiv{\UNIX{} (pure)} ! {\filenq{\filevar{prefix}/lib/python2.0/site-packages}} ! {\filenq{/usr/local/lib/python2.0/site-packages}} {(1)} \lineiv{\UNIX{} (non-pure)} ! {\filenq{\filevar{exec-prefix}/lib/python2.0/site-packages}} ! {\filenq{/usr/local/lib/python2.0/site-packages}} {(1)} \lineiv{Windows} --- 269,278 ---- {Platform}{Standard installation location}{Default value}{Notes} \lineiv{\UNIX{} (pure)} ! {\filenq{\filevar{prefix}/lib/python2.3/site-packages}} ! {\filenq{/usr/local/lib/python2.3/site-packages}} {(1)} \lineiv{\UNIX{} (non-pure)} ! {\filenq{\filevar{exec-prefix}/lib/python2.3/site-packages}} ! {\filenq{/usr/local/lib/python2.3/site-packages}} {(1)} \lineiv{Windows} *************** *** 1015,1027 **** Microsoft Visual \Cpp, which uses COFF as the object file format.) For this reason you have to convert Python's library ! \file{python20.lib} into the Borland format. You can do this as follows: \begin{verbatim} ! coff2omf python20.lib python20_bcpp.lib \end{verbatim} The \file{coff2omf} program comes with the Borland compiler. The file ! \file{python20.lib} is in the \file{Libs} directory of your Python installation. If your extension uses other libraries (zlib,...) you have to convert them too. --- 1015,1027 ---- Microsoft Visual \Cpp, which uses COFF as the object file format.) For this reason you have to convert Python's library ! \file{python23.lib} into the Borland format. You can do this as follows: \begin{verbatim} ! coff2omf python23.lib python23_bcpp.lib \end{verbatim} The \file{coff2omf} program comes with the Borland compiler. The file ! \file{python23.lib} is in the \file{Libs} directory of your Python installation. If your extension uses other libraries (zlib,...) you have to convert them too. *************** *** 1084,1088 **** \begin{verbatim} ! pexports python20.dll >python20.def \end{verbatim} --- 1084,1088 ---- \begin{verbatim} ! pexports python23.dll >python23.def \end{verbatim} *************** *** 1090,1098 **** \begin{verbatim} ! dlltool --dllname python20.dll --def python20.def --output-lib libpython20.a \end{verbatim} The resulting library has to be placed in the same directory as ! \file{python20.lib}. (Should be the \file{libs} directory under your Python installation directory.) --- 1090,1098 ---- \begin{verbatim} ! dlltool --dllname python23.dll --def python23.def --output-lib libpython23.a \end{verbatim} The resulting library has to be placed in the same directory as ! \file{python23.lib}. (Should be the \file{libs} directory under your Python installation directory.) From akuchling at users.sourceforge.net Sat Aug 7 23:44:39 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sat Aug 7 23:44:43 2004 Subject: [Python-checkins] python/dist/src/Lib whrandom.py,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28765 Modified Files: whrandom.py Log Message: Trigger DeprecationWarning Index: whrandom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/whrandom.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** whrandom.py 11 Apr 2002 20:57:30 -0000 1.20 --- whrandom.py 7 Aug 2004 21:44:37 -0000 1.21 *************** *** 34,37 **** --- 34,41 ---- """ + import warnings + warnings.warn("the whrandom module is deprecated; please use the random module", + DeprecationWarning) + # Translated by Guido van Rossum from C source provided by # Adrian Baddeley. From tim_one at users.sourceforge.net Sun Aug 8 02:54:24 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 02:54:27 2004 Subject: [Python-checkins] python/dist/src/Lib/bsddb/test test_lock.py, 1.5, 1.6 test_thread.py, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/bsddb/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24443/Lib/bsddb/test Modified Files: test_lock.py test_thread.py Log Message: Purged Berkeley code of references to the long-obsolete whrandom. Index: test_lock.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/test/test_lock.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_lock.py 21 Sep 2003 00:08:14 -0000 1.5 --- test_lock.py 8 Aug 2004 00:54:21 -0000 1.6 *************** *** 7,11 **** import time from pprint import pprint - from whrandom import random try: --- 7,10 ---- Index: test_thread.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/test/test_thread.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_thread.py 21 Sep 2003 00:08:14 -0000 1.8 --- test_thread.py 8 Aug 2004 00:54:21 -0000 1.9 *************** *** 9,13 **** import tempfile from pprint import pprint ! from whrandom import random try: --- 9,13 ---- import tempfile from pprint import pprint ! from random import random try: From tim_one at users.sourceforge.net Sun Aug 8 02:54:23 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 02:54:30 2004 Subject: [Python-checkins] python/dist/src/Lib/bsddb dbtables.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/bsddb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24443/Lib/bsddb Modified Files: dbtables.py Log Message: Purged Berkeley code of references to the long-obsolete whrandom. Index: dbtables.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/dbtables.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** dbtables.py 12 Feb 2004 17:35:08 -0000 1.10 --- dbtables.py 8 Aug 2004 00:54:20 -0000 1.11 *************** *** 22,26 **** import copy import xdrlib ! import whrandom from types import ListType, StringType import cPickle as pickle --- 22,26 ---- import copy import xdrlib ! import random from types import ListType, StringType import cPickle as pickle *************** *** 355,360 **** # but it's plenty for our database id needs!) p = xdrlib.Packer() ! p.pack_int(int(whrandom.random()*2147483647)) ! p.pack_int(int(whrandom.random()*2147483647)) newid = p.get_buffer() --- 355,360 ---- # but it's plenty for our database id needs!) p = xdrlib.Packer() ! p.pack_int(int(random.random()*2147483647)) ! p.pack_int(int(random.random()*2147483647)) newid = p.get_buffer() From tim_one at users.sourceforge.net Sun Aug 8 03:00:49 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 03:00:51 2004 Subject: [Python-checkins] python/dist/src/Modules getpath.c,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24572/Modules Modified Files: getpath.c Log Message: Bug 1003471: Python 1.5.2 security vulnerability still present in 2.3.4 That's the title of the report, but the hole was probably plugged since Python 2.0. See corresponding checkin to PC/getpathp.c: a crucial precondition for joinpath() was neither documented nor verified, and there are so many callers with so many conditional paths that no "eyeball analysis" is satisfactory. Now Python dies with a fatal error if the precondition isn't satisfied, instead of allowing a buffer overrun. NOT TESTED! The Windows version of the patch was, but not this one. I don't feel like waiting for someone to notice the patch I attached to the bug report. If it doesn't compile, sorry, but fix it . If it does compile, it's "obviously correct". Index: getpath.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/getpath.c,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** getpath.c 26 Jun 2004 04:03:05 -0000 1.49 --- getpath.c 8 Aug 2004 01:00:47 -0000 1.50 *************** *** 191,198 **** ! /* joinpath requires that any buffer argument passed to it has at ! least MAXPATHLEN + 1 bytes allocated. If this requirement is met, ! it guarantees that it will never overflow the buffer. If stuff ! is too long, buffer will contain a truncated copy of stuff. */ static void --- 191,202 ---- ! /* Add a path component, by appending stuff to buffer. ! buffer must have at least MAXPATHLEN + 1 bytes allocated, and contain a ! NUL-terminated string with no more than MAXPATHLEN characters (not counting ! the trailing NUL). It's a fatal error if it contains a string longer than ! that (callers must be careful!). If these requirements are met, it's ! guaranteed that buffer will still be a NUL-terminated string with no more ! than MAXPATHLEN characters at exit. If stuff is too long, only as much of ! stuff as fits will be appended. */ static void *************** *** 207,210 **** --- 211,216 ---- buffer[n++] = SEP; } + if (n > MAXPATHLEN) + Py_FatalError("buffer overflow in getpath.c's joinpath()"); k = strlen(stuff); if (n + k > MAXPATHLEN) From tim_one at users.sourceforge.net Sun Aug 8 03:05:17 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 03:05:20 2004 Subject: [Python-checkins] python/dist/src/Lib urllib2.py,1.74,1.75 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25557/Lib Modified Files: urllib2.py Log Message: Whitespace normalization. Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** urllib2.py 7 Aug 2004 17:40:50 -0000 1.74 --- urllib2.py 8 Aug 2004 01:05:14 -0000 1.75 *************** *** 1004,1014 **** # to read(). This weird wrapping allows the returned object to # have readline() and readlines() methods. ! # XXX It might be better to extract the read buffering code # out of socket._fileobject() and into a base class. ! r.recv = r.read fp = socket._fileobject(r) ! resp = addinfourl(fp, r.msg, req.get_full_url()) resp.code = r.status --- 1004,1014 ---- # to read(). This weird wrapping allows the returned object to # have readline() and readlines() methods. ! # XXX It might be better to extract the read buffering code # out of socket._fileobject() and into a base class. ! r.recv = r.read fp = socket._fileobject(r) ! resp = addinfourl(fp, r.msg, req.get_full_url()) resp.code = r.status From tim_one at users.sourceforge.net Sun Aug 8 03:05:17 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 03:05:21 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_compiler.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25557/Lib/test Modified Files: test_compiler.py Log Message: Whitespace normalization. Index: test_compiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_compiler.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_compiler.py 7 Aug 2004 19:25:33 -0000 1.1 --- test_compiler.py 8 Aug 2004 01:05:14 -0000 1.2 *************** *** 30,34 **** if __name__ == "__main__": test_main() - - - --- 30,31 ---- From tim_one at users.sourceforge.net Sun Aug 8 03:49:02 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 03:49:04 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.40,1.41 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30640/Lib Modified Files: doctest.py Log Message: Deprecated testmod's useless & confusing isprivate gimmick. Ripped out the docs for the new DocTestFinder's namefilter argument, and renamed it to _namefilter; this only existed to support isprivate. Removed the new DocTestFinder's objfilter argument. No point adding more cruft to a broken filtering design. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** doctest.py 7 Aug 2004 06:03:08 -0000 1.40 --- doctest.py 8 Aug 2004 01:48:59 -0000 1.41 *************** *** 308,311 **** --- 308,312 ---- import sys, traceback, inspect, linecache, os, re, types import unittest, difflib, tempfile + import warnings from StringIO import StringIO *************** *** 779,801 **** object types: modules, functions, classes, methods, staticmethods, classmethods, and properties. - - An optional name filter and an optional object filter may be - passed to the constructor, to restrict which contained objects are - examined by the doctest finder: - - - The name filter is a function `f(prefix, base)`, that returns - true if an object named `prefix.base` should be ignored. - - The object filter is a function `f(obj)` that returns true - if the given object should be ignored. - - Each object is ignored if either filter function returns true for - that object. These filter functions are applied when examining - the contents of a module or of a class, but not when examining a - module's `__test__` dictionary. By default, no objects are - ignored. """ def __init__(self, verbose=False, doctest_factory=DocTest, ! namefilter=None, objfilter=None, recurse=True): """ Create a new doctest finder. --- 780,787 ---- object types: modules, functions, classes, methods, staticmethods, classmethods, and properties. """ def __init__(self, verbose=False, doctest_factory=DocTest, ! recurse=True, _namefilter=None): """ Create a new doctest finder. *************** *** 812,818 **** self._doctest_factory = doctest_factory self._verbose = verbose - self._namefilter = namefilter - self._objfilter = objfilter self._recurse = recurse def find(self, obj, name=None, module=None, globs=None, --- 798,805 ---- self._doctest_factory = doctest_factory self._verbose = verbose self._recurse = recurse + # _namefilter is undocumented, and exists only for temporary backward- + # compatibility support of testmod's deprecated isprivate mess. + self._namefilter = _namefilter def find(self, obj, name=None, module=None, globs=None, *************** *** 895,902 **** Return true if the given object should not be examined. """ ! return ((self._namefilter is not None and ! self._namefilter(prefix, base)) or ! (self._objfilter is not None and ! self._objfilter(obj))) def _from_module(self, module, object): --- 882,887 ---- Return true if the given object should not be examined. """ ! return (self._namefilter is not None and ! self._namefilter(prefix, base)) def _from_module(self, module, object): *************** *** 1745,1754 **** only failures if false; by default, it's true iff "-v" is in sys.argv. - Optional keyword arg "isprivate" specifies a function used to - determine whether a name is private. The default function is - treat all functions as public. Optionally, "isprivate" can be - set to doctest.is_private to skip over functions marked as private - using the underscore naming convention; see its docs for details. - Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is --- 1730,1733 ---- *************** *** 1797,1800 **** --- 1776,1785 ---- post-mortem debugged. + Deprecated in Python 2.4: + Optional keyword arg "isprivate" specifies a function used to + determine whether a name is private. The default function is + treat all functions as public. Optionally, "isprivate" can be + set to doctest.is_private to skip over functions marked as private + using the underscore naming convention; see its docs for details. """ *************** *** 1808,1811 **** --- 1793,1801 ---- when you're done fiddling. """ + if isprivate is not None: + warnings.warn("the isprivate argument is deprecated; " + "examine DocTestFinder.find() lists instead", + DeprecationWarning) + # If no module was given, then use __main__. if m is None: *************** *** 1824,1828 **** # Find, parse, and run all tests in the given module. ! finder = DocTestFinder(namefilter=isprivate) if raise_on_error: --- 1814,1818 ---- # Find, parse, and run all tests in the given module. ! finder = DocTestFinder(_namefilter=isprivate) if raise_on_error: *************** *** 1883,1887 **** self.isprivate = isprivate self.optionflags = optionflags ! self.testfinder = DocTestFinder(namefilter=isprivate) self.testrunner = DocTestRunner(verbose=verbose, optionflags=optionflags) --- 1873,1877 ---- self.isprivate = isprivate self.optionflags = optionflags ! self.testfinder = DocTestFinder(_namefilter=isprivate) self.testrunner = DocTestRunner(verbose=verbose, optionflags=optionflags) *************** *** 2495,2509 **** Tests that objects outside m1 are excluded: - >>> t = Tester(globs={}, verbose=0, isprivate=is_private) - >>> t.rundict(m1.__dict__, "rundict_test", m1) # _f, f2 and g2 and h2 skipped - (0, 3) - - Again, but with the default isprivate function allowing _f: - >>> t = Tester(globs={}, verbose=0) ! >>> t.rundict(m1.__dict__, "rundict_test_pvt", m1) # Only f2, g2 and h2 skipped (0, 4) ! And once more, not excluding stuff outside m1: >>> t = Tester(globs={}, verbose=0) --- 2485,2493 ---- Tests that objects outside m1 are excluded: >>> t = Tester(globs={}, verbose=0) ! >>> t.rundict(m1.__dict__, "rundict_test", m1) # f2 and g2 and h2 skipped (0, 4) ! Once more, not excluding stuff outside m1: >>> t = Tester(globs={}, verbose=0) *************** *** 2514,2519 **** meant to be invoked automagically by testmod. ! >>> testmod(m1, isprivate=is_private, verbose=False) ! (0, 3) """ --- 2498,2503 ---- meant to be invoked automagically by testmod. ! >>> testmod(m1, verbose=False) ! (0, 4) """ From tim_one at users.sourceforge.net Sun Aug 8 03:49:02 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 03:49:06 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30640/Lib/test Modified Files: test_doctest.py Log Message: Deprecated testmod's useless & confusing isprivate gimmick. Ripped out the docs for the new DocTestFinder's namefilter argument, and renamed it to _namefilter; this only existed to support isprivate. Removed the new DocTestFinder's objfilter argument. No point adding more cruft to a broken filtering design. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_doctest.py 7 Aug 2004 05:37:52 -0000 1.9 --- test_doctest.py 8 Aug 2004 01:48:59 -0000 1.10 *************** *** 388,410 **** Filter Functions ~~~~~~~~~~~~~~~~ ! Two filter functions can be used to restrict which objects get ! examined: a name-based filter and an object-based filter. >>> def namefilter(prefix, base): ... return base.startswith('a_') ! >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(SampleClass) ! >>> tests.sort() ! >>> for t in tests: ! ... print '%2s %s' % (len(t.examples), t.name) ! 1 SampleClass ! 3 SampleClass.NestedClass ! 1 SampleClass.NestedClass.__init__ ! 1 SampleClass.__init__ ! 1 SampleClass.double ! 1 SampleClass.get ! ! >>> def objfilter(obj): ! ... return isinstance(obj, (staticmethod, classmethod)) ! >>> tests = doctest.DocTestFinder(objfilter=objfilter).find(SampleClass) >>> tests.sort() >>> for t in tests: --- 388,398 ---- Filter Functions ~~~~~~~~~~~~~~~~ ! A filter function can be used to restrict which objects get examined, ! but this is temporary, undocumented internal support for testmod's ! deprecated isprivate gimmick. >>> def namefilter(prefix, base): ... return base.startswith('a_') ! >>> tests = doctest.DocTestFinder(_namefilter=namefilter).find(SampleClass) >>> tests.sort() >>> for t in tests: *************** *** 414,418 **** 1 SampleClass.NestedClass.__init__ 1 SampleClass.__init__ - 1 SampleClass.a_property 1 SampleClass.double 1 SampleClass.get --- 402,405 ---- *************** *** 423,427 **** >>> def namefilter(prefix, base): ... return base == 'NestedClass' ! >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(SampleClass) >>> tests.sort() >>> for t in tests: --- 410,414 ---- >>> def namefilter(prefix, base): ... return base == 'NestedClass' ! >>> tests = doctest.DocTestFinder(_namefilter=namefilter).find(SampleClass) >>> tests.sort() >>> for t in tests: *************** *** 435,444 **** 1 SampleClass.get ! The filter functions apply to contained objects, and *not* to the object explicitly passed to DocTestFinder: >>> def namefilter(prefix, base): ... return base == 'SampleClass' ! >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(SampleClass) >>> len(tests) 9 --- 422,431 ---- 1 SampleClass.get ! The filter function apply to contained objects, and *not* to the object explicitly passed to DocTestFinder: >>> def namefilter(prefix, base): ... return base == 'SampleClass' ! >>> tests = doctest.DocTestFinder(_namefilter=namefilter).find(SampleClass) >>> len(tests) 9 *************** *** 1067,1071 **** >>> finder = doctest.DocTestFinder( ! ... namefilter=lambda prefix, base: base!='bar') >>> suite = doctest.DocTestSuite('test.sample_doctest', ... test_finder=finder) --- 1054,1058 ---- >>> finder = doctest.DocTestFinder( ! ... _namefilter=lambda prefix, base: base!='bar') >>> suite = doctest.DocTestSuite('test.sample_doctest', ... test_finder=finder) From tim_one at users.sourceforge.net Sun Aug 8 03:52:59 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 03:53:02 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.41,1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31282/Lib Modified Files: doctest.py Log Message: Deprecate the doctest.is_private() function. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** doctest.py 8 Aug 2004 01:48:59 -0000 1.41 --- doctest.py 8 Aug 2004 01:52:57 -0000 1.42 *************** *** 378,381 **** --- 378,384 ---- does not both begin and end with (at least) two underscores. + >>> import warnings + >>> warnings.filterwarnings("ignore", "is_private", DeprecationWarning, + ... "doctest", 0) >>> is_private("a.b", "my_func") False *************** *** 393,396 **** --- 396,402 ---- False """ + warnings.warn("is_private is deprecated; it wasn't useful; " + "examine DocTestFinder.find() lists instead", + DeprecationWarning) return base[:1] == "_" and not base[:2] == "__" == base[-2:] From tim_one at users.sourceforge.net Sun Aug 8 04:43:35 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 04:43:38 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.42,1.43 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4118/Lib Modified Files: doctest.py Log Message: Also deprecated the old Tester class, which is no longer used by anything except internal tests. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** doctest.py 8 Aug 2004 01:52:57 -0000 1.42 --- doctest.py 8 Aug 2004 02:43:32 -0000 1.43 *************** *** 378,382 **** does not both begin and end with (at least) two underscores. - >>> import warnings >>> warnings.filterwarnings("ignore", "is_private", DeprecationWarning, ... "doctest", 0) --- 378,381 ---- *************** *** 398,402 **** warnings.warn("is_private is deprecated; it wasn't useful; " "examine DocTestFinder.find() lists instead", ! DeprecationWarning) return base[:1] == "_" and not base[:2] == "__" == base[-2:] --- 397,401 ---- warnings.warn("is_private is deprecated; it wasn't useful; " "examine DocTestFinder.find() lists instead", ! DeprecationWarning, stacklevel=2) return base[:1] == "_" and not base[:2] == "__" == base[-2:] *************** *** 1867,1870 **** --- 1866,1873 ---- def __init__(self, mod=None, globs=None, verbose=None, isprivate=None, optionflags=0): + + warnings.warn("class Tester is deprecated; " + "use class doctest.DocTestRunner instead", + DeprecationWarning, stacklevel=2) if mod is None and globs is None: raise TypeError("Tester.__init__: must specify mod or globs") *************** *** 2404,2407 **** --- 2407,2412 ---- def test1(): r""" + >>> warnings.filterwarnings("ignore", "class Tester", DeprecationWarning, + ... "doctest", 0) >>> from doctest import Tester >>> t = Tester(globs={'x': 42}, verbose=0) *************** *** 2438,2441 **** --- 2443,2448 ---- def test2(): r""" + >>> warnings.filterwarnings("ignore", "class Tester", + ... DeprecationWarning, "doctest", 0) >>> t = Tester(globs={}, verbose=1) >>> test = r''' *************** *** 2457,2460 **** --- 2464,2469 ---- """ def test3(): r""" + >>> warnings.filterwarnings("ignore", "class Tester", + ... DeprecationWarning, "doctest", 0) >>> t = Tester(globs={}, verbose=0) >>> def _f(): *************** *** 2491,2494 **** --- 2500,2505 ---- Tests that objects outside m1 are excluded: + >>> warnings.filterwarnings("ignore", "class Tester", + ... DeprecationWarning, "doctest", 0) >>> t = Tester(globs={}, verbose=0) >>> t.rundict(m1.__dict__, "rundict_test", m1) # f2 and g2 and h2 skipped From tim_one at users.sourceforge.net Sun Aug 8 04:43:35 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 04:43:39 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1078,1.1079 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4118/Misc Modified Files: NEWS Log Message: Also deprecated the old Tester class, which is no longer used by anything except internal tests. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1078 retrieving revision 1.1079 diff -C2 -d -r1.1078 -r1.1079 *** NEWS 7 Aug 2004 19:20:05 -0000 1.1078 --- NEWS 8 Aug 2004 02:43:33 -0000 1.1079 *************** *** 13,21 **** ----------------- ! Subclasses of string can no longer be interned. The semantics of ! interning were not clear here -- a subclass could be mutable, for ! example -- and had bugs. Explicitly interning a subclass of string ! via intern() will raise a TypeError. Internal operations that attempt ! to intern a string subclass will have no effect. Extension modules --- 13,21 ---- ----------------- ! - Subclasses of string can no longer be interned. The semantics of ! interning were not clear here -- a subclass could be mutable, for ! example -- and had bugs. Explicitly interning a subclass of string ! via intern() will raise a TypeError. Internal operations that attempt ! to intern a string subclass will have no effect. Extension modules *************** *** 25,28 **** --- 25,43 ---- ------- + - doctest refactoring continued. See the docs for details. As part of + this effort, some old and little- (never?) used features are now + deprecated: the Tester class, the module is_private() function, and the + isprivate argument to testmod(). The Tester class supplied a feeble + "by hand" way to combine multiple doctests, if you knew exactly what + you were doing. The newer doctest features for unittest integration + already did a better job of that, are stronger now than ever, and the + new DocTestRunner class is a saner foundation if you want to do it by + hand. The "private name" filtering gimmick was a mistake from the + start, and testmod() changed long ago to ignore it by default. If + you want to filter out tests, the new DocTestFinder class can be used + to return a list of all doctests, and you can filter that list by + any computable criteria before passing it to a DocTestRunner instance. + + Tools/Demos ----------- From tim_one at users.sourceforge.net Sun Aug 8 05:38:38 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 05:38:41 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.43,1.44 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10330/Lib Modified Files: doctest.py Log Message: Type in docstring. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** doctest.py 8 Aug 2004 02:43:32 -0000 1.43 --- doctest.py 8 Aug 2004 03:38:33 -0000 1.44 *************** *** 794,798 **** The optional argument `doctest_factory` specifies a class or function that should be used to create new DocTest objects (or ! objects that implement the same interface as DocTest). This signature for this factory function should match the signature of the DocTest constructor. --- 794,798 ---- The optional argument `doctest_factory` specifies a class or function that should be used to create new DocTest objects (or ! objects that implement the same interface as DocTest). The signature for this factory function should match the signature of the DocTest constructor. From rhettinger at users.sourceforge.net Sun Aug 8 06:03:27 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Aug 8 06:03:29 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13331 Modified Files: decimal.py Log Message: * Context.copy() now makes a deepcopy. * Facilitate reloads of local thread. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** decimal.py 6 Aug 2004 23:42:16 -0000 1.20 --- decimal.py 8 Aug 2004 04:03:24 -0000 1.21 *************** *** 393,397 **** """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): ! context = copy.deepcopy(context) context.clear_flags() threading.currentThread().__decimal_context__ = context --- 393,397 ---- """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): ! context = context.copy() context.clear_flags() threading.currentThread().__decimal_context__ = context *************** *** 414,417 **** --- 414,419 ---- local = threading.local() + if hasattr(local, '__decimal_context__'): + del local.__decimal_context__ def getcontext(_local=local): *************** *** 432,436 **** """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): ! context = copy.deepcopy(context) context.clear_flags() _local.__decimal_context__ = context --- 434,438 ---- """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): ! context = context.copy() context.clear_flags() _local.__decimal_context__ = context *************** *** 643,647 **** return -((-1)**self._sign) ! context = context.copy() rounding = context._set_rounding(ROUND_UP) #round away from 0 --- 645,649 ---- return -((-1)**self._sign) ! context = context._shallow_copy() rounding = context._set_rounding(ROUND_UP) #round away from 0 *************** *** 862,866 **** if not round: ! context = context.copy() context._set_rounding_decision(NEVER_ROUND) --- 864,868 ---- if not round: ! context = context._shallow_copy() context._set_rounding_decision(NEVER_ROUND) *************** *** 1359,1363 **** # If DivisionImpossible causes an error, do not leave Rounded/Inexact # ignored in the calling function. ! context = context.copy() flags = context._ignore_flags(Rounded, Inexact) #keep DivisionImpossible flags --- 1361,1365 ---- # If DivisionImpossible causes an error, do not leave Rounded/Inexact # ignored in the calling function. ! context = context._shallow_copy() flags = context._ignore_flags(Rounded, Inexact) #keep DivisionImpossible flags *************** *** 1368,1372 **** return r ! context = context.copy() rounding = context._set_rounding_decision(NEVER_ROUND) --- 1370,1374 ---- return r ! context = context._shallow_copy() rounding = context._set_rounding_decision(NEVER_ROUND) *************** *** 1601,1605 **** if prec != context.prec: ! context = context.copy() context.prec = prec ans = this_function(prec, expdiff, context) --- 1603,1607 ---- if prec != context.prec: ! context = context._shallow_copy() context.prec = prec ans = this_function(prec, expdiff, context) *************** *** 1739,1743 **** mul = Decimal(self) val = Decimal(1) ! context = context.copy() context.prec = firstprec + elength + 1 rounding = context.rounding --- 1741,1745 ---- mul = Decimal(self) val = Decimal(1) ! context = context._shallow_copy() context.prec = firstprec + elength + 1 rounding = context.rounding *************** *** 1939,1943 **** tmp._exp = 0 ! context = context.copy() flags = context._ignore_all_flags() firstprec = context.prec --- 1941,1945 ---- tmp._exp = 0 ! context = context._shallow_copy() flags = context._ignore_all_flags() firstprec = context.prec *************** *** 2167,2176 **** self.flags[flag] = 0 ! def copy(self): ! """Returns a copy from self.""" nc = Context(self.prec, self.rounding, self.traps, self.flags, self._rounding_decision, self.Emin, self.Emax, self.capitals, self._clamp, self._ignored_flags) return nc __copy__ = copy --- 2169,2185 ---- self.flags[flag] = 0 ! def _shallow_copy(self): ! """Returns a shallow copy from self.""" nc = Context(self.prec, self.rounding, self.traps, self.flags, self._rounding_decision, self.Emin, self.Emax, self.capitals, self._clamp, self._ignored_flags) return nc + + def copy(self): + """Returns a deep copy from self.""" + nc = Context(self.prec, self.rounding, self.traps.copy(), self.flags.copy(), + self._rounding_decision, self.Emin, self.Emax, + self.capitals, self._clamp, self._ignored_flags) + return nc __copy__ = copy *************** *** 2234,2238 **** rounding decision. Often used like: ! context = context.copy() # That so you don't change the calling context # if an error occurs in the middle (say DivisionImpossible is raised). --- 2243,2247 ---- rounding decision. Often used like: ! context = context._shallow_copy() # That so you don't change the calling context # if an error occurs in the middle (say DivisionImpossible is raised). From tim_one at users.sourceforge.net Sun Aug 8 08:11:50 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 08:11:56 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.44,1.45 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26318/Lib Modified Files: doctest.py Log Message: Get rid of the ignore_imports argument to DocTestFinder.find(). This got slammed in when find() was fixed to stop grabbing doctests from modules imported *by* the module being tested. Such tests cannot be expected to succeed, since they'll be run with the current module's globals. Dozens of Zope3 doctests were failing because of that. It wasn't clear why ignore_imports got added then. Maybe it's because some existing tests failed when the change was made. Whatever, it's a Bad Idea so it's gone now. The only use of it was exceedingly obscure, in test_doctest's "Duplicate Removal" test. It was "needed" there because, as an artifact of running a doctest inside a doctest, the func_globals of functions compiled in the second-level doctest don't match the module globals, and so the test-finder believed these functions were from a foreign module and skipped them. But that took a long time to figure out, and I actually understand some of this stuff <0.9 wink>. That problem was resolved by moving the source code for the second-level doctest into an actual module (test/doctest_aliases.py). The only remaining difficulty was that the test for the deprecated Tester.rundict() then failed, because the test finder doesn't take module=None at face value, trying to guess which module the user really intended then. Its guess wasn't appropriate for what Tester.rundict needs when module=None is given to *it*, which is "no, there is no module here, and I mean it". So now passing module=False means exactly that. This is hokey, but ignore_imports=False was really a hack to worm around that there was no way to tell the test-finder that module=None *sometimes* means what it says. There was no use case for the combination of passing a real module with ignore_imports=False. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** doctest.py 8 Aug 2004 03:38:33 -0000 1.44 --- doctest.py 8 Aug 2004 06:11:47 -0000 1.45 *************** *** 809,813 **** def find(self, obj, name=None, module=None, globs=None, ! extraglobs=None, ignore_imports=True): """ Return a list of the DocTests that are defined by the given --- 809,813 ---- def find(self, obj, name=None, module=None, globs=None, ! extraglobs=None): """ Return a list of the DocTests that are defined by the given *************** *** 816,831 **** The optional parameter `module` is the module that contains ! the given object. If the module is not specified, then the ! test finder will attempt to automatically determine the correct module. The object's module is used: - As a default namespace, if `globs` is not specified. - To prevent the DocTestFinder from extracting DocTests ! from objects that are imported from other modules ! (as long as `ignore_imports` is true). - To find the name of the file containing the object. - To help find the line number of the object within its file. The globals for each DocTest is formed by combining `globs` and `extraglobs` (bindings in `extraglobs` override bindings --- 816,838 ---- The optional parameter `module` is the module that contains ! the given object. If the module is not specified or is None, then ! the test finder will attempt to automatically determine the correct module. The object's module is used: - As a default namespace, if `globs` is not specified. - To prevent the DocTestFinder from extracting DocTests ! from objects that are imported from other modules. - To find the name of the file containing the object. - To help find the line number of the object within its file. + Contained objects whose module does not match `module` are ignored. + + If `module` is False, no attempt to find the module will be made. + This is obscure, of use mostly in tests: if `module` is False, or + is None but cannot be found automatically, then all objects are + considered to belong to the (non-existent) module, so all contained + objects will (recursively) be searched for doctests. + The globals for each DocTest is formed by combining `globs` and `extraglobs` (bindings in `extraglobs` override bindings *************** *** 836,843 **** to {}. - If the optional flag `ignore_imports` is true, then the - doctest finder will ignore any contained objects whose module - does not match `module`. Otherwise, it will extract tests - from all contained objects, including imported objects. """ # If name was not specified, then extract it from the object. --- 843,846 ---- *************** *** 852,856 **** # a module, then module=obj.). Note: this may fail, in which # case module will be None. ! if module is None: module = inspect.getmodule(obj) --- 855,861 ---- # a module, then module=obj.). Note: this may fail, in which # case module will be None. ! if module is False: ! module = None ! elif module is None: module = inspect.getmodule(obj) *************** *** 879,884 **** # Recursively expore `obj`, extracting DocTests. tests = [] ! self._find(tests, obj, name, module, source_lines, ! globs, ignore_imports, {}) return tests --- 884,888 ---- # Recursively expore `obj`, extracting DocTests. tests = [] ! self._find(tests, obj, name, module, source_lines, globs, {}) return tests *************** *** 910,915 **** raise ValueError("object must be a class or function") ! def _find(self, tests, obj, name, module, source_lines, ! globs, ignore_imports, seen): """ Find tests for the given object and any contained objects, and --- 914,918 ---- raise ValueError("object must be a class or function") ! def _find(self, tests, obj, name, module, source_lines, globs, seen): """ Find tests for the given object and any contained objects, and *************** *** 938,944 **** # Recurse to functions & classes. if ((inspect.isfunction(val) or inspect.isclass(val)) and ! (self._from_module(module, val) or not ignore_imports)): self._find(tests, val, valname, module, source_lines, ! globs, ignore_imports, seen) # Look for tests in a module's __test__ dictionary. --- 941,947 ---- # Recurse to functions & classes. if ((inspect.isfunction(val) or inspect.isclass(val)) and ! self._from_module(module, val)): self._find(tests, val, valname, module, source_lines, ! globs, seen) # Look for tests in a module's __test__ dictionary. *************** *** 958,962 **** valname = '%s.%s' % (name, valname) self._find(tests, val, valname, module, source_lines, ! globs, ignore_imports, seen) # Look for tests in a class's contained objects. --- 961,965 ---- valname = '%s.%s' % (name, valname) self._find(tests, val, valname, module, source_lines, ! globs, seen) # Look for tests in a class's contained objects. *************** *** 974,982 **** # Recurse to methods, properties, and nested classes. if ((inspect.isfunction(val) or inspect.isclass(val) or ! isinstance(val, property)) and ! (self._from_module(module, val) or not ignore_imports)): valname = '%s.%s' % (name, valname) self._find(tests, val, valname, module, source_lines, ! globs, ignore_imports, seen) def _get_test(self, obj, name, module, globs, source_lines): --- 977,985 ---- # Recurse to methods, properties, and nested classes. if ((inspect.isfunction(val) or inspect.isclass(val) or ! isinstance(val, property)) and ! self._from_module(module, val)): valname = '%s.%s' % (name, valname) self._find(tests, val, valname, module, source_lines, ! globs, seen) def _get_test(self, obj, name, module, globs, source_lines): *************** *** 1895,1903 **** return (f,t) ! def rundoc(self, object, name=None, module=None, ignore_imports=True): f = t = 0 tests = self.testfinder.find(object, name, module=module, ! globs=self.globs, ! ignore_imports=ignore_imports) for test in tests: (f2, t2) = self.testrunner.run(test) --- 1898,1905 ---- return (f,t) ! def rundoc(self, object, name=None, module=None): f = t = 0 tests = self.testfinder.find(object, name, module=module, ! globs=self.globs) for test in tests: (f2, t2) = self.testrunner.run(test) *************** *** 1909,1914 **** m = new.module(name) m.__dict__.update(d) ! ignore_imports = (module is not None) ! return self.rundoc(m, name, module, ignore_imports) def run__test__(self, d, name): --- 1911,1917 ---- m = new.module(name) m.__dict__.update(d) ! if module is None: ! module = False ! return self.rundoc(m, name, module) def run__test__(self, d, name): From tim_one at users.sourceforge.net Sun Aug 8 08:11:50 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 08:11:58 2004 Subject: [Python-checkins] python/dist/src/Lib/test doctest_aliases.py, NONE, 1.1 test_doctest.py, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26318/Lib/test Modified Files: test_doctest.py Added Files: doctest_aliases.py Log Message: Get rid of the ignore_imports argument to DocTestFinder.find(). This got slammed in when find() was fixed to stop grabbing doctests from modules imported *by* the module being tested. Such tests cannot be expected to succeed, since they'll be run with the current module's globals. Dozens of Zope3 doctests were failing because of that. It wasn't clear why ignore_imports got added then. Maybe it's because some existing tests failed when the change was made. Whatever, it's a Bad Idea so it's gone now. The only use of it was exceedingly obscure, in test_doctest's "Duplicate Removal" test. It was "needed" there because, as an artifact of running a doctest inside a doctest, the func_globals of functions compiled in the second-level doctest don't match the module globals, and so the test-finder believed these functions were from a foreign module and skipped them. But that took a long time to figure out, and I actually understand some of this stuff <0.9 wink>. That problem was resolved by moving the source code for the second-level doctest into an actual module (test/doctest_aliases.py). The only remaining difficulty was that the test for the deprecated Tester.rundict() then failed, because the test finder doesn't take module=None at face value, trying to guess which module the user really intended then. Its guess wasn't appropriate for what Tester.rundict needs when module=None is given to *it*, which is "no, there is no module here, and I mean it". So now passing module=False means exactly that. This is hokey, but ignore_imports=False was really a hack to worm around that there was no way to tell the test-finder that module=None *sometimes* means what it says. There was no use case for the combination of passing a real module with ignore_imports=False. --- NEW FILE: doctest_aliases.py --- # Used by test_doctest.py. class TwoNames: '''f() and g() are two names for the same method''' def f(self): ''' >>> print TwoNames().f() f ''' return 'f' g = f # define an alias for f Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_doctest.py 8 Aug 2004 01:48:59 -0000 1.10 --- test_doctest.py 8 Aug 2004 06:11:48 -0000 1.11 *************** *** 364,387 **** will only be generated for it once: ! >>> class TwoNames: ! ... '''f() and g() are two names for the same method''' ! ... ! ... def f(self): ! ... ''' ! ... >>> print TwoNames().f() ! ... f ! ... ''' ! ... return 'f' ! ... ! ... g = f # define an alias for f. ! ! >>> finder = doctest.DocTestFinder() ! >>> tests = finder.find(TwoNames, ignore_imports=False) >>> tests.sort() >>> print len(tests) 2 >>> print tests[0].name ! TwoNames ! >>> print tests[1].name in ('TwoNames.f', 'TwoNames.g') True --- 364,380 ---- will only be generated for it once: ! >>> from test import doctest_aliases ! >>> tests = finder.find(doctest_aliases) >>> tests.sort() >>> print len(tests) 2 >>> print tests[0].name ! test.doctest_aliases.TwoNames ! ! TwoNames.f and TwoNames.g are bound to the same object. ! We can't guess which will be found in doctest's traversal of ! TwoNames.__dict__ first, so we have to allow for either. ! ! >>> tests[1].name.split('.')[-1] in ['f', 'g'] True From tim_one at users.sourceforge.net Sun Aug 8 08:29:13 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 08:29:16 2004 Subject: [Python-checkins] python/dist/src/Objects rangeobject.c,2.51,2.52 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27686/Objects Modified Files: rangeobject.c Log Message: Trimmed trailing whitespace. Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.51 retrieving revision 2.52 diff -C2 -d -r2.51 -r2.52 *** rangeobject.c 2 Aug 2004 13:22:01 -0000 2.51 --- rangeobject.c 8 Aug 2004 06:29:10 -0000 2.52 *************** *** 33,37 **** long last = start + (len - 1) * step; if ((step > 0) ? ! (last > (PyInt_GetMax() - step)) : (last < (-1 - PyInt_GetMax() - step))) { PyErr_SetString(PyExc_OverflowError, --- 33,37 ---- long last = start + (len - 1) * step; if ((step > 0) ? ! (last > (PyInt_GetMax() - step)) : (last < (-1 - PyInt_GetMax() - step))) { PyErr_SetString(PyExc_OverflowError, *************** *** 39,43 **** Py_DECREF(obj); return NULL; ! } } obj->start = start; --- 39,43 ---- Py_DECREF(obj); return NULL; ! } } obj->start = start; *************** *** 146,150 **** { PyObject *rtn; ! if (r->start == 0 && r->step == 1) rtn = PyString_FromFormat("xrange(%ld)", --- 146,150 ---- { PyObject *rtn; ! if (r->start == 0 && r->step == 1) rtn = PyString_FromFormat("xrange(%ld)", *************** *** 212,216 **** (getiterfunc)range_iter, /* tp_iter */ 0, /* tp_iternext */ ! range_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ --- 212,216 ---- (getiterfunc)range_iter, /* tp_iter */ 0, /* tp_iternext */ ! range_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ *************** *** 285,289 **** rangeiter_next(rangeiterobject *r) { ! if (r->index < r->len) return PyInt_FromLong(r->start + (r->index++) * r->step); return NULL; --- 285,289 ---- rangeiter_next(rangeiterobject *r) { ! if (r->index < r->len) return PyInt_FromLong(r->start + (r->index++) * r->step); return NULL; From tim_one at users.sourceforge.net Sun Aug 8 09:17:41 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 09:17:44 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.170,1.171 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32294/Doc/lib Modified Files: libfuncs.tex Log Message: Bug 1003935: xrange overflows Added XXX comment about why the undocumented PyRange_New() API function is too broken to be worth the considerable pain of repairing. Changed range_new() to stop using PyRange_New(). This fixes a variety of bogus errors. Nothing in the core uses PyRange_New() now. Documented that xrange() is intended to be simple and fast, and that CPython restricts its arguments, and length of its result sequence, to native C longs. Added some tests that failed before the patch, and repaired a test that relied on a bogus OverflowError getting raised. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.170 retrieving revision 1.171 diff -C2 -d -r1.170 -r1.171 *** libfuncs.tex 4 Aug 2004 23:18:49 -0000 1.170 --- libfuncs.tex 8 Aug 2004 07:17:38 -0000 1.171 *************** *** 80,84 **** \indexii{Boolean}{type} \versionadded{2.2.1} ! \versionchanged[If no argument is given, this function returns \constant{False}]{2.3} \end{funcdesc} --- 80,84 ---- \indexii{Boolean}{type} \versionadded{2.2.1} ! \versionchanged[If no argument is given, this function returns \constant{False}]{2.3} \end{funcdesc} *************** *** 380,384 **** ignored). If the file cannot be opened, \exception{IOError} is raised. ! In addition to the standard \cfunction{fopen()} values \var{mode} may be \code{'U'} or \code{'rU'}. If Python is built with universal --- 380,384 ---- ignored). If the file cannot be opened, \exception{IOError} is raised. ! In addition to the standard \cfunction{fopen()} values \var{mode} may be \code{'U'} or \code{'rU'}. If Python is built with universal *************** *** 393,397 **** file objects so opened also have an attribute called \member{newlines} which has a value of \code{None} (if no newlines ! have yet been seen), \code{'\e n'}, \code{'\e r'}, \code{'\e r\e n'}, or a tuple containing all the newline types seen. --- 393,397 ---- file objects so opened also have an attribute called \member{newlines} which has a value of \code{None} (if no newlines ! have yet been seen), \code{'\e n'}, \code{'\e r'}, \code{'\e r\e n'}, or a tuple containing all the newline types seen. *************** *** 460,464 **** \var{iterable} is not specified, returns a new empty set, \code{frozenset([])}. ! \versionadded{2.4} \end{funcdesc} --- 460,464 ---- \var{iterable} is not specified, returns a new empty set, \code{frozenset([])}. ! \versionadded{2.4} \end{funcdesc} *************** *** 660,664 **** \begin{funcdesc}{object}{} ! Return a new featureless object. \function{object()} is a base for all new style classes. It has the methods that are common to all instances of new style classes. --- 660,664 ---- \begin{funcdesc}{object}{} ! Return a new featureless object. \function{object()} is a base for all new style classes. It has the methods that are common to all instances of new style classes. *************** *** 902,906 **** be \class{frozenset} objects. If \var{iterable} is not specified, returns a new empty set, \code{set([])}. ! \versionadded{2.4} \end{funcdesc} --- 902,906 ---- be \class{frozenset} objects. If \var{iterable} is not specified, returns a new empty set, \code{set([])}. ! \versionadded{2.4} \end{funcdesc} *************** *** 932,936 **** The optional arguments \var{cmp}, \var{key}, and \var{reverse} have the same meaning as those for the \method{list.sort()} method. ! \versionadded{2.4} \end{funcdesc} --- 932,936 ---- The optional arguments \var{cmp}, \var{key}, and \var{reverse} have the same meaning as those for the \method{list.sort()} method. ! \versionadded{2.4} \end{funcdesc} *************** *** 1100,1103 **** --- 1100,1109 ---- machine or when all of the range's elements are never used (such as when the loop is usually terminated with \keyword{break}). + + \note{\function{xrange()} is intended to be simple and fast. + Implementations may impose restrictions to achieve this. + The C implementation of Python restricts all arguments to + native C longs ("short" Python integers), and also requires + that that number of elements fit in a native C long.} \end{funcdesc} *************** *** 1115,1123 **** \versionchanged[Formerly, \function{zip()} required at least one argument and \code{zip()} raised a \exception{TypeError} instead of returning ! an empty list.]{2.4} \end{funcdesc} ! % --------------------------------------------------------------------------- --- 1121,1129 ---- \versionchanged[Formerly, \function{zip()} required at least one argument and \code{zip()} raised a \exception{TypeError} instead of returning ! an empty list.]{2.4} \end{funcdesc} ! % --------------------------------------------------------------------------- From tim_one at users.sourceforge.net Sun Aug 8 09:17:42 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 09:17:47 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_xrange.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32294/Lib/test Modified Files: test_xrange.py Log Message: Bug 1003935: xrange overflows Added XXX comment about why the undocumented PyRange_New() API function is too broken to be worth the considerable pain of repairing. Changed range_new() to stop using PyRange_New(). This fixes a variety of bogus errors. Nothing in the core uses PyRange_New() now. Documented that xrange() is intended to be simple and fast, and that CPython restricts its arguments, and length of its result sequence, to native C longs. Added some tests that failed before the patch, and repaired a test that relied on a bogus OverflowError getting raised. Index: test_xrange.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_xrange.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_xrange.py 8 Jul 2004 01:59:55 -0000 1.1 --- test_xrange.py 8 Aug 2004 07:17:39 -0000 1.2 *************** *** 49,56 **** self.assertRaises(TypeError, xrange, 0, 42, "spam") ! self.assertRaises(OverflowError, xrange, 0, sys.maxint, sys.maxint-1) self.assertRaises(OverflowError, xrange, -sys.maxint, sys.maxint) self.assertRaises(OverflowError, xrange, 0, 2*sys.maxint) def test_main(): test.test_support.run_unittest(XrangeTest) --- 49,61 ---- self.assertRaises(TypeError, xrange, 0, 42, "spam") ! self.assertEqual(len(xrange(0, sys.maxint, sys.maxint-1)), 2) ! self.assertRaises(OverflowError, xrange, -sys.maxint, sys.maxint) self.assertRaises(OverflowError, xrange, 0, 2*sys.maxint) + self.assertEqual(len(xrange(-sys.maxint, sys.maxint, 2)), + sys.maxint) + self.assertRaises(OverflowError, xrange, -sys.maxint-1, sys.maxint, 2) + def test_main(): test.test_support.run_unittest(XrangeTest) From tim_one at users.sourceforge.net Sun Aug 8 09:17:42 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 09:17:48 2004 Subject: [Python-checkins] python/dist/src/Objects rangeobject.c,2.52,2.53 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32294/Objects Modified Files: rangeobject.c Log Message: Bug 1003935: xrange overflows Added XXX comment about why the undocumented PyRange_New() API function is too broken to be worth the considerable pain of repairing. Changed range_new() to stop using PyRange_New(). This fixes a variety of bogus errors. Nothing in the core uses PyRange_New() now. Documented that xrange() is intended to be simple and fast, and that CPython restricts its arguments, and length of its result sequence, to native C longs. Added some tests that failed before the patch, and repaired a test that relied on a bogus OverflowError getting raised. Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.52 retrieving revision 2.53 diff -C2 -d -r2.52 -r2.53 *** rangeobject.c 8 Aug 2004 06:29:10 -0000 2.52 --- rangeobject.c 8 Aug 2004 07:17:39 -0000 2.53 *************** *** 10,13 **** --- 10,20 ---- } rangeobject; + /* XXX PyRange_New should be deprecated. It's not documented. It's not + * used in the core. Its error-checking is akin to Swiss cheese: accepts + * step == 0; accepts len < 0; ignores that (len - 1) * step may overflow; + * raises a baffling "integer addition" exception if it thinks the last + * item is "too big"; and doesn't compute whether "last item is too big" + * correctly even if the multiplication doesn't overflow. + */ PyObject * PyRange_New(long start, long len, long step, int reps) *************** *** 80,83 **** --- 87,91 ---- range_new(PyTypeObject *type, PyObject *args, PyObject *kw) { + rangeobject *obj; long ilow = 0, ihigh = 0, istep = 1; long n; *************** *** 108,112 **** return NULL; } ! return PyRange_New(ilow, n, istep, 1); } --- 116,127 ---- return NULL; } ! ! obj = PyObject_New(rangeobject, &PyRange_Type); ! if (obj == NULL) ! return NULL; ! obj->start = ilow; ! obj->len = n; ! obj->step = istep; ! return (PyObject *) obj; } From tim_one at users.sourceforge.net Sun Aug 8 09:24:25 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 09:24:27 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1079,1.1080 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1464/Misc Modified Files: NEWS Log Message: Brief xrange news. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1079 retrieving revision 1.1080 diff -C2 -d -r1.1079 -r1.1080 *** NEWS 8 Aug 2004 02:43:33 -0000 1.1079 --- NEWS 8 Aug 2004 07:24:22 -0000 1.1080 *************** *** 19,22 **** --- 19,25 ---- to intern a string subclass will have no effect. + - Bug 1003935: xrange() could report bogus OverflowErrors. Documented + what xrange() intends, and repaired tests accordingly. + Extension modules ----------------- *************** *** 39,43 **** any computable criteria before passing it to a DocTestRunner instance. - Tools/Demos ----------- --- 42,45 ---- From tim_one at users.sourceforge.net Sun Aug 8 18:32:57 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 18:33:01 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_compiler.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12060/Lib/test Modified Files: test_compiler.py Log Message: In verbose mode, display the name of each file before trying to compile it. Else when this fails, there's no way to tell which file it was chewing on. Index: test_compiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_compiler.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_compiler.py 8 Aug 2004 01:05:14 -0000 1.2 --- test_compiler.py 8 Aug 2004 16:32:54 -0000 1.3 *************** *** 19,23 **** if not path.endswith(".py"): continue ! f = open(os.path.join(dir, path), "r") buf = f.read() f.close() --- 19,26 ---- if not path.endswith(".py"): continue ! fpath = os.path.join(dir, path) ! if test.test_support.verbose: ! print "compiling", fpath ! f = open(fpath) buf = f.read() f.close() From tim_one at users.sourceforge.net Sun Aug 8 18:37:40 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 18:37:43 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_compiler.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12855/Lib/test Modified Files: test_compiler.py Log Message: Renamed locals to better reflect their meanings. Index: test_compiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_compiler.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_compiler.py 8 Aug 2004 16:32:54 -0000 1.3 --- test_compiler.py 8 Aug 2004 16:37:37 -0000 1.4 *************** *** 16,29 **** for dir in [libdir, testdir]: ! for path in os.listdir(dir): ! if not path.endswith(".py"): continue ! fpath = os.path.join(dir, path) if test.test_support.verbose: ! print "compiling", fpath ! f = open(fpath) buf = f.read() f.close() ! compiler.compile(buf, path, "exec") def test_main(): --- 16,29 ---- for dir in [libdir, testdir]: ! for basename in os.listdir(dir): ! if not basename.endswith(".py"): continue ! path = os.path.join(dir, basename) if test.test_support.verbose: ! print "compiling", path ! f = open(path) buf = f.read() f.close() ! compiler.compile(buf, basename, "exec") def test_main(): From tim_one at users.sourceforge.net Sun Aug 8 18:44:01 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 8 18:44:04 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_compiler.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13459/Lib/test Modified Files: test_compiler.py Log Message: Tell unittest that source files with "badsyntax" in their names should raise SyntaxError. test_compiler passes now on WinXP, at least in a release-build non-O run. Index: test_compiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_compiler.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_compiler.py 8 Aug 2004 16:37:37 -0000 1.4 --- test_compiler.py 8 Aug 2004 16:43:59 -0000 1.5 *************** *** 25,29 **** buf = f.read() f.close() ! compiler.compile(buf, basename, "exec") def test_main(): --- 25,33 ---- buf = f.read() f.close() ! if "badsyntax" in basename: ! self.assertRaises(SyntaxError, compiler.compile, ! buf, basename, "exec") ! else: ! compiler.compile(buf, basename, "exec") def test_main(): From rhettinger at users.sourceforge.net Sun Aug 8 22:17:48 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Aug 8 22:17:50 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12132 Modified Files: test_decimal.py Log Message: Add a test for Context.copy(). Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_decimal.py 14 Jul 2004 16:35:30 -0000 1.10 --- test_decimal.py 8 Aug 2004 20:17:45 -0000 1.11 *************** *** 1057,1060 **** --- 1057,1068 ---- self.assert_(Decimal(10) not in ['a', 1.0, (1,2), {}]) + def test_copy(self): + # All copies should be deep + c = Context() + d = c.copy() + self.assertNotEqual(id(c), id(d)) + self.assertNotEqual(id(c.flags), id(d.flags)) + self.assertNotEqual(id(c.traps), id(d.traps)) + def test_main(arith=False, verbose=None): """ Execute the tests. From bcannon at users.sourceforge.net Sun Aug 8 23:21:20 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Aug 8 23:21:23 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.219,2.220 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20971/Objects Modified Files: listobject.c Log Message: Previous commit was viewed as "perverse". Changed to just cast the unused variable to void.. Thanks to Sjoerd Mullender for the suggested change. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.219 retrieving revision 2.220 diff -C2 -d -r2.219 -r2.220 *** listobject.c 3 Aug 2004 04:53:29 -0000 2.219 --- listobject.c 8 Aug 2004 21:21:18 -0000 2.220 *************** *** 863,867 **** * complain about the unused name. */ ! return status++, v; } --- 863,869 ---- * complain about the unused name. */ ! (void) status; ! ! return v; } From edloper at users.sourceforge.net Mon Aug 9 04:03:33 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Mon Aug 9 04:03:36 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_generators.py, 1.39, 1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31213/dist/src/Lib/test Modified Files: test_generators.py Log Message: Fixed doctest error (wrong prompts) Index: test_generators.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** test_generators.py 12 Feb 2004 17:35:11 -0000 1.39 --- test_generators.py 9 Aug 2004 02:03:30 -0000 1.40 *************** *** 268,274 **** >>> # Show it off: create a tree. ! ... t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ! ... # Print the nodes of the tree in in-order. ! ... for x in t: ... print x, A B C D E F G H I J K L M N O P Q R S T U V W X Y Z --- 268,274 ---- >>> # Show it off: create a tree. ! >>> t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ! >>> # Print the nodes of the tree in in-order. ! >>> for x in t: ... print x, A B C D E F G H I J K L M N O P Q R S T U V W X Y Z From edloper at users.sourceforge.net Mon Aug 9 04:06:08 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Mon Aug 9 04:06:10 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31571/dist/src/Lib/test Modified Files: test_doctest.py Log Message: Rewrote Parser, using regular expressions instead of walking though the string one line at a time. The resulting code is (in my opinion, anyway), much easier to read. In the process, I found and fixed a bug in the orginal parser's line numbering in error messages (it was inconsistant between 0-based and 1-based). Also, check for missing blank lines after the prompt on all prompt lines, not just PS1 lines (test added). Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_doctest.py 8 Aug 2004 06:11:48 -0000 1.11 --- test_doctest.py 9 Aug 2004 02:06:06 -0000 1.12 *************** *** 210,214 **** >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ! ValueError: line 3 of the docstring for some_test has inconsistent leading whitespace: ' indentation' If the docstring contains inconsistent leading whitespace on --- 210,214 ---- >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ! ValueError: line 4 of the docstring for some_test has inconsistent leading whitespace: ' indentation' If the docstring contains inconsistent leading whitespace on *************** *** 230,234 **** >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ! ValueError: line 0 of the docstring for some_test lacks blank after >>>: '>>>print 1' """ --- 230,243 ---- >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ! ValueError: line 1 of the docstring for some_test lacks blank after >>>: '>>>print 1' ! ! If there's no blank space after a PS2 prompt ('...'), then `DocTest` ! will raise a ValueError: ! ! >>> docstring = '>>> if 1:\n...print 1\n1' ! >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0) ! Traceback (most recent call last): ! ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print 1' ! """ From edloper at users.sourceforge.net Mon Aug 9 04:06:08 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Mon Aug 9 04:06:13 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.45,1.46 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31571/dist/src/Lib Modified Files: doctest.py Log Message: Rewrote Parser, using regular expressions instead of walking though the string one line at a time. The resulting code is (in my opinion, anyway), much easier to read. In the process, I found and fixed a bug in the orginal parser's line numbering in error messages (it was inconsistant between 0-based and 1-based). Also, check for missing blank lines after the prompt on all prompt lines, not just PS1 lines (test added). Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** doctest.py 8 Aug 2004 06:11:47 -0000 1.45 --- doctest.py 9 Aug 2004 02:06:06 -0000 1.46 *************** *** 355,367 **** ## Table of Contents ###################################################################### ! # 1. Utility Functions ! # 2. Example & DocTest -- store test cases ! # 3. DocTest Finder -- extracts test cases from objects ! # 4. DocTest Runner -- runs test cases ! # 5. Test Functions -- convenient wrappers for testing ! # 6. Tester Class -- for backwards compatibility ! # 7. Unittest Support ! # 8. Debugging Support ! # 9. Example Usage ###################################################################### --- 355,368 ---- ## Table of Contents ###################################################################### ! # 1. Utility Functions ! # 2. Example & DocTest -- store test cases ! # 3. DocTest Parser -- extracts examples from strings ! # 4. DocTest Finder -- extracts test cases from objects ! # 5. DocTest Runner -- runs test cases ! # 6. Test Functions -- convenient wrappers for testing ! # 7. Tester Class -- for backwards compatibility ! # 8. Unittest Support ! # 9. Debugging Support ! # 10. Example Usage ###################################################################### *************** *** 476,682 **** del self.softspace - class Parser: - """ - Extract doctests from a string. - """ - - _PS1 = ">>>" - _PS2 = "..." - _isPS1 = re.compile(r"(\s*)" + re.escape(_PS1)).match - _isPS2 = re.compile(r"(\s*)" + re.escape(_PS2)).match - _isEmpty = re.compile(r"\s*$").match - _isComment = re.compile(r"\s*#").match - - def __init__(self, name, string): - """ - Prepare to extract doctests from string `string`. - - `name` is an arbitrary (string) name associated with the string, - and is used only in error messages. - """ - self.name = name - self.source = string - - def get_examples(self): - """ - Return the doctest examples from the string. - - This is a list of (source, want, lineno) triples, one per example - in the string. "source" is a single Python statement; it ends - with a newline iff the statement contains more than one - physical line. "want" is the expected output from running the - example (either from stdout, or a traceback in case of exception). - "want" always ends with a newline, unless no output is expected, - in which case "want" is an empty string. "lineno" is the 0-based - line number of the first line of "source" within the string. It's - 0-based because it's most common in doctests that nothing - interesting appears on the same line as opening triple-quote, - and so the first interesting line is called "line 1" then. - - >>> text = ''' - ... >>> x, y = 2, 3 # no output expected - ... >>> if 1: - ... ... print x - ... ... print y - ... 2 - ... 3 - ... - ... Some text. - ... >>> x+y - ... 5 - ... ''' - >>> for x in Parser('', text).get_examples(): - ... print x - ('x, y = 2, 3 # no output expected', '', 1) - ('if 1:\\n print x\\n print y\\n', '2\\n3\\n', 2) - ('x+y', '5\\n', 9) - """ - return self._parse(kind='examples') - - def get_program(self): - """ - Return an executable program from the string, as a string. - - The format of this isn't rigidly defined. In general, doctest - examples become the executable statements in the result, and - their expected outputs become comments, preceded by an "#Expected:" - comment. Everything else (text, comments, everything not part of - a doctest test) is also placed in comments. - - >>> text = ''' - ... >>> x, y = 2, 3 # no output expected - ... >>> if 1: - ... ... print x - ... ... print y - ... 2 - ... 3 - ... - ... Some text. - ... >>> x+y - ... 5 - ... ''' - >>> print Parser('', text).get_program() - x, y = 2, 3 # no output expected - if 1: - print x - print y - # Expected: - # 2 - # 3 - # - # Some text. - x+y - # Expected: - # 5 - """ - return self._parse(kind='program') - - def _parse(self, kind): - assert kind in ('examples', 'program') - do_program = kind == 'program' - output = [] - push = output.append - - string = self.source - if not string.endswith('\n'): - string += '\n' - - isPS1, isPS2 = self._isPS1, self._isPS2 - isEmpty, isComment = self._isEmpty, self._isComment - lines = string.split("\n") - i, n = 0, len(lines) - while i < n: - # Search for an example (a PS1 line). - line = lines[i] - i += 1 - m = isPS1(line) - if m is None: - if do_program: - line = line.rstrip() - if line: - line = ' ' + line - push('#' + line) - continue - # line is a PS1 line. - j = m.end(0) # beyond the prompt - if isEmpty(line, j) or isComment(line, j): - # a bare prompt or comment -- not interesting - if do_program: - push("# " + line[j:]) - continue - # line is a non-trivial PS1 line. - lineno = i - 1 - if line[j] != " ": - raise ValueError('line %r of the docstring for %s lacks ' - 'blank after %s: %r' % - (lineno, self.name, self._PS1, line)) - - j += 1 - blanks = m.group(1) - nblanks = len(blanks) - # suck up this and following PS2 lines - source = [] - while 1: - source.append(line[j:]) - line = lines[i] - m = isPS2(line) - if m: - if m.group(1) != blanks: - raise ValueError('line %r of the docstring for %s ' - 'has inconsistent leading whitespace: %r' % - (i, self.name, line)) - i += 1 - else: - break - - if do_program: - output.extend(source) - else: - # get rid of useless null line from trailing empty "..." - if source[-1] == "": - assert len(source) > 1 - del source[-1] - if len(source) == 1: - source = source[0] - else: - source = "\n".join(source) + "\n" - - # suck up response - if isPS1(line) or isEmpty(line): - if not do_program: - push((source, "", lineno)) - continue - - # There is a response. - want = [] - if do_program: - push("# Expected:") - while 1: - if line[:nblanks] != blanks: - raise ValueError('line %r of the docstring for %s ' - 'has inconsistent leading whitespace: %r' % - (i, self.name, line)) - want.append(line[nblanks:]) - i += 1 - line = lines[i] - if isPS1(line) or isEmpty(line): - break - - if do_program: - output.extend(['# ' + x for x in want]) - else: - want = "\n".join(want) + "\n" - push((source, want, lineno)) - - if do_program: - # Trim junk on both ends. - while output and output[-1] == '#': - output.pop() - while output and output[0] == '#': - output.pop(0) - output = '\n'.join(output) - - return output - ###################################################################### ## 2. Example & DocTest --- 477,480 ---- *************** *** 775,779 **** ###################################################################### ! ## 3. DocTest Finder ###################################################################### --- 573,776 ---- ###################################################################### ! ## 2. Example Parser ! ###################################################################### ! ! class Parser: ! """ ! Extract doctests from a string. ! """ ! def __init__(self, name, string): ! """ ! Prepare to extract doctests from string `string`. ! ! `name` is an arbitrary (string) name associated with the string, ! and is used only in error messages. ! """ ! self.name = name ! self.string = string.expandtabs() ! ! _EXAMPLE_RE = re.compile(r''' ! # Source consists of a PS1 line followed by zero or more PS2 lines. ! (?P ! (?:^(?P [ ]*) >>> .*) # PS1 line ! (?:\n [ ]* \.\.\. .*)*) # PS2 lines ! \n? ! # Want consists of any non-blank lines that do not start with PS1. ! (?P (?:(?![ ]*$) # Not a blank line ! (?![ ]*>>>) # Not a line starting with PS1 ! .*$\n? # But any other line ! )*) ! ''', re.MULTILINE | re.VERBOSE) ! _IS_BLANK_OR_COMMENT = re.compile('^[ ]*(#.*)?$') ! ! def get_examples(self): ! """ ! Return the doctest examples from the string. ! ! This is a list of (source, want, lineno) triples, one per example ! in the string. "source" is a single Python statement; it ends ! with a newline iff the statement contains more than one ! physical line. "want" is the expected output from running the ! example (either from stdout, or a traceback in case of exception). ! "want" always ends with a newline, unless no output is expected, ! in which case "want" is an empty string. "lineno" is the 0-based ! line number of the first line of "source" within the string. It's ! 0-based because it's most common in doctests that nothing ! interesting appears on the same line as opening triple-quote, ! and so the first interesting line is called "line 1" then. ! ! >>> text = ''' ! ... >>> x, y = 2, 3 # no output expected ! ... >>> if 1: ! ... ... print x ! ... ... print y ! ... 2 ! ... 3 ! ... ! ... Some text. ! ... >>> x+y ! ... 5 ! ... ''' ! >>> for x in Parser('', text).get_examples(): ! ... print x ! ('x, y = 2, 3 # no output expected', '', 1) ! ('if 1:\\n print x\\n print y\\n', '2\\n3\\n', 2) ! ('x+y', '5\\n', 9) ! """ ! examples = [] ! charno, lineno = 0, 0 ! # Find all doctest examples in the string: ! for m in self._EXAMPLE_RE.finditer(self.string): ! # Update lineno (lines before this example) ! lineno += self.string.count('\n', charno, m.start()) ! ! # Extract source/want from the regexp match. ! (source, want) = self._parse_example(m, lineno) ! if self._IS_BLANK_OR_COMMENT.match(source): ! continue ! examples.append( (source, want, lineno) ) ! ! # Update lineno (lines inside this example) ! lineno += self.string.count('\n', m.start(), m.end()) ! # Update charno. ! charno = m.end() ! return examples ! ! def get_program(self): ! """ ! Return an executable program from the string, as a string. ! ! The format of this isn't rigidly defined. In general, doctest ! examples become the executable statements in the result, and ! their expected outputs become comments, preceded by an \"#Expected:\" ! comment. Everything else (text, comments, everything not part of ! a doctest test) is also placed in comments. ! ! >>> text = ''' ! ... >>> x, y = 2, 3 # no output expected ! ... >>> if 1: ! ... ... print x ! ... ... print y ! ... 2 ! ... 3 ! ... ! ... Some text. ! ... >>> x+y ! ... 5 ! ... ''' ! >>> print Parser('', text).get_program() ! x, y = 2, 3 # no output expected ! if 1: ! print x ! print y ! # Expected: ! # 2 ! # 3 ! # ! # Some text. ! x+y ! # Expected: ! # 5 ! """ ! output = [] ! charnum, lineno = 0, 0 ! # Find all doctest examples in the string: ! for m in self._EXAMPLE_RE.finditer(self.string): ! # Add any text before this example, as a comment. ! if m.start() > charnum: ! lines = self.string[charnum:m.start()-1].split('\n') ! output.extend([self._comment_line(l) for l in lines]) ! lineno += len(lines) ! ! # Extract source/want from the regexp match. ! (source, want) = self._parse_example(m, lineno, False) ! # Display the source ! output.append(source) ! # Display the expected output, if any ! if want: ! output.append('# Expected:') ! output.extend(['# '+l for l in want.split('\n')]) ! ! # Update the line number & char number. ! lineno += self.string.count('\n', m.start(), m.end()) ! charnum = m.end() ! # Add any remaining text, as comments. ! output.extend([self._comment_line(l) ! for l in self.string[charnum:].split('\n')]) ! # Trim junk on both ends. ! while output and output[-1] == '#': ! output.pop() ! while output and output[0] == '#': ! output.pop(0) ! # Combine the output, and return it. ! return '\n'.join(output) ! ! def _parse_example(self, m, lineno, add_newlines=True): ! # Get the example's indentation level. ! indent = len(m.group('indent')) ! ! # Divide source into lines; check that they're properly ! # indented; and then strip their indentation & prompts. ! source_lines = m.group('source').split('\n') ! self._check_prompt_blank(source_lines, indent, lineno) ! self._check_prefix(source_lines[1:], ' '*indent+'.', lineno) ! source = '\n'.join([sl[indent+4:] for sl in source_lines]) ! if len(source_lines) > 1 and add_newlines: ! source += '\n' ! ! # Divide want into lines; check that it's properly ! # indented; and then strip the indentation. ! want_lines = m.group('want').rstrip().split('\n') ! self._check_prefix(want_lines, ' '*indent, ! lineno+len(source_lines)) ! want = '\n'.join([wl[indent:] for wl in want_lines]) ! if len(want) > 0 and add_newlines: ! want += '\n' ! ! return source, want ! ! def _comment_line(self, line): ! line = line.rstrip() ! if line: return '# '+line ! else: return '#' ! ! def _check_prompt_blank(self, lines, indent, lineno): ! for i, line in enumerate(lines): ! if len(line) >= indent+4 and line[indent+3] != ' ': ! raise ValueError('line %r of the docstring for %s ' ! 'lacks blank after %s: %r' % ! (lineno+i+1, self.name, ! line[indent:indent+3], line)) ! ! def _check_prefix(self, lines, prefix, lineno): ! for i, line in enumerate(lines): ! if line and not line.startswith(prefix): ! raise ValueError('line %r of the docstring for %s has ' ! 'inconsistent leading whitespace: %r' % ! (lineno+i+1, self.name, line)) ! ! ! ###################################################################### ! ## 4. DocTest Finder ###################################################################### *************** *** 1063,1067 **** ###################################################################### ! ## 4. DocTest Runner ###################################################################### --- 1060,1064 ---- ###################################################################### ! ## 5. DocTest Runner ###################################################################### *************** *** 1699,1703 **** ###################################################################### ! ## 5. Test Functions ###################################################################### # These should be backwards compatible. --- 1696,1700 ---- ###################################################################### ! ## 6. Test Functions ###################################################################### # These should be backwards compatible. *************** *** 1861,1865 **** ###################################################################### ! ## 6. Tester ###################################################################### # This is provided only for backwards compatibility. It's not --- 1858,1862 ---- ###################################################################### ! ## 7. Tester ###################################################################### # This is provided only for backwards compatibility. It's not *************** *** 1936,1940 **** ###################################################################### ! ## 7. Unittest Support ###################################################################### --- 1933,1937 ---- ###################################################################### ! ## 8. Unittest Support ###################################################################### *************** *** 2181,2185 **** ###################################################################### ! ## 8. Debugging Support ###################################################################### --- 2178,2182 ---- ###################################################################### ! ## 9. Debugging Support ###################################################################### *************** *** 2316,2320 **** ###################################################################### ! ## 9. Example Usage ###################################################################### class _TestClass: --- 2313,2317 ---- ###################################################################### ! ## 10. Example Usage ###################################################################### class _TestClass: From edloper at users.sourceforge.net Mon Aug 9 04:45:43 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Mon Aug 9 04:45:46 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.46,1.47 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4376/dist/src/Lib Modified Files: doctest.py Log Message: - Split DocTestRunner's check_output and output_difference methods off into their own class, OutputChecker. - Added optional OutputChecker arguments to DocTestRunner, DocTestCase, DocTestSuite. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** doctest.py 9 Aug 2004 02:06:06 -0000 1.46 --- doctest.py 9 Aug 2004 02:45:41 -0000 1.47 *************** *** 1063,1069 **** ###################################################################### - # [XX] Should overridable methods (eg DocTestRunner.check_output) be - # named with a leading underscore? - class DocTestRunner: """ --- 1063,1066 ---- *************** *** 1106,1115 **** The comparison between expected outputs and actual outputs is done ! by the `check_output` method. This comparison may be customized ! with a number of option flags; see the documentation for `testmod` ! for more information. If the option flags are insufficient, then ! the comparison may also be customized by subclassing ! DocTestRunner, and overriding the methods `check_output` and ! `output_difference`. The test runner's display output can be controlled in two ways. --- 1103,1111 ---- The comparison between expected outputs and actual outputs is done ! by an `OutputChecker`. This comparison may be customized with a ! number of option flags; see the documentation for `testmod` for ! more information. If the option flags are insufficient, then the ! comparison may also be customized by passing a subclass of ! `OutputChecker` to the constructor. The test runner's display output can be controlled in two ways. *************** *** 1126,1133 **** DIVIDER = "*" * 70 ! def __init__(self, verbose=None, optionflags=0): """ Create a new test runner. Optional keyword arg 'verbose' prints lots of stuff if true, only failures if false; by default, it's true iff '-v' is in --- 1122,1133 ---- DIVIDER = "*" * 70 ! def __init__(self, checker=None, verbose=None, optionflags=0): """ Create a new test runner. + Optional keyword arg `checker` is the `OutputChecker` that + should be used to compare the expected outputs and actual + outputs of doctest examples. + Optional keyword arg 'verbose' prints lots of stuff if true, only failures if false; by default, it's true iff '-v' is in *************** *** 1139,1142 **** --- 1139,1143 ---- more information. """ + self._checker = checker or OutputChecker() if verbose is None: verbose = '-v' in sys.argv *************** *** 1153,1264 **** #///////////////////////////////////////////////////////////////// - # Output verification methods - #///////////////////////////////////////////////////////////////// - # These two methods should be updated together, since the - # output_difference method needs to know what should be considered - # to match by check_output. - - def check_output(self, want, got): - """ - Return True iff the actual output (`got`) matches the expected - output (`want`). These strings are always considered to match - if they are identical; but depending on what option flags the - test runner is using, several non-exact match types are also - possible. See the documentation for `TestRunner` for more - information about option flags. - """ - # Handle the common case first, for efficiency: - # if they're string-identical, always return true. - if got == want: - return True - - # The values True and False replaced 1 and 0 as the return - # value for boolean comparisons in Python 2.3. - if not (self.optionflags & DONT_ACCEPT_TRUE_FOR_1): - if (got,want) == ("True\n", "1\n"): - return True - if (got,want) == ("False\n", "0\n"): - return True - - # can be used as a special sequence to signify a - # blank line, unless the DONT_ACCEPT_BLANKLINE flag is used. - if not (self.optionflags & DONT_ACCEPT_BLANKLINE): - # Replace in want with a blank line. - want = re.sub('(?m)^%s\s*?$' % re.escape(BLANKLINE_MARKER), - '', want) - # If a line in got contains only spaces, then remove the - # spaces. - got = re.sub('(?m)^\s*?$', '', got) - if got == want: - return True - - # This flag causes doctest to ignore any differences in the - # contents of whitespace strings. Note that this can be used - # in conjunction with the ELLISPIS flag. - if (self.optionflags & NORMALIZE_WHITESPACE): - got = ' '.join(got.split()) - want = ' '.join(want.split()) - if got == want: - return True - - # The ELLIPSIS flag says to let the sequence "..." in `want` - # match any substring in `got`. We implement this by - # transforming `want` into a regular expression. - if (self.optionflags & ELLIPSIS): - # Escape any special regexp characters - want_re = re.escape(want) - # Replace ellipsis markers ('...') with .* - want_re = want_re.replace(re.escape(ELLIPSIS_MARKER), '.*') - # Require that it matches the entire string; and set the - # re.DOTALL flag (with '(?s)'). - want_re = '(?s)^%s$' % want_re - # Check if the `want_re` regexp matches got. - if re.match(want_re, got): - return True - - # We didn't find any match; return false. - return False - - def output_difference(self, want, got): - """ - Return a string describing the differences between the - expected output (`want`) and the actual output (`got`). - """ - # If s are being used, then replace - # with blank lines in the expected output string. - if not (self.optionflags & DONT_ACCEPT_BLANKLINE): - want = re.sub('(?m)^%s$' % re.escape(BLANKLINE_MARKER), '', want) - - # Check if we should use diff. Don't use diff if the actual - # or expected outputs are too short, or if the expected output - # contains an ellipsis marker. - if ((self.optionflags & (UNIFIED_DIFF | CONTEXT_DIFF)) and - want.count('\n') > 2 and got.count('\n') > 2 and - not (self.optionflags & ELLIPSIS and '...' in want)): - # Split want & got into lines. - want_lines = [l+'\n' for l in want.split('\n')] - got_lines = [l+'\n' for l in got.split('\n')] - # Use difflib to find their differences. - if self.optionflags & UNIFIED_DIFF: - diff = difflib.unified_diff(want_lines, got_lines, n=2, - fromfile='Expected', tofile='Got') - kind = 'unified' - elif self.optionflags & CONTEXT_DIFF: - diff = difflib.context_diff(want_lines, got_lines, n=2, - fromfile='Expected', tofile='Got') - kind = 'context' - else: - assert 0, 'Bad diff option' - # Remove trailing whitespace on diff output. - diff = [line.rstrip() + '\n' for line in diff] - return _tag_msg("Differences (" + kind + " diff)", - ''.join(diff)) - - # If we're not using diff, then simply list the expected - # output followed by the actual output. - return (_tag_msg("Expected", want or "Nothing") + - _tag_msg("Got", got)) - - #///////////////////////////////////////////////////////////////// # Reporting methods #///////////////////////////////////////////////////////////////// --- 1154,1157 ---- *************** *** 1287,1291 **** # Print an error message. out(self.__failure_header(test, example) + ! self.output_difference(example.want, got)) def report_unexpected_exception(self, out, test, example, exc_info): --- 1180,1185 ---- # Print an error message. out(self.__failure_header(test, example) + ! self._checker.output_difference(example.want, got, ! self.optionflags)) def report_unexpected_exception(self, out, test, example, exc_info): *************** *** 1413,1417 **** # then verify its output and report its outcome. if exception is None: ! if self.check_output(example.want, got): self.report_success(out, test, example, got) else: --- 1307,1312 ---- # then verify its output and report its outcome. if exception is None: ! if self._checker.check_output(example.want, got, ! self.optionflags): self.report_success(out, test, example, got) else: *************** *** 1437,1442 **** # the exception description match the values given # in `want`. ! if (self.check_output(m.group('out'), got) and ! self.check_output(m.group('exc'), exc_msg)): # Is +exc_msg the right thing here?? self.report_success(out, test, example, --- 1332,1339 ---- # the exception description match the values given # in `want`. ! if (self._checker.check_output(m.group('out'), got, ! self.optionflags) and ! self._checker.check_output(m.group('exc'), exc_msg, ! self.optionflags)): # Is +exc_msg the right thing here?? self.report_success(out, test, example, *************** *** 1555,1558 **** --- 1452,1564 ---- return totalf, totalt + class OutputChecker: + """ + A class used to check the whether the actual output from a doctest + example matches the expected output. `OutputChecker` defines two + methods: `check_output`, which compares a given pair of outputs, + and returns true if they match; and `output_difference`, which + returns a string describing the differences between two outputs. + """ + def check_output(self, want, got, optionflags): + """ + Return True iff the actual output (`got`) matches the expected + output (`want`). These strings are always considered to match + if they are identical; but depending on what option flags the + test runner is using, several non-exact match types are also + possible. See the documentation for `TestRunner` for more + information about option flags. + """ + # Handle the common case first, for efficiency: + # if they're string-identical, always return true. + if got == want: + return True + + # The values True and False replaced 1 and 0 as the return + # value for boolean comparisons in Python 2.3. + if not (optionflags & DONT_ACCEPT_TRUE_FOR_1): + if (got,want) == ("True\n", "1\n"): + return True + if (got,want) == ("False\n", "0\n"): + return True + + # can be used as a special sequence to signify a + # blank line, unless the DONT_ACCEPT_BLANKLINE flag is used. + if not (optionflags & DONT_ACCEPT_BLANKLINE): + # Replace in want with a blank line. + want = re.sub('(?m)^%s\s*?$' % re.escape(BLANKLINE_MARKER), + '', want) + # If a line in got contains only spaces, then remove the + # spaces. + got = re.sub('(?m)^\s*?$', '', got) + if got == want: + return True + + # This flag causes doctest to ignore any differences in the + # contents of whitespace strings. Note that this can be used + # in conjunction with the ELLISPIS flag. + if (optionflags & NORMALIZE_WHITESPACE): + got = ' '.join(got.split()) + want = ' '.join(want.split()) + if got == want: + return True + + # The ELLIPSIS flag says to let the sequence "..." in `want` + # match any substring in `got`. We implement this by + # transforming `want` into a regular expression. + if (optionflags & ELLIPSIS): + # Escape any special regexp characters + want_re = re.escape(want) + # Replace ellipsis markers ('...') with .* + want_re = want_re.replace(re.escape(ELLIPSIS_MARKER), '.*') + # Require that it matches the entire string; and set the + # re.DOTALL flag (with '(?s)'). + want_re = '(?s)^%s$' % want_re + # Check if the `want_re` regexp matches got. + if re.match(want_re, got): + return True + + # We didn't find any match; return false. + return False + + def output_difference(self, want, got, optionflags): + """ + Return a string describing the differences between the + expected output (`want`) and the actual output (`got`). + """ + # If s are being used, then replace + # with blank lines in the expected output string. + if not (optionflags & DONT_ACCEPT_BLANKLINE): + want = re.sub('(?m)^%s$' % re.escape(BLANKLINE_MARKER), '', want) + + # Check if we should use diff. Don't use diff if the actual + # or expected outputs are too short, or if the expected output + # contains an ellipsis marker. + if ((optionflags & (UNIFIED_DIFF | CONTEXT_DIFF)) and + want.count('\n') > 2 and got.count('\n') > 2 and + not (optionflags & ELLIPSIS and '...' in want)): + # Split want & got into lines. + want_lines = [l+'\n' for l in want.split('\n')] + got_lines = [l+'\n' for l in got.split('\n')] + # Use difflib to find their differences. + if optionflags & UNIFIED_DIFF: + diff = difflib.unified_diff(want_lines, got_lines, n=2, + fromfile='Expected', tofile='Got') + kind = 'unified' + elif optionflags & CONTEXT_DIFF: + diff = difflib.context_diff(want_lines, got_lines, n=2, + fromfile='Expected', tofile='Got') + kind = 'context' + else: + assert 0, 'Bad diff option' + # Remove trailing whitespace on diff output. + diff = [line.rstrip() + '\n' for line in diff] + return _tag_msg("Differences (" + kind + " diff)", + ''.join(diff)) + + # If we're not using diff, then simply list the expected + # output followed by the actual output. + return (_tag_msg("Expected", want or "Nothing") + + _tag_msg("Got", got)) + class DocTestFailure(Exception): """A DocTest example has failed in debugging mode. *************** *** 1938,1944 **** class DocTestCase(unittest.TestCase): ! def __init__(self, test, optionflags=0, setUp=None, tearDown=None): unittest.TestCase.__init__(self) self._dt_optionflags = optionflags self._dt_test = test self._dt_setUp = setUp --- 1944,1952 ---- class DocTestCase(unittest.TestCase): ! def __init__(self, test, optionflags=0, setUp=None, tearDown=None, ! checker=None): unittest.TestCase.__init__(self) self._dt_optionflags = optionflags + self._dt_checker = checker self._dt_test = test self._dt_setUp = setUp *************** *** 1957,1961 **** old = sys.stdout new = StringIO() ! runner = DocTestRunner(optionflags=self._dt_optionflags, verbose=False) try: --- 1965,1970 ---- old = sys.stdout new = StringIO() ! runner = DocTestRunner(optionflags=self._dt_optionflags, ! checker=self._dt_checker, verbose=False) try: *************** *** 2046,2050 **** """ ! runner = DebugRunner(verbose = False, optionflags=self._dt_optionflags) runner.run(self._dt_test, out=nooutput) --- 2055,2060 ---- """ ! runner = DebugRunner(optionflags=self._dt_optionflags, ! checker=self._dt_checker, verbose=False) runner.run(self._dt_test, out=nooutput) *************** *** 2066,2070 **** def DocTestSuite(module=None, globs=None, extraglobs=None, optionflags=0, test_finder=None, ! setUp=lambda: None, tearDown=lambda: None): """ Convert doctest tests for a mudule to a unittest test suite. --- 2076,2081 ---- def DocTestSuite(module=None, globs=None, extraglobs=None, optionflags=0, test_finder=None, ! setUp=lambda: None, tearDown=lambda: None, ! checker=None): """ Convert doctest tests for a mudule to a unittest test suite. *************** *** 2104,2108 **** filename = filename[:-1] test.filename = filename ! suite.addTest(DocTestCase(test, optionflags, setUp, tearDown)) return suite --- 2115,2120 ---- filename = filename[:-1] test.filename = filename ! suite.addTest(DocTestCase(test, optionflags, setUp, tearDown, ! checker)) return suite From edloper at users.sourceforge.net Mon Aug 9 04:56:04 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Mon Aug 9 04:56:11 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.47,1.48 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5630/dist/src/Lib Modified Files: doctest.py Log Message: Changed Parser.get_examples() to return a list of Example objects, rather than a list of triples. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** doctest.py 9 Aug 2004 02:45:41 -0000 1.47 --- doctest.py 9 Aug 2004 02:56:02 -0000 1.48 *************** *** 494,502 **** output. Example defines the following attributes: ! - source: The source code that should be run. It ends with a ! newline iff the source spans more than one line. ! - want: The expected output from running the source code. If ! not empty, then this string ends with a newline. - lineno: The line number within the DocTest string containing --- 494,503 ---- output. Example defines the following attributes: ! - source: A single python statement, ending in a newline iff the ! statement spans more than one line. ! - want: The expected output from running the source code (either ! from stdout, or a traceback in case of exception). `want` ! should always end with a newline, unless no output is expected, - lineno: The line number within the DocTest string containing *************** *** 551,556 **** # Parse the docstring. self.docstring = docstring ! examples = Parser(name, docstring).get_examples() ! self.examples = [Example(*example) for example in examples] def __repr__(self): --- 552,556 ---- # Parse the docstring. self.docstring = docstring ! self.examples = Parser(name, docstring).get_examples() def __repr__(self): *************** *** 606,622 **** def get_examples(self): """ ! Return the doctest examples from the string. ! ! This is a list of (source, want, lineno) triples, one per example ! in the string. "source" is a single Python statement; it ends ! with a newline iff the statement contains more than one ! physical line. "want" is the expected output from running the ! example (either from stdout, or a traceback in case of exception). ! "want" always ends with a newline, unless no output is expected, ! in which case "want" is an empty string. "lineno" is the 0-based ! line number of the first line of "source" within the string. It's ! 0-based because it's most common in doctests that nothing ! interesting appears on the same line as opening triple-quote, ! and so the first interesting line is called "line 1" then. >>> text = ''' --- 606,614 ---- def get_examples(self): """ ! Extract all doctest examples, from the string, and return them ! as a list of `Example` objects. Line numbers are 0-based, ! because it's most common in doctests that nothing interesting ! appears on the same line as opening triple-quote, and so the ! first interesting line is called \"line 1\" then. >>> text = ''' *************** *** 633,637 **** ... ''' >>> for x in Parser('', text).get_examples(): ! ... print x ('x, y = 2, 3 # no output expected', '', 1) ('if 1:\\n print x\\n print y\\n', '2\\n3\\n', 2) --- 625,629 ---- ... ''' >>> for x in Parser('', text).get_examples(): ! ... print (x.source, x.want, x.lineno) ('x, y = 2, 3 # no output expected', '', 1) ('if 1:\\n print x\\n print y\\n', '2\\n3\\n', 2) *************** *** 649,653 **** if self._IS_BLANK_OR_COMMENT.match(source): continue ! examples.append( (source, want, lineno) ) # Update lineno (lines inside this example) --- 641,645 ---- if self._IS_BLANK_OR_COMMENT.match(source): continue ! examples.append( Example(source, want, lineno) ) # Update lineno (lines inside this example) From tim_one at users.sourceforge.net Mon Aug 9 05:28:48 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 9 05:28:51 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.48,1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10393/Lib Modified Files: doctest.py Log Message: Indent body of _EXAMPLE_RE for readability. _IS_BLANK_OR_COMMENT makes more sense as a callable. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** doctest.py 9 Aug 2004 02:56:02 -0000 1.48 --- doctest.py 9 Aug 2004 03:28:45 -0000 1.49 *************** *** 591,606 **** _EXAMPLE_RE = re.compile(r''' ! # Source consists of a PS1 line followed by zero or more PS2 lines. ! (?P ! (?:^(?P [ ]*) >>> .*) # PS1 line ! (?:\n [ ]* \.\.\. .*)*) # PS2 lines ! \n? ! # Want consists of any non-blank lines that do not start with PS1. ! (?P (?:(?![ ]*$) # Not a blank line ! (?![ ]*>>>) # Not a line starting with PS1 ! .*$\n? # But any other line ! )*) ! ''', re.MULTILINE | re.VERBOSE) ! _IS_BLANK_OR_COMMENT = re.compile('^[ ]*(#.*)?$') def get_examples(self): --- 591,606 ---- _EXAMPLE_RE = re.compile(r''' ! # Source consists of a PS1 line followed by zero or more PS2 lines. ! (?P ! (?:^(?P [ ]*) >>> .*) # PS1 line ! (?:\n [ ]* \.\.\. .*)*) # PS2 lines ! \n? ! # Want consists of any non-blank lines that do not start with PS1. ! (?P (?:(?![ ]*$) # Not a blank line ! (?![ ]*>>>) # Not a line starting with PS1 ! .*$\n? # But any other line ! )*) ! ''', re.MULTILINE | re.VERBOSE) ! _IS_BLANK_OR_COMMENT = re.compile('^[ ]*(#.*)?$').match def get_examples(self): *************** *** 639,643 **** # Extract source/want from the regexp match. (source, want) = self._parse_example(m, lineno) ! if self._IS_BLANK_OR_COMMENT.match(source): continue examples.append( Example(source, want, lineno) ) --- 639,643 ---- # Extract source/want from the regexp match. (source, want) = self._parse_example(m, lineno) ! if self._IS_BLANK_OR_COMMENT(source): continue examples.append( Example(source, want, lineno) ) From tim_one at users.sourceforge.net Mon Aug 9 05:31:58 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 9 05:32:01 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10835/Lib Modified Files: doctest.py Log Message: Give return stmts their own lines. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** doctest.py 9 Aug 2004 03:28:45 -0000 1.49 --- doctest.py 9 Aug 2004 03:31:56 -0000 1.50 *************** *** 744,749 **** def _comment_line(self, line): line = line.rstrip() ! if line: return '# '+line ! else: return '#' def _check_prompt_blank(self, lines, indent, lineno): --- 744,751 ---- def _comment_line(self, line): line = line.rstrip() ! if line: ! return '# '+line ! else: ! return '#' def _check_prompt_blank(self, lines, indent, lineno): From tim_one at users.sourceforge.net Mon Aug 9 05:51:49 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 9 05:51:52 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.50,1.51 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12808/Lib Modified Files: doctest.py Log Message: Drop the excruciating newline requirements on arguments to Example.__init__. The constructor now adds trailing newlines when needed, and no longer distinguishes between multi- and single-line cases for source. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** doctest.py 9 Aug 2004 03:31:56 -0000 1.50 --- doctest.py 9 Aug 2004 03:51:46 -0000 1.51 *************** *** 494,515 **** output. Example defines the following attributes: ! - source: A single python statement, ending in a newline iff the ! statement spans more than one line. ! - want: The expected output from running the source code (either ! from stdout, or a traceback in case of exception). `want` ! should always end with a newline, unless no output is expected, ! - lineno: The line number within the DocTest string containing this Example where the Example begins. This line number is zero-based, with respect to the beginning of the DocTest. """ def __init__(self, source, want, lineno): ! # Check invariants. ! if (source[-1:] == '\n') != ('\n' in source[:-1]): ! raise AssertionError("source must end with newline iff " ! "source contains more than one line") ! if want and want[-1] != '\n': ! raise AssertionError("non-empty want must end with newline") # Store properties. self.source = source --- 494,515 ---- output. Example defines the following attributes: ! - source: A single Python statement, always ending with a newline. ! The constructor adds a newline if needed. ! - want: The expected output from running the source code (either ! from stdout, or a traceback in case of exception). `want` ends ! with a newline unless it's empty, in which case it's an empty ! string. The constructor adds a newline if needed. ! - lineno: The line number within the DocTest string containing this Example where the Example begins. This line number is zero-based, with respect to the beginning of the DocTest. """ def __init__(self, source, want, lineno): ! # Normalize inputs. ! if not source.endswith('\n'): ! source += '\n' ! if want and not want.endswith('\n'): ! want += '\n' # Store properties. self.source = source *************** *** 626,632 **** >>> for x in Parser('', text).get_examples(): ... print (x.source, x.want, x.lineno) ! ('x, y = 2, 3 # no output expected', '', 1) ('if 1:\\n print x\\n print y\\n', '2\\n3\\n', 2) ! ('x+y', '5\\n', 9) """ examples = [] --- 626,632 ---- >>> for x in Parser('', text).get_examples(): ... print (x.source, x.want, x.lineno) ! ('x, y = 2, 3 # no output expected\\n', '', 1) ('if 1:\\n print x\\n print y\\n', '2\\n3\\n', 2) ! ('x+y\\n', '5\\n', 9) """ examples = [] *************** *** 1284,1288 **** # trailing newline. Rather than analyze that, always # append one (it never hurts). ! exec compile(example.source + '\n', "", "single", compileflags, 1) in test.globs exception = None --- 1284,1288 ---- # trailing newline. Rather than analyze that, always # append one (it never hurts). ! exec compile(example.source, "", "single", compileflags, 1) in test.globs exception = None From tim_one at users.sourceforge.net Mon Aug 9 05:51:49 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 9 05:51:54 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12808/Lib/test Modified Files: test_doctest.py Log Message: Drop the excruciating newline requirements on arguments to Example.__init__. The constructor now adds trailing newlines when needed, and no longer distinguishes between multi- and single-line cases for source. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_doctest.py 9 Aug 2004 02:06:06 -0000 1.12 --- test_doctest.py 9 Aug 2004 03:51:46 -0000 1.13 *************** *** 128,156 **** >>> example = doctest.Example('print 1', '1\n', 0) >>> (example.source, example.want, example.lineno) ! ('print 1', '1\n', 0) ! The `source` string should end in a newline iff the source spans more ! than one line: ! >>> # Source spans a single line: no terminating newline. >>> e = doctest.Example('print 1', '1\n', 0) >>> e = doctest.Example('print 1\n', '1\n', 0) ! Traceback (most recent call last): ! AssertionError: source must end with newline iff source contains more than one line ! >>> # Source spans multiple lines: require terminating newline. >>> e = doctest.Example('print 1;\nprint 2\n', '1\n2\n', 0) >>> e = doctest.Example('print 1;\nprint 2', '1\n2\n', 0) ! Traceback (most recent call last): ! AssertionError: source must end with newline iff source contains more than one line ! The `want` string should be terminated by a newline, unless it's the ! empty string: >>> e = doctest.Example('print 1', '1\n', 0) >>> e = doctest.Example('print 1', '1', 0) ! Traceback (most recent call last): ! AssertionError: non-empty want must end with newline >>> e = doctest.Example('print', '', 0) """ --- 128,166 ---- >>> example = doctest.Example('print 1', '1\n', 0) >>> (example.source, example.want, example.lineno) ! ('print 1\n', '1\n', 0) ! The `source` string ends in a newline: ! Source spans a single line: no terminating newline. >>> e = doctest.Example('print 1', '1\n', 0) + >>> e.source, e.want + ('print 1\n', '1\n') + >>> e = doctest.Example('print 1\n', '1\n', 0) ! >>> e.source, e.want ! ('print 1\n', '1\n') ! Source spans multiple lines: require terminating newline. >>> e = doctest.Example('print 1;\nprint 2\n', '1\n2\n', 0) + >>> e.source, e.want + ('print 1;\nprint 2\n', '1\n2\n') + >>> e = doctest.Example('print 1;\nprint 2', '1\n2\n', 0) ! >>> e.source, e.want ! ('print 1;\nprint 2\n', '1\n2\n') ! The `want` string ends with a newline, unless it's the empty string: >>> e = doctest.Example('print 1', '1\n', 0) + >>> e.source, e.want + ('print 1\n', '1\n') + >>> e = doctest.Example('print 1', '1', 0) ! >>> e.source, e.want ! ('print 1\n', '1\n') ! >>> e = doctest.Example('print', '', 0) + >>> e.source, e.want + ('print\n', '') """ *************** *** 181,187 **** >>> e1, e2 = test.examples >>> (e1.source, e1.want, e1.lineno) ! ('print 12', '12\n', 1) >>> (e2.source, e2.want, e2.lineno) ! ("print 'another\\example'", 'another\nexample\n', 6) Source information (name, filename, and line number) is available as --- 191,197 ---- >>> e1, e2 = test.examples >>> (e1.source, e1.want, e1.lineno) ! ('print 12\n', '12\n', 1) >>> (e2.source, e2.want, e2.lineno) ! ("print 'another\\example'\n", 'another\nexample\n', 6) Source information (name, filename, and line number) is available as *************** *** 265,270 **** [] >>> e = tests[0].examples[0] ! >>> print (e.source, e.want, e.lineno) ! ('print sample_func(22)', '44\n', 3) >>> doctest: -ELLIPSIS # Turn ellipsis back off --- 275,280 ---- [] >>> e = tests[0].examples[0] ! >>> (e.source, e.want, e.lineno) ! ('print sample_func(22)\n', '44\n', 3) >>> doctest: -ELLIPSIS # Turn ellipsis back off From tim_one at users.sourceforge.net Mon Aug 9 06:12:38 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 9 06:12:40 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.51,1.52 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16064/Lib Modified Files: doctest.py Log Message: Repair some out-of-date comments. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** doctest.py 9 Aug 2004 03:51:46 -0000 1.51 --- doctest.py 9 Aug 2004 04:12:36 -0000 1.52 *************** *** 1280,1287 **** # keyboard interrupts.) try: ! # If the example is a compound statement on one line, ! # like "if 1: print 2", then compile() requires a ! # trailing newline. Rather than analyze that, always ! # append one (it never hurts). exec compile(example.source, "", "single", compileflags, 1) in test.globs --- 1280,1284 ---- # keyboard interrupts.) try: ! # Don't blink! This is where the user's code gets run. exec compile(example.source, "", "single", compileflags, 1) in test.globs *************** *** 1292,1299 **** exception = sys.exc_info() ! # Extract the example's actual output from fakeout, and ! # write it to `got`. Add a terminating newline if it ! # doesn't have already one. ! got = self._fakeout.getvalue() self._fakeout.truncate(0) --- 1289,1293 ---- exception = sys.exc_info() ! got = self._fakeout.getvalue() # the actual output self._fakeout.truncate(0) From tim_one at users.sourceforge.net Mon Aug 9 06:34:48 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 9 06:34:51 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.52,1.53 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18647/Lib Modified Files: doctest.py Log Message: Removed lots of stuff from the module docstring. My intent for 2.4 is to put details in the LaTeX docs instead, and lots of stuff in the module docstring wasn't useful anyway. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** doctest.py 9 Aug 2004 04:12:36 -0000 1.52 --- doctest.py 9 Aug 2004 04:34:45 -0000 1.53 *************** *** 7,20 **** # Provided as-is; use at your own risk; no warranty; no promises; enjoy! - # [XX] This docstring is out-of-date: r"""Module doctest -- a framework for running examples in docstrings. NORMAL USAGE ! In normal use, end each module M with: def _test(): ! import doctest, M # replace M with your module's name ! return doctest.testmod(M) # ditto if __name__ == "__main__": --- 7,19 ---- # Provided as-is; use at your own risk; no warranty; no promises; enjoy! r"""Module doctest -- a framework for running examples in docstrings. NORMAL USAGE ! In simplest use, end each module M to be tested with: def _test(): ! import doctest ! return doctest.testmod() if __name__ == "__main__": *************** *** 38,43 **** with assorted summaries at the end. ! You can force verbose mode by passing "verbose=1" to testmod, or prohibit ! it by passing "verbose=0". In either of those cases, sys.argv is not examined by testmod. --- 37,42 ---- with assorted summaries at the end. ! You can force verbose mode by passing "verbose=True" to testmod, or prohibit ! it by passing "verbose=False". In either of those cases, sys.argv is not examined by testmod. *************** *** 46,49 **** --- 45,54 ---- docstring examples attempted. + There are a variety of other ways to run doctests, including integration + with the unittest framework, and support for running non-Python text + files containing doctests. There are also many ways to override parts + of doctest's default behaviors. See the Library Reference Manual for + details. + WHICH DOCSTRINGS ARE EXAMINED? *************** *** 60,84 **** each entry maps a (string) name to a function object, class object, or string. Function and class object docstrings found from M.__test__ ! are searched even if the name is private, and strings are searched ! directly as if they were docstrings. In output, a key K in M.__test__ ! appears with name .__test__.K Any classes found are recursively searched similarly, to test docstrings in ! their contained methods and nested classes. All names reached from ! M.__test__ are searched. ! ! Optionally, functions with private names can be skipped (unless listed in ! M.__test__) by supplying a function to the "isprivate" argument that will ! identify private functions. For convenience, one such function is ! supplied. docttest.is_private considers a name to be private if it begins ! with an underscore (like "_my_func") but doesn't both begin and end with ! (at least) two underscores (like "__init__"). By supplying this function ! or your own "isprivate" function to testmod, the behavior can be customized. - If you want to test docstrings in objects with private names too, stuff - them into an M.__test__ dict, or see ADVANCED USAGE below (e.g., pass your - own isprivate function to Tester's constructor, or call the rundoc method - of a Tester instance). WHAT'S THE EXECUTION CONTEXT? --- 65,75 ---- each entry maps a (string) name to a function object, class object, or string. Function and class object docstrings found from M.__test__ ! are searched, and strings are searched directly as if they were docstrings. ! In output, a key K in M.__test__ appears with name .__test__.K Any classes found are recursively searched similarly, to test docstrings in ! their contained methods and nested classes. WHAT'S THE EXECUTION CONTEXT? *************** *** 97,142 **** - WHAT IF I WANT TO TEST A WHOLE PACKAGE? - - Piece o' cake, provided the modules do their testing from docstrings. - Here's the test.py I use for the world's most elaborate Rational/ - floating-base-conversion pkg (which I'll distribute some day): - - from Rational import Cvt - from Rational import Format - from Rational import machprec - from Rational import Rat - from Rational import Round - from Rational import utils - - modules = (Cvt, - Format, - machprec, - Rat, - Round, - utils) - - def _test(): - import doctest - import sys - verbose = "-v" in sys.argv - for mod in modules: - doctest.testmod(mod, verbose=verbose, report=0) - doctest.master.summarize() - - if __name__ == "__main__": - _test() - - IOW, it just runs testmod on all the pkg modules. testmod remembers the - names and outcomes (# of failures, # of tries) for each item it's seen, and - passing "report=0" prevents it from printing a summary in verbose mode. - Instead, the summary is delayed until all modules have been tested, and - then "doctest.master.summarize()" forces the summary at the end. - - So this is very nice in practice: each module can be tested individually - with almost no work beyond writing up docstring examples, and collections - of modules can be tested too as a unit with no more work than the above. - - WHAT ABOUT EXCEPTIONS? --- 88,91 ---- *************** *** 150,172 **** >>> ! Note that only the exception type and value are compared (specifically, ! only the last line in the traceback). ! ! ! ADVANCED USAGE ! ! doctest.testmod() captures the testing policy I find most useful most ! often. You may want other policies. ! ! testmod() actually creates a local instance of class doctest.Tester, runs ! appropriate methods of that class, and merges the results into global ! Tester instance doctest.master. ! ! You can create your own instances of doctest.Tester, and so build your own ! policies, or even run methods of doctest.master directly. See ! doctest.Tester.__doc__ for details. ! SO WHAT DOES A DOCSTRING EXAMPLE LOOK LIKE ALREADY!? Oh ya. It's easy! In most cases a copy-and-paste of an interactive --- 99,106 ---- >>> ! Note that only the exception type and value are compared. ! SO WHAT DOES A DOCTEST EXAMPLE LOOK LIKE ALREADY!? Oh ya. It's easy! In most cases a copy-and-paste of an interactive *************** *** 198,204 **** Bummers: - + Expected output cannot contain an all-whitespace line, since such a line - is taken to signal the end of expected output. - + Output to stdout is captured, but not output to stderr (exception tracebacks are captured via a different means). --- 132,135 ---- *************** *** 235,289 **** If you execute this very file, the examples above will be found and ! executed, leading to this output in verbose mode: ! ! Running doctest.__doc__ ! Trying: [1, 2, 3].remove(42) ! Expecting: ! Traceback (most recent call last): ! File "", line 1, in ? ! ValueError: list.remove(x): x not in list ! ok ! Trying: x = 12 ! Expecting: nothing ! ok ! Trying: x ! Expecting: 12 ! ok ! Trying: ! if x == 13: ! print "yes" ! else: ! print "no" ! print "NO" ! print "NO!!!" ! Expecting: ! no ! NO ! NO!!! ! ok ! ... and a bunch more like that, with this summary at the end: ! ! 5 items had no tests: ! doctest.Tester.__init__ ! doctest.Tester.run__test__ ! doctest.Tester.summarize ! doctest.run_docstring_examples ! doctest.testmod ! 12 items passed all tests: ! 8 tests in doctest ! 6 tests in doctest.Tester ! 10 tests in doctest.Tester.merge ! 14 tests in doctest.Tester.rundict ! 3 tests in doctest.Tester.rundoc ! 3 tests in doctest.Tester.runstring ! 2 tests in doctest.__test__._TestClass ! 2 tests in doctest.__test__._TestClass.__init__ ! 2 tests in doctest.__test__._TestClass.get ! 1 tests in doctest.__test__._TestClass.square ! 2 tests in doctest.__test__.string ! 7 tests in doctest.is_private ! 60 tests in 17 items. ! 60 passed and 0 failed. ! Test passed. """ --- 166,170 ---- If you execute this very file, the examples above will be found and ! executed. """ From davecole at users.sourceforge.net Mon Aug 9 06:51:42 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Mon Aug 9 06:51:48 2004 Subject: [Python-checkins] python/dist/src configure.in, 1.463, 1.464 pyconfig.h.in, 1.101, 1.102 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20818 Modified Files: configure.in pyconfig.h.in Log Message: Patch #1003700: Add socketpair function to socket module. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.463 retrieving revision 1.464 diff -C2 -d -r1.463 -r1.464 *** configure.in 22 Jul 2004 18:43:59 -0000 1.463 --- configure.in 9 Aug 2004 04:51:39 -0000 1.464 *************** *** 2469,2472 **** --- 2469,2483 ---- AC_MSG_RESULT($works) + # check for socketpair + AC_MSG_CHECKING(for socketpair) + AC_TRY_COMPILE([ + #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) Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.101 retrieving revision 1.102 diff -C2 -d -r1.101 -r1.102 *** pyconfig.h.in 22 Jul 2004 18:43:59 -0000 1.101 --- pyconfig.h.in 9 Aug 2004 04:51:40 -0000 1.102 *************** *** 429,432 **** --- 429,435 ---- #undef HAVE_SNPRINTF + /* Define to 1 if you have the `socketpair' function. */ + #undef HAVE_SOCKETPAIR + /* Define if sockaddr has sa_len member */ #undef HAVE_SOCKADDR_SA_LEN From davecole at users.sourceforge.net Mon Aug 9 06:51:42 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Mon Aug 9 06:51:49 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.84,1.85 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20818/Doc/lib Modified Files: libsocket.tex Log Message: Patch #1003700: Add socketpair function to socket module. Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** libsocket.tex 28 Jun 2004 00:50:35 -0000 1.84 --- libsocket.tex 9 Aug 2004 04:51:40 -0000 1.85 *************** *** 304,307 **** --- 304,315 ---- \end{funcdesc} + \begin{funcdesc}{socketpair}{\optional{family\optional{, type\optional{, proto}}}} + 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 \function{socket()} function above. + Availability: \UNIX. + \versionadded{2.3} + \end{funcdesc} + \begin{funcdesc}{fromfd}{fd, family, type\optional{, proto}} Build a socket object from an existing file descriptor (an integer as From davecole at users.sourceforge.net Mon Aug 9 06:51:42 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Mon Aug 9 06:51:50 2004 Subject: [Python-checkins] python/dist/src/Lib socket.py,1.44,1.45 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20818/Lib Modified Files: socket.py Log Message: Patch #1003700: Add socketpair function to socket module. Index: socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/socket.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** socket.py 31 May 2004 03:09:22 -0000 1.44 --- socket.py 9 Aug 2004 04:51:40 -0000 1.45 *************** *** 11,14 **** --- 11,15 ---- socket() -- create a new socket object + socketpair() -- create a pair of new socket objects [*] fromfd() -- create a socket object from an open file descriptor [*] gethostname() -- return the current hostname From davecole at users.sourceforge.net Mon Aug 9 06:51:43 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Mon Aug 9 06:51:51 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py, 1.72, 1.73 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20818/Lib/test Modified Files: test_socket.py Log Message: Patch #1003700: Add socketpair function to socket module. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** test_socket.py 12 Jul 2004 12:10:30 -0000 1.72 --- test_socket.py 9 Aug 2004 04:51:40 -0000 1.73 *************** *** 188,191 **** --- 188,213 ---- ThreadedTCPSocketTest.clientTearDown(self) + class SocketPairTest(unittest.TestCase, ThreadableTest): + + def __init__(self, methodName='runTest'): + unittest.TestCase.__init__(self, methodName=methodName) + ThreadableTest.__init__(self) + + def setUp(self): + self.serv, self.cli = socket.socketpair() + + def tearDown(self): + self.serv.close() + self.serv = None + + def clientSetUp(self): + pass + + def clientTearDown(self): + self.cli.close() + self.cli = None + ThreadableTest.clientTearDown(self) + + ####################################################################### ## Begin Tests *************** *** 542,545 **** --- 564,586 ---- self.cli.sendto(MSG, 0, (HOST, PORT)) + class BasicSocketPairTest(SocketPairTest): + + def __init__(self, methodName='runTest'): + SocketPairTest.__init__(self, methodName=methodName) + + def testRecv(self): + msg = self.serv.recv(1024) + self.assertEqual(msg, MSG) + + def _testRecv(self): + self.cli.send(MSG) + + def testSend(self): + self.serv.send(MSG) + + def _testSend(self): + msg = self.cli.recv(1024) + self.assertEqual(msg, MSG) + class NonBlockingTCPTests(ThreadedTCPSocketTest): *************** *** 787,790 **** --- 828,833 ---- SmallBufferedFileObjectClassTestCase ]) + if hasattr(socket, "socketpair"): + tests.append(BasicSocketPairTest) test_support.run_unittest(*tests) From davecole at users.sourceforge.net Mon Aug 9 06:51:43 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Mon Aug 9 06:51:52 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1080,1.1081 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20818/Misc Modified Files: NEWS Log Message: Patch #1003700: Add socketpair function to socket module. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1080 retrieving revision 1.1081 diff -C2 -d -r1.1080 -r1.1081 *** NEWS 8 Aug 2004 07:24:22 -0000 1.1080 --- NEWS 9 Aug 2004 04:51:41 -0000 1.1081 *************** *** 25,28 **** --- 25,30 ---- ----------------- + - Added socket.socketpair(). + Library ------- From davecole at users.sourceforge.net Mon Aug 9 06:51:43 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Mon Aug 9 06:51:53 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.298, 1.299 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20818/Modules Modified Files: socketmodule.c Log Message: Patch #1003700: Add socketpair function to socket module. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.298 retrieving revision 1.299 diff -C2 -d -r1.298 -r1.299 *** socketmodule.c 3 Aug 2004 08:52:45 -0000 1.298 --- socketmodule.c 9 Aug 2004 04:51:41 -0000 1.299 *************** *** 29,32 **** --- 29,33 ---- - socket.getservbyport(portnumber[, protocolname]) --> service name - socket.socket([family[, type [, proto]]]) --> new socket object + - socket.socketpair([family[, type [, proto]]]) --> (socket, socket) - socket.ntohs(16 bit value) --> new int object - socket.ntohl(32 bit value) --> new int object *************** *** 3010,3013 **** --- 3011,3071 ---- + #ifdef HAVE_SOCKETPAIR + /* Create a pair of sockets using the socketpair() function. + Arguments as for socket(). */ + + /*ARGSUSED*/ + static PyObject * + socket_socketpair(PyObject *self, PyObject *args) + { + PySocketSockObject *s0 = NULL, *s1 = NULL; + SOCKET_T sv[2]; + int family, type = SOCK_STREAM, proto = 0; + PyObject *res = NULL; + + #if defined(AF_UNIX) + family = AF_UNIX; + #else + family = AF_INET; + #endif + if (!PyArg_ParseTuple(args, "|iii:socketpair", + &family, &type, &proto)) + return NULL; + /* Create a pair of socket fds */ + if (socketpair(family, type, proto, sv) < 0) + return set_error(); + #ifdef SIGPIPE + (void) signal(SIGPIPE, SIG_IGN); + #endif + s0 = new_sockobject(sv[0], family, type, proto); + if (s0 == NULL) + goto finally; + s1 = new_sockobject(sv[1], family, type, proto); + if (s1 == NULL) + goto finally; + res = PyTuple_Pack(2, s0, s1); + + finally: + if (res == NULL) { + if (s0 == NULL) + SOCKETCLOSE(sv[0]); + if (s1 == NULL) + SOCKETCLOSE(sv[1]); + } + Py_XDECREF(s0); + Py_XDECREF(s1); + return res; + } + + PyDoc_STRVAR(socketpair_doc, + "socketpair([family[, type[, proto]]]) -> (socket object, socket object)\n\ + \n\ + Create a pair of socket objects from the sockets returned by the platform\n\ + socketpair() function.\n\ + The arguments are the same as for socket()."); + + #endif /* HAVE_SOCKETPAIR */ + + #ifndef NO_DUP /* Create a socket object from a numeric file description. *************** *** 3609,3612 **** --- 3667,3674 ---- METH_VARARGS, fromfd_doc}, #endif + #ifdef HAVE_SOCKETPAIR + {"socketpair", socket_socketpair, + METH_VARARGS, socketpair_doc}, + #endif {"ntohs", socket_ntohs, METH_VARARGS, ntohs_doc}, From rhettinger at users.sourceforge.net Mon Aug 9 07:52:51 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Aug 9 07:52:54 2004 Subject: [Python-checkins] python/nondist/sandbox/string/string alt292.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/string/string In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27487 Added Files: alt292.py Log Message: Suggest an alternate approach to implementing PEP292 with functions. --- NEW FILE: alt292.py --- # Alternate implementation of PEP 292 # uses functions instead of classes # does not consume memory with a pre-converted template # directly extendable with a user supplied pattern # C speed iteration using re.sub instead of % formatting # # Todo: # rename functions for clarity (sub_from_env or somesuch) # add dotted attribute lookup __all__ = ['regularsub', 'safesub', 'envsub'] import re import sys _pattern = re.compile(r'(\${2})|\$([_a-z][_a-z0-9]*)|\${([_a-z][_a-z0-9]*)}', re.IGNORECASE) def regularsub(template, mapping, pattern=_pattern): # raises KeyError if key not found def xlat(matchobj, mapping=mapping): escape, name, braced = matchobj.groups() if escape is not None: return '$' return mapping[name or braced] return pattern.sub(xlat, template) def safesub(template, mapping, pattern=_pattern): # Idempotent if key is missing def xlat(matchobj, mapping=mapping): escape, name, braced = matchobj.groups() if escape is not None: return '$' if name is not None: try: return mapping[name] except KeyError: return '$' + name try: return mapping[braced] except KeyError: return '${' + braced + '}' return _pattern.sub(xlat, template) def envsub(template): # Default mapping from the locals/globals of caller frame = sys._getframe(1) mapping = frame.f_globals.copy() mapping.update(frame.f_locals) mapping['$$'] = '$' def xlat(matchobj, mapping=mapping): return mapping[matchobj.group(matchobj.lastindex)] return _pattern.sub(xlat, template) ####### Unittests ######################## import unittest class TestSimplerSubstitutions(unittest.TestCase): def test_regular(self): s = '$name was born in ${country} $$' self.assertEqual( regularsub(s, {'name':'Guido', 'country':'the Netherlands'}), 'Guido was born in the Netherlands $') maps = [ {'name':'Tim'}, {'country':'the Netherlands'}, {}, ] for mapping in maps: self.assertRaises(KeyError, regularsub, s, mapping) def test_safe(self): s = '$name was born in ${country} $$' pairs = [ ({'name':'Guido', 'country':'the Netherlands'}, 'Guido was born in the Netherlands $'), ({'name':'Tim'}, 'Tim was born in ${country} $'), ({'country':'the Netherlands'}, '$name was born in the Netherlands $'), ({}, '$name was born in ${country} $'), ] for mapping, expected in pairs: self.assertEqual(safesub(s, mapping), expected) def test_env(self): s = '$name was born in ${country} $$' name = 'Guido' country = 'the Netherlands' self.assertEqual(envsub(s), 'Guido was born in the Netherlands $') del name self.assertRaises(KeyError, envsub, s) if __name__ == '__main__': suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestSimplerSubstitutions)) unittest.TextTestRunner(verbosity=2).run(suite) From davecole at users.sourceforge.net Mon Aug 9 07:59:12 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Mon Aug 9 07:59:15 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.85,1.86 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28461 Modified Files: libsocket.tex Log Message: Ooops - for some reason I had the wrong versionadded... Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** libsocket.tex 9 Aug 2004 04:51:40 -0000 1.85 --- libsocket.tex 9 Aug 2004 05:59:09 -0000 1.86 *************** *** 309,313 **** and protocol number are as for the \function{socket()} function above. Availability: \UNIX. ! \versionadded{2.3} \end{funcdesc} --- 309,313 ---- and protocol number are as for the \function{socket()} function above. Availability: \UNIX. ! \versionadded{2.4} \end{funcdesc} From dcjim at users.sourceforge.net Mon Aug 9 13:34:49 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Mon Aug 9 13:34:52 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.53,1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13178/Lib Modified Files: doctest.py Log Message: Added support for pdb.set_trace. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** doctest.py 9 Aug 2004 04:34:45 -0000 1.53 --- doctest.py 9 Aug 2004 11:34:47 -0000 1.54 *************** *** 188,195 **** import sys, traceback, inspect, linecache, os, re, types ! import unittest, difflib, tempfile import warnings from StringIO import StringIO # Option constants. DONT_ACCEPT_TRUE_FOR_1 = 1 << 0 --- 188,197 ---- import sys, traceback, inspect, linecache, os, re, types ! import unittest, difflib, pdb, tempfile import warnings from StringIO import StringIO + real_pdb_set_trace = pdb.set_trace + # Option constants. DONT_ACCEPT_TRUE_FOR_1 = 1 << 0 *************** *** 1252,1264 **** --- 1254,1279 ---- if compileflags is None: compileflags = _extract_future_flags(test.globs) + if out is None: out = sys.stdout.write saveout = sys.stdout + # Note that don't save away the previous pdb.set_trace. Rather, + # we safe pdb.set_trace on import (see import section above). + # We then call and restore that original cersion. We do it this + # way to make this feature testable. If we kept and called the + # previous version, we'd end up restoring the original stdout, + # which is not what we want. + def set_trace(): + sys.stdout = saveout + real_pdb_set_trace() + try: sys.stdout = self._fakeout + pdb.set_trace = set_trace return self.__run(test, compileflags, out) finally: sys.stdout = saveout + pdb.set_trace = real_pdb_set_trace if clear_globs: test.globs.clear() From dcjim at users.sourceforge.net Mon Aug 9 13:34:49 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Mon Aug 9 13:34:54 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13178/Lib/test Modified Files: test_doctest.py Log Message: Added support for pdb.set_trace. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_doctest.py 9 Aug 2004 03:51:46 -0000 1.13 --- test_doctest.py 9 Aug 2004 11:34:47 -0000 1.14 *************** *** 985,988 **** --- 985,1075 ---- """ + def test_pdb_set_trace(): + r"""Using pdb.set_trace from a doctest + + You can use pdb.set_trace from a doctest. To do so, you must + retrieve the set_trace function from the pdb module at the time + you use it. The doctest module changes sys,stdout so that it can + capture program output. It also temporarily replaces pdb.set_trace + with a version that restores stdout. This is necessary for you to + see debugger output. + + >>> doc = ''' + ... >>> x = 42 + ... >>> import pdb; pdb.set_trace() + ... ''' + >>> test = doctest.DocTest(doc, {}, "foo", "foo.py", 0) + >>> runner = doctest.DocTestRunner(verbose=False) + + To demonstrate this, we'll create a fake standard input that + captures our debugger input: + + >>> import tempfile + >>> fake_stdin = tempfile.TemporaryFile(mode='w+') + >>> fake_stdin.write('\n'.join([ + ... 'up', # up out of pdb.set_trace + ... 'up', # up again to get out of our wrapper + ... 'print x', # print data defined by the example + ... 'continue', # stop debugging + ... ''])) + >>> fake_stdin.seek(0) + >>> real_stdin = sys.stdin + >>> sys.stdin = fake_stdin + + >>> doctest: +ELLIPSIS + >>> runner.run(test) + --Return-- + > ...set_trace()->None + -> Pdb().set_trace() + (Pdb) > ...set_trace() + -> real_pdb_set_trace() + (Pdb) > (1)?() + (Pdb) 42 + (Pdb) (0, 2) + + >>> sys.stdin = real_stdin + >>> fake_stdin.close() + + You can also put pdb.set_trace in a function called from a test: + + >>> def calls_set_trace(): + ... y=2 + ... import pdb; pdb.set_trace() + + >>> doc = ''' + ... >>> x=1 + ... >>> calls_set_trace() + ... ''' + >>> test = doctest.DocTest(doc, globals(), "foo", "foo.py", 0) + + >>> import tempfile + >>> fake_stdin = tempfile.TemporaryFile(mode='w+') + >>> fake_stdin.write('\n'.join([ + ... 'up', # up out of pdb.set_trace + ... 'up', # up again to get out of our wrapper + ... 'print y', # print data defined in the function + ... 'up', # out of function + ... 'print x', # print data defined by the example + ... 'continue', # stop debugging + ... ''])) + >>> fake_stdin.seek(0) + >>> real_stdin = sys.stdin + >>> sys.stdin = fake_stdin + + >>> runner.run(test) + --Return-- + > ...set_trace()->None + -> Pdb().set_trace() + (Pdb) ...set_trace() + -> real_pdb_set_trace() + (Pdb) > (3)calls_set_trace() + (Pdb) 2 + (Pdb) > (1)?() + (Pdb) 1 + (Pdb) (0, 2) + + >>> doctest: -ELLIPSIS + """ + def test_DocTestSuite(): """DocTestSuite creates a unittest test suite from a doctest. From jlt63 at users.sourceforge.net Mon Aug 9 15:26:01 2004 From: jlt63 at users.sourceforge.net (jlt63@users.sourceforge.net) Date: Mon Aug 9 15:26:03 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.299, 1.300 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31479 Modified Files: socketmodule.c Log Message: Bug #1001857: socketmodule does not build under cygwin Restore clean building under Cygwin. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.299 retrieving revision 1.300 diff -C2 -d -r1.299 -r1.300 *** socketmodule.c 9 Aug 2004 04:51:41 -0000 1.299 --- socketmodule.c 9 Aug 2004 13:25:59 -0000 1.300 *************** *** 287,290 **** --- 287,294 ---- #endif + #if defined(__CYGWIN__) + #include "addrinfo.h" + #endif + #ifndef HAVE_INET_PTON int inet_pton(int af, const char *src, void *dst); From fdrake at users.sourceforge.net Mon Aug 9 16:07:01 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Aug 9 16:07:47 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.244,1.245 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5774 Modified Files: tut.tex Log Message: fix markup nit Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.244 retrieving revision 1.245 diff -C2 -d -r1.244 -r1.245 *** tut.tex 7 Aug 2004 17:05:42 -0000 1.244 --- tut.tex 9 Aug 2004 14:06:58 -0000 1.245 *************** *** 2768,2772 **** \subsection{Importing * From a Package \label{pkg-import-star}} %The \code{__all__} Attribute ! \index{__all__} Now what happens when the user writes \code{from Sound.Effects import *}? Ideally, one would hope that this somehow goes out to the --- 2768,2773 ---- \subsection{Importing * From a Package \label{pkg-import-star}} %The \code{__all__} Attribute ! ! \ttindex{__all__} Now what happens when the user writes \code{from Sound.Effects import *}? Ideally, one would hope that this somehow goes out to the From fdrake at users.sourceforge.net Mon Aug 9 16:12:07 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Aug 9 16:12:39 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libpopen2.tex,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6694 Modified Files: libpopen2.tex Log Message: - make a module reference a hyperlink - wrap a long line Index: libpopen2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpopen2.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** libpopen2.tex 7 Aug 2004 17:28:17 -0000 1.21 --- libpopen2.tex 9 Aug 2004 14:12:05 -0000 1.22 *************** *** 31,36 **** \function{popen2()}, \function{popen3()}, and \function{popen4()} functions, or the equivalent functions in the \refmodule{os} module. ! (Note that the tuples returned by the \module{os} module's functions ! are in a different order from the ones returned by the \module{popen2} module.) \begin{funcdesc}{popen2}{cmd\optional{, bufsize\optional{, mode}}} --- 31,37 ---- \function{popen2()}, \function{popen3()}, and \function{popen4()} functions, or the equivalent functions in the \refmodule{os} module. ! (Note that the tuples returned by the \refmodule{os} module's functions ! are in a different order from the ones returned by the \module{popen2} ! module.) \begin{funcdesc}{popen2}{cmd\optional{, bufsize\optional{, mode}}} From akuchling at users.sourceforge.net Mon Aug 9 16:48:31 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Aug 9 16:49:17 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.86, 1.87 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13569 Modified Files: whatsnew24.tex Log Message: Add item Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** whatsnew24.tex 7 Aug 2004 14:28:37 -0000 1.86 --- whatsnew24.tex 9 Aug 2004 14:48:28 -0000 1.87 *************** *** 1071,1074 **** --- 1071,1078 ---- the group didn't match, the pattern \var{B} will be used instead. + \item A new \function{socketpair()} function was added to the + \module{socket} module, returning a pair of connected sockets. + (Contributed by Dave Cole.) + % XXX sre is now non-recursive. From jlt63 at users.sourceforge.net Mon Aug 9 17:02:43 2004 From: jlt63 at users.sourceforge.net (jlt63@users.sourceforge.net) Date: Mon Aug 9 17:04:40 2004 Subject: [Python-checkins] python/dist/src/Include pystrtod.h, 2.1, 2.2 pythonrun.h, 2.62, 2.63 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16182 Modified Files: pystrtod.h pythonrun.h Log Message: Patch #1006003: Cygwin standard module build problems Add missing PyAPI_FUNC/PyAPI_DATA macros. Index: pystrtod.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pystrtod.h,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -d -r2.1 -r2.2 *** pystrtod.h 8 Jun 2004 18:52:41 -0000 2.1 --- pystrtod.h 9 Aug 2004 15:02:29 -0000 2.2 *************** *** 7,13 **** ! double PyOS_ascii_strtod(const char *str, char **ptr); ! double PyOS_ascii_atof(const char *str); ! char * PyOS_ascii_formatd(char *buffer, int buf_len, const char *format, double d); --- 7,13 ---- ! PyAPI_FUNC(double) PyOS_ascii_strtod(const char *str, char **ptr); ! PyAPI_FUNC(double) PyOS_ascii_atof(const char *str); ! PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, int buf_len, const char *format, double d); Index: pythonrun.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pythonrun.h,v retrieving revision 2.62 retrieving revision 2.63 diff -C2 -d -r2.62 -r2.63 *** pythonrun.h 13 Feb 2003 22:07:52 -0000 2.62 --- pythonrun.h 9 Aug 2004 15:02:30 -0000 2.63 *************** *** 122,125 **** --- 122,126 ---- PyAPI_DATA(int) (*PyOS_InputHook)(void); PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *); + PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState; /* Stack size, in "pointers" (so we get extra safety margins From tim_one at users.sourceforge.net Mon Aug 9 17:43:49 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 9 17:43:52 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22785/Lib/test Modified Files: test_doctest.py Log Message: This started as a spelling and whitespace cleanup. The comment for the set_trace fiddling didn't make sense to me, and I ended up reworking that part of the code. We really do want to save and restore pdb.set_trace, so that each dynamically nested level of doctest gets sys.stdout fiddled to what's appropriate for *it*. The only "trick" really needed is that these layers of set_trace wrappers each call the original pdb.set_trace (instead of the current pdb.set_trace). Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** test_doctest.py 9 Aug 2004 11:34:47 -0000 1.14 --- test_doctest.py 9 Aug 2004 15:43:47 -0000 1.15 *************** *** 988,996 **** r"""Using pdb.set_trace from a doctest ! You can use pdb.set_trace from a doctest. To do so, you must retrieve the set_trace function from the pdb module at the time ! you use it. The doctest module changes sys,stdout so that it can ! capture program output. It also temporarily replaces pdb.set_trace ! with a version that restores stdout. This is necessary for you to see debugger output. --- 988,996 ---- r"""Using pdb.set_trace from a doctest ! You can use pdb.set_trace from a doctest. To do so, you must retrieve the set_trace function from the pdb module at the time ! you use it. The doctest module changes sys.stdout so that it can ! capture program output. It also temporarily replaces pdb.set_trace ! with a version that restores stdout. This is necessary for you to see debugger output. *************** *** 1042,1047 **** ... ''' >>> test = doctest.DocTest(doc, globals(), "foo", "foo.py", 0) ! ! >>> import tempfile >>> fake_stdin = tempfile.TemporaryFile(mode='w+') >>> fake_stdin.write('\n'.join([ --- 1042,1046 ---- ... ''' >>> test = doctest.DocTest(doc, globals(), "foo", "foo.py", 0) ! >>> fake_stdin = tempfile.TemporaryFile(mode='w+') >>> fake_stdin.write('\n'.join([ From tim_one at users.sourceforge.net Mon Aug 9 17:43:49 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 9 17:43:54 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.54,1.55 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22785/Lib Modified Files: doctest.py Log Message: This started as a spelling and whitespace cleanup. The comment for the set_trace fiddling didn't make sense to me, and I ended up reworking that part of the code. We really do want to save and restore pdb.set_trace, so that each dynamically nested level of doctest gets sys.stdout fiddled to what's appropriate for *it*. The only "trick" really needed is that these layers of set_trace wrappers each call the original pdb.set_trace (instead of the current pdb.set_trace). Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** doctest.py 9 Aug 2004 11:34:47 -0000 1.54 --- doctest.py 9 Aug 2004 15:43:46 -0000 1.55 *************** *** 1255,1279 **** compileflags = _extract_future_flags(test.globs) if out is None: ! out = sys.stdout.write ! saveout = sys.stdout ! # Note that don't save away the previous pdb.set_trace. Rather, ! # we safe pdb.set_trace on import (see import section above). ! # We then call and restore that original cersion. We do it this ! # way to make this feature testable. If we kept and called the ! # previous version, we'd end up restoring the original stdout, ! # which is not what we want. def set_trace(): ! sys.stdout = saveout real_pdb_set_trace() try: - sys.stdout = self._fakeout - pdb.set_trace = set_trace return self.__run(test, compileflags, out) finally: ! sys.stdout = saveout ! pdb.set_trace = real_pdb_set_trace if clear_globs: test.globs.clear() --- 1255,1282 ---- compileflags = _extract_future_flags(test.globs) + save_stdout = sys.stdout if out is None: ! out = save_stdout.write ! sys.stdout = self._fakeout ! # Patch pdb.set_trace to restore sys.stdout, so that interactive ! # debugging output is visible (not still redirected to self._fakeout). ! # Note that we run "the real" pdb.set_trace (captured at doctest ! # import time) in our replacement. Because the current run() may ! # run another doctest (and so on), the current pdb.set_trace may be ! # our set_trace function, which changes sys.stdout. If we called ! # a chain of those, we wouldn't be left with the save_stdout ! # *this* run() invocation wants. def set_trace(): ! sys.stdout = save_stdout real_pdb_set_trace() + save_set_trace = pdb.set_trace + pdb.set_trace = set_trace try: return self.__run(test, compileflags, out) finally: ! sys.stdout = save_stdout ! pdb.set_trace = save_set_trace if clear_globs: test.globs.clear() From edloper at users.sourceforge.net Mon Aug 9 18:14:43 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Mon Aug 9 18:14:46 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.55,1.56 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30812 Modified Files: doctest.py Log Message: - DocTest is now a simple container class; its constructor is no longer responsible for parsing the string. - Renamed Parser to DocTestParser - DocTestParser.get_*() now accept the string & name as command-line arguments; the parser's constructor is now empty. - Added DocTestParser.get_doctest() method - Replaced "doctest_factory" argument to DocTestFinder with a "parser" argument (takes a DocTestParser). - Changed _tag_msg to take an indentation string argument. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** doctest.py 9 Aug 2004 15:43:46 -0000 1.55 --- doctest.py 9 Aug 2004 16:14:41 -0000 1.56 *************** *** 315,328 **** raise TypeError("Expected a module, string, or None") ! def _tag_msg(tag, msg, indent_msg=True): """ Return a string that displays a tag-and-message pair nicely, keeping the tag and its message on the same line when that ! makes sense. If `indent_msg` is true, then messages that are ! put on separate lines will be indented. """ - # What string should we use to indent contents? - INDENT = ' ' - # If the message doesn't end in a newline, then add one. if msg[-1:] != '\n': --- 315,325 ---- raise TypeError("Expected a module, string, or None") ! def _tag_msg(tag, msg, indent=' '): """ Return a string that displays a tag-and-message pair nicely, keeping the tag and its message on the same line when that ! makes sense. If the message is displayed on separate lines, ! then `indent` is added to the beginning of each line. """ # If the message doesn't end in a newline, then add one. if msg[-1:] != '\n': *************** *** 335,342 **** return '%s: %s' % (tag, msg) else: ! if indent_msg: ! msg = '\n'.join([INDENT+l for l in msg.split('\n')]) ! msg = msg[:-len(INDENT)] ! return '%s:\n%s' % (tag, msg) # Override some StringIO methods. --- 332,337 ---- return '%s: %s' % (tag, msg) else: ! msg = '\n'.join([indent+l for l in msg[:-1].split('\n')]) ! return '%s:\n%s\n' % (tag, msg) # Override some StringIO methods. *************** *** 368,379 **** ## where the example was extracted from. ## ! ## - A "doctest" is a collection of examples extracted from a string ! ## (such as an object's docstring). The DocTest class also includes ! ## information about where the string was extracted from. class Example: """ A single doctest example, consisting of source code and expected ! output. Example defines the following attributes: - source: A single Python statement, always ending with a newline. --- 363,374 ---- ## where the example was extracted from. ## ! ## - A "doctest" is a collection of examples, typically extracted from ! ## a string (such as an object's docstring). The DocTest class also ! ## includes information about where the string was extracted from. class Example: """ A single doctest example, consisting of source code and expected ! output. `Example` defines the following attributes: - source: A single Python statement, always ending with a newline. *************** *** 403,407 **** """ A collection of doctest examples that should be run in a single ! namespace. Each DocTest defines the following attributes: - examples: the list of examples. --- 398,402 ---- """ A collection of doctest examples that should be run in a single ! namespace. Each `DocTest` defines the following attributes: - examples: the list of examples. *************** *** 413,439 **** the object whose docstring this DocTest was extracted from). - - docstring: The docstring being tested - - filename: The name of the file that this DocTest was extracted ! from. - lineno: The line number within filename where this DocTest ! begins. This line number is zero-based, with respect to the ! beginning of the file. """ ! def __init__(self, docstring, globs, name, filename, lineno): """ ! Create a new DocTest, by extracting examples from `docstring`. ! The DocTest's globals are initialized with a copy of `globs`. """ ! # Store a copy of the globals self.globs = globs.copy() - # Store identifying information self.name = name self.filename = filename self.lineno = lineno - # Parse the docstring. - self.docstring = docstring - self.examples = Parser(name, docstring).get_examples() def __repr__(self): --- 408,435 ---- the object whose docstring this DocTest was extracted from). - filename: The name of the file that this DocTest was extracted ! from, or `None` if the filename is unknown. - lineno: The line number within filename where this DocTest ! begins, or `None` if the line number is unavailable. This ! line number is zero-based, with respect to the beginning of ! the file. ! ! - docstring: The string that the examples were extracted from, ! or `None` if the string is unavailable. """ ! def __init__(self, examples, globs, name, filename, lineno, docstring): """ ! Create a new DocTest containing the given examples. The ! DocTest's globals are initialized with a copy of `globs`. """ ! assert not isinstance(examples, basestring), \ ! "DocTest no longer accepts str; use DocTestParser instead" ! self.examples = examples ! self.docstring = docstring self.globs = globs.copy() self.name = name self.filename = filename self.lineno = lineno def __repr__(self): *************** *** 456,476 **** ###################################################################### ! ## 2. Example Parser ###################################################################### ! class Parser: """ ! Extract doctests from a string. """ - def __init__(self, name, string): - """ - Prepare to extract doctests from string `string`. - - `name` is an arbitrary (string) name associated with the string, - and is used only in error messages. - """ - self.name = name - self.string = string.expandtabs() - _EXAMPLE_RE = re.compile(r''' # Source consists of a PS1 line followed by zero or more PS2 lines. --- 452,462 ---- ###################################################################### ! ## 2. DocTestParser ###################################################################### ! class DocTestParser: """ ! A class used to parse strings containing doctest examples. """ _EXAMPLE_RE = re.compile(r''' # Source consists of a PS1 line followed by zero or more PS2 lines. *************** *** 487,497 **** _IS_BLANK_OR_COMMENT = re.compile('^[ ]*(#.*)?$').match ! def get_examples(self): """ ! Extract all doctest examples, from the string, and return them ! as a list of `Example` objects. Line numbers are 0-based, ! because it's most common in doctests that nothing interesting ! appears on the same line as opening triple-quote, and so the ! first interesting line is called \"line 1\" then. >>> text = ''' --- 473,498 ---- _IS_BLANK_OR_COMMENT = re.compile('^[ ]*(#.*)?$').match ! def get_doctest(self, string, globs, name, filename, lineno): """ ! Extract all doctest examples from the given string, and ! collect them into a `DocTest` object. ! ! `globs`, `name`, `filename`, and `lineno` are attributes for ! the new `DocTest` object. See the documentation for `DocTest` ! for more information. ! """ ! return DocTest(self.get_examples(string, name), globs, ! name, filename, lineno, string) ! ! def get_examples(self, string, name=''): ! """ ! Extract all doctest examples from the given string, and return ! them as a list of `Example` objects. Line numbers are ! 0-based, because it's most common in doctests that nothing ! interesting appears on the same line as opening triple-quote, ! and so the first interesting line is called \"line 1\" then. ! ! The optional argument `name` is a name identifying this ! string, and is only used for error messages. >>> text = ''' *************** *** 507,511 **** ... 5 ... ''' ! >>> for x in Parser('', text).get_examples(): ... print (x.source, x.want, x.lineno) ('x, y = 2, 3 # no output expected\\n', '', 1) --- 508,512 ---- ... 5 ... ''' ! >>> for x in DocTestParser().get_examples(text): ... print (x.source, x.want, x.lineno) ('x, y = 2, 3 # no output expected\\n', '', 1) *************** *** 516,525 **** charno, lineno = 0, 0 # Find all doctest examples in the string: ! for m in self._EXAMPLE_RE.finditer(self.string): # Update lineno (lines before this example) ! lineno += self.string.count('\n', charno, m.start()) # Extract source/want from the regexp match. ! (source, want) = self._parse_example(m, lineno) if self._IS_BLANK_OR_COMMENT(source): continue --- 517,526 ---- charno, lineno = 0, 0 # Find all doctest examples in the string: ! for m in self._EXAMPLE_RE.finditer(string.expandtabs()): # Update lineno (lines before this example) ! lineno += string.count('\n', charno, m.start()) # Extract source/want from the regexp match. ! (source, want) = self._parse_example(m, name, lineno) if self._IS_BLANK_OR_COMMENT(source): continue *************** *** 527,538 **** # Update lineno (lines inside this example) ! lineno += self.string.count('\n', m.start(), m.end()) # Update charno. charno = m.end() return examples ! def get_program(self): """ ! Return an executable program from the string, as a string. The format of this isn't rigidly defined. In general, doctest --- 528,539 ---- # Update lineno (lines inside this example) ! lineno += string.count('\n', m.start(), m.end()) # Update charno. charno = m.end() return examples ! def get_program(self, string, name=""): """ ! Return an executable program from the given string, as a string. The format of this isn't rigidly defined. In general, doctest *************** *** 542,545 **** --- 543,549 ---- a doctest test) is also placed in comments. + The optional argument `name` is a name identifying this + string, and is only used for error messages. + >>> text = ''' ... >>> x, y = 2, 3 # no output expected *************** *** 554,558 **** ... 5 ... ''' ! >>> print Parser('', text).get_program() x, y = 2, 3 # no output expected if 1: --- 558,562 ---- ... 5 ... ''' ! >>> print DocTestParser().get_program(text) x, y = 2, 3 # no output expected if 1: *************** *** 571,583 **** charnum, lineno = 0, 0 # Find all doctest examples in the string: ! for m in self._EXAMPLE_RE.finditer(self.string): # Add any text before this example, as a comment. if m.start() > charnum: ! lines = self.string[charnum:m.start()-1].split('\n') output.extend([self._comment_line(l) for l in lines]) lineno += len(lines) # Extract source/want from the regexp match. ! (source, want) = self._parse_example(m, lineno, False) # Display the source output.append(source) --- 575,587 ---- charnum, lineno = 0, 0 # Find all doctest examples in the string: ! for m in self._EXAMPLE_RE.finditer(string.expandtabs()): # Add any text before this example, as a comment. if m.start() > charnum: ! lines = string[charnum:m.start()-1].split('\n') output.extend([self._comment_line(l) for l in lines]) lineno += len(lines) # Extract source/want from the regexp match. ! (source, want) = self._parse_example(m, name, lineno, False) # Display the source output.append(source) *************** *** 588,596 **** # Update the line number & char number. ! lineno += self.string.count('\n', m.start(), m.end()) charnum = m.end() # Add any remaining text, as comments. output.extend([self._comment_line(l) ! for l in self.string[charnum:].split('\n')]) # Trim junk on both ends. while output and output[-1] == '#': --- 592,600 ---- # Update the line number & char number. ! lineno += string.count('\n', m.start(), m.end()) charnum = m.end() # Add any remaining text, as comments. output.extend([self._comment_line(l) ! for l in string[charnum:].split('\n')]) # Trim junk on both ends. while output and output[-1] == '#': *************** *** 601,605 **** return '\n'.join(output) ! def _parse_example(self, m, lineno, add_newlines=True): # Get the example's indentation level. indent = len(m.group('indent')) --- 605,609 ---- return '\n'.join(output) ! def _parse_example(self, m, name, lineno, add_newlines=True): # Get the example's indentation level. indent = len(m.group('indent')) *************** *** 608,613 **** # indented; and then strip their indentation & prompts. source_lines = m.group('source').split('\n') ! self._check_prompt_blank(source_lines, indent, lineno) ! self._check_prefix(source_lines[1:], ' '*indent+'.', lineno) source = '\n'.join([sl[indent+4:] for sl in source_lines]) if len(source_lines) > 1 and add_newlines: --- 612,617 ---- # indented; and then strip their indentation & prompts. source_lines = m.group('source').split('\n') ! self._check_prompt_blank(source_lines, indent, name, lineno) ! self._check_prefix(source_lines[1:], ' '*indent+'.', name, lineno) source = '\n'.join([sl[indent+4:] for sl in source_lines]) if len(source_lines) > 1 and add_newlines: *************** *** 617,621 **** # indented; and then strip the indentation. want_lines = m.group('want').rstrip().split('\n') ! self._check_prefix(want_lines, ' '*indent, lineno+len(source_lines)) want = '\n'.join([wl[indent:] for wl in want_lines]) --- 621,625 ---- # indented; and then strip the indentation. want_lines = m.group('want').rstrip().split('\n') ! self._check_prefix(want_lines, ' '*indent, name, lineno+len(source_lines)) want = '\n'.join([wl[indent:] for wl in want_lines]) *************** *** 632,649 **** return '#' ! def _check_prompt_blank(self, lines, indent, lineno): for i, line in enumerate(lines): if len(line) >= indent+4 and line[indent+3] != ' ': raise ValueError('line %r of the docstring for %s ' 'lacks blank after %s: %r' % ! (lineno+i+1, self.name, line[indent:indent+3], line)) ! def _check_prefix(self, lines, prefix, lineno): for i, line in enumerate(lines): if line and not line.startswith(prefix): raise ValueError('line %r of the docstring for %s has ' 'inconsistent leading whitespace: %r' % ! (lineno+i+1, self.name, line)) --- 636,653 ---- return '#' ! def _check_prompt_blank(self, lines, indent, name, lineno): for i, line in enumerate(lines): if len(line) >= indent+4 and line[indent+3] != ' ': raise ValueError('line %r of the docstring for %s ' 'lacks blank after %s: %r' % ! (lineno+i+1, name, line[indent:indent+3], line)) ! def _check_prefix(self, lines, prefix, name, lineno): for i, line in enumerate(lines): if line and not line.startswith(prefix): raise ValueError('line %r of the docstring for %s has ' 'inconsistent leading whitespace: %r' % ! (lineno+i+1, name, line)) *************** *** 661,670 **** """ ! def __init__(self, verbose=False, doctest_factory=DocTest, recurse=True, _namefilter=None): """ Create a new doctest finder. ! The optional argument `doctest_factory` specifies a class or function that should be used to create new DocTest objects (or objects that implement the same interface as DocTest). The --- 665,674 ---- """ ! def __init__(self, verbose=False, parser=DocTestParser(), recurse=True, _namefilter=None): """ Create a new doctest finder. ! The optional argument `parser` specifies a class or function that should be used to create new DocTest objects (or objects that implement the same interface as DocTest). The *************** *** 675,679 **** only examine the given object, and not any contained objects. """ ! self._doctest_factory = doctest_factory self._verbose = verbose self._recurse = recurse --- 679,683 ---- only examine the given object, and not any contained objects. """ ! self._parser = parser self._verbose = verbose self._recurse = recurse *************** *** 886,890 **** else: filename = getattr(module, '__file__', module.__name__) ! return self._doctest_factory(docstring, globs, name, filename, lineno) def _find_lineno(self, obj, source_lines): --- 890,895 ---- else: filename = getattr(module, '__file__', module.__name__) ! return self._parser.get_doctest(docstring, globs, name, ! filename, lineno) def _find_lineno(self, obj, source_lines): *************** *** 1255,1282 **** compileflags = _extract_future_flags(test.globs) - save_stdout = sys.stdout if out is None: ! out = save_stdout.write ! sys.stdout = self._fakeout ! # Patch pdb.set_trace to restore sys.stdout, so that interactive ! # debugging output is visible (not still redirected to self._fakeout). ! # Note that we run "the real" pdb.set_trace (captured at doctest ! # import time) in our replacement. Because the current run() may ! # run another doctest (and so on), the current pdb.set_trace may be ! # our set_trace function, which changes sys.stdout. If we called ! # a chain of those, we wouldn't be left with the save_stdout ! # *this* run() invocation wants. def set_trace(): ! sys.stdout = save_stdout real_pdb_set_trace() - save_set_trace = pdb.set_trace - pdb.set_trace = set_trace try: return self.__run(test, compileflags, out) finally: ! sys.stdout = save_stdout ! pdb.set_trace = save_set_trace if clear_globs: test.globs.clear() --- 1260,1284 ---- compileflags = _extract_future_flags(test.globs) if out is None: ! out = sys.stdout.write ! saveout = sys.stdout ! # Note that don't save away the previous pdb.set_trace. Rather, ! # we safe pdb.set_trace on import (see import section above). ! # We then call and restore that original cersion. We do it this ! # way to make this feature testable. If we kept and called the ! # previous version, we'd end up restoring the original stdout, ! # which is not what we want. def set_trace(): ! sys.stdout = saveout real_pdb_set_trace() try: + sys.stdout = self._fakeout + pdb.set_trace = set_trace return self.__run(test, compileflags, out) finally: ! sys.stdout = saveout ! pdb.set_trace = real_pdb_set_trace if clear_globs: test.globs.clear() *************** *** 1493,1497 **** >>> runner = DebugRunner(verbose=False) ! >>> test = DocTest('>>> raise KeyError\n42', {}, 'foo', 'foo.py', 0) >>> try: ... runner.run(test) --- 1495,1500 ---- >>> runner = DebugRunner(verbose=False) ! >>> test = DocTestParser().get_doctest('>>> raise KeyError\n42', ! ... {}, 'foo', 'foo.py', 0) >>> try: ... runner.run(test) *************** *** 1516,1520 **** If the output doesn't match, then a DocTestFailure is raised: ! >>> test = DocTest(''' ... >>> x = 1 ... >>> x --- 1519,1523 ---- If the output doesn't match, then a DocTestFailure is raised: ! >>> test = DocTestParser().get_doctest(''' ... >>> x = 1 ... >>> x *************** *** 1548,1552 **** {'x': 1} ! >>> test = DocTest(''' ... >>> x = 2 ... >>> raise KeyError --- 1551,1555 ---- {'x': 1} ! >>> test = DocTestParser().get_doctest(''' ... >>> x = 2 ... >>> raise KeyError *************** *** 1564,1568 **** But the globals are cleared if there is no error: ! >>> test = DocTest(''' ... >>> x = 2 ... ''', {}, 'foo', 'foo.py', 0) --- 1567,1571 ---- But the globals are cleared if there is no error: ! >>> test = DocTestParser().get_doctest(''' ... >>> x = 2 ... ''', {}, 'foo', 'foo.py', 0) *************** *** 1780,1784 **** def runstring(self, s, name): ! test = DocTest(s, self.globs, name, None, None) if self.verbose: print "Running string", name --- 1783,1787 ---- def runstring(self, s, name): ! test = DocTestParser().get_doctest(s, self.globs, name, None, None) if self.verbose: print "Running string", name *************** *** 1888,1892 **** exception: ! >>> test = DocTest('>>> raise KeyError\n42', ... {}, 'foo', 'foo.py', 0) >>> case = DocTestCase(test) --- 1891,1895 ---- exception: ! >>> test = DocTestParser().get_doctest('>>> raise KeyError\n42', ... {}, 'foo', 'foo.py', 0) >>> case = DocTestCase(test) *************** *** 1913,1917 **** If the output doesn't match, then a DocTestFailure is raised: ! >>> test = DocTest(''' ... >>> x = 1 ... >>> x --- 1916,1920 ---- If the output doesn't match, then a DocTestFailure is raised: ! >>> test = DocTestParser().get_doctest(''' ... >>> x = 1 ... >>> x *************** *** 2033,2037 **** globs = {} ! test = DocTest(doc, globs, name, path, 0) return DocFileCase(test, optionflags, setUp, tearDown) --- 2036,2040 ---- globs = {} ! test = DocTestParser().get_doctest(doc, globs, name, path, 0) return DocFileCase(test, optionflags, setUp, tearDown) *************** *** 2139,2143 **** """ ! return Parser('', s).get_program() def _want_comment(example): --- 2142,2146 ---- """ ! return DocTestParser().get_program(s) def _want_comment(example): From edloper at users.sourceforge.net Mon Aug 9 18:14:57 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Mon Aug 9 18:15:00 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30812/test Modified Files: test_doctest.py Log Message: - DocTest is now a simple container class; its constructor is no longer responsible for parsing the string. - Renamed Parser to DocTestParser - DocTestParser.get_*() now accept the string & name as command-line arguments; the parser's constructor is now empty. - Added DocTestParser.get_doctest() method - Replaced "doctest_factory" argument to DocTestFinder with a "parser" argument (takes a DocTestParser). - Changed _tag_msg to take an indentation string argument. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_doctest.py 9 Aug 2004 15:43:47 -0000 1.15 --- test_doctest.py 9 Aug 2004 16:14:41 -0000 1.16 *************** *** 184,188 **** ... ''' >>> globs = {} # globals to run the test in. ! >>> test = doctest.DocTest(docstring, globs, 'some_test', 'some_file', 20) >>> print test --- 184,190 ---- ... ''' >>> globs = {} # globals to run the test in. ! >>> parser = doctest.DocTestParser() ! >>> test = parser.get_doctest(docstring, globs, 'some_test', ! ... 'some_file', 20) >>> print test *************** *** 218,222 **** ... indentation ... ''' ! >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 4 of the docstring for some_test has inconsistent leading whitespace: ' indentation' --- 220,224 ---- ... indentation ... ''' ! >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 4 of the docstring for some_test has inconsistent leading whitespace: ' indentation' *************** *** 230,234 **** ... ('bad', 'indentation') ... ''' ! >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: ' ... 2)' --- 232,236 ---- ... ('bad', 'indentation') ... ''' ! >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: ' ... 2)' *************** *** 238,242 **** >>> docstring = '>>>print 1\n1' ! >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 1 of the docstring for some_test lacks blank after >>>: '>>>print 1' --- 240,244 ---- >>> docstring = '>>>print 1\n1' ! >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 1 of the docstring for some_test lacks blank after >>>: '>>>print 1' *************** *** 246,250 **** >>> docstring = '>>> if 1:\n...print 1\n1' ! >>> doctest.DocTest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print 1' --- 248,252 ---- >>> docstring = '>>> if 1:\n...print 1\n1' ! >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print 1' *************** *** 999,1003 **** ... >>> import pdb; pdb.set_trace() ... ''' ! >>> test = doctest.DocTest(doc, {}, "foo", "foo.py", 0) >>> runner = doctest.DocTestRunner(verbose=False) --- 1001,1006 ---- ... >>> import pdb; pdb.set_trace() ... ''' ! >>> parser = doctest.DocTestParser() ! >>> test = parser.get_doctest(doc, {}, "foo", "foo.py", 0) >>> runner = doctest.DocTestRunner(verbose=False) *************** *** 1041,1045 **** ... >>> calls_set_trace() ... ''' ! >>> test = doctest.DocTest(doc, globals(), "foo", "foo.py", 0) >>> fake_stdin = tempfile.TemporaryFile(mode='w+') --- 1044,1048 ---- ... >>> calls_set_trace() ... ''' ! >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) >>> fake_stdin = tempfile.TemporaryFile(mode='w+') From tim_one at users.sourceforge.net Mon Aug 9 18:43:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 9 18:43:41 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3910/Lib/test Modified Files: test_doctest.py Log Message: Edward's latest checkins somehow managed to wipe out my previous latest checkins. Reapplying the latter changes. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** test_doctest.py 9 Aug 2004 16:14:41 -0000 1.16 --- test_doctest.py 9 Aug 2004 16:43:36 -0000 1.17 *************** *** 1045,1049 **** ... ''' >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) - >>> fake_stdin = tempfile.TemporaryFile(mode='w+') >>> fake_stdin.write('\n'.join([ --- 1045,1048 ---- From tim_one at users.sourceforge.net Mon Aug 9 18:43:38 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 9 18:43:42 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.56,1.57 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3910/Lib Modified Files: doctest.py Log Message: Edward's latest checkins somehow managed to wipe out my previous latest checkins. Reapplying the latter changes. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** doctest.py 9 Aug 2004 16:14:41 -0000 1.56 --- doctest.py 9 Aug 2004 16:43:36 -0000 1.57 *************** *** 1260,1284 **** compileflags = _extract_future_flags(test.globs) if out is None: ! out = sys.stdout.write ! saveout = sys.stdout ! # Note that don't save away the previous pdb.set_trace. Rather, ! # we safe pdb.set_trace on import (see import section above). ! # We then call and restore that original cersion. We do it this ! # way to make this feature testable. If we kept and called the ! # previous version, we'd end up restoring the original stdout, ! # which is not what we want. def set_trace(): ! sys.stdout = saveout real_pdb_set_trace() try: - sys.stdout = self._fakeout - pdb.set_trace = set_trace return self.__run(test, compileflags, out) finally: ! sys.stdout = saveout ! pdb.set_trace = real_pdb_set_trace if clear_globs: test.globs.clear() --- 1260,1287 ---- compileflags = _extract_future_flags(test.globs) + save_stdout = sys.stdout if out is None: ! out = save_stdout.write ! sys.stdout = self._fakeout ! # Patch pdb.set_trace to restore sys.stdout, so that interactive ! # debugging output is visible (not still redirected to self._fakeout). ! # Note that we run "the real" pdb.set_trace (captured at doctest ! # import time) in our replacement. Because the current run() may ! # run another doctest (and so on), the current pdb.set_trace may be ! # our set_trace function, which changes sys.stdout. If we called ! # a chain of those, we wouldn't be left with the save_stdout ! # *this* run() invocation wants. def set_trace(): ! sys.stdout = save_stdout real_pdb_set_trace() + save_set_trace = pdb.set_trace + pdb.set_trace = set_trace try: return self.__run(test, compileflags, out) finally: ! sys.stdout = save_stdout ! pdb.set_trace = save_set_trace if clear_globs: test.globs.clear() From akuchling at users.sourceforge.net Mon Aug 9 19:28:03 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Aug 9 19:28:07 2004 Subject: [Python-checkins] python/dist/src/Tools/scripts byteyears.py, 1.10, 1.11 checkpyc.py, 1.10, 1.11 classfix.py, 1.13, 1.14 copytime.py, 1.5, 1.6 crlf.py, 1.4, 1.5 cvsfiles.py, 1.5, 1.6 diff.py, 1.2, 1.3 dutree.py, 1.13, 1.14 findlinksto.py, 1.9, 1.10 fixcid.py, 1.11, 1.12 fixheader.py, 1.6, 1.7 fixps.py, 1.7, 1.8 google.py, 1.2, 1.3 gprof2html.py, 1.1, 1.2 h2py.py, 1.18, 1.19 idle, 1.1, 1.2 ifdef.py, 1.6, 1.7 lfcr.py, 1.4, 1.5 linktree.py, 1.6, 1.7 lll.py, 1.5, 1.6 logmerge.py, 1.12, 1.13 methfix.py, 1.8, 1.9 mkreal.py, 1.7, 1.8 objgraph.py, 1.7, 1.8 pathfix.py, 1.6, 1.7 pdeps.py, 1.6, 1.7 ptags.py, 1.8, 1.9 pydoc, 1.2, 1.3 pydocgui.pyw, 1.1, 1.2 setup.py, 1.3, 1.4 suff.py, 1.7, 1.8 treesync.py, 1.6, 1.7 which.py, 1.13, 1.14 xxci.py, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12113 Modified Files: byteyears.py checkpyc.py classfix.py copytime.py crlf.py cvsfiles.py diff.py dutree.py findlinksto.py fixcid.py fixheader.py fixps.py google.py gprof2html.py h2py.py idle ifdef.py lfcr.py linktree.py lll.py logmerge.py methfix.py mkreal.py objgraph.py pathfix.py pdeps.py ptags.py pydoc pydocgui.pyw setup.py suff.py treesync.py which.py xxci.py Log Message: [Patch #1005491 ] use __name__ == '__main__' in scripts Index: byteyears.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/byteyears.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** byteyears.py 12 Feb 2004 17:35:31 -0000 1.10 --- byteyears.py 9 Aug 2004 17:27:55 -0000 1.11 *************** *** 10,56 **** from stat import * ! # Use lstat() to stat files if it exists, else stat() ! try: ! statfunc = os.lstat ! except AttributeError: ! statfunc = os.stat ! # Parse options ! if sys.argv[1] == '-m': ! itime = ST_MTIME ! del sys.argv[1] ! elif sys.argv[1] == '-c': ! itime = ST_CTIME ! del sys.argv[1] ! elif sys.argv[1] == '-a': ! itime = ST_CTIME ! del sys.argv[1] ! else: ! itime = ST_MTIME ! secs_per_year = 365.0 * 24.0 * 3600.0 # Scale factor ! now = time.time() # Current time, for age computations ! status = 0 # Exit status, set to 1 on errors ! # Compute max file name length ! maxlen = 1 ! for filename in sys.argv[1:]: ! maxlen = max(maxlen, len(filename)) ! # Process each argument in turn ! for filename in sys.argv[1:]: ! try: ! st = statfunc(filename) ! except os.error, msg: ! sys.stderr.write("can't stat %r: %r\n" % (filename, msg)) ! status = 1 ! st = () ! if st: ! anytime = st[itime] ! size = st[ST_SIZE] ! age = now - anytime ! byteyears = float(size) * float(age) / secs_per_year ! print filename.ljust(maxlen), ! print repr(int(byteyears)).rjust(8) ! sys.exit(status) --- 10,61 ---- from stat import * ! def main(): ! # Use lstat() to stat files if it exists, else stat() ! try: ! statfunc = os.lstat ! except AttributeError: ! statfunc = os.stat ! # Parse options ! if sys.argv[1] == '-m': ! itime = ST_MTIME ! del sys.argv[1] ! elif sys.argv[1] == '-c': ! itime = ST_CTIME ! del sys.argv[1] ! elif sys.argv[1] == '-a': ! itime = ST_CTIME ! del sys.argv[1] ! else: ! itime = ST_MTIME ! secs_per_year = 365.0 * 24.0 * 3600.0 # Scale factor ! now = time.time() # Current time, for age computations ! status = 0 # Exit status, set to 1 on errors ! # Compute max file name length ! maxlen = 1 ! for filename in sys.argv[1:]: ! maxlen = max(maxlen, len(filename)) ! # Process each argument in turn ! for filename in sys.argv[1:]: ! try: ! st = statfunc(filename) ! except os.error, msg: ! sys.stderr.write("can't stat %r: %r\n" % (filename, msg)) ! status = 1 ! st = () ! if st: ! anytime = st[itime] ! size = st[ST_SIZE] ! age = now - anytime ! byteyears = float(size) * float(age) / secs_per_year ! print filename.ljust(maxlen), ! print repr(int(byteyears)).rjust(8) ! ! sys.exit(status) ! ! if __name__ == '__main__': ! main() Index: checkpyc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/checkpyc.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** checkpyc.py 12 Feb 2004 17:35:31 -0000 1.10 --- checkpyc.py 9 Aug 2004 17:27:55 -0000 1.11 *************** *** 63,65 **** return ord(s[0]) + (ord(s[1])<<8) + (ord(s[2])<<16) + (ord(s[3])<<24) ! main() --- 63,66 ---- return ord(s[0]) + (ord(s[1])<<8) + (ord(s[2])<<16) + (ord(s[3])<<24) ! if __name__ == '__main__': ! main() Index: classfix.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/classfix.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** classfix.py 12 Feb 2004 17:35:31 -0000 1.13 --- classfix.py 9 Aug 2004 17:27:55 -0000 1.14 *************** *** 187,189 **** return head + '(' + basepart + '):' + tail ! main() --- 187,190 ---- return head + '(' + basepart + '):' + tail ! if __name__ == '__main__': ! main() Index: copytime.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/copytime.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** copytime.py 17 Jan 2001 08:48:39 -0000 1.5 --- copytime.py 9 Aug 2004 17:27:55 -0000 1.6 *************** *** 23,25 **** sys.exit(2) ! main() --- 23,26 ---- sys.exit(2) ! if __name__ == '__main__': ! main() Index: crlf.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/crlf.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** crlf.py 13 May 2003 14:51:39 -0000 1.4 --- crlf.py 9 Aug 2004 17:27:55 -0000 1.5 *************** *** 1,19 **** #! /usr/bin/env python - "Replace CRLF with LF in argument files. Print names of changed files." import sys, os ! for filename in sys.argv[1:]: ! if os.path.isdir(filename): ! print filename, "Directory!" ! continue ! data = open(filename, "rb").read() ! if '\0' in data: ! print filename, "Binary!" ! continue ! newdata = data.replace("\r\n", "\n") ! if newdata != data: ! print filename ! f = open(filename, "wb") ! f.write(newdata) ! f.close() --- 1,24 ---- #! /usr/bin/env python "Replace CRLF with LF in argument files. Print names of changed files." import sys, os ! ! def main(): ! for filename in sys.argv[1:]: ! if os.path.isdir(filename): ! print filename, "Directory!" ! continue ! data = open(filename, "rb").read() ! if '\0' in data: ! print filename, "Binary!" ! continue ! newdata = data.replace("\r\n", "\n") ! if newdata != data: ! print filename ! f = open(filename, "wb") ! f.write(newdata) ! f.close() ! ! if __name__ == '__main__': ! main() ! Index: cvsfiles.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/cvsfiles.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** cvsfiles.py 11 Sep 2002 20:36:01 -0000 1.5 --- cvsfiles.py 9 Aug 2004 17:27:55 -0000 1.6 *************** *** 69,71 **** return st[stat.ST_MTIME] ! sys.exit(main()) --- 69,72 ---- return st[stat.ST_MTIME] ! if __name__ == '__main__': ! main() Index: diff.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/diff.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** diff.py 8 Jul 2004 04:22:20 -0000 1.2 --- diff.py 9 Aug 2004 17:27:55 -0000 1.3 *************** *** 9,40 **** import sys, os, time, difflib, optparse ! usage = "usage: %prog [options] fromfile tofile" ! parser = optparse.OptionParser(usage) ! parser.add_option("-c", action="store_true", default=False, help='Produce a context format diff (default)') ! parser.add_option("-u", action="store_true", default=False, help='Produce a unified format diff') ! parser.add_option("-n", action="store_true", default=False, help='Produce a ndiff format diff') ! parser.add_option("-l", "--lines", type="int", default=3, help='Set number of context lines (default 3)') ! (options, args) = parser.parse_args() ! if len(args) == 0: ! parser.print_help() ! sys.exit(1) ! if len(args) != 2: ! parser.error("need to specify both a fromfile and tofile") ! n = options.lines ! fromfile, tofile = args ! fromdate = time.ctime(os.stat(fromfile).st_mtime) ! todate = time.ctime(os.stat(tofile).st_mtime) ! fromlines = open(fromfile).readlines() ! tolines = open(tofile).readlines() ! if options.u: ! diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n) ! elif options.n: ! diff = difflib.ndiff(fromlines, tolines) ! else: ! diff = difflib.context_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n) ! sys.stdout.writelines(diff) --- 9,45 ---- import sys, os, time, difflib, optparse ! def main(): ! usage = "usage: %prog [options] fromfile tofile" ! parser = optparse.OptionParser(usage) ! parser.add_option("-c", action="store_true", default=False, help='Produce a context format diff (default)') ! parser.add_option("-u", action="store_true", default=False, help='Produce a unified format diff') ! parser.add_option("-n", action="store_true", default=False, help='Produce a ndiff format diff') ! parser.add_option("-l", "--lines", type="int", default=3, help='Set number of context lines (default 3)') ! (options, args) = parser.parse_args() ! if len(args) == 0: ! parser.print_help() ! sys.exit(1) ! if len(args) != 2: ! parser.error("need to specify both a fromfile and tofile") ! n = options.lines ! fromfile, tofile = args ! fromdate = time.ctime(os.stat(fromfile).st_mtime) ! todate = time.ctime(os.stat(tofile).st_mtime) ! fromlines = open(fromfile).readlines() ! tolines = open(tofile).readlines() ! if options.u: ! diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n) ! elif options.n: ! diff = difflib.ndiff(fromlines, tolines) ! else: ! diff = difflib.context_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n) ! ! sys.stdout.writelines(diff) ! ! if __name__ == '__main__': ! main() Index: dutree.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/dutree.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** dutree.py 12 Feb 2004 17:35:31 -0000 1.13 --- dutree.py 9 Aug 2004 17:27:55 -0000 1.14 *************** *** 57,59 **** show(tsub, d[key][1], psub) ! main() --- 57,60 ---- show(tsub, d[key][1], psub) ! if __name__ == '__main__': ! main() Index: findlinksto.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/findlinksto.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** findlinksto.py 6 Feb 2003 19:55:35 -0000 1.9 --- findlinksto.py 9 Aug 2004 17:27:55 -0000 1.10 *************** *** 40,42 **** pass ! main() --- 40,43 ---- pass ! if __name__ == '__main__': ! main() Index: fixcid.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/fixcid.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** fixcid.py 12 Feb 2004 17:35:31 -0000 1.11 --- fixcid.py 9 Aug 2004 17:27:55 -0000 1.12 *************** *** 311,313 **** fp.close() ! main() --- 311,314 ---- fp.close() ! if __name__ == '__main__': ! main() Index: fixheader.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/fixheader.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** fixheader.py 13 May 2003 18:14:24 -0000 1.6 --- fixheader.py 9 Aug 2004 17:27:55 -0000 1.7 *************** *** 46,48 **** print '#endif /*', '!'+magic, '*/' ! main() --- 46,49 ---- print '#endif /*', '!'+magic, '*/' ! if __name__ == '__main__': ! main() Index: fixps.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/fixps.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** fixps.py 12 Feb 2004 17:35:31 -0000 1.7 --- fixps.py 9 Aug 2004 17:27:55 -0000 1.8 *************** *** 30,33 **** f.close() ! ! main() --- 30,33 ---- f.close() ! if __name__ == '__main__': ! main() Index: google.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/google.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** google.py 8 Feb 2002 16:20:07 -0000 1.2 --- google.py 9 Aug 2004 17:27:55 -0000 1.3 *************** *** 20,22 **** webbrowser.open(url) ! main() --- 20,23 ---- webbrowser.open(url) ! if __name__ == '__main__': ! main() Index: gprof2html.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/gprof2html.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gprof2html.py 9 Aug 2002 20:07:34 -0000 1.1 --- gprof2html.py 9 Aug 2004 17:27:55 -0000 1.2 *************** *** 76,78 **** webbrowser.open("file:" + os.path.abspath(outputfilename)) ! main() --- 76,79 ---- webbrowser.open("file:" + os.path.abspath(outputfilename)) ! if __name__ == '__main__': ! main() Index: h2py.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/h2py.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** h2py.py 23 Nov 2002 12:08:10 -0000 1.18 --- h2py.py 9 Aug 2004 17:27:55 -0000 1.19 *************** *** 172,174 **** filename) ! main() --- 172,175 ---- filename) ! if __name__ == '__main__': ! main() Index: idle =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/idle,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** idle 13 Jun 2003 20:34:27 -0000 1.1 --- idle 9 Aug 2004 17:27:55 -0000 1.2 *************** *** 2,4 **** from idlelib.PyShell import main ! main() --- 2,5 ---- from idlelib.PyShell import main ! if __name__ == '__main__': ! main() Index: ifdef.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/ifdef.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ifdef.py 13 May 2003 18:14:24 -0000 1.6 --- ifdef.py 9 Aug 2004 17:27:55 -0000 1.7 *************** *** 110,112 **** sys.stderr.write('stack: %s\n' % stack) ! main() --- 110,113 ---- sys.stderr.write('stack: %s\n' % stack) ! if __name__ == '__main__': ! main() Index: lfcr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/lfcr.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** lfcr.py 13 May 2003 17:09:01 -0000 1.4 --- lfcr.py 9 Aug 2004 17:27:55 -0000 1.5 *************** *** 4,19 **** import sys, re, os ! for filename in sys.argv[1:]: ! if os.path.isdir(filename): ! print filename, "Directory!" ! continue ! data = open(filename, "rb").read() ! if '\0' in data: ! print filename, "Binary!" ! continue ! newdata = re.sub("\r?\n", "\r\n", data) ! if newdata != data: ! print filename ! f = open(filename, "wb") ! f.write(newdata) ! f.close() --- 4,24 ---- import sys, re, os ! ! def main(): ! for filename in sys.argv[1:]: ! if os.path.isdir(filename): ! print filename, "Directory!" ! continue ! data = open(filename, "rb").read() ! if '\0' in data: ! print filename, "Binary!" ! continue ! newdata = re.sub("\r?\n", "\r\n", data) ! if newdata != data: ! print filename ! f = open(filename, "wb") ! f.write(newdata) ! f.close() ! ! if __name__ == '__main__': ! main() Index: linktree.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/linktree.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** linktree.py 17 Jan 2001 08:48:39 -0000 1.6 --- linktree.py 9 Aug 2004 17:27:55 -0000 1.7 *************** *** 77,79 **** os.symlink(linkname, newname) ! sys.exit(main()) --- 77,80 ---- os.symlink(linkname, newname) ! if __name__ == '__main__': ! sys.exit(main()) Index: lll.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/lll.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** lll.py 17 Jan 2001 08:48:39 -0000 1.5 --- lll.py 9 Aug 2004 17:27:55 -0000 1.6 *************** *** 14,25 **** if os.path.islink(full): print name, '->', os.readlink(full) ! ! args = sys.argv[1:] ! if not args: args = [os.curdir] ! first = 1 ! for arg in args: ! if len(args) > 1: ! if not first: print ! first = 0 ! print arg + ':' lll(arg) --- 14,29 ---- if os.path.islink(full): print name, '->', os.readlink(full) ! def main(): ! args = sys.argv[1:] ! if not args: args = [os.curdir] ! first = 1 ! for arg in args: ! if len(args) > 1: ! if not first: print ! first = 0 ! print arg + ':' lll(arg) + + if __name__ == '__main__': + main() + Index: logmerge.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/logmerge.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** logmerge.py 14 Aug 2003 15:52:33 -0000 1.12 --- logmerge.py 9 Aug 2004 17:27:55 -0000 1.13 *************** *** 178,184 **** prevtext = text ! try: ! main() ! except IOError, e: ! if e.errno != errno.EPIPE: ! raise --- 178,185 ---- prevtext = text ! if __name__ == '__main__': ! try: ! main() ! except IOError, e: ! if e.errno != errno.EPIPE: ! raise Index: methfix.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/methfix.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** methfix.py 12 Feb 2004 17:35:31 -0000 1.8 --- methfix.py 9 Aug 2004 17:27:55 -0000 1.9 *************** *** 168,171 **** return line ! ! main() --- 168,171 ---- return line ! if __name__ == '__main__': ! main() Index: mkreal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/mkreal.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** mkreal.py 13 May 2003 18:14:25 -0000 1.7 --- mkreal.py 9 Aug 2004 17:27:55 -0000 1.8 *************** *** 63,65 **** sys.exit(status) ! main() --- 63,66 ---- sys.exit(status) ! if __name__ == '__main__': ! main() Index: objgraph.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/objgraph.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** objgraph.py 13 May 2003 18:14:25 -0000 1.7 --- objgraph.py 9 Aug 2004 17:27:55 -0000 1.8 *************** *** 209,214 **** # Catch interrupts to avoid stack trace. # ! try: ! sys.exit(main()) ! except KeyboardInterrupt: ! sys.exit(1) --- 209,215 ---- # Catch interrupts to avoid stack trace. # ! if __name__ == '__main__': ! try: ! sys.exit(main()) ! except KeyboardInterrupt: ! sys.exit(1) Index: pathfix.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/pathfix.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pathfix.py 12 Feb 2004 17:35:31 -0000 1.6 --- pathfix.py 9 Aug 2004 17:27:55 -0000 1.7 *************** *** 146,148 **** return '#! %s\n' % new_interpreter ! main() --- 146,150 ---- return '#! %s\n' % new_interpreter ! if __name__ == '__main__': ! main() ! Index: pdeps.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/pdeps.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pdeps.py 11 Sep 2002 20:36:01 -0000 1.6 --- pdeps.py 9 Aug 2004 17:27:55 -0000 1.7 *************** *** 161,166 **** # Call main and honor exit status ! try: ! sys.exit(main()) ! except KeyboardInterrupt: ! sys.exit(1) --- 161,167 ---- # Call main and honor exit status ! if __name__ == '__main__': ! try: ! sys.exit(main()) ! except KeyboardInterrupt: ! sys.exit(1) Index: ptags.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/ptags.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ptags.py 13 May 2003 18:14:25 -0000 1.8 --- ptags.py 9 Aug 2004 17:27:55 -0000 1.9 *************** *** 50,52 **** tags.append(s) ! main() --- 50,53 ---- tags.append(s) ! if __name__ == '__main__': ! main() Index: pydoc =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/pydoc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pydoc 1 Mar 2001 00:25:40 -0000 1.2 --- pydoc 9 Aug 2004 17:27:55 -0000 1.3 *************** *** 2,4 **** import pydoc ! pydoc.cli() --- 2,5 ---- import pydoc ! if __name__ == '__main__': ! pydoc.cli() Index: pydocgui.pyw =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/pydocgui.pyw,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pydocgui.pyw 5 Aug 2001 05:43:20 -0000 1.1 --- pydocgui.pyw 9 Aug 2004 17:27:55 -0000 1.2 *************** *** 3,5 **** # between 2.2a1 and 2.2a2). import pydoc ! pydoc.gui() --- 3,7 ---- # between 2.2a1 and 2.2a2). import pydoc ! ! if __name__ == '__main__': ! pydoc.gui() Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/setup.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** setup.py 8 Apr 2003 19:50:02 -0000 1.3 --- setup.py 9 Aug 2004 17:27:55 -0000 1.4 *************** *** 1,18 **** from distutils.core import setup ! setup( ! scripts=[ ! 'byteyears.py', ! 'checkpyc.py', ! 'copytime.py', ! 'crlf.py', ! 'dutree.py', ! 'ftpmirror.py', ! 'h2py.py', ! 'lfcr.py', ! 'logmerge.py', ! '../../Lib/tabnanny.py', ! '../../Lib/timeit.py', ! 'untabify.py', ! ], ! ) --- 1,19 ---- from distutils.core import setup ! if __name__ == '__main__': ! setup( ! scripts=[ ! 'byteyears.py', ! 'checkpyc.py', ! 'copytime.py', ! 'crlf.py', ! 'dutree.py', ! 'ftpmirror.py', ! 'h2py.py', ! 'lfcr.py', ! 'logmerge.py', ! '../../Lib/tabnanny.py', ! '../../Lib/timeit.py', ! 'untabify.py', ! ], ! ) Index: suff.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/suff.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** suff.py 12 Feb 2004 17:35:31 -0000 1.7 --- suff.py 9 Aug 2004 17:27:55 -0000 1.8 *************** *** 27,29 **** return suff ! main() --- 27,30 ---- return suff ! if __name__ == '__main__': ! main() Index: treesync.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/treesync.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** treesync.py 11 Sep 2002 20:36:01 -0000 1.6 --- treesync.py 9 Aug 2004 17:27:55 -0000 1.7 *************** *** 202,204 **** return okay(prompt) ! main() --- 202,205 ---- return okay(prompt) ! if __name__ == '__main__': ! main() Index: which.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/which.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** which.py 12 Feb 2004 17:35:32 -0000 1.13 --- which.py 9 Aug 2004 17:27:55 -0000 1.14 *************** *** 14,56 **** sys.stderr.write(str + '\n') ! pathlist = os.environ['PATH'].split(os.pathsep) ! sts = 0 ! longlist = '' ! if sys.argv[1:] and sys.argv[1][:2] == '-l': ! longlist = sys.argv[1] ! del sys.argv[1] ! for prog in sys.argv[1:]: ! ident = () ! for dir in pathlist: ! filename = os.path.join(dir, prog) ! try: ! st = os.stat(filename) ! except os.error: ! continue ! if not S_ISREG(st[ST_MODE]): ! msg(filename + ': not a disk file') ! else: ! mode = S_IMODE(st[ST_MODE]) ! if mode & 0111: ! if not ident: ! print filename ! ident = st[:3] ! else: ! if st[:3] == ident: ! s = 'same as: ' ! else: ! s = 'also: ' ! msg(s + filename) else: ! msg(filename + ': not executable') ! if longlist: ! sts = os.system('ls ' + longlist + ' ' + filename) ! if sts: msg('"ls -l" exit status: ' + repr(sts)) ! if not ident: ! msg(prog + ': not found') ! sts = 1 - sys.exit(sts) --- 14,61 ---- sys.stderr.write(str + '\n') ! def main(): ! pathlist = os.environ['PATH'].split(os.pathsep) ! sts = 0 ! longlist = '' ! if sys.argv[1:] and sys.argv[1][:2] == '-l': ! longlist = sys.argv[1] ! del sys.argv[1] ! for prog in sys.argv[1:]: ! ident = () ! for dir in pathlist: ! filename = os.path.join(dir, prog) ! try: ! st = os.stat(filename) ! except os.error: ! continue ! if not S_ISREG(st[ST_MODE]): ! msg(filename + ': not a disk file') else: ! mode = S_IMODE(st[ST_MODE]) ! if mode & 0111: ! if not ident: ! print filename ! ident = st[:3] ! else: ! if st[:3] == ident: ! s = 'same as: ' ! else: ! s = 'also: ' ! msg(s + filename) ! else: ! msg(filename + ': not executable') ! if longlist: ! sts = os.system('ls ' + longlist + ' ' + filename) ! if sts: msg('"ls -l" exit status: ' + repr(sts)) ! if not ident: ! msg(prog + ': not found') ! sts = 1 ! ! sys.exit(sts) ! ! if __name__ == '__main__': ! main() Index: xxci.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/xxci.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** xxci.py 11 Sep 2002 20:36:01 -0000 1.15 --- xxci.py 9 Aug 2004 17:27:55 -0000 1.16 *************** *** 110,116 **** return s in ['y', 'yes'] ! try: ! setup() ! go(getargs()) ! except KeyboardInterrupt: ! print '[Intr]' --- 110,117 ---- return s in ['y', 'yes'] ! if __name__ == '__main__': ! try: ! setup() ! go(getargs()) ! except KeyboardInterrupt: ! print '[Intr]' From akuchling at users.sourceforge.net Mon Aug 9 19:36:59 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Aug 9 19:37:02 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.171,1.172 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14044 Modified Files: libfuncs.tex Log Message: [Patch #1005465] Markup tweaks Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.171 retrieving revision 1.172 diff -C2 -d -r1.171 -r1.172 *** libfuncs.tex 8 Aug 2004 07:17:38 -0000 1.171 --- libfuncs.tex 9 Aug 2004 17:36:56 -0000 1.172 *************** *** 127,131 **** If you want those, see \function{staticmethod()} in this section. \versionadded{2.2} ! Function decorator syntax added in version 2.4. \end{funcdesc} --- 127,131 ---- If you want those, see \function{staticmethod()} in this section. \versionadded{2.2} ! \versionchanged[Function decorator syntax added]{2.4} \end{funcdesc} *************** *** 959,962 **** --- 959,963 ---- section. \versionadded{2.2} + \versionchanged[Function decorator syntax added]{2.4} \end{funcdesc} From tim_one at users.sourceforge.net Mon Aug 9 20:54:13 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 9 20:54:17 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py, 1.73, 1.74 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31924/Lib/test Modified Files: test_socket.py Log Message: Whitespace normalization. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** test_socket.py 9 Aug 2004 04:51:40 -0000 1.73 --- test_socket.py 9 Aug 2004 18:54:11 -0000 1.74 *************** *** 209,213 **** ThreadableTest.clientTearDown(self) ! ####################################################################### ## Begin Tests --- 209,213 ---- ThreadableTest.clientTearDown(self) ! ####################################################################### ## Begin Tests From tim_one at users.sourceforge.net Mon Aug 9 20:54:13 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 9 20:54:19 2004 Subject: [Python-checkins] python/dist/src/Tools/scripts crlf.py, 1.5, 1.6 lll.py, 1.6, 1.7 pathfix.py, 1.7, 1.8 which.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31924/Tools/scripts Modified Files: crlf.py lll.py pathfix.py which.py Log Message: Whitespace normalization. Index: crlf.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/crlf.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** crlf.py 9 Aug 2004 17:27:55 -0000 1.5 --- crlf.py 9 Aug 2004 18:54:11 -0000 1.6 *************** *** 22,24 **** if __name__ == '__main__': main() - --- 22,23 ---- Index: lll.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/lll.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** lll.py 9 Aug 2004 17:27:55 -0000 1.6 --- lll.py 9 Aug 2004 18:54:11 -0000 1.7 *************** *** 27,29 **** if __name__ == '__main__': main() - --- 27,28 ---- Index: pathfix.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/pathfix.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pathfix.py 9 Aug 2004 17:27:55 -0000 1.7 --- pathfix.py 9 Aug 2004 18:54:11 -0000 1.8 *************** *** 148,150 **** if __name__ == '__main__': main() - --- 148,149 ---- Index: which.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/which.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** which.py 9 Aug 2004 17:27:55 -0000 1.14 --- which.py 9 Aug 2004 18:54:11 -0000 1.15 *************** *** 59,61 **** if __name__ == '__main__': main() - --- 59,60 ---- From pierslauder at users.sourceforge.net Tue Aug 10 03:24:59 2004 From: pierslauder at users.sourceforge.net (pierslauder@users.sourceforge.net) Date: Tue Aug 10 03:25:02 2004 Subject: [Python-checkins] python/dist/src/Lib imaplib.py,1.71,1.72 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2801/dist/src/Lib Modified Files: imaplib.py Log Message: Fix typo in getquotaroot parameter reported by Thierry FLORAC. Also amplify doc string for select to indicate proper way to obtain other responses. Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** imaplib.py 27 Jul 2004 05:07:18 -0000 1.71 --- imaplib.py 10 Aug 2004 01:24:54 -0000 1.72 *************** *** 20,24 **** # PROXYAUTH contributed by Rick Holbert November 2002. ! __version__ = "2.54" import binascii, os, random, re, socket, sys, time --- 20,24 ---- # PROXYAUTH contributed by Rick Holbert November 2002. ! __version__ = "2.55" import binascii, os, random, re, socket, sys, time *************** *** 453,457 **** (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = .getquotaroot(mailbox) """ ! typ, dat = self._simple_command('GETQUOTA', mailbox) typ, quota = self._untagged_response(typ, dat, 'QUOTA') typ, quotaroot = self._untagged_response(typ, dat, 'QUOTAROOT') --- 453,457 ---- (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = .getquotaroot(mailbox) """ ! typ, dat = self._simple_command('GETQUOTAROOT', mailbox) typ, quota = self._untagged_response(typ, dat, 'QUOTA') typ, quotaroot = self._untagged_response(typ, dat, 'QUOTAROOT') *************** *** 612,617 **** 'data' is count of messages in mailbox ('EXISTS' response). """ - # Mandated responses are ('FLAGS', 'EXISTS', 'RECENT', 'UIDVALIDITY') self.untagged_responses = {} # Flush old responses. self.is_readonly = readonly --- 612,619 ---- 'data' is count of messages in mailbox ('EXISTS' response). + + Mandated responses are ('FLAGS', 'EXISTS', 'RECENT', 'UIDVALIDITY'), so + other responses should be obtained via .response('FLAGS') etc. """ self.untagged_responses = {} # Flush old responses. self.is_readonly = readonly From tim_one at users.sourceforge.net Tue Aug 10 03:41:30 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 10 03:41:33 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.57,1.58 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5319/Lib Modified Files: doctest.py Log Message: Start rewriting doctest's LaTeX docs. Damn, this is slow going! Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** doctest.py 9 Aug 2004 16:43:36 -0000 1.57 --- doctest.py 10 Aug 2004 01:41:28 -0000 1.58 *************** *** 1611,1615 **** Also test examples reachable from dict m.__test__ if it exists and is ! not None. m.__dict__ maps names to functions, classes and strings; function and class docstrings are tested even if the name is private; strings are tested directly, as if they were docstrings. --- 1611,1615 ---- Also test examples reachable from dict m.__test__ if it exists and is ! not None. m.__test__ maps names to functions, classes and strings; function and class docstrings are tested even if the name is private; strings are tested directly, as if they were docstrings. From tim_one at users.sourceforge.net Tue Aug 10 03:41:30 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 10 03:41:35 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5319/Doc/lib Modified Files: libdoctest.tex Log Message: Start rewriting doctest's LaTeX docs. Damn, this is slow going! Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** libdoctest.tex 23 Jul 2004 02:48:24 -0000 1.21 --- libdoctest.tex 10 Aug 2004 01:41:27 -0000 1.22 *************** *** 79,84 **** def _test(): ! import doctest, example ! return doctest.testmod(example) if __name__ == "__main__": --- 79,84 ---- def _test(): ! import doctest ! return doctest.testmod() if __name__ == "__main__": *************** *** 101,110 **** \begin{verbatim} $ python example.py -v - Running example.__doc__ Trying: factorial(5) Expecting: 120 ok - 0 of 1 examples failed in example.__doc__ - Running example.factorial.__doc__ Trying: [factorial(n) for n in range(6)] Expecting: [1, 1, 2, 6, 24, 120] --- 101,107 ---- *************** *** 112,120 **** Trying: [factorial(long(n)) for n in range(6)] Expecting: [1, 1, 2, 6, 24, 120] ! ok ! Trying: factorial(30) ! Expecting: 265252859812191058636308480000000L ! ok ! \end{verbatim} And so on, eventually ending with: --- 109,113 ---- Trying: [factorial(long(n)) for n in range(6)] Expecting: [1, 1, 2, 6, 24, 120] ! ok\end{verbatim} And so on, eventually ending with: *************** *** 123,131 **** Trying: factorial(1e100) Expecting: ! Traceback (most recent call last): ! ... ! OverflowError: n too large ok - 0 of 8 examples failed in example.factorial.__doc__ 2 items passed all tests: 1 tests in example --- 116,123 ---- Trying: factorial(1e100) Expecting: ! Traceback (most recent call last): ! ... ! OverflowError: n too large ok 2 items passed all tests: 1 tests in example *************** *** 138,153 **** That's all you need to know to start making productive use of ! \module{doctest}! Jump in. The docstrings in \file{doctest.py} contain ! detailed information about all aspects of \module{doctest}, and we'll ! just cover the more important points here. ! \subsection{Normal Usage} ! In normal use, end each module \module{M} with: \begin{verbatim} def _test(): ! import doctest, M # replace M with your module's name ! return doctest.testmod(M) # ditto if __name__ == "__main__": --- 130,144 ---- That's all you need to know to start making productive use of ! \module{doctest}! Jump in. ! \subsection{Simple Usage} ! The simplest (not necessarily the best) way to start using doctest is to ! end each module \module{M} with: \begin{verbatim} def _test(): ! import doctest ! return doctest.testmod() if __name__ == "__main__": *************** *** 155,163 **** \end{verbatim} ! If you want to test the current module as the main module, you don't need to ! pass M to \function{testmod()}; in this case, it will test the current ! module. ! Then running the module as a script causes the examples in the docstrings to get executed and verified: --- 146,154 ---- \end{verbatim} ! \module{doctest} then examines docstrings in the module calling ! \function{testmod()}. If you want to test a different module, you can ! pass that module object to \function{testmod()}. ! Running the module as a script causes the examples in the docstrings to get executed and verified: *************** *** 168,172 **** This won't display anything unless an example fails, in which case the failing example(s) and the cause(s) of the failure(s) are printed to stdout, ! and the final line of output is \code{'Test failed.'}. Run it with the \programopt{-v} switch instead: --- 159,165 ---- This won't display anything unless an example fails, in which case the failing example(s) and the cause(s) of the failure(s) are printed to stdout, ! and the final line of output is ! \\code{'***Test Failed*** \var{N} failures.'}, where \var{N} is the ! number of examples that failed. Run it with the \programopt{-v} switch instead: *************** *** 179,185 **** output, along with assorted summaries at the end. ! You can force verbose mode by passing \code{verbose=1} to \function{testmod()}, or ! prohibit it by passing \code{verbose=0}. In either of those cases, \code{sys.argv} is not examined by \function{testmod()}. --- 172,178 ---- output, along with assorted summaries at the end. ! You can force verbose mode by passing \code{verbose=True} to \function{testmod()}, or ! prohibit it by passing \code{verbose=False}. In either of those cases, \code{sys.argv} is not examined by \function{testmod()}. *************** *** 189,192 **** --- 182,311 ---- attempted. + \begin{funcdesc}{testmod}{\optional{m}\optional{, name}\optional{, + globs}\optional{, verbose}\optional{, + isprivate}\optional{, report}\optional{, + optionflags}\optional{, extraglobs}\optional{, + raise_on_error}} + + All arguments are optional, and all except for \var{m} should be + specified in keyword form. + + Test examples in docstrings in functions and classes reachable + from module \var{m} (or the current module if \var{m} is not supplied + or is \code{None}), starting with \code{\var{m}.__doc__}. + + Also test examples reachable from dict \code{\var{m}.__test__}, if it + exists and is not \code{None}. \code{\var{m}.__test__} maps + names (strings) to functions, classes and strings; function and class + docstrings are searched for examples; strings are searched directly, + as if they were docstrings. + + Only docstrings attached to objects belonging to module \var{m} are + searched. + + Return \code{(#failures, #tests)}. + + Optional argument \var{name} gives the name of the module; by default, + or if \code{None}, \code{\var{m}.__name__} is used. + + Optional argument \var{globs} gives a dict to be used as the globals + when executing examples; by default, or if \code{None}, + \code{\var{m}.__dict__} is used. A new shallow copy of this dict is + created for each docstring with examples, so that each docstring's + examples start with a clean slate. + + Optional argument \var{extraglobs} gives a dicti merged into the + globals used to execute examples. This works like + \method{dict.update()}: if \var{globs} and \var{extraglobs} have a + common key, the associated value in \var{extraglobs} appears in the + combined dict. By default, or if \code{None}, no extra globals are + used. This is an advanced feature that allows parameterization of + doctests. For example, a doctest can be written for a base class, using + a generic name for the class, then reused to test any number of + subclasses by passing an \var{extraglobs} dict mapping the generic + name to the subclass to be tested. + + Optional argument \var{verbose} prints lots of stuff if true, and prints + only failures if false; by default, or if \code{None}, it's true + if and only if \code{'-v'} is in \code{\module{sys}.argv}. + + Optional argument \var{report} prints a summary at the end when true, + else prints nothing at the end. In verbose mode, the summary is + detailed, else the summary is very brief (in fact, empty if all tests + passed). + + Optional argument \var{optionflags} or's together module constants, + and defaults to 0. + + % Possible values: + % + % DONT_ACCEPT_TRUE_FOR_1 + % By default, if an expected output block contains just "1", + % an actual output block containing just "True" is considered + % to be a match, and similarly for "0" versus "False". When + % DONT_ACCEPT_TRUE_FOR_1 is specified, neither substitution + % is allowed. + % + % DONT_ACCEPT_BLANKLINE + % By default, if an expected output block contains a line + % containing only the string "", then that line + % will match a blank line in the actual output. When + % DONT_ACCEPT_BLANKLINE is specified, this substitution is + % not allowed. + % + % NORMALIZE_WHITESPACE + % When NORMALIZE_WHITESPACE is specified, all sequences of + % whitespace are treated as equal. I.e., any sequence of + % whitespace within the expected output will match any + % sequence of whitespace within the actual output. + % + % ELLIPSIS + % When ELLIPSIS is specified, then an ellipsis marker + % ("...") in the expected output can match any substring in + % the actual output. + % + % UNIFIED_DIFF + % When UNIFIED_DIFF is specified, failures that involve + % multi-line expected and actual outputs will be displayed + % using a unified diff. + % + % CONTEXT_DIFF + % When CONTEXT_DIFF is specified, failures that involve + % multi-line expected and actual outputs will be displayed + % using a context diff. + + Optional argument \var{raise_on_error} defaults to false. If true, + an exception is raised upon the first failure or unexpected exception + in an example. This allows failures to be post-mortem debugged. + Default behavior is to continue running examples. + + Optional argument \var{isprivate} specifies a function used to + determine whether a name is private. The default function treats + all names as public. \var{isprivate} can be set to + \code{\module{doctest}.is_private} to skip over names that are + private according to Python's underscore naming convention. + \deprecated{2.4}{\var{isprivate} was a stupid idea -- don't use it. + If you need to skip tests based on name, filter the list returned by + \code{\class{DocTestFinder.find()} instead.} + + % """ [XX] This is no longer true: + % Advanced tomfoolery: testmod runs methods of a local instance of + % class doctest.Tester, then merges the results into (or creates) + % global Tester instance doctest.master. Methods of doctest.master + % can be called directly too, if you want to do something unusual. + % Passing report=0 to testmod is especially useful then, to delay + % displaying a summary. Invoke doctest.master.summarize(verbose) + % when you're done fiddling. + + \versionchanged[The parameter \var{optionflags} was added]{2.3} + + \versionchanged[Many new module constants for use with \var{optionflags} + were added]{2.4} + + \versionchanged[The parameters \var{extraglobs} and \var{raise_on_error} + were added]{2.4} + \end{funcdesc} + + \subsection{Which Docstrings Are Examined?} From montanaro at users.sourceforge.net Tue Aug 10 03:51:33 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Tue Aug 10 03:51:36 2004 Subject: [Python-checkins] python/nondist/peps pep-0318.txt,1.19,1.20 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6796 Modified Files: pep-0318.txt Log Message: minor corrections Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** pep-0318.txt 6 Aug 2004 18:34:15 -0000 1.19 --- pep-0318.txt 10 Aug 2004 01:51:30 -0000 1.20 *************** *** 107,111 **** .. _outlined his case: ! http://mail.python.org/pipermail/python-dev/2004-August/authors.html .. _this piece: --- 107,111 ---- .. _outlined his case: ! http://mail.python.org/pipermail/python-dev/2004-August/author.html .. _this piece: *************** *** 248,252 **** entire function/method body. ! Guido proposed and implementated a patch to support interpretation of a `list of decorators`_ as a prefix to function definitions :: --- 248,252 ---- entire function/method body. ! Guido proposed and implemented a patch to support interpretation of a `list of decorators`_ as a prefix to function definitions :: From akuchling at users.sourceforge.net Tue Aug 10 15:27:35 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Tue Aug 10 15:27:37 2004 Subject: [Python-checkins] python/nondist/peps pep-0004.txt,1.11,1.12 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7627 Modified Files: pep-0004.txt Log Message: Add unlisted modules Index: pep-0004.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0004.txt,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pep-0004.txt 2 Jun 2004 14:48:11 -0000 1.11 --- pep-0004.txt 10 Aug 2004 13:27:32 -0000 1.12 *************** *** 137,140 **** --- 137,166 ---- Documentation: TBD + Module name: TERMIOS.py + Rationale: The constants in this file are now in the 'termios' module. + Date: 10-Aug-2004 + Documentation: This module has been documented as obsolete since + Python 2.1, but listing in this PEP was neglected. + + Module name: statcache + Rationale: Using the cache can be fragile and error-prone; + applications should just use os.stat() directly. + Date: 10-Aug-2004 + Documentation: This module has been documented as obsolete since + Python 2.2, but listing in this PEP was neglected. + + Module name: mpz + Rationale: Third-party packages provide similiar features + and wrap more of GMP's API. + Date: 10-Aug-2004 + Documentation: This module has been documented as obsolete since + Python 2.2, but listing in this PEP was neglected. + + Module name: xreadlines + Rationale: Using 'for line in file', introduced in 2.3, is preferable. + Date: 10-Aug-2004 + Documentation: This module has been documented as obsolete since + Python 2.3, but listing in this PEP was neglected. + Undeprecated modules From vsajip at users.sourceforge.net Tue Aug 10 16:27:59 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Tue Aug 10 16:28:02 2004 Subject: [Python-checkins] python/nondist/peps pep-0282.txt,1.4,1.5 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18893 Modified Files: pep-0282.txt Log Message: Marked as final Index: pep-0282.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0282.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pep-0282.txt 12 Jul 2002 23:17:00 -0000 1.4 --- pep-0282.txt 10 Aug 2004 14:27:57 -0000 1.5 *************** *** 5,9 **** Author: vinay_sajip at red-dove.com (Vinay Sajip), trentm@activestate.com (Trent Mick) ! Status: Draft Type: Standards Track Created: 4-Feb-2002 --- 5,9 ---- Author: vinay_sajip at red-dove.com (Vinay Sajip), trentm@activestate.com (Trent Mick) ! Status: Final Type: Standards Track Created: 4-Feb-2002 From vsajip at users.sourceforge.net Tue Aug 10 16:31:45 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Tue Aug 10 16:31:48 2004 Subject: [Python-checkins] python/nondist/peps pep-0000.txt,1.278,1.279 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19428 Modified Files: pep-0000.txt Log Message: Marked PEP 282 as Final Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.278 retrieving revision 1.279 diff -C2 -d -r1.278 -r1.279 *** pep-0000.txt 7 Aug 2004 15:59:56 -0000 1.278 --- pep-0000.txt 10 Aug 2004 14:31:41 -0000 1.279 *************** *** 95,99 **** S 280 Optimizing access to globals GvR S 281 Loop Counter Iteration with range and xrange Hetland - S 282 A Logging System Sajip, Mick S 284 Integer for-loops Eppstein, Ewing S 286 Enhanced Argument Tuples von Loewis --- 95,98 ---- *************** *** 159,170 **** SF 277 Unicode file name support for Windows NT Hodgson SF 279 The enumerate() built-in function Hettinger IF 283 Python 2.3 Release Schedule GvR SF 285 Adding a bool type GvR ! SF 289 Generator Expressions Hettinger SF 293 Codec Error Handling Callbacks Dörwald SF 307 Extensions to the pickle protocol GvR, Peters SF 311 Simplified GIL Acquisition for Extensions Hammond SF 322 Reverse Iteration Hettinger ! SF 327 Decimal Data Type Batista Empty PEPs (or containing only an abstract) --- 158,170 ---- SF 277 Unicode file name support for Windows NT Hodgson SF 279 The enumerate() built-in function Hettinger + SF 282 A Logging System Sajip, Mick IF 283 Python 2.3 Release Schedule GvR SF 285 Adding a bool type GvR ! SF 289 Generator Expressions Hettinger SF 293 Codec Error Handling Callbacks Dörwald SF 307 Extensions to the pickle protocol GvR, Peters SF 311 Simplified GIL Acquisition for Extensions Hammond SF 322 Reverse Iteration Hettinger ! SF 327 Decimal Data Type Batista Empty PEPs (or containing only an abstract) *************** *** 197,201 **** SR 317 Eliminate Implicit Exception Instantiation Taschuk SR 326 A Case for Top and Bottom Values Carlson, Reedy ! SR 329 Treating Builtins as Constants in the Standard Library Hettinger SR 666 Reject Foolish Indentation Creighton --- 197,201 ---- SR 317 Eliminate Implicit Exception Instantiation Taschuk SR 326 A Case for Top and Bottom Values Carlson, Reedy ! SR 329 Treating Builtins as Constants in the Standard Library Hettinger SR 666 Reject Foolish Indentation Creighton *************** *** 353,357 **** SF 327 Decimal Data Type Batista SA 328 Imports: Multi-Line and Absolute/Relative Aahz ! SR 329 Treating Builtins as Constants in the Standard Library Hettinger S 330 Python Bytecode Verification Pelletier S 331 Locale-Independent Float/String conversions Reis --- 353,357 ---- SF 327 Decimal Data Type Batista SA 328 Imports: Multi-Line and Absolute/Relative Aahz ! SR 329 Treating Builtins as Constants in the Standard Library Hettinger S 330 Python Bytecode Verification Pelletier S 331 Locale-Independent Float/String conversions Reis From fdrake at users.sourceforge.net Tue Aug 10 17:41:05 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 10 17:41:08 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32745 Modified Files: libdoctest.tex Log Message: minor changes to make this format again Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** libdoctest.tex 10 Aug 2004 01:41:27 -0000 1.22 --- libdoctest.tex 10 Aug 2004 15:41:03 -0000 1.23 *************** *** 204,208 **** searched. ! Return \code{(#failures, #tests)}. Optional argument \var{name} gives the name of the module; by default, --- 204,208 ---- searched. ! Return \code{(\var{failure_count}, \var{test_count})}. Optional argument \var{name} gives the name of the module; by default, *************** *** 287,291 **** \deprecated{2.4}{\var{isprivate} was a stupid idea -- don't use it. If you need to skip tests based on name, filter the list returned by ! \code{\class{DocTestFinder.find()} instead.} % """ [XX] This is no longer true: --- 287,291 ---- \deprecated{2.4}{\var{isprivate} was a stupid idea -- don't use it. If you need to skip tests based on name, filter the list returned by ! \code{DocTestFinder.find()} instead.} % """ [XX] This is no longer true: From fdrake at users.sourceforge.net Tue Aug 10 18:47:21 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 10 18:47:25 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libpyexpat.tex,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13530 Modified Files: libpyexpat.tex Log Message: add descriptions for many of the new error codes Index: libpyexpat.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpyexpat.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** libpyexpat.tex 12 May 2003 03:23:51 -0000 1.21 --- libpyexpat.tex 10 Aug 2004 16:47:18 -0000 1.22 *************** *** 625,629 **** \begin{datadescni}{XML_ERROR_PARTIAL_CHAR} ! \end{datadescni} --- 625,629 ---- \begin{datadescni}{XML_ERROR_PARTIAL_CHAR} ! An incomplete character was found in the input. \end{datadescni} *************** *** 653,654 **** --- 653,735 ---- The document encoding is not supported by Expat. \end{datadescni} + + \begin{datadescni}{XML_ERROR_UNCLOSED_CDATA_SECTION} + A CDATA marked section was not closed. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_EXTERNAL_ENTITY_HANDLING} + \end{datadescni} + + \begin{datadescni}{XML_ERROR_NOT_STANDALONE} + The parser determined that the document was not ``standalone'' though + it declared itself to be in the XML declaration, and the + \member{NotStandaloneHandler} was set and returned \code{0}. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_UNEXPECTED_STATE} + \end{datadescni} + + \begin{datadescni}{XML_ERROR_ENTITY_DECLARED_IN_PE} + \end{datadescni} + + \begin{datadescni}{XML_ERROR_FEATURE_REQUIRES_XML_DTD} + An operation was requested that requires DTD support to be compiled + in, but Expat was configured without DTD support. This should never + be reported by a standard build of the \module{xml.parsers.expat} + module. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING} + A behavioral change was requested after parsing started that can only + be changed before parsing has started. This is (currently) only + raised by \method{UseForeignDTD()}. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_UNBOUND_PREFIX} + An undeclared prefix was found when namespace processing was enabled. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_UNDECLARING_PREFIX} + The document attempted to remove the namespace declaration associated + with a prefix. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_INCOMPLETE_PE} + A parameter entity contained incomplete markup. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_XML_DECL} + The document contained no document element at all. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_TEXT_DECL} + There was an error parsing a text declaration in an external entity. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_PUBLICID} + Characters were found in the public id that are not allowed. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_SUSPENDED} + The requested operation was made on a suspended parser, but isn't + allowed. This includes attempts to provide additional input or to + stop the parser. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_NOT_SUSPENDED} + An attempt to resume the parser was made when the parser had not been + suspended. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_ABORTED} + This should not be reported to Python applications. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_FINISHED} + The requested operation was made on a parser which was finished + parsing input, but isn't allowed. This includes attempts to provide + additional input or to stop the parser. + \end{datadescni} + + \begin{datadescni}{XML_ERROR_SUSPEND_PE} + \end{datadescni} From fdrake at users.sourceforge.net Tue Aug 10 19:18:35 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 10 19:18:38 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libpyexpat.tex,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19883 Modified Files: libpyexpat.tex Log Message: added missing documentation for UseForeignDTD() (new in 2.3) someone should backport to the release23-maint branch Index: libpyexpat.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpyexpat.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** libpyexpat.tex 10 Aug 2004 16:47:18 -0000 1.22 --- libpyexpat.tex 10 Aug 2004 17:18:32 -0000 1.23 *************** *** 157,160 **** --- 157,181 ---- \end{methoddesc} + \begin{methoddesc}[xmlparser]{UseForeignDTD}{\optional{flag}} + Calling this with a true value for \var{flag} (the default) will cause + Expat to call the \member{ExternalEntityRefHandler} with + \constant{None} for all arguments to allow an alternate DTD to be + loaded. If the document does not contain a document type declaration, + the \member{ExternalEntityRefHandler} will still be called, but the + \member{StartDoctypeDeclHandler} and \member{EndDoctypeDeclHandler} + will not be called. + + Passing a false value for \var{flag} will cancel a previous call that + passed a true value, but otherwise has no effect. + + This method can only be called before the \method{Parse()} or + \method{ParseFile()} methods are called; calling it after either of + those have been called causes \exception{ExpatError} to be raised with + the \member{code} attribute set to + \constant{errors.XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING}. + + \versionadded{2.3} + \end{methoddesc} + \class{xmlparser} objects have the following attributes: From akuchling at users.sourceforge.net Tue Aug 10 21:01:53 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Tue Aug 10 21:01:56 2004 Subject: [Python-checkins] python/dist/src/Doc/api utilities.tex,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8614 Modified Files: utilities.tex Log Message: Spelling fix Index: utilities.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/utilities.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** utilities.tex 2 Aug 2004 04:30:37 -0000 1.19 --- utilities.tex 10 Aug 2004 19:01:50 -0000 1.20 *************** *** 85,89 **** \code{-1}. The cleanup function registered last is called first. Each cleanup function will be called at most once. Since Python's ! internal finallization will have completed before the cleanup function, no Python APIs should be called by \var{func}. \end{cfuncdesc} --- 85,89 ---- \code{-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 \var{func}. \end{cfuncdesc} From akuchling at users.sourceforge.net Tue Aug 10 21:03:03 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Tue Aug 10 21:03:06 2004 Subject: [Python-checkins] python/dist/src/Doc/api utilities.tex, 1.10.12.1, 1.10.12.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8853 Modified Files: Tag: release23-maint utilities.tex Log Message: Spelling fix Index: utilities.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/utilities.tex,v retrieving revision 1.10.12.1 retrieving revision 1.10.12.2 diff -C2 -d -r1.10.12.1 -r1.10.12.2 *** utilities.tex 22 Sep 2003 15:37:38 -0000 1.10.12.1 --- utilities.tex 10 Aug 2004 19:02:54 -0000 1.10.12.2 *************** *** 85,89 **** \code{-1}. The cleanup function registered last is called first. Each cleanup function will be called at most once. Since Python's ! internal finallization will have completed before the cleanup function, no Python APIs should be called by \var{func}. \end{cfuncdesc} --- 85,89 ---- \code{-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 \var{func}. \end{cfuncdesc} From fdrake at users.sourceforge.net Tue Aug 10 21:22:51 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 10 21:22:58 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libbsddb.tex,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12997 Modified Files: libbsddb.tex Log Message: clarify the behavior of the .first() and .last() methods for empty databases this should be backported to the release23-maint branch Index: libbsddb.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libbsddb.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** libbsddb.tex 26 Jul 2004 16:33:29 -0000 1.17 --- libbsddb.tex 10 Aug 2004 19:22:48 -0000 1.18 *************** *** 136,139 **** --- 136,140 ---- Set the cursor to the first item in the DB file and return it. The order of keys in the file is unspecified, except in the case of B-Tree databases. + This method raises \exception{bsddb.error} if the database is empty. \end{methoddesc} *************** *** 154,157 **** --- 155,159 ---- order of keys in the file is unspecified. This is not supported on hashtable databases (those opened with \function{hashopen()}). + This method raises \exception{bsddb.error} if the database is empty. \end{methoddesc} From fdrake at users.sourceforge.net Tue Aug 10 23:20:13 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Aug 10 23:20:16 2004 Subject: [Python-checkins] python/dist/src/Doc/inst inst.tex,1.57,1.58 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/inst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2699 Modified Files: inst.tex Log Message: avoid version numbers in the text where possible Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** inst.tex 7 Aug 2004 21:33:44 -0000 1.57 --- inst.tex 10 Aug 2004 21:20:10 -0000 1.58 *************** *** 268,277 **** {Platform}{Standard installation location}{Default value}{Notes} \lineiv{\UNIX{} (pure)} ! {\filenq{\filevar{prefix}/lib/python2.4/site-packages}} ! {\filenq{/usr/local/lib/python2.4/site-packages}} {(1)} \lineiv{\UNIX{} (non-pure)} ! {\filenq{\filevar{exec-prefix}/lib/python2.4/site-packages}} ! {\filenq{/usr/local/lib/python2.4/site-packages}} {(1)} \lineiv{Windows} --- 268,277 ---- {Platform}{Standard installation location}{Default value}{Notes} \lineiv{\UNIX{} (pure)} ! {\filenq{\filevar{prefix}/lib/python\shortversion/site-packages}} ! {\filenq{/usr/local/lib/python\shortversion/site-packages}} {(1)} \lineiv{\UNIX{} (non-pure)} ! {\filenq{\filevar{exec-prefix}/lib/python\shortversion/site-packages}} ! {\filenq{/usr/local/lib/python\shortversion/site-packages}} {(1)} \lineiv{Windows} *************** *** 309,313 **** Under \UNIX, just type \code{python} at the shell prompt. Under Windows, choose \menuselection{Start \sub Programs \sub Python ! 2.4 \sub Python (command line)}. Once the interpreter is started, you type Python code at the prompt. For example, on my Linux system, I type the three Python --- 309,313 ---- Under \UNIX, just type \code{python} at the shell prompt. Under Windows, choose \menuselection{Start \sub Programs \sub Python ! \shortversion \sub Python (command line)}. Once the interpreter is started, you type Python code at the prompt. For example, on my Linux system, I type the three Python From bwarsaw at users.sourceforge.net Wed Aug 11 00:20:01 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Wed Aug 11 00:20:05 2004 Subject: [Python-checkins] python/nondist/peps pep-0292.txt,1.8,1.9 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13147 Modified Files: pep-0292.txt Log Message: Updated and simplified PEP, after a few very good rounds of discussion with Raymond. Index: pep-0292.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0292.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pep-0292.txt 16 Jun 2004 19:31:35 -0000 1.8 --- pep-0292.txt 10 Aug 2004 22:19:59 -0000 1.9 *************** *** 44,52 **** A Simpler Proposal ! We propose the addition of a new class -- called 'dstring' -- ! derived from the built-in unicode type, which supports new rules ! for string substitution. dstring's value contains placeholders, ! introduced with the $ character. The following rules for ! $-placeholders apply: 1. $$ is an escape; it is replaced with a single $ --- 44,52 ---- A Simpler Proposal ! We propose the addition of a new class -- called 'template', which ! will live in the string module -- derived from the built-in ! unicode type. The template class supports new rules for string ! substitution; its value contains placeholders, introduced with the ! $ character. The following rules for $-placeholders apply: 1. $$ is an escape; it is replaced with a single $ *************** *** 58,62 **** specification. ! 3. ${identifier} is equivalent to $identifier. It is required for when valid identifier characters follow the placeholder but are not part of the placeholder, e.g. "${noun}ification". --- 58,62 ---- specification. ! 3. ${identifier} is equivalent to $identifier. It is required when valid identifier characters follow the placeholder but are not part of the placeholder, e.g. "${noun}ification". *************** *** 68,84 **** No other characters have special meaning, however it is possible ! to derive from the dstring class to define different rules for the ! placeholder. For example, a derived class could allow for periods ! in the placeholder (e.g. to support a kind of dynamic namespace ! and attribute path lookup). ! Once the dstring has been created, substitutions can be performed using traditional Python syntax. For example: >>> mapping = dict(name='Guido', country='the Netherlands') ! >>> s = dstring('${name} was born in ${country}) >>> print s % mapping Guido was born in the Netherlands Why `$' and Braces? --- 68,104 ---- No other characters have special meaning, however it is possible ! to derive from the template class to define different rules for ! the placeholder. For example, a derived class could allow for ! periods in the placeholder (e.g. to support a kind of dynamic ! namespace and attribute path lookup). ! Once the template has been created, substitutions can be performed using traditional Python syntax. For example: + >>> from string import template >>> mapping = dict(name='Guido', country='the Netherlands') ! >>> s = template('${name} was born in ${country}) >>> print s % mapping Guido was born in the Netherlands + Another class is provided which derives from template. This class + is called 'safe_template' and supports rules identical to those + above. The difference between template instances and + safe_template instances is that if a placeholder is missing from + the interpolation mapping, no KeyError is raised. Instead, the + original placeholder is included in the result string unchanged. + For example: + + >>> from string import template, safe_template + >>> mapping = dict(name='Guido', country='the Netherlands') + >>> s = template('$who was born in $country') + >>> print s % mapping + Traceback (most recent call last): + [...traceback omitted...] + KeyError: u'who' + >>> s = safe_template('$who was born in $country') + >>> print s % mapping + $who was born in the Netherlands + Why `$' and Braces? *************** *** 89,101 **** - Reference Implementation - - A reference implementation is available at [4]. The - implementation contains the dstring class described above, - situated in a new standard library package called 'stringlib'. - Inside the reference implementation stringlib package are a few - other related nifty tools that aren't described in this PEP. - - Comparison to PEP 215 --- 109,112 ---- *************** *** 125,151 **** placeholder in the original $-string. ! The interesting thing is that the dstring class defined in this PEP has nothing to say about the values that are substituted for the placeholders. Thus, with a little extra work, it's possible to support PEP 215's functionality using existing Python syntax. ! For example, one could define a subclass of dict that allowed a ! more complex placeholder syntax and a mapping that evaluated those ! placeholders. Internationalization ! The reference implementation accomplishes this magic by parsing ! the constructor string, transforming $-strings into standard ! Python %-strings. dstring caches this value and uses it whenever ! the special __mod__() method is called via the % operator. ! However the string value of a dstring is the string that was ! passed to its constructor. This approach allows a gettext-based internationalized program to ! use the dstring instance as a lookup into the catalog; in fact ! gettext doesn't care that the catalog key is a dstring. Because ! the value of the dstring is the original $-string, translators also never need to use %-strings. The right thing will happen at run-time. --- 136,161 ---- placeholder in the original $-string. ! The interesting thing is that the template class defined in this PEP has nothing to say about the values that are substituted for the placeholders. Thus, with a little extra work, it's possible to support PEP 215's functionality using existing Python syntax. ! For example, one could define subclasses of template and dict that ! allowed for a more complex placeholder syntax and a mapping that ! evaluated those placeholders. Internationalization ! The implementation supports internationalization magic by keeping ! the original string value intact. In fact, all the work of the ! special substitution rules are implemented by overriding the ! __mod__() operator. However the string value of a template (or ! safe_template) is the string that was passed to its constructor. This approach allows a gettext-based internationalized program to ! use the template instance as a lookup into the catalog; in fact ! gettext doesn't care that the catalog key is a template. Because ! the value of the template is the original $-string, translators also never need to use %-strings. The right thing will happen at run-time. *************** *** 163,169 **** http://mail.python.org/pipermail/python-dev/2002-July/026397.html - [4] Reference implementation - http://sourceforge.net/tracker/index.php?func=detail&aid=922115&group_id=5470&atid=305470 - Copyright --- 173,176 ---- From bwarsaw at users.sourceforge.net Wed Aug 11 00:27:48 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Wed Aug 11 00:27:50 2004 Subject: [Python-checkins] python/nondist/sandbox/string libstring.tex, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/string In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15312 Added Files: libstring.tex Log Message: Latest round of PEP 292 implementation after discussions w/Raymond. I think we're basically ready for a thumbs up or down. - Got rid of older versions alt292.py and pep292.py - Got rid of safedict.py, which thanks to Raymond's we don't need to be able to retain braces in safe-substitutions - Updated re-org of the string module -> package (not strictly a PEP 292 proposal but something I still think is useful to do -- and backward compatibly transparent - Updated documentation for the string package - Updated tests --- NEW FILE: libstring.tex --- \section{\module{string} --- Common string operations} \declaremodule{standard}{string} \modulesynopsis{Common string operations.} The \module{string} package contains a number of useful constants and classes, as well as some deprecated legacy functions that are also available as methods on strings. See the module \refmodule{re}\refstmodindex{re} for string functions based on regular expressions. In general, all of these objects are exposed directly in the \module{string} package so users need only import the \module{string} package to begin using these constants, classes, and functions. \begin{notice} Starting with Python 2.4, the traditional \module{string} module was turned into a package, however backward compatibility with existing code has been retained. Code using the \module{string} module that worked prior to Python 2.4 should continue to work unchanged. \end{notice} \subsection{String constants} The constants defined in this module are: \begin{datadesc}{ascii_letters} The concatenation of the \constant{ascii_lowercase} and \constant{ascii_uppercase} constants described below. This value is not locale-dependent. \end{datadesc} \begin{datadesc}{ascii_lowercase} The lowercase letters \code{'abcdefghijklmnopqrstuvwxyz'}. This value is not locale-dependent and will not change. \end{datadesc} \begin{datadesc}{ascii_uppercase} The uppercase letters \code{'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}. This value is not locale-dependent and will not change. \end{datadesc} \begin{datadesc}{digits} The string \code{'0123456789'}. \end{datadesc} \begin{datadesc}{hexdigits} The string \code{'0123456789abcdefABCDEF'}. \end{datadesc} \begin{datadesc}{letters} The concatenation of the strings \constant{lowercase} and \constant{uppercase} described below. The specific value is locale-dependent, and will be updated when \function{locale.setlocale()} is called. \end{datadesc} \begin{datadesc}{lowercase} A string containing all the characters that are considered lowercase letters. On most systems this is the string \code{'abcdefghijklmnopqrstuvwxyz'}. Do not change its definition --- the effect on the routines \function{upper()} and \function{swapcase()} is undefined. The specific value is locale-dependent, and will be updated when \function{locale.setlocale()} is called. \end{datadesc} \begin{datadesc}{octdigits} The string \code{'01234567'}. \end{datadesc} \begin{datadesc}{punctuation} String of \ASCII{} characters which are considered punctuation characters in the \samp{C} locale. \end{datadesc} \begin{datadesc}{printable} String of characters which are considered printable. This is a combination of \constant{digits}, \constant{letters}, \constant{punctuation}, and \constant{whitespace}. \end{datadesc} \begin{datadesc}{uppercase} A string containing all the characters that are considered uppercase letters. On most systems this is the string \code{'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}. Do not change its definition --- the effect on the routines \function{lower()} and \function{swapcase()} is undefined. The specific value is locale-dependent, and will be updated when \function{locale.setlocale()} is called. \end{datadesc} \begin{datadesc}{whitespace} A string containing all characters that are considered whitespace. On most systems this includes the characters space, tab, linefeed, return, formfeed, and vertical tab. Do not change its definition --- the effect on the routines \function{strip()} and \function{split()} is undefined. \end{datadesc} \subsection{Template strings} Templates are Unicode strings that can be used to provide simpler string substitutions as described in \pep{292}. There is a \class{template} class that is a subclass of \class{unicode}, overriding the default \method{__mod__()} method. Instead of the normal \samp{\%}-based substitutions, template strings support \samp{\$}-based substitutions, using the following rules: \begin{itemize} \item \samp{\$\$} is an escape; it is replaced with a single \samp{\$}. \item \samp{\$identifier} names a substitution placeholder matching a mapping key of "identifier". By default, "identifier" must spell a Python identifier. The first non-identifier character after the \samp{\$} character terminates this placeholder specification. \item \samp{\$\{identifier\}} is equivalent to \samp{\$identifier}. It is required when valid identifier characters follow the placeholder but are not part of the placeholder, e.g. "\$\{noun\}ification". \end{itemize} Template strings are used just like normal strings, in that the modulus operator is used to interpolate a dictionary of values into a template string, e.g.: \begin{verbatim} >>> from string import template >>> s = template('$who likes $what') >>> print s % dict(who='tim', what='kung pao') tim likes kung pao \end{verbatim} There is also a \class{safe_template} class, derived from \class{template} which acts the same as \class{template}, except that if placeholders are missing in the interpolation dictionary, no \exception{KeyError} will be raised. Instead the original placeholder (with or without the braces, as appropriate) will be used: \begin{verbatim} >>> from string import safe_template >>> s = safe_template('$who likes $what for ${meal}') >>> print s % dict(who='tim') tim likes $what for ${meal} \end{verbatim} Advanced usage: you can derive subclasses of \class{template} or \class{safe_template} to use application-specific placeholder rules. To do this, you override the class attribute \member{pattern}; the value must be a compiled regular expression object with three capturing groups. The capturing groups correspond to the three rules given above. \subsection{String functions} The following functions are available to operate on string and Unicode objects. They are not available as string methods. \begin{funcdesc}{capwords}{s} Split the argument into words using \function{split()}, capitalize each word using \function{capitalize()}, and join the capitalized words using \function{join()}. Note that this replaces runs of whitespace characters by a single space, and removes leading and trailing whitespace. \end{funcdesc} \begin{funcdesc}{maketrans}{from, to} Return a translation table suitable for passing to \function{translate()} or \function{regex.compile()}, that will map each character in \var{from} into the character at the same position in \var{to}; \var{from} and \var{to} must have the same length. \warning{Don't use strings derived from \constant{lowercase} and \constant{uppercase} as arguments; in some locales, these don't have the same length. For case conversions, always use \function{lower()} and \function{upper()}.} \end{funcdesc} \subsection{Deprecated string functions} The following list of functions are also defined as methods of string and Unicode objects; see ``String Methods'' (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.0. The functions defined in this module are: \begin{funcdesc}{atof}{s} \deprecated{2.0}{Use the \function{float()} built-in function.} Convert a string to a floating point number. The string must have the standard syntax for a floating point literal in Python, optionally preceded by a sign (\samp{+} or \samp{-}). Note that this behaves identical to the built-in function \function{float()}\bifuncindex{float} when passed a string. \note{When passing in a string, values for NaN\index{NaN} and Infinity\index{Infinity} may be returned, depending on the underlying C library. The specific set of strings accepted which cause these values to be returned depends entirely on the C library and is known to vary.} \end{funcdesc} \begin{funcdesc}{atoi}{s\optional{, base}} \deprecated{2.0}{Use the \function{int()} built-in function.} Convert string \var{s} to an integer in the given \var{base}. The string must consist of one or more digits, optionally preceded by a sign (\samp{+} or \samp{-}). The \var{base} defaults to 10. If it is 0, a default base is chosen depending on the leading characters of the string (after stripping the sign): \samp{0x} or \samp{0X} means 16, \samp{0} means 8, anything else means 10. If \var{base} is 16, a leading \samp{0x} or \samp{0X} is always accepted, though not required. This behaves identically to the built-in function \function{int()} when passed a string. (Also note: for a more flexible interpretation of numeric literals, use the built-in function \function{eval()}\bifuncindex{eval}.) \end{funcdesc} \begin{funcdesc}{atol}{s\optional{, base}} \deprecated{2.0}{Use the \function{long()} built-in function.} Convert string \var{s} to a long integer in the given \var{base}. The string must consist of one or more digits, optionally preceded by a sign (\samp{+} or \samp{-}). The \var{base} argument has the same meaning as for \function{atoi()}. A trailing \samp{l} or \samp{L} is not allowed, except if the base is 0. Note that when invoked without \var{base} or with \var{base} set to 10, this behaves identical to the built-in function \function{long()}\bifuncindex{long} when passed a string. \end{funcdesc} \begin{funcdesc}{capitalize}{word} Return a copy of \var{word} with only its first character capitalized. \end{funcdesc} \begin{funcdesc}{expandtabs}{s\optional{, tabsize}} Expand tabs in a string, i.e.\ replace them by one or 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. This doesn't understand other non-printing characters or escape sequences. The tab size defaults to 8. \end{funcdesc} \begin{funcdesc}{find}{s, sub\optional{, start\optional{,end}}} Return the lowest index in \var{s} where the substring \var{sub} is found such that \var{sub} is wholly contained in \code{\var{s}[\var{start}:\var{end}]}. Return \code{-1} on failure. Defaults for \var{start} and \var{end} and interpretation of negative values is the same as for slices. \end{funcdesc} \begin{funcdesc}{rfind}{s, sub\optional{, start\optional{, end}}} Like \function{find()} but find the highest index. \end{funcdesc} \begin{funcdesc}{index}{s, sub\optional{, start\optional{, end}}} Like \function{find()} but raise \exception{ValueError} when the substring is not found. \end{funcdesc} \begin{funcdesc}{rindex}{s, sub\optional{, start\optional{, end}}} Like \function{rfind()} but raise \exception{ValueError} when the substring is not found. \end{funcdesc} \begin{funcdesc}{count}{s, sub\optional{, start\optional{, end}}} Return the number of (non-overlapping) occurrences of substring \var{sub} in string \code{\var{s}[\var{start}:\var{end}]}. Defaults for \var{start} and \var{end} and interpretation of negative values are the same as for slices. \end{funcdesc} \begin{funcdesc}{lower}{s} Return a copy of \var{s}, but with upper case letters converted to lower case. \end{funcdesc} \begin{funcdesc}{split}{s\optional{, sep\optional{, maxsplit}}} Return a list of the words of the string \var{s}. If the optional second argument \var{sep} is absent or \code{None}, the words are separated by arbitrary strings of whitespace characters (space, tab, newline, return, formfeed). If the second argument \var{sep} is present and not \code{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. The optional third argument \var{maxsplit} defaults to 0. If it is nonzero, at most \var{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 \code{\var{maxsplit}+1} elements). The behavior of split on an empty string depends on the value of \var{sep}. If \var{sep} is not specified, or specified as \code{None}, the result will be an empty list. If \var{sep} is specified as any string, the result will be a list containing one element which is an empty string. \end{funcdesc} \begin{funcdesc}{rsplit}{s\optional{, sep\optional{, maxsplit}}} Return a list of the words of the string \var{s}, scanning \var{s} from the end. To all intents and purposes, the resulting list of words is the same as returned by \function{split()}, except when the optional third argument \var{maxsplit} is explicitly specified and nonzero. When \var{maxsplit} is nonzero, at most \var{maxsplit} number of splits -- the \emph{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 \code{\var{maxsplit}+1} elements). \versionadded{2.4} \end{funcdesc} \begin{funcdesc}{splitfields}{s\optional{, sep\optional{, maxsplit}}} This function behaves identically to \function{split()}. (In the past, \function{split()} was only used with one argument, while \function{splitfields()} was only used with two arguments.) \end{funcdesc} \begin{funcdesc}{join}{words\optional{, sep}} Concatenate a list or tuple of words with intervening occurrences of \var{sep}. The default value for \var{sep} is a single space character. It is always true that \samp{string.join(string.split(\var{s}, \var{sep}), \var{sep})} equals \var{s}. \end{funcdesc} \begin{funcdesc}{joinfields}{words\optional{, sep}} This function behaves identically to \function{join()}. (In the past, \function{join()} was only used with one argument, while \function{joinfields()} was only used with two arguments.) Note that there is no \method{joinfields()} method on string objects; use the \method{join()} method instead. \end{funcdesc} \begin{funcdesc}{lstrip}{s\optional{, chars}} Return a copy of the string with leading characters removed. If \var{chars} is omitted or \code{None}, whitespace characters are removed. If given and not \code{None}, \var{chars} must be a string; the characters in the string will be stripped from the beginning of the string this method is called on. \versionchanged[The \var{chars} parameter was added. The \var{chars} parameter cannot be passed in earlier 2.2 versions]{2.2.3} \end{funcdesc} \begin{funcdesc}{rstrip}{s\optional{, chars}} Return a copy of the string with trailing characters removed. If \var{chars} is omitted or \code{None}, whitespace characters are removed. If given and not \code{None}, \var{chars} must be a string; the characters in the string will be stripped from the end of the string this method is called on. \versionchanged[The \var{chars} parameter was added. The \var{chars} parameter cannot be passed in earlier 2.2 versions]{2.2.3} \end{funcdesc} \begin{funcdesc}{strip}{s\optional{, chars}} Return a copy of the string with leading and trailing characters removed. If \var{chars} is omitted or \code{None}, whitespace characters are removed. If given and not \code{None}, \var{chars} must be a string; the characters in the string will be stripped from the both ends of the string this method is called on. \versionchanged[The \var{chars} parameter was added. The \var{chars} parameter cannot be passed in earlier 2.2 versions]{2.2.3} \end{funcdesc} \begin{funcdesc}{swapcase}{s} Return a copy of \var{s}, but with lower case letters converted to upper case and vice versa. \end{funcdesc} \begin{funcdesc}{translate}{s, table\optional{, deletechars}} Delete all characters from \var{s} that are in \var{deletechars} (if present), and then translate the characters using \var{table}, which must be a 256-character string giving the translation for each character value, indexed by its ordinal. \end{funcdesc} \begin{funcdesc}{upper}{s} Return a copy of \var{s}, but with lower case letters converted to upper case. \end{funcdesc} \begin{funcdesc}{ljust}{s, width} \funcline{rjust}{s, width} \funcline{center}{s, width} These functions respectively left-justify, right-justify and center a string in a field of given width. They return a string that is at least \var{width} characters wide, created by padding the string \var{s} with spaces until the given width on the right, left or both sides. The string is never truncated. \end{funcdesc} \begin{funcdesc}{zfill}{s, width} Pad a numeric string on the left with zero digits until the given width is reached. Strings starting with a sign are handled correctly. \end{funcdesc} \begin{funcdesc}{replace}{str, old, new\optional{, maxreplace}} Return a copy of string \var{str} with all occurrences of substring \var{old} replaced by \var{new}. If the optional argument \var{maxreplace} is given, the first \var{maxreplace} occurrences are replaced. \end{funcdesc} From bwarsaw at users.sourceforge.net Wed Aug 11 00:27:49 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Wed Aug 11 00:27:53 2004 Subject: [Python-checkins] python/nondist/sandbox/string/tests test_pep292.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/string/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15312/tests Modified Files: test_pep292.py Log Message: Latest round of PEP 292 implementation after discussions w/Raymond. I think we're basically ready for a thumbs up or down. - Got rid of older versions alt292.py and pep292.py - Got rid of safedict.py, which thanks to Raymond's we don't need to be able to retain braces in safe-substitutions - Updated re-org of the string module -> package (not strictly a PEP 292 proposal but something I still think is useful to do -- and backward compatibly transparent - Updated documentation for the string package - Updated tests Index: test_pep292.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/string/tests/test_pep292.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_pep292.py 14 Jun 2004 17:25:22 -0000 1.1 --- test_pep292.py 10 Aug 2004 22:27:46 -0000 1.2 *************** *** 4,78 **** import unittest ! from string.pep292 import dstring, astring ! from string.safedict import safedict, nsdict ! ! class Bag: ! pass ! class TestDstrings(unittest.TestCase): ! def test_basic_dstring(self): ! eq = self.assertEqual ! s = dstring('$who likes to eat a bag of $what worth $100') ! eq(s % safedict(who='tim', what='ham'), ! 'tim likes to eat a bag of ham worth $100') ! eq(s % safedict(who='tim'), ! 'tim likes to eat a bag of $what worth $100') ! ! def test_brace_identifiers(self): ! eq = self.assertEqual ! s = dstring('${who} likes to eat a bag of ${what} worth $100') ! eq(s % safedict(who='tim', what='ham'), ! 'tim likes to eat a bag of ham worth $100') ! eq(s % safedict(who='tim'), ! 'tim likes to eat a bag of ${what} worth $100') ! def test_embedded_brace_identifiers(self): ! eq = self.assertEqual ! s = dstring('${who} likes to eat a bag of ${what}ster worth $100') ! eq(s % safedict(who='tim', what='ham'), ! 'tim likes to eat a bag of hamster worth $100') ! eq(s % safedict(who='tim'), ! 'tim likes to eat a bag of ${what}ster worth $100') def test_escapes(self): eq = self.assertEqual ! s = dstring('$who likes to eat a bag of $$what worth $100') ! eq(s % safedict(who='tim', what='ham'), 'tim likes to eat a bag of $what worth $100') ! ! class TestAstrings(unittest.TestCase): ! def setUp(self): ! self.bag = Bag() ! self.bag.who = 'tim' ! self.bag.food = 'ham' ! ! def test_basic_astring(self): ! eq = self.assertEqual ! s = astring( ! '$self.bag.who likes to eat a bag of $self.bag.food worth $100') ! eq(s % nsdict(), ! 'tim likes to eat a bag of ham worth $100') ! ! def test_brace_identifiers(self): ! eq = self.assertEqual ! s = astring( ! '${self.bag.who} likes to eat bags of ${self.bag.food} worth $100') ! eq(s % nsdict(), ! 'tim likes to eat bags of ham worth $100') ! ! def test_embedded_brace_identifiers(self): ! eq = self.assertEqual ! s = astring( ! '${self.bag.who} likes to eat bags of ${self.bag.food}ster') ! eq(s % nsdict(), 'tim likes to eat bags of hamster') ! ! def test_escapes(self): eq = self.assertEqual ! s = astring('$self.bag.who likes to eat bags of $${self.bag.food}') ! eq(s % nsdict(), 'tim likes to eat bags of ${self.bag.food}') --- 4,50 ---- import unittest ! from string import template, safe_template ! class TestTemplates(unittest.TestCase): ! def test_regular_templates(self): ! s = template('$who likes to eat a bag of $what worth $100') ! self.assertEqual(s % dict(who='tim', what='ham'), ! 'tim likes to eat a bag of ham worth $100') ! self.assertRaises(KeyError, lambda s, d: s % d, s, dict(who='tim')) ! def test_regular_templates_with_braces(self): ! s = template('$who likes ${what} for ${meal}') ! self.assertEqual(s % dict(who='tim', what='ham', meal='dinner'), ! 'tim likes ham for dinner') ! self.assertRaises(KeyError, lambda s, d: s % d, ! s, dict(who='tim', what='ham')) def test_escapes(self): eq = self.assertEqual ! s = template('$who likes to eat a bag of $$what worth $100') ! eq(s % dict(who='tim', what='ham'), 'tim likes to eat a bag of $what worth $100') + def test_percents(self): + s = template('%(foo)s $foo ${foo}') + self.assertEqual(s % dict(foo='baz'), '%(foo)s baz baz') + s = safe_template('%(foo)s $foo ${foo}') + self.assertEqual(s % dict(foo='baz'), '%(foo)s baz baz') ! def test_safe_templates(self): eq = self.assertEqual ! s = safe_template('$who likes ${what} for ${meal}') ! eq(s % dict(who='tim'), ! 'tim likes ${what} for ${meal}') ! eq(s % dict(what='ham'), ! '$who likes ham for ${meal}') ! eq(s % dict(what='ham', meal='dinner'), ! '$who likes ham for dinner') ! eq(s % dict(who='tim', what='ham'), ! 'tim likes ham for ${meal}') ! eq(s % dict(who='tim', what='ham', meal='dinner'), ! 'tim likes ham for dinner') *************** *** 80,85 **** def test_suite(): suite = unittest.TestSuite() ! suite.addTest(unittest.makeSuite(TestDstrings)) ! suite.addTest(unittest.makeSuite(TestAstrings)) return suite --- 52,56 ---- def test_suite(): suite = unittest.TestSuite() ! suite.addTest(unittest.makeSuite(TestTemplates)) return suite From bwarsaw at users.sourceforge.net Wed Aug 11 00:27:49 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Wed Aug 11 00:27:54 2004 Subject: [Python-checkins] python/nondist/sandbox/string/string deprecated.py, NONE, 1.1 template.py, NONE, 1.1 __init__.py, 1.1, 1.2 alt292.py, 1.1, NONE pep292.py, 1.1, NONE safedict.py, 1.1, NONE string.py, 1.1, NONE Message-ID: Update of /cvsroot/python/python/nondist/sandbox/string/string In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15312/string Modified Files: __init__.py Added Files: deprecated.py template.py Removed Files: alt292.py pep292.py safedict.py string.py Log Message: Latest round of PEP 292 implementation after discussions w/Raymond. I think we're basically ready for a thumbs up or down. - Got rid of older versions alt292.py and pep292.py - Got rid of safedict.py, which thanks to Raymond's we don't need to be able to retain braces in safe-substitutions - Updated re-org of the string module -> package (not strictly a PEP 292 proposal but something I still think is useful to do -- and backward compatibly transparent - Updated documentation for the string package - Updated tests --- NEW FILE: deprecated.py --- """A collection of deprecated string operations. Warning: most of the code you see here isn't normally used nowadays. Beginning with Python 1.6, many of these functions are implemented as methods on the standard string object. They used to be implemented by a built-in module called strop, but strop is now obsolete itself. """ # Backward compatible names for exceptions index_error = ValueError atoi_error = ValueError atof_error = ValueError atol_error = ValueError # convert UPPER CASE letters to lower case def lower(s): """lower(s) -> string Return a copy of the string s converted to lowercase. """ return s.lower() # Convert lower case letters to UPPER CASE def upper(s): """upper(s) -> string Return a copy of the string s converted to uppercase. """ return s.upper() # Swap lower case letters and UPPER CASE def swapcase(s): """swapcase(s) -> string Return a copy of the string s with upper case characters converted to lowercase and vice versa. """ return s.swapcase() # Strip leading and trailing tabs and spaces def strip(s, chars=None): """strip(s [,chars]) -> string Return a copy of the string s with leading and trailing whitespace removed. If chars is given and not None, remove characters in chars instead. If chars is unicode, S will be converted to unicode before stripping. """ return s.strip(chars) # Strip leading tabs and spaces def lstrip(s, chars=None): """lstrip(s [,chars]) -> string Return a copy of the string s with leading whitespace removed. If chars is given and not None, remove characters in chars instead. """ return s.lstrip(chars) # Strip trailing tabs and spaces def rstrip(s, chars=None): """rstrip(s [,chars]) -> string Return a copy of the string s with trailing whitespace removed. If chars is given and not None, remove characters in chars instead. """ return s.rstrip(chars) # Split a string into a list of space/tab-separated words def split(s, sep=None, maxsplit=-1): """split(s [,sep [,maxsplit]]) -> list of strings Return a list of the words in the string s, using sep as the delimiter string. If maxsplit is given, splits at no more than maxsplit places (resulting in at most maxsplit+1 words). If sep is not specified, any whitespace string is a separator. (split and splitfields are synonymous) """ return s.split(sep, maxsplit) splitfields = split # Split a string into a list of space/tab-separated words def rsplit(s, sep=None, maxsplit=-1): """rsplit(s [,sep [,maxsplit]]) -> list of strings Return a list of the words in the string s, using sep as the delimiter string, starting at the end of the string and working to the front. If maxsplit is given, at most maxsplit splits are done. If sep is not specified or is None, any whitespace string is a separator. """ return s.rsplit(sep, maxsplit) # Join fields with optional separator def join(words, sep = ' '): """join(list [,sep]) -> string Return a string composed of the words in list, with intervening occurrences of sep. The default separator is a single space. (joinfields and join are synonymous) """ return sep.join(words) joinfields = join # Find substring, raise exception if not found def index(s, *args): """index(s, sub [,start [,end]]) -> int Like find but raises ValueError when the substring is not found. """ return s.index(*args) # Find last substring, raise exception if not found def rindex(s, *args): """rindex(s, sub [,start [,end]]) -> int Like rfind but raises ValueError when the substring is not found. """ return s.rindex(*args) # Count non-overlapping occurrences of substring def count(s, *args): """count(s, sub[, start[,end]]) -> int Return the number of occurrences of substring sub in string s[start:end]. Optional arguments start and end are interpreted as in slice notation. """ return s.count(*args) # Find substring, return -1 if not found def find(s, *args): """find(s, sub [,start [,end]]) -> in Return the lowest index in s where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. """ return s.find(*args) # Find last substring, return -1 if not found def rfind(s, *args): """rfind(s, sub [,start [,end]]) -> int Return the highest index in s where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. """ return s.rfind(*args) # for a bit of speed _float = float _int = int _long = long # Convert string to float def atof(s): """atof(s) -> float Return the floating point number represented by the string s. """ return _float(s) # Convert string to integer def atoi(s , base=10): """atoi(s [,base]) -> int Return the integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. """ return _int(s, base) # Convert string to long integer def atol(s, base=10): """atol(s [,base]) -> long Return the long integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. A trailing L or l is not accepted, unless base is 0. """ return _long(s, base) # Left-justify a string def ljust(s, width, *args): """ljust(s, width[, fillchar]) -> string Return a left-justified version of s, in a field of the specified width, padded with spaces as needed. The string is never truncated. If specified the fillchar is used instead of spaces. """ return s.ljust(width, *args) # Right-justify a string def rjust(s, width, *args): """rjust(s, width[, fillchar]) -> string Return a right-justified version of s, in a field of the specified width, padded with spaces as needed. The string is never truncated. If specified the fillchar is used instead of spaces. """ return s.rjust(width, *args) # Center a string def center(s, width, *args): """center(s, width[, fillchar]) -> string Return a center version of s, in a field of the specified width. padded with spaces as needed. The string is never truncated. If specified the fillchar is used instead of spaces. """ return s.center(width, *args) # Zero-fill a number, e.g., (12, 3) --> '012' and (-3, 3) --> '-03' # Decadent feature: the argument may be a string or a number # (Use of this is deprecated; it should be a string as with ljust c.s.) def zfill(x, width): """zfill(x, width) -> string Pad a numeric string x with zeros on the left, to fill a field of the specified width. The string x is never truncated. """ if not isinstance(x, basestring): x = repr(x) return x.zfill(width) # Expand tabs in a string. # Doesn't take non-printing chars into account, but does understand \n. def expandtabs(s, tabsize=8): """expandtabs(s [,tabsize]) -> string Return a copy of the string s with all tab characters replaced by the appropriate number of spaces, depending on the current column, and the tabsize (default 8). """ return s.expandtabs(tabsize) # Character translation through look-up table. def translate(s, table, deletions=""): """translate(s,table [,deletions]) -> string Return a copy of the string s, where all characters occurring in the optional argument deletions are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256. The deletions argument is not allowed for Unicode strings. """ if deletions: return s.translate(table, deletions) else: # Add s[:0] so that if s is Unicode and table is an 8-bit string, # table is converted to Unicode. This means that table *cannot* # be a dictionary -- for that feature, use u.translate() directly. return s.translate(table + s[:0]) # Capitalize a string, e.g. "aBc dEf" -> "Abc def". def capitalize(s): """capitalize(s) -> string Return a copy of the string s with only its first character capitalized. """ return s.capitalize() # Substring replacement (global) def replace(s, old, new, maxsplit=-1): """replace (str, old, new[, maxsplit]) -> string Return a copy of string str with all occurrences of substring old replaced by new. If the optional argument maxsplit is given, only the first maxsplit occurrences are replaced. """ return s.replace(old, new, maxsplit) --- NEW FILE: template.py --- # Copyright (C) 2004 Python Software Foundation # Author: barry@python.org (Barry Warsaw) """A package supporting PEP 292 Simple String Substitutions. See http://www.python.org/peps/pep-0292.html for full specification. Two subclasses of the unicode type are provided: template - PEP 292 'dollar' strings with the following substitution rules: 1. $$ is an escape; it is replaced with a single $ 2. $identifier names a substitution placeholder matching a mapping key of "identifier". "identifier" must be a Python identifier as defined in [2]. The first non-identifier character after the $ character terminates this placeholder specification. 3. ${identifier} is equivalent to $identifier. It is required for when valid identifier characters follow the placeholder but are not part of the placeholder, e.g. "${noun}ification". No other characters have special meaning. [2] Identifiers and Keywords http://www.python.org/doc/current/ref/identifiers.html safe_template - Like templates, except that KeyErrors will never be raised when a placeholder is missing from the interpolation dictionary. You can also derive your own classes from template to define different substitution rules. UTSL for details. Examples: >>> from string import template >>> x = template('$who owes me $what') >>> print x $who owes me $what >>> print x % {'who': 'Tim', 'what': 'a bag of ham'} Tim owes me a bag of ham >>> import re >>> class mstring(template): ... pattern = re.compile( ... r'(\${2})|\$(mm:[_a-z]\w*)|\$({mm:[_a-z]\w*})', re.IGNORECASE) ... >>> x = mstring('$who owes me $mm:what') >>> print x % {'who': 'Tim', 'mm:what', 'nothing'} $who owes me nothing """ __all__ = ['template', 'safe_template'] import re class template(unicode): """A string class for supporting $-substitutions.""" # Search for $$, $identifier, or ${identifier} pattern = re.compile( r'(\${2})|\$([_a-z][_a-z0-9]*)|\${([_a-z][_a-z0-9]*)}', re.IGNORECASE) def __mod__(self, mapping): def convert(mo): escaped, named, braced = mo.groups() if escaped is not None: return '$' else: return mapping[named or braced] return self.pattern.sub(convert, self) class safe_template(template): """A string class for supporting $-substitutions. This class is 'safe' in the sense that you will never get KeyErrors if there are placeholders missing from the interpolation dictionary. In that case, you will get the original placeholder in the value string. """ def __mod__(self, mapping): def convert(mo): escaped, named, braced = mo.groups() if escaped is not None: return '$' elif named is not None: try: return mapping[named] except KeyError: return '$' + named else: try: return mapping[braced] except KeyError: return '${' + braced + '}' return self.pattern.sub(convert, self) Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/string/string/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** __init__.py 14 Jun 2004 17:25:22 -0000 1.1 --- __init__.py 10 Aug 2004 22:27:46 -0000 1.2 *************** *** 2,18 **** # Author: barry@python.org (Barry Warsaw) ! __version__ = '1.0' ! # __all__ either needs to be left out for blanket importation or needs to have ! # something like ``__all__.extend([stuff ! # for stuff from dir(sys.modules['string']) ! # if not stuff.startswith('_')])`` ! #__all__ = [ ! # 'dstring', 'astring', ! # 'safedict', 'nsdict', ! # ] ! from pep292 import dstring, astring ! from safedict import safedict, nsdict ! from string import * --- 2,101 ---- # Author: barry@python.org (Barry Warsaw) ! """The string package. ! Public constants: ! whitespace -- a string containing all characters considered whitespace ! lowercase -- a string containing all characters considered lowercase letters ! uppercase -- a string containing all characters considered uppercase letters ! letters -- a string containing all characters considered letters ! digits -- a string containing all characters considered decimal digits ! hexdigits -- a string containing all characters considered hexadecimal digits ! octdigits -- a string containing all characters considered octal digits ! punctuation -- a string containing all characters considered punctuation ! printable -- a string containing all characters considered printable ! """ ! # Only include non-deprecated attributes in __all__ ! __all__ = [ ! # Constants ! 'whitespace', 'lowercase', 'uppercase', 'letters', ! 'ascii_lowercase', 'ascii_uppercase', 'ascii_letters', ! 'digits', 'hexdigits', 'octdigits', 'punctuation', 'printable', ! # PEP 292 ! 'template', 'safe_template' ! ] ! ! from template import template, safe_template ! from deprecated import * ! ! ! # Constants ! # Some strings for ctype-style character classification ! whitespace = ' \t\n\r\v\f' ! lowercase = 'abcdefghijklmnopqrstuvwxyz' ! uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ! letters = lowercase + uppercase ! ascii_lowercase = lowercase ! ascii_uppercase = uppercase ! ascii_letters = ascii_lowercase + ascii_uppercase ! digits = '0123456789' ! hexdigits = digits + 'abcdef' + 'ABCDEF' ! octdigits = '01234567' ! punctuation = """!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" ! printable = digits + letters + punctuation + whitespace ! ! # Case conversion helpers ! # Use str to convert Unicode literal in case of -U ! # Cookie.py imports this non-public attribute :( ! l = map(chr, xrange(256)) ! _idmap = str('').join(l) ! del l ! ! # Function that aren't methods on string objects, and are thus not yet ! # deprecated. ! ! # Capitalize the words in a string, e.g. " aBc dEf " -> "Abc Def". ! # See also regsub.capwords(). ! def capwords(s, sep=None): ! """capwords(s, [sep]) -> string ! ! Split the argument into words using split, capitalize each ! word using capitalize, and join the capitalized words using ! join. Note that this replaces runs of whitespace characters by ! a single space. ! ! """ ! return join(map(capitalize, s.split(sep)), sep or ' ') ! ! # Construct a translation string ! _idmapL = None ! def maketrans(fromstr, tostr): ! """maketrans(frm, to) -> string ! ! Return a translation table (a string of 256 bytes long) ! suitable for use in string.translate. The strings frm and to ! must be of the same length. ! ! """ ! if len(fromstr) != len(tostr): ! raise ValueError, "maketrans arguments must have same length" ! global _idmapL ! if not _idmapL: ! _idmapL = map(None, _idmap) ! L = _idmapL[:] ! fromstr = map(ord, fromstr) ! for i in range(len(fromstr)): ! L[fromstr[i]] = tostr[i] ! return join(L, "") ! ! ! # Try importing optional built-in module "strop" -- if it exists, ! # it redefines some string operations that are 100-1000 times faster. ! # It also defines values for whitespace, lowercase and uppercase ! # that match 's definitions. ! try: ! from strop import maketrans, lowercase, uppercase, whitespace ! letters = lowercase + uppercase ! except ImportError: ! pass # Use the original versions --- alt292.py DELETED --- --- pep292.py DELETED --- --- safedict.py DELETED --- --- string.py DELETED --- From akuchling at users.sourceforge.net Wed Aug 11 17:05:30 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Aug 11 17:05:33 2004 Subject: [Python-checkins] python/nondist/peps pep-0292.txt,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11465 Modified Files: pep-0292.txt Log Message: Add missing closing apostrophe Index: pep-0292.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0292.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pep-0292.txt 10 Aug 2004 22:19:59 -0000 1.9 --- pep-0292.txt 11 Aug 2004 15:05:26 -0000 1.10 *************** *** 78,82 **** >>> from string import template >>> mapping = dict(name='Guido', country='the Netherlands') ! >>> s = template('${name} was born in ${country}) >>> print s % mapping Guido was born in the Netherlands --- 78,82 ---- >>> from string import template >>> mapping = dict(name='Guido', country='the Netherlands') ! >>> s = template('${name} was born in ${country}') >>> print s % mapping Guido was born in the Netherlands From montanaro at users.sourceforge.net Wed Aug 11 23:00:29 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Aug 11 23:00:36 2004 Subject: [Python-checkins] python/nondist/peps pep-0000.txt, 1.279, 1.280 pep-0305.txt, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18787 Modified Files: pep-0000.txt pep-0305.txt Log Message: marking pep 305 final Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.279 retrieving revision 1.280 diff -C2 -d -r1.279 -r1.280 *** pep-0000.txt 10 Aug 2004 14:31:41 -0000 1.279 --- pep-0000.txt 11 Aug 2004 21:00:24 -0000 1.280 *************** *** 108,112 **** S 303 Extend divmod() for Multiple Divisors Bellman S 304 Controlling Generation of Bytecode Files Montanaro - S 305 CSV File API Montanaro, et al S 310 Reliable Acquisition/Release Pairs Hudson, Moore S 312 Simple Implicit Lambda Suzi, Martelli --- 108,111 ---- *************** *** 163,166 **** --- 162,166 ---- SF 289 Generator Expressions Hettinger SF 293 Codec Error Handling Callbacks Dörwald + SF 305 CSV File API Montanaro, et al SF 307 Extensions to the pickle protocol GvR, Peters SF 311 Simplified GIL Acquisition for Extensions Hammond *************** *** 329,333 **** S 303 Extend divmod() for Multiple Divisors Bellman S 304 Controlling Generation of Bytecode Files Montanaro ! S 305 CSV File API Montanaro, et al I 306 How to Change Python's Grammar Hudson SF 307 Extensions to the pickle protocol GvR, Peters --- 329,333 ---- S 303 Extend divmod() for Multiple Divisors Bellman S 304 Controlling Generation of Bytecode Files Montanaro ! SF 305 CSV File API Montanaro, et al I 306 How to Change Python's Grammar Hudson SF 307 Extensions to the pickle protocol GvR, Peters Index: pep-0305.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0305.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** pep-0305.txt 22 Mar 2003 06:39:54 -0000 1.17 --- pep-0305.txt 11 Aug 2004 21:00:25 -0000 1.18 *************** *** 5,9 **** Author: Kevin Altis, Dave Cole, Andrew McNamara, Skip Montanaro, Cliff Wells Discussions-To: ! Status: Draft Type: Standards Track Content-Type: text/x-rst --- 5,9 ---- Author: Kevin Altis, Dave Cole, Andrew McNamara, Skip Montanaro, Cliff Wells Discussions-To: ! Status: Final Type: Standards Track Content-Type: text/x-rst From edloper at users.sourceforge.net Thu Aug 12 04:02:26 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 12 04:02:30 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.58,1.59 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5381/dist/src/Lib Modified Files: doctest.py Log Message: - Added a register_optionflag function (so users can add their own option flags); and use it to define the existing optionflag constants. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** doctest.py 10 Aug 2004 01:41:28 -0000 1.58 --- doctest.py 12 Aug 2004 02:02:24 -0000 1.59 *************** *** 194,219 **** real_pdb_set_trace = pdb.set_trace - # Option constants. - DONT_ACCEPT_TRUE_FOR_1 = 1 << 0 - DONT_ACCEPT_BLANKLINE = 1 << 1 - NORMALIZE_WHITESPACE = 1 << 2 - ELLIPSIS = 1 << 3 - UNIFIED_DIFF = 1 << 4 - CONTEXT_DIFF = 1 << 5 - - OPTIONFLAGS_BY_NAME = { - 'DONT_ACCEPT_TRUE_FOR_1': DONT_ACCEPT_TRUE_FOR_1, - 'DONT_ACCEPT_BLANKLINE': DONT_ACCEPT_BLANKLINE, - 'NORMALIZE_WHITESPACE': NORMALIZE_WHITESPACE, - 'ELLIPSIS': ELLIPSIS, - 'UNIFIED_DIFF': UNIFIED_DIFF, - 'CONTEXT_DIFF': CONTEXT_DIFF, - } - - # Special string markers for use in `want` strings: - BLANKLINE_MARKER = '' - ELLIPSIS_MARKER = '...' - - # There are 4 basic classes: # - Example: a pair, plus an intra-docstring line number. --- 194,197 ---- *************** *** 235,238 **** --- 213,234 ---- # +---------+ + # Option constants. + OPTIONFLAGS_BY_NAME = {} + def register_optionflag(name): + flag = 1 << len(OPTIONFLAGS_BY_NAME) + OPTIONFLAGS_BY_NAME[name] = flag + return flag + + DONT_ACCEPT_TRUE_FOR_1 = register_optionflag('DONT_ACCEPT_TRUE_FOR_1') + DONT_ACCEPT_BLANKLINE = register_optionflag('DONT_ACCEPT_BLANKLINE') + NORMALIZE_WHITESPACE = register_optionflag('NORMALIZE_WHITESPACE') + ELLIPSIS = register_optionflag('ELLIPSIS') + UNIFIED_DIFF = register_optionflag('UNIFIED_DIFF') + CONTEXT_DIFF = register_optionflag('CONTEXT_DIFF') + + # Special string markers for use in `want` strings: + BLANKLINE_MARKER = '' + ELLIPSIS_MARKER = '...' + ###################################################################### ## Table of Contents From edloper at users.sourceforge.net Thu Aug 12 04:27:46 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 12 04:27:50 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8446/dist/src/Lib/test Modified Files: test_doctest.py Log Message: - Changed option directives to be example-specific. (i.e., they now modify option flags for a single example; they do not turn options on or off.) - Added "indent" and "options" attributes for Example - Got rid of add_newlines param to DocTestParser._parse_example (it's no longer needed; Example's constructor now takes care of it). - Added some docstrings Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** test_doctest.py 9 Aug 2004 16:43:36 -0000 1.17 --- test_doctest.py 12 Aug 2004 02:27:44 -0000 1.18 *************** *** 268,285 **** will return a single test (for that function's docstring): - >>> # Allow ellipsis in the following examples (since the filename - >>> # and line number in the traceback can vary): - >>> doctest: +ELLIPSIS - >>> finder = doctest.DocTestFinder() >>> tests = finder.find(sample_func) ! >>> print tests [] >>> e = tests[0].examples[0] >>> (e.source, e.want, e.lineno) ('print sample_func(22)\n', '44\n', 3) - >>> doctest: -ELLIPSIS # Turn ellipsis back off - If an object has no docstring, then a test is not created for it: --- 268,281 ---- will return a single test (for that function's docstring): >>> finder = doctest.DocTestFinder() >>> tests = finder.find(sample_func) ! ! >>> print tests # doctest: +ELLIPSIS [] + >>> e = tests[0].examples[0] >>> (e.source, e.want, e.lineno) ('print sample_func(22)\n', '44\n', 3) If an object has no docstring, then a test is not created for it: *************** *** 639,646 **** unexpected exception: - >>> # Allow ellipsis in the following examples (since the filename - >>> # and line number in the traceback can vary): - >>> doctest: +ELLIPSIS - >>> def f(x): ... r''' --- 635,638 ---- *************** *** 650,653 **** --- 642,646 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS ********************************************************************** Failure in example: 1/0 *************** *** 658,663 **** ZeroDivisionError: integer division or modulo by zero (1, 1) - - >>> doctest: -ELLIPSIS # Turn ellipsis back off: """ def optionflags(): r""" --- 651,654 ---- *************** *** 864,881 **** Tests of `DocTestRunner`'s option directive mechanism. ! Option directives can be used to turn option flags on or off from ! within a DocTest case. The following example shows how a flag can be ! turned on and off. Note that comments on the same line as the option ! directive are ignored. >>> def f(x): r''' ... >>> print range(10) # Should fail: no ellipsis ... [0, 1, ..., 9] ... ! ... >>> doctest: +ELLIPSIS # turn ellipsis on. ! ... >>> print range(10) # Should succeed ... [0, 1, ..., 9] ... - ... >>> doctest: -ELLIPSIS # turn ellipsis back off. ... >>> print range(10) # Should fail: no ellipsis ... [0, 1, ..., 9] --- 855,909 ---- Tests of `DocTestRunner`'s option directive mechanism. ! Option directives can be used to turn option flags on or off for a ! single example. To turn an option on for an example, follow that ! example with a comment of the form ``# doctest: +OPTION``: >>> def f(x): r''' + ... >>> print range(10) # should fail: no ellipsis + ... [0, 1, ..., 9] + ... + ... >>> print range(10) # doctest: +ELLIPSIS + ... [0, 1, ..., 9] + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + ********************************************************************** + Failure in example: print range(10) # should fail: no ellipsis + from line #1 of f + Expected: [0, 1, ..., 9] + Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + (1, 2) + + To turn an option off for an example, follow that example with a + comment of the form ``# doctest: -OPTION``: + + >>> def f(x): r''' + ... >>> print range(10) + ... [0, 1, ..., 9] + ... + ... >>> # should fail: no ellipsis + ... >>> print range(10) # doctest: -ELLIPSIS + ... [0, 1, ..., 9] + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False, + ... optionflags=doctest.ELLIPSIS).run(test) + ********************************************************************** + Failure in example: print range(10) # doctest: -ELLIPSIS + from line #6 of f + Expected: [0, 1, ..., 9] + Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + (1, 2) + + Option directives affect only the example that they appear with; they + do not change the options for surrounding examples: + + >>> def f(x): r''' ... >>> print range(10) # Should fail: no ellipsis ... [0, 1, ..., 9] ... ! ... >>> print range(10) # doctest: +ELLIPSIS ... [0, 1, ..., 9] ... ... >>> print range(10) # Should fail: no ellipsis ... [0, 1, ..., 9] *************** *** 890,905 **** ********************************************************************** Failure in example: print range(10) # Should fail: no ellipsis ! from line #9 of f Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (2, 3) ! Multiple flags can be toggled by a single option directive: >>> def f(x): r''' ... >>> print range(10) # Should fail ... [0, 1, ..., 9] - ... >>> doctest: +ELLIPSIS +NORMALIZE_WHITESPACE ... >>> print range(10) # Should succeed ... [0, 1, ..., 9] ... ''' --- 918,966 ---- ********************************************************************** Failure in example: print range(10) # Should fail: no ellipsis ! from line #7 of f Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (2, 3) ! Multiple options may be modified by a single option directive. They ! may be separated by whitespace, commas, or both: ! ! >>> def f(x): r''' ! ... >>> print range(10) # Should fail ! ... [0, 1, ..., 9] ! ... >>> print range(10) # Should succeed ! ... ... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE ! ... [0, 1, ..., 9] ! ... ''' ! >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) ! ********************************************************************** ! Failure in example: print range(10) # Should fail ! from line #1 of f ! Expected: [0, 1, ..., 9] ! Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ! (1, 2) ! ! >>> def f(x): r''' ! ... >>> print range(10) # Should fail ! ... [0, 1, ..., 9] ! ... >>> print range(10) # Should succeed ! ... ... # doctest: +ELLIPSIS,+NORMALIZE_WHITESPACE ! ... [0, 1, ..., 9] ! ... ''' ! >>> test = doctest.DocTestFinder().find(f)[0] ! >>> doctest.DocTestRunner(verbose=False).run(test) ! ********************************************************************** ! Failure in example: print range(10) # Should fail ! from line #1 of f ! Expected: [0, 1, ..., 9] ! Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ! (1, 2) >>> def f(x): r''' ... >>> print range(10) # Should fail ... [0, 1, ..., 9] ... >>> print range(10) # Should succeed + ... ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE ... [0, 1, ..., 9] ... ''' *************** *** 912,915 **** --- 973,1042 ---- Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (1, 2) + + The option directive may be put on the line following the source, as + long as a continuation prompt is used: + + >>> def f(x): r''' + ... >>> print range(10) + ... ... # doctest: +ELLIPSIS + ... [0, 1, ..., 9] + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + (0, 1) + + For examples with multi-line source, the option directive may appear + at the end of any line: + + >>> def f(x): r''' + ... >>> for x in range(10): # doctest: +ELLIPSIS + ... ... print x, + ... 0 1 2 ... 9 + ... + ... >>> for x in range(10): + ... ... print x, # doctest: +ELLIPSIS + ... 0 1 2 ... 9 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + (0, 2) + + If more than one line of an example with multi-line source has an + option directive, then they are combined: + + >>> def f(x): r''' + ... Should fail (option directive not on the last line): + ... >>> for x in range(10): # doctest: +ELLIPSIS + ... ... print x, # doctest: +NORMALIZE_WHITESPACE + ... 0 1 2...9 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + (0, 1) + + It is an error to have a comment of the form ``# doctest:`` that is + *not* followed by words of the form ``+OPTION`` or ``-OPTION``, where + ``OPTION`` is an option that has been registered with + `register_option`: + + >>> # Error: Option not registered + >>> s = '>>> print 12 #doctest: +BADOPTION' + >>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) + Traceback (most recent call last): + ValueError: line 1 of the doctest for s has an invalid option: '+BADOPTION' + + >>> # Error: No + or - prefix + >>> s = '>>> print 12 #doctest: ELLIPSIS' + >>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) + Traceback (most recent call last): + ValueError: line 1 of the doctest for s has an invalid option: 'ELLIPSIS' + + It is an error to use an option directive on a line that contains no + source: + + >>> s = '>>> # doctest: +ELLIPSIS' + >>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) + Traceback (most recent call last): + ValueError: line 0 of the doctest for s has an option directive on a line with no example: '# doctest: +ELLIPSIS' """ *************** *** 972,976 **** Run the debugger on the docstring, and then restore sys.stdin. - >>> doctest: +NORMALIZE_WHITESPACE >>> try: ... doctest.debug_src(s) --- 1099,1102 ---- *************** *** 978,981 **** --- 1104,1108 ---- ... sys.stdin = real_stdin ... fake_stdin.close() + ... # doctest: +NORMALIZE_WHITESPACE > (1)?() (Pdb) 12 *************** *** 1020,1025 **** >>> sys.stdin = fake_stdin ! >>> doctest: +ELLIPSIS ! >>> runner.run(test) --Return-- > ...set_trace()->None --- 1147,1151 ---- >>> sys.stdin = fake_stdin ! >>> runner.run(test) # doctest: +ELLIPSIS --Return-- > ...set_trace()->None *************** *** 1058,1062 **** >>> sys.stdin = fake_stdin ! >>> runner.run(test) --Return-- > ...set_trace()->None --- 1184,1188 ---- >>> sys.stdin = fake_stdin ! >>> runner.run(test) # doctest: +ELLIPSIS --Return-- > ...set_trace()->None *************** *** 1069,1074 **** (Pdb) 1 (Pdb) (0, 2) - - >>> doctest: -ELLIPSIS """ --- 1195,1198 ---- From edloper at users.sourceforge.net Thu Aug 12 04:27:47 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 12 04:27:51 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.59,1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8446/dist/src/Lib Modified Files: doctest.py Log Message: - Changed option directives to be example-specific. (i.e., they now modify option flags for a single example; they do not turn options on or off.) - Added "indent" and "options" attributes for Example - Got rid of add_newlines param to DocTestParser._parse_example (it's no longer needed; Example's constructor now takes care of it). - Added some docstrings Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** doctest.py 12 Aug 2004 02:02:24 -0000 1.59 --- doctest.py 12 Aug 2004 02:27:44 -0000 1.60 *************** *** 368,384 **** output. `Example` defines the following attributes: ! - source: A single Python statement, always ending with a newline. The constructor adds a newline if needed. ! - want: The expected output from running the source code (either from stdout, or a traceback in case of exception). `want` ends with a newline unless it's empty, in which case it's an empty string. The constructor adds a newline if needed. ! - lineno: The line number within the DocTest string containing this Example where the Example begins. This line number is zero-based, with respect to the beginning of the DocTest. """ ! def __init__(self, source, want, lineno): # Normalize inputs. if not source.endswith('\n'): --- 368,394 ---- output. `Example` defines the following attributes: ! - source: A single Python statement, always ending with a newline. The constructor adds a newline if needed. ! - want: The expected output from running the source code (either from stdout, or a traceback in case of exception). `want` ends with a newline unless it's empty, in which case it's an empty string. The constructor adds a newline if needed. ! - lineno: The line number within the DocTest string containing this Example where the Example begins. This line number is zero-based, with respect to the beginning of the DocTest. + + - indent: The example's indentation in the DocTest string. + I.e., the number of space characters that preceed the + example's first prompt. + + - options: A dictionary mapping from option flags to True or + False, which is used to override default options for this + example. Any option flags not contained in this dictionary + are left at their default value (as specified by the + DocTestRunner's optionflags). By default, no options are set. """ ! def __init__(self, source, want, lineno, indent=0, options=None): # Normalize inputs. if not source.endswith('\n'): *************** *** 390,393 **** --- 400,406 ---- self.want = want self.lineno = lineno + self.indent = indent + if options is None: options = {} + self.options = options class DocTest: *************** *** 516,526 **** # Update lineno (lines before this example) lineno += string.count('\n', charno, m.start()) - # Extract source/want from the regexp match. (source, want) = self._parse_example(m, name, lineno) if self._IS_BLANK_OR_COMMENT(source): continue ! examples.append( Example(source, want, lineno) ) ! # Update lineno (lines inside this example) lineno += string.count('\n', m.start(), m.end()) --- 529,542 ---- # Update lineno (lines before this example) lineno += string.count('\n', charno, m.start()) # Extract source/want from the regexp match. (source, want) = self._parse_example(m, name, lineno) + # Extract extra options from the source. + options = self._find_options(source, name, lineno) + # If it contains no real source, then ignore it. if self._IS_BLANK_OR_COMMENT(source): continue ! # Create an Example, and add it to the list. ! examples.append( Example(source, want, lineno, ! len(m.group('indent')), options) ) # Update lineno (lines inside this example) lineno += string.count('\n', m.start(), m.end()) *************** *** 579,583 **** # Extract source/want from the regexp match. ! (source, want) = self._parse_example(m, name, lineno, False) # Display the source output.append(source) --- 595,599 ---- # Extract source/want from the regexp match. ! (source, want) = self._parse_example(m, name, lineno) # Display the source output.append(source) *************** *** 601,605 **** return '\n'.join(output) ! def _parse_example(self, m, name, lineno, add_newlines=True): # Get the example's indentation level. indent = len(m.group('indent')) --- 617,631 ---- return '\n'.join(output) ! def _parse_example(self, m, name, lineno): ! """ ! Given a regular expression match from `_EXAMPLE_RE` (`m`), ! return a pair `(source, want)`, where `source` is the matched ! example's source code (with prompts and indentation stripped); ! and `want` is the example's expected output (with indentation ! stripped). ! ! `name` is the string's name, and `lineno` is the line number ! where the example starts; both are used for error messages. ! """ # Get the example's indentation level. indent = len(m.group('indent')) *************** *** 611,616 **** self._check_prefix(source_lines[1:], ' '*indent+'.', name, lineno) source = '\n'.join([sl[indent+4:] for sl in source_lines]) - if len(source_lines) > 1 and add_newlines: - source += '\n' # Divide want into lines; check that it's properly --- 637,640 ---- *************** *** 620,629 **** lineno+len(source_lines)) want = '\n'.join([wl[indent:] for wl in want_lines]) - if len(want) > 0 and add_newlines: - want += '\n' return source, want def _comment_line(self, line): line = line.rstrip() if line: --- 644,688 ---- lineno+len(source_lines)) want = '\n'.join([wl[indent:] for wl in want_lines]) return source, want + # This regular expression looks for option directives in the + # source code of an example. Option directives are comments + # starting with "doctest:". Warning: this may give false + # positives for string-literals that contain the string + # "#doctest:". Eliminating these false positives would require + # actually parsing the string; but we limit them by ignoring any + # line containing "#doctest:" that is *followed* by a quote mark. + _OPTION_DIRECTIVE_RE = re.compile(r'#\s*doctest:\s*([^\n\'"]*)$', + re.MULTILINE) + + def _find_options(self, source, name, lineno): + """ + Return a dictionary containing option overrides extracted from + option directives in the given source string. + + `name` is the string's name, and `lineno` is the line number + where the example starts; both are used for error messages. + """ + options = {} + # (note: with the current regexp, this will match at most once:) + for m in self._OPTION_DIRECTIVE_RE.finditer(source): + option_strings = m.group(1).replace(',', ' ').split() + for option in option_strings: + if (option[0] not in '+-' or + option[1:] not in OPTIONFLAGS_BY_NAME): + raise ValueError('line %r of the doctest for %s ' + 'has an invalid option: %r' % + (lineno+1, name, option)) + flag = OPTIONFLAGS_BY_NAME[option[1:]] + options[flag] = (option[0] == '+') + if options and self._IS_BLANK_OR_COMMENT(source): + raise ValueError('line %r of the doctest for %s has an option ' + 'directive on a line with no example: %r' % + (lineno, name, source)) + return options + def _comment_line(self, line): + "Return a commented form of the given line" line = line.rstrip() if line: *************** *** 633,636 **** --- 692,701 ---- def _check_prompt_blank(self, lines, indent, name, lineno): + """ + Given the lines of a source string (including prompts and + leading indentation), check to make sure that every prompt is + followed by a space character. If any line is not followed by + a space character, then raise ValueError. + """ for i, line in enumerate(lines): if len(line) >= indent+4 and line[indent+3] != ' ': *************** *** 641,644 **** --- 706,713 ---- def _check_prefix(self, lines, prefix, name, lineno): + """ + Check that every line in the given list starts with the given + prefix; if any line does not, then raise a ValueError. + """ for i, line in enumerate(lines): if line and not line.startswith(prefix): *************** *** 1106,1135 **** re.MULTILINE | re.DOTALL) - _OPTION_DIRECTIVE_RE = re.compile('\s*doctest:\s*(?P[^#\n]*)') - - def __handle_directive(self, example): - """ - Check if the given example is actually a directive to doctest - (to turn an optionflag on or off); and if it is, then handle - the directive. - - Return true iff the example is actually a directive (and so - should not be executed). - - """ - m = self._OPTION_DIRECTIVE_RE.match(example.source) - if m is None: - return False - - for flag in m.group('flags').upper().split(): - if (flag[:1] not in '+-' or - flag[1:] not in OPTIONFLAGS_BY_NAME): - raise ValueError('Bad doctest option directive: '+flag) - if flag[0] == '+': - self.optionflags |= OPTIONFLAGS_BY_NAME[flag[1:]] - else: - self.optionflags &= ~OPTIONFLAGS_BY_NAME[flag[1:]] - return True - def __run(self, test, compileflags, out): """ --- 1175,1178 ---- *************** *** 1151,1158 **** # Process each example. for example in test.examples: ! # Check if it's an option directive. If it is, then handle ! # it, and go on to the next example. ! if self.__handle_directive(example): ! continue # Record that we started this example. --- 1194,1205 ---- # Process each example. for example in test.examples: ! # Merge in the example's options. ! self.optionflags = original_optionflags ! if example.options: ! for (optionflag, val) in example.options.items(): ! if val: ! self.optionflags |= optionflag ! else: ! self.optionflags &= ~optionflag # Record that we started this example. *************** *** 1350,1359 **** def check_output(self, want, got, optionflags): """ ! Return True iff the actual output (`got`) matches the expected ! output (`want`). These strings are always considered to match ! if they are identical; but depending on what option flags the ! test runner is using, several non-exact match types are also ! possible. See the documentation for `TestRunner` for more ! information about option flags. """ # Handle the common case first, for efficiency: --- 1397,1407 ---- def check_output(self, want, got, optionflags): """ ! Return True iff the actual output from an example (`got`) ! matches the expected output (`want`). These strings are ! always considered to match if they are identical; but ! depending on what option flags the test runner is using, ! several non-exact match types are also possible. See the ! documentation for `TestRunner` for more information about ! option flags. """ # Handle the common case first, for efficiency: *************** *** 1412,1416 **** """ Return a string describing the differences between the ! expected output (`want`) and the actual output (`got`). """ # If s are being used, then replace --- 1460,1467 ---- """ Return a string describing the differences between the ! expected output for an example (`want`) and the actual output ! (`got`). `optionflags` is the set of option flags used to ! compare `want` and `got`. `indent` is the indentation of the ! original example. """ # If s are being used, then replace From edloper at users.sourceforge.net Thu Aug 12 04:34:32 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 12 04:34:36 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.60,1.61 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9201/dist/src/Lib Modified Files: doctest.py Log Message: - Added __docformat__ - Added comments for some regexps - If the traceback type/message don't match, then still print full traceback in report_failure (not just the first & last lines) - Renamed DocTestRunner.__failure_header -> _failure_header Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** doctest.py 12 Aug 2004 02:27:44 -0000 1.60 --- doctest.py 12 Aug 2004 02:34:27 -0000 1.61 *************** *** 168,171 **** --- 168,172 ---- executed. """ + __docformat__ = 'reStructuredText en' __all__ = [ *************** *** 331,334 **** --- 332,346 ---- return '%s:\n%s\n' % (tag, msg) + def _exception_traceback(exc_info): + """ + Return a string containing a traceback message for the given + exc_info tuple (as returned by sys.exc_info()). + """ + # Get a traceback message. + excout = StringIO() + exc_type, exc_val, exc_tb = exc_info + traceback.print_exception(exc_type, exc_val, exc_tb, file=excout) + return excout.getvalue() + # Override some StringIO methods. class _SpoofOut(StringIO): *************** *** 468,471 **** --- 480,488 ---- A class used to parse strings containing doctest examples. """ + # This regular expression is used to find doctest examples in a + # string. It defines three groups: `source` is the source code + # (including leading indentation and prompts); `indent` is the + # indentation of the first (PS1) line of the source code; and + # `want` is the expected output (including leading indentation). _EXAMPLE_RE = re.compile(r''' # Source consists of a PS1 line followed by zero or more PS2 lines. *************** *** 480,484 **** )*) ''', re.MULTILINE | re.VERBOSE) ! _IS_BLANK_OR_COMMENT = re.compile('^[ ]*(#.*)?$').match def get_doctest(self, string, globs, name, filename, lineno): --- 497,504 ---- )*) ''', re.MULTILINE | re.VERBOSE) ! ! # This regular expression matcher checks if a given string is a ! # blank line or contains a single comment. ! _IS_BLANK_OR_COMMENT = re.compile(r'^[ ]*(#.*)?$').match def get_doctest(self, string, globs, name, filename, lineno): *************** *** 1126,1130 **** """ # Print an error message. ! out(self.__failure_header(test, example) + self._checker.output_difference(example.want, got, self.optionflags)) --- 1146,1150 ---- """ # Print an error message. ! out(self._failure_header(test, example) + self._checker.output_difference(example.want, got, self.optionflags)) *************** *** 1134,1147 **** Report that the given example raised an unexpected exception. """ ! # Get a traceback message. ! excout = StringIO() ! exc_type, exc_val, exc_tb = exc_info ! traceback.print_exception(exc_type, exc_val, exc_tb, file=excout) ! exception_tb = excout.getvalue() ! # Print an error message. ! out(self.__failure_header(test, example) + ! _tag_msg("Exception raised", exception_tb)) ! def __failure_header(self, test, example): s = (self.DIVIDER + "\n" + _tag_msg("Failure in example", example.source)) --- 1154,1161 ---- Report that the given example raised an unexpected exception. """ ! out(self._failure_header(test, example) + ! _tag_msg("Exception raised", _exception_traceback(exc_info))) ! def _failure_header(self, test, example): s = (self.DIVIDER + "\n" + _tag_msg("Failure in example", example.source)) *************** *** 1257,1264 **** # Is +exc_msg the right thing here?? self.report_success(out, test, example, ! got+exc_hdr+exc_msg) else: self.report_failure(out, test, example, ! got+exc_hdr+exc_msg) failures += 1 --- 1271,1278 ---- # Is +exc_msg the right thing here?? self.report_success(out, test, example, ! got+_exception_traceback(exc_info)) else: self.report_failure(out, test, example, ! got+_exception_traceback(exc_info)) failures += 1 From edloper at users.sourceforge.net Thu Aug 12 04:34:32 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 12 04:34:37 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9201/dist/src/Lib/test Modified Files: test_doctest.py Log Message: - Added __docformat__ - Added comments for some regexps - If the traceback type/message don't match, then still print full traceback in report_failure (not just the first & last lines) - Renamed DocTestRunner.__failure_header -> _failure_header Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** test_doctest.py 12 Aug 2004 02:27:44 -0000 1.18 --- test_doctest.py 12 Aug 2004 02:34:27 -0000 1.19 *************** *** 270,277 **** >>> finder = doctest.DocTestFinder() >>> tests = finder.find(sample_func) ! >>> print tests # doctest: +ELLIPSIS [] ! >>> e = tests[0].examples[0] >>> (e.source, e.want, e.lineno) --- 270,277 ---- >>> finder = doctest.DocTestFinder() >>> tests = finder.find(sample_func) ! >>> print tests # doctest: +ELLIPSIS [] ! >>> e = tests[0].examples[0] >>> (e.source, e.want, e.lineno) *************** *** 621,624 **** --- 621,625 ---- >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS ********************************************************************** Failure in example: raise ValueError, 'message' *************** *** 629,632 **** --- 630,634 ---- Got: Traceback (most recent call last): + ... ValueError: message (1, 1) *************** *** 898,902 **** Option directives affect only the example that they appear with; they do not change the options for surrounding examples: ! >>> def f(x): r''' ... >>> print range(10) # Should fail: no ellipsis --- 900,904 ---- Option directives affect only the example that they appear with; they do not change the options for surrounding examples: ! >>> def f(x): r''' ... >>> print range(10) # Should fail: no ellipsis *************** *** 985,989 **** >>> doctest.DocTestRunner(verbose=False).run(test) (0, 1) ! For examples with multi-line source, the option directive may appear at the end of any line: --- 987,991 ---- >>> doctest.DocTestRunner(verbose=False).run(test) (0, 1) ! For examples with multi-line source, the option directive may appear at the end of any line: From edloper at users.sourceforge.net Thu Aug 12 04:41:32 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 12 04:41:35 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10037/dist/src/Lib/test Modified Files: test_doctest.py Log Message: - Changed output of DocTestParser.get_program() to make it easier to visually distinguish the expected output from the comments (use "##" to mark expected outputs, and "#" to mark comments). - If the string given to DocTestParser.get_program() is indented, then strip its indentation. (In particular, find the min indentation of non-blank lines, and strip that indentation from all lines.) Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** test_doctest.py 12 Aug 2004 02:34:27 -0000 1.19 --- test_doctest.py 12 Aug 2004 02:41:30 -0000 1.20 *************** *** 1054,1064 **** >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) ! # Blah blah # print sample_func(22) # Expected: ! # 44 # ! # Yee ha! >>> name = 'test.test_doctest.SampleNewStyleClass' --- 1054,1064 ---- >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) ! # Blah blah # print sample_func(22) # Expected: ! ## 44 # ! # Yee ha! >>> name = 'test.test_doctest.SampleNewStyleClass' *************** *** 1066,1072 **** print '1\n2\n3' # Expected: ! # 1 ! # 2 ! # 3 >>> name = 'test.test_doctest.SampleClass.a_classmethod' --- 1066,1072 ---- print '1\n2\n3' # Expected: ! ## 1 ! ## 2 ! ## 3 >>> name = 'test.test_doctest.SampleClass.a_classmethod' *************** *** 1074,1081 **** print SampleClass.a_classmethod(10) # Expected: ! # 12 print SampleClass(0).a_classmethod(10) # Expected: ! # 12 """ --- 1074,1081 ---- print SampleClass.a_classmethod(10) # Expected: ! ## 12 print SampleClass(0).a_classmethod(10) # Expected: ! ## 12 """ From edloper at users.sourceforge.net Thu Aug 12 04:41:32 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 12 04:41:36 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.61,1.62 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10037/dist/src/Lib Modified Files: doctest.py Log Message: - Changed output of DocTestParser.get_program() to make it easier to visually distinguish the expected output from the comments (use "##" to mark expected outputs, and "#" to mark comments). - If the string given to DocTestParser.get_program() is indented, then strip its indentation. (In particular, find the min indentation of non-blank lines, and strip that indentation from all lines.) Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** doctest.py 12 Aug 2004 02:34:27 -0000 1.61 --- doctest.py 12 Aug 2004 02:41:30 -0000 1.62 *************** *** 596,607 **** print y # Expected: ! # 2 ! # 3 # ! # Some text. x+y # Expected: ! # 5 """ output = [] charnum, lineno = 0, 0 --- 596,613 ---- print y # Expected: ! ## 2 ! ## 3 # ! # Some text. x+y # Expected: ! ## 5 """ + string = string.expandtabs() + # If all lines begin with the same indentation, then strip it. + min_indent = self._min_indent(string) + if min_indent > 0: + string = '\n'.join([l[min_indent:] for l in string.split('\n')]) + output = [] charnum, lineno = 0, 0 *************** *** 621,625 **** if want: output.append('# Expected:') ! output.extend(['# '+l for l in want.split('\n')]) # Update the line number & char number. --- 627,631 ---- if want: output.append('# Expected:') ! output.extend(['## '+l for l in want.split('\n')]) # Update the line number & char number. *************** *** 703,711 **** return options def _comment_line(self, line): "Return a commented form of the given line" line = line.rstrip() if line: ! return '# '+line else: return '#' --- 709,725 ---- return options + # This regular expression finds the indentation of every non-blank + # line in a string. + _INDENT_RE = re.compile('^([ ]+)(?=\S)', re.MULTILINE) + + def _min_indent(self, s): + "Return the minimum indentation of any non-blank line in `s`" + return min([len(indent) for indent in self._INDENT_RE.findall(s)]) + def _comment_line(self, line): "Return a commented form of the given line" line = line.rstrip() if line: ! return '# '+line else: return '#' *************** *** 2180,2200 **** >>> print script_from_examples(text) ! # Here are examples of simple math. # ! # Python has super accurate integer addition # 2 + 2 # Expected: ! # 5 # ! # And very friendly error messages: # 1/0 # Expected: ! # To Infinity ! # And ! # Beyond # ! # You can use logic if you want: # if 0: --- 2194,2214 ---- >>> print script_from_examples(text) ! # Here are examples of simple math. # ! # Python has super accurate integer addition # 2 + 2 # Expected: ! ## 5 # ! # And very friendly error messages: # 1/0 # Expected: ! ## To Infinity ! ## And ! ## Beyond # ! # You can use logic if you want: # if 0: *************** *** 2203,2207 **** # ! # Ho hum """ --- 2217,2221 ---- # ! # Ho hum """ From edloper at users.sourceforge.net Thu Aug 12 04:43:52 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 12 04:43:54 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.62,1.63 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10417/dist/src/Lib Modified Files: doctest.py Log Message: In output_difference(), replace blank lines in `want` with (rather than replacing with blank lines in `got`). This makes it easier to see what's intended. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** doctest.py 12 Aug 2004 02:41:30 -0000 1.62 --- doctest.py 12 Aug 2004 02:43:49 -0000 1.63 *************** *** 1493,1500 **** original example. """ ! # If s are being used, then replace ! # with blank lines in the expected output string. if not (optionflags & DONT_ACCEPT_BLANKLINE): ! want = re.sub('(?m)^%s$' % re.escape(BLANKLINE_MARKER), '', want) # Check if we should use diff. Don't use diff if the actual --- 1493,1500 ---- original example. """ ! # If s are being used, then replace blank lines ! # with in the actual output string. if not (optionflags & DONT_ACCEPT_BLANKLINE): ! got = re.sub('(?m)^[ ]*(?=\n)', BLANKLINE_MARKER, got) # Check if we should use diff. Don't use diff if the actual From loewis at users.sourceforge.net Thu Aug 12 15:14:24 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 12 15:14:27 2004 Subject: [Python-checkins] python/dist/src/Lib/idlelib IOBinding.py, 1.19.8.3, 1.19.8.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11209 Modified Files: Tag: release23-maint IOBinding.py Log Message: Ignore the locale's encoding if it is an empty string. Index: IOBinding.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/IOBinding.py,v retrieving revision 1.19.8.3 retrieving revision 1.19.8.4 diff -C2 -d -r1.19.8.3 -r1.19.8.4 *** IOBinding.py 25 Nov 2003 05:06:56 -0000 1.19.8.3 --- IOBinding.py 12 Aug 2004 13:14:20 -0000 1.19.8.4 *************** *** 49,53 **** # these problems, falling back to ASCII encoding = locale.nl_langinfo(locale.CODESET) ! if encoding is None: # situation occurs on Mac OS X encoding = 'ascii' --- 49,53 ---- # these problems, falling back to ASCII encoding = locale.nl_langinfo(locale.CODESET) ! if encoding is None or encoding is '': # situation occurs on Mac OS X encoding = 'ascii' *************** *** 59,63 **** try: encoding = locale.getdefaultlocale()[1] ! if encoding is None: # situation occurs on Mac OS X encoding = 'ascii' --- 59,63 ---- try: encoding = locale.getdefaultlocale()[1] ! if encoding is None or encoding is '': # situation occurs on Mac OS X encoding = 'ascii' From loewis at users.sourceforge.net Thu Aug 12 15:14:55 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 12 15:14:57 2004 Subject: [Python-checkins] python/dist/src/Lib/idlelib IOBinding.py, 1.23, 1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11377 Modified Files: IOBinding.py Log Message: Patch #808719: Ignore the locale's encoding if it is an empty string. Backported to 2.3. Index: IOBinding.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/IOBinding.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** IOBinding.py 11 Apr 2004 03:16:07 -0000 1.23 --- IOBinding.py 12 Aug 2004 13:14:52 -0000 1.24 *************** *** 49,53 **** # these problems, falling back to ASCII encoding = locale.nl_langinfo(locale.CODESET) ! if encoding is None: # situation occurs on Mac OS X encoding = 'ascii' --- 49,53 ---- # these problems, falling back to ASCII encoding = locale.nl_langinfo(locale.CODESET) ! if encoding is None or encoding is '': # situation occurs on Mac OS X encoding = 'ascii' *************** *** 59,63 **** try: encoding = locale.getdefaultlocale()[1] ! if encoding is None: # situation occurs on Mac OS X encoding = 'ascii' --- 59,63 ---- try: encoding = locale.getdefaultlocale()[1] ! if encoding is None or encoding is '': # situation occurs on Mac OS X encoding = 'ascii' From loewis at users.sourceforge.net Thu Aug 12 15:17:14 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 12 15:17:16 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.136, 1.831.4.137 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11867 Modified Files: Tag: release23-maint NEWS Log Message: Patch #808719: Ignore locale's encoding in IDLE if it is an empty string. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.136 retrieving revision 1.831.4.137 diff -C2 -d -r1.831.4.136 -r1.831.4.137 *** NEWS 3 Aug 2004 19:13:18 -0000 1.831.4.136 --- NEWS 12 Aug 2004 13:17:11 -0000 1.831.4.137 *************** *** 44,47 **** --- 44,49 ---- ------- + - Patch #808719: Ignore locale's encoding in IDLE if it is an empty string. + - Patch #946153: Add wait_visibility before grab_set. From loewis at users.sourceforge.net Thu Aug 12 15:26:36 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 12 15:26:40 2004 Subject: [Python-checkins] python/dist/src/Modules resource.c, 2.31, 2.31.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13795/Modules Modified Files: Tag: release23-maint resource.c Log Message: Patch #1005568: Use _SC_PAGESIZE on Irix. Index: resource.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/resource.c,v retrieving revision 2.31 retrieving revision 2.31.10.1 diff -C2 -d -r2.31 -r2.31.10.1 *** resource.c 30 Mar 2003 20:51:29 -0000 2.31 --- resource.c 12 Aug 2004 13:26:33 -0000 2.31.10.1 *************** *** 203,207 **** --- 203,212 ---- pagesize = getpagesize(); #elif defined(HAVE_SYSCONF) + #if defined(_SC_PAGE_SIZE) pagesize = sysconf(_SC_PAGE_SIZE); + #else + /* Irix 5.3 has _SC_PAGESIZE, but not _SC_PAGE_SIZE */ + pagesize = sysconf(_SC_PAGESIZE); + #endif #endif return Py_BuildValue("i", pagesize); From loewis at users.sourceforge.net Thu Aug 12 15:26:45 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 12 15:26:48 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.137, 1.831.4.138 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13795/Misc Modified Files: Tag: release23-maint NEWS Log Message: Patch #1005568: Use _SC_PAGESIZE on Irix. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.137 retrieving revision 1.831.4.138 diff -C2 -d -r1.831.4.137 -r1.831.4.138 *** NEWS 12 Aug 2004 13:17:11 -0000 1.831.4.137 --- NEWS 12 Aug 2004 13:26:33 -0000 1.831.4.138 *************** *** 29,32 **** --- 29,34 ---- ----------------- + - Patch #1005568: Use _SC_PAGESIZE on Irix in resourcemoudle. + - Patch #924294: Do no check for AF_INET6 if it is not defined. From loewis at users.sourceforge.net Thu Aug 12 15:26:59 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 12 15:27:02 2004 Subject: [Python-checkins] python/dist/src/Modules resource.c,2.31,2.32 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13901/Modules Modified Files: resource.c Log Message: Patch #1005568: Use _SC_PAGESIZE on Irix. Backported to 2.3. Index: resource.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/resource.c,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -d -r2.31 -r2.32 *** resource.c 30 Mar 2003 20:51:29 -0000 2.31 --- resource.c 12 Aug 2004 13:26:56 -0000 2.32 *************** *** 203,207 **** --- 203,212 ---- pagesize = getpagesize(); #elif defined(HAVE_SYSCONF) + #if defined(_SC_PAGE_SIZE) pagesize = sysconf(_SC_PAGE_SIZE); + #else + /* Irix 5.3 has _SC_PAGESIZE, but not _SC_PAGE_SIZE */ + pagesize = sysconf(_SC_PAGESIZE); + #endif #endif return Py_BuildValue("i", pagesize); From loewis at users.sourceforge.net Thu Aug 12 15:44:49 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 12 15:44:52 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.138, 1.831.4.139 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17406/Misc Modified Files: Tag: release23-maint NEWS Log Message: Define _BSD_TYPES. Fixes #1005308. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.138 retrieving revision 1.831.4.139 diff -C2 -d -r1.831.4.138 -r1.831.4.139 *** NEWS 12 Aug 2004 13:26:33 -0000 1.831.4.138 --- NEWS 12 Aug 2004 13:44:45 -0000 1.831.4.139 *************** *** 29,32 **** --- 29,34 ---- ----------------- + - Bug #1005308: Define _BSD_TYPES. + - Patch #1005568: Use _SC_PAGESIZE on Irix in resourcemoudle. From loewis at users.sourceforge.net Thu Aug 12 15:44:57 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 12 15:45:03 2004 Subject: [Python-checkins] python/dist/src configure, 1.416.4.14, 1.416.4.15 configure.in, 1.427.4.13, 1.427.4.14 pyconfig.h.in, 1.83.4.4, 1.83.4.5 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17406 Modified Files: Tag: release23-maint configure configure.in pyconfig.h.in Log Message: Define _BSD_TYPES. Fixes #1005308. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.416.4.14 retrieving revision 1.416.4.15 diff -C2 -d -r1.416.4.14 -r1.416.4.15 *** configure 7 May 2004 19:13:40 -0000 1.416.4.14 --- configure 12 Aug 2004 13:44:25 -0000 1.416.4.15 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.427.4.12 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for python 2.3. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.427.4.13 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for python 2.3. *************** *** 1350,1353 **** --- 1350,1361 ---- + # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables + # u_int on Irix 5.3. Defining _BSD_TYPES brings it back. + + cat >>confdefs.h <<\_ACEOF + #define _BSD_TYPES 1 + _ACEOF + + define_xopen_source=yes Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.427.4.13 retrieving revision 1.427.4.14 diff -C2 -d -r1.427.4.13 -r1.427.4.14 *** configure.in 7 May 2004 19:13:47 -0000 1.427.4.13 --- configure.in 12 Aug 2004 13:44:44 -0000 1.427.4.14 *************** *** 51,54 **** --- 51,58 ---- 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]) + define_xopen_source=yes Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.83.4.4 retrieving revision 1.83.4.5 diff -C2 -d -r1.83.4.4 -r1.83.4.5 *** pyconfig.h.in 22 Mar 2004 20:20:32 -0000 1.83.4.4 --- pyconfig.h.in 12 Aug 2004 13:44:44 -0000 1.83.4.5 *************** *** 824,827 **** --- 824,830 ---- #endif + /* Define on Irix to enable u_int */ + #undef _BSD_TYPES + /* This must be set to 64 on some systems to enable large file support. */ #undef _FILE_OFFSET_BITS From loewis at users.sourceforge.net Thu Aug 12 15:45:11 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 12 15:45:14 2004 Subject: [Python-checkins] python/dist/src configure, 1.451, 1.452 configure.in, 1.464, 1.465 pyconfig.h.in, 1.102, 1.103 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17447 Modified Files: configure configure.in pyconfig.h.in Log Message: Define _BSD_TYPES. Fixes #1005308. Backported to 2.3. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.451 retrieving revision 1.452 diff -C2 -d -r1.451 -r1.452 *** configure 16 Jul 2004 08:43:47 -0000 1.451 --- configure 12 Aug 2004 13:45:08 -0000 1.452 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.462 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for python 2.4. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.464 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for python 2.4. *************** *** 1348,1351 **** --- 1348,1359 ---- + # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables + # u_int on Irix 5.3. Defining _BSD_TYPES brings it back. + + cat >>confdefs.h <<\_ACEOF + #define _BSD_TYPES 1 + _ACEOF + + define_xopen_source=yes *************** *** 12352,12357 **** ! for ac_func in alarm chown clock confstr ctermid execv \ ! fork fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ getpriority getpwent getsid getwd \ --- 12360,12366 ---- ! ! for ac_func in alarm bind_textdomain_codeset chown clock confstr ctermid \ ! execv fork fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ getpriority getpwent getsid getwd \ *************** *** 15593,15596 **** --- 15602,15656 ---- echo "${ECHO_T}$works" >&6 + # check for socketpair + echo "$as_me:$LINENO: checking for socketpair" >&5 + echo $ECHO_N "checking for socketpair... $ECHO_C" >&6 + cat >conftest.$ac_ext <<_ACEOF + #line $LINENO "configure" + /* confdefs.h. */ + _ACEOF + cat confdefs.h >>conftest.$ac_ext + cat >>conftest.$ac_ext <<_ACEOF + /* end confdefs.h. */ + + #include + #include + + int + main () + { + void *x=socketpair + ; + return 0; + } + _ACEOF + rm -f conftest.$ac_objext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + cat >>confdefs.h <<\_ACEOF + #define HAVE_SOCKETPAIR 1 + _ACEOF + + echo "$as_me:$LINENO: result: yes" >&5 + echo "${ECHO_T}yes" >&6 + else + echo "$as_me: failed program was:" >&5 + sed 's/^/| /' conftest.$ac_ext >&5 + + echo "$as_me:$LINENO: result: no" >&5 + echo "${ECHO_T}no" >&6 + + fi + rm -f conftest.$ac_objext conftest.$ac_ext + # check if sockaddr has sa_len member echo "$as_me:$LINENO: checking if sockaddr has sa_len member" >&5 Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.464 retrieving revision 1.465 diff -C2 -d -r1.464 -r1.465 *** configure.in 9 Aug 2004 04:51:39 -0000 1.464 --- configure.in 12 Aug 2004 13:45:08 -0000 1.465 *************** *** 51,54 **** --- 51,58 ---- 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]) + define_xopen_source=yes Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** pyconfig.h.in 9 Aug 2004 04:51:40 -0000 1.102 --- pyconfig.h.in 12 Aug 2004 13:45:08 -0000 1.103 *************** *** 429,435 **** #undef HAVE_SNPRINTF - /* Define to 1 if you have the `socketpair' function. */ - #undef HAVE_SOCKETPAIR - /* Define if sockaddr has sa_len member */ #undef HAVE_SOCKADDR_SA_LEN --- 429,432 ---- *************** *** 438,441 **** --- 435,441 ---- #undef HAVE_SOCKADDR_STORAGE + /* Define if you have the 'socketpair' function. */ + #undef HAVE_SOCKETPAIR + /* Define to 1 if you have the `statvfs' function. */ #undef HAVE_STATVFS *************** *** 807,810 **** --- 807,813 ---- #endif + /* Define on Irix to enable u_int */ + #undef _BSD_TYPES + /* This must be set to 64 on some systems to enable large file support. */ #undef _FILE_OFFSET_BITS From loewis at users.sourceforge.net Thu Aug 12 16:07:53 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 12 16:07:56 2004 Subject: [Python-checkins] python/dist/src/PCbuild _bsddb.vcproj, 1.3, 1.4 _socket.vcproj, 1.3, 1.4 _tkinter.vcproj, 1.3, 1.4 make_versioninfo.vcproj, 1.3, 1.4 pyexpat.vcproj, 1.3, 1.4 python.vcproj, 1.3, 1.4 select.vcproj, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21218 Modified Files: _bsddb.vcproj _socket.vcproj _tkinter.vcproj make_versioninfo.vcproj pyexpat.vcproj python.vcproj select.vcproj Log Message: Patch #1006916: Remove ODBC library references. Index: _bsddb.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/_bsddb.vcproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** _bsddb.vcproj 20 Jul 2004 14:37:47 -0000 1.3 --- _bsddb.vcproj 12 Aug 2004 14:07:49 -0000 1.4 *************** *** 37,41 **** Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28376/Python Modified Files: bltinmodule.c Log Message: Patch #1005468: Disambiguate "min() or max()" exception string. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.316 retrieving revision 2.317 diff -C2 -d -r2.316 -r2.317 *** bltinmodule.c 7 Aug 2004 19:20:05 -0000 2.316 --- bltinmodule.c 12 Aug 2004 14:42:37 -0000 2.317 *************** *** 1117,1125 **** min_max(PyObject *args, int op) { PyObject *v, *w, *x, *it; if (PyTuple_Size(args) > 1) v = args; ! else if (!PyArg_UnpackTuple(args, (op==Py_LT) ? "min" : "max", 1, 1, &v)) return NULL; --- 1117,1126 ---- min_max(PyObject *args, int op) { + const char *name = op == Py_LT ? "min" : "max"; PyObject *v, *w, *x, *it; if (PyTuple_Size(args) > 1) v = args; ! else if (!PyArg_UnpackTuple(args, (char *)name, 1, 1, &v)) return NULL; *************** *** 1159,1164 **** } if (w == NULL) ! PyErr_SetString(PyExc_ValueError, ! "min() or max() arg is an empty sequence"); Py_DECREF(it); return w; --- 1160,1165 ---- } if (w == NULL) ! PyErr_Format(PyExc_ValueError, ! "%s() arg is an empty sequence", name); Py_DECREF(it); return w; From mwh at users.sourceforge.net Thu Aug 12 19:56:31 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Aug 12 19:56:39 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.314,2.315 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31215/Python Modified Files: compile.c Log Message: Fix bug [ 1005248 ] new.code() not cleanly checking its arguments using the result of new.code() can still destroy the sun, but merely calling the function shouldn't any more. I also rewrote the existing tests of new.code() to use vastly less un-bogus arguments, and added tests for the previous insane behaviours. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.314 retrieving revision 2.315 diff -C2 -d -r2.314 -r2.315 *** compile.c 6 Aug 2004 19:46:34 -0000 2.314 --- compile.c 12 Aug 2004 17:56:20 -0000 2.315 *************** *** 89,92 **** --- 89,136 ---- }; + /* Helper for code_new: return a shallow copy of a tuple that is + guaranteed to contain exact strings, by converting string subclasses + to exact strings and complaining if a non-string is found. */ + static PyObject* + validate_and_copy_tuple(PyObject *tup) + { + PyObject *newtuple; + PyObject *item; + int i, len; + + len = PyTuple_GET_SIZE(tup); + newtuple = PyTuple_New(len); + if (newtuple == NULL) + return NULL; + + for (i = 0; i < len; i++) { + item = PyTuple_GET_ITEM(tup, i); + if (PyString_CheckExact(item)) { + Py_INCREF(item); + } + else if (!PyString_Check(item)) { + PyErr_Format( + PyExc_TypeError, + "name tuples must contain only " + "strings, not '%.500s'", + item->ob_type->tp_name); + Py_DECREF(newtuple); + return NULL; + } + else { + item = PyString_FromStringAndSize( + PyString_AS_STRING(item), + PyString_GET_SIZE(item)); + if (item == NULL) { + Py_DECREF(newtuple); + return NULL; + } + } + PyTuple_SET_ITEM(newtuple, i, item); + } + + return newtuple; + } + PyDoc_STRVAR(code_doc, "code(argcount, nlocals, stacksize, flags, codestring, constants, names,\n\ *************** *** 102,113 **** int stacksize; int flags; ! PyObject *co; ! PyObject *empty = NULL; PyObject *code; PyObject *consts; ! PyObject *names; ! PyObject *varnames; ! PyObject *freevars = NULL; ! PyObject *cellvars = NULL; PyObject *filename; PyObject *name; --- 146,156 ---- int stacksize; int flags; ! PyObject *co = NULL;; PyObject *code; PyObject *consts; ! PyObject *names, *ournames = NULL; ! PyObject *varnames, *ourvarnames = NULL; ! PyObject *freevars = NULL, *ourfreevars = NULL; ! PyObject *cellvars = NULL, *ourcellvars = NULL; PyObject *filename; PyObject *name; *************** *** 127,151 **** return NULL; ! if (!PyObject_CheckReadBuffer(code)) { ! PyErr_SetString(PyExc_TypeError, ! "bytecode object must be a single-segment read-only buffer"); ! return NULL; } ! if (freevars == NULL || cellvars == NULL) { ! empty = PyTuple_New(0); ! if (empty == NULL) ! return NULL; ! if (freevars == NULL) ! freevars = empty; ! if (cellvars == NULL) ! cellvars = empty; } co = (PyObject *) PyCode_New(argcount, nlocals, stacksize, flags, ! code, consts, names, varnames, ! freevars, cellvars, filename, name, ! firstlineno, lnotab); ! Py_XDECREF(empty); return co; } --- 170,215 ---- return NULL; ! if (argcount < 0) { ! PyErr_SetString( ! PyExc_ValueError, ! "code: argcount must not be negative"); ! goto cleanup; } ! if (nlocals < 0) { ! PyErr_SetString( ! PyExc_ValueError, ! "code: nlocals must not be negative"); ! goto cleanup; } + ournames = validate_and_copy_tuple(names); + if (ournames == NULL) + goto cleanup; + ourvarnames = validate_and_copy_tuple(varnames); + if (ourvarnames == NULL) + goto cleanup; + if (freevars) + ourfreevars = validate_and_copy_tuple(freevars); + else + ourfreevars = PyTuple_New(0); + if (ourfreevars == NULL) + goto cleanup; + if (cellvars) + ourcellvars = validate_and_copy_tuple(cellvars); + else + ourcellvars = PyTuple_New(0); + if (ourcellvars == NULL) + goto cleanup; + co = (PyObject *) PyCode_New(argcount, nlocals, stacksize, flags, ! code, consts, ournames, ourvarnames, ! ourfreevars, ourcellvars, filename, ! name, firstlineno, lnotab); ! cleanup: ! Py_XDECREF(ournames); ! Py_XDECREF(ourvarnames); ! Py_XDECREF(ourfreevars); ! Py_XDECREF(ourcellvars); return co; } *************** *** 303,307 **** } ! static int intern_strings(PyObject *tuple) { --- 367,371 ---- } ! static void intern_strings(PyObject *tuple) { *************** *** 310,321 **** for (i = PyTuple_GET_SIZE(tuple); --i >= 0; ) { PyObject *v = PyTuple_GET_ITEM(tuple, i); ! if (v == NULL || !PyString_Check(v)) { Py_FatalError("non-string found in code slot"); - PyErr_BadInternalCall(); - return -1; } PyString_InternInPlace(&PyTuple_GET_ITEM(tuple, i)); } - return 0; } --- 374,382 ---- for (i = PyTuple_GET_SIZE(tuple); --i >= 0; ) { PyObject *v = PyTuple_GET_ITEM(tuple, i); ! if (v == NULL || !PyString_CheckExact(v)) { Py_FatalError("non-string found in code slot"); } PyString_InternInPlace(&PyTuple_GET_ITEM(tuple, i)); } } From mwh at users.sourceforge.net Thu Aug 12 19:56:32 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Aug 12 19:56:42 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_new.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31215/Lib/test Modified Files: test_new.py Log Message: Fix bug [ 1005248 ] new.code() not cleanly checking its arguments using the result of new.code() can still destroy the sun, but merely calling the function shouldn't any more. I also rewrote the existing tests of new.code() to use vastly less un-bogus arguments, and added tests for the previous insane behaviours. Index: test_new.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_new.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** test_new.py 12 Jun 2004 16:30:32 -0000 1.17 --- test_new.py 12 Aug 2004 17:56:29 -0000 1.18 *************** *** 1,3 **** ! from test.test_support import verbose, verify import sys import new --- 1,3 ---- ! from test.test_support import verbose, verify, TestFailed import sys import new *************** *** 100,109 **** # Note: Jython will never have new.code() if hasattr(new, 'code'): ! # XXX should use less criminally bogus arguments! ! d = new.code(3, 3, 3, 3, codestr, (), (), (), ! "", "", 1, "", (), ()) # test backwards-compatibility version with no freevars or cellvars ! d = new.code(3, 3, 3, 3, codestr, (), (), (), ! "", "", 1, "") if verbose: print d --- 100,165 ---- # Note: Jython will never have new.code() if hasattr(new, 'code'): ! def f(a): pass ! ! c = f.func_code ! argcount = c.co_argcount ! nlocals = c.co_nlocals ! stacksize = c.co_stacksize ! flags = c.co_flags ! codestring = c.co_code ! constants = c.co_consts ! names = c.co_names ! varnames = c.co_varnames ! filename = c.co_filename ! name = c.co_name ! firstlineno = c.co_firstlineno ! lnotab = c.co_lnotab ! freevars = c.co_freevars ! cellvars = c.co_cellvars ! ! d = new.code(argcount, nlocals, stacksize, flags, codestring, ! constants, names, varnames, filename, name, ! firstlineno, lnotab, freevars, cellvars) ! # test backwards-compatibility version with no freevars or cellvars ! d = new.code(argcount, nlocals, stacksize, flags, codestring, ! constants, names, varnames, filename, name, ! firstlineno, lnotab) ! ! try: # this used to trigger a SystemError ! d = new.code(-argcount, nlocals, stacksize, flags, codestring, ! constants, names, varnames, filename, name, ! firstlineno, lnotab) ! except ValueError: ! pass ! else: ! raise TestFailed, "negative co_argcount didn't trigger an exception" ! ! try: # this used to trigger a SystemError ! d = new.code(argcount, -nlocals, stacksize, flags, codestring, ! constants, names, varnames, filename, name, ! firstlineno, lnotab) ! except ValueError: ! pass ! else: ! raise TestFailed, "negative co_nlocals didn't trigger an exception" ! ! try: # this used to trigger a Py_FatalError! ! d = new.code(argcount, nlocals, stacksize, flags, codestring, ! constants, (5,), varnames, filename, name, ! firstlineno, lnotab) ! except TypeError: ! pass ! else: ! raise TestFailed, "non-string co_name didn't trigger an exception" ! ! # new.code used to be a way to mutate a tuple... ! class S(str): pass ! t = (S("ab"),) ! d = new.code(argcount, nlocals, stacksize, flags, codestring, ! constants, t, varnames, filename, name, ! firstlineno, lnotab) ! verify(type(t[0]) is S, "eek, tuple changed under us!") ! if verbose: print d From mwh at users.sourceforge.net Thu Aug 12 20:09:05 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Aug 12 20:09:08 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1081,1.1082 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1347 Modified Files: NEWS Log Message: A NEWS entry for my last checked in change (I've gotten out of the habit of these, sorry). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1081 retrieving revision 1.1082 diff -C2 -d -r1.1081 -r1.1082 *** NEWS 9 Aug 2004 04:51:41 -0000 1.1081 --- NEWS 12 Aug 2004 18:09:00 -0000 1.1082 *************** *** 13,16 **** --- 13,21 ---- ----------------- + - code_new (a.k.a new.code()) now checks its arguments sufficiently + carefully that passing them on to PyCode_New() won't trigger calls + to Py_FatalError() or PyErr_BadInternalCall(). It is still the case + that the returned code object might be entirely insane. + - Subclasses of string can no longer be interned. The semantics of interning were not clear here -- a subclass could be mutable, for From mwh at users.sourceforge.net Thu Aug 12 20:12:46 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Aug 12 20:12:49 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.162, 1.163 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2096/Doc/lib Modified Files: libstdtypes.tex Log Message: This is my patch [ 1004703 ] Make func_name writable plus fixing a couple of nits in the documentation changes spotted by MvL and a Misc/NEWS entry. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.162 retrieving revision 1.163 diff -C2 -d -r1.162 -r1.163 *** libstdtypes.tex 7 Aug 2004 16:41:34 -0000 1.162 --- libstdtypes.tex 12 Aug 2004 18:12:43 -0000 1.163 *************** *** 1683,1705 **** different object types. ! The implementation adds two special read-only attributes: ! \code{\var{f}.func_code} is a function's \dfn{code ! object}\obindex{code} (see below) and \code{\var{f}.func_globals} is ! the dictionary used as the function's global namespace (this is the ! same as \code{\var{m}.__dict__} where \var{m} is the module in which ! the function \var{f} was defined). ! ! 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. \emph{Note that the current implementation only supports ! function attributes on user-defined functions. Function attributes on ! built-in functions may be supported in the future.} ! ! Functions have another special attribute \code{\var{f}.__dict__} ! (a.k.a. \code{\var{f}.func_dict}) which contains the namespace used to ! support function attributes. \code{__dict__} and \code{func_dict} can ! be accessed directly or set to a dictionary object. A function's ! dictionary cannot be deleted. \subsubsection{Methods \label{typesmethods}} --- 1683,1688 ---- different object types. ! See the \citetitle[../ref/ref.html]{Python Reference Manual} for more ! information. \subsubsection{Methods \label{typesmethods}} From mwh at users.sourceforge.net Thu Aug 12 20:12:46 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Aug 12 20:12:51 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_funcattrs.py, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2096/Lib/test Modified Files: test_funcattrs.py Log Message: This is my patch [ 1004703 ] Make func_name writable plus fixing a couple of nits in the documentation changes spotted by MvL and a Misc/NEWS entry. Index: test_funcattrs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_funcattrs.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_funcattrs.py 31 Jan 2003 18:33:17 -0000 1.13 --- test_funcattrs.py 12 Aug 2004 18:12:43 -0000 1.14 *************** *** 269,274 **** verify(f.__name__ == "f") verify(f.func_name == "f") ! cantset(f, "func_name", "f") ! cantset(f, "__name__", "f") def test_func_code(): --- 269,281 ---- verify(f.__name__ == "f") verify(f.func_name == "f") ! f.__name__ = "g" ! verify(f.__name__ == "g") ! verify(f.func_name == "g") ! f.func_name = "h" ! verify(f.__name__ == "h") ! verify(f.func_name == "h") ! cantset(f, "func_globals", 1) ! cantset(f, "__name__", 1) ! def test_func_code(): From mwh at users.sourceforge.net Thu Aug 12 20:12:47 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Aug 12 20:12:52 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1082,1.1083 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2096/Misc Modified Files: NEWS Log Message: This is my patch [ 1004703 ] Make func_name writable plus fixing a couple of nits in the documentation changes spotted by MvL and a Misc/NEWS entry. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1082 retrieving revision 1.1083 diff -C2 -d -r1.1082 -r1.1083 *** NEWS 12 Aug 2004 18:09:00 -0000 1.1082 --- NEWS 12 Aug 2004 18:12:44 -0000 1.1083 *************** *** 13,16 **** --- 13,19 ---- ----------------- + - The ``func_name`` (a.k.a. ``__name__``) attribute of user-defined + functions is now writable. + - code_new (a.k.a new.code()) now checks its arguments sufficiently carefully that passing them on to PyCode_New() won't trigger calls From mwh at users.sourceforge.net Thu Aug 12 20:12:46 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Aug 12 20:12:53 2004 Subject: [Python-checkins] python/dist/src/Doc/ref ref3.tex,1.120,1.121 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2096/Doc/ref Modified Files: ref3.tex Log Message: This is my patch [ 1004703 ] Make func_name writable plus fixing a couple of nits in the documentation changes spotted by MvL and a Misc/NEWS entry. Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** ref3.tex 29 Jun 2004 04:14:02 -0000 1.120 --- ref3.tex 12 Aug 2004 18:12:43 -0000 1.121 *************** *** 434,459 **** \obindex{user-defined function} ! Special attributes: \member{func_doc} or \member{__doc__} is the ! function's documentation string, or \code{None} if unavailable; ! \member{func_name} or \member{__name__} is the function's name; ! \member{__module__} is the name of the module the function was defined ! in, or \code{None} if unavailable; ! \member{func_defaults} is a tuple containing default argument values for ! those arguments that have defaults, or \code{None} if no arguments ! have a default value; \member{func_code} is the code object representing ! the compiled function body; \member{func_globals} is (a reference to) ! the dictionary that holds the function's global variables --- it ! defines the global namespace of the module in which the function was ! defined; \member{func_dict} or \member{__dict__} contains the ! namespace supporting arbitrary function attributes; ! \member{func_closure} is \code{None} or a tuple of cells that contain ! bindings for the function's free variables. ! Of these, \member{func_code}, \member{func_defaults}, ! \member{func_doc}/\member{__doc__}, and ! \member{func_dict}/\member{__dict__} may be writable; the ! others can never be changed. Additional information about a ! function's definition can be retrieved from its code object; see the ! description of internal types below. \withsubitem{(function attribute)}{ --- 434,486 ---- \obindex{user-defined function} ! Special attributes: ! \begin{tableiii}{lll}{member}{Attribute}{Meaning}{} ! \lineiii{func_doc}{The function's documentation string, or ! \code{None} if unavailable}{Writable} ! ! \lineiii{__doc__}{Another way of spelling ! \member{func_doc}}{Writable} ! ! \lineiii{func_name}{The function's name}{Writable} ! ! \lineiii{__name__}{Another way of spelling ! \member{func_name}}{Writable} ! ! \lineiii{__module__}{The name of the module the function was defined ! in, or \code{None} if unavailable.}{Writable} ! ! \lineiii{func_defaults}{Atuple containing default argument values ! for those arguments that have defaults, or \code{None} if no ! arguments have a default value}{Writable} ! ! \lineiii{func_code}{The code object representing the compiled ! function body.}{Writable} ! ! \lineiii{func_globals}{A reference to the dictionary that holds the ! function's global variables --- the global namespace of the module ! in which the function was defined.}{Read-only} ! ! \lineiii{func_dict}{The namespace supporting arbitrary function ! attributes.}{Writable} ! ! \lineiii{func_closure}{\code{None} or a tuple of cells that contain ! bindings for the function's free variables.}{Read-only} ! \end{tableiii} ! ! Most of the attributes labelled ``Writable'' check the type of the ! assigned value. ! ! \versionchanged[\code{func_name} is now writable]{2.4} ! ! 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. \emph{Note that the current implementation only supports ! function attributes on user-defined functions. Function attributes on ! built-in functions may be supported in the future.} ! ! Additional information about a function's definition can be retrieved ! from its code object; see the description of internal types below. \withsubitem{(function attribute)}{ From mwh at users.sourceforge.net Thu Aug 12 20:12:47 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Aug 12 20:12:54 2004 Subject: [Python-checkins] python/dist/src/Objects funcobject.c,2.65,2.66 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2096/Objects Modified Files: funcobject.c Log Message: This is my patch [ 1004703 ] Make func_name writable plus fixing a couple of nits in the documentation changes spotted by MvL and a Misc/NEWS entry. Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.65 retrieving revision 2.66 diff -C2 -d -r2.65 -r2.66 *** funcobject.c 8 Jul 2004 01:48:59 -0000 2.65 --- funcobject.c 12 Aug 2004 18:12:44 -0000 2.66 *************** *** 164,169 **** {"func_globals", T_OBJECT, OFF(func_globals), RESTRICTED|READONLY}, - {"func_name", T_OBJECT, OFF(func_name), READONLY}, - {"__name__", T_OBJECT, OFF(func_name), READONLY}, {"__module__", T_OBJECT, OFF(func_module), WRITE_RESTRICTED}, {NULL} /* Sentinel */ --- 164,167 ---- *************** *** 251,254 **** --- 249,282 ---- static PyObject * + func_get_name(PyFunctionObject *op) + { + if (restricted()) + return NULL; + Py_INCREF(op->func_name); + return op->func_name; + } + + static int + func_set_name(PyFunctionObject *op, PyObject *value) + { + PyObject *tmp; + + if (restricted()) + return -1; + /* Not legal to del f.func_name or to set it to anything + * other than a string object. */ + if (value == NULL || !PyString_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "func_name must be set to a string object"); + return -1; + } + tmp = op->func_name; + Py_INCREF(value); + op->func_name = value; + Py_DECREF(tmp); + return 0; + } + + static PyObject * func_get_defaults(PyFunctionObject *op) { *************** *** 292,295 **** --- 320,325 ---- {"func_dict", (getter)func_get_dict, (setter)func_set_dict}, {"__dict__", (getter)func_get_dict, (setter)func_set_dict}, + {"func_name", (getter)func_get_name, (setter)func_set_name}, + {"__name__", (getter)func_get_name, (setter)func_set_name}, {NULL} /* Sentinel */ }; *************** *** 417,422 **** func_repr(PyFunctionObject *op) { - if (op->func_name == Py_None) - return PyString_FromFormat("", op); return PyString_FromFormat("", PyString_AsString(op->func_name), --- 447,450 ---- From tim_one at users.sourceforge.net Thu Aug 12 20:16:52 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 12 20:16:56 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.315,2.316 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2945/Python Modified Files: compile.c Log Message: code_new(): Wouldn't compile on Windows, because of gcc'ism. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.315 retrieving revision 2.316 diff -C2 -d -r2.315 -r2.316 *** compile.c 12 Aug 2004 17:56:20 -0000 2.315 --- compile.c 12 Aug 2004 18:16:43 -0000 2.316 *************** *** 146,150 **** int stacksize; int flags; ! PyObject *co = NULL;; PyObject *code; PyObject *consts; --- 146,150 ---- int stacksize; int flags; ! PyObject *co = NULL; PyObject *code; PyObject *consts; From mwh at users.sourceforge.net Thu Aug 12 20:19:20 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Aug 12 20:19:26 2004 Subject: [Python-checkins] python/dist/src/Python ceval.c, 2.414, 2.415 sysmodule.c, 2.125, 2.126 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3386/Python Modified Files: ceval.c sysmodule.c Log Message: This is my patch: [ 1005891 ] support --with-tsc on PPC plus a trivial change to settscdump's docstring and a Misc/NEWS entry. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.414 retrieving revision 2.415 diff -C2 -d -r2.414 -r2.415 *** ceval.c 7 Aug 2004 20:58:32 -0000 2.414 --- ceval.c 12 Aug 2004 18:19:07 -0000 2.415 *************** *** 18,25 **** #ifdef WITH_TSC - #include typedef unsigned long long uint64; void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1, uint64 loop0, uint64 loop1, uint64 intr0, uint64 intr1) --- 18,53 ---- #ifdef WITH_TSC typedef unsigned long long uint64; + #if defined(__ppc__) /* <- Don't know if this is the correct symbol; this + section should work for GCC on any PowerPC platform, + irrespective of OS. POWER? Who knows :-) */ + + #define rdtscll(var) ppc_getcounter(&var) + + static void + ppc_getcounter(uint64 *v) + { + register unsigned long tbu, tb, tbu2; + + loop: + asm volatile ("mftbu %0" : "=r" (tbu) ); + asm volatile ("mftb %0" : "=r" (tb) ); + asm volatile ("mftbu %0" : "=r" (tbu2)); + if (__builtin_expect(tbu != tbu2, 0)) goto loop; + + /* The slightly peculiar way of writing the next lines is + compiled better by GCC than any other way I tried. */ + ((long*)(v))[0] = tbu; + ((long*)(v))[1] = tb; + } + + #else /* this section is for linux/x86 */ + + #include + + #endif + void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1, uint64 loop0, uint64 loop1, uint64 intr0, uint64 intr1) *************** *** 35,38 **** --- 63,67 ---- opcode, ticked, inst, loop); } + #endif *************** *** 546,549 **** --- 575,581 ---- rdtscll(loop0); rdtscll(loop1); + + /* shut up the compiler */ + opcode = 0; #endif Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.125 retrieving revision 2.126 diff -C2 -d -r2.125 -r2.126 *** sysmodule.c 13 Jun 2004 20:32:17 -0000 2.125 --- sysmodule.c 12 Aug 2004 18:19:17 -0000 2.126 *************** *** 466,470 **** If true, tell the Python interpreter to dump VM measurements to\n\ stderr. If false, turn off dump. The measurements are based on the\n\ ! Pentium time-stamp counter." ); #endif /* TSC */ --- 466,470 ---- If true, tell the Python interpreter to dump VM measurements to\n\ stderr. If false, turn off dump. The measurements are based on the\n\ ! processor's time-stamp counter." ); #endif /* TSC */ From mwh at users.sourceforge.net Thu Aug 12 20:19:20 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Aug 12 20:19:27 2004 Subject: [Python-checkins] python/dist/src/Misc SpecialBuilds.txt, 1.15, 1.16 NEWS, 1.1083, 1.1084 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3386/Misc Modified Files: SpecialBuilds.txt NEWS Log Message: This is my patch: [ 1005891 ] support --with-tsc on PPC plus a trivial change to settscdump's docstring and a Misc/NEWS entry. Index: SpecialBuilds.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/SpecialBuilds.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** SpecialBuilds.txt 18 Apr 2003 00:45:58 -0000 1.15 --- SpecialBuilds.txt 12 Aug 2004 18:19:17 -0000 1.16 *************** *** 228,229 **** --- 228,254 ---- about what kind of object was called and whether the call hit any of the special fast paths in the code. + + --------------------------------------------------------------------------- + WITH_TSC introduced for Python 2.4 + + Super-lowlevel profiling of the interpreter. When enabled, the sys + module grows a new function: + + settscdump(bool) + If true, tell the Python interpreter to dump VM measurements to + stderr. If false, turn off dump. The measurements are based on the + processor's time-stamp counter. + + This build option requires a small amount of platform specific code. + Currently this code is present for linux/x86 and any PowerPC platform + that uses GCC (i.e. OS X and linux/ppc). + + On the PowerPC the rate at which the time base register is incremented + is not defined by the architecture specification, so you'll need to + find the manual for your specific processor. For the 750CX, 750CXe, + 750FX (all sold as the G3) we find: + + The time base counter is clocked at a frequency that is + one-fourth that of the bus clock. + + This build is enabled by the --with-tsc flag to configure. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1083 retrieving revision 1.1084 diff -C2 -d -r1.1083 -r1.1084 *** NEWS 12 Aug 2004 18:12:44 -0000 1.1083 --- NEWS 12 Aug 2004 18:19:17 -0000 1.1084 *************** *** 58,61 **** --- 58,64 ---- ----- + - The --with-tsc flag to configure to enable VM profiling with the + processor's timestamp counter now works on PPC platforms. + C API ----- From mwh at users.sourceforge.net Thu Aug 12 20:28:06 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Aug 12 20:28:09 2004 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py,1.159,1.160 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5283 Modified Files: regrtest.py Log Message: Report refleaks to stderr as the tests run as well as logging them to a file. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.159 retrieving revision 1.160 diff -C2 -d -r1.159 -r1.160 *** regrtest.py 7 Aug 2004 19:25:33 -0000 1.159 --- regrtest.py 12 Aug 2004 18:27:48 -0000 1.160 *************** *** 509,512 **** --- 509,514 ---- print >>sys.stderr if max(map(abs, deltas[-huntrleaks[1]:])) > 0: + print >>sys.stderr, test, 'leaked', \ + deltas[-huntrleaks[1]:], 'references' print >>refrep, test, 'leaked', \ deltas[-huntrleaks[1]:], 'references' From tim_one at users.sourceforge.net Thu Aug 12 20:37:13 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 12 20:37:16 2004 Subject: [Python-checkins] python/dist/src/PCbuild python.vcproj, 1.4, 1.5 pythonw.vcproj, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7449/PCbuild Modified Files: python.vcproj pythonw.vcproj Log Message: Boosted the stack reservation for python.exe and python_w.exe from the default 1MB to 2 million bytes. The test suite passes with -uall again (test_compiler no longer drives WinXP into an insane state). Index: python.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python.vcproj,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** python.vcproj 12 Aug 2004 14:07:49 -0000 1.4 --- python.vcproj 12 Aug 2004 18:37:10 -0000 1.5 *************** *** 48,51 **** --- 48,52 ---- ProgramDatabaseFile=".\./python.pdb" SubSystem="1" + StackReserveSize="2000000" BaseAddress="0x1d000000" TargetMachine="1"/> *************** *** 110,113 **** --- 111,115 ---- ProgramDatabaseFile=".\./python_d.pdb" SubSystem="1" + StackReserveSize="2000000" BaseAddress="0x1d000000" TargetMachine="1"/> *************** *** 180,183 **** --- 182,186 ---- ProgramDatabaseFile=".\./python.pdb" SubSystem="1" + StackReserveSize="2000000" BaseAddress="0x1d000000" TargetMachine="0"/> Index: pythonw.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythonw.vcproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pythonw.vcproj 20 Jul 2004 14:37:48 -0000 1.3 --- pythonw.vcproj 12 Aug 2004 18:37:10 -0000 1.4 *************** *** 43,46 **** --- 43,47 ---- ProgramDatabaseFile=".\./pythonw_d.pdb" SubSystem="2" + StackReserveSize="2000000" BaseAddress="0x1d000000" TargetMachine="1"/> *************** *** 109,112 **** --- 110,114 ---- ProgramDatabaseFile=".\./pythonw.pdb" SubSystem="2" + StackReserveSize="2000000" BaseAddress="0x1d000000" TargetMachine="1"/> *************** *** 180,183 **** --- 182,186 ---- ProgramDatabaseFile=".\./pythonw.pdb" SubSystem="2" + StackReserveSize="2000000" BaseAddress="0x1d000000" TargetMachine="0"/> From tim_one at users.sourceforge.net Thu Aug 12 20:37:13 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 12 20:37:17 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1084,1.1085 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7449/Misc Modified Files: NEWS Log Message: Boosted the stack reservation for python.exe and python_w.exe from the default 1MB to 2 million bytes. The test suite passes with -uall again (test_compiler no longer drives WinXP into an insane state). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1084 retrieving revision 1.1085 diff -C2 -d -r1.1084 -r1.1085 *** NEWS 12 Aug 2004 18:19:17 -0000 1.1084 --- NEWS 12 Aug 2004 18:37:10 -0000 1.1085 *************** *** 76,79 **** --- 76,89 ---- ------- + - Boosted the stack reservation for python.exe and pythonw.exe from + the default 1MB to 2MB. Stack frames under VC 7.1 for 2.4 are enough + bigger than under VC 6.0 for 2.3.4 that deeply recursive progams + within the default sys.getrecursionlimit() default value of 1000 were + able to suffer undetected C stack overflows. The standard test program + test_compiler was one such program. If a Python process on Windows + "just vanishes" without a trace, and without an error message of any + kind, but with an exit code of 128, undetected stack overflow may be + the problem. + Mac --- From montanaro at users.sourceforge.net Thu Aug 12 22:33:05 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Thu Aug 12 22:33:08 2004 Subject: [Python-checkins] python/nondist/peps pep-0318.txt,1.20,1.21 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31684 Modified Files: pep-0318.txt Log Message: Michael Hudson checked in a mod to allow a function's func_name attribute to be modified, thus closing open issue #2. Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** pep-0318.txt 10 Aug 2004 01:51:30 -0000 1.20 --- pep-0318.txt 12 Aug 2004 20:33:02 -0000 1.21 *************** *** 479,487 **** ``python-dev``. - 2. Decorators which wrap a function and return a different function - should be able to easily change the func_name attribute without - constructing it with new.function(). Perhaps the func_name - attribute should be writable. - .. _strong arguments: http://mail.python.org/pipermail/python-dev/2004-March/thread.html --- 479,482 ---- From rhettinger at users.sourceforge.net Thu Aug 12 23:20:28 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Aug 12 23:20:34 2004 Subject: [Python-checkins] python/nondist/sandbox/string/string __init__.py, 1.2, 1.3 template.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/string/string In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7407 Modified Files: __init__.py template.py Log Message: Capitalized the class names. Fixed a broken example Cleaned-up the namespace. Added __slots__ for compactness. Doctest the example. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/string/string/__init__.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** __init__.py 10 Aug 2004 22:27:46 -0000 1.2 --- __init__.py 12 Aug 2004 21:20:24 -0000 1.3 *************** *** 24,31 **** 'digits', 'hexdigits', 'octdigits', 'punctuation', 'printable', # PEP 292 ! 'template', 'safe_template' ] ! from template import template, safe_template from deprecated import * --- 24,31 ---- 'digits', 'hexdigits', 'octdigits', 'punctuation', 'printable', # PEP 292 ! 'Template', 'SafeTemplate' ] ! from template import Template, SafeTemplate from deprecated import * Index: template.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/string/string/template.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** template.py 10 Aug 2004 22:27:46 -0000 1.1 --- template.py 12 Aug 2004 21:20:24 -0000 1.2 *************** *** 8,12 **** Two subclasses of the unicode type are provided: ! template - PEP 292 'dollar' strings with the following substitution rules: 1. $$ is an escape; it is replaced with a single $ --- 8,12 ---- Two subclasses of the unicode type are provided: ! Template - PEP 292 'dollar' strings with the following substitution rules: 1. $$ is an escape; it is replaced with a single $ *************** *** 26,39 **** http://www.python.org/doc/current/ref/identifiers.html ! safe_template - Like templates, except that KeyErrors will never be raised when a placeholder is missing from the interpolation dictionary. ! You can also derive your own classes from template to define different ! substitution rules. UTSL for details. Examples: ! >>> from string import template ! >>> x = template('$who owes me $what') >>> print x $who owes me $what --- 26,39 ---- http://www.python.org/doc/current/ref/identifiers.html ! SafeTemplate - Like Template, except that KeyErrors will never be raised when a placeholder is missing from the interpolation dictionary. ! You can also derive your own classes from Template to define different ! substitution rules. Examples: ! >>> from string import Template ! >>> x = Template('$who owes me $what') >>> print x $who owes me $what *************** *** 42,61 **** >>> import re ! >>> class mstring(template): ... pattern = re.compile( ... r'(\${2})|\$(mm:[_a-z]\w*)|\$({mm:[_a-z]\w*})', re.IGNORECASE) ... >>> x = mstring('$who owes me $mm:what') ! >>> print x % {'who': 'Tim', 'mm:what', 'nothing'} $who owes me nothing """ ! __all__ = ['template', 'safe_template'] import re ! ! class template(unicode): """A string class for supporting $-substitutions.""" # Search for $$, $identifier, or ${identifier} --- 42,61 ---- >>> import re ! >>> class mstring(Template): ... pattern = re.compile( ... r'(\${2})|\$(mm:[_a-z]\w*)|\$({mm:[_a-z]\w*})', re.IGNORECASE) ... >>> x = mstring('$who owes me $mm:what') ! >>> print x % {'who':'Tim', 'mm:what':'nothing'} $who owes me nothing """ ! __all__ = ['Template', 'SafeTemplate'] import re ! class Template(unicode): """A string class for supporting $-substitutions.""" + __slots__ = [] # Search for $$, $identifier, or ${identifier} *************** *** 74,78 **** ! class safe_template(template): """A string class for supporting $-substitutions. --- 74,78 ---- ! class SafeTemplate(Template): """A string class for supporting $-substitutions. *************** *** 81,84 **** --- 81,85 ---- case, you will get the original placeholder in the value string. """ + __slots__ = [] def __mod__(self, mapping): *************** *** 98,99 **** --- 99,106 ---- return '${' + braced + '}' return self.pattern.sub(convert, self) + + del re + + if __name__ == '__main__': + import doctest + print doctest.testmod() From rhettinger at users.sourceforge.net Thu Aug 12 23:22:54 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Aug 12 23:22:56 2004 Subject: [Python-checkins] python/nondist/sandbox/string/tests test_pep292.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/string/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7979 Modified Files: test_pep292.py Log Message: Capitalized the class names. Removed the yucky page breaks. Index: test_pep292.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/string/tests/test_pep292.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_pep292.py 10 Aug 2004 22:27:46 -0000 1.2 --- test_pep292.py 12 Aug 2004 21:22:51 -0000 1.3 *************** *** 4,14 **** import unittest ! from string import template, safe_template - - class TestTemplates(unittest.TestCase): def test_regular_templates(self): ! s = template('$who likes to eat a bag of $what worth $100') self.assertEqual(s % dict(who='tim', what='ham'), 'tim likes to eat a bag of ham worth $100') --- 4,13 ---- import unittest ! from string import Template, SafeTemplate + class TestTemplate(unittest.TestCase): def test_regular_templates(self): ! s = Template('$who likes to eat a bag of $what worth $100') self.assertEqual(s % dict(who='tim', what='ham'), 'tim likes to eat a bag of ham worth $100') *************** *** 16,20 **** def test_regular_templates_with_braces(self): ! s = template('$who likes ${what} for ${meal}') self.assertEqual(s % dict(who='tim', what='ham', meal='dinner'), 'tim likes ham for dinner') --- 15,19 ---- def test_regular_templates_with_braces(self): ! s = Template('$who likes ${what} for ${meal}') self.assertEqual(s % dict(who='tim', what='ham', meal='dinner'), 'tim likes ham for dinner') *************** *** 24,40 **** def test_escapes(self): eq = self.assertEqual ! s = template('$who likes to eat a bag of $$what worth $100') eq(s % dict(who='tim', what='ham'), 'tim likes to eat a bag of $what worth $100') def test_percents(self): ! s = template('%(foo)s $foo ${foo}') self.assertEqual(s % dict(foo='baz'), '%(foo)s baz baz') ! s = safe_template('%(foo)s $foo ${foo}') self.assertEqual(s % dict(foo='baz'), '%(foo)s baz baz') ! def test_safe_templates(self): eq = self.assertEqual ! s = safe_template('$who likes ${what} for ${meal}') eq(s % dict(who='tim'), 'tim likes ${what} for ${meal}') --- 23,39 ---- def test_escapes(self): eq = self.assertEqual ! s = Template('$who likes to eat a bag of $$what worth $100') eq(s % dict(who='tim', what='ham'), 'tim likes to eat a bag of $what worth $100') def test_percents(self): ! s = Template('%(foo)s $foo ${foo}') self.assertEqual(s % dict(foo='baz'), '%(foo)s baz baz') ! s = SafeTemplate('%(foo)s $foo ${foo}') self.assertEqual(s % dict(foo='baz'), '%(foo)s baz baz') ! def test_SafeTemplate(self): eq = self.assertEqual ! s = SafeTemplate('$who likes ${what} for ${meal}') eq(s % dict(who='tim'), 'tim likes ${what} for ${meal}') *************** *** 49,53 **** - def test_suite(): suite = unittest.TestSuite() --- 48,51 ---- From tim_one at users.sourceforge.net Fri Aug 13 00:31:27 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 13 00:31:31 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20362/Doc/lib Modified Files: libdoctest.tex Log Message: Excruciatingly slow progress on the docs. Option flags / directive names are documented now, and ripped out a bunch of "private name" convolutions. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** libdoctest.tex 10 Aug 2004 15:41:03 -0000 1.23 --- libdoctest.tex 12 Aug 2004 22:31:25 -0000 1.24 *************** *** 215,219 **** examples start with a clean slate. ! Optional argument \var{extraglobs} gives a dicti merged into the globals used to execute examples. This works like \method{dict.update()}: if \var{globs} and \var{extraglobs} have a --- 215,219 ---- examples start with a clean slate. ! Optional argument \var{extraglobs} gives a dict merged into the globals used to execute examples. This works like \method{dict.update()}: if \var{globs} and \var{extraglobs} have a *************** *** 235,277 **** passed). ! Optional argument \var{optionflags} or's together module constants, ! and defaults to 0. ! ! % Possible values: ! % ! % DONT_ACCEPT_TRUE_FOR_1 ! % By default, if an expected output block contains just "1", ! % an actual output block containing just "True" is considered ! % to be a match, and similarly for "0" versus "False". When ! % DONT_ACCEPT_TRUE_FOR_1 is specified, neither substitution ! % is allowed. ! % ! % DONT_ACCEPT_BLANKLINE ! % By default, if an expected output block contains a line ! % containing only the string "", then that line ! % will match a blank line in the actual output. When ! % DONT_ACCEPT_BLANKLINE is specified, this substitution is ! % not allowed. ! % ! % NORMALIZE_WHITESPACE ! % When NORMALIZE_WHITESPACE is specified, all sequences of ! % whitespace are treated as equal. I.e., any sequence of ! % whitespace within the expected output will match any ! % sequence of whitespace within the actual output. ! % ! % ELLIPSIS ! % When ELLIPSIS is specified, then an ellipsis marker ! % ("...") in the expected output can match any substring in ! % the actual output. ! % ! % UNIFIED_DIFF ! % When UNIFIED_DIFF is specified, failures that involve ! % multi-line expected and actual outputs will be displayed ! % using a unified diff. ! % ! % CONTEXT_DIFF ! % When CONTEXT_DIFF is specified, failures that involve ! % multi-line expected and actual outputs will be displayed ! % using a context diff. Optional argument \var{raise_on_error} defaults to false. If true, --- 235,240 ---- passed). ! Optional argument \var{optionflags} or's together option flags. See ! see section \ref{doctest-options}. Optional argument \var{raise_on_error} defaults to false. If true, *************** *** 300,306 **** \versionchanged[The parameter \var{optionflags} was added]{2.3} - \versionchanged[Many new module constants for use with \var{optionflags} - were added]{2.4} - \versionchanged[The parameters \var{extraglobs} and \var{raise_on_error} were added]{2.4} --- 263,266 ---- *************** *** 310,325 **** \subsection{Which Docstrings Are Examined?} ! See the docstrings in \file{doctest.py} for all the details. They're ! unsurprising: the module docstring, and all function, class and method ! docstrings are searched. Optionally, the tester can be directed to ! exclude docstrings attached to objects with private names. Objects ! imported into the module are not searched. In addition, if \code{M.__test__} exists and "is true", it must be a dict, and each entry maps a (string) name to a function object, class object, or string. Function and class object docstrings found from ! \code{M.__test__} are searched even if the tester has been ! directed to skip over private names in the rest of the module. ! In output, a key \code{K} in \code{M.__test__} appears with name \begin{verbatim} --- 270,282 ---- \subsection{Which Docstrings Are Examined?} ! The module docstring, and all function, class and method docstrings are ! searched. Objects imported into the module are not searched. In addition, if \code{M.__test__} exists and "is true", it must be a dict, and each entry maps a (string) name to a function object, class object, or string. Function and class object docstrings found from ! \code{M.__test__} are searched, and strings are treated as if they ! were docstrings. In output, a key \code{K} in \code{M.__test__} appears ! with name \begin{verbatim} *************** *** 328,334 **** Any classes found are recursively searched similarly, to test docstrings in ! their contained methods and nested classes. While private names reached ! from \module{M}'s globals can be optionally skipped, all names reached from ! \code{M.__test__} are searched. \subsection{What's the Execution Context?} --- 285,293 ---- Any classes found are recursively searched similarly, to test docstrings in ! their contained methods and nested classes. ! ! \versionchanged[A "private name" concept is deprecated and no longer ! documented.]{2.4} ! \subsection{What's the Execution Context?} *************** *** 364,367 **** --- 323,390 ---- value of the example). + \subsection{Option Flags and Directive Names\label{doctest-options}} + + 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 doctest directives. + + \begin{datadesc}{DONT_ACCEPT_TRUE_FOR_1} + By default, if an expected output block contains just \code{1}, + an actual output block containing just \code{1} or just + \code{True} is considered to be a match, and similarly for \code{0} + versus \code{False}. When \constant{DONT_ACCEPT_TRUE_FOR_1} is + specified, neither substitution is allowed. The default behavior + caters to that Python changed the return type of many functions + from integer to boolean; doctests expecting "little integer" + output still work in these cases. This option will probably go + away, but not for several years. + \end{datadesc} + + \begin{datadesc}{DONT_ACCEPT_BLANKLINE} + By default, if an expected output block contains a line + containing only the string \code{}, then that line + will match a blank line in the actual output. Because a + genuinely blank line delimits the expected output, this is + the only way to communicate that a blank line is expected. When + \constant{DONT_ACCEPT_BLANKLINE} is specified, this substitution + is not allowed. + \end{datadesc} + + \begin{datadesc}{NORMALIZE_WHITESPACE} + When specified, all sequences of whitespace (blanks and newlines) are + treated as equal. Any sequence of whitespace within the expected + output will match any sequence of whitespace within the actual output. + By default, whitespace must match exactly. + \constant{NORMALIZE_WHITESPACE} is especially useful when a line + of expected output is very long, and you want to wrap it across + multiple lines in your source. + \end{datadesc} + + \begin{datadesc}{ELLIPSIS} + When specified, an ellipsis marker (\code{...}) in the expected output + can match any substring in the actual output. This includes + substrings that span line boundaries, so it's best to keep usage of + this simple. Complicated uses can lead to the same kinds of + surprises that \code{.*} is prone to in regular expressions. + \end{datadesc} + + \begin{datadesc}{UNIFIED_DIFF} + When specified, failures that involve multi-line expected and + actual outputs are displayed using a unified diff. + \end{datadesc} + + \begin{datadesc}{CONTEXT_DIFF} + When specified, failures that involve multi-line expected and + actual outputs will be displayed using a context diff. + \end{datadesc} + + + \versionchanged[Constants \constant{DONT_ACCEPT_BLANKLINE}, + \constant{NORMALIZE_WHITESPACE}, \constant{ELLIPSIS}, + \constant{UNIFIED_DIFF}, and \constant{CONTEXT_DIFF} + were added, and \code{} in expected output matches + an empty line in actual output by default.]{2.4} + \subsection{Advanced Usage} From rhettinger at users.sourceforge.net Fri Aug 13 03:05:34 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Aug 13 03:05:37 2004 Subject: [Python-checkins] python/nondist/sandbox/string/string template.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/string/string In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12830 Modified Files: template.py Log Message: SafeTemplate does not depend on Template. Index: template.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/string/string/template.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** template.py 12 Aug 2004 21:20:24 -0000 1.2 --- template.py 13 Aug 2004 01:05:31 -0000 1.3 *************** *** 74,78 **** ! class SafeTemplate(Template): """A string class for supporting $-substitutions. --- 74,78 ---- ! class SafeTemplate(unicode): """A string class for supporting $-substitutions. From rhettinger at users.sourceforge.net Fri Aug 13 03:20:46 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Aug 13 03:20:49 2004 Subject: [Python-checkins] python/nondist/sandbox/string/string template.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/string/string In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15838 Modified Files: template.py Log Message: Revert last change so that regexes are shared between the classes. Index: template.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/string/string/template.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** template.py 13 Aug 2004 01:05:31 -0000 1.3 --- template.py 13 Aug 2004 01:20:43 -0000 1.4 *************** *** 74,78 **** ! class SafeTemplate(unicode): """A string class for supporting $-substitutions. --- 74,78 ---- ! class SafeTemplate(Template): """A string class for supporting $-substitutions. From tim_one at users.sourceforge.net Fri Aug 13 03:49:15 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 13 03:49:19 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20744/Doc/lib Modified Files: libdoctest.tex Log Message: Markup fiddling. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** libdoctest.tex 12 Aug 2004 22:31:25 -0000 1.24 --- libdoctest.tex 13 Aug 2004 01:49:12 -0000 1.25 *************** *** 160,164 **** failing example(s) and the cause(s) of the failure(s) are printed to stdout, and the final line of output is ! \\code{'***Test Failed*** \var{N} failures.'}, where \var{N} is the number of examples that failed. --- 160,164 ---- failing example(s) and the cause(s) of the failure(s) are printed to stdout, and the final line of output is ! \samp{'***Test Failed*** \var{N} failures.'}, where \var{N} is the number of examples that failed. *************** *** 204,208 **** searched. ! Return \code{(\var{failure_count}, \var{test_count})}. Optional argument \var{name} gives the name of the module; by default, --- 204,208 ---- searched. ! Return \samp{(\var{failure_count}, \var{test_count})}. Optional argument \var{name} gives the name of the module; by default, *************** *** 228,232 **** Optional argument \var{verbose} prints lots of stuff if true, and prints only failures if false; by default, or if \code{None}, it's true ! if and only if \code{'-v'} is in \code{\module{sys}.argv}. Optional argument \var{report} prints a summary at the end when true, --- 228,232 ---- Optional argument \var{verbose} prints lots of stuff if true, and prints only failures if false; by default, or if \code{None}, it's true ! if and only if \code{'-v'} is in \code{sys.argv}. Optional argument \var{report} prints a summary at the end when true, *************** *** 246,250 **** determine whether a name is private. The default function treats all names as public. \var{isprivate} can be set to ! \code{\module{doctest}.is_private} to skip over names that are private according to Python's underscore naming convention. \deprecated{2.4}{\var{isprivate} was a stupid idea -- don't use it. --- 246,250 ---- determine whether a name is private. The default function treats all names as public. \var{isprivate} can be set to ! \code{doctest.is_private} to skip over names that are private according to Python's underscore naming convention. \deprecated{2.4}{\var{isprivate} was a stupid idea -- don't use it. *************** *** 288,292 **** \versionchanged[A "private name" concept is deprecated and no longer ! documented.]{2.4} --- 288,292 ---- \versionchanged[A "private name" concept is deprecated and no longer ! documented]{2.4} *************** *** 367,371 **** substrings that span line boundaries, so it's best to keep usage of this simple. Complicated uses can lead to the same kinds of ! surprises that \code{.*} is prone to in regular expressions. \end{datadesc} --- 367,371 ---- substrings that span line boundaries, so it's best to keep usage of this simple. Complicated uses can lead to the same kinds of ! surprises that \regexp{.*} is prone to in regular expressions. \end{datadesc} *************** *** 385,389 **** \constant{UNIFIED_DIFF}, and \constant{CONTEXT_DIFF} were added, and \code{} in expected output matches ! an empty line in actual output by default.]{2.4} \subsection{Advanced Usage} --- 385,389 ---- \constant{UNIFIED_DIFF}, and \constant{CONTEXT_DIFF} were added, and \code{} in expected output matches ! an empty line in actual output by default]{2.4} \subsection{Advanced Usage} From tim_one at users.sourceforge.net Fri Aug 13 03:53:02 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 13 03:53:05 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.63,1.64 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21521/Lib Modified Files: doctest.py Log Message: Nit in _IS_BLANK_OR_COMMENT comment -- it doesn't matter how this is implemented, just what it does. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** doctest.py 12 Aug 2004 02:43:49 -0000 1.63 --- doctest.py 13 Aug 2004 01:52:59 -0000 1.64 *************** *** 498,503 **** ''', re.MULTILINE | re.VERBOSE) ! # This regular expression matcher checks if a given string is a ! # blank line or contains a single comment. _IS_BLANK_OR_COMMENT = re.compile(r'^[ ]*(#.*)?$').match --- 498,503 ---- ''', re.MULTILINE | re.VERBOSE) ! # A callable returning a true value iff its argument is a blank line ! # or contains a single comment. _IS_BLANK_OR_COMMENT = re.compile(r'^[ ]*(#.*)?$').match From nnorwitz at users.sourceforge.net Fri Aug 13 04:34:09 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Fri Aug 13 04:34:13 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libtime.tex,1.65,1.66 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27663/Doc/lib Modified Files: libtime.tex Log Message: Fix the version number in which changes were made Index: libtime.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtime.tex,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** libtime.tex 3 Aug 2004 17:58:54 -0000 1.65 --- libtime.tex 13 Aug 2004 02:34:06 -0000 1.66 *************** *** 165,169 **** \versionchanged[Allowed \var{secs} to be omitted]{2.1} \versionchanged[If \var{secs} is \constant{None}, the current time is ! used]{2.3} \end{funcdesc} --- 165,169 ---- \versionchanged[Allowed \var{secs} to be omitted]{2.1} \versionchanged[If \var{secs} is \constant{None}, the current time is ! used]{2.4} \end{funcdesc} *************** *** 180,184 **** \versionchanged[Allowed \var{secs} to be omitted]{2.1} \versionchanged[If \var{secs} is \constant{None}, the current time is ! used]{2.3} \end{funcdesc} --- 180,184 ---- \versionchanged[Allowed \var{secs} to be omitted]{2.1} \versionchanged[If \var{secs} is \constant{None}, the current time is ! used]{2.4} \end{funcdesc} *************** *** 190,194 **** \versionchanged[Allowed \var{secs} to be omitted]{2.1} \versionchanged[If \var{secs} is \constant{None}, the current time is ! used]{2.3} \end{funcdesc} --- 190,194 ---- \versionchanged[Allowed \var{secs} to be omitted]{2.1} \versionchanged[If \var{secs} is \constant{None}, the current time is ! used]{2.4} \end{funcdesc} From nnorwitz at users.sourceforge.net Fri Aug 13 04:56:19 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Fri Aug 13 04:56:23 2004 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.83,1.84 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30267/dist Modified Files: dist.tex Log Message: SF #1005913, Patch to allow building of paper-*/dist.pdf by Jeff Epler There were subsections without sections, so drop a sub. Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** dist.tex 7 Aug 2004 21:35:06 -0000 1.83 --- dist.tex 13 Aug 2004 02:56:16 -0000 1.84 *************** *** 315,319 **** ! \subsection{Listing whole packages} \label{listing-packages} --- 315,319 ---- ! \section{Listing whole packages} \label{listing-packages} *************** *** 370,374 **** ! \subsection{Listing individual modules} \label{listing-modules} --- 370,374 ---- ! \section{Listing individual modules} \label{listing-modules} *************** *** 391,395 **** ! \subsection{Describing extension modules} \label{describing-extensions} --- 391,395 ---- ! \section{Describing extension modules} \label{describing-extensions} *************** *** 434,438 **** ! \subsubsection{Extension names and packages} The first argument to the \class{Extension} constructor is always the --- 434,438 ---- ! \subsection{Extension names and packages} The first argument to the \class{Extension} constructor is always the *************** *** 470,474 **** ! \subsubsection{Extension source files} The second argument to the \class{Extension} constructor is a list of --- 470,474 ---- ! \subsection{Extension source files} The second argument to the \class{Extension} constructor is a list of *************** *** 495,499 **** ! \subsubsection{Preprocessor options} Three optional arguments to \class{Extension} will help if you need to --- 495,499 ---- ! \subsection{Preprocessor options} Three optional arguments to \class{Extension} will help if you need to *************** *** 582,586 **** ! \subsubsection{Library options} You can also specify the libraries to link against when building your --- 582,586 ---- ! \subsection{Library options} You can also specify the libraries to link against when building your *************** *** 613,617 **** \XXX{Should mention clib libraries here or somewhere else!} ! \subsubsection{Other options} There are still some other options which can be used to handle special --- 613,617 ---- \XXX{Should mention clib libraries here or somewhere else!} ! \subsection{Other options} There are still some other options which can be used to handle special *************** *** 632,636 **** to the list of exported symbols. ! \subsection{Installing Scripts} So far we have been dealing with pure and non-pure Python modules, which are usually not run by themselves but imported by scripts. --- 632,636 ---- to the list of exported symbols. ! \section{Installing Scripts} So far we have been dealing with pure and non-pure Python modules, which are usually not run by themselves but imported by scripts. *************** *** 653,657 **** ! \subsection{Installing Package Data} Often, additional files need to be installed into a package. These --- 653,657 ---- ! \section{Installing Package Data} Often, additional files need to be installed into a package. These *************** *** 702,706 **** ! \subsection{Installing Additional Files} The \option{data\_files} option can be used to specify additional --- 702,706 ---- ! \section{Installing Additional Files} The \option{data\_files} option can be used to specify additional *************** *** 740,744 **** string should be given as the directory. ! \subsection{Additional meta-data} \label{meta-data} --- 740,744 ---- string should be given as the directory. ! \section{Additional meta-data} \label{meta-data} *************** *** 847,851 **** ! \subsection{Debugging the setup script} Sometimes things go wrong, and the setup script doesn't do what the --- 847,851 ---- ! \section{Debugging the setup script} Sometimes things go wrong, and the setup script doesn't do what the *************** *** 1052,1056 **** ! \subsection{Specifying the files to distribute} \label{manifest} --- 1052,1056 ---- ! \section{Specifying the files to distribute} \label{manifest} *************** *** 1157,1161 **** ! \subsection{Manifest-related options} \label{manifest-options} --- 1157,1161 ---- ! \section{Manifest-related options} \label{manifest-options} *************** *** 1325,1329 **** ! \subsection{Creating dumb built distributions} \label{creating-dumb} --- 1325,1329 ---- ! \section{Creating dumb built distributions} \label{creating-dumb} *************** *** 1332,1336 **** ! \subsection{Creating RPM packages} \label{creating-rpms} --- 1332,1336 ---- ! \section{Creating RPM packages} \label{creating-rpms} *************** *** 1456,1460 **** ! \subsection{Creating Windows Installers} \label{creating-wininst} --- 1456,1460 ---- ! \section{Creating Windows Installers} \label{creating-wininst} *************** *** 1509,1513 **** \longprogramopt{dist-dir} option. ! \subsubsection{The Postinstallation script} \label{postinstallation-script} --- 1509,1513 ---- \longprogramopt{dist-dir} option. ! \subsection{The Postinstallation script} \label{postinstallation-script} *************** *** 1983,1987 **** ! %\subsection{Building modules: the \protect\command{build} command family} %\label{build-cmds} --- 1983,1987 ---- ! %\section{Building modules: the \protect\command{build} command family} %\label{build-cmds} *************** *** 3511,3515 **** % todo ! \subsubsection{\module{distutils.command.install} --- Install a package} \declaremodule{standard}{distutils.command.install} \modulesynopsis{Install a package} --- 3511,3515 ---- % todo ! \section{\module{distutils.command.install} --- Install a package} \declaremodule{standard}{distutils.command.install} \modulesynopsis{Install a package} *************** *** 3517,3521 **** % todo ! \subsubsection{\module{distutils.command.install_data} --- Install data files from a package} \declaremodule[distutils.command.installdata]{standard}{distutils.command.install_data} --- 3517,3521 ---- % todo ! \section{\module{distutils.command.install_data} --- Install data files from a package} \declaremodule[distutils.command.installdata]{standard}{distutils.command.install_data} *************** *** 3524,3528 **** % todo ! \subsubsection{\module{distutils.command.install_headers} --- Install C/\Cpp{} header files from a package} \declaremodule[distutils.command.installheaders]{standard}{distutils.command.install_headers} --- 3524,3528 ---- % todo ! \section{\module{distutils.command.install_headers} --- Install C/\Cpp{} header files from a package} \declaremodule[distutils.command.installheaders]{standard}{distutils.command.install_headers} *************** *** 3531,3535 **** % todo ! \subsubsection{\module{distutils.command.install_lib} --- Install library files from a package} \declaremodule[distutils.command.installlib]{standard}{distutils.command.install_lib} --- 3531,3535 ---- % todo ! \section{\module{distutils.command.install_lib} --- Install library files from a package} \declaremodule[distutils.command.installlib]{standard}{distutils.command.install_lib} *************** *** 3538,3542 **** % todo ! \subsubsection{\module{distutils.command.install_scripts} --- Install script files from a package} \declaremodule[distutils.command.installscripts]{standard}{distutils.command.install_scripts} --- 3538,3542 ---- % todo ! \section{\module{distutils.command.install_scripts} --- Install script files from a package} \declaremodule[distutils.command.installscripts]{standard}{distutils.command.install_scripts} *************** *** 3545,3549 **** % todo ! \subsubsection{\module{distutils.command.register} --- Register a module with the Python Package Index} \declaremodule{standard}{distutils.command.register} --- 3545,3549 ---- % todo ! \section{\module{distutils.command.register} --- Register a module with the Python Package Index} \declaremodule{standard}{distutils.command.register} *************** *** 3554,3558 **** % todo ! \subsubsection{Creating a new Distutils command} This section outlines the steps to create a new Distutils command. --- 3554,3558 ---- % todo ! \section{Creating a new Distutils command} This section outlines the steps to create a new Distutils command. From fdrake at users.sourceforge.net Fri Aug 13 05:09:17 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Aug 13 05:09:19 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_pyexpat.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32356/Lib/test Modified Files: test_pyexpat.py Log Message: include at least one example of an exception passing through pyexpat Index: test_pyexpat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyexpat.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** test_pyexpat.py 12 Feb 2004 17:35:11 -0000 1.14 --- test_pyexpat.py 13 Aug 2004 03:09:07 -0000 1.15 *************** *** 312,313 **** --- 312,328 ---- "", "4", "", "5", ""], "buffered text not properly split") + + # Test handling of exception from callback: + def StartElementHandler(name, attrs): + raise RuntimeError(name) + + parser = expat.ParserCreate() + parser.StartElementHandler = StartElementHandler + + try: + parser.Parse("", 1) + except RuntimeError, e: + if e.args[0] != "a": + print "Expected RuntimeError for element 'a'; found %r" % e.args[0] + else: + print "Expected RuntimeError for 'a'" From fdrake at users.sourceforge.net Fri Aug 13 05:13:00 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Aug 13 05:13:03 2004 Subject: [Python-checkins] python/dist/src/Modules pyexpat.c,2.86,2.87 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv535/Modules Modified Files: pyexpat.c Log Message: make exception propogation more efficient; this avoids having Expat parse the remaining data in the buffer (which it had done happily without reporting any results) this depends on a new feature in Expat added in 1.95.8 Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.86 retrieving revision 2.87 diff -C2 -d -r2.86 -r2.87 *** pyexpat.c 4 Aug 2004 22:28:16 -0000 2.86 --- pyexpat.c 13 Aug 2004 03:12:57 -0000 2.87 *************** *** 358,362 **** static PyObject* ! call_with_frame(PyCodeObject *c, PyObject* func, PyObject* args) { PyThreadState *tstate = PyThreadState_GET(); --- 358,363 ---- static PyObject* ! call_with_frame(PyCodeObject *c, PyObject* func, PyObject* args, ! xmlparseobject *self) { PyThreadState *tstate = PyThreadState_GET(); *************** *** 380,383 **** --- 381,385 ---- if (tstate->curexc_traceback == NULL) PyTraceBack_Here(f); + XML_StopParser(self->itself, XML_FALSE); #ifdef FIX_TRACE if (trace_frame_exc(tstate, f) < 0) { *************** *** 454,458 **** self->in_callback = 1; temp = call_with_frame(getcode(CharacterData, "CharacterData", __LINE__), ! self->handlers[CharacterData], args); /* temp is an owned reference again, or NULL */ self->in_callback = 0; --- 456,460 ---- self->in_callback = 1; temp = call_with_frame(getcode(CharacterData, "CharacterData", __LINE__), ! self->handlers[CharacterData], args, self); /* temp is an owned reference again, or NULL */ self->in_callback = 0; *************** *** 575,579 **** self->in_callback = 1; rv = call_with_frame(getcode(StartElement, "StartElement", __LINE__), ! self->handlers[StartElement], args); self->in_callback = 0; Py_DECREF(args); --- 577,581 ---- self->in_callback = 1; rv = call_with_frame(getcode(StartElement, "StartElement", __LINE__), ! self->handlers[StartElement], args, self); self->in_callback = 0; Py_DECREF(args); *************** *** 602,606 **** self->in_callback = 1; \ rv = call_with_frame(getcode(NAME,#NAME,__LINE__), \ ! self->handlers[NAME], args); \ self->in_callback = 0; \ Py_DECREF(args); \ --- 604,608 ---- self->in_callback = 1; \ rv = call_with_frame(getcode(NAME,#NAME,__LINE__), \ ! self->handlers[NAME], args, self); \ self->in_callback = 0; \ Py_DECREF(args); \ *************** *** 759,763 **** self->in_callback = 1; rv = call_with_frame(getcode(ElementDecl, "ElementDecl", __LINE__), ! self->handlers[ElementDecl], args); self->in_callback = 0; if (rv == NULL) { --- 761,765 ---- self->in_callback = 1; rv = call_with_frame(getcode(ElementDecl, "ElementDecl", __LINE__), ! self->handlers[ElementDecl], args, self); self->in_callback = 0; if (rv == NULL) { From nnorwitz at users.sourceforge.net Fri Aug 13 05:18:36 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Fri Aug 13 05:18:39 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1085,1.1086 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1355/Misc Modified Files: NEWS Log Message: SF patch #1005778, Fix seg fault if list object is modified during list.index() Backport candidate Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1085 retrieving revision 1.1086 diff -C2 -d -r1.1085 -r1.1086 *** NEWS 12 Aug 2004 18:37:10 -0000 1.1085 --- NEWS 13 Aug 2004 03:18:29 -0000 1.1086 *************** *** 13,16 **** --- 13,20 ---- ----------------- + - SF patch #1005778. Fix a seg fault if the list size changed while + calling list.index(). This could happen if a rich comparison function + modified the list. + - The ``func_name`` (a.k.a. ``__name__``) attribute of user-defined functions is now writable. From nnorwitz at users.sourceforge.net Fri Aug 13 05:19:01 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Fri Aug 13 05:19:04 2004 Subject: [Python-checkins] python/dist/src/Lib/test list_tests.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1355/Lib/test Modified Files: list_tests.py Log Message: SF patch #1005778, Fix seg fault if list object is modified during list.index() Backport candidate Index: list_tests.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/list_tests.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** list_tests.py 18 Jan 2004 21:03:23 -0000 1.2 --- list_tests.py 13 Aug 2004 03:18:29 -0000 1.3 *************** *** 312,315 **** --- 312,327 ---- self.assertEqual(a, self.type2test([-2, -1, 0, 1, 2])) + # Test modifying the list during index's iteration + class EvilCmp: + def __init__(self, victim): + self.victim = victim + def __eq__(self, other): + del self.victim[:] + return False + a = self.type2test() + a[:] = [EvilCmp(a) for _ in xrange(100)] + # This used to seg fault before patch #1005778 + self.assertRaises(ValueError, a.index, None) + def test_reverse(self): u = self.type2test([-2, -1, 0, 1, 2]) From nnorwitz at users.sourceforge.net Fri Aug 13 05:19:01 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Fri Aug 13 05:19:05 2004 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.220,2.221 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1355/Objects Modified Files: listobject.c Log Message: SF patch #1005778, Fix seg fault if list object is modified during list.index() Backport candidate Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.220 retrieving revision 2.221 diff -C2 -d -r2.220 -r2.221 *** listobject.c 8 Aug 2004 21:21:18 -0000 2.220 --- listobject.c 13 Aug 2004 03:18:27 -0000 2.221 *************** *** 2187,2193 **** stop = 0; } ! else if (stop > self->ob_size) ! stop = self->ob_size; ! for (i = start; i < stop; i++) { int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); if (cmp > 0) --- 2187,2191 ---- stop = 0; } ! for (i = start; i < stop && i < self->ob_size; i++) { int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); if (cmp > 0) From tim_one at users.sourceforge.net Fri Aug 13 05:55:07 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 13 05:55:11 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.64,1.65 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6538/Lib Modified Files: doctest.py Log Message: Doctest has new traceback gimmicks in 2.4. While trying to document them (which they are now), I had to rewrite the code to understand it. This has got to be the most DWIM part of doctest -- but in context is really necessary. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** doctest.py 13 Aug 2004 01:52:59 -0000 1.64 --- doctest.py 13 Aug 2004 03:55:05 -0000 1.65 *************** *** 1192,1205 **** # A regular expression for handling `want` strings that contain ! # expected exceptions. It divides `want` into two pieces: the ! # pre-exception output (`out`) and the exception message (`exc`), ! # as generated by traceback.format_exception_only(). (I assume ! # that the exception_only message is the first non-indented line ! # starting with word characters after the "Traceback ...".) ! _EXCEPTION_RE = re.compile(('^(?P.*)' ! '^(?PTraceback \((?:%s|%s)\):)\s*$.*?' ! '^(?P\w+.*)') % ! ('most recent call last', 'innermost last'), ! re.MULTILINE | re.DOTALL) def __run(self, test, compileflags, out): --- 1192,1216 ---- # A regular expression for handling `want` strings that contain ! # expected exceptions. It divides `want` into three pieces: ! # - the pre-exception output (`want`) ! # - the traceback header line (`hdr`) ! # - the exception message (`msg`), as generated by ! # traceback.format_exception_only() ! # `msg` may have multiple lines. We assume/require that the ! # exception message is the first non-indented line starting with a word ! # character following the traceback header line. ! _EXCEPTION_RE = re.compile(r""" ! (?P .*?) # suck up everything until traceback header ! # Grab the traceback header. Different versions of Python have ! # said different things on the first traceback line. ! ^(?P Traceback\ \( ! (?: most\ recent\ call\ last ! | innermost\ last ! ) \) : ! ) ! \s* $ # toss trailing whitespace on traceback header ! .*? # don't blink: absorb stuff until a line *starts* with \w ! ^ (?P \w+ .*) ! """, re.VERBOSE | re.MULTILINE | re.DOTALL) def __run(self, test, compileflags, out): *************** *** 1275,1292 **** failures += 1 else: ! exc_hdr = m.group('hdr')+'\n' # Exception header # The test passes iff the pre-exception output and # the exception description match the values given # in `want`. ! if (self._checker.check_output(m.group('out'), got, self.optionflags) and ! self._checker.check_output(m.group('exc'), exc_msg, self.optionflags)): - # Is +exc_msg the right thing here?? self.report_success(out, test, example, ! got+_exception_traceback(exc_info)) else: self.report_failure(out, test, example, ! got+_exception_traceback(exc_info)) failures += 1 --- 1286,1302 ---- failures += 1 else: ! e_want, e_msg = m.group('want', 'msg') # The test passes iff the pre-exception output and # the exception description match the values given # in `want`. ! if (self._checker.check_output(e_want, got, self.optionflags) and ! self._checker.check_output(e_msg, exc_msg, self.optionflags)): self.report_success(out, test, example, ! got + _exception_traceback(exc_info)) else: self.report_failure(out, test, example, ! got + _exception_traceback(exc_info)) failures += 1 From tim_one at users.sourceforge.net Fri Aug 13 05:55:07 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 13 05:55:12 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6538/Doc/lib Modified Files: libdoctest.tex Log Message: Doctest has new traceback gimmicks in 2.4. While trying to document them (which they are now), I had to rewrite the code to understand it. This has got to be the most DWIM part of doctest -- but in context is really necessary. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** libdoctest.tex 13 Aug 2004 01:49:12 -0000 1.25 --- libdoctest.tex 13 Aug 2004 03:55:05 -0000 1.26 *************** *** 109,113 **** Trying: [factorial(long(n)) for n in range(6)] Expecting: [1, 1, 2, 6, 24, 120] ! ok\end{verbatim} And so on, eventually ending with: --- 109,114 ---- Trying: [factorial(long(n)) for n in range(6)] Expecting: [1, 1, 2, 6, 24, 120] ! ok ! \end{verbatim} And so on, eventually ending with: *************** *** 130,139 **** That's all you need to know to start making productive use of ! \module{doctest}! Jump in. \subsection{Simple Usage} ! The simplest (not necessarily the best) way to start using doctest is to ! end each module \module{M} with: \begin{verbatim} --- 131,142 ---- That's all you need to know to start making productive use of ! \module{doctest}! Jump in. The following sections provide full ! details. Note that there are many examples of doctests in ! the standard Python test suite and libraries. \subsection{Simple Usage} ! The simplest way to start using doctest (but not necessarily the way ! you'll continue to do it) is to end each module \module{M} with: \begin{verbatim} *************** *** 147,152 **** \module{doctest} then examines docstrings in the module calling ! \function{testmod()}. If you want to test a different module, you can ! pass that module object to \function{testmod()}. Running the module as a script causes the examples in the docstrings --- 150,154 ---- \module{doctest} then examines docstrings in the module calling ! \function{testmod()}. Running the module as a script causes the examples in the docstrings *************** *** 293,312 **** \subsection{What's the Execution Context?} ! By default, each time \function{testmod()} finds a docstring to test, it uses ! a \emph{copy} of \module{M}'s globals, so that running tests on a module doesn't change the module's real globals, and so that one test in \module{M} can't leave behind crumbs that accidentally allow another test to work. This means examples can freely use any names defined at top-level in \module{M}, and names defined earlier in the docstring being run. You can force use of your own dict as the execution context by passing ! \code{globs=your_dict} to \function{testmod()} instead. Presumably this ! would be a copy of \code{M.__dict__} merged with the globals from other ! imported modules. \subsection{What About Exceptions?} ! No problem, as long as the only output generated by the example is the ! traceback itself. For example: \begin{verbatim} --- 295,317 ---- \subsection{What's the Execution Context?} ! By default, each time \function{testmod()} finds a docstring to test, it ! uses a \emph{shallow copy} of \module{M}'s globals, so that running tests doesn't change the module's real globals, and so that one test in \module{M} can't leave behind crumbs that accidentally allow another test to work. This means examples can freely use any names defined at top-level in \module{M}, and names defined earlier in the docstring being run. + Examples cannot see names defined in other docstrings. You can force use of your own dict as the execution context by passing ! \code{globs=your_dict} to \function{testmod()} instead. \subsection{What About Exceptions?} ! No problem: just paste in the expected traceback. Since ! tracebacks contain details that are likely to change ! rapidly (for example, exact file paths and line numbers), this is one ! case where doctest works hard to be flexible in what it accepts. ! This makes the full story involved, but you really don't have ! to remember much. Simple example: \begin{verbatim} *************** *** 315,325 **** File "", line 1, in ? ValueError: list.remove(x): x not in list - >>> \end{verbatim} ! Note that only the exception type and value are compared (specifically, ! only the last line in the traceback). The various ``File'' lines in ! between can be left out (unless they add significantly to the documentation ! value of the example). \subsection{Option Flags and Directive Names\label{doctest-options}} --- 320,387 ---- File "", line 1, in ? ValueError: list.remove(x): x not in list \end{verbatim} ! That doctest succeeds if, and only if, \exception{ValueError} is raised, ! with the \samp{list.remove(x): x not in list} detail as shown. ! ! The expected output for an exception is divided into four parts. ! First, an example may produce some normal output before an exception ! is raised, although that's unusual. The "normal output" is taken to ! be everything until the first "Traceback" line, and is usually an ! empty string. Next, the traceback line must be one of these two, and ! indented the same as the first line in the example: ! ! \begin{verbatim} ! Traceback (most recent call last): ! Traceback (innermost last): ! \end{verbatim} ! ! The most interesting part is the last part: the line(s) starting with the ! exception type and detail. This is usually the last line of a traceback, ! but can extend across any number of lines. After the "Traceback" line, ! doctest simply ignores everything until the first line indented the same as ! the first line of the example, \emph{and} starting with an alphanumeric ! character. This example illustrates the complexities that are possible: ! ! \begin{verbatim} ! >>> print 1, 2; raise ValueError('printed 1\nand 2\n but not 3') ! 1 2 ! Traceback (most recent call last): ! ... indented the same, but doesn't start with an alphanumeric ! not indented the same, so ignored too ! File "/Python23/lib/doctest.py", line 442, in _run_examples_inner ! compileflags, 1) in globs ! File "", line 1, in ? # and all these are ignored ! ValueError: printed 1 ! and 2 ! but not 3 ! \end{verbatim} ! ! The first (\samp{1 2}) and last three (starting with ! \exception{ValueError}) lines are compared, and the rest are ignored. ! ! Best practice is to omit the ``File'' lines, unless they add ! significant documentation value to the example. So the example above ! is probably better as: ! ! \begin{verbatim} ! >>> print 1, 2; raise ValueError('printed 1\nand 2\n but not 3') ! 1 2 ! Traceback (most recent call last): ! ... ! ValueError: printed 1 ! and 2 ! but not 3 ! \end{verbatim} ! ! Note the tracebacks are treated very specially. In particular, in the ! rewritten example, the use of \samp{...} is independent of doctest's ! \constant{ELLIPSIS} option. The ellipsis in that example could ! be left out, or could just as well be three (or three hundred) commas. ! ! \versionchanged[The abilities to check both normal output and an ! exception in a single example, and to have a multi-line ! exception detail, were added]{2.4} ! \subsection{Option Flags and Directive Names\label{doctest-options}} From tim_one at users.sourceforge.net Fri Aug 13 05:57:24 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 13 05:57:27 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_funcattrs.py, 1.14, 1.15 test_new.py, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7111/Lib/test Modified Files: test_funcattrs.py test_new.py Log Message: Whitespace normalization. Index: test_funcattrs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_funcattrs.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** test_funcattrs.py 12 Aug 2004 18:12:43 -0000 1.14 --- test_funcattrs.py 13 Aug 2004 03:57:22 -0000 1.15 *************** *** 277,281 **** cantset(f, "func_globals", 1) cantset(f, "__name__", 1) ! def test_func_code(): --- 277,281 ---- cantset(f, "func_globals", 1) cantset(f, "__name__", 1) ! def test_func_code(): Index: test_new.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_new.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** test_new.py 12 Aug 2004 17:56:29 -0000 1.18 --- test_new.py 13 Aug 2004 03:57:22 -0000 1.19 *************** *** 101,105 **** if hasattr(new, 'code'): def f(a): pass ! c = f.func_code argcount = c.co_argcount --- 101,105 ---- if hasattr(new, 'code'): def f(a): pass ! c = f.func_code argcount = c.co_argcount *************** *** 117,130 **** freevars = c.co_freevars cellvars = c.co_cellvars ! d = new.code(argcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab, freevars, cellvars) ! # test backwards-compatibility version with no freevars or cellvars d = new.code(argcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab) ! try: # this used to trigger a SystemError d = new.code(-argcount, nlocals, stacksize, flags, codestring, --- 117,130 ---- freevars = c.co_freevars cellvars = c.co_cellvars ! d = new.code(argcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab, freevars, cellvars) ! # test backwards-compatibility version with no freevars or cellvars d = new.code(argcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab) ! try: # this used to trigger a SystemError d = new.code(-argcount, nlocals, stacksize, flags, codestring, *************** *** 144,148 **** else: raise TestFailed, "negative co_nlocals didn't trigger an exception" ! try: # this used to trigger a Py_FatalError! d = new.code(argcount, nlocals, stacksize, flags, codestring, --- 144,148 ---- else: raise TestFailed, "negative co_nlocals didn't trigger an exception" ! try: # this used to trigger a Py_FatalError! d = new.code(argcount, nlocals, stacksize, flags, codestring, From rhettinger at users.sourceforge.net Fri Aug 13 09:12:49 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Aug 13 09:12:53 2004 Subject: [Python-checkins] python/dist/src/Lib weakref.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30827 Modified Files: weakref.py Log Message: Convert weak iterators to generator form. Index: weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/weakref.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** weakref.py 2 Jul 2004 18:57:42 -0000 1.23 --- weakref.py 13 Aug 2004 07:12:45 -0000 1.24 *************** *** 278,330 **** ! class BaseIter: ! def __iter__(self): ! return self ! ! ! class WeakKeyedKeyIterator(BaseIter): ! def __init__(self, weakdict): ! self._next = weakdict.data.iterkeys().next ! ! def next(self): ! while 1: ! wr = self._next() ! obj = wr() ! if obj is not None: ! return obj ! ! ! class WeakKeyedItemIterator(BaseIter): ! def __init__(self, weakdict): ! self._next = weakdict.data.iteritems().next ! ! def next(self): ! while 1: ! wr, value = self._next() ! key = wr() ! if key is not None: ! return key, value ! ! ! class WeakValuedValueIterator(BaseIter): ! def __init__(self, weakdict): ! self._next = weakdict.data.itervalues().next ! ! def next(self): ! while 1: ! wr = self._next() ! obj = wr() ! if obj is not None: ! return obj ! class WeakValuedItemIterator(BaseIter): ! def __init__(self, weakdict): ! self._next = weakdict.data.itervalues().next ! def next(self): ! while 1: ! wr = self._next() ! value = wr() ! if value is not None: ! return wr.key, value --- 278,302 ---- ! def WeakKeyedKeyIterator(weakdict): ! for wr in weakdict.data.iterkeys(): ! obj = wr() ! if obj is not None: ! yield obj + def WeakKeyedItemIterator(weakdict): + for wr, value in weakdict.data.iteritems(): + key = wr() + if key is not None: + yield key, value ! def WeakValuedValueIterator(weakdict): ! for wr in weakdict.data.itervalues(): ! obj = wr() ! if obj is not None: ! yield obj ! def WeakValuedItemIterator(weakdict): ! for wr in weakdict.data.itervalues(): ! value = wr() ! if value is not None: ! yield wr.key, value From erica55 at bol.com.br Fri Aug 13 16:34:46 2004 From: erica55 at bol.com.br (Erica Silveira) Date: Fri Aug 13 16:34:39 2004 Subject: [Python-checkins] Mala direta por e-mail - As melhores listas de email Message-ID: <20040813143437.EC4351E43C2@bag.python.org> Mala direta por e-mail. Cadastros selecionados. As melhores listas de e-mails selecionados por estados, atividades e profiss?es. Listas atualizadas para mala direta via e-mail marketing. Visite http://www.promonet.mx.gs Cadastros altamente selecionados para divulga??o de produtos por email marketing. Listas de e-mails e programas gr?tis para divulga??o via correio eletr?nico. Mala direta por e-mail. Visite agora: http://www.promonet.mx.gs From loewis at users.sourceforge.net Fri Aug 13 17:25:31 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Aug 13 17:25:35 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py, 1.26, 1.27 msilib.py, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16471 Modified Files: msi.py msilib.py Log Message: Add support for advertised shortcuts and extensions Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** msi.py 5 Aug 2004 20:29:05 -0000 1.26 --- msi.py 13 Aug 2004 15:25:28 -0000 1.27 *************** *** 281,284 **** --- 281,286 ---- # Bitmaps + if not os.path.exists(srcdir+r"\PC\python_icon.exe"): + raise "Run icons.mak in PC directory" add_data(db, "Binary", [("PythonWin", msilib.Binary(srcdir+r"\PCbuild\installer.bmp")), # 152x328 pixels *************** *** 287,290 **** --- 289,295 ---- ("py.ico",msilib.Binary(srcdir+r"\PC\py.ico")), ]) + add_data(db, "Icon", + [("python_icon.exe", msilib.Binary(srcdir+r"\PC\python_icon.exe"))]) + # Scripts open("inst.vbs","w").write(""" *************** *** 681,685 **** # column. def add_features(db): ! global default_feature, tcltk, htmlfiles, tools, testsuite, ext_feature default_feature = Feature(db, "DefaultFeature", "Python", "Python Interpreter and Libraries", --- 686,690 ---- # column. def add_features(db): ! global default_feature, tcltk, idle, htmlfiles, tools, testsuite, ext_feature default_feature = Feature(db, "DefaultFeature", "Python", "Python Interpreter and Libraries", *************** *** 688,693 **** "Make this Python installation the default Python installation", 3, parent = default_feature) ! tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, IDLE, pydoc", 5, parent = default_feature) htmlfiles = Feature(db, "Documentation", "Documentation", "Python HTMLHelp File", 7, parent = default_feature) --- 693,700 ---- "Make this Python installation the default Python installation", 3, parent = default_feature) ! tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, pydoc", 5, parent = default_feature) + idle = Feature(db, "IDLE", "IDLE", "IDLE (Python GUI)", 6, + parent = tcltk) htmlfiles = Feature(db, "Documentation", "Documentation", "Python HTMLHelp File", 7, parent = default_feature) *************** *** 768,773 **** if dir == "CVS" or dir.startswith("plat-"): continue ! elif dir in ["lib-tk", "idlelib", "Icons"]: tcltk.set_current() elif dir in ['test', 'output']: testsuite.set_current() --- 775,782 ---- if dir == "CVS" or dir.startswith("plat-"): continue ! elif dir in ["lib-tk"]: tcltk.set_current() + elif dir in ["idlelib", "Icons"]: + idle.set_current() elif dir in ['test', 'output']: testsuite.set_current() *************** *** 775,778 **** --- 784,791 ---- default_feature.set_current() lib = Directory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir)) + # Register keyfiles for components which need them + if dir=="idlelib": + lib.start_component("idlelib", keyfile="idle.pyw") + # Add additional files dirs[dir]=lib lib.glob("*.txt") *************** *** 874,878 **** lib = Directory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f)) lib.glob("*.py") ! lib.glob("*.pyw") lib.remove_pyc() lib.glob("*.txt") --- 887,891 ---- lib = Directory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f)) lib.glob("*.py") ! lib.glob("*.pyw", exclude=['pydocgui.pyw']) lib.remove_pyc() lib.glob("*.txt") *************** *** 882,888 **** --- 895,904 ---- if f == 'Scripts': lib.add_file("README.txt", src="README") + lib.start_component("pydocgui.pyw", tcltk, keyfile="pydocgui.pyw") + lib.add_file("pydocgui.pyw") # Add documentation htmlfiles.set_current() lib = Directory(db, cab, root, "Doc", "Doc", "DOC|Doc") + lib.start_component("documentation", keyfile="Python%s%s.chm" % (major,minor)) lib.add_file("Python%s%s.chm" % (major, minor)) *************** *** 903,907 **** "InstallPath"), ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", 4, ! None, "py.ext"), ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", 4, "&%s <> 2" % ext_feature.id, "py.IDLE")]) --- 919,923 ---- "InstallPath"), ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", 4, ! None, None), ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", 4, "&%s <> 2" % ext_feature.id, "py.IDLE")]) *************** *** 916,941 **** pat2 = r"Software\Classes\%sPython.%sFile\DefaultIcon" pat3 = r"Software\Classes\%sPython.%sFile" add_data(db, "Registry", ! [# Extensions ! ("py.ext", -1, r"Software\Classes\."+ext, "", ! "Python.File", "REGISTRY.def"), ! ("pyw.ext", -1, r"Software\Classes\."+ext+'w', "", ! "Python.NoConFile", "REGISTRY.def"), ! ("pyc.ext", -1, r"Software\Classes\."+ext+'c', "", ! "Python.CompiledFile", "REGISTRY.def"), ! ("pyo.ext", -1, r"Software\Classes\."+ext+'o', "", ! "Python.CompiledFile", "REGISTRY.def"), ! # MIME types ! ("py.mime", -1, r"Software\Classes\."+ext, "Content Type", ! "text/plain", "REGISTRY.def"), ! ("pyw.mime", -1, r"Software\Classes\."+ext+'w', "Content Type", ! "text/plain", "REGISTRY.def"), ! #Verbs ! ("py.open", -1, pat % (testprefix, "", "open"), "", ! r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"), ! ("pyw.open", -1, pat % (testprefix, "NoCon", "open"), "", ! r'"[TARGETDIR]pythonw.exe" "%1" %*', "REGISTRY.def"), ! ("pyc.open", -1, pat % (testprefix, "Compiled", "open"), "", ! r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"), ("py.IDLE", -1, pat % (testprefix, "", ewi), "", r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"', --- 932,957 ---- pat2 = r"Software\Classes\%sPython.%sFile\DefaultIcon" pat3 = r"Software\Classes\%sPython.%sFile" + # Advertised extensions + add_data(db, "Extension", + [("py", "python.exe", "Python.File", None, default_feature.id), + ("pyw", "pythonw.exe", "Python.NoConFile", None, default_feature.id), + ("pyc", "python.exe", "Python.CompiledFile", None, default_feature.id), + ("pyo", "python.exe", "Python.CompiledFile", None, default_feature.id)]) + # add_data(db, "MIME") XXX + add_data(db, "Verb", + [("py", "open", 1, None, r'-n -e "%1"'), + ("pyw", "open", 1, None, r'-n -e "%1"'), + ("pyc", "open", 1, None, r'-n -e "%1"'), + ("pyo", "open", 1, None, r'-n -e "%1"')]) + add_data(db, "ProgId", + [("Python.File", None, None, "Python File", "python_icon.exe", 0), + ("Python.NoConFile", None, None, "Python File (no console)", "python_icon.exe", 0), + ("Python.CompiledFile", None, None, "Compiled Python File", "python_icon.exe", 1)]) + + # Non-advertised verbs: for advertised verbs, we would need to invoke the same + # executable for both open and "Edit with IDLE". This cannot work, as we want + # to use pythonw.exe in either case add_data(db, "Registry", ! [#Verbs ("py.IDLE", -1, pat % (testprefix, "", ewi), "", r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"', *************** *** 944,961 **** r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"', "REGISTRY.tcl"), - #Icons - ("py.icon", -1, pat2 % (testprefix, ""), "", - r'[TARGETDIR]py.ico', "REGISTRY.def"), - ("pyw.icon", -1, pat2 % (testprefix, "NoCon"), "", - r'[TARGETDIR]py.ico', "REGISTRY.def"), - ("pyc.icon", -1, pat2 % (testprefix, "Compiled"), "", - r'[TARGETDIR]pyc.ico', "REGISTRY.def"), - # Descriptions - ("py.txt", -1, pat3 % (testprefix, ""), "", - "Python File", "REGISTRY.def"), - ("pyw.txt", -1, pat3 % (testprefix, "NoCon"), "", - "Python File (no console)", "REGISTRY.def"), - ("pyc.txt", -1, pat3 % (testprefix, "Compiled"), "", - "Compiled Python File", "REGISTRY.def"), ]) --- 960,963 ---- *************** *** 982,1011 **** add_data(db, "Shortcut", [# Advertised shortcuts: targets are features, not files ! # The key file of the component is then entered as the real target ! # XXX, advertised shortcuts don't work, so make them unadvertised ! # for now ! #("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe", ! # tcltk.id, r"[TARGETDIR]Lib\idlelib\idle.pyw", ! # None, None, None, "py.ico", None, "TARGETDIR"), ! #("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe", ! # default_feature.id, r"[TARGETDIR]Tools\scripts\pydocgui.pyw", ! # None, None, None, "py.ico", None, "TARGETDIR"), ! #("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe", ! # default_feature.id, None, ! # None, None, None, "py.ico", None, "TARGETDIR"), ! ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "REGISTRY", ! r"[TARGETDIR]pythonw.exe", r"[TARGETDIR]Lib\idlelib\idle.pyw", ! None, None, None, None, None, "TARGETDIR"), ! ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "REGISTRY", ! r"[TARGETDIR]pythonw.exe", r"[TARGETDIR]Tools\scripts\pydocgui.pyw", ! None, None, None, None, None, "TARGETDIR"), ! ("Python", "MenuDir", "PYTHON|Python (command line)", "REGISTRY", ! r"[TARGETDIR]python.exe", None, ! None, None, None, None, None, "TARGETDIR"), ! ! ## Non-advertised features: must be associated with a registry component ! ("Manual", "MenuDir", "MANUAL|Python Manuals", "REGISTRY", ! r"[TARGETDIR]Doc\python%s%s.chm" % (major, minor), None, ! None, None, None, None, None, None), ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY", SystemFolderName+"msiexec", "/x%s" % product_code, --- 984,996 ---- add_data(db, "Shortcut", [# Advertised shortcuts: targets are features, not files ! ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe", ! idle.id, r"[TARGETDIR]Lib\idlelib\idle.pyw", None, None, "python_icon.exe", 0, None, "TARGETDIR"), ! ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe", ! tcltk.id, r"[TARGETDIR]Tools\scripts\pydocgui.pyw", None, None, "python_icon.exe", 0, None, "TARGETDIR"), ! ("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe", ! default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"), ! ("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation", ! htmlfiles.id, None, None, None, None, None, None, None), ! ## Non-advertised shortcuts: must be associated with a registry component ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY", SystemFolderName+"msiexec", "/x%s" % product_code, Index: msilib.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msilib.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** msilib.py 1 Aug 2004 22:14:19 -0000 1.10 --- msilib.py 13 Aug 2004 15:25:28 -0000 1.11 *************** *** 430,435 **** add_data(db, "Directory", [(logical, blogical, default)]) ! def start_component(self, component, feature = None, flags = 0, keyfile = None): uuid = gen_uuid() self.component = component if Win64: --- 430,437 ---- add_data(db, "Directory", [(logical, blogical, default)]) ! def start_component(self, component = None, feature = None, flags = 0, keyfile = None): uuid = gen_uuid() + if component is None: + component = self.logical self.component = component if Win64: *************** *** 522,528 **** # self.logical, 2)]) ! def glob(self, pattern): files = glob.glob1(self.absolute, pattern) for f in files: self.add_file(f) return files --- 524,531 ---- # self.logical, 2)]) ! def glob(self, pattern, exclude = None): files = glob.glob1(self.absolute, pattern) for f in files: + if exclude and f in exclude: continue self.add_file(f) return files From loewis at users.sourceforge.net Fri Aug 13 17:26:42 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Aug 13 17:26:45 2004 Subject: [Python-checkins] python/dist/src/PC icons.mak, NONE, 1.1 icons.rc, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16663 Added Files: icons.mak icons.rc Log Message: Help compiling icons into an exe, for use with MSI advertisement. --- NEW FILE: icons.mak --- python_icon.exe: py.res empty.obj link /out:python_icon.exe /machine:x86 /subsystem:windows py.res empty.obj py.res: py.ico pyc.ico pycon.ico icons.rc rc /fo py.res icons.rc empty.obj: empty.c cl /c empty.c --- NEW FILE: icons.rc --- 101 ICON "py.ico" 102 ICON "pyc.ico" 103 ICON "pycon.ico" From bcannon at users.sourceforge.net Fri Aug 13 20:46:26 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Aug 13 20:46:29 2004 Subject: [Python-checkins] python/dist/src/Lib inspect.py,1.51,1.52 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21072/Lib Modified Files: inspect.py Log Message: 'inspect' was not listing the functions in a module properly if the module was reached through a symlink (was comparing path of module to path to function and were not matching because of the symlink). os.path.realpath() is now used to solve this discrepency. Closes bug #570300. Thanks Johannes Gijsbers for the fix. Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** inspect.py 15 Jun 2004 11:22:53 -0000 1.51 --- inspect.py 13 Aug 2004 18:46:23 -0000 1.52 *************** *** 381,385 **** for module in sys.modules.values(): if hasattr(module, '__file__'): ! modulesbyfile[getabsfile(module)] = module.__name__ if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) --- 381,387 ---- for module in sys.modules.values(): if hasattr(module, '__file__'): ! modulesbyfile[ ! os.path.realpath( ! getabsfile(module))] = module.__name__ if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) From bcannon at users.sourceforge.net Fri Aug 13 20:46:27 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Aug 13 20:46:33 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1086,1.1087 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21072/Misc Modified Files: NEWS Log Message: 'inspect' was not listing the functions in a module properly if the module was reached through a symlink (was comparing path of module to path to function and were not matching because of the symlink). os.path.realpath() is now used to solve this discrepency. Closes bug #570300. Thanks Johannes Gijsbers for the fix. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1086 retrieving revision 1.1087 diff -C2 -d -r1.1086 -r1.1087 *** NEWS 13 Aug 2004 03:18:29 -0000 1.1086 --- NEWS 13 Aug 2004 18:46:24 -0000 1.1087 *************** *** 42,45 **** --- 42,49 ---- ------- + - bug #570300: Fix inspect to resolve file locations using os.path.realpath() + so as to properly list all functions in a module when the module itself is + reached through a symlink. Thanks Johannes Gijsbers. + - doctest refactoring continued. See the docs for details. As part of this effort, some old and little- (never?) used features are now From akuchling at users.sourceforge.net Fri Aug 13 22:06:59 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Fri Aug 13 22:07:02 2004 Subject: [Python-checkins] python/dist/src/Lib asyncore.py,1.59,1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2450 Modified Files: asyncore.py Log Message: Back out patch #982681 Index: asyncore.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** asyncore.py 18 Jul 2004 06:14:41 -0000 1.59 --- asyncore.py 13 Aug 2004 20:06:57 -0000 1.60 *************** *** 264,277 **** # try to re-use a server port if possible try: - # Windows SO_REUSEADDR is very broken (from a unixy perspective) - if sys.platform == 'win32': - reuse_constant = socket.SO_EXCLUSIVEADDRUSE - else: - reuse_constant = socket.SO_REUSEADDR - self.socket.setsockopt( ! socket.SOL_SOCKET, reuse_constant, self.socket.getsockopt(socket.SOL_SOCKET, ! reuse_constant) | 1 ) except socket.error: --- 264,271 ---- # try to re-use a server port if possible try: self.socket.setsockopt( ! socket.SOL_SOCKET, socket.SO_REUSEADDR, self.socket.getsockopt(socket.SOL_SOCKET, ! socket.SO_REUSEADDR) | 1 ) except socket.error: From tim_one at users.sourceforge.net Fri Aug 13 23:55:24 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 13 23:55:27 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21931/Doc/lib Modified Files: libdoctest.tex Log Message: Another microburst of snail-like progress. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** libdoctest.tex 13 Aug 2004 03:55:05 -0000 1.26 --- libdoctest.tex 13 Aug 2004 21:55:21 -0000 1.27 *************** *** 184,273 **** attempted. - \begin{funcdesc}{testmod}{\optional{m}\optional{, name}\optional{, - globs}\optional{, verbose}\optional{, - isprivate}\optional{, report}\optional{, - optionflags}\optional{, extraglobs}\optional{, - raise_on_error}} - - All arguments are optional, and all except for \var{m} should be - specified in keyword form. - - Test examples in docstrings in functions and classes reachable - from module \var{m} (or the current module if \var{m} is not supplied - or is \code{None}), starting with \code{\var{m}.__doc__}. - - Also test examples reachable from dict \code{\var{m}.__test__}, if it - exists and is not \code{None}. \code{\var{m}.__test__} maps - names (strings) to functions, classes and strings; function and class - docstrings are searched for examples; strings are searched directly, - as if they were docstrings. - - Only docstrings attached to objects belonging to module \var{m} are - searched. - - Return \samp{(\var{failure_count}, \var{test_count})}. - - Optional argument \var{name} gives the name of the module; by default, - or if \code{None}, \code{\var{m}.__name__} is used. - - Optional argument \var{globs} gives a dict to be used as the globals - when executing examples; by default, or if \code{None}, - \code{\var{m}.__dict__} is used. A new shallow copy of this dict is - created for each docstring with examples, so that each docstring's - examples start with a clean slate. - - Optional argument \var{extraglobs} gives a dict merged into the - globals used to execute examples. This works like - \method{dict.update()}: if \var{globs} and \var{extraglobs} have a - common key, the associated value in \var{extraglobs} appears in the - combined dict. By default, or if \code{None}, no extra globals are - used. This is an advanced feature that allows parameterization of - doctests. For example, a doctest can be written for a base class, using - a generic name for the class, then reused to test any number of - subclasses by passing an \var{extraglobs} dict mapping the generic - name to the subclass to be tested. - - Optional argument \var{verbose} prints lots of stuff if true, and prints - only failures if false; by default, or if \code{None}, it's true - if and only if \code{'-v'} is in \code{sys.argv}. - - Optional argument \var{report} prints a summary at the end when true, - else prints nothing at the end. In verbose mode, the summary is - detailed, else the summary is very brief (in fact, empty if all tests - passed). - - Optional argument \var{optionflags} or's together option flags. See - see section \ref{doctest-options}. - - Optional argument \var{raise_on_error} defaults to false. If true, - an exception is raised upon the first failure or unexpected exception - in an example. This allows failures to be post-mortem debugged. - Default behavior is to continue running examples. - - Optional argument \var{isprivate} specifies a function used to - determine whether a name is private. The default function treats - all names as public. \var{isprivate} can be set to - \code{doctest.is_private} to skip over names that are - private according to Python's underscore naming convention. - \deprecated{2.4}{\var{isprivate} was a stupid idea -- don't use it. - If you need to skip tests based on name, filter the list returned by - \code{DocTestFinder.find()} instead.} - - % """ [XX] This is no longer true: - % Advanced tomfoolery: testmod runs methods of a local instance of - % class doctest.Tester, then merges the results into (or creates) - % global Tester instance doctest.master. Methods of doctest.master - % can be called directly too, if you want to do something unusual. - % Passing report=0 to testmod is especially useful then, to delay - % displaying a summary. Invoke doctest.master.summarize(verbose) - % when you're done fiddling. - - \versionchanged[The parameter \var{optionflags} was added]{2.3} - - \versionchanged[The parameters \var{extraglobs} and \var{raise_on_error} - were added]{2.4} - \end{funcdesc} - - \subsection{Which Docstrings Are Examined?} --- 184,187 ---- *************** *** 387,394 **** \subsection{Option Flags and Directive Names\label{doctest-options}} ! 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 doctest directives. \begin{datadesc}{DONT_ACCEPT_TRUE_FOR_1} --- 301,308 ---- \subsection{Option Flags and Directive Names\label{doctest-options}} ! A number of option flags control various aspects of doctest's comparison ! 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 doctest directives. \begin{datadesc}{DONT_ACCEPT_TRUE_FOR_1} *************** *** 446,451 **** \constant{NORMALIZE_WHITESPACE}, \constant{ELLIPSIS}, \constant{UNIFIED_DIFF}, and \constant{CONTEXT_DIFF} ! were added, and \code{} in expected output matches ! an empty line in actual output by default]{2.4} \subsection{Advanced Usage} --- 360,365 ---- \constant{NORMALIZE_WHITESPACE}, \constant{ELLIPSIS}, \constant{UNIFIED_DIFF}, and \constant{CONTEXT_DIFF} ! were added, and by default \code{} in expected output ! matches an empty line in actual output]{2.4} \subsection{Advanced Usage} *************** *** 467,479 **** \end{funcdesc} ! \begin{funcdesc}{testmod}{} ! This function provides the most basic interface to the doctests. ! It creates a local instance of class \class{Tester}, runs appropriate ! methods of that class, and merges the results into the global \class{Tester} ! instance, \code{master}. ! To get finer control than \function{testmod()} offers, create an instance ! of \class{Tester} with custom policies, or run methods of \code{master} ! directly. See \code{Tester.__doc__} for details. \end{funcdesc} --- 381,458 ---- \end{funcdesc} ! \begin{funcdesc}{testmod}{\optional{m}\optional{, name}\optional{, ! globs}\optional{, verbose}\optional{, ! isprivate}\optional{, report}\optional{, ! optionflags}\optional{, extraglobs}\optional{, ! raise_on_error}} ! All arguments are optional, and all except for \var{m} should be ! specified in keyword form. ! ! Test examples in docstrings in functions and classes reachable ! from module \var{m} (or the current module if \var{m} is not supplied ! or is \code{None}), starting with \code{\var{m}.__doc__}. ! ! Also test examples reachable from dict \code{\var{m}.__test__}, if it ! exists and is not \code{None}. \code{\var{m}.__test__} maps ! names (strings) to functions, classes and strings; function and class ! docstrings are searched for examples; strings are searched directly, ! as if they were docstrings. ! ! Only docstrings attached to objects belonging to module \var{m} are ! searched. ! ! Return \samp{(\var{failure_count}, \var{test_count})}. ! ! Optional argument \var{name} gives the name of the module; by default, ! or if \code{None}, \code{\var{m}.__name__} is used. ! ! Optional argument \var{globs} gives a dict to be used as the globals ! when executing examples; by default, or if \code{None}, ! \code{\var{m}.__dict__} is used. A new shallow copy of this dict is ! created for each docstring with examples, so that each docstring's ! examples start with a clean slate. ! ! Optional argument \var{extraglobs} gives a dict merged into the ! globals used to execute examples. This works like ! \method{dict.update()}: if \var{globs} and \var{extraglobs} have a ! common key, the associated value in \var{extraglobs} appears in the ! combined dict. By default, or if \code{None}, no extra globals are ! used. This is an advanced feature that allows parameterization of ! doctests. For example, a doctest can be written for a base class, using ! a generic name for the class, then reused to test any number of ! subclasses by passing an \var{extraglobs} dict mapping the generic ! name to the subclass to be tested. ! ! Optional argument \var{verbose} prints lots of stuff if true, and prints ! only failures if false; by default, or if \code{None}, it's true ! if and only if \code{'-v'} is in \code{sys.argv}. ! ! Optional argument \var{report} prints a summary at the end when true, ! else prints nothing at the end. In verbose mode, the summary is ! detailed, else the summary is very brief (in fact, empty if all tests ! passed). ! ! Optional argument \var{optionflags} or's together option flags. See ! see section \ref{doctest-options}. ! ! Optional argument \var{raise_on_error} defaults to false. If true, ! an exception is raised upon the first failure or unexpected exception ! in an example. This allows failures to be post-mortem debugged. ! Default behavior is to continue running examples. ! ! Optional argument \var{isprivate} specifies a function used to ! determine whether a name is private. The default function treats ! all names as public. \var{isprivate} can be set to ! \code{doctest.is_private} to skip over names that are ! private according to Python's underscore naming convention. ! \deprecated{2.4}{\var{isprivate} was a stupid idea -- don't use it. ! If you need to skip tests based on name, filter the list returned by ! \code{DocTestFinder.find()} instead.} ! ! \versionchanged[The parameter \var{optionflags} was added]{2.3} ! ! \versionchanged[The parameters \var{extraglobs} and \var{raise_on_error} ! were added]{2.4} \end{funcdesc} *************** *** 528,535 **** In most cases a copy-and-paste of an interactive console session works ! fine---just make sure the leading whitespace is rigidly consistent ! (you can mix tabs and spaces if you're too lazy to do it right, but ! \module{doctest} is not in the business of guessing what you think a tab ! means). \begin{verbatim} --- 507,518 ---- In most cases a copy-and-paste of an interactive console session works ! fine, but doctest isn't trying to do an exact emulation of any specific ! Python shell. All hard tab characters are expanded to spaces, using ! 8-column tab stops. If you don't believe tabs should mean that, too ! bad: don't use hard tabs, or write your own \class{DocTestParser} ! class. ! ! \versionchanged[Expanding tabs to spaces is new; previous versions ! tried to preserve hard tabs, with confusing results]{2.4} \begin{verbatim} *************** *** 561,565 **** \item Expected output cannot contain an all-whitespace line, since such a ! line is taken to signal the end of expected output. \item Output to stdout is captured, but not output to stderr (exception --- 544,553 ---- \item Expected output cannot contain an all-whitespace line, since such a ! line is taken to signal the end of expected output. If expected ! output does contain a blank line, put \code{} in your ! doctest example each place a blank line is expected. ! \versionchanged[\code{} was added; there was no way to ! use expected output containing empty lines in ! previous versions]{2.4} \item Output to stdout is captured, but not output to stderr (exception *************** *** 601,605 **** and as many leading whitespace characters are stripped from the expected output as appeared in the initial \code{'>\code{>}>~'} line ! that triggered it. \end{itemize} --- 589,593 ---- and as many leading whitespace characters are stripped from the expected output as appeared in the initial \code{'>\code{>}>~'} line ! that started the example. \end{itemize} From tim_one at users.sourceforge.net Sat Aug 14 00:34:17 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Aug 14 00:34:20 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1087,1.1088 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29444/Misc Modified Files: NEWS Log Message: Removed item about an asyncore patch that got backed out. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1087 retrieving revision 1.1088 diff -C2 -d -r1.1087 -r1.1088 *** NEWS 13 Aug 2004 18:46:24 -0000 1.1087 --- NEWS 13 Aug 2004 22:34:14 -0000 1.1088 *************** *** 273,279 **** string methods of the same name). - - asyncore's dispatcher.set_reuse_addr() now works correctly on Windows. - SF patch 982681. - - Non-blocking SSL sockets work again; they were broken in Python 2.3. SF patch 945642. --- 273,276 ---- From jlgijsbers at users.sourceforge.net Sat Aug 14 12:56:57 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 12:57:00 2004 Subject: [Python-checkins] python/dist/src/Lib/test test__locale.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22785 Modified Files: test__locale.py Log Message: Reset old locale after running tests. Not doing so broke test_format/test_unicode in some circumstances (patch #1007539/bug #992078). Index: test__locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test__locale.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test__locale.py 19 Dec 2003 01:16:03 -0000 1.4 --- test__locale.py 14 Aug 2004 10:56:54 -0000 1.5 *************** *** 14,34 **** 'es_ES.ISO8859-1', 'fr_FR.ISO8859-15', 'ru_RU.KOI8-R', 'ko_KR.eucKR'] ! saw_locale = 0 ! for loc in candidate_locales: ! try: ! setlocale(LC_NUMERIC, loc) ! except Error: ! continue ! if verbose: ! print "locale %r" % loc ! saw_locale = 1 ! nl_radixchar = nl_langinfo(RADIXCHAR) ! li_radixchar = localeconv()['decimal_point'] ! if nl_radixchar != li_radixchar: ! print "%r != %r" % (nl_radixchar, li_radixchar) ! nl_radixchar = nl_langinfo(THOUSEP) ! li_radixchar = localeconv()['thousands_sep'] ! if nl_radixchar != li_radixchar: ! print "%r != %r" % (nl_radixchar, li_radixchar) ! if not saw_locale: ! raise ImportError, "None of the listed locales found" --- 14,38 ---- 'es_ES.ISO8859-1', 'fr_FR.ISO8859-15', 'ru_RU.KOI8-R', 'ko_KR.eucKR'] ! oldlocale = setlocale(LC_NUMERIC) ! try: ! saw_locale = 0 ! for loc in candidate_locales: ! try: ! setlocale(LC_NUMERIC, loc) ! except Error: ! continue ! if verbose: ! print "locale %r" % loc ! saw_locale = 1 ! nl_radixchar = nl_langinfo(RADIXCHAR) ! li_radixchar = localeconv()['decimal_point'] ! if nl_radixchar != li_radixchar: ! print "%r != %r" % (nl_radixchar, li_radixchar) ! nl_radixchar = nl_langinfo(THOUSEP) ! li_radixchar = localeconv()['thousands_sep'] ! if nl_radixchar != li_radixchar: ! print "%r != %r" % (nl_radixchar, li_radixchar) ! if not saw_locale: ! raise ImportError, "None of the listed locales found" ! finally: ! setlocale(LC_NUMERIC, oldlocale) From jlgijsbers at users.sourceforge.net Sat Aug 14 15:30:04 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 15:30:11 2004 Subject: [Python-checkins] python/dist/src/Lib shutil.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13343 Modified Files: shutil.py Log Message: Raise an exception when src and dst refer to the same file via a hard link or a symbolic link (bug #851123 / patch #854853, thanks Gregory Ball). Index: shutil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/shutil.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** shutil.py 14 Jul 2004 00:45:59 -0000 1.30 --- shutil.py 14 Aug 2004 13:30:01 -0000 1.31 *************** *** 25,38 **** fdst.write(buf) def copyfile(src, dst): """Copy data from src to dst""" fsrc = None fdst = None - # check for same pathname; all platforms - _src = os.path.normcase(os.path.abspath(src)) - _dst = os.path.normcase(os.path.abspath(dst)) - if _src == _dst: - return try: fsrc = open(src, 'rb') --- 25,44 ---- fdst.write(buf) + def _samefile(src, dst): + # Macintosh, Unix. + if hasattr(os.path,'samefile'): + return os.path.samefile(src, dst) + + # All other platforms: check for same pathname. + return (os.path.normcase(os.path.abspath(src)) == + os.path.normcase(os.path.abspath(dst))) def copyfile(src, dst): """Copy data from src to dst""" + if _samefile(src, dst): + raise Error, "`%s` and `%s` are the same file" % (src, dst) + fsrc = None fdst = None try: fsrc = open(src, 'rb') From jlgijsbers at users.sourceforge.net Sat Aug 14 15:30:04 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 15:30:13 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_shutil.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13343/test Modified Files: test_shutil.py Log Message: Raise an exception when src and dst refer to the same file via a hard link or a symbolic link (bug #851123 / patch #854853, thanks Gregory Ball). Index: test_shutil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_shutil.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_shutil.py 14 Jul 2004 00:48:32 -0000 1.4 --- test_shutil.py 14 Aug 2004 13:30:02 -0000 1.5 *************** *** 7,10 **** --- 7,11 ---- import os.path from test import test_support + from test.test_support import TESTFN class TestShutil(unittest.TestCase): *************** *** 27,30 **** --- 28,51 ---- pass + if hasattr(os, "symlink"): + def test_dont_copy_file_onto_link_to_itself(self): + # bug 851123. + os.mkdir(TESTFN) + src = os.path.join(TESTFN,'cheese') + dst = os.path.join(TESTFN,'shop') + try: + f = open(src,'w') + f.write('cheddar') + f.close() + for funcname in 'link','symlink': + getattr(os, funcname)(src, dst) + self.assertRaises(shutil.Error, shutil.copyfile, src, dst) + self.assertEqual(open(src,'r').read(), 'cheddar') + os.remove(dst) + finally: + try: + shutil.rmtree(TESTFN) + except OSError: + pass From jlgijsbers at users.sourceforge.net Sat Aug 14 15:57:11 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 15:57:14 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_shutil.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17756 Modified Files: test_shutil.py Log Message: Unwrap too-smart loop: we can't use `src` for both hard and symbolic links. Index: test_shutil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_shutil.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_shutil.py 14 Aug 2004 13:30:02 -0000 1.5 --- test_shutil.py 14 Aug 2004 13:57:08 -0000 1.6 *************** *** 32,46 **** # bug 851123. os.mkdir(TESTFN) ! src = os.path.join(TESTFN,'cheese') ! dst = os.path.join(TESTFN,'shop') try: ! f = open(src,'w') f.write('cheddar') f.close() ! for funcname in 'link','symlink': ! getattr(os, funcname)(src, dst) ! self.assertRaises(shutil.Error, shutil.copyfile, src, dst) ! self.assertEqual(open(src,'r').read(), 'cheddar') ! os.remove(dst) finally: try: --- 32,54 ---- # bug 851123. os.mkdir(TESTFN) ! src = os.path.join(TESTFN, 'cheese') ! dst = os.path.join(TESTFN, 'shop') try: ! f = open(src, 'w') f.write('cheddar') f.close() ! ! os.link(src, dst) ! self.assertRaises(shutil.Error, shutil.copyfile, src, dst) ! self.assertEqual(open(src,'r').read(), 'cheddar') ! os.remove(dst) ! ! # Using `src` here would mean we end up with a symlink pointing ! # to TESTFN/TESTFN/cheese, while it should point at ! # TESTFN/cheese. ! os.symlink('cheese', dst) ! self.assertRaises(shutil.Error, shutil.copyfile, src, dst) ! self.assertEqual(open(src,'r').read(), 'cheddar') ! os.remove(dst) finally: try: From jlgijsbers at users.sourceforge.net Sat Aug 14 16:03:05 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 16:03:08 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1088,1.1089 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18683 Modified Files: NEWS Log Message: bug #851123: shutil.copyfile will raise an exception when trying to copy a file onto a link to itself. Thanks Gregory Ball. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1088 retrieving revision 1.1089 diff -C2 -d -r1.1088 -r1.1089 *** NEWS 13 Aug 2004 22:34:14 -0000 1.1088 --- NEWS 14 Aug 2004 14:03:03 -0000 1.1089 *************** *** 42,45 **** --- 42,48 ---- ------- + - bug #851123: shutil.copyfile will raise an exception when trying to copy a + file onto a link to itself. Thanks Gregory Ball. + - bug #570300: Fix inspect to resolve file locations using os.path.realpath() so as to properly list all functions in a module when the module itself is From jlgijsbers at users.sourceforge.net Sat Aug 14 16:41:35 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 16:41:38 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libposixpath.tex, 1.38, 1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24295/Doc/lib Modified Files: libposixpath.tex Log Message: bug 990669: os.path.normpath may alter the meaning of a path if it contains symbolic links. This has been documented in a comment since 1992, but is now in the library reference as well. Index: libposixpath.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libposixpath.tex,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** libposixpath.tex 29 Oct 2003 00:46:19 -0000 1.38 --- libposixpath.tex 14 Aug 2004 14:41:32 -0000 1.39 *************** *** 155,159 **** \code{A/foo/../B} all become \code{A/B}. It does not normalize the case (use \function{normcase()} for that). On Windows, it converts ! forward slashes to backward slashes. \end{funcdesc} --- 155,160 ---- \code{A/foo/../B} all become \code{A/B}. It does not normalize the case (use \function{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! \end{funcdesc} From jlgijsbers at users.sourceforge.net Sat Aug 14 16:41:35 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 16:41:39 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1089,1.1090 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24295/Misc Modified Files: NEWS Log Message: bug 990669: os.path.normpath may alter the meaning of a path if it contains symbolic links. This has been documented in a comment since 1992, but is now in the library reference as well. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1089 retrieving revision 1.1090 diff -C2 -d -r1.1089 -r1.1090 *** NEWS 14 Aug 2004 14:03:03 -0000 1.1089 --- NEWS 14 Aug 2004 14:41:32 -0000 1.1090 *************** *** 78,81 **** --- 78,85 ---- ------------- + - bug 990669: os.path.normpath may alter the meaning of a path if it contains + symbolic links. This has been documented in a comment since 1992, but is now in + the library reference as well. + New platforms ------------- From jlgijsbers at users.sourceforge.net Sat Aug 14 16:51:04 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 16:51:06 2004 Subject: [Python-checkins] python/dist/src/Lib shutil.py,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25609 Modified Files: shutil.py Log Message: Catch OSError raised when src or dst argument to os.path.samefile doesn't exist. Index: shutil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/shutil.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** shutil.py 14 Aug 2004 13:30:01 -0000 1.31 --- shutil.py 14 Aug 2004 14:51:01 -0000 1.32 *************** *** 28,32 **** # Macintosh, Unix. if hasattr(os.path,'samefile'): ! return os.path.samefile(src, dst) # All other platforms: check for same pathname. --- 28,35 ---- # Macintosh, Unix. if hasattr(os.path,'samefile'): ! try: ! return os.path.samefile(src, dst) ! except OSError: ! return False # All other platforms: check for same pathname. From jlgijsbers at users.sourceforge.net Sat Aug 14 17:01:55 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 17:01:58 2004 Subject: [Python-checkins] python/dist/src/Lib posixpath.py,1.70,1.71 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27018/Lib Modified Files: posixpath.py Log Message: bug #990669: os.path.realpath() will resolve symlinks before normalizing the path, as normalizing the path may alter the meaning of the path if it contains symlinks. Also add tests for infinite symlink loops and parent symlinks that need to be resolved. Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** posixpath.py 2 Aug 2004 14:54:16 -0000 1.70 --- posixpath.py 14 Aug 2004 15:01:53 -0000 1.71 *************** *** 401,407 **** """Return the canonical path of the specified filename, eliminating any symbolic links encountered in the path.""" ! filename = abspath(filename) ! ! bits = ['/'] + filename.split('/')[1:] for i in range(2, len(bits)+1): component = join(*bits[0:i]) --- 401,409 ---- """Return the canonical path of the specified filename, eliminating any symbolic links encountered in the path.""" ! if isabs(filename): ! bits = ['/'] + filename.split('/')[1:] ! else: ! bits = filename.split('/') ! for i in range(2, len(bits)+1): component = join(*bits[0:i]) *************** *** 411,421 **** if resolved is None: # Infinite loop -- return original component + rest of the path ! return join(*([component] + bits[i:])) else: newpath = join(*([resolved] + bits[i:])) ! return realpath(newpath) ! ! return filename def _resolve_link(path): --- 413,423 ---- if resolved is None: # Infinite loop -- return original component + rest of the path ! return abspath(join(*([component] + bits[i:]))) else: newpath = join(*([resolved] + bits[i:])) ! return realpath(newpath) + return abspath(filename) + def _resolve_link(path): From jlgijsbers at users.sourceforge.net Sat Aug 14 17:01:55 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 17:02:00 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_posixpath.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27018/Lib/test Modified Files: test_posixpath.py Log Message: bug #990669: os.path.realpath() will resolve symlinks before normalizing the path, as normalizing the path may alter the meaning of the path if it contains symlinks. Also add tests for infinite symlink loops and parent symlinks that need to be resolved. Index: test_posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_posixpath.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_posixpath.py 1 Jul 2003 03:33:31 -0000 1.9 --- test_posixpath.py 14 Aug 2004 15:01:53 -0000 1.10 *************** *** 3,6 **** --- 3,12 ---- import posixpath, os + from posixpath import realpath, abspath, join, dirname, basename + + # An absolute path to a temporary filename for testing. We can't rely on TESTFN + # being an absolute path, so we need this. + + ABSTFN = abspath(test_support.TESTFN) class PosixPathTest(unittest.TestCase): *************** *** 390,396 **** def test_realpath(self): ! self.assert_("foo" in posixpath.realpath("foo")) ! self.assertRaises(TypeError, posixpath.realpath) def test_main(): --- 396,489 ---- def test_realpath(self): ! self.assert_("foo" in realpath("foo")) self.assertRaises(TypeError, posixpath.realpath) + + if hasattr(os, "symlink"): + def test_realpath_basic(self): + # Basic operation. + try: + os.symlink(ABSTFN+"1", ABSTFN) + self.assertEqual(realpath(ABSTFN), ABSTFN+"1") + finally: + self.safe_remove(ABSTFN) + + def test_realpath_symlink_loops(self): + # Bug #930024, return the path unchanged if we get into an infinite + # symlink loop. + try: + old_path = abspath('.') + os.symlink(ABSTFN, ABSTFN) + self.assertEqual(realpath(ABSTFN), ABSTFN) + + os.symlink(ABSTFN+"1", ABSTFN+"2") + os.symlink(ABSTFN+"2", ABSTFN+"1") + self.assertEqual(realpath(ABSTFN+"1"), ABSTFN+"1") + self.assertEqual(realpath(ABSTFN+"2"), ABSTFN+"2") + + # Test using relative path as well. + os.chdir(dirname(ABSTFN)) + self.assertEqual(realpath(basename(ABSTFN)), ABSTFN) + finally: + os.chdir(old_path) + self.safe_remove(ABSTFN) + self.safe_remove(ABSTFN+"1") + self.safe_remove(ABSTFN+"2") + + def test_realpath_resolve_parents(self): + # We also need to resolve any symlinks in the parents of a relative + # path passed to realpath. E.g.: current working directory is + # /usr/doc with 'doc' being a symlink to /usr/share/doc. We call + # realpath("a"). This should return /usr/share/doc/a/. + try: + old_path = abspath('.') + os.mkdir(ABSTFN) + os.mkdir(ABSTFN + "/y") + os.symlink(ABSTFN + "/y", ABSTFN + "/k") + + os.chdir(ABSTFN + "/k") + self.assertEqual(realpath("a"), ABSTFN + "/y/a") + finally: + os.chdir(old_path) + self.safe_remove(ABSTFN + "/k") + self.safe_rmdir(ABSTFN + "/y") + self.safe_rmdir(ABSTFN) + + def test_realpath_resolve_before_normalizing(self): + # Bug #990669: Symbolic links should be resolved before we + # normalize the path. E.g.: if we have directories 'a', 'k' and 'y' + # in the following hierarchy: + # a/k/y + # + # and a symbolic link 'link-y' pointing to 'y' in directory 'a', + # then realpath("link-y/..") should return 'k', not 'a'. + try: + old_path = abspath('.') + os.mkdir(ABSTFN) + os.mkdir(ABSTFN + "/k") + os.mkdir(ABSTFN + "/k/y") + os.symlink(ABSTFN + "/k/y", ABSTFN + "/link-y") + + # Absolute path. + self.assertEqual(realpath(ABSTFN + "/link-y/.."), ABSTFN + "/k") + # Relative path. + os.chdir(dirname(ABSTFN)) + self.assertEqual(realpath(basename(ABSTFN) + "/link-y/.."), ABSTFN + "/k") + finally: + os.chdir(old_path) + self.safe_remove(ABSTFN + "/link-y") + self.safe_rmdir(ABSTFN + "/k/y") + self.safe_rmdir(ABSTFN + "/k") + self.safe_rmdir(ABSTFN) + + # Convenience functions for removing temporary files. + def pass_os_error(self, func, filename): + try: func(filename) + except OSError: pass + + def safe_remove(self, filename): + self.pass_os_error(os.remove, filename) + + def safe_rmdir(self, dirname): + self.pass_os_error(os.rmdir, dirname) def test_main(): From jlgijsbers at users.sourceforge.net Sat Aug 14 17:01:56 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 17:02:01 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1090,1.1091 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27018/Misc Modified Files: NEWS Log Message: bug #990669: os.path.realpath() will resolve symlinks before normalizing the path, as normalizing the path may alter the meaning of the path if it contains symlinks. Also add tests for infinite symlink loops and parent symlinks that need to be resolved. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1090 retrieving revision 1.1091 diff -C2 -d -r1.1090 -r1.1091 *** NEWS 14 Aug 2004 14:41:32 -0000 1.1090 --- NEWS 14 Aug 2004 15:01:53 -0000 1.1091 *************** *** 42,45 **** --- 42,49 ---- ------- + - bug #990669: os.path.realpath() will resolve symlinks before normalizing the + path, as normalizing the path may alter the meaning of the path if it + contains symlinks. + - bug #851123: shutil.copyfile will raise an exception when trying to copy a file onto a link to itself. Thanks Gregory Ball. *************** *** 78,82 **** ------------- ! - bug 990669: os.path.normpath may alter the meaning of a path if it contains symbolic links. This has been documented in a comment since 1992, but is now in the library reference as well. --- 82,86 ---- ------------- ! - bug #990669: os.path.normpath may alter the meaning of a path if it contains symbolic links. This has been documented in a comment since 1992, but is now in the library reference as well. From jlgijsbers at users.sourceforge.net Sat Aug 14 17:19:30 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 17:19:32 2004 Subject: [Python-checkins] python/dist/src/Lib pdb.doc, 1.8, 1.9 pdb.py, 1.67, 1.68 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29410/Lib Modified Files: pdb.doc pdb.py Log Message: bug #989672: pdb.doc and the help messages for the help_d and help_u methods of the pdb.Pdb class gives have been corrected. d(own) goes to a newer frame, u(p) to an older frame, not the other way around. Index: pdb.doc =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pdb.doc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pdb.doc 17 Sep 1998 15:01:38 -0000 1.8 --- pdb.doc 14 Aug 2004 15:19:27 -0000 1.9 *************** *** 71,79 **** d(own) Move the current frame one level down in the stack trace ! (to an older frame). u(p) Move the current frame one level up in the stack trace ! (to a newer frame). b(reak) [ ([filename:]lineno | function) [, condition] ] --- 71,79 ---- d(own) Move the current frame one level down in the stack trace ! (to a newer frame). u(p) Move the current frame one level up in the stack trace ! (to an older frame). b(reak) [ ([filename:]lineno | function) [, condition] ] Index: pdb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pdb.py,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** pdb.py 12 Feb 2004 17:35:06 -0000 1.67 --- pdb.py 14 Aug 2004 15:19:27 -0000 1.68 *************** *** 756,760 **** print """d(own) Move the current frame one level down in the stack trace ! (to an older frame).""" def help_up(self): --- 756,760 ---- print """d(own) Move the current frame one level down in the stack trace ! (to a newer frame).""" def help_up(self): *************** *** 764,768 **** print """u(p) Move the current frame one level up in the stack trace ! (to a newer frame).""" def help_break(self): --- 764,768 ---- print """u(p) Move the current frame one level up in the stack trace ! (to an older frame).""" def help_break(self): From jlgijsbers at users.sourceforge.net Sat Aug 14 17:19:30 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 17:19:33 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1091,1.1092 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29410/Misc Modified Files: NEWS Log Message: bug #989672: pdb.doc and the help messages for the help_d and help_u methods of the pdb.Pdb class gives have been corrected. d(own) goes to a newer frame, u(p) to an older frame, not the other way around. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1091 retrieving revision 1.1092 diff -C2 -d -r1.1091 -r1.1092 *** NEWS 14 Aug 2004 15:01:53 -0000 1.1091 --- NEWS 14 Aug 2004 15:19:28 -0000 1.1092 *************** *** 42,45 **** --- 42,49 ---- ------- + - bug #989672: pdb.doc and the help messages for the help_d and help_u methods + of the pdb.Pdb class gives have been corrected. d(own) goes to a newer frame, + u(p) to an older frame, not the other way around. + - bug #990669: os.path.realpath() will resolve symlinks before normalizing the path, as normalizing the path may alter the meaning of the path if it From jlgijsbers at users.sourceforge.net Sat Aug 14 17:39:36 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 14 17:39:39 2004 Subject: [Python-checkins] python/dist/src/Lib cgi.py,1.79,1.80 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31994 Modified Files: cgi.py Log Message: Let cgi.parse_header() properly unquote headers (patch #1008597). Index: cgi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgi.py,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** cgi.py 19 Jul 2004 15:37:24 -0000 1.79 --- cgi.py 14 Aug 2004 15:39:34 -0000 1.80 *************** *** 339,342 **** --- 339,343 ---- if len(value) >= 2 and value[0] == value[-1] == '"': value = value[1:-1] + value = value.replace('\\\\', '\\').replace('\\"', '"') pdict[name] = value return key, pdict From bcannon at users.sourceforge.net Sun Aug 15 03:15:04 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Aug 15 03:15:08 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.316,2.317 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20463/Python Modified Files: compile.c Log Message: Fix incorrect comment for (struct compiling)->c_cellvars Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.316 retrieving revision 2.317 diff -C2 -d -r2.316 -r2.317 *** compile.c 12 Aug 2004 18:16:43 -0000 2.316 --- compile.c 15 Aug 2004 01:15:01 -0000 2.317 *************** *** 722,726 **** PyObject *c_varnames; /* list (inverse of c_locals) */ PyObject *c_freevars; /* dictionary (value=None) */ ! PyObject *c_cellvars; /* list */ int c_nlocals; /* index of next local */ int c_argcount; /* number of top-level arguments */ --- 722,726 ---- PyObject *c_varnames; /* list (inverse of c_locals) */ PyObject *c_freevars; /* dictionary (value=None) */ ! PyObject *c_cellvars; /* dictionary */ int c_nlocals; /* index of next local */ int c_argcount; /* number of top-level arguments */ From bcannon at users.sourceforge.net Sun Aug 15 09:21:27 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Aug 15 09:21:31 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.317,2.318 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31674/Python Modified Files: compile.c Log Message: Correct the order of application for decorators. Meant to be bottom-up and not top-down. Now matches the PEP. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.317 retrieving revision 2.318 diff -C2 -d -r2.317 -r2.318 *** compile.c 15 Aug 2004 01:15:01 -0000 2.317 --- compile.c 15 Aug 2004 07:21:24 -0000 2.318 *************** *** 4133,4137 **** ndecorators = 0; ! for (i = NCH(n) - 1; i >= 0; --i) { node *ch = CHILD(n, i); if (TYPE(ch) != NEWLINE) { --- 4133,4140 ---- ndecorators = 0; ! /* the application order for decorators is the reverse of how they are ! listed; bottom-up */ ! nch -= 1; ! for (i = 0; i < nch; i+=1) { node *ch = CHILD(n, i); if (TYPE(ch) != NEWLINE) { From bcannon at users.sourceforge.net Sun Aug 15 09:21:27 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Aug 15 09:21:33 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decorators.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31674/Lib/test Modified Files: test_decorators.py Log Message: Correct the order of application for decorators. Meant to be bottom-up and not top-down. Now matches the PEP. Index: test_decorators.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decorators.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_decorators.py 4 Aug 2004 02:36:18 -0000 1.3 --- test_decorators.py 15 Aug 2004 07:21:25 -0000 1.4 *************** *** 130,134 **** # see the comment in countcalls. counts = {} ! @countcalls(counts) @memoize def double(x): return x * 2 --- 130,135 ---- # see the comment in countcalls. counts = {} ! @memoize ! @countcalls(counts) def double(x): return x * 2 *************** *** 187,196 **** def test_order(self): ! class C(object): ! @funcattrs(abc=1) @staticmethod ! def foo(): return 42 ! # This wouldn't work if staticmethod was called first ! self.assertEqual(C.foo(), 42) ! self.assertEqual(C().foo(), 42) def test_main(): --- 188,205 ---- def test_order(self): ! # Test that decorators are conceptually applied right-recursively; ! # that means bottom-up ! def ordercheck(num): ! def deco(func): ! return lambda: num ! return deco ! ! # Should go ordercheck(1)(ordercheck(2)(blah)) which should lead to ! # blah() == 1 ! @ordercheck(1) ! @ordercheck(2) ! def blah(): pass ! self.assertEqual(blah(), 1, "decorators are meant to be applied " ! "bottom-up") def test_main(): From bcannon at users.sourceforge.net Sun Aug 15 09:21:28 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Aug 15 09:21:34 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1092,1.1093 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31674/Misc Modified Files: NEWS Log Message: Correct the order of application for decorators. Meant to be bottom-up and not top-down. Now matches the PEP. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1092 retrieving revision 1.1093 diff -C2 -d -r1.1092 -r1.1093 *** NEWS 14 Aug 2004 15:19:28 -0000 1.1092 --- NEWS 15 Aug 2004 07:21:25 -0000 1.1093 *************** *** 13,16 **** --- 13,19 ---- ----------------- + - Fix the order of application of decorators. The proper order is bottom-up; + the first decorator listed is the last one called. + - SF patch #1005778. Fix a seg fault if the list size changed while calling list.index(). This could happen if a rich comparison function From jlgijsbers at users.sourceforge.net Sun Aug 15 14:23:12 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sun Aug 15 14:23:15 2004 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9920 Modified Files: _csv.c Log Message: Quote \r\n correctly, remove random indentation (patch #1009384). Thanks Cherniavsky Beni! Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** _csv.c 20 Jun 2004 04:23:19 -0000 1.14 --- _csv.c 15 Aug 2004 12:23:10 -0000 1.15 *************** *** 1413,1417 **** " doublequote = True\n" " skipinitialspace = False\n" ! " lineterminator = '\r\n'\n" " quoting = QUOTE_MINIMAL\n" "\n" --- 1413,1417 ---- " doublequote = True\n" " skipinitialspace = False\n" ! " lineterminator = '\\r\\n'\n" " quoting = QUOTE_MINIMAL\n" "\n" *************** *** 1458,1462 **** "\n" "The returned object is an iterator. Each iteration returns a row\n" ! "of the CSV file (which can span multiple input lines):\n"); PyDoc_STRVAR(csv_writer_doc, --- 1458,1462 ---- "\n" "The returned object is an iterator. Each iteration returns a row\n" ! "of the CSV file (which can span multiple input lines):\n"); PyDoc_STRVAR(csv_writer_doc, From montanaro at users.sourceforge.net Sun Aug 15 16:08:27 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Sun Aug 15 16:08:29 2004 Subject: [Python-checkins] python/dist/src configure, 1.452, 1.453 configure.in, 1.465, 1.466 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23802 Modified Files: configure configure.in Log Message: Match the def'n of _XOPEN_SOURCE on Solaris 8/9 to suppress redefinition warning from GCC. Closes patch #1006629. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.452 retrieving revision 1.453 diff -C2 -d -r1.452 -r1.453 *** configure 12 Aug 2004 13:45:08 -0000 1.452 --- configure 15 Aug 2004 14:08:22 -0000 1.453 *************** *** 1,9 **** #! /bin/sh ! # From configure.in Revision: 1.464 . # Guess values for system-dependent variables and create Makefiles. ! # Generated by GNU Autoconf 2.57 for python 2.4. # ! # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 ! # Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. --- 1,8 ---- [...12750 lines suppressed...] sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } *************** *** 19414,19421 **** as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ ! X"$as_dir" : 'X\(//\)[^/]' \| \ ! X"$as_dir" : 'X\(//\)$' \| \ ! X"$as_dir" : 'X\(/\)' \| \ ! . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } --- 21217,21224 ---- as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ ! X"$as_dir" : 'X\(//\)[^/]' \| \ ! X"$as_dir" : 'X\(//\)$' \| \ ! X"$as_dir" : 'X\(/\)' \| \ ! . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.465 retrieving revision 1.466 diff -C2 -d -r1.465 -r1.466 *** configure.in 12 Aug 2004 13:45:08 -0000 1.465 --- configure.in 15 Aug 2004 14:08:23 -0000 1.466 *************** *** 171,176 **** 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 --- 171,186 ---- if test $define_xopen_source = yes then ! # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be ! # defined precisely as g++ defines it ! case $ac_sys_system/$ac_sys_release in ! SunOS/5.8|SunOS/5.9) ! AC_DEFINE(_XOPEN_SOURCE, 500, ! Define to the level of X/Open that your system supports) ! ;; ! *) ! AC_DEFINE(_XOPEN_SOURCE, 600, ! Define to the level of X/Open that your system supports) ! ;; ! esac # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires From montanaro at users.sourceforge.net Sun Aug 15 16:32:09 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Sun Aug 15 16:32:12 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libreadline.tex, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28578/Doc/lib Modified Files: libreadline.tex Log Message: Add get_history_item and replace_history_item functions to the readline module. Closes patch #675551. My apologies to Michal Vitecek for taking so long to process this. Index: libreadline.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libreadline.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** libreadline.tex 24 May 2004 14:20:16 -0000 1.15 --- libreadline.tex 15 Aug 2004 14:32:06 -0000 1.16 *************** *** 72,75 **** --- 72,85 ---- \end{funcdesc} + \begin{funcdesc}{remove_history_item}{pos} + Remove history item specified by its position from the history. + \versionadded{2.4} + \end{funcdesc} + + \begin{funcdesc}{replace_history_item}{pos, line} + Replace history item specified by its position with the given line. + \versionadded{2.4} + \end{funcdesc} + \begin{funcdesc}{redisplay}{} Change what's displayed on the screen to reflect the current contents *************** *** 128,132 **** \end{funcdesc} - \begin{seealso} \seemodule{rlcompleter}{Completion of Python identifiers at the --- 138,141 ---- From montanaro at users.sourceforge.net Sun Aug 15 16:32:09 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Sun Aug 15 16:32:14 2004 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.72,2.73 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28578/Modules Modified Files: readline.c Log Message: Add get_history_item and replace_history_item functions to the readline module. Closes patch #675551. My apologies to Michal Vitecek for taking so long to process this. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.72 retrieving revision 2.73 diff -C2 -d -r2.72 -r2.73 *** readline.c 8 Jul 2004 15:28:18 -0000 2.72 --- readline.c 15 Aug 2004 14:31:57 -0000 2.73 *************** *** 295,298 **** --- 295,363 ---- set the readline word delimiters for tab-completion"); + static PyObject * + py_remove_history(PyObject *self, PyObject *args) + { + int entry_number; + HIST_ENTRY *entry; + + if (!PyArg_ParseTuple(args, "i:remove_history", &entry_number)) + return NULL; + entry = remove_history(entry_number); + if (!entry) { + char buf[80]; + PyOS_snprintf(buf, sizeof(buf), + "No history item at position %i", + entry_number); + PyErr_SetString(PyExc_ValueError, buf); + return NULL; + } + /* free memory allocated for the history entry */ + if (entry->line) + free(entry->line); + if (entry->data) + free(entry->data); + free(entry); + + Py_INCREF(Py_None); + return Py_None; + } + + PyDoc_STRVAR(doc_remove_history, + "remove_history(pos) -> None\n\ + remove history item given by its position"); + + static PyObject * + py_replace_history(PyObject *self, PyObject *args) + { + int entry_number; + char *line; + HIST_ENTRY *old_entry; + + if (!PyArg_ParseTuple(args, "is:replace_history", &entry_number, &line)) { + return NULL; + } + old_entry = replace_history_entry(entry_number, line, (void *)NULL); + if (!old_entry) { + char buf[80]; + PyOS_snprintf(buf, sizeof(buf), + "No history item at position %i", + entry_number); + PyErr_SetString(PyExc_ValueError, buf); + return NULL; + } + /* free memory allocated for the old history entry */ + if (old_entry->line) + free(old_entry->line); + if (old_entry->data) + free(old_entry->data); + free(old_entry); + + Py_INCREF(Py_None); + return Py_None; + } + + PyDoc_STRVAR(doc_replace_history, + "replace_history(pos, line) -> None\n\ + replaces history item given by its position with contents of line"); /* Add a line to the history buffer */ *************** *** 494,497 **** --- 559,564 ---- METH_VARARGS, doc_set_completer_delims}, {"add_history", py_add_history, METH_VARARGS, doc_add_history}, + {"remove_history_item", py_remove_history, METH_VARARGS, doc_remove_history}, + {"replace_history_item", py_replace_history, METH_VARARGS, doc_replace_history}, {"get_completer_delims", get_completer_delims, METH_NOARGS, doc_get_completer_delims}, From montanaro at users.sourceforge.net Sun Aug 15 16:32:29 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Sun Aug 15 16:32:32 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1093,1.1094 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28578/Misc Modified Files: NEWS Log Message: Add get_history_item and replace_history_item functions to the readline module. Closes patch #675551. My apologies to Michal Vitecek for taking so long to process this. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1093 retrieving revision 1.1094 diff -C2 -d -r1.1093 -r1.1094 *** NEWS 15 Aug 2004 07:21:25 -0000 1.1093 --- NEWS 15 Aug 2004 14:31:54 -0000 1.1094 *************** *** 45,51 **** ------- - bug #989672: pdb.doc and the help messages for the help_d and help_u methods ! of the pdb.Pdb class gives have been corrected. d(own) goes to a newer frame, ! u(p) to an older frame, not the other way around. - bug #990669: os.path.realpath() will resolve symlinks before normalizing the --- 45,54 ---- ------- + - patch #675551: Add get_history_item and replace_history_item functions + to the readline module. + - bug #989672: pdb.doc and the help messages for the help_d and help_u methods ! of the pdb.Pdb class gives have been corrected. d(own) goes to a newer ! frame, u(p) to an older frame, not the other way around. - bug #990669: os.path.realpath() will resolve symlinks before normalizing the *************** *** 83,86 **** --- 86,92 ---- processor's timestamp counter now works on PPC platforms. + - patch #1006629: Define _XOPEN_SOURCE to 500 on Solaris 8/9 to match + GCC's definition and avoid redefinition warnings. + C API ----- From doko at users.sourceforge.net Sun Aug 15 19:04:53 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Sun Aug 15 19:04:57 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1094,1.1095 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20414/Misc Modified Files: NEWS Log Message: - Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1094 retrieving revision 1.1095 diff -C2 -d -r1.1094 -r1.1095 *** NEWS 15 Aug 2004 14:31:54 -0000 1.1094 --- NEWS 15 Aug 2004 17:04:33 -0000 1.1095 *************** *** 77,80 **** --- 77,82 ---- any computable criteria before passing it to a DocTestRunner instance. + - Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)). + Tools/Demos ----------- From doko at users.sourceforge.net Sun Aug 15 19:05:05 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Sun Aug 15 19:05:08 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_inspect.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20414/Lib/test Modified Files: test_inspect.py Log Message: - Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)). Index: test_inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_inspect.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** test_inspect.py 5 Jun 2004 14:11:59 -0000 1.14 --- test_inspect.py 15 Aug 2004 17:04:32 -0000 1.15 *************** *** 375,376 **** --- 375,384 ---- count = len(filter(lambda x:x.startswith('is'), dir(inspect))) test(count == 11, "There are %d (not 11) is* functions", count) + + def sublistOfOne((foo)): return 1 + + args, varargs, varkw, defaults = inspect.getargspec(sublistOfOne) + test(args == [['foo']], 'sublistOfOne args') + test(varargs is None, 'sublistOfOne varargs') + test(varkw is None, 'sublistOfOne varkw') + test(defaults is None, 'sublistOfOn defaults') From doko at users.sourceforge.net Sun Aug 15 19:05:05 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Sun Aug 15 19:05:10 2004 Subject: [Python-checkins] python/dist/src/Lib inspect.py,1.52,1.53 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20414/Lib Modified Files: inspect.py Log Message: - Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)). Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** inspect.py 13 Aug 2004 18:46:23 -0000 1.52 --- inspect.py 15 Aug 2004 17:04:32 -0000 1.53 *************** *** 625,636 **** elif opname == 'STORE_FAST': stack.append(names[value]) ! remain[-1] = remain[-1] - 1 ! while remain[-1] == 0: ! remain.pop() ! size = count.pop() ! stack[-size:] = [stack[-size:]] ! if not remain: break remain[-1] = remain[-1] - 1 ! if not remain: break args[i] = stack[0] --- 625,644 ---- elif opname == 'STORE_FAST': stack.append(names[value]) ! ! # Special case for sublists of length 1: def foo((bar)) ! # doesn't generate the UNPACK_TUPLE bytecode, so if ! # `remain` is empty here, we have such a sublist. ! if not remain: ! stack[0] = [stack[0]] ! break ! else: remain[-1] = remain[-1] - 1 ! while remain[-1] == 0: ! remain.pop() ! size = count.pop() ! stack[-size:] = [stack[-size:]] ! if not remain: break ! remain[-1] = remain[-1] - 1 ! if not remain: break args[i] = stack[0] From doko at users.sourceforge.net Sun Aug 15 19:16:28 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Sun Aug 15 19:16:30 2004 Subject: [Python-checkins] python/dist/src/Lib inspect.py,1.47.8.1,1.47.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22377/Lib Modified Files: Tag: release23-maint inspect.py Log Message: - Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)). Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.47.8.1 retrieving revision 1.47.8.2 diff -C2 -d -r1.47.8.1 -r1.47.8.2 *** inspect.py 5 Jun 2004 14:14:48 -0000 1.47.8.1 --- inspect.py 15 Aug 2004 17:16:25 -0000 1.47.8.2 *************** *** 622,633 **** elif opname == 'STORE_FAST': stack.append(names[value]) ! remain[-1] = remain[-1] - 1 ! while remain[-1] == 0: ! remain.pop() ! size = count.pop() ! stack[-size:] = [stack[-size:]] ! if not remain: break remain[-1] = remain[-1] - 1 ! if not remain: break args[i] = stack[0] --- 622,641 ---- elif opname == 'STORE_FAST': stack.append(names[value]) ! ! # Special case for sublists of length 1: def foo((bar)) ! # doesn't generate the UNPACK_TUPLE bytecode, so if ! # `remain` is empty here, we have such a sublist. ! if not remain: ! stack[0] = [stack[0]] ! break ! else: remain[-1] = remain[-1] - 1 ! while remain[-1] == 0: ! remain.pop() ! size = count.pop() ! stack[-size:] = [stack[-size:]] ! if not remain: break ! remain[-1] = remain[-1] - 1 ! if not remain: break args[i] = stack[0] From doko at users.sourceforge.net Sun Aug 15 19:16:28 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Sun Aug 15 19:16:34 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_inspect.py, 1.12.8.2, 1.12.8.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22377/Lib/test Modified Files: Tag: release23-maint test_inspect.py Log Message: - Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)). Index: test_inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_inspect.py,v retrieving revision 1.12.8.2 retrieving revision 1.12.8.3 diff -C2 -d -r1.12.8.2 -r1.12.8.3 *** test_inspect.py 5 Jun 2004 14:14:48 -0000 1.12.8.2 --- test_inspect.py 15 Aug 2004 17:16:25 -0000 1.12.8.3 *************** *** 375,376 **** --- 375,384 ---- count = len(filter(lambda x:x.startswith('is'), dir(inspect))) test(count == 11, "There are %d (not 11) is* functions", count) + + def sublistOfOne((foo)): return 1 + + args, varargs, varkw, defaults = inspect.getargspec(sublistOfOne) + test(args == [['foo']], 'sublistOfOne args') + test(varargs is None, 'sublistOfOne varargs') + test(varkw is None, 'sublistOfOne varkw') + test(defaults is None, 'sublistOfOn defaults') From doko at users.sourceforge.net Sun Aug 15 19:16:28 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Sun Aug 15 19:16:36 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.139, 1.831.4.140 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22377/Misc Modified Files: Tag: release23-maint NEWS Log Message: - Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.139 retrieving revision 1.831.4.140 diff -C2 -d -r1.831.4.139 -r1.831.4.140 *** NEWS 12 Aug 2004 13:44:45 -0000 1.831.4.139 --- NEWS 15 Aug 2004 17:16:25 -0000 1.831.4.140 *************** *** 93,96 **** --- 93,98 ---- - Bug #934282: make pydoc.stripid() be case-insensitive. + - Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)). + Build ----- From rhettinger at users.sourceforge.net Mon Aug 16 01:28:13 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Aug 16 01:28:15 2004 Subject: [Python-checkins] python/dist/src/Doc/ref ref5.tex,1.82,1.83 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16053 Modified Files: ref5.tex Log Message: SF patch #872326: generator expression implementation (Contributed by Jiwon Seo.) Add genexps to the reference manual. Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** ref5.tex 7 Aug 2004 19:16:32 -0000 1.82 --- ref5.tex 15 Aug 2004 23:28:10 -0000 1.83 *************** *** 56,60 **** \production{enclosure} {\token{parenth_form} | \token{list_display}} ! \productioncont{| \token{dict_display} | \token{string_conversion}} \end{productionlist} --- 56,61 ---- \production{enclosure} {\token{parenth_form} | \token{list_display}} ! \productioncont{| \token{generator_expression | \token{dict_display}}} ! \productioncont{| \token{string_conversion}} \end{productionlist} *************** *** 194,197 **** --- 195,240 ---- + \subsection{Generator expressions\label{genexpr}} + \indexii{generator}{expression} + + A generator expression is a compact generator notation in parentheses: + + \begin{productionlist} + \production{generator_expression} + {"(" \token{test} \token{genexpr_for} ")"} + \production{genexpr_for} + {"for" \token{expression_list} "in" \token{test} + [\token{genexpr_iter}]} + \production{genexpr_iter} + {\token{genexpr_for} | \token{genexpr_if}} + \production{genexpr_if} + {"if" \token{test} [\token{genexpr_iter}]} + \end{productionlist} + + A generator expression yields a new generator object. + \obindex{generator} + \obindex{generator expression} + It consists of a single expression followed by at least one + \keyword{for} clause and zero or more \keyword{for} or \keyword{if} + clauses. The iterating values of the new generator are those that + would be produced by considering each of the \keyword{for} or + \keyword{if} clauses a block, nesting from left to right, and + evaluating the expression to yield a value that is reached the + innermost block for each iteration. + + Variables used in the generator expression are evaluated lazily + when the \method{next()} method is called for generator object + (in the same fashion as normal generators). However, the leftmost + \keyword{for} clause is immediately evaluated so that error produced + by it can be seen before any other possible error in the code that + handles the generator expression. + Subsequent \keyword{for} clauses cannot be evaluated immediately since + they may depend on the previous \keyword{for} loop. + For example: \samp{(x*y for x in range(10) for y in bar(x))}. + + The parentheses can be omitted on calls with only one argument. + See section \ref{calls} for the detail. + + \subsection{Dictionary displays\label{dict}} \indexii{dictionary}{display} *************** *** 433,436 **** --- 476,481 ---- \production{call} {\token{primary} "(" [\token{argument_list} [","]] ")"} + {\token{primary} "(" [\token{argument_list} [","] | + \token{test} \token{genexpr_for} ] ")"} \production{argument_list} {\token{positional_arguments} ["," \token{keyword_arguments}]} From rhettinger at users.sourceforge.net Mon Aug 16 01:47:52 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Aug 16 01:47:58 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18585 Modified Files: libdecimal.tex Log Message: Add a notes section to the docs: * Discuss representation error versus loss of significance. * Document special values including qNaN, sNaN, +0, -0. * Show the suprising display of non-normalized zero values. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** libdecimal.tex 14 Jul 2004 21:06:55 -0000 1.14 --- libdecimal.tex 15 Aug 2004 23:47:48 -0000 1.15 *************** *** 830,833 **** --- 830,929 ---- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \subsection{Floating Point Notes \label{decimal-notes}} + + The use of decimal floating point eliminates decimal representation error + (making it possible to represent \constant{0.1} exactly); however, some + operations can still incur round-off error when non-zero digits exceed the + fixed precision. + + The effects of round-off error can be amplified by the addition or subtraction + of nearly offsetting quantities resulting in loss of significance. Knuth + provides two instructive examples where rounded floating point arithmetic with + insufficient precision causes the break down of the associative and + distributive properties of addition: + + \begin{verbatim} + # Examples from Seminumerical Algorithms, Section 4.2.2. + >>> from decimal import * + >>> getcontext().prec = 8 + + >>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') + >>> (u + v) + w + Decimal("9.5111111") + >>> u + (v + w) + Decimal("10") + + >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003') + >>> (u*v) + (u*w) + Decimal("0.01") + >>> u * (v+w) + Decimal("0.0060000") + \end{verbatim} + + The \module{decimal} module makes it possible to restore the identities + by expanding the precision sufficiently to avoid loss of significance: + + \begin{verbatim} + >>> getcontext().prec = 20 + >>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') + >>> (u + v) + w + Decimal("9.51111111") + >>> u + (v + w) + Decimal("9.51111111") + >>> + >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003') + >>> (u*v) + (u*w) + Decimal("0.0060000") + >>> u * (v+w) + Decimal("0.0060000") + \end{verbatim} + + + The number system for the \module{decimal} module provides special + values including \constant{NaN}, \constant{sNaN}, \constant{-Infinity}, + \constant{Infinity}, and two zeroes, \constant{+0} and \constant{-0}. + + Infinities can constructed directly with: \code{Decimal('Infinity')}. Also, + they can arise from dividing by zero when the \exception{DivisionByZero} + signal is not trapped. Likewise, when the \exception{Overflow} signal is not + trapped, infinity can result from rounding beyond the limits of the largest + representable number. + + The infinities are signed (affine) and can be used in arithmetic operations + where they get treated as very large, indeterminate numbers. For instance, + adding a constant to infinity gives another infinite result. + + Some operations are indeterminate and return \constant{NaN} or when the + \exception{InvalidOperation} signal is trapped, raise an exception. For + example, \code{0/0} returns \constant{NaN} which means ``not a number''. This + variety of \constant{NaN} is quiet and, once created, will flow through other + computations always resulting in another \constant{NaN}. This behavior can be + useful for a series of computations that occasionally have missing inputs --- + it allows the calculation to proceed while flagging specific results as + invalid. + + A variant is \constant{sNaN} which signals rather than remaining quiet + after every operation. This is a useful return value when an invalid + result needs to interrupt a calculation for special handling. + + The signed zeros can result from calculations that underflow. + They keep the sign that would have resulted if the calculation had + been carried out to greater precision. Since their magnitude is + zero, the positive and negative zero are treated as equal and their + sign is informational. + + In addition to the two signed zeros which are distinct, yet equal, + there are various representations of zero with differing precisions, + yet equivalent in value. This takes a bit of getting used to. For + an eye accustomed to normalized floating point representations, it + is not immediately obvious that the following calculation returns + a value equal to zero: + + \begin{verbatim} + >>> 1 / Decimal('Infinity') + Decimal("0E-1000000026") + \end{verbatim} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Working with threads \label{decimal-threads}} *************** *** 865,869 **** . . . \end{verbatim} ! --- 961,965 ---- . . . \end{verbatim} ! From rhettinger at users.sourceforge.net Mon Aug 16 01:51:41 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Aug 16 01:51:44 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19614 Modified Files: libdecimal.tex Log Message: Fix punctuation typo. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** libdecimal.tex 15 Aug 2004 23:47:48 -0000 1.15 --- libdecimal.tex 15 Aug 2004 23:51:38 -0000 1.16 *************** *** 372,376 **** of an equivalence class. For example, \code{Decimal("32.100")} and \code{Decimal("0.321000e+2")} both normalize to the equivalent value ! \code{Decimal("32.1")}, \end{methoddesc} --- 372,376 ---- of an equivalence class. For example, \code{Decimal("32.100")} and \code{Decimal("0.321000e+2")} both normalize to the equivalent value ! \code{Decimal("32.1")}. \end{methoddesc} From rhettinger at users.sourceforge.net Mon Aug 16 03:35:30 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Aug 16 03:35:33 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_genexps.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1851 Modified Files: test_genexps.py Log Message: * Uncomment the SyntaxError doctest after Tim demonstrated how. * Remove unnecessary sys.PS2 prompt lines. Index: test_genexps.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_genexps.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_genexps.py 8 Jul 2004 04:22:19 -0000 1.3 --- test_genexps.py 16 Aug 2004 01:35:28 -0000 1.4 *************** *** 61,65 **** >>> def f(n): ... return (i*i for i in xrange(n)) - ... >>> list(f(10)) [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] --- 61,64 ---- *************** *** 67,76 **** >>> def f(n): ... return ((i,j) for i in xrange(3) for j in xrange(n)) - ... >>> list(f(4)) [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3)] >>> def f(n): ... return ((i,j) for i in xrange(3) for j in xrange(4) if j in xrange(n)) - ... >>> list(f(4)) [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3)] --- 66,73 ---- *************** *** 78,86 **** [(0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1)] ! #Verify that parenthesis are required in a statement ! #>>> def f(n): ! #... return i*i for i in xrange(n) ! #... ! #SyntaxError: invalid syntax Verify early binding for the outermost for-expression --- 75,84 ---- [(0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1)] ! Verify that parenthesis are required in a statement ! >>> def f(n): ! ... return i*i for i in xrange(n) ! Traceback (most recent call last): ! ... ! SyntaxError: invalid syntax Verify early binding for the outermost for-expression *************** *** 138,147 **** ... print "creator", r.next() ... return r - ... >>> def caller(): ... r = creator() ... for i in r: ... print "caller", i - ... >>> caller() creator 0 --- 136,143 ---- *************** *** 156,160 **** ... for i in yrange(n): ... yield i - ... >>> list(zrange(5)) [0, 1, 2, 3, 4] --- 152,155 ---- From rhettinger at users.sourceforge.net Mon Aug 16 03:45:36 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Aug 16 03:45:39 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_genexps.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3727 Modified Files: test_genexps.py Log Message: Minor formatting cleanup. Index: test_genexps.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_genexps.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_genexps.py 16 Aug 2004 01:35:28 -0000 1.4 --- test_genexps.py 16 Aug 2004 01:45:34 -0000 1.5 *************** *** 76,84 **** Verify that parenthesis are required in a statement ! >>> def f(n): ! ... return i*i for i in xrange(n) ! Traceback (most recent call last): ! ... ! SyntaxError: invalid syntax Verify early binding for the outermost for-expression --- 76,85 ---- Verify that parenthesis are required in a statement ! ! >>> def f(n): ! ... return i*i for i in xrange(n) ! Traceback (most recent call last): ! ... ! SyntaxError: invalid syntax Verify early binding for the outermost for-expression From rhettinger at users.sourceforge.net Mon Aug 16 05:14:55 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Aug 16 05:14:59 2004 Subject: [Python-checkins] python/nondist/peps pep-0290.txt,1.14,1.15 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16563 Modified Files: pep-0290.txt Log Message: Add migration advice about the atexit module. Index: pep-0290.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0290.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pep-0290.txt 4 May 2004 08:24:05 -0000 1.14 --- pep-0290.txt 16 Aug 2004 03:14:53 -0000 1.15 *************** *** 396,399 **** --- 396,414 ---- + The ``atexit`` Module + ''''''''''''''''''''' + + The atexit module supports multiple functions to be executed upon + program termination. Also, it supports parameterized functions. + Unfortunately, its implementation conflicts with the sys.exitfunc + attribute which only supports a single exit function. Code relying + on sys.exitfunc may interfere with other modules (including library + modules) that elect to use the newer and more versatile atexit module. + + Pattern:: + + sys.exitfunc = myfunc --> atexit.register(myfunc) + + Python 1.5 or Later ------------------- From erica55 at bol.com.br Mon Aug 16 06:20:38 2004 From: erica55 at bol.com.br (Erica Silveira) Date: Mon Aug 16 06:20:23 2004 Subject: [Python-checkins] listagem de e-mails Message-ID: <20040816042021.D5EAF1E400A@bag.python.org> Mais Emails, venda online de listas de email, fazemos mala direta e propaganda de sua empresa ou neg?cio para milh?es de emails. Temos listas de email Mala Direta, Mala-Direta, Cadastro de Emails, Lista de Emails, Mailing List, Milh?es de Emails, Programas de Envio de Email, Email Bombers, Extratores de Email, Listas Segmentadas de Email, Emails Segmentados, Emails em Massa, E-mails http://www.promonet.mx.gs Temos listas de email Mala Direta, Mala-Direta, Cadastro de Emails, Lista de Emails, Mailing List, Milh?es de Emails, Programas de Envio de Email, Email Bombers, Extratores de Email, Listas Segmentadas de Email, Emails Segmentados, Emails em Massa, E-mails http://www.promonet.mx.gs From rhettinger at users.sourceforge.net Mon Aug 16 07:11:06 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Aug 16 07:11:09 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.245,1.246 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30341 Modified Files: tut.tex Log Message: Minor improvements to the threading introduction: * Expand the example to show a join. * Mention the use case of I/O running concurrent with a computational thread. * Be a tad more forceful about recommending Queue over other approaches to synchonization. * Eliminate discussion around having a single interpreter. This is a more advanced discussion that belongs in the library reference and in a section on extending and embedding. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.245 retrieving revision 1.246 diff -C2 -d -r1.245 -r1.246 *** tut.tex 9 Aug 2004 14:06:58 -0000 1.245 --- tut.tex 16 Aug 2004 05:11:04 -0000 1.246 *************** *** 4869,4878 **** Threading is a technique for decoupling tasks which are not sequentially ! dependent. Python threads are driven by the operating system and run ! in a single process and share memory space in a single interpreter. ! Threads can be used to improve the responsiveness of applications that ! accept user input while other tasks run in the background. The ! following code shows how the high level \ulink{\module{threading}}{../lib/module-threading.html} module can run tasks in background while the main program continues to run: --- 4869,4878 ---- Threading is a technique for decoupling tasks which are not sequentially ! dependent. Threads can be used to improve the responsiveness of ! applications that accept user input while other tasks run in the ! background. A related use case is running I/O in parallel with ! computations in another thread. ! The following code shows how the high level \ulink{\module{threading}}{../lib/module-threading.html} module can run tasks in background while the main program continues to run: *************** *** 4892,4897 **** print 'Finished background zip of: ', self.infile ! AsyncZip('mydata.txt', 'myarchive.zip').start() ! print 'The main program continues to run' \end{verbatim} --- 4892,4901 ---- print 'Finished background zip of: ', self.infile ! background = AsyncZip('mydata.txt', 'myarchive.zip') ! background.start() ! print 'The main program continues to run in foreground.' ! ! background.join() # Wait for the background task to finish ! print 'Main program waited until background was done.' \end{verbatim} *************** *** 4902,4912 **** While those tools are powerful, minor design errors can result in ! problems that are difficult to reproduce. A simpler and more robust ! approach to task coordination is concentrating all access to a resource in a single thread and then using the \ulink{\module{Queue}}{../lib/module-Queue.html} module to feed that ! thread with requests from other threads. Applications that use \class{Queue} objects for inter-thread communication and coordination ! tend to be easier to design, more readable, and more reliable. --- 4906,4916 ---- While those tools are powerful, minor design errors can result in ! problems that are difficult to reproduce. So, the preferred approach ! to task coordination is to concentrate all access to a resource in a single thread and then using the \ulink{\module{Queue}}{../lib/module-Queue.html} module to feed that ! thread with requests from other threads. Applications using \class{Queue} objects for inter-thread communication and coordination ! are easier to design, more readable, and more reliable. From loewis at users.sourceforge.net Mon Aug 16 11:08:42 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Aug 16 11:08:46 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31094 Modified Files: msi.py Log Message: Remove idle feature as it wasn't really needed for advertising. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** msi.py 13 Aug 2004 15:25:28 -0000 1.27 --- msi.py 16 Aug 2004 09:08:38 -0000 1.28 *************** *** 686,690 **** # column. def add_features(db): ! global default_feature, tcltk, idle, htmlfiles, tools, testsuite, ext_feature default_feature = Feature(db, "DefaultFeature", "Python", "Python Interpreter and Libraries", --- 686,690 ---- # column. def add_features(db): ! global default_feature, tcltk, htmlfiles, tools, testsuite, ext_feature default_feature = Feature(db, "DefaultFeature", "Python", "Python Interpreter and Libraries", *************** *** 695,700 **** tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, pydoc", 5, parent = default_feature) - idle = Feature(db, "IDLE", "IDLE", "IDLE (Python GUI)", 6, - parent = tcltk) htmlfiles = Feature(db, "Documentation", "Documentation", "Python HTMLHelp File", 7, parent = default_feature) --- 695,698 ---- *************** *** 775,782 **** if dir == "CVS" or dir.startswith("plat-"): continue ! elif dir in ["lib-tk"]: tcltk.set_current() - elif dir in ["idlelib", "Icons"]: - idle.set_current() elif dir in ['test', 'output']: testsuite.set_current() --- 773,778 ---- if dir == "CVS" or dir.startswith("plat-"): continue ! elif dir in ["lib-tk", "idlelib", "Icons"]: tcltk.set_current() elif dir in ['test', 'output']: testsuite.set_current() *************** *** 784,790 **** default_feature.set_current() lib = Directory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir)) - # Register keyfiles for components which need them - if dir=="idlelib": - lib.start_component("idlelib", keyfile="idle.pyw") # Add additional files dirs[dir]=lib --- 780,783 ---- *************** *** 985,989 **** [# Advertised shortcuts: targets are features, not files ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe", ! idle.id, r"[TARGETDIR]Lib\idlelib\idle.pyw", None, None, "python_icon.exe", 0, None, "TARGETDIR"), ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe", tcltk.id, r"[TARGETDIR]Tools\scripts\pydocgui.pyw", None, None, "python_icon.exe", 0, None, "TARGETDIR"), --- 978,982 ---- [# Advertised shortcuts: targets are features, not files ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe", ! tcltk.id, r"[TARGETDIR]Lib\idlelib\idle.pyw", None, None, "python_icon.exe", 0, None, "TARGETDIR"), ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe", tcltk.id, r"[TARGETDIR]Tools\scripts\pydocgui.pyw", None, None, "python_icon.exe", 0, None, "TARGETDIR"), From doko at users.sourceforge.net Mon Aug 16 13:35:53 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Mon Aug 16 13:35:56 2004 Subject: [Python-checkins] python/dist/src/Python thread.c,2.50,2.51 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20417/Python Modified Files: thread.c Log Message: The attached patch fixes FTBFS on GNU/k*BSD. The problem happens on GNU/k*BSD because GNU/k*BSD uses gnu pth to provide pthreads, but will also happen on any system that does the same. python fails to build because it doesn't detect gnu pth in pthread emulation. See C comments in patch for details. patch taken from http://bugs.debian.org/264315 Index: thread.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread.c,v retrieving revision 2.50 retrieving revision 2.51 diff -C2 -d -r2.50 -r2.51 *** thread.c 10 Feb 2004 16:50:20 -0000 2.50 --- thread.c 16 Aug 2004 11:35:51 -0000 2.51 *************** *** 8,11 **** --- 8,21 ---- #include "Python.h" + + #ifndef _POSIX_THREADS + /* This means pthreads are not implemented in libc headers, hence the macro + not present in unistd.h. But they still can be implemented as an external + library (e.g. gnu pth in pthread emulation) */ + # ifdef HAVE_PTHREAD_H + # include /* _POSIX_THREADS */ + # endif + #endif + #ifndef DONT_HAVE_STDIO_H #include From doko at users.sourceforge.net Mon Aug 16 13:35:53 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Mon Aug 16 13:35:57 2004 Subject: [Python-checkins] python/dist/src configure, 1.453, 1.454 configure.in, 1.466, 1.467 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20417 Modified Files: configure configure.in Log Message: The attached patch fixes FTBFS on GNU/k*BSD. The problem happens on GNU/k*BSD because GNU/k*BSD uses gnu pth to provide pthreads, but will also happen on any system that does the same. python fails to build because it doesn't detect gnu pth in pthread emulation. See C comments in patch for details. patch taken from http://bugs.debian.org/264315 Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.453 retrieving revision 1.454 diff -C2 -d -r1.453 -r1.454 *** configure 15 Aug 2004 14:08:22 -0000 1.453 --- configure 16 Aug 2004 11:35:49 -0000 1.454 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.465 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.4. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.466 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.4. *************** [...2833 lines suppressed...] - { echo "$as_me:$LINENO: creating $ac_file" >&5 - echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: --- 20740,20743 ---- *************** *** 20990,20993 **** --- 20778,20787 ---- esac done` || { (exit 1); exit 1; } + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 + echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.466 retrieving revision 1.467 diff -C2 -d -r1.466 -r1.467 *** configure.in 15 Aug 2004 14:08:23 -0000 1.466 --- configure.in 16 Aug 2004 11:35:50 -0000 1.467 *************** *** 1629,1633 **** # According to the POSIX spec, a pthreads implementation must ! # define _POSIX_THREADS in unistd.h. Some apparently don't (which ones?) AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h) AC_EGREP_CPP(yes, --- 1629,1634 ---- # 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, From doko at users.sourceforge.net Mon Aug 16 13:35:55 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Mon Aug 16 13:36:00 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1095,1.1096 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20417/Misc Modified Files: NEWS Log Message: The attached patch fixes FTBFS on GNU/k*BSD. The problem happens on GNU/k*BSD because GNU/k*BSD uses gnu pth to provide pthreads, but will also happen on any system that does the same. python fails to build because it doesn't detect gnu pth in pthread emulation. See C comments in patch for details. patch taken from http://bugs.debian.org/264315 Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1095 retrieving revision 1.1096 diff -C2 -d -r1.1095 -r1.1096 *** NEWS 15 Aug 2004 17:04:33 -0000 1.1095 --- NEWS 16 Aug 2004 11:35:51 -0000 1.1096 *************** *** 91,94 **** --- 91,97 ---- GCC's definition and avoid redefinition warnings. + - Detect pthreads support (provided by gnu pth pthread emulation) on + GNU/k*BSD systems. + C API ----- From doko at users.sourceforge.net Mon Aug 16 14:10:14 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Mon Aug 16 14:10:17 2004 Subject: [Python-checkins] python/dist/src/Tools/i18n pygettext.py, 1.23, 1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/i18n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26208/Tools/i18n Modified Files: pygettext.py Log Message: - pygettext.py: Generate POT-Creation-Date header in ISO format. Index: pygettext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/i18n/pygettext.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** pygettext.py 16 Apr 2003 18:08:23 -0000 1.23 --- pygettext.py 16 Aug 2004 12:10:12 -0000 1.24 *************** *** 446,450 **** def write(self, fp): options = self.__options ! timestamp = time.ctime(time.time()) # The time stamp in the header doesn't have the same format as that # generated by xgettext... --- 446,450 ---- def write(self, fp): options = self.__options ! timestamp = time.strftime('%Y-%m-%d %H:%M+%Z') # The time stamp in the header doesn't have the same format as that # generated by xgettext... From doko at users.sourceforge.net Mon Aug 16 14:10:15 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Mon Aug 16 14:10:20 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1096,1.1097 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26208/Misc Modified Files: NEWS Log Message: - pygettext.py: Generate POT-Creation-Date header in ISO format. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1096 retrieving revision 1.1097 diff -C2 -d -r1.1096 -r1.1097 *** NEWS 16 Aug 2004 11:35:51 -0000 1.1096 --- NEWS 16 Aug 2004 12:10:12 -0000 1.1097 *************** *** 82,85 **** --- 82,87 ---- ----------- + - pygettext.py: Generate POT-Creation-Date header in ISO format. + Build ----- From doko at users.sourceforge.net Mon Aug 16 14:12:41 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Mon Aug 16 14:12:44 2004 Subject: [Python-checkins] python/dist/src/Tools/i18n pygettext.py, 1.23, 1.23.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/i18n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26711/Tools/i18n Modified Files: Tag: release23-maint pygettext.py Log Message: - pygettext.py: Generate POT-Creation-Date header in ISO format. Index: pygettext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/i18n/pygettext.py,v retrieving revision 1.23 retrieving revision 1.23.10.1 diff -C2 -d -r1.23 -r1.23.10.1 *** pygettext.py 16 Apr 2003 18:08:23 -0000 1.23 --- pygettext.py 16 Aug 2004 12:12:38 -0000 1.23.10.1 *************** *** 446,450 **** def write(self, fp): options = self.__options ! timestamp = time.ctime(time.time()) # The time stamp in the header doesn't have the same format as that # generated by xgettext... --- 446,450 ---- def write(self, fp): options = self.__options ! timestamp = time.strftime('%Y-%m-%d %H:%M+%Z') # The time stamp in the header doesn't have the same format as that # generated by xgettext... From doko at users.sourceforge.net Mon Aug 16 14:12:42 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Mon Aug 16 14:12:46 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.140, 1.831.4.141 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26711/Misc Modified Files: Tag: release23-maint NEWS Log Message: - pygettext.py: Generate POT-Creation-Date header in ISO format. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.140 retrieving revision 1.831.4.141 diff -C2 -d -r1.831.4.140 -r1.831.4.141 *** NEWS 15 Aug 2004 17:16:25 -0000 1.831.4.140 --- NEWS 16 Aug 2004 12:12:38 -0000 1.831.4.141 *************** *** 95,98 **** --- 95,103 ---- - Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)). + Tools/Demos + ----------- + + - pygettext.py: Generate POT-Creation-Date header in ISO format. + Build ----- From doko at users.sourceforge.net Mon Aug 16 14:15:12 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Mon Aug 16 14:15:14 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command sdist.py, 1.56.14.1, 1.56.14.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27115/Lib/distutils/command Modified Files: Tag: release23-maint sdist.py Log Message: - The distutils sdist command now ignores all .svn directories, in addition to CVS and RCS directories. .svn directories hold administrative files for the Subversion source control system. Index: sdist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/sdist.py,v retrieving revision 1.56.14.1 retrieving revision 1.56.14.2 diff -C2 -d -r1.56.14.1 -r1.56.14.2 *** sdist.py 1 Apr 2004 03:56:46 -0000 1.56.14.1 --- sdist.py 16 Aug 2004 12:15:00 -0000 1.56.14.2 *************** *** 355,359 **** self.filelist.exclude_pattern(None, prefix=build.build_base) self.filelist.exclude_pattern(None, prefix=base_dir) ! self.filelist.exclude_pattern(r'/(RCS|CVS)/.*', is_regex=1) --- 355,359 ---- self.filelist.exclude_pattern(None, prefix=build.build_base) self.filelist.exclude_pattern(None, prefix=base_dir) ! self.filelist.exclude_pattern(r'/(RCS|CVS|\.svn)/.*', is_regex=1) From doko at users.sourceforge.net Mon Aug 16 14:15:33 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Mon Aug 16 14:15:35 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.141, 1.831.4.142 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27115/Misc Modified Files: Tag: release23-maint NEWS Log Message: - The distutils sdist command now ignores all .svn directories, in addition to CVS and RCS directories. .svn directories hold administrative files for the Subversion source control system. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.141 retrieving revision 1.831.4.142 diff -C2 -d -r1.831.4.141 -r1.831.4.142 *** NEWS 16 Aug 2004 12:12:38 -0000 1.831.4.141 --- NEWS 16 Aug 2004 12:15:00 -0000 1.831.4.142 *************** *** 95,98 **** --- 95,102 ---- - Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)). + - The distutils sdist command now ignores all .svn directories, in + addition to CVS and RCS directories. .svn directories hold + administrative files for the Subversion source control system. + Tools/Demos ----------- From bwarsaw at users.sourceforge.net Mon Aug 16 17:31:45 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Mon Aug 16 17:31:49 2004 Subject: [Python-checkins] python/dist/src/Lib/email Message.py, 1.32.10.3, 1.32.10.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30859/Lib/email Modified Files: Tag: release23-maint Message.py Log Message: Test cases and fixes for bugs described in patch #873418: email/Message.py: del_param fails when specifying a header. I'll port this to Python 2.4 shortly. Index: Message.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Message.py,v retrieving revision 1.32.10.3 retrieving revision 1.32.10.4 diff -C2 -d -r1.32.10.3 -r1.32.10.4 *** Message.py 20 Oct 2003 14:34:46 -0000 1.32.10.3 --- Message.py 16 Aug 2004 15:31:42 -0000 1.32.10.4 *************** *** 673,677 **** return new_ctype = '' ! for p, v in self.get_params(header, unquote=requote): if p.lower() <> param.lower(): if not new_ctype: --- 673,677 ---- return new_ctype = '' ! for p, v in self.get_params(header=header, unquote=requote): if p.lower() <> param.lower(): if not new_ctype: *************** *** 709,713 **** self[header] = type return ! params = self.get_params(header, unquote=requote) del self[header] self[header] = type --- 709,713 ---- self[header] = type return ! params = self.get_params(header=header, unquote=requote) del self[header] self[header] = type From bwarsaw at users.sourceforge.net Mon Aug 16 17:31:45 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Mon Aug 16 17:31:51 2004 Subject: [Python-checkins] python/dist/src/Lib/email/test test_email.py, 1.50.10.4, 1.50.10.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30859/Lib/email/test Modified Files: Tag: release23-maint test_email.py Log Message: Test cases and fixes for bugs described in patch #873418: email/Message.py: del_param fails when specifying a header. I'll port this to Python 2.4 shortly. Index: test_email.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/test/test_email.py,v retrieving revision 1.50.10.4 retrieving revision 1.50.10.5 diff -C2 -d -r1.50.10.4 -r1.50.10.5 *** test_email.py 13 May 2004 23:13:24 -0000 1.50.10.4 --- test_email.py 16 Aug 2004 15:31:43 -0000 1.50.10.5 *************** *** 362,365 **** --- 362,371 ---- ('report-type', old_val)]) + def test_del_param_on_other_header(self): + msg = Message() + msg.add_header('Content-Disposition', 'attachment', filename='bud.gif') + msg.del_param('filename', 'content-disposition') + self.assertEqual(msg['content-disposition'], 'attachment') + def test_set_type(self): eq = self.assertEqual *************** *** 373,376 **** --- 379,388 ---- eq(msg['content-type'], 'text/html; charset="us-ascii"') + def test_set_type_on_other_header(self): + msg = Message() + msg['X-Content-Type'] = 'text/plain' + msg.set_type('application/octet-stream', 'X-Content-Type') + self.assertEqual(msg['x-content-type'], 'application/octet-stream') + def test_get_content_type_missing(self): msg = Message() From montanaro at users.sourceforge.net Mon Aug 16 17:35:57 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Mon Aug 16 17:36:00 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py, 1.74, 1.75 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31673 Modified Files: test_socket.py Log Message: Being bsd-based, darwin/macosx has the same limitation w.r.t. the "echo" service. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** test_socket.py 9 Aug 2004 18:54:11 -0000 1.74 --- test_socket.py 16 Aug 2004 15:35:54 -0000 1.75 *************** *** 312,316 **** # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. ! if sys.platform in ('freebsd4', 'freebsd5'): # avoid the 'echo' service on this platform, as there is an # assumption breaking non-standard port/protocol entry --- 312,316 ---- # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. ! if sys.platform in ('freebsd4', 'freebsd5', 'darwin'): # avoid the 'echo' service on this platform, as there is an # assumption breaking non-standard port/protocol entry From bwarsaw at users.sourceforge.net Mon Aug 16 17:47:36 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Mon Aug 16 17:47:41 2004 Subject: [Python-checkins] python/dist/src/Lib/email Message.py,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1396/Lib/email Modified Files: Message.py Log Message: Test cases and fixes for bugs described in patch #873418: email/Message.py: del_param fails when specifying a header. Index: Message.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Message.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Message.py 9 May 2004 03:44:55 -0000 1.36 --- Message.py 16 Aug 2004 15:47:34 -0000 1.37 *************** *** 665,669 **** return new_ctype = '' ! for p, v in self.get_params(header, unquote=requote): if p.lower() <> param.lower(): if not new_ctype: --- 665,669 ---- return new_ctype = '' ! for p, v in self.get_params(header=header, unquote=requote): if p.lower() <> param.lower(): if not new_ctype: *************** *** 701,705 **** self[header] = type return ! params = self.get_params(header, unquote=requote) del self[header] self[header] = type --- 701,705 ---- self[header] = type return ! params = self.get_params(header=header, unquote=requote) del self[header] self[header] = type From bwarsaw at users.sourceforge.net Mon Aug 16 17:47:37 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Mon Aug 16 17:47:46 2004 Subject: [Python-checkins] python/dist/src/Lib/email/test test_email.py, 1.60, 1.61 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1396/Lib/email/test Modified Files: test_email.py Log Message: Test cases and fixes for bugs described in patch #873418: email/Message.py: del_param fails when specifying a header. Index: test_email.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/test/test_email.py,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** test_email.py 7 Aug 2004 16:38:39 -0000 1.60 --- test_email.py 16 Aug 2004 15:47:34 -0000 1.61 *************** *** 355,358 **** --- 355,364 ---- ('report-type', old_val)]) + def test_del_param_on_other_header(self): + msg = Message() + msg.add_header('Content-Disposition', 'attachment', filename='bud.gif') + msg.del_param('filename', 'content-disposition') + self.assertEqual(msg['content-disposition'], 'attachment') + def test_set_type(self): eq = self.assertEqual *************** *** 366,369 **** --- 372,381 ---- eq(msg['content-type'], 'text/html; charset="us-ascii"') + def test_set_type_on_other_header(self): + msg = Message() + msg['X-Content-Type'] = 'text/plain' + msg.set_type('application/octet-stream', 'X-Content-Type') + self.assertEqual(msg['x-content-type'], 'application/octet-stream') + def test_get_content_type_missing(self): msg = Message() From akuchling at users.sourceforge.net Mon Aug 16 18:12:33 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Aug 16 18:12:35 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6751 Modified Files: libdecimal.tex Log Message: Typo fix Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** libdecimal.tex 15 Aug 2004 23:51:38 -0000 1.16 --- libdecimal.tex 16 Aug 2004 16:12:23 -0000 1.17 *************** *** 884,888 **** \constant{Infinity}, and two zeroes, \constant{+0} and \constant{-0}. ! Infinities can constructed directly with: \code{Decimal('Infinity')}. Also, they can arise from dividing by zero when the \exception{DivisionByZero} signal is not trapped. Likewise, when the \exception{Overflow} signal is not --- 884,888 ---- \constant{Infinity}, and two zeroes, \constant{+0} and \constant{-0}. ! Infinities can be constructed directly with: \code{Decimal('Infinity')}. Also, they can arise from dividing by zero when the \exception{DivisionByZero} signal is not trapped. Likewise, when the \exception{Overflow} signal is not From montanaro at users.sourceforge.net Mon Aug 16 18:15:16 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Mon Aug 16 18:15:21 2004 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.73,2.74 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7409 Modified Files: readline.c Log Message: fix a couple problems with the last patch picked up by Michael Hudson Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.73 retrieving revision 2.74 diff -C2 -d -r2.73 -r2.74 *** readline.c 15 Aug 2004 14:31:57 -0000 2.73 --- readline.c 16 Aug 2004 16:15:13 -0000 2.74 *************** *** 305,313 **** entry = remove_history(entry_number); if (!entry) { ! char buf[80]; ! PyOS_snprintf(buf, sizeof(buf), ! "No history item at position %i", ! entry_number); ! PyErr_SetString(PyExc_ValueError, buf); return NULL; } --- 305,311 ---- entry = remove_history(entry_number); if (!entry) { ! PyErr_Format(PyExc_ValueError, ! "No history item at position %d", ! entry_number); return NULL; } *************** *** 324,328 **** PyDoc_STRVAR(doc_remove_history, ! "remove_history(pos) -> None\n\ remove history item given by its position"); --- 322,326 ---- PyDoc_STRVAR(doc_remove_history, ! "remove_history_item(pos) -> None\n\ remove history item given by its position"); *************** *** 339,347 **** old_entry = replace_history_entry(entry_number, line, (void *)NULL); if (!old_entry) { ! char buf[80]; ! PyOS_snprintf(buf, sizeof(buf), ! "No history item at position %i", ! entry_number); ! PyErr_SetString(PyExc_ValueError, buf); return NULL; } --- 337,343 ---- old_entry = replace_history_entry(entry_number, line, (void *)NULL); if (!old_entry) { ! PyErr_Format(PyExc_ValueError, ! "No history item at position %d", ! entry_number); return NULL; } *************** *** 358,362 **** PyDoc_STRVAR(doc_replace_history, ! "replace_history(pos, line) -> None\n\ replaces history item given by its position with contents of line"); --- 354,358 ---- PyDoc_STRVAR(doc_replace_history, ! "replace_history_item(pos, line) -> None\n\ replaces history item given by its position with contents of line"); From rhettinger at users.sourceforge.net Tue Aug 17 04:22:03 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 17 04:22:11 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.172,1.173 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18922 Modified Files: libfuncs.tex Log Message: SF bug #805304: super instances don't support item assignment Document a nuance of super(). It is designed to work well with dotted attribute lookup but not with equivalent implicit lookups using operators or statements. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.172 retrieving revision 1.173 diff -C2 -d -r1.172 -r1.173 *** libfuncs.tex 9 Aug 2004 17:36:56 -0000 1.172 --- libfuncs.tex 17 Aug 2004 02:21:45 -0000 1.173 *************** *** 997,1000 **** --- 997,1006 ---- super(C, self).meth(arg) \end{verbatim} + + Note that \function{super} is implemented as part of the binding process for + explicit dotted attribute lookups such as + \samp{super(C, self).__getitem__(name)}. Accordingly, \function{super} is + undefined for implicit lookups using statements or operators such as + \samp{super(C, self)[name]}. \versionadded{2.2} \end{funcdesc} From rhettinger at users.sourceforge.net Tue Aug 17 04:32:08 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 17 04:32:11 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libnew.tex,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20325 Modified Files: libnew.tex Log Message: SF bug #951482: New module: doc versus action Strengthen the warnings about creating bogus objects using the new module. Index: libnew.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libnew.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** libnew.tex 15 Jan 2002 19:21:05 -0000 1.9 --- libnew.tex 17 Aug 2004 02:31:55 -0000 1.10 *************** *** 12,15 **** --- 12,17 ---- regular creation functions. This module provides a low-level interface to the interpreter, so care must be exercised when using this module. + It is possible to supply non-sensical arguments which crash the + interpreter when the object is used. The \module{new} module defines the following functions: From rhettinger at users.sourceforge.net Tue Aug 17 07:42:17 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 17 07:42:21 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12076 Modified Files: test_decimal.py Log Message: * Dynamically build a list of files to be tested (necessary because version 2.39 of dectest.zip adds some new test files and because some existing test files were getting skipped). * Remove two docstrings which cluttered unittest's output. * Simplify a for-loop with a list comprehension. Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_decimal.py 8 Aug 2004 20:17:45 -0000 1.11 --- test_decimal.py 17 Aug 2004 05:42:09 -0000 1.12 *************** *** 280,288 **** def getexceptions(self): ! L = [] ! for exception in Signals: ! if self.context.flags[exception]: ! L.append(exception) ! return L def change_precision(self, prec): --- 280,284 ---- def getexceptions(self): ! return [e for e in Signals if self.context.flags[e]] def change_precision(self, prec): *************** *** 297,379 **** self.context._clamp = clamp ! def test_abs(self): ! self.eval_file(dir + 'abs' + '.decTest') ! ! def test_add(self): ! self.eval_file(dir + 'add' + '.decTest') ! ! def test_base(self): ! self.eval_file(dir + 'base' + '.decTest') ! ! def test_clamp(self): ! self.eval_file(dir + 'clamp' + '.decTest') ! ! def test_compare(self): ! self.eval_file(dir + 'compare' + '.decTest') ! ! def test_divide(self): ! self.eval_file(dir + 'divide' + '.decTest') ! ! def test_divideint(self): ! self.eval_file(dir + 'divideint' + '.decTest') ! ! def test_inexact(self): ! self.eval_file(dir + 'inexact' + '.decTest') ! ! def test_max(self): ! self.eval_file(dir + 'max' + '.decTest') ! ! def test_min(self): ! self.eval_file(dir + 'min' + '.decTest') ! ! def test_minus(self): ! self.eval_file(dir + 'minus' + '.decTest') ! ! def test_multiply(self): ! self.eval_file(dir+'multiply'+'.decTest') ! ! def test_normalize(self): ! self.eval_file(dir + 'normalize' + '.decTest') ! ! def test_plus(self): ! self.eval_file(dir + 'plus' + '.decTest') ! ! def test_power(self): ! self.eval_file(dir + 'power' + '.decTest') ! ! def test_quantize(self): ! self.eval_file(dir + 'quantize' + '.decTest') ! ! def test_randomBound32(self): ! self.eval_file(dir + 'randomBound32' + '.decTest') ! ! def test_randoms(self): ! self.eval_file(dir + 'randoms' + '.decTest') ! ! def test_remainder(self): ! self.eval_file(dir + 'remainder' + '.decTest') ! ! def test_remainderNear(self): ! self.eval_file(dir + 'remainderNear' + '.decTest') ! ! def test_rounding(self): ! self.eval_file(dir + 'rounding' + '.decTest') ! ! def test_samequantum(self): ! self.eval_file(dir + 'samequantum' + '.decTest') ! ! def test_squareroot(self): ! self.eval_file(dir + 'squareroot' + '.decTest') ! ! def test_subtract(self): ! self.eval_file(dir + 'subtract' + '.decTest') - def test_tointegral(self): - self.eval_file(dir + 'tointegral' + '.decTest') # The following classes test the behaviour of Decimal according to PEP 327 - class DecimalExplicitConstructionTest(unittest.TestCase): '''Unit tests for Explicit Construction cases of Decimal.''' --- 293,314 ---- self.context._clamp = clamp ! # Dynamically build custom test definition for each file in the test ! # directory and add the definitions to the DecimalTest class. This ! # procedure insures that new files do not get skipped. ! for filename in os.listdir(dir): ! if '.decTest' not in filename: ! continue ! ## XXX buildout to include integer and trim ! if 'integer' in filename or 'trim' in filename: ! continue ! head, tail = filename.split('.') ! tester = lambda self, f=filename: self.eval_file(dir + f) ! setattr(DecimalTest, 'test_' + head, tester) ! del filename, head, tail, tester # The following classes test the behaviour of Decimal according to PEP 327 class DecimalExplicitConstructionTest(unittest.TestCase): '''Unit tests for Explicit Construction cases of Decimal.''' *************** *** 404,408 **** def test_explicit_from_string(self): - '''Explicit construction with string.''' #empty --- 339,342 ---- *************** *** 816,820 **** def test_comparison_operators(self): - '''Testing ==, !=, <, >, <=, >=, cmp.''' da = Decimal('23.42') --- 750,753 ---- From rhettinger at users.sourceforge.net Tue Aug 17 08:39:50 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 17 08:39:58 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19307 Modified Files: decimal.py Log Message: Revise max() and min() to comply with the 8/2/2004 update to the specification (version 1.45): The max and min operations follow the rules in the current IEEE 754 revision draft: if one operand is a quiet NaN and the other is number, then the number is always returned if both operands are finite and equal in numerical value then an ordering is applied: if the signs differ then max returns the operand with the positive sign and min returns the operand with the negative sign; if the signs are the same then the exponent is used to select the result. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** decimal.py 8 Aug 2004 04:03:24 -0000 1.21 --- decimal.py 17 Aug 2004 06:39:37 -0000 1.22 *************** *** 2033,2047 **** other = self._convert_other(other) ! ans = self._check_nans(other, context) ! if ans: ! return ans ans = self ! if self < other: ans = other ! shouldround = context._rounding_decision == ALWAYS_ROUND ! if shouldround: ! ans = ans._fix(context=context) ! return ans def min(self, other, context=None): --- 2033,2069 ---- other = self._convert_other(other) ! # if one operand is a quiet NaN and the other is number, then the ! # number is always returned ! sn = self._isnan() ! on = other._isnan() ! if sn or on: ! if on == 1 and sn != 2: ! return self ! if sn == 1 and on != 2: ! return other ! return self._check_nans(other, context) ans = self ! c = self.__cmp__(other) ! if c == 0: ! # if both operands are finite and equal in numerical value ! # then an ordering is applied: ! # ! # if the signs differ then max returns the operand with the ! # positive sign and min returns the operand with the negative sign ! # ! # if the signs are the same then the exponent is used to select ! # the result. ! if self._sign != other._sign: ! if self._sign: ! ans = other ! elif self._exp < other._exp and not self._sign: ! ans = other ! elif self._exp > other._exp and self._sign: ! ans = other ! elif c == -1: ans = other ! context._rounding_decision == ALWAYS_ROUND ! return ans._fix(context=context) def min(self, other, context=None): *************** *** 2055,2071 **** other = self._convert_other(other) ! ans = self._check_nans(other, context) ! if ans: ! return ans ans = self ! ! if self > other: ans = other ! ! if context._rounding_decision == ALWAYS_ROUND: ! ans = ans._fix(context=context) ! ! return ans def _isinteger(self): --- 2077,2113 ---- other = self._convert_other(other) ! # if one operand is a quiet NaN and the other is number, then the ! # number is always returned ! sn = self._isnan() ! on = other._isnan() ! if sn or on: ! if on == 1 and sn != 2: ! return self ! if sn == 1 and on != 2: ! return other ! return self._check_nans(other, context) ans = self ! c = self.__cmp__(other) ! if c == 0: ! # if both operands are finite and equal in numerical value ! # then an ordering is applied: ! # ! # if the signs differ then max returns the operand with the ! # positive sign and min returns the operand with the negative sign ! # ! # if the signs are the same then the exponent is used to select ! # the result. ! if self._sign != other._sign: ! if other._sign: ! ans = other ! elif self._exp > other._exp and not self._sign: ! ans = other ! elif self._exp < other._exp and self._sign: ! ans = other ! elif c == 1: ans = other ! context._rounding_decision == ALWAYS_ROUND ! return ans._fix(context=context) def _isinteger(self): *************** *** 2398,2402 **** Decimal("3") >>> ExtendedContext.max(Decimal('1.0'), Decimal('1')) ! Decimal("1.0") """ return a.max(b, context=self) --- 2440,2446 ---- Decimal("3") >>> ExtendedContext.max(Decimal('1.0'), Decimal('1')) ! Decimal("1") ! >>> ExtendedContext.max(Decimal('7'), Decimal('NaN')) ! Decimal("7") """ return a.max(b, context=self) *************** *** 2417,2420 **** --- 2461,2466 ---- >>> ExtendedContext.min(Decimal('1.0'), Decimal('1')) Decimal("1.0") + >>> ExtendedContext.min(Decimal('7'), Decimal('NaN')) + Decimal("7") """ return a.min(b, context=self) From rhettinger at users.sourceforge.net Tue Aug 17 08:43:07 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 17 08:43:13 2004 Subject: [Python-checkins] python/dist/src/Lib/test/decimaltestdata decimal128.decTest, NONE, 1.1 decimal32.decTest, NONE, 1.1 abs.decTest, 1.1, 1.2 add.decTest, 1.1, 1.2 base.decTest, 1.1, 1.2 clamp.decTest, 1.1, 1.2 compare.decTest, 1.1, 1.2 decimal64.decTest, 1.1, 1.2 divide.decTest, 1.1, 1.2 divideint.decTest, 1.1, 1.2 inexact.decTest, 1.1, 1.2 max.decTest, 1.1, 1.2 min.decTest, 1.1, 1.2 minus.decTest, 1.1, 1.2 multiply.decTest, 1.1, 1.2 normalize.decTest, 1.1, 1.2 plus.decTest, 1.1, 1.2 power.decTest, 1.1, 1.2 quantize.decTest, 1.1, 1.2 randomBound32.decTest, 1.1, 1.2 randoms.decTest, 1.1, 1.2 remainder.decTest, 1.1, 1.2 remainderNear.decTest, 1.1, 1.2 rescale.decTest, 1.1, 1.2 rounding.decTest, 1.1, 1.2 samequantum.decTest, 1.1, 1.2 squareroot.decTest, 1.1, 1.2 subtract.decTest, 1.1, 1.2 testall.decTest, 1.1, 1.2 tointegral.decTest, 1.1, 1.2 trim.decTest, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/decimaltestdata In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19771 Modified Files: abs.decTest add.decTest base.decTest clamp.decTest compare.decTest decimal64.decTest divide.decTest divideint.decTest inexact.decTest max.decTest min.decTest minus.decTest multiply.decTest normalize.decTest plus.decTest power.decTest quantize.decTest randomBound32.decTest randoms.decTest remainder.decTest remainderNear.decTest rescale.decTest rounding.decTest samequantum.decTest squareroot.decTest subtract.decTest testall.decTest tointegral.decTest trim.decTest Added Files: decimal128.decTest decimal32.decTest Log Message: Add two new files and update remaining tests from the latest update of the test suite in version 2.39 of dectest.zip. --- NEW FILE: decimal128.decTest --- ------------------------------------------------------------------------ -- decimal128.decTest -- decimal sixteen-byte format testcases -- -- Copyright (c) IBM Corporation, 2000, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.39 -- This set of tests is for the sixteen-byte concrete representation. -- Its characteristics are: -- -- 1 bit sign -- 5 bits combination field -- 12 bits exponent continuation -- 110 bits coefficient continuation -- -- Total exponent length 14 bits -- Total coefficient length 114 bits (34 digits) -- -- Elimit = 12287 (maximum encoded exponent) -- Emax = 6144 (largest exponent value) -- Emin = -6143 (smallest exponent value) -- bias = 6176 (subtracted from encoded exponent) = -Etiny extended: 1 precision: 34 rounding: half_up maxExponent: 6144 minExponent: -6143 -- General testcases -- (mostly derived from the Strawman 4 document and examples) decg001 apply #A20780000000000000000000000003D0 -> -7.50 decg002 apply -7.50 -> #A20780000000000000000000000003D0 -- Normality decf010 apply 1234567890123456789012345678901234 -> #2608134b9c1e28e56f3c127177823534 decf011 apply 1234567890123456789012345678901234.0 -> #2608134b9c1e28e56f3c127177823534 Rounded decf012 apply 1234567890123456789012345678901234.1 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact decf013 apply -1234567890123456789012345678901234 -> #a608134b9c1e28e56f3c127177823534 decf014 apply -1234567890123456789012345678901234.0 -> #a608134b9c1e28e56f3c127177823534 Rounded decf015 apply -1234567890123456789012345678901234.1 -> #a608134b9c1e28e56f3c127177823534 Rounded Inexact -- Nmax and similar decf022 apply 9.999999999999999999999999999999999E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff decf023 apply #77ffcff3fcff3fcff3fcff3fcff3fcff -> 9.999999999999999999999999999999999E+6144 decf024 apply 1.234567890123456789012345678901234E+6144 -> #47ffd34b9c1e28e56f3c127177823534 decf025 apply #47ffd34b9c1e28e56f3c127177823534 -> 1.234567890123456789012345678901234E+6144 -- fold-downs (more below) decf030 apply 1.23E+6144 -> #47ffd300000000000000000000000000 Clamped decf031 apply #47ffd300000000000000000000000000 -> 1.230000000000000000000000000000000E+6144 decf032 apply 1E+6144 -> #47ffc000000000000000000000000000 Clamped decf033 apply #47ffc000000000000000000000000000 -> 1.000000000000000000000000000000000E+6144 -- overflows maxExponent: 9999 -- set high so conversion causes the overflow minExponent: -9999 decf040 apply 10E+6144 -> #78000000000000000000000000000000 Overflow Rounded Inexact decf041 apply 1.000000000000000E+6145 -> #78000000000000000000000000000000 Overflow Rounded Inexact maxExponent: 6144 minExponent: -6143 decf051 apply 12345 -> #220800000000000000000000000049c5 decf052 apply #220800000000000000000000000049c5 -> 12345 decf053 apply 1234 -> #22080000000000000000000000000534 decf054 apply #22080000000000000000000000000534 -> 1234 decf055 apply 123 -> #220800000000000000000000000000a3 decf056 apply #220800000000000000000000000000a3 -> 123 decf057 apply 12 -> #22080000000000000000000000000012 decf058 apply #22080000000000000000000000000012 -> 12 decf059 apply 1 -> #22080000000000000000000000000001 decf060 apply #22080000000000000000000000000001 -> 1 decf061 apply 1.23 -> #220780000000000000000000000000a3 decf062 apply #220780000000000000000000000000a3 -> 1.23 decf063 apply 123.45 -> #220780000000000000000000000049c5 decf064 apply #220780000000000000000000000049c5 -> 123.45 -- Nmin and below decf071 apply 1E-6143 -> #00084000000000000000000000000001 decf072 apply #00084000000000000000000000000001 -> 1E-6143 decf073 apply 1.000000000000000000000000000000000E-6143 -> #04000000000000000000000000000000 decf074 apply #04000000000000000000000000000000 -> 1.000000000000000000000000000000000E-6143 decf075 apply 1.000000000000000000000000000000001E-6143 -> #04000000000000000000000000000001 decf076 apply #04000000000000000000000000000001 -> 1.000000000000000000000000000000001E-6143 decf077 apply 0.100000000000000000000000000000000E-6143 -> #00000800000000000000000000000000 Subnormal decf078 apply #00000800000000000000000000000000 -> 1.00000000000000000000000000000000E-6144 Subnormal decf079 apply 0.000000000000000000000000000000010E-6143 -> #00000000000000000000000000000010 Subnormal decf080 apply #00000000000000000000000000000010 -> 1.0E-6175 Subnormal decf081 apply 0.00000000000000000000000000000001E-6143 -> #00004000000000000000000000000001 Subnormal decf082 apply #00004000000000000000000000000001 -> 1E-6175 Subnormal decf083 apply 0.000000000000000000000000000000001E-6143 -> #00000000000000000000000000000001 Subnormal decf084 apply #00000000000000000000000000000001 -> 1E-6176 Subnormal -- underflows decf090 apply 1e-6176 -> #00000000000000000000000000000001 Subnormal decf091 apply 1.9e-6176 -> #00000000000000000000000000000002 Subnormal Underflow Inexact Rounded decf092 apply 1.1e-6176 -> #00000000000000000000000000000001 Subnormal Underflow Inexact Rounded decf093 apply 1.00000000001e-6176 -> #00000000000000000000000000000001 Subnormal Underflow Inexact Rounded decf094 apply 1.00000000000001e-6176 -> #00000000000000000000000000000001 Subnormal Underflow Inexact Rounded decf095 apply 1.000000000000001e-6176 -> #00000000000000000000000000000001 Subnormal Underflow Inexact Rounded decf096 apply 0.1e-6176 -> #00000000000000000000000000000000 Subnormal Underflow Inexact Rounded decf097 apply 0.00000000001e-6176 -> #00000000000000000000000000000000 Subnormal Underflow Inexact Rounded decf098 apply 0.00000000000001e-6176 -> #00000000000000000000000000000000 Subnormal Underflow Inexact Rounded decf099 apply 0.000000000000001e-6176 -> #00000000000000000000000000000000 Subnormal Underflow Inexact Rounded decf100 apply 999999999999999999999999999999999e-6176 -> #00000ff3fcff3fcff3fcff3fcff3fcff Subnormal -- same again, negatives -- Nmax and similar decf122 apply -9.999999999999999999999999999999999E+6144 -> #f7ffcff3fcff3fcff3fcff3fcff3fcff decf123 apply #f7ffcff3fcff3fcff3fcff3fcff3fcff -> -9.999999999999999999999999999999999E+6144 decf124 apply -1.234567890123456789012345678901234E+6144 -> #c7ffd34b9c1e28e56f3c127177823534 decf125 apply #c7ffd34b9c1e28e56f3c127177823534 -> -1.234567890123456789012345678901234E+6144 -- fold-downs (more below) decf130 apply -1.23E+6144 -> #c7ffd300000000000000000000000000 Clamped decf131 apply #c7ffd300000000000000000000000000 -> -1.230000000000000000000000000000000E+6144 decf132 apply -1E+6144 -> #c7ffc000000000000000000000000000 Clamped decf133 apply #c7ffc000000000000000000000000000 -> -1.000000000000000000000000000000000E+6144 -- overflows maxExponent: 9999 -- set high so conversion causes the overflow minExponent: -9999 decf140 apply -10E+6144 -> #f8000000000000000000000000000000 Overflow Rounded Inexact decf141 apply -1.000000000000000E+6145 -> #f8000000000000000000000000000000 Overflow Rounded Inexact maxExponent: 6144 minExponent: -6143 decf151 apply -12345 -> #a20800000000000000000000000049c5 decf152 apply #a20800000000000000000000000049c5 -> -12345 decf153 apply -1234 -> #a2080000000000000000000000000534 decf154 apply #a2080000000000000000000000000534 -> -1234 decf155 apply -123 -> #a20800000000000000000000000000a3 decf156 apply #a20800000000000000000000000000a3 -> -123 decf157 apply -12 -> #a2080000000000000000000000000012 decf158 apply #a2080000000000000000000000000012 -> -12 decf159 apply -1 -> #a2080000000000000000000000000001 decf160 apply #a2080000000000000000000000000001 -> -1 decf161 apply -1.23 -> #a20780000000000000000000000000a3 decf162 apply #a20780000000000000000000000000a3 -> -1.23 decf163 apply -123.45 -> #a20780000000000000000000000049c5 decf164 apply #a20780000000000000000000000049c5 -> -123.45 -- Nmin and below decf171 apply -1E-6143 -> #80084000000000000000000000000001 decf172 apply #80084000000000000000000000000001 -> -1E-6143 decf173 apply -1.000000000000000000000000000000000E-6143 -> #84000000000000000000000000000000 decf174 apply #84000000000000000000000000000000 -> -1.000000000000000000000000000000000E-6143 decf175 apply -1.000000000000000000000000000000001E-6143 -> #84000000000000000000000000000001 decf176 apply #84000000000000000000000000000001 -> -1.000000000000000000000000000000001E-6143 decf177 apply -0.100000000000000000000000000000000E-6143 -> #80000800000000000000000000000000 Subnormal decf178 apply #80000800000000000000000000000000 -> -1.00000000000000000000000000000000E-6144 Subnormal decf179 apply -0.000000000000000000000000000000010E-6143 -> #80000000000000000000000000000010 Subnormal decf180 apply #80000000000000000000000000000010 -> -1.0E-6175 Subnormal decf181 apply -0.00000000000000000000000000000001E-6143 -> #80004000000000000000000000000001 Subnormal decf182 apply #80004000000000000000000000000001 -> -1E-6175 Subnormal decf183 apply -0.000000000000000000000000000000001E-6143 -> #80000000000000000000000000000001 Subnormal decf184 apply #80000000000000000000000000000001 -> -1E-6176 Subnormal -- underflows decf190 apply -1e-6176 -> #80000000000000000000000000000001 Subnormal decf191 apply -1.9e-6176 -> #80000000000000000000000000000002 Subnormal Underflow Inexact Rounded decf192 apply -1.1e-6176 -> #80000000000000000000000000000001 Subnormal Underflow Inexact Rounded decf193 apply -1.00000000001e-6176 -> #80000000000000000000000000000001 Subnormal Underflow Inexact Rounded decf194 apply -1.00000000000001e-6176 -> #80000000000000000000000000000001 Subnormal Underflow Inexact Rounded decf195 apply -1.000000000000001e-6176 -> #80000000000000000000000000000001 Subnormal Underflow Inexact Rounded decf196 apply -0.1e-6176 -> #80000000000000000000000000000000 Subnormal Underflow Inexact Rounded decf197 apply -0.00000000001e-6176 -> #80000000000000000000000000000000 Subnormal Underflow Inexact Rounded decf198 apply -0.00000000000001e-6176 -> #80000000000000000000000000000000 Subnormal Underflow Inexact Rounded decf199 apply -0.000000000000001e-6176 -> #80000000000000000000000000000000 Subnormal Underflow Inexact Rounded decf200 apply -999999999999999999999999999999999e-6176 -> #80000ff3fcff3fcff3fcff3fcff3fcff Subnormal -- zeros decf400 apply 0E-8000 -> #00000000000000000000000000000000 Clamped decf401 apply 0E-6177 -> #00000000000000000000000000000000 Clamped decf402 apply 0E-6176 -> #00000000000000000000000000000000 decf403 apply #00000000000000000000000000000000 -> 0E-6176 decf404 apply 0.000000000000000000000000000000000E-6143 -> #00000000000000000000000000000000 decf405 apply #00000000000000000000000000000000 -> 0E-6176 decf406 apply 0E-2 -> #22078000000000000000000000000000 decf407 apply #22078000000000000000000000000000 -> 0.00 decf408 apply 0 -> #22080000000000000000000000000000 decf409 apply #22080000000000000000000000000000 -> 0 decf410 apply 0E+3 -> #2208c000000000000000000000000000 decf411 apply #2208c000000000000000000000000000 -> 0E+3 decf412 apply 0E+6111 -> #43ffc000000000000000000000000000 decf413 apply #43ffc000000000000000000000000000 -> 0E+6111 -- clamped zeros... decf414 apply 0E+6112 -> #43ffc000000000000000000000000000 Clamped decf415 apply #43ffc000000000000000000000000000 -> 0E+6111 decf416 apply 0E+6144 -> #43ffc000000000000000000000000000 Clamped decf417 apply #43ffc000000000000000000000000000 -> 0E+6111 decf418 apply 0E+8000 -> #43ffc000000000000000000000000000 Clamped decf419 apply #43ffc000000000000000000000000000 -> 0E+6111 -- negative zeros decf420 apply -0E-8000 -> #80000000000000000000000000000000 Clamped decf421 apply -0E-6177 -> #80000000000000000000000000000000 Clamped decf422 apply -0E-6176 -> #80000000000000000000000000000000 decf423 apply #80000000000000000000000000000000 -> -0E-6176 decf424 apply -0.000000000000000000000000000000000E-6143 -> #80000000000000000000000000000000 decf425 apply #80000000000000000000000000000000 -> -0E-6176 decf426 apply -0E-2 -> #a2078000000000000000000000000000 decf427 apply #a2078000000000000000000000000000 -> -0.00 decf428 apply -0 -> #a2080000000000000000000000000000 decf429 apply #a2080000000000000000000000000000 -> -0 decf430 apply -0E+3 -> #a208c000000000000000000000000000 decf431 apply #a208c000000000000000000000000000 -> -0E+3 decf432 apply -0E+6111 -> #c3ffc000000000000000000000000000 decf433 apply #c3ffc000000000000000000000000000 -> -0E+6111 -- clamped zeros... decf434 apply -0E+6112 -> #c3ffc000000000000000000000000000 Clamped decf435 apply #c3ffc000000000000000000000000000 -> -0E+6111 decf436 apply -0E+6144 -> #c3ffc000000000000000000000000000 Clamped decf437 apply #c3ffc000000000000000000000000000 -> -0E+6111 decf438 apply -0E+8000 -> #c3ffc000000000000000000000000000 Clamped decf439 apply #c3ffc000000000000000000000000000 -> -0E+6111 -- Specials decf500 apply Infinity -> #78000000000000000000000000000000 decf501 apply #78787878787878787878787878787878 -> #78000000000000000000000000000000 decf502 apply #78000000000000000000000000000000 -> Infinity decf503 apply #79797979797979797979797979797979 -> #78000000000000000000000000000000 decf504 apply #79000000000000000000000000000000 -> Infinity decf505 apply #7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #78000000000000000000000000000000 decf506 apply #7a000000000000000000000000000000 -> Infinity decf507 apply #7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #78000000000000000000000000000000 decf508 apply #7b000000000000000000000000000000 -> Infinity decf509 apply NaN -> #7c000000000000000000000000000000 decf510 apply #7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #7c003c7c7c7c7c7c7c7c7c7c7c7c7c7c decf511 apply #7c000000000000000000000000000000 -> NaN decf512 apply #7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #7c003d7d7d7d7d7d7d7d7d7d7d7d7d7d decf513 apply #7d000000000000000000000000000000 -> NaN decf514 apply #7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #7e003e7e7c7e7e7e7e7c7e7e7e7e7c7e decf515 apply #7e000000000000000000000000000000 -> sNaN decf516 apply #7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #7e003f7f7c7f7f7f7f7c7f7f7f7f7c7f decf517 apply #7f000000000000000000000000000000 -> sNaN decf518 apply #7fffffffffffffffffffffffffffffff -> sNaN999999999999999999999999999999999 decf519 apply #7fffffffffffffffffffffffffffffff -> #7e000ff3fcff3fcff3fcff3fcff3fcff decf520 apply -Infinity -> #f8000000000000000000000000000000 decf521 apply #f8787878787878787878787878787878 -> #f8000000000000000000000000000000 decf522 apply #f8000000000000000000000000000000 -> -Infinity decf523 apply #f9797979797979797979797979797979 -> #f8000000000000000000000000000000 decf524 apply #f9000000000000000000000000000000 -> -Infinity decf525 apply #fa7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #f8000000000000000000000000000000 decf526 apply #fa000000000000000000000000000000 -> -Infinity decf527 apply #fb7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #f8000000000000000000000000000000 decf528 apply #fb000000000000000000000000000000 -> -Infinity decf529 apply -NaN -> #fc000000000000000000000000000000 decf530 apply #fc7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #fc003c7c7c7c7c7c7c7c7c7c7c7c7c7c decf531 apply #fc000000000000000000000000000000 -> -NaN decf532 apply #fd7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #fc003d7d7d7d7d7d7d7d7d7d7d7d7d7d decf533 apply #fd000000000000000000000000000000 -> -NaN decf534 apply #fe7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #fe003e7e7c7e7e7e7e7c7e7e7e7e7c7e decf535 apply #fe000000000000000000000000000000 -> -sNaN decf536 apply #ff7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #fe003f7f7c7f7f7f7f7c7f7f7f7f7c7f decf537 apply #ff000000000000000000000000000000 -> -sNaN decf538 apply #ffffffffffffffffffffffffffffffff -> -sNaN999999999999999999999999999999999 decf539 apply #ffffffffffffffffffffffffffffffff -> #fe000ff3fcff3fcff3fcff3fcff3fcff decf540 apply NaN -> #7c000000000000000000000000000000 decf541 apply NaN0 -> #7c000000000000000000000000000000 decf542 apply NaN1 -> #7c000000000000000000000000000001 decf543 apply NaN12 -> #7c000000000000000000000000000012 decf544 apply NaN79 -> #7c000000000000000000000000000079 decf545 apply NaN12345 -> #7c0000000000000000000000000049c5 decf546 apply NaN123456 -> #7c000000000000000000000000028e56 decf547 apply NaN799799 -> #7c0000000000000000000000000f7fdf decf548 apply NaN799799799799799799799799799799799 -> #7c003dff7fdff7fdff7fdff7fdff7fdf decf549 apply NaN999999999999999999999999999999999 -> #7c000ff3fcff3fcff3fcff3fcff3fcff decf550 apply NaN1234567890123456789012345678901234 -> #7c000000000000000000000000000000 -- too many digits -- fold-down full sequence decf600 apply 1E+6145 -> #78000000000000000000000000000000 Overflow Inexact Rounded decf601 apply 1E+6144 -> #47ffc000000000000000000000000000 Clamped decf602 apply #47ffc000000000000000000000000000 -> 1.000000000000000000000000000000000E+6144 decf603 apply 1E+6143 -> #43ffc800000000000000000000000000 Clamped decf604 apply #43ffc800000000000000000000000000 -> 1.00000000000000000000000000000000E+6143 decf605 apply 1E+6142 -> #43ffc100000000000000000000000000 Clamped decf606 apply #43ffc100000000000000000000000000 -> 1.0000000000000000000000000000000E+6142 decf607 apply 1E+6141 -> #43ffc010000000000000000000000000 Clamped decf608 apply #43ffc010000000000000000000000000 -> 1.000000000000000000000000000000E+6141 decf609 apply 1E+6140 -> #43ffc002000000000000000000000000 Clamped decf610 apply #43ffc002000000000000000000000000 -> 1.00000000000000000000000000000E+6140 decf611 apply 1E+6139 -> #43ffc000400000000000000000000000 Clamped decf612 apply #43ffc000400000000000000000000000 -> 1.0000000000000000000000000000E+6139 decf613 apply 1E+6138 -> #43ffc000040000000000000000000000 Clamped decf614 apply #43ffc000040000000000000000000000 -> 1.000000000000000000000000000E+6138 decf615 apply 1E+6137 -> #43ffc000008000000000000000000000 Clamped decf616 apply #43ffc000008000000000000000000000 -> 1.00000000000000000000000000E+6137 decf617 apply 1E+6136 -> #43ffc000001000000000000000000000 Clamped decf618 apply #43ffc000001000000000000000000000 -> 1.0000000000000000000000000E+6136 decf619 apply 1E+6135 -> #43ffc000000100000000000000000000 Clamped decf620 apply #43ffc000000100000000000000000000 -> 1.000000000000000000000000E+6135 decf621 apply 1E+6134 -> #43ffc000000020000000000000000000 Clamped decf622 apply #43ffc000000020000000000000000000 -> 1.00000000000000000000000E+6134 decf623 apply 1E+6133 -> #43ffc000000004000000000000000000 Clamped decf624 apply #43ffc000000004000000000000000000 -> 1.0000000000000000000000E+6133 decf625 apply 1E+6132 -> #43ffc000000000400000000000000000 Clamped decf626 apply #43ffc000000000400000000000000000 -> 1.000000000000000000000E+6132 decf627 apply 1E+6131 -> #43ffc000000000080000000000000000 Clamped decf628 apply #43ffc000000000080000000000000000 -> 1.00000000000000000000E+6131 decf629 apply 1E+6130 -> #43ffc000000000010000000000000000 Clamped decf630 apply #43ffc000000000010000000000000000 -> 1.0000000000000000000E+6130 decf631 apply 1E+6129 -> #43ffc000000000001000000000000000 Clamped decf632 apply #43ffc000000000001000000000000000 -> 1.000000000000000000E+6129 decf633 apply 1E+6128 -> #43ffc000000000000200000000000000 Clamped decf634 apply #43ffc000000000000200000000000000 -> 1.00000000000000000E+6128 decf635 apply 1E+6127 -> #43ffc000000000000040000000000000 Clamped decf636 apply #43ffc000000000000040000000000000 -> 1.0000000000000000E+6127 decf637 apply 1E+6126 -> #43ffc000000000000004000000000000 Clamped decf638 apply #43ffc000000000000004000000000000 -> 1.000000000000000E+6126 decf639 apply 1E+6125 -> #43ffc000000000000000800000000000 Clamped decf640 apply #43ffc000000000000000800000000000 -> 1.00000000000000E+6125 decf641 apply 1E+6124 -> #43ffc000000000000000100000000000 Clamped decf642 apply #43ffc000000000000000100000000000 -> 1.0000000000000E+6124 decf643 apply 1E+6123 -> #43ffc000000000000000010000000000 Clamped decf644 apply #43ffc000000000000000010000000000 -> 1.000000000000E+6123 decf645 apply 1E+6122 -> #43ffc000000000000000002000000000 Clamped decf646 apply #43ffc000000000000000002000000000 -> 1.00000000000E+6122 decf647 apply 1E+6121 -> #43ffc000000000000000000400000000 Clamped decf648 apply #43ffc000000000000000000400000000 -> 1.0000000000E+6121 decf649 apply 1E+6120 -> #43ffc000000000000000000040000000 Clamped decf650 apply #43ffc000000000000000000040000000 -> 1.000000000E+6120 decf651 apply 1E+6119 -> #43ffc000000000000000000008000000 Clamped decf652 apply #43ffc000000000000000000008000000 -> 1.00000000E+6119 decf653 apply 1E+6118 -> #43ffc000000000000000000001000000 Clamped decf654 apply #43ffc000000000000000000001000000 -> 1.0000000E+6118 decf655 apply 1E+6117 -> #43ffc000000000000000000000100000 Clamped decf656 apply #43ffc000000000000000000000100000 -> 1.000000E+6117 decf657 apply 1E+6116 -> #43ffc000000000000000000000020000 Clamped decf658 apply #43ffc000000000000000000000020000 -> 1.00000E+6116 decf659 apply 1E+6115 -> #43ffc000000000000000000000004000 Clamped decf660 apply #43ffc000000000000000000000004000 -> 1.0000E+6115 decf661 apply 1E+6114 -> #43ffc000000000000000000000000400 Clamped decf662 apply #43ffc000000000000000000000000400 -> 1.000E+6114 decf663 apply 1E+6113 -> #43ffc000000000000000000000000080 Clamped decf664 apply #43ffc000000000000000000000000080 -> 1.00E+6113 decf665 apply 1E+6112 -> #43ffc000000000000000000000000010 Clamped decf666 apply #43ffc000000000000000000000000010 -> 1.0E+6112 decf667 apply 1E+6111 -> #43ffc000000000000000000000000001 decf668 apply #43ffc000000000000000000000000001 -> 1E+6111 decf669 apply 1E+6110 -> #43ff8000000000000000000000000001 decf670 apply #43ff8000000000000000000000000001 -> 1E+6110 -- Selected DPD codes decf700 apply #22080000000000000000000000000000 -> 0 decf701 apply #22080000000000000000000000000009 -> 9 decf702 apply #22080000000000000000000000000010 -> 10 decf703 apply #22080000000000000000000000000019 -> 19 decf704 apply #22080000000000000000000000000020 -> 20 decf705 apply #22080000000000000000000000000029 -> 29 decf706 apply #22080000000000000000000000000030 -> 30 decf707 apply #22080000000000000000000000000039 -> 39 decf708 apply #22080000000000000000000000000040 -> 40 decf709 apply #22080000000000000000000000000049 -> 49 decf710 apply #22080000000000000000000000000050 -> 50 decf711 apply #22080000000000000000000000000059 -> 59 decf712 apply #22080000000000000000000000000060 -> 60 decf713 apply #22080000000000000000000000000069 -> 69 decf714 apply #22080000000000000000000000000070 -> 70 decf715 apply #22080000000000000000000000000071 -> 71 decf716 apply #22080000000000000000000000000072 -> 72 decf717 apply #22080000000000000000000000000073 -> 73 decf718 apply #22080000000000000000000000000074 -> 74 decf719 apply #22080000000000000000000000000075 -> 75 decf720 apply #22080000000000000000000000000076 -> 76 decf721 apply #22080000000000000000000000000077 -> 77 decf722 apply #22080000000000000000000000000078 -> 78 decf723 apply #22080000000000000000000000000079 -> 79 decf730 apply #2208000000000000000000000000029e -> 994 decf731 apply #2208000000000000000000000000029f -> 995 decf732 apply #220800000000000000000000000002a0 -> 520 decf733 apply #220800000000000000000000000002a1 -> 521 -- DPD: one of each of the huffman groups decf740 apply #220800000000000000000000000003f7 -> 777 decf741 apply #220800000000000000000000000003f8 -> 778 decf742 apply #220800000000000000000000000003eb -> 787 decf743 apply #2208000000000000000000000000037d -> 877 decf744 apply #2208000000000000000000000000039f -> 997 decf745 apply #220800000000000000000000000003bf -> 979 decf746 apply #220800000000000000000000000003df -> 799 decf747 apply #2208000000000000000000000000006e -> 888 -- DPD all-highs cases (includes the 24 redundant codes) decf750 apply #2208000000000000000000000000006e -> 888 decf751 apply #2208000000000000000000000000016e -> 888 decf752 apply #2208000000000000000000000000026e -> 888 decf753 apply #2208000000000000000000000000036e -> 888 decf754 apply #2208000000000000000000000000006f -> 889 decf755 apply #2208000000000000000000000000016f -> 889 decf756 apply #2208000000000000000000000000026f -> 889 decf757 apply #2208000000000000000000000000036f -> 889 decf760 apply #2208000000000000000000000000007e -> 898 decf761 apply #2208000000000000000000000000017e -> 898 decf762 apply #2208000000000000000000000000027e -> 898 decf763 apply #2208000000000000000000000000037e -> 898 decf764 apply #2208000000000000000000000000007f -> 899 decf765 apply #2208000000000000000000000000017f -> 899 decf766 apply #2208000000000000000000000000027f -> 899 decf767 apply #2208000000000000000000000000037f -> 899 decf770 apply #220800000000000000000000000000ee -> 988 decf771 apply #220800000000000000000000000001ee -> 988 decf772 apply #220800000000000000000000000002ee -> 988 decf773 apply #220800000000000000000000000003ee -> 988 decf774 apply #220800000000000000000000000000ef -> 989 decf775 apply #220800000000000000000000000001ef -> 989 decf776 apply #220800000000000000000000000002ef -> 989 decf777 apply #220800000000000000000000000003ef -> 989 decf780 apply #220800000000000000000000000000fe -> 998 decf781 apply #220800000000000000000000000001fe -> 998 decf782 apply #220800000000000000000000000002fe -> 998 decf783 apply #220800000000000000000000000003fe -> 998 decf784 apply #220800000000000000000000000000ff -> 999 decf785 apply #220800000000000000000000000001ff -> 999 decf786 apply #220800000000000000000000000002ff -> 999 decf787 apply #220800000000000000000000000003ff -> 999 --- NEW FILE: decimal32.decTest --- ------------------------------------------------------------------------ -- decimal32.decTest -- decimal four-byte format testcases -- -- Copyright (c) IBM Corporation, 2000, 2003. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.39 -- This set of tests is for the four-byte concrete representation. -- Its characteristics are: -- -- 1 bit sign -- 5 bits combination field -- 6 bits exponent continuation -- 20 bits coefficient continuation -- -- Total exponent length 8 bits -- Total coefficient length 24 bits (7 digits) -- -- Elimit = 191 (maximum encoded exponent) -- Emax = 96 (largest exponent value) -- Emin = -95 (smallest exponent value) -- bias = 101 (subtracted from encoded exponent) = -Etiny extended: 1 precision: 7 rounding: half_up maxExponent: 96 minExponent: -95 -- General testcases -- (mostly derived from the Strawman 4 document and examples) decd001 apply #A23003D0 -> -7.50 decd002 apply -7.50 -> #A23003D0 -- Normality decd010 apply 1234567 -> #2654d2e7 decd011 apply 1234567.0 -> #2654d2e7 Rounded decd012 apply 1234567.1 -> #2654d2e7 Rounded Inexact decd013 apply -1234567 -> #a654d2e7 decd014 apply -1234567.0 -> #a654d2e7 Rounded decd015 apply -1234567.1 -> #a654d2e7 Rounded Inexact -- Nmax and similar decd022 apply 9.999999E+96 -> #77f3fcff decd023 apply #77f3fcff -> 9.999999E+96 decd024 apply 1.234567E+96 -> #47f4d2e7 decd025 apply #47f4d2e7 -> 1.234567E+96 -- fold-downs (more below) decd030 apply 1.23E+96 -> #47f4c000 Clamped decd031 apply #47f4c000 -> 1.230000E+96 decd032 apply 1E+96 -> #47f00000 Clamped decd033 apply #47f00000 -> 1.000000E+96 -- overflows maxExponent: 999 -- set high so conversion causes the overflow minExponent: -999 decd040 apply 10E+96 -> #78000000 Overflow Rounded Inexact decd041 apply 1.000000E+97 -> #78000000 Overflow Rounded Inexact maxExponent: 96 minExponent: -95 decd051 apply 12345 -> #225049c5 decd052 apply #225049c5 -> 12345 decd053 apply 1234 -> #22500534 decd054 apply #22500534 -> 1234 decd055 apply 123 -> #225000a3 decd056 apply #225000a3 -> 123 decd057 apply 12 -> #22500012 decd058 apply #22500012 -> 12 decd059 apply 1 -> #22500001 decd060 apply #22500001 -> 1 decd061 apply 1.23 -> #223000a3 decd062 apply #223000a3 -> 1.23 decd063 apply 123.45 -> #223049c5 decd064 apply #223049c5 -> 123.45 -- Nmin and below decd071 apply 1E-95 -> #00600001 decd072 apply #00600001 -> 1E-95 decd073 apply 1.000000E-95 -> #04000000 decd074 apply #04000000 -> 1.000000E-95 decd075 apply 1.000001E-95 -> #04000001 decd076 apply #04000001 -> 1.000001E-95 decd077 apply 0.100000E-95 -> #00020000 Subnormal decd07x apply 1.00000E-96 -> 1.00000E-96 Subnormal decd078 apply #00020000 -> 1.00000E-96 Subnormal decd079 apply 0.000010E-95 -> #00000010 Subnormal decd080 apply #00000010 -> 1.0E-100 Subnormal decd081 apply 0.000001E-95 -> #00000001 Subnormal decd082 apply #00000001 -> 1E-101 Subnormal decd083 apply 1e-101 -> #00000001 Subnormal decd084 apply #00000001 -> 1E-101 Subnormal decd08x apply 1e-101 -> 1E-101 Subnormal -- underflows decd090 apply 1e-101 -> #00000001 Subnormal decd091 apply 1.9e-101 -> #00000002 Subnormal Underflow Inexact Rounded decd092 apply 1.1e-101 -> #00000001 Subnormal Underflow Inexact Rounded decd093 apply 1.001e-101 -> #00000001 Subnormal Underflow Inexact Rounded decd094 apply 1.000001e-101 -> #00000001 Subnormal Underflow Inexact Rounded decd095 apply 1.0000001e-101 -> #00000001 Subnormal Underflow Inexact Rounded decd096 apply 0.1e-101 -> #00000000 Subnormal Underflow Inexact Rounded decd097 apply 0.001e-101 -> #00000000 Subnormal Underflow Inexact Rounded decd098 apply 0.000001e-101 -> #00000000 Subnormal Underflow Inexact Rounded decd099 apply 0.0000001e-101 -> #00000000 Subnormal Underflow Inexact Rounded -- same again, negatives -- -- Nmax and similar decd122 apply -9.999999E+96 -> #f7f3fcff decd123 apply #f7f3fcff -> -9.999999E+96 decd124 apply -1.234567E+96 -> #c7f4d2e7 decd125 apply #c7f4d2e7 -> -1.234567E+96 -- fold-downs (more below) decd130 apply -1.23E+96 -> #c7f4c000 Clamped decd131 apply #c7f4c000 -> -1.230000E+96 decd132 apply -1E+96 -> #c7f00000 Clamped decd133 apply #c7f00000 -> -1.000000E+96 -- overflows maxExponent: 999 -- set high so conversion causes the overflow minExponent: -999 decd140 apply -10E+96 -> #f8000000 Overflow Rounded Inexact decd141 apply -1.000000E+97 -> #f8000000 Overflow Rounded Inexact maxExponent: 96 minExponent: -95 decd151 apply -12345 -> #a25049c5 decd152 apply #a25049c5 -> -12345 decd153 apply -1234 -> #a2500534 decd154 apply #a2500534 -> -1234 decd155 apply -123 -> #a25000a3 decd156 apply #a25000a3 -> -123 decd157 apply -12 -> #a2500012 decd158 apply #a2500012 -> -12 decd159 apply -1 -> #a2500001 decd160 apply #a2500001 -> -1 decd161 apply -1.23 -> #a23000a3 decd162 apply #a23000a3 -> -1.23 decd163 apply -123.45 -> #a23049c5 decd164 apply #a23049c5 -> -123.45 -- Nmin and below decd171 apply -1E-95 -> #80600001 decd172 apply #80600001 -> -1E-95 decd173 apply -1.000000E-95 -> #84000000 decd174 apply #84000000 -> -1.000000E-95 decd175 apply -1.000001E-95 -> #84000001 decd176 apply #84000001 -> -1.000001E-95 decd177 apply -0.100000E-95 -> #80020000 Subnormal decd178 apply #80020000 -> -1.00000E-96 Subnormal decd179 apply -0.000010E-95 -> #80000010 Subnormal decd180 apply #80000010 -> -1.0E-100 Subnormal decd181 apply -0.000001E-95 -> #80000001 Subnormal decd182 apply #80000001 -> -1E-101 Subnormal decd183 apply -1e-101 -> #80000001 Subnormal decd184 apply #80000001 -> -1E-101 Subnormal -- underflows decd190 apply -1e-101 -> #80000001 Subnormal decd191 apply -1.9e-101 -> #80000002 Subnormal Underflow Inexact Rounded decd192 apply -1.1e-101 -> #80000001 Subnormal Underflow Inexact Rounded decd193 apply -1.001e-101 -> #80000001 Subnormal Underflow Inexact Rounded decd194 apply -1.000001e-101 -> #80000001 Subnormal Underflow Inexact Rounded decd195 apply -1.0000001e-101 -> #80000001 Subnormal Underflow Inexact Rounded decd196 apply -0.1e-101 -> #80000000 Subnormal Underflow Inexact Rounded decd197 apply -0.001e-101 -> #80000000 Subnormal Underflow Inexact Rounded decd198 apply -0.000001e-101 -> #80000000 Subnormal Underflow Inexact Rounded decd199 apply -0.0000001e-101 -> #80000000 Subnormal Underflow Inexact Rounded -- zeros decd400 apply 0E-400 -> #00000000 Clamped decd401 apply 0E-101 -> #00000000 decd402 apply #00000000 -> 0E-101 decd403 apply 0.000000E-95 -> #00000000 decd404 apply #00000000 -> 0E-101 decd405 apply 0E-2 -> #22300000 decd406 apply #22300000 -> 0.00 decd407 apply 0 -> #22500000 decd408 apply #22500000 -> 0 decd409 apply 0E+3 -> #22800000 decd410 apply #22800000 -> 0E+3 decd411 apply 0E+90 -> #43f00000 decd412 apply #43f00000 -> 0E+90 -- clamped zeros... decd413 apply 0E+91 -> #43f00000 Clamped decd414 apply #43f00000 -> 0E+90 decd415 apply 0E+96 -> #43f00000 Clamped decd416 apply #43f00000 -> 0E+90 decd417 apply 0E+400 -> #43f00000 Clamped decd418 apply #43f00000 -> 0E+90 -- negative zeros decd420 apply -0E-400 -> #80000000 Clamped decd421 apply -0E-101 -> #80000000 decd422 apply #80000000 -> -0E-101 decd423 apply -0.000000E-95 -> #80000000 decd424 apply #80000000 -> -0E-101 decd425 apply -0E-2 -> #a2300000 decd426 apply #a2300000 -> -0.00 decd427 apply -0 -> #a2500000 decd428 apply #a2500000 -> -0 decd429 apply -0E+3 -> #a2800000 decd430 apply #a2800000 -> -0E+3 decd431 apply -0E+90 -> #c3f00000 decd432 apply #c3f00000 -> -0E+90 -- clamped zeros... decd433 apply -0E+91 -> #c3f00000 Clamped decd434 apply #c3f00000 -> -0E+90 decd435 apply -0E+96 -> #c3f00000 Clamped decd436 apply #c3f00000 -> -0E+90 decd437 apply -0E+400 -> #c3f00000 Clamped decd438 apply #c3f00000 -> -0E+90 -- Specials decd500 apply Infinity -> #78000000 decd501 apply #78787878 -> #78000000 decd502 apply #78000000 -> Infinity decd503 apply #79797979 -> #78000000 decd504 apply #79000000 -> Infinity decd505 apply #7a7a7a7a -> #78000000 decd506 apply #7a000000 -> Infinity decd507 apply #7b7b7b7b -> #78000000 decd508 apply #7b000000 -> Infinity decd509 apply #7c7c7c7c -> #7c0c7c7c decd510 apply NaN -> #7c000000 decd511 apply #7c000000 -> NaN decd512 apply #7d7d7d7d -> #7c0d7d7d decd513 apply #7d000000 -> NaN decd514 apply #7e7e7e7e -> #7e0e7c7e decd515 apply #7e000000 -> sNaN decd516 apply #7f7f7f7f -> #7e0f7c7f decd517 apply #7f000000 -> sNaN decd518 apply #7fffffff -> sNaN999999 decd519 apply #7fffffff -> #7e03fcff decd520 apply -Infinity -> #f8000000 decd521 apply #f8787878 -> #f8000000 decd522 apply #f8000000 -> -Infinity decd523 apply #f9797979 -> #f8000000 decd524 apply #f9000000 -> -Infinity decd525 apply #fa7a7a7a -> #f8000000 decd526 apply #fa000000 -> -Infinity decd527 apply #fb7b7b7b -> #f8000000 decd528 apply #fb000000 -> -Infinity decd529 apply -NaN -> #fc000000 decd530 apply #fc7c7c7c -> #fc0c7c7c decd531 apply #fc000000 -> -NaN decd532 apply #fd7d7d7d -> #fc0d7d7d decd533 apply #fd000000 -> -NaN decd534 apply #fe7e7e7e -> #fe0e7c7e decd535 apply #fe000000 -> -sNaN decd536 apply #ff7f7f7f -> #fe0f7c7f decd537 apply #ff000000 -> -sNaN decd538 apply #ffffffff -> -sNaN999999 decd539 apply #ffffffff -> #fe03fcff -- diagnostic NaNs decd540 apply NaN -> #7c000000 decd541 apply NaN0 -> #7c000000 decd542 apply NaN1 -> #7c000001 decd543 apply NaN12 -> #7c000012 decd544 apply NaN79 -> #7c000079 decd545 apply NaN12345 -> #7c0049c5 decd546 apply NaN123456 -> #7c028e56 decd547 apply NaN799799 -> #7c0f7fdf decd548 apply NaN999999 -> #7c03fcff decd549 apply NaN1234567 -> #7c000000 -- too many digits -- fold-down full sequence decd601 apply 1E+96 -> #47f00000 Clamped decd602 apply #47f00000 -> 1.000000E+96 decd603 apply 1E+95 -> #43f20000 Clamped decd604 apply #43f20000 -> 1.00000E+95 decd605 apply 1E+94 -> #43f04000 Clamped decd606 apply #43f04000 -> 1.0000E+94 decd607 apply 1E+93 -> #43f00400 Clamped decd608 apply #43f00400 -> 1.000E+93 decd609 apply 1E+92 -> #43f00080 Clamped decd610 apply #43f00080 -> 1.00E+92 decd611 apply 1E+91 -> #43f00010 Clamped decd612 apply #43f00010 -> 1.0E+91 decd613 apply 1E+90 -> #43f00001 decd614 apply #43f00001 -> 1E+90 -- Selected DPD codes decd700 apply #22500000 -> 0 decd701 apply #22500009 -> 9 decd702 apply #22500010 -> 10 decd703 apply #22500019 -> 19 decd704 apply #22500020 -> 20 decd705 apply #22500029 -> 29 decd706 apply #22500030 -> 30 decd707 apply #22500039 -> 39 decd708 apply #22500040 -> 40 decd709 apply #22500049 -> 49 decd710 apply #22500050 -> 50 decd711 apply #22500059 -> 59 decd712 apply #22500060 -> 60 decd713 apply #22500069 -> 69 decd714 apply #22500070 -> 70 decd715 apply #22500071 -> 71 decd716 apply #22500072 -> 72 decd717 apply #22500073 -> 73 decd718 apply #22500074 -> 74 decd719 apply #22500075 -> 75 decd720 apply #22500076 -> 76 decd721 apply #22500077 -> 77 decd722 apply #22500078 -> 78 decd723 apply #22500079 -> 79 decd730 apply #2250029e -> 994 decd731 apply #2250029f -> 995 decd732 apply #225002a0 -> 520 decd733 apply #225002a1 -> 521 -- DPD: one of each of the huffman groups decd740 apply #225003f7 -> 777 decd741 apply #225003f8 -> 778 decd742 apply #225003eb -> 787 decd743 apply #2250037d -> 877 decd744 apply #2250039f -> 997 decd745 apply #225003bf -> 979 decd746 apply #225003df -> 799 decd747 apply #2250006e -> 888 -- DPD all-highs cases (includes the 24 redundant codes) decd750 apply #2250006e -> 888 decd751 apply #2250016e -> 888 decd752 apply #2250026e -> 888 decd753 apply #2250036e -> 888 decd754 apply #2250006f -> 889 decd755 apply #2250016f -> 889 decd756 apply #2250026f -> 889 decd757 apply #2250036f -> 889 decd760 apply #2250007e -> 898 decd761 apply #2250017e -> 898 decd762 apply #2250027e -> 898 decd763 apply #2250037e -> 898 decd764 apply #2250007f -> 899 decd765 apply #2250017f -> 899 decd766 apply #2250027f -> 899 decd767 apply #2250037f -> 899 decd770 apply #225000ee -> 988 decd771 apply #225001ee -> 988 decd772 apply #225002ee -> 988 decd773 apply #225003ee -> 988 decd774 apply #225000ef -> 989 decd775 apply #225001ef -> 989 decd776 apply #225002ef -> 989 decd777 apply #225003ef -> 989 decd780 apply #225000fe -> 998 decd781 apply #225001fe -> 998 decd782 apply #225002fe -> 998 decd783 apply #225003fe -> 998 decd784 apply #225000ff -> 999 decd785 apply #225001ff -> 999 decd786 apply #225002ff -> 999 decd787 apply #225003ff -> 999 Index: abs.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/abs.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** abs.decTest 1 Jul 2004 11:01:32 -0000 1.1 --- abs.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 -- This set of tests primarily tests the existence of the operator. --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 -- This set of tests primarily tests the existence of the operator. Index: add.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/add.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** add.decTest 1 Jul 2004 11:01:32 -0000 1.1 --- add.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 precision: 9 --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 precision: 9 Index: base.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/base.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** base.decTest 1 Jul 2004 11:01:32 -0000 1.1 --- base.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 -- This file tests base conversions from string to a decimal number --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 -- This file tests base conversions from string to a decimal number *************** *** 74,92 **** -- String [many more examples are implicitly tested elsewhere] -- strings without E cannot generate E in result ! basx101 toSci "12" -> '12' ! basx102 toSci "-76" -> '-76' ! basx103 toSci "12.76" -> '12.76' ! basx104 toSci "+12.76" -> '12.76' ! basx105 toSci "012.76" -> '12.76' ! basx106 toSci "+0.003" -> '0.003' ! basx107 toSci "17." -> '17' ! basx108 toSci ".5" -> '0.5' ! basx109 toSci "044" -> '44' ! basx110 toSci "0044" -> '44' ! basx111 toSci "0.0005" -> '0.0005' ! basx112 toSci "00.00005" -> '0.00005' ! basx113 toSci "0.000005" -> '0.000005' ! basx114 toSci "0.0000005" -> '5E-7' ! basx115 toSci "0.00000005" -> '5E-8' basx116 toSci "12345678.543210" -> '12345678.543210' basx117 toSci "2345678.543210" -> '2345678.543210' --- 74,93 ---- -- String [many more examples are implicitly tested elsewhere] -- strings without E cannot generate E in result ! basx100 toSci "12" -> '12' ! basx101 toSci "-76" -> '-76' ! basx102 toSci "12.76" -> '12.76' ! basx103 toSci "+12.76" -> '12.76' ! basx104 toSci "012.76" -> '12.76' ! basx105 toSci "+0.003" -> '0.003' ! basx106 toSci "17." -> '17' ! basx107 toSci ".5" -> '0.5' ! basx108 toSci "044" -> '44' ! basx109 toSci "0044" -> '44' ! basx110 toSci "0.0005" -> '0.0005' ! basx111 toSci "00.00005" -> '0.00005' ! basx112 toSci "0.000005" -> '0.000005' ! basx113 toSci "0.0000050" -> '0.0000050' ! basx114 toSci "0.0000005" -> '5E-7' ! basx115 toSci "0.00000005" -> '5E-8' basx116 toSci "12345678.543210" -> '12345678.543210' basx117 toSci "2345678.543210" -> '2345678.543210' *************** *** 100,103 **** --- 101,109 ---- basx125 toSci "-0345678.5432" -> '-345678.5432' basx126 toSci "-00345678.5432" -> '-345678.5432' + -- examples + basx127 toSci "5E-6" -> '0.000005' + basx128 toSci "50E-7" -> '0.0000050' + basx129 toSci "5E-7" -> '5E-7' + -- [No exotics as no Unicode] Index: clamp.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/clamp.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** clamp.decTest 1 Jul 2004 11:01:32 -0000 1.1 --- clamp.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 -- This set of tests uses the same limits as the 8-byte concrete --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 -- This set of tests uses the same limits as the 8-byte concrete Index: compare.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/compare.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** compare.decTest 1 Jul 2004 11:01:32 -0000 1.1 --- compare.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 -- Note that we cannot assume add/subtract tests cover paths adequately, --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 -- Note that we cannot assume add/subtract tests cover paths adequately, Index: decimal64.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/decimal64.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** decimal64.decTest 1 Jul 2004 11:01:32 -0000 1.1 --- decimal64.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 1,421 **** ! ------------------------------------------------------------------------ ! -- decimal64.decTest -- decimal eight-byte format testcases -- ! -- Copyright (c) IBM Corporation, 2000, 2003. All rights reserved. -- ! ------------------------------------------------------------------------ ! -- Please see the document "General Decimal Arithmetic Testcases" -- ! -- at http://www2.hursley.ibm.com/decimal for the description of -- ! -- these testcases. -- ! -- -- ! -- These testcases are experimental ('beta' versions), and they -- ! -- may contain errors. They are offered on an as-is basis. In -- ! -- particular, achieving the same results as the tests here is not -- ! -- a guarantee that an implementation complies with any Standard -- ! -- or specification. The tests are not exhaustive. -- ! -- -- ! -- Please send comments, suggestions, and corrections to the author: -- ! -- Mike Cowlishaw, IBM Fellow -- ! -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- ! -- mfc@uk.ibm.com -- ! ------------------------------------------------------------------------ ! version: 2.28 ! ! -- This set of tests is for the eight-byte concrete representation. ! -- Its characteristics are: ! -- ! -- 1 bit sign ! -- 5 bits combination field ! -- 8 bits exponent continuation ! -- 50 bits coefficient continuation ! -- ! -- Total exponent length 10 bits ! -- Total coefficient length 54 bits (16 digits) ! -- ! -- Elimit = 767 (maximum encoded exponent) ! -- Emax = 384 (largest exponent value) ! -- Emin = -383 (smallest exponent value) ! -- bias = 398 (subtracted from encoded exponent) = -Etiny ! ! extended: 1 ! precision: 16 ! rounding: half_up ! maxExponent: 384 ! minExponent: -383 ! ! -- General testcases ! -- (mostly derived from the Strawman 4 document and examples) ! dece001 apply #A2300000000003D0 -> -7.50 ! dece002 apply -7.50 -> #A2300000000003D0 ! ! -- Normality ! dece010 apply 1234567890123456 -> #263934b9c1e28e56 ! dece011 apply 1234567890123456.0 -> #263934b9c1e28e56 Rounded ! dece012 apply 1234567890123456.1 -> #263934b9c1e28e56 Rounded Inexact ! dece013 apply -1234567890123456 -> #a63934b9c1e28e56 ! dece014 apply -1234567890123456.0 -> #a63934b9c1e28e56 Rounded ! dece015 apply -1234567890123456.1 -> #a63934b9c1e28e56 Rounded Inexact ! ! ! -- Nmax and similar ! dece022 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff ! dece023 apply #77fcff3fcff3fcff -> 9.999999999999999E+384 ! dece024 apply 1.234567890123456E+384 -> #47fd34b9c1e28e56 ! dece025 apply #47fd34b9c1e28e56 -> 1.234567890123456E+384 ! -- fold-downs (more below) ! dece030 apply 1.23E+384 -> #47fd300000000000 Clamped ! dece031 apply #47fd300000000000 -> 1.230000000000000E+384 ! dece032 apply 1E+384 -> #47fc000000000000 Clamped ! dece033 apply #47fc000000000000 -> 1.000000000000000E+384 ! ! -- overflows ! maxExponent: 999 -- set high so conversion causes the overflow ! minExponent: -999 ! dece040 apply 10E+384 -> #7800000000000000 Overflow Rounded Inexact ! dece041 apply 1.000000000000000E+385 -> #7800000000000000 Overflow Rounded Inexact ! maxExponent: 384 ! minExponent: -383 ! ! dece051 apply 12345 -> #22380000000049c5 ! dece052 apply #22380000000049c5 -> 12345 ! dece053 apply 1234 -> #2238000000000534 ! dece054 apply #2238000000000534 -> 1234 ! dece055 apply 123 -> #22380000000000a3 ! dece056 apply #22380000000000a3 -> 123 ! dece057 apply 12 -> #2238000000000012 ! dece058 apply #2238000000000012 -> 12 ! dece059 apply 1 -> #2238000000000001 ! dece060 apply #2238000000000001 -> 1 ! dece061 apply 1.23 -> #22300000000000a3 ! dece062 apply #22300000000000a3 -> 1.23 ! dece063 apply 123.45 -> #22300000000049c5 ! dece064 apply #22300000000049c5 -> 123.45 ! ! -- Nmin and below ! dece071 apply 1E-383 -> #003c000000000001 ! dece072 apply #003c000000000001 -> 1E-383 ! dece073 apply 1.000000000000000E-383 -> #0400000000000000 ! dece074 apply #0400000000000000 -> 1.000000000000000E-383 ! dece075 apply 1.000000000000001E-383 -> #0400000000000001 ! dece076 apply #0400000000000001 -> 1.000000000000001E-383 ! ! dece077 apply 0.100000000000000E-383 -> #0000800000000000 Subnormal ! dece078 apply #0000800000000000 -> 1.00000000000000E-384 Subnormal ! dece079 apply 0.000000000000010E-383 -> #0000000000000010 Subnormal ! dece080 apply #0000000000000010 -> 1.0E-397 Subnormal ! dece081 apply 0.00000000000001E-383 -> #0004000000000001 Subnormal ! dece082 apply #0004000000000001 -> 1E-397 Subnormal ! dece083 apply 0.000000000000001E-383 -> #0000000000000001 Subnormal ! dece084 apply #0000000000000001 -> 1E-398 Subnormal ! ! -- underflows ! dece090 apply 1e-398 -> #0000000000000001 Subnormal ! dece091 apply 1.9e-398 -> #0000000000000002 Subnormal Underflow Inexact Rounded ! dece092 apply 1.1e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded ! dece093 apply 1.00000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded ! dece094 apply 1.00000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded ! dece095 apply 1.000000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded ! dece096 apply 0.1e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded ! dece097 apply 0.00000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded ! dece098 apply 0.00000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded ! dece099 apply 0.000000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded ! ! -- Same again, negatives ! -- Nmax and similar ! dece122 apply -9.999999999999999E+384 -> #f7fcff3fcff3fcff ! dece123 apply #f7fcff3fcff3fcff -> -9.999999999999999E+384 ! dece124 apply -1.234567890123456E+384 -> #c7fd34b9c1e28e56 ! dece125 apply #c7fd34b9c1e28e56 -> -1.234567890123456E+384 ! -- fold-downs (more below) ! dece130 apply -1.23E+384 -> #c7fd300000000000 Clamped ! dece131 apply #c7fd300000000000 -> -1.230000000000000E+384 ! dece132 apply -1E+384 -> #c7fc000000000000 Clamped ! dece133 apply #c7fc000000000000 -> -1.000000000000000E+384 ! ! -- overflows ! maxExponent: 999 -- set high so conversion causes the overflow ! minExponent: -999 ! dece140 apply -10E+384 -> #f800000000000000 Overflow Rounded Inexact ! dece141 apply -1.000000000000000E+385 -> #f800000000000000 Overflow Rounded Inexact ! maxExponent: 384 ! minExponent: -383 ! ! dece151 apply -12345 -> #a2380000000049c5 ! dece152 apply #a2380000000049c5 -> -12345 ! dece153 apply -1234 -> #a238000000000534 ! dece154 apply #a238000000000534 -> -1234 ! dece155 apply -123 -> #a2380000000000a3 ! dece156 apply #a2380000000000a3 -> -123 ! dece157 apply -12 -> #a238000000000012 ! dece158 apply #a238000000000012 -> -12 ! dece159 apply -1 -> #a238000000000001 ! dece160 apply #a238000000000001 -> -1 ! dece161 apply -1.23 -> #a2300000000000a3 ! dece162 apply #a2300000000000a3 -> -1.23 ! dece163 apply -123.45 -> #a2300000000049c5 ! dece164 apply #a2300000000049c5 -> -123.45 ! ! -- Nmin and below ! dece171 apply -1E-383 -> #803c000000000001 ! dece172 apply #803c000000000001 -> -1E-383 ! dece173 apply -1.000000000000000E-383 -> #8400000000000000 ! dece174 apply #8400000000000000 -> -1.000000000000000E-383 ! dece175 apply -1.000000000000001E-383 -> #8400000000000001 ! dece176 apply #8400000000000001 -> -1.000000000000001E-383 ! ! dece177 apply -0.100000000000000E-383 -> #8000800000000000 Subnormal ! dece178 apply #8000800000000000 -> -1.00000000000000E-384 Subnormal ! dece179 apply -0.000000000000010E-383 -> #8000000000000010 Subnormal ! dece180 apply #8000000000000010 -> -1.0E-397 Subnormal ! dece181 apply -0.00000000000001E-383 -> #8004000000000001 Subnormal ! dece182 apply #8004000000000001 -> -1E-397 Subnormal ! dece183 apply -0.000000000000001E-383 -> #8000000000000001 Subnormal ! dece184 apply #8000000000000001 -> -1E-398 Subnormal ! ! -- underflows ! dece189 apply -1e-398 -> #8000000000000001 Subnormal ! dece190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded ! dece191 apply -1.9e-398 -> #8000000000000002 Subnormal Underflow Inexact Rounded ! dece192 apply -1.1e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded ! dece193 apply -1.00000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded ! dece194 apply -1.00000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded ! dece195 apply -1.000000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded ! dece196 apply -0.1e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded ! dece197 apply -0.00000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded ! dece198 apply -0.00000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded ! dece199 apply -0.000000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded ! ! -- zeros ! dece401 apply 0E-500 -> #0000000000000000 Clamped ! dece402 apply 0E-400 -> #0000000000000000 Clamped ! dece403 apply 0E-398 -> #0000000000000000 ! dece404 apply #0000000000000000 -> 0E-398 ! dece405 apply 0.000000000000000E-383 -> #0000000000000000 ! dece406 apply #0000000000000000 -> 0E-398 ! dece407 apply 0E-2 -> #2230000000000000 ! dece408 apply #2230000000000000 -> 0.00 ! dece409 apply 0 -> #2238000000000000 ! dece410 apply #2238000000000000 -> 0 ! dece411 apply 0E+3 -> #2244000000000000 ! dece412 apply #2244000000000000 -> 0E+3 ! dece413 apply 0E+369 -> #43fc000000000000 ! dece414 apply #43fc000000000000 -> 0E+369 ! -- clamped zeros... ! dece415 apply 0E+370 -> #43fc000000000000 Clamped ! dece416 apply #43fc000000000000 -> 0E+369 ! dece417 apply 0E+384 -> #43fc000000000000 Clamped ! dece418 apply #43fc000000000000 -> 0E+369 ! dece419 apply 0E+400 -> #43fc000000000000 Clamped ! dece420 apply #43fc000000000000 -> 0E+369 ! dece421 apply 0E+500 -> #43fc000000000000 Clamped ! dece422 apply #43fc000000000000 -> 0E+369 ! ! -- negative zeros ! dece431 apply -0E-400 -> #8000000000000000 Clamped ! dece432 apply -0E-400 -> #8000000000000000 Clamped ! dece433 apply -0E-398 -> #8000000000000000 ! dece434 apply #8000000000000000 -> -0E-398 ! dece435 apply -0.000000000000000E-383 -> #8000000000000000 ! dece436 apply #8000000000000000 -> -0E-398 ! dece437 apply -0E-2 -> #a230000000000000 ! dece438 apply #a230000000000000 -> -0.00 ! dece439 apply -0 -> #a238000000000000 ! dece440 apply #a238000000000000 -> -0 ! dece441 apply -0E+3 -> #a244000000000000 ! dece442 apply #a244000000000000 -> -0E+3 ! dece443 apply -0E+369 -> #c3fc000000000000 ! dece444 apply #c3fc000000000000 -> -0E+369 ! -- clamped zeros... ! dece445 apply -0E+370 -> #c3fc000000000000 Clamped ! dece446 apply #c3fc000000000000 -> -0E+369 ! dece447 apply -0E+384 -> #c3fc000000000000 Clamped ! dece448 apply #c3fc000000000000 -> -0E+369 ! dece449 apply -0E+400 -> #c3fc000000000000 Clamped ! dece450 apply #c3fc000000000000 -> -0E+369 ! dece451 apply -0E+500 -> #c3fc000000000000 Clamped ! dece452 apply #c3fc000000000000 -> -0E+369 ! ! -- Specials ! dece501 apply #7878787878787878 -> #7800000000000000 ! dece502 apply #7800000000000000 -> Infinity ! dece503 apply #7979797979797979 -> #7800000000000000 ! dece504 apply #7900000000000000 -> Infinity ! dece505 apply #7a7a7a7a7a7a7a7a -> #7800000000000000 ! dece506 apply #7a00000000000000 -> Infinity ! dece507 apply #7b7b7b7b7b7b7b7b -> #7800000000000000 ! dece508 apply #7b00000000000000 -> Infinity ! dece509 apply #7c7c7c7c7c7c7c7c -> #7dffffffffffffff ! dece510 apply #7c00000000000000 -> NaN ! dece511 apply #7d7d7d7d7d7d7d7d -> #7dffffffffffffff ! dece512 apply #7d00000000000000 -> NaN ! dece513 apply #7e7e7e7e7e7e7e7e -> #7fffffffffffffff ! dece514 apply #7e00000000000000 -> sNaN ! dece515 apply #7f7f7f7f7f7f7f7f -> #7fffffffffffffff ! dece516 apply #7f00000000000000 -> sNaN ! ! dece521 apply #f878787878787878 -> #f800000000000000 ! dece522 apply #f800000000000000 -> -Infinity ! dece523 apply #f979797979797979 -> #f800000000000000 ! dece524 apply #f900000000000000 -> -Infinity ! dece525 apply #fa7a7a7a7a7a7a7a -> #f800000000000000 ! dece526 apply #fa00000000000000 -> -Infinity ! dece527 apply #fb7b7b7b7b7b7b7b -> #f800000000000000 ! dece528 apply #fb00000000000000 -> -Infinity ! dece529 apply #fc7c7c7c7c7c7c7c -> #7dffffffffffffff ! dece530 apply #fc00000000000000 -> NaN ! dece531 apply #fd7d7d7d7d7d7d7d -> #7dffffffffffffff ! dece532 apply #fd00000000000000 -> NaN ! dece533 apply #fe7e7e7e7e7e7e7e -> #7fffffffffffffff ! dece534 apply #fe00000000000000 -> sNaN ! dece535 apply #ff7f7f7f7f7f7f7f -> #7fffffffffffffff ! dece536 apply #ff00000000000000 -> sNaN ! ! -- fold-down full sequence ! dece601 apply 1E+384 -> #47fc000000000000 Clamped ! dece602 apply #47fc000000000000 -> 1.000000000000000E+384 ! dece603 apply 1E+383 -> #43fc800000000000 Clamped ! dece604 apply #43fc800000000000 -> 1.00000000000000E+383 ! dece605 apply 1E+382 -> #43fc100000000000 Clamped ! dece606 apply #43fc100000000000 -> 1.0000000000000E+382 ! dece607 apply 1E+381 -> #43fc010000000000 Clamped ! dece608 apply #43fc010000000000 -> 1.000000000000E+381 ! dece609 apply 1E+380 -> #43fc002000000000 Clamped ! dece610 apply #43fc002000000000 -> 1.00000000000E+380 ! dece611 apply 1E+379 -> #43fc000400000000 Clamped ! dece612 apply #43fc000400000000 -> 1.0000000000E+379 ! dece613 apply 1E+378 -> #43fc000040000000 Clamped ! dece614 apply #43fc000040000000 -> 1.000000000E+378 ! dece615 apply 1E+377 -> #43fc000008000000 Clamped ! dece616 apply #43fc000008000000 -> 1.00000000E+377 ! dece617 apply 1E+376 -> #43fc000001000000 Clamped ! dece618 apply #43fc000001000000 -> 1.0000000E+376 ! dece619 apply 1E+375 -> #43fc000000100000 Clamped ! dece620 apply #43fc000000100000 -> 1.000000E+375 ! dece621 apply 1E+374 -> #43fc000000020000 Clamped ! dece622 apply #43fc000000020000 -> 1.00000E+374 ! dece623 apply 1E+373 -> #43fc000000004000 Clamped ! dece624 apply #43fc000000004000 -> 1.0000E+373 ! dece625 apply 1E+372 -> #43fc000000000400 Clamped ! dece626 apply #43fc000000000400 -> 1.000E+372 ! dece627 apply 1E+371 -> #43fc000000000080 Clamped ! dece628 apply #43fc000000000080 -> 1.00E+371 ! dece629 apply 1E+370 -> #43fc000000000010 Clamped ! dece630 apply #43fc000000000010 -> 1.0E+370 ! dece631 apply 1E+369 -> #43fc000000000001 ! dece632 apply #43fc000000000001 -> 1E+369 ! dece633 apply 1E+368 -> #43f8000000000001 ! dece634 apply #43f8000000000001 -> 1E+368 ! -- same with 9s ! dece641 apply 9E+384 -> #77fc000000000000 Clamped ! dece642 apply #77fc000000000000 -> 9.000000000000000E+384 ! dece643 apply 9E+383 -> #43fc8c0000000000 Clamped ! dece644 apply #43fc8c0000000000 -> 9.00000000000000E+383 ! dece645 apply 9E+382 -> #43fc1a0000000000 Clamped ! dece646 apply #43fc1a0000000000 -> 9.0000000000000E+382 ! dece647 apply 9E+381 -> #43fc090000000000 Clamped ! dece648 apply #43fc090000000000 -> 9.000000000000E+381 ! dece649 apply 9E+380 -> #43fc002300000000 Clamped ! dece650 apply #43fc002300000000 -> 9.00000000000E+380 ! dece651 apply 9E+379 -> #43fc000680000000 Clamped ! dece652 apply #43fc000680000000 -> 9.0000000000E+379 ! dece653 apply 9E+378 -> #43fc000240000000 Clamped ! dece654 apply #43fc000240000000 -> 9.000000000E+378 ! dece655 apply 9E+377 -> #43fc000008c00000 Clamped ! dece656 apply #43fc000008c00000 -> 9.00000000E+377 ! dece657 apply 9E+376 -> #43fc000001a00000 Clamped ! dece658 apply #43fc000001a00000 -> 9.0000000E+376 ! dece659 apply 9E+375 -> #43fc000000900000 Clamped ! dece660 apply #43fc000000900000 -> 9.000000E+375 ! dece661 apply 9E+374 -> #43fc000000023000 Clamped ! dece662 apply #43fc000000023000 -> 9.00000E+374 ! dece663 apply 9E+373 -> #43fc000000006800 Clamped ! dece664 apply #43fc000000006800 -> 9.0000E+373 ! dece665 apply 9E+372 -> #43fc000000002400 Clamped ! dece666 apply #43fc000000002400 -> 9.000E+372 ! dece667 apply 9E+371 -> #43fc00000000008c Clamped ! dece668 apply #43fc00000000008c -> 9.00E+371 ! dece669 apply 9E+370 -> #43fc00000000001a Clamped ! dece670 apply #43fc00000000001a -> 9.0E+370 ! dece671 apply 9E+369 -> #43fc000000000009 ! dece672 apply #43fc000000000009 -> 9E+369 ! dece673 apply 9E+368 -> #43f8000000000009 ! dece674 apply #43f8000000000009 -> 9E+368 ! ! ! -- Selected DPD codes ! dece700 apply #2238000000000000 -> 0 ! dece701 apply #2238000000000009 -> 9 ! dece702 apply #2238000000000010 -> 10 ! dece703 apply #2238000000000019 -> 19 ! dece704 apply #2238000000000020 -> 20 ! dece705 apply #2238000000000029 -> 29 ! dece706 apply #2238000000000030 -> 30 ! dece707 apply #2238000000000039 -> 39 ! dece708 apply #2238000000000040 -> 40 ! dece709 apply #2238000000000049 -> 49 ! dece710 apply #2238000000000050 -> 50 ! dece711 apply #2238000000000059 -> 59 ! dece712 apply #2238000000000060 -> 60 ! dece713 apply #2238000000000069 -> 69 ! dece714 apply #2238000000000070 -> 70 ! dece715 apply #2238000000000071 -> 71 ! dece716 apply #2238000000000072 -> 72 ! dece717 apply #2238000000000073 -> 73 ! dece718 apply #2238000000000074 -> 74 ! dece719 apply #2238000000000075 -> 75 ! dece720 apply #2238000000000076 -> 76 ! dece721 apply #2238000000000077 -> 77 ! dece722 apply #2238000000000078 -> 78 ! dece723 apply #2238000000000079 -> 79 ! ! dece730 apply #223800000000029e -> 994 ! dece731 apply #223800000000029f -> 995 ! dece732 apply #22380000000002a0 -> 520 ! dece733 apply #22380000000002a1 -> 521 ! ! -- DPD: one of each of the huffman groups ! dece740 apply #22380000000003f7 -> 777 ! dece741 apply #22380000000003f8 -> 778 ! dece742 apply #22380000000003eb -> 787 ! dece743 apply #223800000000037d -> 877 ! dece744 apply #223800000000039f -> 997 ! dece745 apply #22380000000003bf -> 979 ! dece746 apply #22380000000003df -> 799 ! dece747 apply #223800000000006e -> 888 ! ! ! -- DPD all-highs cases (includes the 24 redundant codes) ! dece750 apply #223800000000006e -> 888 ! dece751 apply #223800000000016e -> 888 ! dece752 apply #223800000000026e -> 888 ! dece753 apply #223800000000036e -> 888 ! dece754 apply #223800000000006f -> 889 ! dece755 apply #223800000000016f -> 889 ! dece756 apply #223800000000026f -> 889 ! dece757 apply #223800000000036f -> 889 ! ! dece760 apply #223800000000007e -> 898 ! dece761 apply #223800000000017e -> 898 ! dece762 apply #223800000000027e -> 898 ! dece763 apply #223800000000037e -> 898 ! dece764 apply #223800000000007f -> 899 ! dece765 apply #223800000000017f -> 899 ! dece766 apply #223800000000027f -> 899 ! dece767 apply #223800000000037f -> 899 ! ! dece770 apply #22380000000000ee -> 988 ! dece771 apply #22380000000001ee -> 988 ! dece772 apply #22380000000002ee -> 988 ! dece773 apply #22380000000003ee -> 988 ! dece774 apply #22380000000000ef -> 989 ! dece775 apply #22380000000001ef -> 989 ! dece776 apply #22380000000002ef -> 989 ! dece777 apply #22380000000003ef -> 989 ! ! dece780 apply #22380000000000fe -> 998 ! dece781 apply #22380000000001fe -> 998 ! dece782 apply #22380000000002fe -> 998 ! dece783 apply #22380000000003fe -> 998 ! dece784 apply #22380000000000ff -> 999 ! dece785 apply #22380000000001ff -> 999 ! dece786 apply #22380000000002ff -> 999 ! dece787 apply #22380000000003ff -> 999 ! --- 1,444 ---- ! ------------------------------------------------------------------------ ! -- decimal64.decTest -- decimal eight-byte format testcases -- ! -- Copyright (c) IBM Corporation, 2000, 2003. All rights reserved. -- ! ------------------------------------------------------------------------ ! -- Please see the document "General Decimal Arithmetic Testcases" -- ! -- at http://www2.hursley.ibm.com/decimal for the description of -- ! -- these testcases. -- ! -- -- ! -- These testcases are experimental ('beta' versions), and they -- ! -- may contain errors. They are offered on an as-is basis. In -- ! -- particular, achieving the same results as the tests here is not -- ! -- a guarantee that an implementation complies with any Standard -- ! -- or specification. The tests are not exhaustive. -- ! -- -- ! -- Please send comments, suggestions, and corrections to the author: -- ! -- Mike Cowlishaw, IBM Fellow -- ! -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- ! -- mfc@uk.ibm.com -- ! ------------------------------------------------------------------------ ! version: 2.39 ! ! -- This set of tests is for the eight-byte concrete representation. ! -- Its characteristics are: ! -- ! -- 1 bit sign ! -- 5 bits combination field ! -- 8 bits exponent continuation ! -- 50 bits coefficient continuation ! -- ! -- Total exponent length 10 bits ! -- Total coefficient length 54 bits (16 digits) ! -- ! -- Elimit = 767 (maximum encoded exponent) ! -- Emax = 384 (largest exponent value) ! -- Emin = -383 (smallest exponent value) ! -- bias = 398 (subtracted from encoded exponent) = -Etiny ! ! extended: 1 ! precision: 16 ! rounding: half_up ! maxExponent: 384 ! minExponent: -383 ! ! -- General testcases ! -- (mostly derived from the Strawman 4 document and examples) ! dece001 apply #A2300000000003D0 -> -7.50 ! dece002 apply -7.50 -> #A2300000000003D0 ! ! -- Normality ! dece010 apply 1234567890123456 -> #263934b9c1e28e56 ! dece011 apply 1234567890123456.0 -> #263934b9c1e28e56 Rounded ! dece012 apply 1234567890123456.1 -> #263934b9c1e28e56 Rounded Inexact ! dece013 apply -1234567890123456 -> #a63934b9c1e28e56 ! dece014 apply -1234567890123456.0 -> #a63934b9c1e28e56 Rounded ! dece015 apply -1234567890123456.1 -> #a63934b9c1e28e56 Rounded Inexact ! ! ! -- Nmax and similar ! dece022 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff ! dece023 apply #77fcff3fcff3fcff -> 9.999999999999999E+384 ! dece024 apply 1.234567890123456E+384 -> #47fd34b9c1e28e56 ! dece025 apply #47fd34b9c1e28e56 -> 1.234567890123456E+384 ! -- fold-downs (more below) ! dece030 apply 1.23E+384 -> #47fd300000000000 Clamped ! dece031 apply #47fd300000000000 -> 1.230000000000000E+384 ! dece032 apply 1E+384 -> #47fc000000000000 Clamped ! dece033 apply #47fc000000000000 -> 1.000000000000000E+384 ! ! -- overflows ! maxExponent: 999 -- set high so conversion causes the overflow ! minExponent: -999 ! dece040 apply 10E+384 -> #7800000000000000 Overflow Rounded Inexact ! dece041 apply 1.000000000000000E+385 -> #7800000000000000 Overflow Rounded Inexact ! maxExponent: 384 ! minExponent: -383 ! ! dece051 apply 12345 -> #22380000000049c5 ! dece052 apply #22380000000049c5 -> 12345 ! dece053 apply 1234 -> #2238000000000534 ! dece054 apply #2238000000000534 -> 1234 ! dece055 apply 123 -> #22380000000000a3 ! dece056 apply #22380000000000a3 -> 123 ! dece057 apply 12 -> #2238000000000012 ! dece058 apply #2238000000000012 -> 12 ! dece059 apply 1 -> #2238000000000001 ! dece060 apply #2238000000000001 -> 1 ! dece061 apply 1.23 -> #22300000000000a3 ! dece062 apply #22300000000000a3 -> 1.23 ! dece063 apply 123.45 -> #22300000000049c5 ! dece064 apply #22300000000049c5 -> 123.45 ! ! -- Nmin and below ! dece071 apply 1E-383 -> #003c000000000001 ! dece072 apply #003c000000000001 -> 1E-383 ! dece073 apply 1.000000000000000E-383 -> #0400000000000000 ! dece074 apply #0400000000000000 -> 1.000000000000000E-383 ! dece075 apply 1.000000000000001E-383 -> #0400000000000001 ! dece076 apply #0400000000000001 -> 1.000000000000001E-383 ! ! dece077 apply 0.100000000000000E-383 -> #0000800000000000 Subnormal ! dece078 apply #0000800000000000 -> 1.00000000000000E-384 Subnormal ! dece079 apply 0.000000000000010E-383 -> #0000000000000010 Subnormal ! dece080 apply #0000000000000010 -> 1.0E-397 Subnormal ! dece081 apply 0.00000000000001E-383 -> #0004000000000001 Subnormal ! dece082 apply #0004000000000001 -> 1E-397 Subnormal ! dece083 apply 0.000000000000001E-383 -> #0000000000000001 Subnormal ! dece084 apply #0000000000000001 -> 1E-398 Subnormal ! ! -- underflows ! dece090 apply 1e-398 -> #0000000000000001 Subnormal ! dece091 apply 1.9e-398 -> #0000000000000002 Subnormal Underflow Inexact Rounded ! dece092 apply 1.1e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded ! dece093 apply 1.00000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded ! dece094 apply 1.00000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded ! dece095 apply 1.000000000000001e-398 -> #0000000000000001 Subnormal Underflow Inexact Rounded ! dece096 apply 0.1e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded ! dece097 apply 0.00000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded ! dece098 apply 0.00000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded ! dece099 apply 0.000000000000001e-398 -> #0000000000000000 Subnormal Underflow Inexact Rounded ! ! -- Same again, negatives ! -- Nmax and similar ! dece122 apply -9.999999999999999E+384 -> #f7fcff3fcff3fcff ! dece123 apply #f7fcff3fcff3fcff -> -9.999999999999999E+384 ! dece124 apply -1.234567890123456E+384 -> #c7fd34b9c1e28e56 ! dece125 apply #c7fd34b9c1e28e56 -> -1.234567890123456E+384 ! -- fold-downs (more below) ! dece130 apply -1.23E+384 -> #c7fd300000000000 Clamped ! dece131 apply #c7fd300000000000 -> -1.230000000000000E+384 ! dece132 apply -1E+384 -> #c7fc000000000000 Clamped ! dece133 apply #c7fc000000000000 -> -1.000000000000000E+384 ! ! -- overflows ! maxExponent: 999 -- set high so conversion causes the overflow ! minExponent: -999 ! dece140 apply -10E+384 -> #f800000000000000 Overflow Rounded Inexact ! dece141 apply -1.000000000000000E+385 -> #f800000000000000 Overflow Rounded Inexact ! maxExponent: 384 ! minExponent: -383 ! ! dece151 apply -12345 -> #a2380000000049c5 ! dece152 apply #a2380000000049c5 -> -12345 ! dece153 apply -1234 -> #a238000000000534 ! dece154 apply #a238000000000534 -> -1234 ! dece155 apply -123 -> #a2380000000000a3 ! dece156 apply #a2380000000000a3 -> -123 ! dece157 apply -12 -> #a238000000000012 ! dece158 apply #a238000000000012 -> -12 ! dece159 apply -1 -> #a238000000000001 ! dece160 apply #a238000000000001 -> -1 ! dece161 apply -1.23 -> #a2300000000000a3 ! dece162 apply #a2300000000000a3 -> -1.23 ! dece163 apply -123.45 -> #a2300000000049c5 ! dece164 apply #a2300000000049c5 -> -123.45 ! ! -- Nmin and below ! dece171 apply -1E-383 -> #803c000000000001 ! dece172 apply #803c000000000001 -> -1E-383 ! dece173 apply -1.000000000000000E-383 -> #8400000000000000 ! dece174 apply #8400000000000000 -> -1.000000000000000E-383 ! dece175 apply -1.000000000000001E-383 -> #8400000000000001 ! dece176 apply #8400000000000001 -> -1.000000000000001E-383 ! ! dece177 apply -0.100000000000000E-383 -> #8000800000000000 Subnormal ! dece178 apply #8000800000000000 -> -1.00000000000000E-384 Subnormal ! dece179 apply -0.000000000000010E-383 -> #8000000000000010 Subnormal ! dece180 apply #8000000000000010 -> -1.0E-397 Subnormal ! dece181 apply -0.00000000000001E-383 -> #8004000000000001 Subnormal ! dece182 apply #8004000000000001 -> -1E-397 Subnormal ! dece183 apply -0.000000000000001E-383 -> #8000000000000001 Subnormal ! dece184 apply #8000000000000001 -> -1E-398 Subnormal ! ! -- underflows ! dece189 apply -1e-398 -> #8000000000000001 Subnormal ! dece190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded ! dece191 apply -1.9e-398 -> #8000000000000002 Subnormal Underflow Inexact Rounded ! dece192 apply -1.1e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded ! dece193 apply -1.00000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded ! dece194 apply -1.00000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded ! dece195 apply -1.000000000000001e-398 -> #8000000000000001 Subnormal Underflow Inexact Rounded ! dece196 apply -0.1e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded ! dece197 apply -0.00000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded ! dece198 apply -0.00000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded ! dece199 apply -0.000000000000001e-398 -> #8000000000000000 Subnormal Underflow Inexact Rounded ! ! -- zeros ! dece401 apply 0E-500 -> #0000000000000000 Clamped ! dece402 apply 0E-400 -> #0000000000000000 Clamped ! dece403 apply 0E-398 -> #0000000000000000 ! dece404 apply #0000000000000000 -> 0E-398 ! dece405 apply 0.000000000000000E-383 -> #0000000000000000 ! dece406 apply #0000000000000000 -> 0E-398 ! dece407 apply 0E-2 -> #2230000000000000 ! dece408 apply #2230000000000000 -> 0.00 ! dece409 apply 0 -> #2238000000000000 ! dece410 apply #2238000000000000 -> 0 ! dece411 apply 0E+3 -> #2244000000000000 ! dece412 apply #2244000000000000 -> 0E+3 ! dece413 apply 0E+369 -> #43fc000000000000 ! dece414 apply #43fc000000000000 -> 0E+369 ! -- clamped zeros... ! dece415 apply 0E+370 -> #43fc000000000000 Clamped ! dece416 apply #43fc000000000000 -> 0E+369 ! dece417 apply 0E+384 -> #43fc000000000000 Clamped ! dece418 apply #43fc000000000000 -> 0E+369 ! dece419 apply 0E+400 -> #43fc000000000000 Clamped ! dece420 apply #43fc000000000000 -> 0E+369 ! dece421 apply 0E+500 -> #43fc000000000000 Clamped ! dece422 apply #43fc000000000000 -> 0E+369 ! ! -- negative zeros ! dece431 apply -0E-400 -> #8000000000000000 Clamped ! dece432 apply -0E-400 -> #8000000000000000 Clamped ! dece433 apply -0E-398 -> #8000000000000000 ! dece434 apply #8000000000000000 -> -0E-398 ! dece435 apply -0.000000000000000E-383 -> #8000000000000000 ! dece436 apply #8000000000000000 -> -0E-398 ! dece437 apply -0E-2 -> #a230000000000000 ! dece438 apply #a230000000000000 -> -0.00 ! dece439 apply -0 -> #a238000000000000 ! dece440 apply #a238000000000000 -> -0 ! dece441 apply -0E+3 -> #a244000000000000 ! dece442 apply #a244000000000000 -> -0E+3 ! dece443 apply -0E+369 -> #c3fc000000000000 ! dece444 apply #c3fc000000000000 -> -0E+369 ! -- clamped zeros... ! dece445 apply -0E+370 -> #c3fc000000000000 Clamped ! dece446 apply #c3fc000000000000 -> -0E+369 ! dece447 apply -0E+384 -> #c3fc000000000000 Clamped ! dece448 apply #c3fc000000000000 -> -0E+369 ! dece449 apply -0E+400 -> #c3fc000000000000 Clamped ! dece450 apply #c3fc000000000000 -> -0E+369 ! dece451 apply -0E+500 -> #c3fc000000000000 Clamped ! dece452 apply #c3fc000000000000 -> -0E+369 ! ! -- Specials ! dece500 apply Infinity -> #7800000000000000 ! dece501 apply #7878787878787878 -> #7800000000000000 ! dece502 apply #7800000000000000 -> Infinity ! dece503 apply #7979797979797979 -> #7800000000000000 ! dece504 apply #7900000000000000 -> Infinity ! dece505 apply #7a7a7a7a7a7a7a7a -> #7800000000000000 ! dece506 apply #7a00000000000000 -> Infinity ! dece507 apply #7b7b7b7b7b7b7b7b -> #7800000000000000 ! dece508 apply #7b00000000000000 -> Infinity ! ! dece509 apply NaN -> #7c00000000000000 ! dece510 apply #7c7c7c7c7c7c7c7c -> #7c007c7c7c7c7c7c ! dece511 apply #7c00000000000000 -> NaN ! dece512 apply #7d7d7d7d7d7d7d7d -> #7c017d7d7d7d7d7d ! dece513 apply #7d00000000000000 -> NaN ! dece514 apply #7e7e7e7e7e7e7e7e -> #7e007e7e7e7e7c7e ! dece515 apply #7e00000000000000 -> sNaN ! dece516 apply #7f7f7f7f7f7f7f7f -> #7e007f7f7f7f7c7f ! dece517 apply #7f00000000000000 -> sNaN ! dece518 apply #7fffffffffffffff -> sNaN999999999999999 ! dece519 apply #7fffffffffffffff -> #7e00ff3fcff3fcff ! ! dece520 apply -Infinity -> #f800000000000000 ! dece521 apply #f878787878787878 -> #f800000000000000 ! dece522 apply #f800000000000000 -> -Infinity ! dece523 apply #f979797979797979 -> #f800000000000000 ! dece524 apply #f900000000000000 -> -Infinity ! dece525 apply #fa7a7a7a7a7a7a7a -> #f800000000000000 ! dece526 apply #fa00000000000000 -> -Infinity ! dece527 apply #fb7b7b7b7b7b7b7b -> #f800000000000000 ! dece528 apply #fb00000000000000 -> -Infinity ! ! dece529 apply -NaN -> #fc00000000000000 ! dece530 apply #fc7c7c7c7c7c7c7c -> #fc007c7c7c7c7c7c ! dece531 apply #fc00000000000000 -> -NaN ! dece532 apply #fd7d7d7d7d7d7d7d -> #fc017d7d7d7d7d7d ! dece533 apply #fd00000000000000 -> -NaN ! dece534 apply #fe7e7e7e7e7e7e7e -> #fe007e7e7e7e7c7e ! dece535 apply #fe00000000000000 -> -sNaN ! dece536 apply #ff7f7f7f7f7f7f7f -> #fe007f7f7f7f7c7f ! dece537 apply #ff00000000000000 -> -sNaN ! dece538 apply #ffffffffffffffff -> -sNaN999999999999999 ! dece539 apply #ffffffffffffffff -> #fe00ff3fcff3fcff ! ! -- diagnostic NaNs ! dece540 apply NaN -> #7c00000000000000 ! dece541 apply NaN0 -> #7c00000000000000 ! dece542 apply NaN1 -> #7c00000000000001 ! dece543 apply NaN12 -> #7c00000000000012 ! dece544 apply NaN79 -> #7c00000000000079 ! dece545 apply NaN12345 -> #7c000000000049c5 ! dece546 apply NaN123456 -> #7c00000000028e56 ! dece547 apply NaN799799 -> #7c000000000f7fdf ! dece548 apply NaN799799799799799 -> #7c03dff7fdff7fdf ! dece549 apply NaN999999999999999 -> #7c00ff3fcff3fcff ! dece550 apply NaN1234567890123456 -> #7c00000000000000 -- too many digits ! ! -- fold-down full sequence ! dece601 apply 1E+384 -> #47fc000000000000 Clamped ! dece602 apply #47fc000000000000 -> 1.000000000000000E+384 ! dece603 apply 1E+383 -> #43fc800000000000 Clamped ! dece604 apply #43fc800000000000 -> 1.00000000000000E+383 ! dece605 apply 1E+382 -> #43fc100000000000 Clamped ! dece606 apply #43fc100000000000 -> 1.0000000000000E+382 ! dece607 apply 1E+381 -> #43fc010000000000 Clamped ! dece608 apply #43fc010000000000 -> 1.000000000000E+381 ! dece609 apply 1E+380 -> #43fc002000000000 Clamped ! dece610 apply #43fc002000000000 -> 1.00000000000E+380 ! dece611 apply 1E+379 -> #43fc000400000000 Clamped ! dece612 apply #43fc000400000000 -> 1.0000000000E+379 ! dece613 apply 1E+378 -> #43fc000040000000 Clamped ! dece614 apply #43fc000040000000 -> 1.000000000E+378 ! dece615 apply 1E+377 -> #43fc000008000000 Clamped ! dece616 apply #43fc000008000000 -> 1.00000000E+377 ! dece617 apply 1E+376 -> #43fc000001000000 Clamped ! dece618 apply #43fc000001000000 -> 1.0000000E+376 ! dece619 apply 1E+375 -> #43fc000000100000 Clamped ! dece620 apply #43fc000000100000 -> 1.000000E+375 ! dece621 apply 1E+374 -> #43fc000000020000 Clamped ! dece622 apply #43fc000000020000 -> 1.00000E+374 ! dece623 apply 1E+373 -> #43fc000000004000 Clamped ! dece624 apply #43fc000000004000 -> 1.0000E+373 ! dece625 apply 1E+372 -> #43fc000000000400 Clamped ! dece626 apply #43fc000000000400 -> 1.000E+372 ! dece627 apply 1E+371 -> #43fc000000000080 Clamped ! dece628 apply #43fc000000000080 -> 1.00E+371 ! dece629 apply 1E+370 -> #43fc000000000010 Clamped ! dece630 apply #43fc000000000010 -> 1.0E+370 ! dece631 apply 1E+369 -> #43fc000000000001 ! dece632 apply #43fc000000000001 -> 1E+369 ! dece633 apply 1E+368 -> #43f8000000000001 ! dece634 apply #43f8000000000001 -> 1E+368 ! -- same with 9s ! dece641 apply 9E+384 -> #77fc000000000000 Clamped ! dece642 apply #77fc000000000000 -> 9.000000000000000E+384 ! dece643 apply 9E+383 -> #43fc8c0000000000 Clamped ! dece644 apply #43fc8c0000000000 -> 9.00000000000000E+383 ! dece645 apply 9E+382 -> #43fc1a0000000000 Clamped ! dece646 apply #43fc1a0000000000 -> 9.0000000000000E+382 ! dece647 apply 9E+381 -> #43fc090000000000 Clamped ! dece648 apply #43fc090000000000 -> 9.000000000000E+381 ! dece649 apply 9E+380 -> #43fc002300000000 Clamped ! dece650 apply #43fc002300000000 -> 9.00000000000E+380 ! dece651 apply 9E+379 -> #43fc000680000000 Clamped ! dece652 apply #43fc000680000000 -> 9.0000000000E+379 ! dece653 apply 9E+378 -> #43fc000240000000 Clamped ! dece654 apply #43fc000240000000 -> 9.000000000E+378 ! dece655 apply 9E+377 -> #43fc000008c00000 Clamped ! dece656 apply #43fc000008c00000 -> 9.00000000E+377 ! dece657 apply 9E+376 -> #43fc000001a00000 Clamped ! dece658 apply #43fc000001a00000 -> 9.0000000E+376 ! dece659 apply 9E+375 -> #43fc000000900000 Clamped ! dece660 apply #43fc000000900000 -> 9.000000E+375 ! dece661 apply 9E+374 -> #43fc000000023000 Clamped ! dece662 apply #43fc000000023000 -> 9.00000E+374 ! dece663 apply 9E+373 -> #43fc000000006800 Clamped ! dece664 apply #43fc000000006800 -> 9.0000E+373 ! dece665 apply 9E+372 -> #43fc000000002400 Clamped ! dece666 apply #43fc000000002400 -> 9.000E+372 ! dece667 apply 9E+371 -> #43fc00000000008c Clamped ! dece668 apply #43fc00000000008c -> 9.00E+371 ! dece669 apply 9E+370 -> #43fc00000000001a Clamped ! dece670 apply #43fc00000000001a -> 9.0E+370 ! dece671 apply 9E+369 -> #43fc000000000009 ! dece672 apply #43fc000000000009 -> 9E+369 ! dece673 apply 9E+368 -> #43f8000000000009 ! dece674 apply #43f8000000000009 -> 9E+368 ! ! ! -- Selected DPD codes ! dece700 apply #2238000000000000 -> 0 ! dece701 apply #2238000000000009 -> 9 ! dece702 apply #2238000000000010 -> 10 ! dece703 apply #2238000000000019 -> 19 ! dece704 apply #2238000000000020 -> 20 ! dece705 apply #2238000000000029 -> 29 ! dece706 apply #2238000000000030 -> 30 ! dece707 apply #2238000000000039 -> 39 ! dece708 apply #2238000000000040 -> 40 ! dece709 apply #2238000000000049 -> 49 ! dece710 apply #2238000000000050 -> 50 ! dece711 apply #2238000000000059 -> 59 ! dece712 apply #2238000000000060 -> 60 ! dece713 apply #2238000000000069 -> 69 ! dece714 apply #2238000000000070 -> 70 ! dece715 apply #2238000000000071 -> 71 ! dece716 apply #2238000000000072 -> 72 ! dece717 apply #2238000000000073 -> 73 ! dece718 apply #2238000000000074 -> 74 ! dece719 apply #2238000000000075 -> 75 ! dece720 apply #2238000000000076 -> 76 ! dece721 apply #2238000000000077 -> 77 ! dece722 apply #2238000000000078 -> 78 ! dece723 apply #2238000000000079 -> 79 ! ! dece730 apply #223800000000029e -> 994 ! dece731 apply #223800000000029f -> 995 ! dece732 apply #22380000000002a0 -> 520 ! dece733 apply #22380000000002a1 -> 521 ! ! -- DPD: one of each of the huffman groups ! dece740 apply #22380000000003f7 -> 777 ! dece741 apply #22380000000003f8 -> 778 ! dece742 apply #22380000000003eb -> 787 ! dece743 apply #223800000000037d -> 877 ! dece744 apply #223800000000039f -> 997 ! dece745 apply #22380000000003bf -> 979 ! dece746 apply #22380000000003df -> 799 ! dece747 apply #223800000000006e -> 888 ! ! ! -- DPD all-highs cases (includes the 24 redundant codes) ! dece750 apply #223800000000006e -> 888 ! dece751 apply #223800000000016e -> 888 ! dece752 apply #223800000000026e -> 888 ! dece753 apply #223800000000036e -> 888 ! dece754 apply #223800000000006f -> 889 ! dece755 apply #223800000000016f -> 889 ! dece756 apply #223800000000026f -> 889 ! dece757 apply #223800000000036f -> 889 ! ! dece760 apply #223800000000007e -> 898 ! dece761 apply #223800000000017e -> 898 ! dece762 apply #223800000000027e -> 898 ! dece763 apply #223800000000037e -> 898 ! dece764 apply #223800000000007f -> 899 ! dece765 apply #223800000000017f -> 899 ! dece766 apply #223800000000027f -> 899 ! dece767 apply #223800000000037f -> 899 ! ! dece770 apply #22380000000000ee -> 988 ! dece771 apply #22380000000001ee -> 988 ! dece772 apply #22380000000002ee -> 988 ! dece773 apply #22380000000003ee -> 988 ! dece774 apply #22380000000000ef -> 989 ! dece775 apply #22380000000001ef -> 989 ! dece776 apply #22380000000002ef -> 989 ! dece777 apply #22380000000003ef -> 989 ! ! dece780 apply #22380000000000fe -> 998 ! dece781 apply #22380000000001fe -> 998 ! dece782 apply #22380000000002fe -> 998 ! dece783 apply #22380000000003fe -> 998 ! dece784 apply #22380000000000ff -> 999 ! dece785 apply #22380000000001ff -> 999 ! dece786 apply #22380000000002ff -> 999 ! dece787 apply #22380000000003ff -> 999 ! Index: divide.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/divide.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** divide.decTest 1 Jul 2004 11:01:32 -0000 1.1 --- divide.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 extended: 1 --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 extended: 1 Index: divideint.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/divideint.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** divideint.decTest 1 Jul 2004 11:01:32 -0000 1.1 --- divideint.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 extended: 1 --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 extended: 1 Index: inexact.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/inexact.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** inexact.decTest 1 Jul 2004 11:01:32 -0000 1.1 --- inexact.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 extended: 1 --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 extended: 1 Index: max.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/max.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** max.decTest 1 Jul 2004 11:01:33 -0000 1.1 --- max.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 -- we assume that base comparison is tested in compare.decTest, so --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 -- we assume that base comparison is tested in compare.decTest, so *************** *** 61,82 **** maxx032 max 0 -0.0 -> 0 maxx033 max 0 0.0 -> 0 ! maxx034 max -0 0 -> -0 -- note: -0 = 0 maxx035 max -0 -0 -> -0 ! maxx036 max -0 -0.0 -> -0 ! maxx037 max -0 0.0 -> -0 ! maxx038 max 0.0 0 -> 0.0 maxx039 max 0.0 -0 -> 0.0 maxx040 max 0.0 -0.0 -> 0.0 maxx041 max 0.0 0.0 -> 0.0 ! maxx042 max -0.0 0 -> -0.0 maxx043 max -0.0 -0 -> -0.0 maxx044 max -0.0 -0.0 -> -0.0 ! maxx045 max -0.0 0.0 -> -0.0 ! maxx046 max -0E1 0E2 -> -0E+1 ! maxx047 max 0E2 0E1 -> 0E+2 ! maxx048 max 0E1 0E2 -> 0E+1 ! maxx049 max -0E3 -0E2 -> -0E+3 -- Specials --- 61,94 ---- maxx032 max 0 -0.0 -> 0 maxx033 max 0 0.0 -> 0 ! maxx034 max -0 0 -> 0 -- note: -0 = 0, but 0 chosen maxx035 max -0 -0 -> -0 ! maxx036 max -0 -0.0 -> -0.0 ! maxx037 max -0 0.0 -> 0.0 ! maxx038 max 0.0 0 -> 0 maxx039 max 0.0 -0 -> 0.0 maxx040 max 0.0 -0.0 -> 0.0 maxx041 max 0.0 0.0 -> 0.0 ! maxx042 max -0.0 0 -> 0 maxx043 max -0.0 -0 -> -0.0 maxx044 max -0.0 -0.0 -> -0.0 ! maxx045 max -0.0 0.0 -> 0.0 ! maxx050 max -0E1 0E1 -> 0E+1 ! maxx051 max -0E2 0E2 -> 0E+2 ! maxx052 max -0E2 0E1 -> 0E+1 ! maxx053 max -0E1 0E2 -> 0E+2 ! maxx054 max 0E1 -0E1 -> 0E+1 ! maxx055 max 0E2 -0E2 -> 0E+2 ! maxx056 max 0E2 -0E1 -> 0E+2 ! maxx057 max 0E1 -0E2 -> 0E+1 + maxx058 max 0E1 0E1 -> 0E+1 + maxx059 max 0E2 0E2 -> 0E+2 + maxx060 max 0E2 0E1 -> 0E+2 + maxx061 max 0E1 0E2 -> 0E+2 + maxx062 max -0E1 -0E1 -> -0E+1 + maxx063 max -0E2 -0E2 -> -0E+2 + maxx064 max -0E2 -0E1 -> -0E+1 + maxx065 max -0E1 -0E2 -> -0E+1 -- Specials *************** *** 116,136 **** maxx135 max Inf -Inf -> Infinity ! maxx141 max NaN -Inf -> NaN ! maxx142 max NaN -1000 -> NaN ! maxx143 max NaN -1 -> NaN ! maxx144 max NaN -0 -> NaN ! maxx145 max NaN 0 -> NaN ! maxx146 max NaN 1 -> NaN ! maxx147 max NaN 1000 -> NaN ! maxx148 max NaN Inf -> NaN maxx149 max NaN NaN -> NaN ! maxx150 max -Inf NaN -> NaN ! maxx151 max -1000 NaN -> NaN ! maxx152 max -1 NaN -> NaN ! maxx153 max -0 NaN -> NaN ! maxx154 max 0 NaN -> NaN ! maxx155 max 1 NaN -> NaN ! maxx156 max 1000 NaN -> NaN ! maxx157 max Inf NaN -> NaN maxx161 max sNaN -Inf -> NaN Invalid_operation --- 128,149 ---- maxx135 max Inf -Inf -> Infinity ! -- 2004.08.02 754r chooses number over NaN in mixed cases ! maxx141 max NaN -Inf -> -Infinity ! maxx142 max NaN -1000 -> -1000 ! maxx143 max NaN -1 -> -1 ! maxx144 max NaN -0 -> -0 ! maxx145 max NaN 0 -> 0 ! maxx146 max NaN 1 -> 1 ! maxx147 max NaN 1000 -> 1000 ! maxx148 max NaN Inf -> Infinity maxx149 max NaN NaN -> NaN ! maxx150 max -Inf NaN -> -Infinity ! maxx151 max -1000 NaN -> -1000 ! maxx152 max -1 NaN -> -1 ! maxx153 max -0 NaN -> -0 ! maxx154 max 0 NaN -> 0 ! maxx155 max 1 NaN -> 1 ! maxx156 max 1000 NaN -> 1000 ! maxx157 max Inf NaN -> Infinity maxx161 max sNaN -Inf -> NaN Invalid_operation *************** *** 155,165 **** -- propagating NaNs ! maxx181 max NaN9 -Inf -> NaN9 ! maxx182 max NaN8 9 -> NaN8 ! maxx183 max -NaN7 Inf -> -NaN7 ! maxx184 max NaN6 NaN5 -> NaN6 ! maxx185 max -Inf NaN4 -> NaN4 ! maxx186 max -9 -NaN3 -> -NaN3 ! maxx187 max Inf NaN2 -> NaN2 maxx191 max sNaN99 -Inf -> NaN99 Invalid_operation --- 168,183 ---- -- propagating NaNs ! maxx181 max NaN9 -Inf -> -Infinity ! maxx182 max NaN8 9 -> 9 ! maxx183 max -NaN7 Inf -> Infinity ! ! maxx184 max -NaN1 NaN11 -> -NaN1 ! maxx185 max NaN2 NaN12 -> NaN2 ! maxx186 max -NaN13 -NaN7 -> -NaN13 ! maxx187 max NaN14 -NaN5 -> NaN14 ! ! maxx188 max -Inf NaN4 -> -Infinity ! maxx189 max -9 -NaN3 -> -9 ! maxx190 max Inf NaN2 -> Infinity maxx191 max sNaN99 -Inf -> NaN99 Invalid_operation *************** *** 219,224 **** maxx280 max '3' '2' -> '3' maxx281 max '-10' '3' -> '3' ! maxx282 max '1.0' '1' -> '1.0' maxx283 max '1' '1.0' -> '1' -- overflow and underflow tests ... --- 237,243 ---- maxx280 max '3' '2' -> '3' maxx281 max '-10' '3' -> '3' ! maxx282 max '1.0' '1' -> '1' maxx283 max '1' '1.0' -> '1' + maxx284 max '7' 'NaN' -> '7' -- overflow and underflow tests ... *************** *** 256,259 **** --- 275,335 ---- maxx358 max -1e-777777777 -1e-411111111 -> -1E-777777777 + -- expanded list from min/max 754r purple prose + -- [explicit tests for exponent ordering] + maxx401 max Inf 1.1 -> Infinity + maxx402 max 1.1 1 -> 1.1 + maxx403 max 1 1.0 -> 1 + maxx404 max 1.0 0.1 -> 1.0 + maxx405 max 0.1 0.10 -> 0.1 + maxx406 max 0.10 0.100 -> 0.10 + maxx407 max 0.10 0 -> 0.10 + maxx408 max 0 0.0 -> 0 + maxx409 max 0.0 -0 -> 0.0 + maxx410 max 0.0 -0.0 -> 0.0 + maxx411 max 0.00 -0.0 -> 0.00 + maxx412 max 0.0 -0.00 -> 0.0 + maxx413 max 0 -0.0 -> 0 + maxx414 max 0 -0 -> 0 + maxx415 max -0.0 -0 -> -0.0 + maxx416 max -0 -0.100 -> -0 + maxx417 max -0.100 -0.10 -> -0.100 + maxx418 max -0.10 -0.1 -> -0.10 + maxx419 max -0.1 -1.0 -> -0.1 + maxx420 max -1.0 -1 -> -1.0 + maxx421 max -1 -1.1 -> -1 + maxx423 max -1.1 -Inf -> -1.1 + -- same with operands reversed + maxx431 max 1.1 Inf -> Infinity + maxx432 max 1 1.1 -> 1.1 + maxx433 max 1.0 1 -> 1 + maxx434 max 0.1 1.0 -> 1.0 + maxx435 max 0.10 0.1 -> 0.1 + maxx436 max 0.100 0.10 -> 0.10 + maxx437 max 0 0.10 -> 0.10 + maxx438 max 0.0 0 -> 0 + maxx439 max -0 0.0 -> 0.0 + maxx440 max -0.0 0.0 -> 0.0 + maxx441 max -0.0 0.00 -> 0.00 + maxx442 max -0.00 0.0 -> 0.0 + maxx443 max -0.0 0 -> 0 + maxx444 max -0 0 -> 0 + maxx445 max -0 -0.0 -> -0.0 + maxx446 max -0.100 -0 -> -0 + maxx447 max -0.10 -0.100 -> -0.100 + maxx448 max -0.1 -0.10 -> -0.10 + maxx449 max -1.0 -0.1 -> -0.1 + maxx450 max -1 -1.0 -> -1.0 + maxx451 max -1.1 -1 -> -1 + maxx453 max -Inf -1.1 -> -1.1 + -- largies + maxx460 max 1000 1E+3 -> 1E+3 + maxx461 max 1E+3 1000 -> 1E+3 + maxx462 max 1000 -1E+3 -> 1000 + maxx463 max 1E+3 -1000 -> 1E+3 + maxx464 max -1000 1E+3 -> 1E+3 + maxx465 max -1E+3 1000 -> 1000 + maxx466 max -1000 -1E+3 -> -1000 + maxx467 max -1E+3 -1000 -> -1000 + -- overflow tests *************** *** 261,266 **** minexponent: -999999999 precision: 3 ! maxx400 max 9.999E+999999999 0 -> Infinity Inexact Overflow Rounded ! maxx401 max -9.999E+999999999 0 -> 0 -- subnormals and underflow --- 337,342 ---- minexponent: -999999999 precision: 3 ! maxx500 max 9.999E+999999999 0 -> Infinity Inexact Overflow Rounded ! maxx501 max -9.999E+999999999 0 -> 0 -- subnormals and underflow *************** *** 268,295 **** maxexponent: 999 minexponent: -999 ! maxx410 max 1.00E-999 0 -> 1.00E-999 ! maxx411 max 0.1E-999 0 -> 1E-1000 Subnormal ! maxx412 max 0.10E-999 0 -> 1.0E-1000 Subnormal ! maxx413 max 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded ! maxx414 max 0.01E-999 0 -> 1E-1001 Subnormal -- next is rounded to Emin ! maxx415 max 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow ! maxx416 max 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow ! maxx417 max 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow ! maxx418 max 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow ! maxx419 max 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow ! maxx420 max 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow ! maxx430 max -1.00E-999 0 -> 0 ! maxx431 max -0.1E-999 0 -> 0 ! maxx432 max -0.10E-999 0 -> 0 ! maxx433 max -0.100E-999 0 -> 0 ! maxx434 max -0.01E-999 0 -> 0 ! maxx435 max -0.999E-999 0 -> 0 ! maxx436 max -0.099E-999 0 -> 0 ! maxx437 max -0.009E-999 0 -> 0 ! maxx438 max -0.001E-999 0 -> 0 ! maxx439 max -0.0009E-999 0 -> 0 ! maxx440 max -0.0001E-999 0 -> 0 -- Null tests --- 344,371 ---- maxexponent: 999 minexponent: -999 ! maxx510 max 1.00E-999 0 -> 1.00E-999 ! maxx511 max 0.1E-999 0 -> 1E-1000 Subnormal ! maxx512 max 0.10E-999 0 -> 1.0E-1000 Subnormal ! maxx513 max 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded ! maxx514 max 0.01E-999 0 -> 1E-1001 Subnormal -- next is rounded to Emin ! maxx515 max 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow ! maxx516 max 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow ! maxx517 max 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow ! maxx518 max 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow ! maxx519 max 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow ! maxx520 max 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow ! maxx530 max -1.00E-999 0 -> 0 ! maxx531 max -0.1E-999 0 -> 0 ! maxx532 max -0.10E-999 0 -> 0 ! maxx533 max -0.100E-999 0 -> 0 ! maxx534 max -0.01E-999 0 -> 0 ! maxx535 max -0.999E-999 0 -> 0 ! maxx536 max -0.099E-999 0 -> 0 ! maxx537 max -0.009E-999 0 -> 0 ! maxx538 max -0.001E-999 0 -> 0 ! maxx539 max -0.0009E-999 0 -> 0 ! maxx540 max -0.0001E-999 0 -> 0 -- Null tests Index: min.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/min.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** min.decTest 1 Jul 2004 11:01:33 -0000 1.1 --- min.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 -- we assume that base comparison is tested in compare.decTest, so --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 -- we assume that base comparison is tested in compare.decTest, so *************** *** 58,64 **** -- extended zeros mnmx030 min 0 0 -> 0 ! mnmx031 min 0 -0 -> 0 ! mnmx032 min 0 -0.0 -> 0 ! mnmx033 min 0 0.0 -> 0 mnmx034 min -0 0 -> -0 mnmx035 min -0 -0 -> -0 --- 58,64 ---- -- extended zeros mnmx030 min 0 0 -> 0 ! mnmx031 min 0 -0 -> -0 ! mnmx032 min 0 -0.0 -> -0.0 ! mnmx033 min 0 0.0 -> 0.0 mnmx034 min -0 0 -> -0 mnmx035 min -0 -0 -> -0 *************** *** 66,81 **** mnmx037 min -0 0.0 -> -0 mnmx038 min 0.0 0 -> 0.0 ! mnmx039 min 0.0 -0 -> 0.0 ! mnmx040 min 0.0 -0.0 -> 0.0 mnmx041 min 0.0 0.0 -> 0.0 mnmx042 min -0.0 0 -> -0.0 ! mnmx043 min -0.0 -0 -> -0.0 mnmx044 min -0.0 -0.0 -> -0.0 mnmx045 min -0.0 0.0 -> -0.0 ! mnmx046 min -0E1 0E2 -> -0E+1 ! mnmx047 min 0E2 0E1 -> 0E+2 ! mnmx048 min 0E1 0E2 -> 0E+1 ! mnmx049 min -0E3 -0E2 -> -0E+3 -- Specials --- 66,83 ---- mnmx037 min -0 0.0 -> -0 mnmx038 min 0.0 0 -> 0.0 ! mnmx039 min 0.0 -0 -> -0 ! mnmx040 min 0.0 -0.0 -> -0.0 mnmx041 min 0.0 0.0 -> 0.0 mnmx042 min -0.0 0 -> -0.0 ! mnmx043 min -0.0 -0 -> -0 mnmx044 min -0.0 -0.0 -> -0.0 mnmx045 min -0.0 0.0 -> -0.0 ! mnmx046 min 0E1 -0E1 -> -0E+1 ! mnmx047 min -0E1 0E2 -> -0E+1 ! mnmx048 min 0E2 0E1 -> 0E+1 ! mnmx049 min 0E1 0E2 -> 0E+1 ! mnmx050 min -0E3 -0E2 -> -0E+3 ! mnmx051 min -0E2 -0E3 -> -0E+3 -- Specials *************** *** 115,135 **** mnmx135 min Inf -Inf -> -Infinity ! mnmx141 min NaN -Inf -> NaN ! mnmx142 min NaN -1000 -> NaN ! mnmx143 min NaN -1 -> NaN ! mnmx144 min NaN -0 -> NaN ! mnmx145 min NaN 0 -> NaN ! mnmx146 min NaN 1 -> NaN ! mnmx147 min NaN 1000 -> NaN ! mnmx148 min NaN Inf -> NaN mnmx149 min NaN NaN -> NaN ! mnmx150 min -Inf NaN -> NaN ! mnmx151 min -1000 NaN -> NaN ! mnmx152 min -1 -NaN -> -NaN ! mnmx153 min -0 NaN -> NaN ! mnmx154 min 0 -NaN -> -NaN ! mnmx155 min 1 NaN -> NaN ! mnmx156 min 1000 NaN -> NaN ! mnmx157 min Inf NaN -> NaN mnmx161 min sNaN -Inf -> NaN Invalid_operation --- 117,138 ---- mnmx135 min Inf -Inf -> -Infinity ! -- 2004.08.02 754r chooses number over NaN in mixed cases ! mnmx141 min NaN -Inf -> -Infinity ! mnmx142 min NaN -1000 -> -1000 ! mnmx143 min NaN -1 -> -1 ! mnmx144 min NaN -0 -> -0 ! mnmx145 min NaN 0 -> 0 ! mnmx146 min NaN 1 -> 1 ! mnmx147 min NaN 1000 -> 1000 ! mnmx148 min NaN Inf -> Infinity mnmx149 min NaN NaN -> NaN ! mnmx150 min -Inf NaN -> -Infinity ! mnmx151 min -1000 NaN -> -1000 ! mnmx152 min -1 -NaN -> -1 ! mnmx153 min -0 NaN -> -0 ! mnmx154 min 0 -NaN -> 0 ! mnmx155 min 1 NaN -> 1 ! mnmx156 min 1000 NaN -> 1000 ! mnmx157 min Inf NaN -> Infinity mnmx161 min sNaN -Inf -> NaN Invalid_operation *************** *** 154,168 **** -- propagating NaNs ! mnmx181 min NaN9 -Inf -> NaN9 ! mnmx182 min -NaN8 9990 -> -NaN8 ! mnmx183 min NaN71 Inf -> NaN71 ! mnmx184 min NaN6 NaN51 -> NaN6 ! mnmx185 min -Inf NaN41 -> NaN41 ! mnmx186 min -9999 -NaN33 -> -NaN33 ! mnmx187 min Inf NaN2 -> NaN2 mnmx191 min sNaN99 -Inf -> NaN99 Invalid_operation mnmx192 min sNaN98 -11 -> NaN98 Invalid_operation ! mnmx193 min -sNaN97 NaN -> -NaN97 Invalid_operation mnmx194 min sNaN69 sNaN94 -> NaN69 Invalid_operation mnmx195 min NaN95 sNaN93 -> NaN93 Invalid_operation --- 157,176 ---- -- propagating NaNs ! mnmx181 min NaN9 -Inf -> -Infinity ! mnmx182 min -NaN8 9990 -> 9990 ! mnmx183 min NaN71 Inf -> Infinity ! ! mnmx184 min NaN1 NaN54 -> NaN1 ! mnmx185 min NaN22 -NaN53 -> NaN22 ! mnmx186 min -NaN3 NaN6 -> -NaN3 ! mnmx187 min -NaN44 NaN7 -> -NaN44 ! ! mnmx188 min -Inf NaN41 -> -Infinity ! mnmx189 min -9999 -NaN33 -> -9999 ! mnmx190 min Inf NaN2 -> Infinity mnmx191 min sNaN99 -Inf -> NaN99 Invalid_operation mnmx192 min sNaN98 -11 -> NaN98 Invalid_operation ! mnmx193 min -sNaN97 NaN8 -> -NaN97 Invalid_operation mnmx194 min sNaN69 sNaN94 -> NaN69 Invalid_operation mnmx195 min NaN95 sNaN93 -> NaN93 Invalid_operation *************** *** 219,223 **** mnmx281 min '-10' '3' -> '-10' mnmx282 min '1.0' '1' -> '1.0' ! mnmx283 min '1' '1.0' -> '1' -- overflow and underflow tests .. subnormal results [inputs] now allowed --- 227,232 ---- mnmx281 min '-10' '3' -> '-10' mnmx282 min '1.0' '1' -> '1.0' ! mnmx283 min '1' '1.0' -> '1.0' ! mnmx284 min '7' 'NaN' -> '7' -- overflow and underflow tests .. subnormal results [inputs] now allowed *************** *** 255,258 **** --- 264,324 ---- mnmx358 min +1e-777777777 +1e-411111111 -> 1E-777777777 + -- expanded list from min/max 754r purple prose + -- [explicit tests for exponent ordering] + mnmx401 min Inf 1.1 -> 1.1 + mnmx402 min 1.1 1 -> 1 + mnmx403 min 1 1.0 -> 1.0 + mnmx404 min 1.0 0.1 -> 0.1 + mnmx405 min 0.1 0.10 -> 0.10 + mnmx406 min 0.10 0.100 -> 0.100 + mnmx407 min 0.10 0 -> 0 + mnmx408 min 0 0.0 -> 0.0 + mnmx409 min 0.0 -0 -> -0 + mnmx410 min 0.0 -0.0 -> -0.0 + mnmx411 min 0.00 -0.0 -> -0.0 + mnmx412 min 0.0 -0.00 -> -0.00 + mnmx413 min 0 -0.0 -> -0.0 + mnmx414 min 0 -0 -> -0 + mnmx415 min -0.0 -0 -> -0 + mnmx416 min -0 -0.100 -> -0.100 + mnmx417 min -0.100 -0.10 -> -0.10 + mnmx418 min -0.10 -0.1 -> -0.1 + mnmx419 min -0.1 -1.0 -> -1.0 + mnmx420 min -1.0 -1 -> -1 + mnmx421 min -1 -1.1 -> -1.1 + mnmx423 min -1.1 -Inf -> -Infinity + -- same with operands reversed + mnmx431 min 1.1 Inf -> 1.1 + mnmx432 min 1 1.1 -> 1 + mnmx433 min 1.0 1 -> 1.0 + mnmx434 min 0.1 1.0 -> 0.1 + mnmx435 min 0.10 0.1 -> 0.10 + mnmx436 min 0.100 0.10 -> 0.100 + mnmx437 min 0 0.10 -> 0 + mnmx438 min 0.0 0 -> 0.0 + mnmx439 min -0 0.0 -> -0 + mnmx440 min -0.0 0.0 -> -0.0 + mnmx441 min -0.0 0.00 -> -0.0 + mnmx442 min -0.00 0.0 -> -0.00 + mnmx443 min -0.0 0 -> -0.0 + mnmx444 min -0 0 -> -0 + mnmx445 min -0 -0.0 -> -0 + mnmx446 min -0.100 -0 -> -0.100 + mnmx447 min -0.10 -0.100 -> -0.10 + mnmx448 min -0.1 -0.10 -> -0.1 + mnmx449 min -1.0 -0.1 -> -1.0 + mnmx450 min -1 -1.0 -> -1 + mnmx451 min -1.1 -1 -> -1.1 + mnmx453 min -Inf -1.1 -> -Infinity + -- largies + mnmx460 min 1000 1E+3 -> 1000 + mnmx461 min 1E+3 1000 -> 1000 + mnmx462 min 1000 -1E+3 -> -1E+3 + mnmx463 min 1E+3 -1000 -> -1000 + mnmx464 min -1000 1E+3 -> -1000 + mnmx465 min -1E+3 1000 -> -1E+3 + mnmx466 min -1000 -1E+3 -> -1E+3 + mnmx467 min -1E+3 -1000 -> -1E+3 + -- overflow tests *************** *** 260,265 **** minexponent: -999999999 precision: 3 ! mnmx400 min 9.999E+999999999 0 -> 0 ! mnmx401 min -9.999E+999999999 0 -> -Infinity Inexact Overflow Rounded -- subnormals and underflow --- 326,331 ---- minexponent: -999999999 precision: 3 ! mnmx500 min 9.999E+999999999 0 -> 0 ! mnmx501 min -9.999E+999999999 0 -> -Infinity Inexact Overflow Rounded -- subnormals and underflow *************** *** 267,294 **** maxexponent: 999 minexponent: -999 ! mnmx410 min 1.00E-999 0 -> 0 ! mnmx411 min 0.1E-999 0 -> 0 ! mnmx412 min 0.10E-999 0 -> 0 ! mnmx413 min 0.100E-999 0 -> 0 ! mnmx414 min 0.01E-999 0 -> 0 ! mnmx415 min 0.999E-999 0 -> 0 ! mnmx416 min 0.099E-999 0 -> 0 ! mnmx417 min 0.009E-999 0 -> 0 ! mnmx418 min 0.001E-999 0 -> 0 ! mnmx419 min 0.0009E-999 0 -> 0 ! mnmx420 min 0.0001E-999 0 -> 0 ! mnmx430 min -1.00E-999 0 -> -1.00E-999 ! mnmx431 min -0.1E-999 0 -> -1E-1000 Subnormal ! mnmx432 min -0.10E-999 0 -> -1.0E-1000 Subnormal ! mnmx433 min -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded ! mnmx434 min -0.01E-999 0 -> -1E-1001 Subnormal -- next is rounded to Emin ! mnmx435 min -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow ! mnmx436 min -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow ! mnmx437 min -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow ! mnmx438 min -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow ! mnmx439 min -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow ! mnmx440 min -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow --- 333,360 ---- maxexponent: 999 minexponent: -999 ! mnmx510 min 1.00E-999 0 -> 0 ! mnmx511 min 0.1E-999 0 -> 0 ! mnmx512 min 0.10E-999 0 -> 0 ! mnmx513 min 0.100E-999 0 -> 0 ! mnmx514 min 0.01E-999 0 -> 0 ! mnmx515 min 0.999E-999 0 -> 0 ! mnmx516 min 0.099E-999 0 -> 0 ! mnmx517 min 0.009E-999 0 -> 0 ! mnmx518 min 0.001E-999 0 -> 0 ! mnmx519 min 0.0009E-999 0 -> 0 ! mnmx520 min 0.0001E-999 0 -> 0 ! mnmx530 min -1.00E-999 0 -> -1.00E-999 ! mnmx531 min -0.1E-999 0 -> -1E-1000 Subnormal ! mnmx532 min -0.10E-999 0 -> -1.0E-1000 Subnormal ! mnmx533 min -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded ! mnmx534 min -0.01E-999 0 -> -1E-1001 Subnormal -- next is rounded to Emin ! mnmx535 min -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow ! mnmx536 min -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow ! mnmx537 min -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow ! mnmx538 min -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow ! mnmx539 min -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow ! mnmx540 min -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Index: minus.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/minus.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** minus.decTest 1 Jul 2004 11:01:33 -0000 1.1 --- minus.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 -- This set of tests primarily tests the existence of the operator. --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 -- This set of tests primarily tests the existence of the operator. Index: multiply.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/multiply.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** multiply.decTest 1 Jul 2004 11:01:33 -0000 1.1 --- multiply.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 extended: 1 --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 extended: 1 Index: normalize.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/normalize.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** normalize.decTest 1 Jul 2004 11:01:33 -0000 1.1 --- normalize.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 extended: 1 --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 extended: 1 Index: plus.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/plus.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** plus.decTest 1 Jul 2004 11:01:33 -0000 1.1 --- plus.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 -- This set of tests primarily tests the existence of the operator. --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 -- This set of tests primarily tests the existence of the operator. Index: power.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/power.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** power.decTest 1 Jul 2004 11:01:33 -0000 1.1 --- power.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 -- This set of testcases tests raising numbers to an integer power only. --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 -- This set of testcases tests raising numbers to an integer power only. Index: quantize.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/quantize.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** quantize.decTest 1 Jul 2004 11:01:33 -0000 1.1 --- quantize.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 -- Most of the tests here assume a "regular pattern", where the --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 -- Most of the tests here assume a "regular pattern", where the Index: randomBound32.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/randomBound32.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** randomBound32.decTest 1 Jul 2004 11:01:33 -0000 1.1 --- randomBound32.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 -- These testcases test calculations at precisions 31, 32, and 33, to --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 -- These testcases test calculations at precisions 31, 32, and 33, to Index: randoms.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/randoms.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** randoms.decTest 1 Jul 2004 11:01:34 -0000 1.1 --- randoms.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 extended: 1 --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 extended: 1 Index: remainder.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/remainder.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** remainder.decTest 1 Jul 2004 11:01:34 -0000 1.1 --- remainder.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 extended: 1 --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 extended: 1 Index: remainderNear.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/remainderNear.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** remainderNear.decTest 1 Jul 2004 11:01:34 -0000 1.1 --- remainderNear.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 extended: 1 --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 extended: 1 Index: rescale.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/rescale.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rescale.decTest 1 Jul 2004 11:01:34 -0000 1.1 --- rescale.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 1,756 **** ! ------------------------------------------------------------------------ ! -- rescale.decTest -- decimal rescale operation -- ! -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ! ------------------------------------------------------------------------ ! -- Please see the document "General Decimal Arithmetic Testcases" -- ! -- at http://www2.hursley.ibm.com/decimal for the description of -- ! -- these testcases. -- ! -- -- ! -- These testcases are experimental ('beta' versions), and they -- ! -- may contain errors. They are offered on an as-is basis. In -- [...1485 lines suppressed...] ! resx846 rescale 0 -1000000000 -> 0E-1000000000 ! resx847 rescale 0 -1000000001 -> 0E-1000000001 ! resx848 rescale 0 -1000000002 -> 0E-1000000002 ! resx849 rescale 0 -1000000003 -> 0E-1000000003 ! resx850 rescale 0 -1000000004 -> 0E-1000000004 ! resx851 rescale 0 -1000000005 -> 0E-1000000005 ! resx852 rescale 0 -1000000006 -> 0E-1000000006 ! resx853 rescale 0 -1000000007 -> 0E-1000000007 ! resx854 rescale 0 -1000000008 -> NaN Invalid_operation ! ! resx861 rescale 1 +2147483649 -> NaN Invalid_operation ! resx862 rescale 1 +2147483648 -> NaN Invalid_operation ! resx863 rescale 1 +2147483647 -> NaN Invalid_operation ! resx864 rescale 1 -2147483647 -> NaN Invalid_operation ! resx865 rescale 1 -2147483648 -> NaN Invalid_operation ! resx866 rescale 1 -2147483649 -> NaN Invalid_operation ! ! -- Null tests ! res900 rescale 10 # -> NaN Invalid_operation ! res901 rescale # 10 -> NaN Invalid_operation Index: rounding.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/rounding.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rounding.decTest 1 Jul 2004 11:01:34 -0000 1.1 --- rounding.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 -- These tests require that implementations take account of residues in --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 -- These tests require that implementations take account of residues in Index: samequantum.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/samequantum.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** samequantum.decTest 1 Jul 2004 11:01:34 -0000 1.1 --- samequantum.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 extended: 1 --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 extended: 1 Index: squareroot.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/squareroot.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** squareroot.decTest 1 Jul 2004 11:01:34 -0000 1.1 --- squareroot.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 extended: 1 --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 extended: 1 Index: subtract.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/subtract.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** subtract.decTest 1 Jul 2004 11:01:34 -0000 1.1 --- subtract.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 extended: 1 --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 extended: 1 Index: testall.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/testall.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testall.decTest 1 Jul 2004 11:01:34 -0000 1.1 --- testall.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 1,58 **** ! ------------------------------------------------------------------------ ! -- testall.decTest -- run all general decimal arithmetic testcases -- ! -- Copyright (c) IBM Corporation, 1981, 2003. All rights reserved. -- ! ------------------------------------------------------------------------ ! -- Please see the document "General Decimal Arithmetic Testcases" -- ! -- at http://www2.hursley.ibm.com/decimal for the description of -- ! -- these testcases. -- ! -- -- ! -- These testcases are experimental ('beta' versions), and they -- ! -- may contain errors. They are offered on an as-is basis. In -- ! -- particular, achieving the same results as the tests here is not -- ! -- a guarantee that an implementation complies with any Standard -- ! -- or specification. The tests are not exhaustive. -- ! -- -- ! -- Please send comments, suggestions, and corrections to the author: -- ! -- Mike Cowlishaw, IBM Fellow -- ! -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- ! -- mfc@uk.ibm.com -- ! ------------------------------------------------------------------------ ! version: 2.35 ! ! -- core tests (using Extended: 1) -------------------------------------- ! dectest: base ! dectest: abs ! dectest: add ! dectest: clamp ! dectest: compare ! dectest: divide ! dectest: divideint ! dectest: inexact ! dectest: max ! dectest: min ! dectest: minus ! dectest: multiply ! dectest: normalize ! dectest: plus ! dectest: power ! dectest: quantize ! dectest: randoms ! dectest: remainder ! dectest: remaindernear ! dectest: rescale -- [obsolete] ! dectest: rounding ! dectest: samequantum ! dectest: squareroot ! dectest: subtract ! dectest: tointegral ! dectest: trim ! ! -- The next are for the Strawman 4d concrete representations ! dectest: decimal32 ! dectest: decimal64 ! dectest: decimal128 ! ! ! -- General 31->33-digit boundary tests ! dectest: randomBound32 ! --- 1,58 ---- ! ------------------------------------------------------------------------ ! -- testall.decTest -- run all general decimal arithmetic testcases -- ! -- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. -- ! ------------------------------------------------------------------------ ! -- Please see the document "General Decimal Arithmetic Testcases" -- ! -- at http://www2.hursley.ibm.com/decimal for the description of -- ! -- these testcases. -- ! -- -- ! -- These testcases are experimental ('beta' versions), and they -- ! -- may contain errors. They are offered on an as-is basis. In -- ! -- particular, achieving the same results as the tests here is not -- ! -- a guarantee that an implementation complies with any Standard -- ! -- or specification. The tests are not exhaustive. -- ! -- -- ! -- Please send comments, suggestions, and corrections to the author: -- ! -- Mike Cowlishaw, IBM Fellow -- ! -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- ! -- mfc@uk.ibm.com -- ! ------------------------------------------------------------------------ ! version: 2.39 ! ! -- core tests (using Extended: 1) -------------------------------------- ! dectest: base ! dectest: abs ! dectest: add ! dectest: clamp ! dectest: compare ! dectest: divide ! dectest: divideint ! dectest: inexact ! dectest: max ! dectest: min ! dectest: minus ! dectest: multiply ! dectest: normalize ! dectest: plus ! dectest: power ! dectest: quantize ! dectest: randoms ! dectest: remainder ! dectest: remaindernear ! dectest: rescale -- [obsolete] ! dectest: rounding ! dectest: samequantum ! dectest: squareroot ! dectest: subtract ! dectest: tointegral ! dectest: trim ! ! -- The next are for the Strawman 4d concrete representations ! dectest: decimal32 ! dectest: decimal64 ! dectest: decimal128 ! ! ! -- General 31->33-digit boundary tests ! dectest: randombound32 ! Index: tointegral.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/tointegral.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tointegral.decTest 1 Jul 2004 11:01:34 -0000 1.1 --- tointegral.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 18,22 **** -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.38 -- This set of tests tests the extended specification 'round-to-integral --- 18,22 ---- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ ! version: 2.39 -- This set of tests tests the extended specification 'round-to-integral Index: trim.decTest =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/decimaltestdata/trim.decTest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** trim.decTest 1 Jul 2004 11:01:35 -0000 1.1 --- trim.decTest 17 Aug 2004 06:42:13 -0000 1.2 *************** *** 1,152 **** ! ------------------------------------------------------------------------ ! -- trim.decTest -- remove insignificant trailing zeros -- ! -- Copyright (c) IBM Corporation, 2003. All rights reserved. -- ! ------------------------------------------------------------------------ ! -- Please see the document "General Decimal Arithmetic Testcases" -- ! -- at http://www2.hursley.ibm.com/decimal for the description of -- ! -- these testcases. -- ! -- -- ! -- These testcases are experimental ('beta' versions), and they -- ! -- may contain errors. They are offered on an as-is basis. In -- ! -- particular, achieving the same results as the tests here is not -- ! -- a guarantee that an implementation complies with any Standard -- ! -- or specification. The tests are not exhaustive. -- ! -- -- ! -- Please send comments, suggestions, and corrections to the author: -- ! -- Mike Cowlishaw, IBM Fellow -- ! -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- ! -- mfc@uk.ibm.com -- ! ------------------------------------------------------------------------ ! version: 2.35 ! ! extended: 1 ! precision: 9 ! rounding: half_up ! maxExponent: 999 ! minexponent: -999 ! ! trmx001 trim '1' -> '1' ! trmx002 trim '-1' -> '-1' ! trmx003 trim '1.00' -> '1' ! trmx004 trim '-1.00' -> '-1' ! trmx005 trim '0' -> '0' ! trmx006 trim '0.00' -> '0' ! trmx007 trim '00.0' -> '0' ! trmx008 trim '00.00' -> '0' ! trmx009 trim '00' -> '0' ! ! trmx010 trim '-2' -> '-2' ! trmx011 trim '2' -> '2' ! trmx012 trim '-2.00' -> '-2' ! trmx013 trim '2.00' -> '2' ! trmx014 trim '-0' -> '-0' ! trmx015 trim '-0.00' -> '-0' ! trmx016 trim '-00.0' -> '-0' ! trmx017 trim '-00.00' -> '-0' ! trmx018 trim '-00' -> '-0' ! trmx019 trim '0E+5' -> '0' ! trmx020 trim '-0E+1' -> '-0' ! ! trmx030 trim '+0.1' -> '0.1' ! trmx031 trim '-0.1' -> '-0.1' ! trmx032 trim '+0.01' -> '0.01' ! trmx033 trim '-0.01' -> '-0.01' ! trmx034 trim '+0.001' -> '0.001' ! trmx035 trim '-0.001' -> '-0.001' ! trmx036 trim '+0.000001' -> '0.000001' ! trmx037 trim '-0.000001' -> '-0.000001' ! trmx038 trim '+0.000000000001' -> '1E-12' ! trmx039 trim '-0.000000000001' -> '-1E-12' ! ! trmx041 trim 1.1 -> 1.1 ! trmx042 trim 1.10 -> 1.1 ! trmx043 trim 1.100 -> 1.1 ! trmx044 trim 1.110 -> 1.11 ! trmx045 trim -1.1 -> -1.1 ! trmx046 trim -1.10 -> -1.1 ! trmx047 trim -1.100 -> -1.1 ! trmx048 trim -1.110 -> -1.11 ! trmx049 trim 9.9 -> 9.9 ! trmx050 trim 9.90 -> 9.9 ! trmx051 trim 9.900 -> 9.9 ! trmx052 trim 9.990 -> 9.99 ! trmx053 trim -9.9 -> -9.9 ! trmx054 trim -9.90 -> -9.9 ! trmx055 trim -9.900 -> -9.9 ! trmx056 trim -9.990 -> -9.99 ! ! -- some insignificant trailing fractional zeros ! trmx060 trim 10.0 -> 10 ! trmx061 trim 10.00 -> 10 ! trmx062 trim 100.0 -> 100 ! trmx063 trim 100.00 -> 100 ! trmx064 trim 1.1000E+3 -> 1100 ! trmx065 trim 1.10000E+3 -> 1100 ! trmx066 trim -10.0 -> -10 ! trmx067 trim -10.00 -> -10 ! trmx068 trim -100.0 -> -100 ! trmx069 trim -100.00 -> -100 ! trmx070 trim -1.1000E+3 -> -1100 ! trmx071 trim -1.10000E+3 -> -1100 ! ! -- some insignificant trailing zeros with positive exponent ! trmx080 trim 10E+1 -> 1E+2 ! trmx081 trim 100E+1 -> 1E+3 ! trmx082 trim 1.0E+2 -> 1E+2 ! trmx083 trim 1.0E+3 -> 1E+3 ! trmx084 trim 1.1E+3 -> 1.1E+3 ! trmx085 trim 1.00E+3 -> 1E+3 ! trmx086 trim 1.10E+3 -> 1.1E+3 ! trmx087 trim -10E+1 -> -1E+2 ! trmx088 trim -100E+1 -> -1E+3 ! trmx089 trim -1.0E+2 -> -1E+2 ! trmx090 trim -1.0E+3 -> -1E+3 ! trmx091 trim -1.1E+3 -> -1.1E+3 ! trmx092 trim -1.00E+3 -> -1E+3 ! trmx093 trim -1.10E+3 -> -1.1E+3 ! ! -- some significant trailing zeros ! trmx100 trim 11 -> 11 ! trmx101 trim 10 -> 10 ! trmx102 trim 10. -> 10 ! trmx103 trim 1.1E+1 -> 11 ! trmx104 trim 1.0E+1 -> 10 ! trmx105 trim 1.10E+2 -> 110 ! trmx106 trim 1.00E+2 -> 100 ! trmx107 trim 1.100E+3 -> 1100 ! trmx108 trim 1.000E+3 -> 1000 ! trmx109 trim 1.000000E+6 -> 1000000 ! trmx110 trim -11 -> -11 ! trmx111 trim -10 -> -10 ! trmx112 trim -10. -> -10 ! trmx113 trim -1.1E+1 -> -11 ! trmx114 trim -1.0E+1 -> -10 ! trmx115 trim -1.10E+2 -> -110 ! trmx116 trim -1.00E+2 -> -100 ! trmx117 trim -1.100E+3 -> -1100 ! trmx118 trim -1.000E+3 -> -1000 ! trmx119 trim -1.00000E+5 -> -100000 ! trmx120 trim -1.000000E+6 -> -1000000 ! ! -- examples from decArith ! trmx140 trim '2.1' -> '2.1' ! trmx141 trim '-2.0' -> '-2' ! trmx142 trim '1.200' -> '1.2' ! trmx143 trim '-120' -> '-120' ! trmx144 trim '120.00' -> '120' ! trmx145 trim '0.00' -> '0' ! ! -- utilities pass through specials without raising exceptions ! trmx320 trim 'Inf' -> 'Infinity' ! trmx321 trim '-Inf' -> '-Infinity' ! trmx322 trim NaN -> NaN ! trmx323 trim sNaN -> sNaN ! trmx324 trim NaN999 -> NaN999 ! trmx325 trim sNaN777 -> sNaN777 ! trmx326 trim -NaN -> -NaN ! trmx327 trim -sNaN -> -sNaN ! trmx328 trim -NaN999 -> -NaN999 ! trmx329 trim -sNaN777 -> -sNaN777 ! ! -- Null test ! trmx900 trim # -> NaN Invalid_operation --- 1,152 ---- ! ------------------------------------------------------------------------ ! -- trim.decTest -- remove insignificant trailing zeros -- ! -- Copyright (c) IBM Corporation, 2003. All rights reserved. -- ! ------------------------------------------------------------------------ ! -- Please see the document "General Decimal Arithmetic Testcases" -- ! -- at http://www2.hursley.ibm.com/decimal for the description of -- ! -- these testcases. -- ! -- -- ! -- These testcases are experimental ('beta' versions), and they -- ! -- may contain errors. They are offered on an as-is basis. In -- ! -- particular, achieving the same results as the tests here is not -- ! -- a guarantee that an implementation complies with any Standard -- ! -- or specification. The tests are not exhaustive. -- ! -- -- ! -- Please send comments, suggestions, and corrections to the author: -- ! -- Mike Cowlishaw, IBM Fellow -- ! -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- ! -- mfc@uk.ibm.com -- ! ------------------------------------------------------------------------ ! version: 2.39 ! ! extended: 1 ! precision: 9 ! rounding: half_up ! maxExponent: 999 ! minexponent: -999 ! ! trmx001 trim '1' -> '1' ! trmx002 trim '-1' -> '-1' ! trmx003 trim '1.00' -> '1' ! trmx004 trim '-1.00' -> '-1' ! trmx005 trim '0' -> '0' ! trmx006 trim '0.00' -> '0' ! trmx007 trim '00.0' -> '0' ! trmx008 trim '00.00' -> '0' ! trmx009 trim '00' -> '0' ! ! trmx010 trim '-2' -> '-2' ! trmx011 trim '2' -> '2' ! trmx012 trim '-2.00' -> '-2' ! trmx013 trim '2.00' -> '2' ! trmx014 trim '-0' -> '-0' ! trmx015 trim '-0.00' -> '-0' ! trmx016 trim '-00.0' -> '-0' ! trmx017 trim '-00.00' -> '-0' ! trmx018 trim '-00' -> '-0' ! trmx019 trim '0E+5' -> '0' ! trmx020 trim '-0E+1' -> '-0' ! ! trmx030 trim '+0.1' -> '0.1' ! trmx031 trim '-0.1' -> '-0.1' ! trmx032 trim '+0.01' -> '0.01' ! trmx033 trim '-0.01' -> '-0.01' ! trmx034 trim '+0.001' -> '0.001' ! trmx035 trim '-0.001' -> '-0.001' ! trmx036 trim '+0.000001' -> '0.000001' ! trmx037 trim '-0.000001' -> '-0.000001' ! trmx038 trim '+0.000000000001' -> '1E-12' ! trmx039 trim '-0.000000000001' -> '-1E-12' ! ! trmx041 trim 1.1 -> 1.1 ! trmx042 trim 1.10 -> 1.1 ! trmx043 trim 1.100 -> 1.1 ! trmx044 trim 1.110 -> 1.11 ! trmx045 trim -1.1 -> -1.1 ! trmx046 trim -1.10 -> -1.1 ! trmx047 trim -1.100 -> -1.1 ! trmx048 trim -1.110 -> -1.11 ! trmx049 trim 9.9 -> 9.9 ! trmx050 trim 9.90 -> 9.9 ! trmx051 trim 9.900 -> 9.9 ! trmx052 trim 9.990 -> 9.99 ! trmx053 trim -9.9 -> -9.9 ! trmx054 trim -9.90 -> -9.9 ! trmx055 trim -9.900 -> -9.9 ! trmx056 trim -9.990 -> -9.99 ! ! -- some insignificant trailing fractional zeros ! trmx060 trim 10.0 -> 10 ! trmx061 trim 10.00 -> 10 ! trmx062 trim 100.0 -> 100 ! trmx063 trim 100.00 -> 100 ! trmx064 trim 1.1000E+3 -> 1100 ! trmx065 trim 1.10000E+3 -> 1100 ! trmx066 trim -10.0 -> -10 ! trmx067 trim -10.00 -> -10 ! trmx068 trim -100.0 -> -100 ! trmx069 trim -100.00 -> -100 ! trmx070 trim -1.1000E+3 -> -1100 ! trmx071 trim -1.10000E+3 -> -1100 ! ! -- some insignificant trailing zeros with positive exponent ! trmx080 trim 10E+1 -> 1E+2 ! trmx081 trim 100E+1 -> 1E+3 ! trmx082 trim 1.0E+2 -> 1E+2 ! trmx083 trim 1.0E+3 -> 1E+3 ! trmx084 trim 1.1E+3 -> 1.1E+3 ! trmx085 trim 1.00E+3 -> 1E+3 ! trmx086 trim 1.10E+3 -> 1.1E+3 ! trmx087 trim -10E+1 -> -1E+2 ! trmx088 trim -100E+1 -> -1E+3 ! trmx089 trim -1.0E+2 -> -1E+2 ! trmx090 trim -1.0E+3 -> -1E+3 ! trmx091 trim -1.1E+3 -> -1.1E+3 ! trmx092 trim -1.00E+3 -> -1E+3 ! trmx093 trim -1.10E+3 -> -1.1E+3 ! ! -- some significant trailing zeros ! trmx100 trim 11 -> 11 ! trmx101 trim 10 -> 10 ! trmx102 trim 10. -> 10 ! trmx103 trim 1.1E+1 -> 11 ! trmx104 trim 1.0E+1 -> 10 ! trmx105 trim 1.10E+2 -> 110 ! trmx106 trim 1.00E+2 -> 100 ! trmx107 trim 1.100E+3 -> 1100 ! trmx108 trim 1.000E+3 -> 1000 ! trmx109 trim 1.000000E+6 -> 1000000 ! trmx110 trim -11 -> -11 ! trmx111 trim -10 -> -10 ! trmx112 trim -10. -> -10 ! trmx113 trim -1.1E+1 -> -11 ! trmx114 trim -1.0E+1 -> -10 ! trmx115 trim -1.10E+2 -> -110 ! trmx116 trim -1.00E+2 -> -100 ! trmx117 trim -1.100E+3 -> -1100 ! trmx118 trim -1.000E+3 -> -1000 ! trmx119 trim -1.00000E+5 -> -100000 ! trmx120 trim -1.000000E+6 -> -1000000 ! ! -- examples from decArith ! trmx140 trim '2.1' -> '2.1' ! trmx141 trim '-2.0' -> '-2' ! trmx142 trim '1.200' -> '1.2' ! trmx143 trim '-120' -> '-120' ! trmx144 trim '120.00' -> '120' ! trmx145 trim '0.00' -> '0' ! ! -- utilities pass through specials without raising exceptions ! trmx320 trim 'Inf' -> 'Infinity' ! trmx321 trim '-Inf' -> '-Infinity' ! trmx322 trim NaN -> NaN ! trmx323 trim sNaN -> sNaN ! trmx324 trim NaN999 -> NaN999 ! trmx325 trim sNaN777 -> sNaN777 ! trmx326 trim -NaN -> -NaN ! trmx327 trim -sNaN -> -sNaN ! trmx328 trim -NaN999 -> -NaN999 ! trmx329 trim -sNaN777 -> -sNaN777 ! ! -- Null test ! trmx900 trim # -> NaN Invalid_operation From rhettinger at users.sourceforge.net Tue Aug 17 08:56:46 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 17 08:56:50 2004 Subject: [Python-checkins] python/dist/src/Lib/test/decimaltestdata integer.decTest, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/decimaltestdata In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21676 Removed Files: integer.decTest Log Message: This file is no longer used in version 2.39. Was supplanted by tointegral.decTest. --- integer.decTest DELETED --- From rhettinger at users.sourceforge.net Tue Aug 17 10:01:59 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 17 10:02:03 2004 Subject: [Python-checkins] python/dist/src/Lib/idlelib config-keys.def, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31936 Modified Files: config-keys.def Log Message: SF bug #833957: Ctrl+key combos stop working in IDLE Make key combinations work with upper and lowercase as is the MS standard. Index: config-keys.def =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/config-keys.def,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** config-keys.def 24 Nov 2003 05:26:16 -0000 1.20 --- config-keys.def 17 Aug 2004 08:01:19 -0000 1.21 *************** *** 2,6 **** # file is the default config file for idle key binding settings. # Where multiple keys are specified for an action: if they are separated ! # by a space (eg. action= ) then the keys are altenatives, if # there is no space (eg. action=) then the keys comprise a # single 'emacs style' multi-keystoke binding. The tk event specifier 'Key' --- 2,6 ---- # file is the default config file for idle key binding settings. # Where multiple keys are specified for an action: if they are separated ! # by a space (eg. action= ) then the keys are alternatives, if # there is no space (eg. action=) then the keys comprise a # single 'emacs style' multi-keystoke binding. The tk event specifier 'Key' *************** *** 9,34 **** [IDLE Classic Windows] ! copy= ! cut= ! paste= beginning-of-line= ! center-insert= close-all-windows= close-window= do-nothing= ! end-of-file= python-docs= python-context-help= history-next= history-previous= ! interrupt-execution= view-restart= restart-shell= ! open-class-browser= ! open-module= ! open-new-window= ! open-window-from-file= ! plain-newline-and-indent= ! print-window= redo= remove-selection= --- 9,34 ---- [IDLE Classic Windows] ! copy= ! cut= ! paste= beginning-of-line= ! center-insert= close-all-windows= close-window= do-nothing= ! end-of-file= python-docs= python-context-help= history-next= history-previous= ! interrupt-execution= view-restart= restart-shell= ! open-class-browser= ! open-module= ! open-new-window= ! open-window-from-file= ! plain-newline-and-indent= ! print-window= redo= remove-selection= *************** *** 38,47 **** select-all= toggle-auto-coloring= ! undo= ! find= find-again= find-in-files= find-selection= ! replace= goto-line= smart-backspace= --- 38,47 ---- select-all= toggle-auto-coloring= ! undo= ! find= find-again= find-in-files= find-selection= ! replace= goto-line= smart-backspace= *************** *** 54,59 **** tabify-region= untabify-region= ! toggle-tabs= ! change-indentwidth= [IDLE Classic Unix] --- 54,59 ---- tabify-region= untabify-region= ! toggle-tabs= ! change-indentwidth= [IDLE Classic Unix] From theller at users.sourceforge.net Tue Aug 17 12:15:53 2004 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Tue Aug 17 12:16:01 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_wininst.py, 1.53, 1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20414 Modified Files: bdist_wininst.py Log Message: The get_installer_filename() method forgot to return the name it calculates. Spotted by Cort Danger Stratton. Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** bdist_wininst.py 23 Jul 2004 19:58:28 -0000 1.53 --- bdist_wininst.py 17 Aug 2004 10:15:07 -0000 1.54 *************** *** 284,287 **** --- 284,288 ---- installer_name = os.path.join(self.dist_dir, "%s.win32.exe" % fullname) + return installer_name # get_installer_filename() From loewis at users.sourceforge.net Tue Aug 17 13:52:04 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 17 13:52:09 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py, 1.28, 1.29 msilib.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3341 Modified Files: msi.py msilib.py Log Message: Add "run from source" option to all components. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** msi.py 16 Aug 2004 09:08:38 -0000 1.28 --- msi.py 17 Aug 2004 11:51:51 -0000 1.29 *************** *** 726,729 **** --- 726,737 ---- installer.FileVersion("msvcr71.dll", 1) + class PyDirectory(Directory): + """By default, all components in the Python installer + can run from source.""" + def __init__(self, *args, **kw): + if not kw.has_key("componentflags"): + kw['componentflags'] = 2 #msidbComponentAttributesOptional + Directory.__init__(self, *args, **kw) + # See "File Table", "Component Table", "Directory Table", # "FeatureComponents Table" *************** *** 732,736 **** tmpfiles = [] # Add all executables, icons, text files into the TARGETDIR component ! root = Directory(db, cab, None, srcdir, "TARGETDIR", "SourceDir") default_feature.set_current() root.add_file("PCBuild/w9xpopen.exe") --- 740,744 ---- tmpfiles = [] # Add all executables, icons, text files into the TARGETDIR component ! root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir") default_feature.set_current() root.add_file("PCBuild/w9xpopen.exe") *************** *** 746,750 **** # msidbComponentAttributesSharedDllRefCount = 8, see "Component Table" ! dlldir = Directory(db, cab, root, srcdir, "DLLDIR", ".") pydll = "python%s%s.dll" % (major, minor) pydllsrc = srcdir + "/PCBuild/" + pydll --- 754,758 ---- # msidbComponentAttributesSharedDllRefCount = 8, see "Component Table" ! dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".") pydll = "python%s%s.dll" % (major, minor) pydllsrc = srcdir + "/PCBuild/" + pydll *************** *** 779,783 **** else: default_feature.set_current() ! lib = Directory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir)) # Add additional files dirs[dir]=lib --- 787,791 ---- else: default_feature.set_current() ! lib = PyDirectory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir)) # Add additional files dirs[dir]=lib *************** *** 825,829 **** # Add DLLs default_feature.set_current() ! lib = Directory(db, cab, root, srcdir+"/PCBuild", "DLLs", "DLLS|DLLs") dlls = [] tclfiles = [] --- 833,837 ---- # Add DLLs default_feature.set_current() ! lib = PyDirectory(db, cab, root, srcdir+"/PCBuild", "DLLs", "DLLS|DLLs") dlls = [] tclfiles = [] *************** *** 853,861 **** # Add headers default_feature.set_current() ! lib = Directory(db, cab, root, "include", "include", "INCLUDE|include") lib.glob("*.h") lib.add_file("pyconfig.h", src="../PC/pyconfig.h") # Add import libraries ! lib = Directory(db, cab, root, "PCBuild", "libs", "LIBS|libs") for f in dlls: lib.add_file(f.replace('pyd','lib')) --- 861,869 ---- # Add headers default_feature.set_current() ! lib = PyDirectory(db, cab, root, "include", "include", "INCLUDE|include") lib.glob("*.h") lib.add_file("pyconfig.h", src="../PC/pyconfig.h") # Add import libraries ! lib = PyDirectory(db, cab, root, "PCBuild", "libs", "LIBS|libs") for f in dlls: lib.add_file(f.replace('pyd','lib')) *************** *** 866,870 **** while tcldirs: parent, phys, dir = tcldirs.pop() ! lib = Directory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir)) if not os.path.exists(lib.absolute): continue --- 874,878 ---- while tcldirs: parent, phys, dir = tcldirs.pop() ! lib = PyDirectory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir)) if not os.path.exists(lib.absolute): continue *************** *** 876,882 **** # Add tools tools.set_current() ! tooldir = Directory(db, cab, root, "Tools", "Tools", "TOOLS|Tools") for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker']: ! lib = Directory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f)) lib.glob("*.py") lib.glob("*.pyw", exclude=['pydocgui.pyw']) --- 884,890 ---- # Add tools tools.set_current() ! tooldir = PyDirectory(db, cab, root, "Tools", "Tools", "TOOLS|Tools") for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker']: ! lib = PyDirectory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f)) lib.glob("*.py") lib.glob("*.pyw", exclude=['pydocgui.pyw']) *************** *** 884,888 **** lib.glob("*.txt") if f == "pynche": ! x = Directory(db, cab, lib, "X", "X", "X|X") x.glob("*.txt") if f == 'Scripts': --- 892,896 ---- lib.glob("*.txt") if f == "pynche": ! x = PyDirectory(db, cab, lib, "X", "X", "X|X") x.glob("*.txt") if f == 'Scripts': *************** *** 892,896 **** # Add documentation htmlfiles.set_current() ! lib = Directory(db, cab, root, "Doc", "Doc", "DOC|Doc") lib.start_component("documentation", keyfile="Python%s%s.chm" % (major,minor)) lib.add_file("Python%s%s.chm" % (major, minor)) --- 900,904 ---- # Add documentation htmlfiles.set_current() ! lib = PyDirectory(db, cab, root, "Doc", "Doc", "DOC|Doc") lib.start_component("documentation", keyfile="Python%s%s.chm" % (major,minor)) lib.add_file("Python%s%s.chm" % (major, minor)) Index: msilib.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msilib.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** msilib.py 13 Aug 2004 15:25:28 -0000 1.11 --- msilib.py 17 Aug 2004 11:51:51 -0000 1.12 *************** *** 405,409 **** _directories = sets.Set() class Directory: ! def __init__(self, db, cab, basedir, physical, _logical, default): index = 1 _logical = make_id(_logical) --- 405,417 ---- _directories = sets.Set() class Directory: ! def __init__(self, db, cab, basedir, physical, _logical, default, componentflags=None): ! """Create a new directory in the Directory table. There is a current component ! at each point in time for the directory, which is either explicitly created ! through start_component, or implicitly when files are added for the first ! time. Files are added into the current component, and into the cab file. ! To create a directory, a base directory object needs to be specified (can be ! None), the path to the physical directory, and a logical directory name. ! Default specifies the DefaultDir slot in the directory table. componentflags ! specifies the default flags that new components get.""" index = 1 _logical = make_id(_logical) *************** *** 422,425 **** --- 430,434 ---- self.ids = sets.Set() self.keyfiles = {} + self.componentflags = componentflags if basedir: self.absolute = os.path.join(basedir.absolute, physical) *************** *** 430,434 **** add_data(db, "Directory", [(logical, blogical, default)]) ! def start_component(self, component = None, feature = None, flags = 0, keyfile = None): uuid = gen_uuid() if component is None: --- 439,450 ---- add_data(db, "Directory", [(logical, blogical, default)]) ! def start_component(self, component = None, feature = None, flags = None, keyfile = None): ! """Add an entry to the Component table, and make this component the current for this ! directory. If no component name is given, the directory name is used. If no feature ! is given, the current feature is used. If no flags are given, the directory's default ! flags are used. If no keyfile is given, the KeyPath is left null in the Component ! table.""" ! if flags is None: ! flags = self.componentflags uuid = gen_uuid() if component is None: *************** *** 482,485 **** --- 498,506 ---- 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 + 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.""" if not self.component: self.start_component(self.logical, current_feature) *************** *** 525,528 **** --- 546,551 ---- def glob(self, pattern, exclude = None): + """Add a list of files to the current component as specified in the + glob pattern. Individual files can be excluded in the exclude list.""" files = glob.glob1(self.absolute, pattern) for f in files: From loewis at users.sourceforge.net Tue Aug 17 14:56:30 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 17 14:56:38 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py, 1.29, 1.30 msilib.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14387 Modified Files: msi.py msilib.py Log Message: Conditionalize extension registration. Add support for "Change" installations. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** msi.py 17 Aug 2004 11:51:51 -0000 1.29 --- msi.py 17 Aug 2004 12:56:03 -0000 1.30 *************** *** 134,137 **** --- 134,140 ---- sys32cond = "(Windows9x or (Privileged and ALLUSERS))" + # Install extensions if the feature goes into + # INSTALLSTATE_ADVERTISED or INSTALLSTATE_LOCAL + want_extensions = "(&Extensions = 1) or (&Extensions = 3)" def build_database(): *************** *** 150,154 **** w64 = "" db = msilib.init_database("python-%s%s.msi" % (full_current_version, w64), ! schema, ProductName="Python "+full_current_version, ProductCode=product_code, ProductVersion=current_version, --- 153,157 ---- w64 = "" db = msilib.init_database("python-%s%s.msi" % (full_current_version, w64), ! schema, ProductName="Python "+full_current_version, ProductCode=product_code, ProductVersion=current_version, *************** *** 160,163 **** --- 163,175 ---- msilib.change_sequence(sequence.InstallExecuteSequence, "RemoveExistingProducts", 1510) + # Conditionalize Extension information + msilib.change_sequence(sequence.InstallExecuteSequence, + "RegisterClassInfo", cond=want_extensions) + msilib.change_sequence(sequence.InstallExecuteSequence, + "RegisterExtensionInfo", cond=want_extensions) + msilib.change_sequence(sequence.InstallExecuteSequence, + "RegisterProgIdInfo", cond=want_extensions) + msilib.change_sequence(sequence.InstallExecuteSequence, + "RegisterMIMEInfo", cond=want_extensions) msilib.add_tables(db, sequence) # We cannot set ALLUSERS in the property table, as this cannot be *************** *** 654,670 **** maint.text("BodyText", 135, 63, 230, 42, 3, "Select whether you want to repair or remove [ProductName].") ! g=maint.radiogroup("RepairRadioGroup", 135, 108, 230, 48, 3, "MaintenanceForm_Action", "", "Next") ! g.add("Repair", 0, 0, 200, 17, "&Repair [ProductName]") ! g.add("Remove", 0, 18, 200, 17, "Re&move [ProductName]") maint.back("< Back", None, active=False) c=maint.next("Finish", "Cancel") # Reinstall: Change progress dialog to "Repair", then invoke reinstall # Also set list of reinstalled features to "ALL" ! c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 1) ! c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 2) ! c.event("[Progress2]", "repaires", 'MaintenanceForm_Action="Repair"', 3) ! c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 4) # Uninstall: Change progress to "Remove", then invoke uninstall --- 666,688 ---- maint.text("BodyText", 135, 63, 230, 42, 3, "Select whether you want to repair or remove [ProductName].") ! g=maint.radiogroup("RepairRadioGroup", 135, 108, 230, 60, 3, "MaintenanceForm_Action", "", "Next") ! g.add("Change", 0, 0, 200, 17, "&Change [ProductName]") ! g.add("Repair", 0, 18, 200, 17, "&Repair [ProductName]") ! g.add("Remove", 0, 36, 200, 17, "Re&move [ProductName]") maint.back("< Back", None, active=False) c=maint.next("Finish", "Cancel") + # Change installation: Change progress dialog to "Change", then ask + # for feature selection + c.event("[Progress1]", "Change", 'MaintenanceForm_Action="Change"', 1) + c.event("[Progress2]", "changes", 'MaintenanceForm_Action="Change"', 2) + c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 3) # Reinstall: Change progress dialog to "Repair", then invoke reinstall # Also set list of reinstalled features to "ALL" ! c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 4) ! c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 5) ! c.event("[Progress2]", "repaires", 'MaintenanceForm_Action="Repair"', 6) ! c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 7) # Uninstall: Change progress to "Remove", then invoke uninstall *************** *** 923,931 **** ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", 4, "&%s <> 2" % ext_feature.id, "py.IDLE")]) ! # See "FeatureComponents Table" add_data(db, "FeatureComponents", [(default_feature.id, "REGISTRY"), (ext_feature.id, "REGISTRY.def"), ! (tcltk.id, "REGISTRY.tcl")]) pat = r"Software\Classes\%sPython.%sFile\shell\%s\command" --- 941,955 ---- ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", 4, "&%s <> 2" % ext_feature.id, "py.IDLE")]) ! # See "FeatureComponents Table". ! # The association between TclTk and pythonw.exe is necessary to make ICE59 ! # happy, because the installer otherwise believes that the IDLE and PyDoc ! # shortcuts might get installed without pythonw.exe being install. This ! # is not true, since installing TclTk will install the default feature, which ! # will cause pythonw.exe to be installed. add_data(db, "FeatureComponents", [(default_feature.id, "REGISTRY"), (ext_feature.id, "REGISTRY.def"), ! (tcltk.id, "REGISTRY.tcl"), ! (tcltk.id, "pythonw.exe")]) pat = r"Software\Classes\%sPython.%sFile\shell\%s\command" Index: msilib.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msilib.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** msilib.py 17 Aug 2004 11:51:51 -0000 1.12 --- msilib.py 17 Aug 2004 12:56:03 -0000 1.13 *************** *** 242,246 **** class _Unspecified:pass ! def change_sequence(seq, action, seqno, cond = _Unspecified): "Change the sequence number of an action in a sequence list" for i in range(len(seq)): --- 242,246 ---- class _Unspecified:pass ! def change_sequence(seq, action, seqno=_Unspecified, cond = _Unspecified): "Change the sequence number of an action in a sequence list" for i in range(len(seq)): *************** *** 248,251 **** --- 248,253 ---- if cond is _Unspecified: cond = seq[i][1] + if seqno is _Unspecified: + seqno = seq[i][2] seq[i] = (action, cond, seqno) return From loewis at users.sourceforge.net Tue Aug 17 15:00:20 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 17 15:00:28 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15153 Modified Files: msi.py Log Message: Add IDLE back into description of TclTk. Narrow width of size display. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** msi.py 17 Aug 2004 12:56:03 -0000 1.30 --- msi.py 17 Aug 2004 12:59:58 -0000 1.31 *************** *** 571,575 **** c.mapping("SelectionDescription","Text") ! c=features.text("ItemSize", 140, 210, 220, 45, 3, "The size of the currently selected item.") c.mapping("SelectionSize", "Text") --- 571,575 ---- c.mapping("SelectionDescription","Text") ! c=features.text("ItemSize", 140, 210, 210, 45, 3, "The size of the currently selected item.") c.mapping("SelectionSize", "Text") *************** *** 711,715 **** "Make this Python installation the default Python installation", 3, parent = default_feature) ! tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, pydoc", 5, parent = default_feature) htmlfiles = Feature(db, "Documentation", "Documentation", --- 711,715 ---- "Make this Python installation the default Python installation", 3, parent = default_feature) ! tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, IDLE, pydoc", 5, parent = default_feature) htmlfiles = Feature(db, "Documentation", "Documentation", From jlgijsbers at users.sourceforge.net Tue Aug 17 15:22:19 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Tue Aug 17 15:22:28 2004 Subject: [Python-checkins] python/dist/src/Lib pydoc.py,1.94,1.95 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19912 Modified Files: pydoc.py Log Message: Use readline/raw_input() in pydoc.Helper.interact if available and self.input is sys.stdin. Based on a patch (#726204) by Dmitry Vasiliev and a comment from Guido in an older patch (#549901). Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** pydoc.py 19 Jun 2004 01:22:48 -0000 1.94 --- pydoc.py 17 Aug 2004 13:21:53 -0000 1.95 *************** *** 1619,1632 **** self.output.write('\n') while True: - self.output.write('help> ') - self.output.flush() try: ! request = self.input.readline() if not request: break ! except KeyboardInterrupt: break request = strip(replace(request, '"', '', "'", '')) if lower(request) in ['q', 'quit']: break self.help(request) def help(self, request): if type(request) is type(''): --- 1619,1640 ---- self.output.write('\n') while True: try: ! request = self.getline('help> ') if not request: break ! except (KeyboardInterrupt, EOFError): ! break request = strip(replace(request, '"', '', "'", '')) if lower(request) in ['q', 'quit']: break self.help(request) + def getline(self, prompt): + """Read one line, using raw_input when available.""" + if self.input is sys.stdin: + return raw_input(prompt) + else: + self.output.write(prompt) + self.output.flush() + return self.input.readline() + def help(self, request): if type(request) is type(''): From loewis at users.sourceforge.net Tue Aug 17 15:47:06 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 17 15:47:14 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py, 1.31, 1.32 msilib.py, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24155 Modified Files: msi.py msilib.py Log Message: Fix maintenance form. Don't offer advertisement of test suite. Don't always follow parent. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** msi.py 17 Aug 2004 12:59:58 -0000 1.31 --- msi.py 17 Aug 2004 13:46:39 -0000 1.32 *************** *** 678,688 **** c.event("[Progress1]", "Change", 'MaintenanceForm_Action="Change"', 1) c.event("[Progress2]", "changes", 'MaintenanceForm_Action="Change"', 2) ! c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 3) # Reinstall: Change progress dialog to "Repair", then invoke reinstall # Also set list of reinstalled features to "ALL" ! c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 4) ! c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 5) ! c.event("[Progress2]", "repaires", 'MaintenanceForm_Action="Repair"', 6) ! c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 7) # Uninstall: Change progress to "Remove", then invoke uninstall --- 678,688 ---- c.event("[Progress1]", "Change", 'MaintenanceForm_Action="Change"', 1) c.event("[Progress2]", "changes", 'MaintenanceForm_Action="Change"', 2) ! # Reinstall: Change progress dialog to "Repair", then invoke reinstall # Also set list of reinstalled features to "ALL" ! c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 5) ! c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 6) ! c.event("[Progress2]", "repaires", 'MaintenanceForm_Action="Repair"', 7) ! c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 8) # Uninstall: Change progress to "Remove", then invoke uninstall *************** *** 694,698 **** # Close dialog when maintenance action scheduled ! c.event("EndDialog", "Return", order=20) maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg") --- 694,699 ---- # Close dialog when maintenance action scheduled ! c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20) ! c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21) maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg") *************** *** 704,724 **** # column. def add_features(db): global default_feature, tcltk, htmlfiles, tools, testsuite, ext_feature default_feature = Feature(db, "DefaultFeature", "Python", "Python Interpreter and Libraries", 1, directory = "TARGETDIR") ext_feature = Feature(db, "Extensions", "Register Extensions", "Make this Python installation the default Python installation", 3, parent = default_feature) tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, IDLE, pydoc", 5, ! parent = default_feature) htmlfiles = Feature(db, "Documentation", "Documentation", "Python HTMLHelp File", 7, parent = default_feature) tools = Feature(db, "Tools", "Utility Scripts", "Python utility scripts (Tools/", 9, ! parent = default_feature) testsuite = Feature(db, "Testsuite", "Test suite", "Python test suite (Lib/test/)", 11, ! parent = default_feature) --- 705,742 ---- # column. def add_features(db): + # feature attributes: + # msidbFeatureAttributesFollowParent == 2 + # msidbFeatureAttributesDisallowAdvertise == 8 + # Features that need to be installed with together with the main feature + # (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 default_feature = Feature(db, "DefaultFeature", "Python", "Python Interpreter and Libraries", 1, directory = "TARGETDIR") + # The extensions feature is tricky wrt. advertisement and follow parent. + # The following combinations must be supported: + # default feature extensions effect on extensions + # locally/from source locally/from source registered + # advertised advertised/locally/from source advertised + # locally/from source not installed not installed + # advertised not installed not advertised + # (only shortcuts are) + # The following combination might be considered meaningless, but cannot be excluded + # locally/from source advertised registered ext_feature = Feature(db, "Extensions", "Register Extensions", "Make this Python installation the default Python installation", 3, parent = default_feature) tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, IDLE, pydoc", 5, ! parent = default_feature, attributes=2) htmlfiles = Feature(db, "Documentation", "Documentation", "Python HTMLHelp File", 7, parent = default_feature) tools = Feature(db, "Tools", "Utility Scripts", "Python utility scripts (Tools/", 9, ! parent = default_feature, attributes=2) testsuite = Feature(db, "Testsuite", "Test suite", "Python test suite (Lib/test/)", 11, ! parent = default_feature, attributes=2|8) Index: msilib.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msilib.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** msilib.py 17 Aug 2004 12:56:03 -0000 1.13 --- msilib.py 17 Aug 2004 13:46:39 -0000 1.14 *************** *** 564,572 **** class Feature: def __init__(self, db, id, title, desc, display, level = 1, ! parent=None, directory = None): self.id = id - attributes = 0 if parent: - attributes |= 2 # follow parent parent = parent.id add_data(db, "Feature", --- 564,570 ---- class Feature: def __init__(self, db, id, title, desc, display, level = 1, ! parent=None, directory = None, attributes=0): self.id = id if parent: parent = parent.id add_data(db, "Feature", From barry at python.org Tue Aug 17 16:57:49 2004 From: barry at python.org (Barry Warsaw) Date: Tue Aug 17 16:57:25 2004 Subject: [Python-checkins] Notice: switching to unified diffs Message-ID: <1092754669.9168.19.camel@localhost> I'm posting this here only, because if you're not on this list, you don't care. :) This is a heads-up that we're going to switch the checkins diffs to unified format from the "context 2" diffs currently being sent. In general, unified diffs are more compact and easier to read. I plan to make the switch in the next day or two. I hope this will be acceptable to the majority of list members. If you want to discuss, please email me directly. complaints-are-next-door-it's-getting-hit-on-the-head-lessons-in-here-ly yr's, -Barry -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 307 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-checkins/attachments/20040817/d07a267d/attachment.pgp From loewis at users.sourceforge.net Tue Aug 17 17:39:36 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Aug 17 17:39:40 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py, 1.32, 1.33 msilib.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13137 Modified Files: msi.py msilib.py Log Message: Add Advanced dialog. Add option to COMPILEALL byte code. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** msi.py 17 Aug 2004 13:46:39 -0000 1.32 --- msi.py 17 Aug 2004 15:39:09 -0000 1.33 *************** *** 347,350 **** --- 347,354 ---- ("SetDLLDirToTarget", 307, "DLLDIR", "[TARGETDIR]"), ("SetDLLDirToSystem32", 307, "DLLDIR", SystemFolderName), + # msidbCustomActionTypeExe + msidbCustomActionTypeSourceFile + # See "Custom Action Type 18" + ("CompilePyc", 18, "python.exe", r"[TARGETDIR]Lib\compileall.py [TARGETDIR]Lib"), + ("CompilePyo", 18, "python.exe", r"-O [TARGETDIR]Lib\compileall.py [TARGETDIR]Lib") ]) *************** *** 373,380 **** --- 377,388 ---- ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751), ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752), + ("CompilePyc", "COMPILEALL", 6800), + ("CompilePyo", "COMPILEALL", 6801), ]) add_data(db, "AdminExecuteSequence", [("InitialTargetDir", 'TARGETDIR=""', 750), ("SetDLLDirToTarget", 'DLLDIR=""', 751), + ("CompilePyc", "COMPILEALL", 6800), + ("CompilePyo", "COMPILEALL", 6801), ]) *************** *** 567,570 **** --- 575,581 ---- c.event("SpawnDialog", "DiskCostDlg") + c=features.xbutton("Advanced", "Advanced", None, 0.30) + c.event("SpawnDialog", "AdvancedDlg") + c=features.text("ItemDescription", 140, 180, 210, 30, 3, "Multiline description of the currently selected item.") *************** *** 623,626 **** --- 634,652 ---- ##################################################################### + # Advanced Dialog. + advanced = PyDialog(db, "AdvancedDlg", x, y, w, h, modal, title, + "CompilePyc", "Next", "Cancel") + advanced.title("Advanced Options for [ProductName]") + # A radio group with two options: allusers, justme + advanced.checkbox("CompilePyc", 135, 60, 230, 50, 3, + "COMPILEALL", "Compile .py files to byte code after installation", "Next") + + c = advanced.next("Finish", "Cancel") + c.event("EndDialog", "Return") + + c = advanced.cancel("Cancel", "CompilePyc") + c.event("SpawnDialog", "CancelDlg") + + ##################################################################### # Existing Directory dialog dlg = Dialog(db, "ExistingDirectoryDlg", 50, 30, 200, 80, modal, title, Index: msilib.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msilib.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** msilib.py 17 Aug 2004 13:46:39 -0000 1.14 --- msilib.py 17 Aug 2004 15:39:09 -0000 1.15 *************** *** 637,638 **** --- 637,641 ---- x, y, w, h, attr, prop, text, next, None)]) return RadioButtonGroup(self, name, prop) + + def checkbox(self, name, x, y, w, h, attr, prop, text, next): + return self.control(name, "CheckBox", x, y, w, h, attr, prop, text, next, None) \ No newline at end of file From rhettinger at users.sourceforge.net Tue Aug 17 18:27:30 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 17 18:27:34 2004 Subject: [Python-checkins] python/dist/src/Lib/test/decimaltestdata trim.decTest, 1.2, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/decimaltestdata In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21615 Removed Files: trim.decTest Log Message: Remove test of obsolete trim() operation which was supplanted by normalize() in Draft 1.06 (9 October 2002): The normalize operation has been added; it reduces a number to a canonical form. (This replaces the trim operator, which only removed trailing fractional zeros.) --- trim.decTest DELETED --- From rhettinger at users.sourceforge.net Tue Aug 17 18:35:25 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 17 18:36:08 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py, 1.12, 1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23580 Modified Files: test_decimal.py Log Message: There are no longer any special case test skips. Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_decimal.py 17 Aug 2004 05:42:09 -0000 1.12 --- test_decimal.py 17 Aug 2004 16:34:51 -0000 1.13 *************** *** 299,305 **** if '.decTest' not in filename: continue - ## XXX buildout to include integer and trim - if 'integer' in filename or 'trim' in filename: - continue head, tail = filename.split('.') tester = lambda self, f=filename: self.eval_file(dir + f) --- 299,302 ---- From edloper at users.sourceforge.net Tue Aug 17 18:37:45 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Tue Aug 17 18:37:52 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24048/dist/src/Lib/test Modified Files: test_doctest.py Log Message: Fixed bug in line-number finding for examples (DocTestParser wasn't updating line numbers correctly for bare prompts & examples containing only comments). Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** test_doctest.py 12 Aug 2004 02:41:30 -0000 1.20 --- test_doctest.py 17 Aug 2004 16:37:12 -0000 1.21 *************** *** 254,258 **** """ - # [XX] test that it's getting line numbers right. def test_DocTestFinder(): r""" Unit tests for the `DocTestFinder` class. --- 254,257 ---- *************** *** 451,454 **** --- 450,477 ---- ... print '%2s %s' % (len(t.examples), t.name) 1 SampleClass + + Line numbers + ~~~~~~~~~~~~ + DocTestFinder finds the line number of each example: + + >>> def f(x): + ... ''' + ... >>> x = 12 + ... + ... some text + ... + ... >>> # examples are not created for comments & bare prompts. + ... >>> + ... ... + ... + ... >>> for x in range(10): + ... ... print x, + ... 0 1 2 3 4 5 6 7 8 9 + ... >>> x/2 + ... 6 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> [e.lineno for e in test.examples] + [1, 9, 12] """ *************** *** 893,897 **** ********************************************************************** Failure in example: print range(10) # doctest: -ELLIPSIS ! from line #6 of f Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] --- 916,920 ---- ********************************************************************** Failure in example: print range(10) # doctest: -ELLIPSIS ! from line #5 of f Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] From edloper at users.sourceforge.net Tue Aug 17 18:37:52 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Tue Aug 17 18:37:55 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.65,1.66 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24048/dist/src/Lib Modified Files: doctest.py Log Message: Fixed bug in line-number finding for examples (DocTestParser wasn't updating line numbers correctly for bare prompts & examples containing only comments). Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** doctest.py 13 Aug 2004 03:55:05 -0000 1.65 --- doctest.py 17 Aug 2004 16:37:12 -0000 1.66 *************** *** 553,562 **** # Extract extra options from the source. options = self._find_options(source, name, lineno) - # If it contains no real source, then ignore it. - if self._IS_BLANK_OR_COMMENT(source): - continue # Create an Example, and add it to the list. ! examples.append( Example(source, want, lineno, ! len(m.group('indent')), options) ) # Update lineno (lines inside this example) lineno += string.count('\n', m.start(), m.end()) --- 553,560 ---- # Extract extra options from the source. options = self._find_options(source, name, lineno) # Create an Example, and add it to the list. ! if not self._IS_BLANK_OR_COMMENT(source): ! examples.append( Example(source, want, lineno, ! len(m.group('indent')), options) ) # Update lineno (lines inside this example) lineno += string.count('\n', m.start(), m.end()) From mwh at users.sourceforge.net Tue Aug 17 19:29:28 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 17 19:29:32 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decorators.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1056/Lib/test Modified Files: test_decorators.py Log Message: This is Mark Russell's patch: [ 1009560 ] Fix @decorator evaluation order >From the description: Changes in this patch: - Change Grammar/Grammar to require newlines between adjacent decorators. - Fix order of evaluation of decorators in the C (compile.c) and python (Lib/compiler/pycodegen.py) compilers - Add better order of evaluation check to test_decorators.py (test_eval_order) - Update the decorator documentation in the reference manual (improve description of evaluation order and update syntax description) and the comment: Used Brett's evaluation order (see http://mail.python.org/pipermail/python-dev/2004-August/047835.html) (I'm checking this in for Anthony who was having problems getting SF to talk to him) Index: test_decorators.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decorators.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_decorators.py 15 Aug 2004 07:21:25 -0000 1.4 --- test_decorators.py 17 Aug 2004 17:29:15 -0000 1.5 *************** *** 41,52 **** "Decorator to count calls to a function" def decorate(func): ! name = func.func_name ! counts[name] = 0 def call(*args, **kwds): ! counts[name] += 1 return func(*args, **kwds) ! # XXX: Would like to say: call.func_name = func.func_name here ! # to make nested decorators work in any order, but func_name ! # is a readonly attribute return call return decorate --- 41,50 ---- "Decorator to count calls to a function" def decorate(func): ! func_name = func.func_name ! counts[func_name] = 0 def call(*args, **kwds): ! counts[func_name] += 1 return func(*args, **kwds) ! call.func_name = func_name return call return decorate *************** *** 66,69 **** --- 64,68 ---- # Unhashable argument return func(*args) + call.func_name = func.func_name return call *************** *** 127,137 **** def test_memoize(self): - # XXX: This doesn't work unless memoize is the last decorator - - # see the comment in countcalls. counts = {} @memoize @countcalls(counts) def double(x): return x * 2 self.assertEqual(counts, dict(double=0)) --- 126,136 ---- def test_memoize(self): counts = {} + @memoize @countcalls(counts) def double(x): return x * 2 + self.assertEqual(double.func_name, 'double') self.assertEqual(counts, dict(double=0)) *************** *** 163,166 **** --- 162,170 ---- self.assertRaises(SyntaxError, compile, codestr, "test", "exec") + # You can't put multiple decorators on a single line: + # + self.assertRaises(SyntaxError, compile, + "@f1 @f2\ndef f(): pass", "test", "exec") + # Test runtime errors *************** *** 188,205 **** def test_order(self): ! # Test that decorators are conceptually applied right-recursively; ! # that means bottom-up ! def ordercheck(num): ! def deco(func): ! return lambda: num ! return deco ! # Should go ordercheck(1)(ordercheck(2)(blah)) which should lead to ! # blah() == 1 ! @ordercheck(1) ! @ordercheck(2) ! def blah(): pass ! self.assertEqual(blah(), 1, "decorators are meant to be applied " ! "bottom-up") def test_main(): --- 192,263 ---- def test_order(self): ! class C(object): ! @staticmethod ! @funcattrs(abc=1) ! def foo(): return 42 ! # This wouldn't work if staticmethod was called first ! self.assertEqual(C.foo(), 42) ! self.assertEqual(C().foo(), 42) ! def test_eval_order(self): ! # Evaluating a decorated function involves four steps for each ! # decorator-maker (the function that returns a decorator): ! # ! # 1: Evaluate the decorator-maker name ! # 2: Evaluate the decorator-maker arguments (if any) ! # 3: Call the decorator-maker to make a decorator ! # 4: Call the decorator ! # ! # When there are multiple decorators, these steps should be ! # performed in the above order for each decorator, but we should ! # iterate through the decorators in the reverse of the order they ! # appear in the source. ! ! actions = [] ! ! def make_decorator(tag): ! actions.append('makedec' + tag) ! def decorate(func): ! actions.append('calldec' + tag) ! return func ! return decorate ! ! class NameLookupTracer (object): ! def __init__(self, index): ! self.index = index ! ! def __getattr__(self, fname): ! if fname == 'make_decorator': ! opname, res = ('evalname', make_decorator) ! elif fname == 'arg': ! opname, res = ('evalargs', str(self.index)) ! else: ! assert False, "Unknown attrname %s" % fname ! actions.append('%s%d' % (opname, self.index)) ! return res ! ! c1, c2, c3 = map(NameLookupTracer, [ 1, 2, 3 ]) ! ! expected_actions = [ 'evalname1', 'evalargs1', 'makedec1', ! 'evalname2', 'evalargs2', 'makedec2', ! 'evalname3', 'evalargs3', 'makedec3', ! 'calldec3', 'calldec2', 'calldec1' ] ! ! actions = [] ! @c1.make_decorator(c1.arg) ! @c2.make_decorator(c2.arg) ! @c3.make_decorator(c3.arg) ! def foo(): return 42 ! self.assertEqual(foo(), 42) ! ! self.assertEqual(actions, expected_actions) ! ! # Test the equivalence claim in chapter 7 of the reference manual. ! # ! actions = [] ! def bar(): return 42 ! bar = c1.make_decorator(c1.arg)(c2.make_decorator(c2.arg)(c3.make_decorator(c3.arg)(bar))) ! self.assertEqual(bar(), 42) ! self.assertEqual(actions, expected_actions) def test_main(): From mwh at users.sourceforge.net Tue Aug 17 19:29:32 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 17 19:29:36 2004 Subject: [Python-checkins] python/dist/src/Modules parsermodule.c,2.83,2.84 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1056/Modules Modified Files: parsermodule.c Log Message: This is Mark Russell's patch: [ 1009560 ] Fix @decorator evaluation order >From the description: Changes in this patch: - Change Grammar/Grammar to require newlines between adjacent decorators. - Fix order of evaluation of decorators in the C (compile.c) and python (Lib/compiler/pycodegen.py) compilers - Add better order of evaluation check to test_decorators.py (test_eval_order) - Update the decorator documentation in the reference manual (improve description of evaluation order and update syntax description) and the comment: Used Brett's evaluation order (see http://mail.python.org/pipermail/python-dev/2004-August/047835.html) (I'm checking this in for Anthony who was having problems getting SF to talk to him) Index: parsermodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/parsermodule.c,v retrieving revision 2.83 retrieving revision 2.84 diff -C2 -d -r2.83 -r2.84 *** parsermodule.c 2 Aug 2004 06:09:55 -0000 2.83 --- parsermodule.c 17 Aug 2004 17:29:15 -0000 2.84 *************** *** 2365,2369 **** /* decorator: ! * '@' dotted_name [ '(' [arglist] ')' ] */ static int --- 2365,2369 ---- /* decorator: ! * '@' dotted_name [ '(' [arglist] ')' ] NEWLINE */ static int *************** *** 2373,2393 **** int nch = NCH(tree); ok = (validate_ntype(tree, decorator) && ! (nch == 2 || nch == 4 || nch == 5) && validate_at(CHILD(tree, 0)) && ! validate_dotted_name(CHILD(tree, 1))); ! if (ok && nch != 2) { ! ok = (validate_lparen(CHILD(tree, 2)) && ! validate_rparen(RCHILD(tree, -1))); ! if (ok && nch == 5) ! ok = validate_arglist(CHILD(tree, 3)); } return ok; } ! /* decorators: ! * decorator ([NEWLINE] decorator)* NEWLINE */ static int --- 2373,2394 ---- int nch = NCH(tree); ok = (validate_ntype(tree, decorator) && ! (nch == 3 || nch == 5 || nch == 6) && validate_at(CHILD(tree, 0)) && ! validate_dotted_name(CHILD(tree, 1)) && ! validate_newline(RCHILD(tree, -1))); ! if (ok && nch != 3) { ! ok = (validate_lparen(CHILD(tree, 2)) && ! validate_rparen(RCHILD(tree, -2))); ! if (ok && nch == 6) ! ok = validate_arglist(CHILD(tree, 3)); } return ok; } ! /* decorators: ! * decorator+ */ static int *************** *** 2396,2411 **** int i, nch, ok; nch = NCH(tree); ! ok = validate_ntype(tree, decorators) && nch >= 2; ! i = 0; ! while (ok && i < nch - 1) { ok = validate_decorator(CHILD(tree, i)); - if (TYPE(CHILD(tree, i + 1)) == NEWLINE) - ++i; - ++i; - } return ok; ! } /* funcdef: --- 2397,2407 ---- int i, nch, ok; nch = NCH(tree); ! ok = validate_ntype(tree, decorators) && nch >= 1; ! for (i = 0; ok && i < nch; ++i) ok = validate_decorator(CHILD(tree, i)); return ok; ! } /* funcdef: From mwh at users.sourceforge.net Tue Aug 17 19:29:35 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 17 19:29:39 2004 Subject: [Python-checkins] python/dist/src/Doc/ref ref7.tex,1.39,1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1056/Doc/ref Modified Files: ref7.tex Log Message: This is Mark Russell's patch: [ 1009560 ] Fix @decorator evaluation order >From the description: Changes in this patch: - Change Grammar/Grammar to require newlines between adjacent decorators. - Fix order of evaluation of decorators in the C (compile.c) and python (Lib/compiler/pycodegen.py) compilers - Add better order of evaluation check to test_decorators.py (test_eval_order) - Update the decorator documentation in the reference manual (improve description of evaluation order and update syntax description) and the comment: Used Brett's evaluation order (see http://mail.python.org/pipermail/python-dev/2004-August/047835.html) (I'm checking this in for Anthony who was having problems getting SF to talk to him) Index: ref7.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref7.tex,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** ref7.tex 2 Aug 2004 06:09:52 -0000 1.39 --- ref7.tex 17 Aug 2004 17:29:13 -0000 1.40 *************** *** 319,325 **** ":" \token{suite}} \production{decorators} ! {\token{decorator} ([NEWLINE] \token{decorator})* NEWLINE} \production{decorator} ! {"@" \token{dotted_name} ["(" [\token{argument_list} [","]] ")"]} \production{parameter_list} {(\token{defparameter} ",")*} --- 319,325 ---- ":" \token{suite}} \production{decorators} ! {\token{decorator}+} \production{decorator} ! {"@" \token{dotted_name} ["(" [\token{argument_list} [","]] ")"] NEWLINE} \production{parameter_list} {(\token{defparameter} ",")*} *************** *** 353,361 **** which is invoked with the function object as the only argument. The returned value is bound to the function name instead of the function ! object. If there are multiple decorators, they are applied in reverse ! order. For example, the following code: \begin{verbatim} ! @f1 @f2 def func(): pass --- 353,361 ---- which is invoked with the function object as the only argument. The returned value is bound to the function name instead of the function ! object. Multiple decorators are applied in nested fashion. ! For example, the following code: \begin{verbatim} ! @f1(arg) @f2 def func(): pass *************** *** 366,370 **** \begin{verbatim} def func(): pass ! func = f2(f1(func)) \end{verbatim} --- 366,370 ---- \begin{verbatim} def func(): pass ! func = f1(arg)(f2(func)) \end{verbatim} From mwh at users.sourceforge.net Tue Aug 17 19:29:31 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 17 19:29:40 2004 Subject: [Python-checkins] python/dist/src/Grammar Grammar,1.50,1.51 Message-ID: Update of /cvsroot/python/python/dist/src/Grammar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1056/Grammar Modified Files: Grammar Log Message: This is Mark Russell's patch: [ 1009560 ] Fix @decorator evaluation order >From the description: Changes in this patch: - Change Grammar/Grammar to require newlines between adjacent decorators. - Fix order of evaluation of decorators in the C (compile.c) and python (Lib/compiler/pycodegen.py) compilers - Add better order of evaluation check to test_decorators.py (test_eval_order) - Update the decorator documentation in the reference manual (improve description of evaluation order and update syntax description) and the comment: Used Brett's evaluation order (see http://mail.python.org/pipermail/python-dev/2004-August/047835.html) (I'm checking this in for Anthony who was having problems getting SF to talk to him) Index: Grammar =================================================================== RCS file: /cvsroot/python/python/dist/src/Grammar/Grammar,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** Grammar 2 Aug 2004 06:09:53 -0000 1.50 --- Grammar 17 Aug 2004 17:29:14 -0000 1.51 *************** *** 29,34 **** eval_input: testlist NEWLINE* ENDMARKER ! decorator: '@' dotted_name [ '(' [arglist] ')' ] ! decorators: decorator ([NEWLINE] decorator)* NEWLINE funcdef: [decorators] 'def' NAME parameters ':' suite parameters: '(' [varargslist] ')' --- 29,34 ---- eval_input: testlist NEWLINE* ENDMARKER ! decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE ! decorators: decorator+ funcdef: [decorators] 'def' NAME parameters ':' suite parameters: '(' [varargslist] ')' From mwh at users.sourceforge.net Tue Aug 17 19:29:37 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 17 19:29:43 2004 Subject: [Python-checkins] python/dist/src/Lib/compiler pycodegen.py, 1.71, 1.72 transformer.py, 1.42, 1.43 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1056/Lib/compiler Modified Files: pycodegen.py transformer.py Log Message: This is Mark Russell's patch: [ 1009560 ] Fix @decorator evaluation order >From the description: Changes in this patch: - Change Grammar/Grammar to require newlines between adjacent decorators. - Fix order of evaluation of decorators in the C (compile.c) and python (Lib/compiler/pycodegen.py) compilers - Add better order of evaluation check to test_decorators.py (test_eval_order) - Update the decorator documentation in the reference manual (improve description of evaluation order and update syntax description) and the comment: Used Brett's evaluation order (see http://mail.python.org/pipermail/python-dev/2004-August/047835.html) (I'm checking this in for Anthony who was having problems getting SF to talk to him) Index: pycodegen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/pycodegen.py,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** pycodegen.py 7 Aug 2004 19:21:56 -0000 1.71 --- pycodegen.py 17 Aug 2004 17:29:14 -0000 1.72 *************** *** 368,377 **** def _visitFuncOrLambda(self, node, isLambda=0): if not isLambda and node.decorators: ! for decorator in reversed(node.decorators.nodes): self.visit(decorator) ndecorators = len(node.decorators.nodes) else: ndecorators = 0 ! gen = self.FunctionGen(node, self.scopes, isLambda, self.class_name, self.get_module()) --- 368,377 ---- def _visitFuncOrLambda(self, node, isLambda=0): if not isLambda and node.decorators: ! for decorator in node.decorators.nodes: self.visit(decorator) ndecorators = len(node.decorators.nodes) else: ndecorators = 0 ! gen = self.FunctionGen(node, self.scopes, isLambda, self.class_name, self.get_module()) Index: transformer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/transformer.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** transformer.py 4 Aug 2004 02:36:18 -0000 1.42 --- transformer.py 17 Aug 2004 17:29:14 -0000 1.43 *************** *** 202,212 **** def decorator(self, nodelist): # '@' dotted_name [ '(' [arglist] ')' ] ! assert len(nodelist) in (2, 4, 5) assert nodelist[0][0] == token.AT assert nodelist[1][0] == symbol.dotted_name funcname = self.decorator_name(nodelist[1][1:]) ! if len(nodelist) > 2: assert nodelist[2][0] == token.LPAR expr = self.com_call_function(funcname, nodelist[3]) --- 202,213 ---- def decorator(self, nodelist): # '@' dotted_name [ '(' [arglist] ')' ] ! assert len(nodelist) in (3, 5, 6) assert nodelist[0][0] == token.AT + assert nodelist[-1][0] == token.NEWLINE assert nodelist[1][0] == symbol.dotted_name funcname = self.decorator_name(nodelist[1][1:]) ! if len(nodelist) > 3: assert nodelist[2][0] == token.LPAR expr = self.com_call_function(funcname, nodelist[3]) *************** *** 218,231 **** def decorators(self, nodelist): # decorators: decorator ([NEWLINE] decorator)* NEWLINE - listlen = len(nodelist) - i = 0 items = [] ! while i < listlen: ! assert nodelist[i][0] == symbol.decorator ! items.append(self.decorator(nodelist[i][1:])) ! i += 1 ! ! if i < listlen and nodelist[i][0] == token.NEWLINE: ! i += 1 return Decorators(items) --- 219,226 ---- def decorators(self, nodelist): # decorators: decorator ([NEWLINE] decorator)* NEWLINE items = [] ! for dec_nodelist in nodelist: ! assert dec_nodelist[0] == symbol.decorator ! items.append(self.decorator(dec_nodelist[1:])) return Decorators(items) From mwh at users.sourceforge.net Tue Aug 17 19:29:44 2004 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Aug 17 19:29:52 2004 Subject: [Python-checkins] python/dist/src/Python compile.c, 2.318, 2.319 graminit.c, 2.36, 2.37 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1056/Python Modified Files: compile.c graminit.c Log Message: This is Mark Russell's patch: [ 1009560 ] Fix @decorator evaluation order >From the description: Changes in this patch: - Change Grammar/Grammar to require newlines between adjacent decorators. - Fix order of evaluation of decorators in the C (compile.c) and python (Lib/compiler/pycodegen.py) compilers - Add better order of evaluation check to test_decorators.py (test_eval_order) - Update the decorator documentation in the reference manual (improve description of evaluation order and update syntax description) and the comment: Used Brett's evaluation order (see http://mail.python.org/pipermail/python-dev/2004-August/047835.html) (I'm checking this in for Anthony who was having problems getting SF to talk to him) Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.318 retrieving revision 2.319 diff -C2 -d -r2.318 -r2.319 *** compile.c 15 Aug 2004 07:21:24 -0000 2.318 --- compile.c 17 Aug 2004 17:29:15 -0000 2.319 *************** *** 4108,4121 **** com_decorator(struct compiling *c, node *n) { ! /* decorator: '@' dotted_name [ '(' [arglist] ')' ] */ int nch = NCH(n); ! assert(nch >= 2); REQ(CHILD(n, 0), AT); com_decorator_name(c, CHILD(n, 1)); ! if (nch > 2) { ! assert(nch == 4 || nch == 5); REQ(CHILD(n, 2), LPAR); ! REQ(CHILD(n, nch - 1), RPAR); com_call_function(c, CHILD(n, 3)); } --- 4108,4122 ---- com_decorator(struct compiling *c, node *n) { ! /* decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE */ int nch = NCH(n); ! assert(nch >= 3); REQ(CHILD(n, 0), AT); + REQ(RCHILD(n, -1), NEWLINE); com_decorator_name(c, CHILD(n, 1)); ! if (nch > 3) { ! assert(nch == 5 || nch == 6); REQ(CHILD(n, 2), LPAR); ! REQ(RCHILD(n, -2), RPAR); com_call_function(c, CHILD(n, 3)); } *************** *** 4125,4148 **** com_decorators(struct compiling *c, node *n) { ! int i, nch, ndecorators; ! /* decorator ([NEWLINE] decorator)* NEWLINE */ nch = NCH(n); ! assert(nch >= 2); ! REQ(CHILD(n, nch - 1), NEWLINE); ! ndecorators = 0; ! /* the application order for decorators is the reverse of how they are ! listed; bottom-up */ ! nch -= 1; ! for (i = 0; i < nch; i+=1) { node *ch = CHILD(n, i); ! if (TYPE(ch) != NEWLINE) { ! com_decorator(c, ch); ! ++ndecorators; ! } } ! return ndecorators; } --- 4126,4143 ---- com_decorators(struct compiling *c, node *n) { ! int i, nch; ! /* decorator+ */ nch = NCH(n); ! assert(nch >= 1); ! for (i = 0; i < nch; ++i) { node *ch = CHILD(n, i); ! REQ(ch, decorator); ! ! com_decorator(c, ch); } ! return nch; } *************** *** 4152,4155 **** --- 4147,4151 ---- PyObject *co; int ndefs, ndecorators; + REQ(n, funcdef); /* -6 -5 -4 -3 -2 -1 *************** *** 4160,4164 **** else ndecorators = 0; ! ndefs = com_argdefs(c, n); if (ndefs < 0) --- 4156,4160 ---- else ndecorators = 0; ! ndefs = com_argdefs(c, n); if (ndefs < 0) *************** *** 4180,4188 **** com_addoparg(c, MAKE_FUNCTION, ndefs); com_pop(c, ndefs); while (ndecorators > 0) { com_addoparg(c, CALL_FUNCTION, 1); com_pop(c, 1); ! ndecorators--; } com_addop_varname(c, VAR_STORE, STR(RCHILD(n, -4))); com_pop(c, 1); --- 4176,4186 ---- com_addoparg(c, MAKE_FUNCTION, ndefs); com_pop(c, ndefs); + while (ndecorators > 0) { com_addoparg(c, CALL_FUNCTION, 1); com_pop(c, 1); ! --ndecorators; } + com_addop_varname(c, VAR_STORE, STR(RCHILD(n, -4))); com_pop(c, 1); Index: graminit.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/graminit.c,v retrieving revision 2.36 retrieving revision 2.37 diff -C2 -d -r2.36 -r2.37 *** graminit.c 2 Aug 2004 06:10:10 -0000 2.36 --- graminit.c 17 Aug 2004 17:29:16 -0000 2.37 *************** *** 52,68 **** static arc arcs_3_2[2] = { {13, 3}, ! {0, 2}, }; static arc arcs_3_3[2] = { ! {14, 4}, ! {15, 5}, }; static arc arcs_3_4[1] = { ! {15, 5}, }; static arc arcs_3_5[1] = { ! {0, 5}, }; ! static state states_3[6] = { {1, arcs_3_0}, {1, arcs_3_1}, --- 52,71 ---- static arc arcs_3_2[2] = { {13, 3}, ! {2, 4}, }; static arc arcs_3_3[2] = { ! {14, 5}, ! {15, 6}, }; static arc arcs_3_4[1] = { ! {0, 4}, }; static arc arcs_3_5[1] = { ! {15, 6}, }; ! static arc arcs_3_6[1] = { ! {2, 4}, ! }; ! static state states_3[7] = { {1, arcs_3_0}, {1, arcs_3_1}, *************** *** 71,74 **** --- 74,78 ---- {1, arcs_3_4}, {1, arcs_3_5}, + {1, arcs_3_6}, }; static arc arcs_4_0[1] = { *************** *** 76,90 **** }; static arc arcs_4_1[2] = { - {2, 2}, {10, 1}, }; ! static arc arcs_4_2[2] = { ! {10, 1}, ! {0, 2}, ! }; ! static state states_4[3] = { {1, arcs_4_0}, {2, arcs_4_1}, - {2, arcs_4_2}, }; static arc arcs_5_0[2] = { --- 80,89 ---- }; static arc arcs_4_1[2] = { {10, 1}, + {0, 1}, }; ! static state states_4[2] = { {1, arcs_4_0}, {2, arcs_4_1}, }; static arc arcs_5_0[2] = { *************** *** 1619,1625 **** {258, "eval_input", 0, 3, states_2, "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\001\000"}, ! {259, "decorator", 0, 6, states_3, "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, ! {260, "decorators", 0, 3, states_4, "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {261, "funcdef", 0, 7, states_5, --- 1618,1624 ---- {258, "eval_input", 0, 3, states_2, "\000\040\010\000\000\000\000\000\000\000\000\000\040\000\000\206\220\064\001\000"}, ! {259, "decorator", 0, 7, states_3, "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, ! {260, "decorators", 0, 2, states_4, "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {261, "funcdef", 0, 7, states_5, From rhettinger at users.sourceforge.net Wed Aug 18 04:50:02 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Aug 18 04:50:09 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libsys.tex,1.73,1.74 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2701/doc/lib Modified Files: libsys.tex Log Message: Deprecate sys.exitfunc in favor of the atexit module. Per Guido, sys.exitfunc will be kept around for backwards compatability but atexit will become the one preferred way to do it. Index: libsys.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsys.tex,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** libsys.tex 5 Aug 2004 12:13:46 -0000 1.73 --- libsys.tex 18 Aug 2004 02:50:00 -0000 1.74 *************** *** 196,199 **** --- 196,200 ---- killed by a signal, when a Python fatal internal error is detected, or when \code{os._exit()} is called.} + \deprecated{2.4}{Use \refmodule{atexit} instead.} \end{datadesc} From rhettinger at users.sourceforge.net Wed Aug 18 04:51:35 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Aug 18 04:51:38 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1097,1.1098 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3025 Modified Files: NEWS Log Message: Various alpha 3 updates. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1097 retrieving revision 1.1098 diff -C2 -d -r1.1097 -r1.1098 *** NEWS 16 Aug 2004 12:10:12 -0000 1.1097 --- NEWS 18 Aug 2004 02:51:32 -0000 1.1098 *************** *** 45,48 **** --- 45,59 ---- ------- + - Updated the decimal package's min() and max() methods to match the + latest revision of the General Decimal Arithmetic Specification. + Quiet NaNs are ignored and equal values are sorted based on sign + and exponent. + + - The decimal package's Context.copy() method now returns deep copies. + + - Deprecated sys.exitfunc in favor of the atexit module. The sys.exitfunc + attribute will be kept around for backwards compatability and atexit + will just become the one preferred way to do it. + - patch #675551: Add get_history_item and replace_history_item functions to the readline module. *************** *** 82,85 **** --- 93,99 ---- ----------- + - IDLE's shortcut keys for windows are now case insensitive so that + Control-V works the same as Control-v. + - pygettext.py: Generate POT-Creation-Date header in ISO format. From rhettinger at users.sourceforge.net Wed Aug 18 07:22:09 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Aug 18 07:22:12 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.319,2.320 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22306 Modified Files: compile.c Log Message: Move the bytecode optimizer upstream so that its results are saved in pyc files and not re-optimized upon import. Saves a bit of startup time while still remaining decoupled from the rest of the compiler. As a side benefit, handcoded bytecode is not run through the optimizer when new code objects are created. Hopefully, a handcoder has already created exactly what they want to have run. (Idea suggested by Armin Rigo and Michael Hudson. Initially avoided because of worries about compiler coupling; however, only the nexus point needed to be moved so there won't be a conflict when the AST branch is loaded.) Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.319 retrieving revision 2.320 diff -C2 -d -r2.319 -r2.320 *** compile.c 17 Aug 2004 17:29:15 -0000 2.319 --- compile.c 18 Aug 2004 05:22:06 -0000 2.320 *************** *** 626,630 **** co->co_stacksize = stacksize; co->co_flags = flags; ! co->co_code = optimize_code(code, consts, names); Py_INCREF(consts); co->co_consts = consts; --- 626,631 ---- co->co_stacksize = stacksize; co->co_flags = flags; ! Py_INCREF(code); ! co->co_code = code; Py_INCREF(consts); co->co_consts = consts; *************** *** 4792,4796 **** if (sc.c_errors == 0) { PyObject *consts, *names, *varnames, *filename, *name, ! *freevars, *cellvars; consts = PyList_AsTuple(sc.c_consts); names = PyList_AsTuple(sc.c_names); --- 4793,4797 ---- if (sc.c_errors == 0) { PyObject *consts, *names, *varnames, *filename, *name, ! *freevars, *cellvars, *code; consts = PyList_AsTuple(sc.c_consts); names = PyList_AsTuple(sc.c_names); *************** *** 4801,4804 **** --- 4802,4806 ---- filename = PyString_InternFromString(sc.c_filename); name = PyString_InternFromString(sc.c_name); + code = optimize_code(sc.c_code, consts, names); if (!PyErr_Occurred()) co = PyCode_New(sc.c_argcount, *************** *** 4806,4810 **** sc.c_maxstacklevel, sc.c_flags, ! sc.c_code, consts, names, --- 4808,4812 ---- sc.c_maxstacklevel, sc.c_flags, ! code, consts, names, *************** *** 4823,4826 **** --- 4825,4829 ---- Py_XDECREF(filename); Py_XDECREF(name); + Py_XDECREF(code); } else if (!PyErr_Occurred()) { From loewis at users.sourceforge.net Wed Aug 18 13:06:51 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 13:06:53 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1098,1.1099 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11140/Misc Modified Files: NEWS Log Message: Patch #764217: Add nametofont function, exists parameter. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1098 retrieving revision 1.1099 diff -C2 -d -r1.1098 -r1.1099 *** NEWS 18 Aug 2004 02:51:32 -0000 1.1098 --- NEWS 18 Aug 2004 11:06:45 -0000 1.1099 *************** *** 45,48 **** --- 45,53 ---- ------- + - A new function tkFont.nametofont was added to return an existing + font. The Font class constructor now has an additional exists argument + which, if True, requests to return/configure an existing font, rather + than creating a new one. + - Updated the decimal package's min() and max() methods to match the latest revision of the General Decimal Arithmetic Specification. From loewis at users.sourceforge.net Wed Aug 18 13:07:18 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 13:07:22 2004 Subject: [Python-checkins] python/dist/src/Lib/lib-tk tkFont.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11140/Lib/lib-tk Modified Files: tkFont.py Log Message: Patch #764217: Add nametofont function, exists parameter. Index: tkFont.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/tkFont.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tkFont.py 14 Jun 2003 21:40:04 -0000 1.5 --- tkFont.py 18 Aug 2004 11:06:44 -0000 1.6 *************** *** 26,29 **** --- 26,34 ---- ITALIC = "italic" + def nametofont(name): + """Given the name of a tk named font, returns a Font representation. + """ + return Font(name=name, exists=True) + class Font: *************** *** 33,38 **** font -- font specifier (name, system font, or (family, size, style)-tuple) ! or any combination of family -- font 'family', e.g. Courier, Times, Helvetica --- 38,47 ---- font -- font specifier (name, system font, or (family, size, style)-tuple) + name -- name to use for this font configuration (defaults to a unique name) + exists -- does a named font by this name already exist? + Creates a new named font if False, points to the existing font if True. + Raises _tkinter.TclError if the assertion is false. ! the following are ignored if font is specified: family -- font 'family', e.g. Courier, Times, Helvetica *************** *** 42,46 **** underline -- font underlining: false (0), true (1) overstrike -- font strikeout: false (0), true (1) ! name -- name to use for this font configuration (defaults to a unique name) """ --- 51,55 ---- underline -- font underlining: false (0), true (1) overstrike -- font strikeout: false (0), true (1) ! """ *************** *** 64,68 **** return options ! def __init__(self, root=None, font=None, name=None, **options): if not root: root = Tkinter._default_root --- 73,77 ---- return options ! def __init__(self, root=None, font=None, name=None, exists=False, **options): if not root: root = Tkinter._default_root *************** *** 75,79 **** name = "font" + str(id(self)) self.name = name ! root.tk.call("font", "create", name, *font) # backlinks! self._root = root --- 84,101 ---- name = "font" + str(id(self)) self.name = name ! ! if exists: ! self.delete_font = False ! # confirm font exists ! if self.name not in root.tk.call("font", "names"): ! raise Tkinter._tkinter.TclError, "named font %s does not already exist" % (self.name,) ! # if font config info supplied, apply it ! if font: ! print "font=%r" % font ! root.tk.call("font", "configure", self.name, *font) ! else: ! # create new font (raises TclError if the font exists) ! root.tk.call("font", "create", self.name, *font) ! self.delete_font = True # backlinks! self._root = root *************** *** 84,93 **** return self.name def __del__(self): try: ! self._call("font", "delete", self.name) except (AttributeError, Tkinter.TclError): pass ! def copy(self): "Return a distinct copy of the current font" --- 106,125 ---- return self.name + def __eq__(self, other): + return self.name == other.name and isinstance(other, Font) + + def __getitem__(self, key): + return self.cget(key) + + def __setitem__(self, key, value): + self.configure(**{key: value}) + def __del__(self): try: ! if self.delete_font: ! self._call("font", "delete", self.name) except (AttributeError, Tkinter.TclError): pass ! def copy(self): "Return a distinct copy of the current font" From loewis at users.sourceforge.net Wed Aug 18 13:56:19 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 13:56:22 2004 Subject: [Python-checkins] python/nondist/peps pep-0000.txt, 1.280, 1.281 pep-0269.txt, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20374 Modified Files: pep-0000.txt pep-0269.txt Log Message: Marking PEP 269 as deferred. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.280 retrieving revision 1.281 diff -C2 -d -r1.280 -r1.281 *** pep-0000.txt 11 Aug 2004 21:00:24 -0000 1.280 --- pep-0000.txt 18 Aug 2004 11:56:16 -0000 1.281 *************** *** 87,91 **** S 267 Optimized Access to Module Namespaces Hylton S 268 Extended HTTP functionality and WebDAV Stein - S 269 Pgen Module for Python Riehl S 273 Import Modules from Zip Archives Ahlstrom S 274 Dict Comprehensions Warsaw --- 87,90 ---- *************** *** 189,192 **** --- 188,192 ---- SR 244 The `directive' Statement von Loewis SR 259 Omit printing newline after newline GvR + SD 269 Pgen Module for Python Riehl SR 270 uniq method for list objects Petrone SR 271 Prefixing sys.path by command line option Giacometti Index: pep-0269.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0269.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pep-0269.txt 5 Apr 2002 19:42:56 -0000 1.2 --- pep-0269.txt 18 Aug 2004 11:56:16 -0000 1.3 *************** *** 4,8 **** Last-Modified: $Date$ Author: jriehl@spaceship.com (Jonathan Riehl) ! Status: Draft Type: Standards Track Created: 24-Aug-2001 --- 4,8 ---- Last-Modified: $Date$ Author: jriehl@spaceship.com (Jonathan Riehl) ! Status: Deferred Type: Standards Track Created: 24-Aug-2001 *************** *** 152,156 **** Reference Implementation ! No reference implementation is currently provided. --- 152,159 ---- Reference Implementation ! No reference implementation is currently provided. A patch ! was provided at some point in ! http://sourceforge.net/tracker/index.php?func=detail&aid=599331&group_id=5470&atid=305470 ! but that patch is no longer maintained. From loewis at users.sourceforge.net Wed Aug 18 14:27:43 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 14:27:47 2004 Subject: [Python-checkins] python/dist/src/Lib/logging handlers.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27372/Lib/logging Modified Files: handlers.py Log Message: Patch #791776: Replace SMTPHandler.date_time with email.Utils.formatdate. Index: handlers.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** handlers.py 12 Jul 2004 09:21:41 -0000 1.16 --- handlers.py 18 Aug 2004 12:27:40 -0000 1.17 *************** *** 655,673 **** return self.subject - weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] - - monthname = [None, - 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] - - def date_time(self): - """Return the current date and time formatted for a MIME header.""" - year, month, day, hh, mm, ss, wd, y, z = time.gmtime(time.time()) - s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % ( - self.weekdayname[wd], - day, self.monthname[month], year, - hh, mm, ss) - return s - def emit(self, record): """ --- 655,658 ---- *************** *** 678,681 **** --- 663,667 ---- try: import smtplib + from email.Utils import formatdate port = self.mailport if not port: *************** *** 687,691 **** string.join(self.toaddrs, ","), self.getSubject(record), ! self.date_time(), msg) smtp.sendmail(self.fromaddr, self.toaddrs, msg) smtp.quit() --- 673,677 ---- string.join(self.toaddrs, ","), self.getSubject(record), ! formatdate(), msg) smtp.sendmail(self.fromaddr, self.toaddrs, msg) smtp.quit() From loewis at users.sourceforge.net Wed Aug 18 14:27:44 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 14:27:48 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1099,1.1100 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27372/Misc Modified Files: NEWS Log Message: Patch #791776: Replace SMTPHandler.date_time with email.Utils.formatdate. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1099 retrieving revision 1.1100 diff -C2 -d -r1.1099 -r1.1100 *** NEWS 18 Aug 2004 11:06:45 -0000 1.1099 --- NEWS 18 Aug 2004 12:27:40 -0000 1.1100 *************** *** 45,48 **** --- 45,51 ---- ------- + - logging.handlers.SMTPHandler.date_time has been removed; + the class now uses email.Utils.formatdate to generate the time stamp. + - A new function tkFont.nametofont was added to return an existing font. The Font class constructor now has an additional exists argument From jlgijsbers at users.sourceforge.net Wed Aug 18 14:40:33 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Wed Aug 18 14:40:35 2004 Subject: [Python-checkins] python/dist/src/Lib inspect.py,1.53,1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29903/Lib Modified Files: inspect.py Log Message: Patch #1006219: let inspect.getsource show '@' decorators and add tests for this (which are rather ugly, but it'll have to do until test_inspect gets a major overhaul and a conversion to unittest). Thanks Simon Percivall! Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** inspect.py 15 Aug 2004 17:04:32 -0000 1.53 --- inspect.py 18 Aug 2004 12:40:30 -0000 1.54 *************** *** 434,438 **** raise IOError('could not find function definition') lnum = object.co_firstlineno - 1 ! pat = re.compile(r'^(\s*def\s)|(.*\slambda(:|\s))') while lnum > 0: if pat.match(lines[lnum]): break --- 434,438 ---- raise IOError('could not find function definition') lnum = object.co_firstlineno - 1 ! pat = re.compile(r'^(\s*def\s)|(.*\slambda(:|\s))|^(\s*@)') while lnum > 0: if pat.match(lines[lnum]): break *************** *** 510,514 **** def tokeneater(self, type, token, (srow, scol), (erow, ecol), line): if not self.started: ! if type == tokenize.NAME: self.started = 1 elif type == tokenize.NEWLINE: self.last = srow --- 510,515 ---- def tokeneater(self, type, token, (srow, scol), (erow, ecol), line): if not self.started: ! if '@' in line: pass ! elif type == tokenize.NAME: self.started = 1 elif type == tokenize.NEWLINE: self.last = srow From jlgijsbers at users.sourceforge.net Wed Aug 18 14:40:33 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Wed Aug 18 14:40:36 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_inspect.py, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29903/Lib/test Modified Files: test_inspect.py Log Message: Patch #1006219: let inspect.getsource show '@' decorators and add tests for this (which are rather ugly, but it'll have to do until test_inspect gets a major overhaul and a conversion to unittest). Thanks Simon Percivall! Index: test_inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_inspect.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_inspect.py 15 Aug 2004 17:04:32 -0000 1.15 --- test_inspect.py 18 Aug 2004 12:40:31 -0000 1.16 *************** *** 203,206 **** --- 203,247 ---- pass + # Test for decorators as well. + + source = r""" + def wrap(foo=None): + def wrapper(func): + return func + return wrapper + + def replace(func): + def insteadfunc(): + print 'hello' + return insteadfunc + + # two decorators, one with argument + @wrap() + @wrap(wrap) + def wrapped(): + pass + + @replace + def gone(): + pass""" + + file = open(TESTFN + "2", "w") + file.write(source) + file.close() + files_to_clean_up = [TESTFN + "2", TESTFN + '2c', TESTFN + '2o'] + + mod2 = imp.load_source("testmod3", TESTFN + "2") + + test(inspect.getsource(mod2.wrapped) == sourcerange(13, 16), + "inspect.getsource(mod.wrapped)") + test(inspect.getsource(mod2.gone) == sourcerange(8, 9), + "inspect.getsource(mod.gone)") + + for fname in files_to_clean_up: + try: + os.unlink(fname) + except: + pass + # Test classic-class method resolution order. class A: pass From jlgijsbers at users.sourceforge.net Wed Aug 18 14:40:34 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Wed Aug 18 14:40:39 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1100,1.1101 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29903/Misc Modified Files: NEWS Log Message: Patch #1006219: let inspect.getsource show '@' decorators and add tests for this (which are rather ugly, but it'll have to do until test_inspect gets a major overhaul and a conversion to unittest). Thanks Simon Percivall! Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1100 retrieving revision 1.1101 diff -C2 -d -r1.1100 -r1.1101 *** NEWS 18 Aug 2004 12:27:40 -0000 1.1100 --- NEWS 18 Aug 2004 12:40:31 -0000 1.1101 *************** *** 45,48 **** --- 45,51 ---- ------- + - Patch #1006219: let inspect.getsource handle '@' decorators. Thanks Simon + Percivall. + - logging.handlers.SMTPHandler.date_time has been removed; the class now uses email.Utils.formatdate to generate the time stamp. From loewis at users.sourceforge.net Wed Aug 18 14:46:27 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 14:46:31 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libhttplib.tex,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31353/Doc/lib Modified Files: libhttplib.tex Log Message: Patch #800236: add HTTPResponse.getheaders(). Index: libhttplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libhttplib.tex,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** libhttplib.tex 19 Nov 2003 19:51:55 -0000 1.36 --- libhttplib.tex 18 Aug 2004 12:46:25 -0000 1.37 *************** *** 212,215 **** --- 212,219 ---- \end{methoddesc} + \begin{methoddesc}{getheaders}{} + Return a list of (header, value) tuples. \versionadded{2.4} + \end{methoddesc} + \begin{datadesc}{msg} A \class{mimetools.Message} instance containing the response headers. From loewis at users.sourceforge.net Wed Aug 18 14:46:28 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 14:46:33 2004 Subject: [Python-checkins] python/dist/src/Lib httplib.py,1.86,1.87 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31353/Lib Modified Files: httplib.py Log Message: Patch #800236: add HTTPResponse.getheaders(). Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** httplib.py 7 Aug 2004 16:28:13 -0000 1.86 --- httplib.py 18 Aug 2004 12:46:25 -0000 1.87 *************** *** 494,497 **** --- 494,503 ---- return self.msg.getheader(name, default) + def getheaders(self): + """Return list of (header, value) tuples.""" + if self.msg is None: + raise ResponseNotReady() + return self.msg.items() + class HTTPConnection: From loewis at users.sourceforge.net Wed Aug 18 14:46:28 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 14:46:34 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1101,1.1102 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31353/Misc Modified Files: NEWS Log Message: Patch #800236: add HTTPResponse.getheaders(). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1101 retrieving revision 1.1102 diff -C2 -d -r1.1101 -r1.1102 *** NEWS 18 Aug 2004 12:40:31 -0000 1.1101 --- NEWS 18 Aug 2004 12:46:26 -0000 1.1102 *************** *** 45,48 **** --- 45,50 ---- ------- + - HTTPResponse has now a getheaders method. + - Patch #1006219: let inspect.getsource handle '@' decorators. Thanks Simon Percivall. From loewis at users.sourceforge.net Wed Aug 18 15:16:58 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 15:17:01 2004 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.262,2.263 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6387 Modified Files: typeobject.c Log Message: Patch #980082: Missing INCREF in PyType_Ready. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.262 retrieving revision 2.263 diff -C2 -d -r2.262 -r2.263 *** typeobject.c 3 Aug 2004 10:21:02 -0000 2.262 --- typeobject.c 18 Aug 2004 13:16:54 -0000 2.263 *************** *** 3144,3149 **** /* Initialize tp_base (defaults to BaseObject unless that's us) */ base = type->tp_base; ! if (base == NULL && type != &PyBaseObject_Type) base = type->tp_base = &PyBaseObject_Type; /* Initialize the base class */ --- 3144,3151 ---- /* Initialize tp_base (defaults to BaseObject unless that's us) */ base = type->tp_base; ! if (base == NULL && type != &PyBaseObject_Type) { base = type->tp_base = &PyBaseObject_Type; + Py_INCREF(base); + } /* Initialize the base class */ From loewis at users.sourceforge.net Wed Aug 18 15:21:25 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 15:21:27 2004 Subject: [Python-checkins] python/dist/src/Objects typeobject.c, 2.241.6.11, 2.241.6.12 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7487 Modified Files: Tag: release23-maint typeobject.c Log Message: Patch #980082: Missing INCREF in PyType_Ready. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.241.6.11 retrieving revision 2.241.6.12 diff -C2 -d -r2.241.6.11 -r2.241.6.12 *** typeobject.c 25 Jun 2004 22:18:46 -0000 2.241.6.11 --- typeobject.c 18 Aug 2004 13:21:22 -0000 2.241.6.12 *************** *** 3130,3135 **** /* Initialize tp_base (defaults to BaseObject unless that's us) */ base = type->tp_base; ! if (base == NULL && type != &PyBaseObject_Type) base = type->tp_base = &PyBaseObject_Type; /* Initialize the base class */ --- 3130,3137 ---- /* Initialize tp_base (defaults to BaseObject unless that's us) */ base = type->tp_base; ! if (base == NULL && type != &PyBaseObject_Type) { base = type->tp_base = &PyBaseObject_Type; + Py_INCREF(base); + } /* Initialize the base class */ From loewis at users.sourceforge.net Wed Aug 18 15:25:08 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 15:25:29 2004 Subject: [Python-checkins] python/dist/src/Doc/ref ref2.tex,1.53,1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8071 Modified Files: ref2.tex Log Message: Patch #1011144: Correct regex for coding decls. Index: ref2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref2.tex,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** ref2.tex 5 Aug 2004 21:11:27 -0000 1.53 --- ref2.tex 18 Aug 2004 13:25:05 -0000 1.54 *************** *** 76,80 **** If a comment in the first or second line of the Python script matches ! the regular expression \regexp{coding[=:]\e s*([\e w-_.]+)}, this comment is processed as an encoding declaration; the first group of this expression names the encoding of the source code file. The recommended --- 76,80 ---- If a comment in the first or second line of the Python script matches ! the regular expression \regexp{coding[=:]\e s*([-\e w.]+)}, this comment is processed as an encoding declaration; the first group of this expression names the encoding of the source code file. The recommended From loewis at users.sourceforge.net Wed Aug 18 15:25:57 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 15:25:59 2004 Subject: [Python-checkins] python/nondist/peps pep-0263.txt,1.18,1.19 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8619 Modified Files: pep-0263.txt Log Message: Patch #1011144: Correct regex syntax. Index: pep-0263.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0263.txt,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** pep-0263.txt 24 Jul 2004 20:50:49 -0000 1.18 --- pep-0263.txt 18 Aug 2004 13:25:54 -0000 1.19 *************** *** 53,57 **** More precisely, the first or second line must match the regular ! expression "coding[:=]\s*([-\w_.]+)". The first group of this expression is then interpreted as encoding name. If the encoding is unknown to Python, an error is raised during compilation. There --- 53,57 ---- More precisely, the first or second line must match the regular ! expression "coding[:=]\s*([-\w.]+)". The first group of this expression is then interpreted as encoding name. If the encoding is unknown to Python, an error is raised during compilation. There From loewis at users.sourceforge.net Wed Aug 18 15:34:03 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 15:34:05 2004 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.74,2.75 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10159 Modified Files: readline.c Log Message: Patch #914291: Restore locale while readline is running. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.74 retrieving revision 2.75 diff -C2 -d -r2.74 -r2.75 *** readline.c 16 Aug 2004 16:15:13 -0000 2.74 --- readline.c 18 Aug 2004 13:34:00 -0000 2.75 *************** *** 822,825 **** --- 822,829 ---- call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) { + #ifdef SAVE_LOCALE + char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); + setlocale(LC_CTYPE, ""); + #endif size_t n; char *p, *q; *************** *** 880,883 **** --- 884,891 ---- } free(q); + #ifdef SAVE_LOCALE + setlocale(LC_CTYPE, saved_locale); /* Restore locale */ + free(saved_locale); + #endif return p; } From loewis at users.sourceforge.net Wed Aug 18 15:35:52 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 15:35:56 2004 Subject: [Python-checkins] python/dist/src/Modules readline.c, 2.64.6.1, 2.64.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10492/Modules Modified Files: Tag: release23-maint readline.c Log Message: Patch #914291: Restore locale while calling readline. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.64.6.1 retrieving revision 2.64.6.2 diff -C2 -d -r2.64.6.1 -r2.64.6.2 *** readline.c 13 Nov 2003 07:42:13 -0000 2.64.6.1 --- readline.c 18 Aug 2004 13:35:49 -0000 2.64.6.2 *************** *** 654,657 **** --- 654,661 ---- call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) { + #ifdef SAVE_LOCALE + char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); + setlocale(LC_CTYPE, ""); + #endif size_t n; char *p, *q; *************** *** 715,718 **** --- 719,726 ---- } free(q); + #ifdef SAVE_LOCALE + setlocale(LC_CTYPE, saved_locale); /* Restore locale */ + free(saved_locale); + #endif return p; } From loewis at users.sourceforge.net Wed Aug 18 15:35:52 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 15:35:58 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.142, 1.831.4.143 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10492/Misc Modified Files: Tag: release23-maint NEWS Log Message: Patch #914291: Restore locale while calling readline. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.142 retrieving revision 1.831.4.143 diff -C2 -d -r1.831.4.142 -r1.831.4.143 *** NEWS 16 Aug 2004 12:15:00 -0000 1.831.4.142 --- NEWS 18 Aug 2004 13:35:49 -0000 1.831.4.143 *************** *** 29,32 **** --- 29,34 ---- ----------------- + - Patch #914291: Set locale while getting a line from readline. + - Bug #1005308: Define _BSD_TYPES. From loewis at users.sourceforge.net Wed Aug 18 15:57:46 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 15:57:48 2004 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15057/Lib Modified Files: tarfile.py Log Message: Patch #995126: Correct directory size, and generate GNU tarfiles by default. Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** tarfile.py 20 Jul 2004 22:31:34 -0000 1.15 --- tarfile.py 18 Aug 2004 13:57:44 -0000 1.16 *************** *** 782,786 **** # are passed to the caller as exceptions. ! posix = True # If True, generates POSIX.1-1990-compliant # archives (no GNU extensions!) --- 782,786 ---- # are passed to the caller as exceptions. ! posix = False # If True, generates POSIX.1-1990-compliant # archives (no GNU extensions!) *************** *** 1138,1142 **** tarinfo.uid = statres.st_uid tarinfo.gid = statres.st_gid ! tarinfo.size = statres.st_size tarinfo.mtime = statres.st_mtime tarinfo.type = type --- 1138,1142 ---- tarinfo.uid = statres.st_uid tarinfo.gid = statres.st_gid ! tarinfo.size = not stat.S_ISDIR(stmd) and statres.st_size or 0 tarinfo.mtime = statres.st_mtime tarinfo.type = type From loewis at users.sourceforge.net Wed Aug 18 15:57:46 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 15:57:50 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libtarfile.tex,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15057/Doc/lib Modified Files: libtarfile.tex Log Message: Patch #995126: Correct directory size, and generate GNU tarfiles by default. Index: libtarfile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtarfile.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** libtarfile.tex 20 Jul 2004 22:23:02 -0000 1.4 --- libtarfile.tex 18 Aug 2004 13:57:43 -0000 1.5 *************** *** 262,266 **** this limit. If false, create a GNU tar compatible archive. It will not be \POSIX{} compliant, but can store files without any ! of the above restrictions. \end{memberdesc} --- 262,267 ---- this limit. If false, create a GNU tar compatible archive. It will not be \POSIX{} compliant, but can store files without any ! of the above restrictions. ! \versionchanged[\var{posix} defaults to false.]{2.4} \end{memberdesc} From loewis at users.sourceforge.net Wed Aug 18 15:57:47 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 15:57:52 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1102,1.1103 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15057/Misc Modified Files: NEWS Log Message: Patch #995126: Correct directory size, and generate GNU tarfiles by default. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1102 retrieving revision 1.1103 diff -C2 -d -r1.1102 -r1.1103 *** NEWS 18 Aug 2004 12:46:26 -0000 1.1102 --- NEWS 18 Aug 2004 13:57:44 -0000 1.1103 *************** *** 45,48 **** --- 45,50 ---- ------- + - tarfile now generates GNU tar files by default. + - HTTPResponse has now a getheaders method. From perky at users.sourceforge.net Wed Aug 18 16:14:58 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 18 16:15:00 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-freebsd6 - New directory Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-freebsd6 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18624/plat-freebsd6 Log Message: Directory /cvsroot/python/python/dist/src/Lib/plat-freebsd6 added to the repository From perky at users.sourceforge.net Wed Aug 18 17:13:43 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 18 17:13:47 2004 Subject: [Python-checkins] python/dist/src setup.py,1.197,1.198 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32250 Modified Files: setup.py Log Message: Add support for FreeBSD 6. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.197 retrieving revision 1.198 diff -C2 -d -r1.197 -r1.198 *** setup.py 23 Jul 2004 02:50:10 -0000 1.197 --- setup.py 18 Aug 2004 15:13:39 -0000 1.198 *************** *** 783,787 **** exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) ) ! if platform in ('linux2', 'freebsd4', 'freebsd5'): exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) --- 783,787 ---- exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) ) ! if platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6'): exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) ) From perky at users.sourceforge.net Wed Aug 18 17:13:43 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 18 17:13:49 2004 Subject: [Python-checkins] python/dist/src/Lib posixfile.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32250/Lib Modified Files: posixfile.py Log Message: Add support for FreeBSD 6. Index: posixfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixfile.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** posixfile.py 12 Feb 2004 17:35:06 -0000 1.25 --- posixfile.py 18 Aug 2004 15:13:40 -0000 1.26 *************** *** 186,190 **** 'openbsd2', 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', ! 'bsdos2', 'bsdos3', 'bsdos4'): flock = struct.pack('lxxxxlxxxxlhh', \ l_start, l_len, os.getpid(), l_type, l_whence) --- 186,190 ---- 'openbsd2', 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', ! 'freebsd6', 'bsdos2', 'bsdos3', 'bsdos4'): flock = struct.pack('lxxxxlxxxxlhh', \ l_start, l_len, os.getpid(), l_type, l_whence) From perky at users.sourceforge.net Wed Aug 18 17:13:44 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 18 17:13:51 2004 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py, 1.160, 1.161 test_fcntl.py, 1.25, 1.26 test_socket.py, 1.75, 1.76 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32250/Lib/test Modified Files: regrtest.py test_fcntl.py test_socket.py Log Message: Add support for FreeBSD 6. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.160 retrieving revision 1.161 diff -C2 -d -r1.160 -r1.161 *** regrtest.py 12 Aug 2004 18:27:48 -0000 1.160 --- regrtest.py 18 Aug 2004 15:13:41 -0000 1.161 *************** *** 1037,1040 **** --- 1037,1041 ---- test_cd test_cl + test_gdbm test_gl test_imgfile *************** *** 1043,1046 **** --- 1044,1048 ---- test_macfs test_macostools + test_mpz test_nis test_normalization *************** *** 1048,1055 **** --- 1050,1059 ---- test_pep277 test_plistlib + test_pty test_scriptpackages test_socket_ssl test_socketserver test_sunaudiodev + test_tcl test_timeout test_unicode_file *************** *** 1060,1063 **** --- 1064,1068 ---- } _expectations['freebsd5'] = _expectations['freebsd4'] + _expectations['freebsd6'] = _expectations['freebsd4'] class _ExpectedSkips: Index: test_fcntl.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_fcntl.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** test_fcntl.py 12 Feb 2004 17:35:11 -0000 1.25 --- test_fcntl.py 18 Aug 2004 15:13:41 -0000 1.26 *************** *** 22,26 **** if sys.platform in ('netbsd1', 'Darwin1.2', 'darwin', ! 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', 'bsdos2', 'bsdos3', 'bsdos4', 'openbsd', 'openbsd2', 'openbsd3'): --- 22,26 ---- if sys.platform in ('netbsd1', 'Darwin1.2', 'darwin', ! 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', 'freebsd6', 'bsdos2', 'bsdos3', 'bsdos4', 'openbsd', 'openbsd2', 'openbsd3'): Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** test_socket.py 16 Aug 2004 15:35:54 -0000 1.75 --- test_socket.py 18 Aug 2004 15:13:41 -0000 1.76 *************** *** 312,316 **** # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. ! if sys.platform in ('freebsd4', 'freebsd5', 'darwin'): # avoid the 'echo' service on this platform, as there is an # assumption breaking non-standard port/protocol entry --- 312,316 ---- # I've ordered this by protocols that have both a tcp and udp # protocol, at least for modern Linuxes. ! if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'darwin'): # avoid the 'echo' service on this platform, as there is an # assumption breaking non-standard port/protocol entry From perky at users.sourceforge.net Wed Aug 18 17:13:45 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 18 17:13:52 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1103,1.1104 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32250/Misc Modified Files: NEWS Log Message: Add support for FreeBSD 6. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1103 retrieving revision 1.1104 diff -C2 -d -r1.1103 -r1.1104 *** NEWS 18 Aug 2004 13:57:44 -0000 1.1103 --- NEWS 18 Aug 2004 15:13:41 -0000 1.1104 *************** *** 138,141 **** --- 138,143 ---- ------------- + - FreeBSD 6 is now supported. + Tests ----- From perky at users.sourceforge.net Wed Aug 18 17:13:44 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Wed Aug 18 17:13:54 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-freebsd6 IN.py, NONE, 1.1 regen, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-freebsd6 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32250/Lib/plat-freebsd6 Added Files: IN.py regen Log Message: Add support for FreeBSD 6. --- NEW FILE: IN.py --- # Generated by h2py from /usr/include/netinet/in.h # Included from sys/cdefs.h def __P(protos): return protos def __STRING(x): return #x def __XSTRING(x): return __STRING(x) def __P(protos): return () def __STRING(x): return "x" def __aligned(x): return __attribute__((__aligned__(x))) def __section(x): return __attribute__((__section__(x))) def __aligned(x): return __attribute__((__aligned__(x))) def __section(x): return __attribute__((__section__(x))) def __nonnull(x): return __attribute__((__nonnull__(x))) def __predict_true(exp): return __builtin_expect((exp), 1) def __predict_false(exp): return __builtin_expect((exp), 0) def __predict_true(exp): return (exp) def __predict_false(exp): return (exp) def __FBSDID(s): return __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) def __RCSID(s): return __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) def __RCSID_SOURCE(s): return __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s) def __SCCSID(s): return __IDSTRING(__CONCAT(__sccsid_,__LINE__),s) def __COPYRIGHT(s): return __IDSTRING(__CONCAT(__copyright_,__LINE__),s) _POSIX_C_SOURCE = 199009 _POSIX_C_SOURCE = 199209 __XSI_VISIBLE = 600 _POSIX_C_SOURCE = 200112 __XSI_VISIBLE = 500 _POSIX_C_SOURCE = 199506 _POSIX_C_SOURCE = 198808 __POSIX_VISIBLE = 200112 __ISO_C_VISIBLE = 1999 __POSIX_VISIBLE = 199506 __ISO_C_VISIBLE = 1990 __POSIX_VISIBLE = 199309 __ISO_C_VISIBLE = 1990 __POSIX_VISIBLE = 199209 __ISO_C_VISIBLE = 1990 __POSIX_VISIBLE = 199009 __ISO_C_VISIBLE = 1990 __POSIX_VISIBLE = 198808 __ISO_C_VISIBLE = 0 __POSIX_VISIBLE = 0 __XSI_VISIBLE = 0 __BSD_VISIBLE = 0 __ISO_C_VISIBLE = 1990 __POSIX_VISIBLE = 0 __XSI_VISIBLE = 0 __BSD_VISIBLE = 0 __ISO_C_VISIBLE = 1999 __POSIX_VISIBLE = 200112 __XSI_VISIBLE = 600 __BSD_VISIBLE = 1 __ISO_C_VISIBLE = 1999 # Included from sys/_types.h # Included from machine/_types.h # Included from machine/endian.h _QUAD_HIGHWORD = 1 _QUAD_LOWWORD = 0 _LITTLE_ENDIAN = 1234 _BIG_ENDIAN = 4321 _PDP_ENDIAN = 3412 _BYTE_ORDER = _LITTLE_ENDIAN LITTLE_ENDIAN = _LITTLE_ENDIAN BIG_ENDIAN = _BIG_ENDIAN PDP_ENDIAN = _PDP_ENDIAN BYTE_ORDER = _BYTE_ORDER __INTEL_COMPILER_with_FreeBSD_endian = 1 __INTEL_COMPILER_with_FreeBSD_endian = 1 def __word_swap_int_var(x): return \ def __word_swap_int_const(x): return \ def __word_swap_int(x): return __word_swap_int_var(x) def __byte_swap_int_var(x): return \ def __byte_swap_int_var(x): return \ def __byte_swap_int_const(x): return \ def __byte_swap_int(x): return __byte_swap_int_var(x) def __byte_swap_word_var(x): return \ def __byte_swap_word_const(x): return \ def __byte_swap_word(x): return __byte_swap_word_var(x) def __htonl(x): return __bswap32(x) def __htons(x): return __bswap16(x) def __ntohl(x): return __bswap32(x) def __ntohs(x): return __bswap16(x) IPPROTO_IP = 0 IPPROTO_ICMP = 1 IPPROTO_TCP = 6 IPPROTO_UDP = 17 def htonl(x): return __htonl(x) def htons(x): return __htons(x) def ntohl(x): return __ntohl(x) def ntohs(x): return __ntohs(x) IPPROTO_RAW = 255 INET_ADDRSTRLEN = 16 IPPROTO_HOPOPTS = 0 IPPROTO_IGMP = 2 IPPROTO_GGP = 3 IPPROTO_IPV4 = 4 IPPROTO_IPIP = IPPROTO_IPV4 IPPROTO_ST = 7 IPPROTO_EGP = 8 IPPROTO_PIGP = 9 IPPROTO_RCCMON = 10 IPPROTO_NVPII = 11 IPPROTO_PUP = 12 IPPROTO_ARGUS = 13 IPPROTO_EMCON = 14 IPPROTO_XNET = 15 IPPROTO_CHAOS = 16 IPPROTO_MUX = 18 IPPROTO_MEAS = 19 IPPROTO_HMP = 20 IPPROTO_PRM = 21 IPPROTO_IDP = 22 IPPROTO_TRUNK1 = 23 IPPROTO_TRUNK2 = 24 IPPROTO_LEAF1 = 25 IPPROTO_LEAF2 = 26 IPPROTO_RDP = 27 IPPROTO_IRTP = 28 IPPROTO_TP = 29 IPPROTO_BLT = 30 IPPROTO_NSP = 31 IPPROTO_INP = 32 IPPROTO_SEP = 33 IPPROTO_3PC = 34 IPPROTO_IDPR = 35 IPPROTO_XTP = 36 IPPROTO_DDP = 37 IPPROTO_CMTP = 38 IPPROTO_TPXX = 39 IPPROTO_IL = 40 IPPROTO_IPV6 = 41 IPPROTO_SDRP = 42 IPPROTO_ROUTING = 43 IPPROTO_FRAGMENT = 44 IPPROTO_IDRP = 45 IPPROTO_RSVP = 46 IPPROTO_GRE = 47 IPPROTO_MHRP = 48 IPPROTO_BHA = 49 IPPROTO_ESP = 50 IPPROTO_AH = 51 IPPROTO_INLSP = 52 IPPROTO_SWIPE = 53 IPPROTO_NHRP = 54 IPPROTO_MOBILE = 55 IPPROTO_TLSP = 56 IPPROTO_SKIP = 57 IPPROTO_ICMPV6 = 58 IPPROTO_NONE = 59 IPPROTO_DSTOPTS = 60 IPPROTO_AHIP = 61 IPPROTO_CFTP = 62 IPPROTO_HELLO = 63 IPPROTO_SATEXPAK = 64 IPPROTO_KRYPTOLAN = 65 IPPROTO_RVD = 66 IPPROTO_IPPC = 67 IPPROTO_ADFS = 68 IPPROTO_SATMON = 69 IPPROTO_VISA = 70 IPPROTO_IPCV = 71 IPPROTO_CPNX = 72 IPPROTO_CPHB = 73 IPPROTO_WSN = 74 IPPROTO_PVP = 75 IPPROTO_BRSATMON = 76 IPPROTO_ND = 77 IPPROTO_WBMON = 78 IPPROTO_WBEXPAK = 79 IPPROTO_EON = 80 IPPROTO_VMTP = 81 IPPROTO_SVMTP = 82 IPPROTO_VINES = 83 IPPROTO_TTP = 84 IPPROTO_IGP = 85 IPPROTO_DGP = 86 IPPROTO_TCF = 87 IPPROTO_IGRP = 88 IPPROTO_OSPFIGP = 89 IPPROTO_SRPC = 90 IPPROTO_LARP = 91 IPPROTO_MTP = 92 IPPROTO_AX25 = 93 IPPROTO_IPEIP = 94 IPPROTO_MICP = 95 IPPROTO_SCCSP = 96 IPPROTO_ETHERIP = 97 IPPROTO_ENCAP = 98 IPPROTO_APES = 99 IPPROTO_GMTP = 100 IPPROTO_IPCOMP = 108 IPPROTO_PIM = 103 IPPROTO_PGM = 113 IPPROTO_PFSYNC = 240 IPPROTO_OLD_DIVERT = 254 IPPROTO_MAX = 256 IPPROTO_DONE = 257 IPPROTO_DIVERT = 258 IPPORT_RESERVED = 1024 IPPORT_HIFIRSTAUTO = 49152 IPPORT_HILASTAUTO = 65535 IPPORT_RESERVEDSTART = 600 IPPORT_MAX = 65535 def IN_CLASSA(i): return (((u_int32_t)(i) & (-2147483648)) == 0) IN_CLASSA_NET = (-16777216) IN_CLASSA_NSHIFT = 24 IN_CLASSA_HOST = 0x00ffffff IN_CLASSA_MAX = 128 def IN_CLASSB(i): return (((u_int32_t)(i) & (-1073741824)) == (-2147483648)) IN_CLASSB_NET = (-65536) IN_CLASSB_NSHIFT = 16 IN_CLASSB_HOST = 0x0000ffff IN_CLASSB_MAX = 65536 def IN_CLASSC(i): return (((u_int32_t)(i) & (-536870912)) == (-1073741824)) IN_CLASSC_NET = (-256) IN_CLASSC_NSHIFT = 8 IN_CLASSC_HOST = 0x000000ff def IN_CLASSD(i): return (((u_int32_t)(i) & (-268435456)) == (-536870912)) IN_CLASSD_NET = (-268435456) IN_CLASSD_NSHIFT = 28 IN_CLASSD_HOST = 0x0fffffff def IN_MULTICAST(i): return IN_CLASSD(i) def IN_EXPERIMENTAL(i): return (((u_int32_t)(i) & (-268435456)) == (-268435456)) def IN_BADCLASS(i): return (((u_int32_t)(i) & (-268435456)) == (-268435456)) INADDR_NONE = (-1) IN_LOOPBACKNET = 127 IP_OPTIONS = 1 IP_HDRINCL = 2 IP_TOS = 3 IP_TTL = 4 IP_RECVOPTS = 5 IP_RECVRETOPTS = 6 IP_RECVDSTADDR = 7 IP_SENDSRCADDR = IP_RECVDSTADDR IP_RETOPTS = 8 IP_MULTICAST_IF = 9 IP_MULTICAST_TTL = 10 IP_MULTICAST_LOOP = 11 IP_ADD_MEMBERSHIP = 12 IP_DROP_MEMBERSHIP = 13 IP_MULTICAST_VIF = 14 IP_RSVP_ON = 15 IP_RSVP_OFF = 16 IP_RSVP_VIF_ON = 17 IP_RSVP_VIF_OFF = 18 IP_PORTRANGE = 19 IP_RECVIF = 20 IP_IPSEC_POLICY = 21 IP_FAITH = 22 IP_ONESBCAST = 23 IP_FW_TABLE_ADD = 40 IP_FW_TABLE_DEL = 41 IP_FW_TABLE_FLUSH = 42 IP_FW_TABLE_GETSIZE = 43 IP_FW_TABLE_LIST = 44 IP_FW_ADD = 50 IP_FW_DEL = 51 IP_FW_FLUSH = 52 IP_FW_ZERO = 53 IP_FW_GET = 54 IP_FW_RESETLOG = 55 IP_DUMMYNET_CONFIGURE = 60 IP_DUMMYNET_DEL = 61 IP_DUMMYNET_FLUSH = 62 IP_DUMMYNET_GET = 64 IP_RECVTTL = 65 IP_DEFAULT_MULTICAST_TTL = 1 IP_DEFAULT_MULTICAST_LOOP = 1 IP_MAX_MEMBERSHIPS = 20 IP_PORTRANGE_DEFAULT = 0 IP_PORTRANGE_HIGH = 1 IP_PORTRANGE_LOW = 2 IPPROTO_MAXID = (IPPROTO_AH + 1) IPCTL_FORWARDING = 1 IPCTL_SENDREDIRECTS = 2 IPCTL_DEFTTL = 3 IPCTL_DEFMTU = 4 IPCTL_RTEXPIRE = 5 IPCTL_RTMINEXPIRE = 6 IPCTL_RTMAXCACHE = 7 IPCTL_SOURCEROUTE = 8 IPCTL_DIRECTEDBROADCAST = 9 IPCTL_INTRQMAXLEN = 10 IPCTL_INTRQDROPS = 11 IPCTL_STATS = 12 IPCTL_ACCEPTSOURCEROUTE = 13 IPCTL_FASTFORWARDING = 14 IPCTL_KEEPFAITH = 15 IPCTL_GIF_TTL = 16 IPCTL_MAXID = 17 def in_nullhost(x): return ((x).s_addr == INADDR_ANY) # Included from netinet6/in6.h __KAME_VERSION = "20010528/FreeBSD" IPV6PORT_RESERVED = 1024 IPV6PORT_ANONMIN = 49152 IPV6PORT_ANONMAX = 65535 IPV6PORT_RESERVEDMIN = 600 IPV6PORT_RESERVEDMAX = (IPV6PORT_RESERVED-1) INET6_ADDRSTRLEN = 46 IPV6_ADDR_INT32_ONE = 1 IPV6_ADDR_INT32_TWO = 2 IPV6_ADDR_INT32_MNL = (-16711680) IPV6_ADDR_INT32_MLL = (-16646144) IPV6_ADDR_INT32_SMP = 0x0000ffff IPV6_ADDR_INT16_ULL = 0xfe80 IPV6_ADDR_INT16_USL = 0xfec0 IPV6_ADDR_INT16_MLL = 0xff02 IPV6_ADDR_INT32_ONE = 0x01000000 IPV6_ADDR_INT32_TWO = 0x02000000 IPV6_ADDR_INT32_MNL = 0x000001ff IPV6_ADDR_INT32_MLL = 0x000002ff IPV6_ADDR_INT32_SMP = (-65536) IPV6_ADDR_INT16_ULL = 0x80fe IPV6_ADDR_INT16_USL = 0xc0fe IPV6_ADDR_INT16_MLL = 0x02ff def IN6_IS_ADDR_UNSPECIFIED(a): return \ def IN6_IS_ADDR_LOOPBACK(a): return \ def IN6_IS_ADDR_V4COMPAT(a): return \ def IN6_IS_ADDR_V4MAPPED(a): return \ IPV6_ADDR_SCOPE_NODELOCAL = 0x01 IPV6_ADDR_SCOPE_INTFACELOCAL = 0x01 IPV6_ADDR_SCOPE_LINKLOCAL = 0x02 IPV6_ADDR_SCOPE_SITELOCAL = 0x05 IPV6_ADDR_SCOPE_ORGLOCAL = 0x08 IPV6_ADDR_SCOPE_GLOBAL = 0x0e __IPV6_ADDR_SCOPE_NODELOCAL = 0x01 __IPV6_ADDR_SCOPE_INTFACELOCAL = 0x01 __IPV6_ADDR_SCOPE_LINKLOCAL = 0x02 __IPV6_ADDR_SCOPE_SITELOCAL = 0x05 __IPV6_ADDR_SCOPE_ORGLOCAL = 0x08 __IPV6_ADDR_SCOPE_GLOBAL = 0x0e def IN6_IS_ADDR_LINKLOCAL(a): return \ def IN6_IS_ADDR_SITELOCAL(a): return \ def IN6_IS_ADDR_MC_NODELOCAL(a): return \ def IN6_IS_ADDR_MC_INTFACELOCAL(a): return \ def IN6_IS_ADDR_MC_LINKLOCAL(a): return \ def IN6_IS_ADDR_MC_SITELOCAL(a): return \ def IN6_IS_ADDR_MC_ORGLOCAL(a): return \ def IN6_IS_ADDR_MC_GLOBAL(a): return \ def IN6_IS_ADDR_MC_NODELOCAL(a): return \ def IN6_IS_ADDR_MC_LINKLOCAL(a): return \ def IN6_IS_ADDR_MC_SITELOCAL(a): return \ def IN6_IS_ADDR_MC_ORGLOCAL(a): return \ def IN6_IS_ADDR_MC_GLOBAL(a): return \ def IN6_IS_SCOPE_LINKLOCAL(a): return \ def IFA6_IS_DEPRECATED(a): return \ def IFA6_IS_INVALID(a): return \ IPV6_OPTIONS = 1 IPV6_RECVOPTS = 5 IPV6_RECVRETOPTS = 6 IPV6_RECVDSTADDR = 7 IPV6_RETOPTS = 8 IPV6_SOCKOPT_RESERVED1 = 3 IPV6_UNICAST_HOPS = 4 IPV6_MULTICAST_IF = 9 IPV6_MULTICAST_HOPS = 10 IPV6_MULTICAST_LOOP = 11 IPV6_JOIN_GROUP = 12 IPV6_LEAVE_GROUP = 13 IPV6_PORTRANGE = 14 ICMP6_FILTER = 18 IPV6_2292PKTINFO = 19 IPV6_2292HOPLIMIT = 20 IPV6_2292NEXTHOP = 21 IPV6_2292HOPOPTS = 22 IPV6_2292DSTOPTS = 23 IPV6_2292RTHDR = 24 IPV6_2292PKTOPTIONS = 25 IPV6_CHECKSUM = 26 IPV6_V6ONLY = 27 IPV6_BINDV6ONLY = IPV6_V6ONLY IPV6_IPSEC_POLICY = 28 IPV6_FAITH = 29 IPV6_FW_ADD = 30 IPV6_FW_DEL = 31 IPV6_FW_FLUSH = 32 IPV6_FW_ZERO = 33 IPV6_FW_GET = 34 IPV6_RTHDRDSTOPTS = 35 IPV6_RECVPKTINFO = 36 IPV6_RECVHOPLIMIT = 37 IPV6_RECVRTHDR = 38 IPV6_RECVHOPOPTS = 39 IPV6_RECVDSTOPTS = 40 IPV6_RECVRTHDRDSTOPTS = 41 IPV6_USE_MIN_MTU = 42 IPV6_RECVPATHMTU = 43 IPV6_PATHMTU = 44 IPV6_REACHCONF = 45 IPV6_PKTINFO = 46 IPV6_HOPLIMIT = 47 IPV6_NEXTHOP = 48 IPV6_HOPOPTS = 49 IPV6_DSTOPTS = 50 IPV6_RTHDR = 51 IPV6_PKTOPTIONS = 52 IPV6_RECVTCLASS = 57 IPV6_AUTOFLOWLABEL = 59 IPV6_TCLASS = 61 IPV6_DONTFRAG = 62 IPV6_PREFER_TEMPADDR = 63 IPV6_RTHDR_LOOSE = 0 IPV6_RTHDR_STRICT = 1 IPV6_RTHDR_TYPE_0 = 0 IPV6_DEFAULT_MULTICAST_HOPS = 1 IPV6_DEFAULT_MULTICAST_LOOP = 1 IPV6_PORTRANGE_DEFAULT = 0 IPV6_PORTRANGE_HIGH = 1 IPV6_PORTRANGE_LOW = 2 IPV6PROTO_MAXID = (IPPROTO_PIM + 1) IPV6CTL_FORWARDING = 1 IPV6CTL_SENDREDIRECTS = 2 IPV6CTL_DEFHLIM = 3 IPV6CTL_DEFMTU = 4 IPV6CTL_FORWSRCRT = 5 IPV6CTL_STATS = 6 IPV6CTL_MRTSTATS = 7 IPV6CTL_MRTPROTO = 8 IPV6CTL_MAXFRAGPACKETS = 9 IPV6CTL_SOURCECHECK = 10 IPV6CTL_SOURCECHECK_LOGINT = 11 IPV6CTL_ACCEPT_RTADV = 12 IPV6CTL_KEEPFAITH = 13 IPV6CTL_LOG_INTERVAL = 14 IPV6CTL_HDRNESTLIMIT = 15 IPV6CTL_DAD_COUNT = 16 IPV6CTL_AUTO_FLOWLABEL = 17 IPV6CTL_DEFMCASTHLIM = 18 IPV6CTL_GIF_HLIM = 19 IPV6CTL_KAME_VERSION = 20 IPV6CTL_USE_DEPRECATED = 21 IPV6CTL_RR_PRUNE = 22 IPV6CTL_MAPPED_ADDR = 23 IPV6CTL_V6ONLY = 24 IPV6CTL_RTEXPIRE = 25 IPV6CTL_RTMINEXPIRE = 26 IPV6CTL_RTMAXCACHE = 27 IPV6CTL_USETEMPADDR = 32 IPV6CTL_TEMPPLTIME = 33 IPV6CTL_TEMPVLTIME = 34 IPV6CTL_AUTO_LINKLOCAL = 35 IPV6CTL_RIP6STATS = 36 IPV6CTL_PREFER_TEMPADDR = 37 IPV6CTL_ADDRCTLPOLICY = 38 IPV6CTL_MAXFRAGS = 41 IPV6CTL_MAXID = 42 --- NEW FILE: regen --- #! /bin/sh set -v python ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h From loewis at users.sourceforge.net Wed Aug 18 19:47:44 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 18 19:47:47 2004 Subject: [Python-checkins] python/dist/src/Lib/lib-tk tkFont.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2172 Modified Files: tkFont.py Log Message: Expand tabs. Index: tkFont.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/tkFont.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tkFont.py 18 Aug 2004 11:06:44 -0000 1.6 --- tkFont.py 18 Aug 2004 17:47:40 -0000 1.7 *************** *** 92,96 **** # if font config info supplied, apply it if font: ! print "font=%r" % font root.tk.call("font", "configure", self.name, *font) else: --- 92,96 ---- # if font config info supplied, apply it if font: ! print "font=%r" % font root.tk.call("font", "configure", self.name, *font) else: From doko at users.sourceforge.net Thu Aug 19 00:17:47 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Thu Aug 19 00:17:50 2004 Subject: [Python-checkins] python/dist/src/Doc Makefile,1.275,1.276 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24314/Doc Modified Files: Makefile Log Message: Remove zero-byte gif files from generated html docs Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.275 retrieving revision 1.276 diff -C2 -d -r1.275 -r1.276 *** Makefile 11 Jul 2004 04:10:14 -0000 1.275 --- Makefile 18 Aug 2004 22:17:44 -0000 1.276 *************** *** 621,624 **** --- 621,625 ---- html-$(RELEASE).tar: $(ALLHTMLFILES) $(HTMLCSSFILES) mkdir Python-Docs-$(RELEASE) + -find html -name '*.gif' -size 0 | xargs rm -f cd html && tar cf ../temp.tar $(HTMLPKGFILES) cd Python-Docs-$(RELEASE) && tar xf ../temp.tar From doko at users.sourceforge.net Thu Aug 19 00:27:07 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Thu Aug 19 00:27:10 2004 Subject: [Python-checkins] python/dist/src/Doc Makefile,1.276,1.277 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26034/Doc Modified Files: Makefile Log Message: Remove commented definition of the MKHOWTO macro. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.276 retrieving revision 1.277 diff -C2 -d -r1.276 -r1.277 *** Makefile 18 Aug 2004 22:17:44 -0000 1.276 --- Makefile 18 Aug 2004 22:27:04 -0000 1.277 *************** *** 98,102 **** # the Python CVS trunk. MKHOWTO= TEXINPUTS=$(TEXINPUTS) $(PYTHON) $(PWD)/tools/mkhowto - #MKHOWTO= TEXINPUTS=$(TEXINPUTS) mkhowto MKDVI= $(MKHOWTO) --paper=$(PAPER) --dvi --- 98,101 ---- From fdrake at users.sourceforge.net Thu Aug 19 03:37:51 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Aug 19 03:37:54 2004 Subject: [Python-checkins] python/dist/src/Doc/perl l2hinit.perl,1.81,1.82 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24600 Modified Files: l2hinit.perl Log Message: fix SF bug #1008690: Incorrect href in Tutorial The make_head_and_body() function used a hardcoded value for the element for the index; this patch causes the proper output filename to be captured during the transformation phase so it can be used during the page assembly phase. Index: l2hinit.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/l2hinit.perl,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** l2hinit.perl 13 Jan 2004 23:43:58 -0000 1.81 --- l2hinit.perl 19 Aug 2004 01:37:48 -0000 1.82 *************** *** 486,489 **** --- 486,492 ---- } + $GENERAL_INDEX_FILE = ''; + $MODULE_INDEX_FILE = ''; + # $idx_mark will be replaced with the real index at the end sub do_cmd_textohtmlindex { *************** *** 491,494 **** --- 494,498 ---- $TITLE = $idx_title; $idxfile = $CURRENT_FILE; + $GENERAL_INDEX_FILE = "$CURRENT_FILE"; if (%index_labels) { make_index_labels(); } if (($SHORT_INDEX) && (%index_segment)) { make_preindex(); } *************** *** 500,505 **** } - $MODULE_INDEX_FILE = ''; - # $idx_module_mark will be replaced with the real index at the end sub do_cmd_textohtmlmoduleindex { --- 504,507 ---- *************** *** 683,692 **** : ''), ($HAVE_GENERAL_INDEX ! ? "\n" : ''), # disable for now -- Mozilla doesn't do well with multiple indexes # ($HAVE_MODULE_INDEX ! # ? '\n" # : ''), ($INFO --- 685,695 ---- : ''), ($HAVE_GENERAL_INDEX ! ? ("\n") : ''), # disable for now -- Mozilla doesn't do well with multiple indexes # ($HAVE_MODULE_INDEX ! # ? ("\n") # : ''), ($INFO From bcannon at users.sourceforge.net Thu Aug 19 05:48:28 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Aug 19 05:48:31 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_decorators.py, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9244/Lib/test Modified Files: test_decorators.py Log Message: Rewrite test_order so as to be more "proper". Originally relied on an error based on decorating with staticmethod too soon for the code to execute. This meant that if the test didn't pass it just errored out. Now if the test doesn't pass it leads to a failure instead. Index: test_decorators.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decorators.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_decorators.py 17 Aug 2004 17:29:15 -0000 1.5 --- test_decorators.py 19 Aug 2004 03:48:24 -0000 1.6 *************** *** 192,202 **** def test_order(self): ! class C(object): ! @staticmethod ! @funcattrs(abc=1) ! def foo(): return 42 ! # This wouldn't work if staticmethod was called first ! self.assertEqual(C.foo(), 42) ! self.assertEqual(C().foo(), 42) def test_eval_order(self): --- 192,208 ---- def test_order(self): ! # Test that decorators are applied in the proper order to the function ! # they are decorating. ! def callnum(num): ! """Decorator factory that returns a decorator that replaces the ! passed-in function with one that returns the value of 'num'""" ! def deco(func): ! return lambda: num ! return deco ! @callnum(2) ! @callnum(1) ! def foo(): return 42 ! self.assertEqual(foo(), 2, ! "Application order of decorators is incorrect") def test_eval_order(self): From tim_one at users.sourceforge.net Thu Aug 19 08:49:35 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 19 08:49:40 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.66,1.67 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3017/Lib Modified Files: doctest.py Log Message: ELLIPSIS implementation: an ellipsis couldn't match nothing if it appeared at the end of a line. Repaired that. Also noted that it's too easy to provoke this implementation into requiring exponential time, and especially when a test fails. I'll replace the implementation with an always-efficient one later. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** doctest.py 17 Aug 2004 16:37:12 -0000 1.66 --- doctest.py 19 Aug 2004 06:49:33 -0000 1.67 *************** *** 1469,1473 **** # contents of whitespace strings. Note that this can be used # in conjunction with the ELLISPIS flag. ! if (optionflags & NORMALIZE_WHITESPACE): got = ' '.join(got.split()) want = ' '.join(want.split()) --- 1469,1473 ---- # contents of whitespace strings. Note that this can be used # in conjunction with the ELLISPIS flag. ! if optionflags & NORMALIZE_WHITESPACE: got = ' '.join(got.split()) want = ' '.join(want.split()) *************** *** 1478,1485 **** # match any substring in `got`. We implement this by # transforming `want` into a regular expression. ! if (optionflags & ELLIPSIS): # Escape any special regexp characters ! want_re = re.escape(want) ! # Replace ellipsis markers ('...') with .* want_re = want_re.replace(re.escape(ELLIPSIS_MARKER), '.*') # Require that it matches the entire string; and set the --- 1478,1489 ---- # match any substring in `got`. We implement this by # transforming `want` into a regular expression. ! if optionflags & ELLIPSIS: ! # Remove \n from ...\n, else the newline will be required, ! # and (for example) ... on a line by itself can't match ! # nothing gracefully. ! want_re = want.replace(ELLIPSIS_MARKER + '\n', ELLIPSIS_MARKER) # Escape any special regexp characters ! want_re = re.escape(want_re) ! # Replace escaped ellipsis markers ('\.\.\.') with .* want_re = want_re.replace(re.escape(ELLIPSIS_MARKER), '.*') # Require that it matches the entire string; and set the From tim_one at users.sourceforge.net Thu Aug 19 08:49:36 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 19 08:49:42 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3017/Lib/test Modified Files: test_doctest.py Log Message: ELLIPSIS implementation: an ellipsis couldn't match nothing if it appeared at the end of a line. Repaired that. Also noted that it's too easy to provoke this implementation into requiring exponential time, and especially when a test fails. I'll replace the implementation with an always-efficient one later. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** test_doctest.py 17 Aug 2004 16:37:12 -0000 1.21 --- test_doctest.py 19 Aug 2004 06:49:33 -0000 1.22 *************** *** 781,784 **** --- 781,807 ---- (0, 1) + ... should also match nothing gracefully: + XXX This can be provoked into requiring exponential time by adding more + XXX ellipses; the implementation should change. It's much easier to + XXX provoke exponential time with expected output that doesn't match, + XXX BTW (then multiple regexp .* thingies each try all possiblities, + XXX multiplicatively, without hope of success). That's the real danger, + XXX that a failing test will appear to be hung. + + >>> for i in range(100): + ... print i**2 #doctest: +ELLIPSIS + 0 + ... + 1 + ... + 36 + ... + ... + 49 + 64 + ...... + 9801 + ... + The UNIFIED_DIFF flag causes failures that involve multi-line expected and actual outputs to be displayed using a unified diff: From anthonybaxter at users.sourceforge.net Thu Aug 19 09:06:15 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Aug 19 09:06:19 2004 Subject: [Python-checkins] python/nondist/peps pep-0006.txt,1.10,1.11 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5799 Modified Files: pep-0006.txt Log Message: updated bugfix PEP Index: pep-0006.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0006.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pep-0006.txt 13 May 2004 12:00:45 -0000 1.10 --- pep-0006.txt 19 Aug 2004 07:06:12 -0000 1.11 *************** *** 2,10 **** Title: Bug Fix Releases Version: $Revision$ ! Author: aahz@pobox.com (Aahz) Status: Active Type: Informational Created: 15-Mar-2001 ! Post-History: 15-Mar-2001 18-Apr-2001 --- 2,10 ---- Title: Bug Fix Releases Version: $Revision$ ! Author: aahz@pobox.com (Aahz), anthony@interlink.com.au (Anthony Baxter) Status: Active Type: Informational Created: 15-Mar-2001 ! Post-History: 15-Mar-2001 18-Apr-2001 19-Aug-2004 *************** *** 14,23 **** with releases having the combined purpose of adding new features and delivering bug fixes (these kinds of releases will be referred ! to as "feature releases"). This PEP describes how to fork off ! patch releases of old versions for the primary purpose of fixing ! bugs. ! This PEP is not, repeat NOT, a guarantee of the existence of patch ! releases; it only specifies a procedure to be followed if patch releases are desired by enough of the Python community willing to do the work. --- 14,23 ---- with releases having the combined purpose of adding new features and delivering bug fixes (these kinds of releases will be referred ! to as "major releases"). This PEP describes how to fork off ! maintenance, or bug fix, releases of old versions for the primary ! purpose of fixing bugs. ! This PEP is not, repeat NOT, a guarantee of the existence of bug fix ! releases; it only specifies a procedure to be followed if bug fix releases are desired by enough of the Python community willing to do the work. *************** *** 32,37 **** have been added, sometimes late in the development cycle. ! One solution for this issue is to maintain the previous feature ! release, providing bug fixes until the next feature release. This should make Python more attractive for enterprise development, where Python may need to be installed on hundreds or thousands of --- 32,37 ---- have been added, sometimes late in the development cycle. ! One solution for this issue is to maintain the previous major ! release, providing bug fixes until the next major release. This should make Python more attractive for enterprise development, where Python may need to be installed on hundreds or thousands of *************** *** 41,100 **** Prohibitions ! Patch releases are required to adhere to the following restrictions: 1. There must be zero syntax changes. All .pyc and .pyo files ! must work (no regeneration needed) with all patch releases ! forked off from a feature release. 2. There must be zero pickle changes. 3. There must be no incompatible C API changes. All extensions ! must continue to work without recompiling in all patch releases ! in the same fork as a feature release. Breaking any of these prohibitions requires a BDFL proclamation ! (and a prominent warning in the release notes). Version Numbers ! Starting with Python 2.0, all feature releases are required to ! have a version number of the form X.Y; patch releases will always be ! of the form X.Y.Z. ! The current feature release under development is referred to as ! release N; the just-released feature version is referred to as ! N-1. Procedure ! The process for managing patch releases is modeled in part on the ! Tcl system [1]. ! The Patch Czar is the counterpart to the BDFL for patch releases. However, the BDFL and designated appointees retain veto power over ! individual patches. ! As individual patches get contributed to the feature release fork, ! each patch contributor is requested to consider whether the patch is ! a bug fix suitable for inclusion in a patch release. If the patch is ! considered suitable, the patch contributor will mail the SourceForge ! patch (bug fix?) number to the maintainers' mailing list. In addition, anyone from the Python community is free to suggest ! patches for inclusion. Patches may be submitted specifically for ! patch releases; they should follow the guidelines in PEP 3 [2]. ! ! The Patch Czar decides when there are a sufficient number of ! patches to warrant a release. The release gets packaged up, ! including a Windows installer, and made public. If any new bugs ! are found, they must be fixed immediately and a new patch release ! publicized (with an incremented version number). ! Patch releases are expected to occur at an interval of roughly one ! month. In general, only the N-1 release will be under active ! maintenance at any time. Patch Czar History --- 41,154 ---- Prohibitions ! Bug fix releases are required to adhere to the following restrictions: 1. There must be zero syntax changes. All .pyc and .pyo files ! must work (no regeneration needed) with all bugfix releases ! forked off from a major release. 2. There must be zero pickle changes. 3. There must be no incompatible C API changes. All extensions ! must continue to work without recompiling in all bugfix releases ! in the same fork as a major release. Breaking any of these prohibitions requires a BDFL proclamation ! (and a prominent warning in the release notes). ! ! Not-Quite-Prohibitions ! ! Where possible, bug fix releases should also: + 1. Have no new features. The purpose of a bug fix release is to + fix bugs, not add the latest and greatest whizzo feature from + the HEAD of the CVS root. + + 2. Be a painless upgrade. Users should feel confident that an + upgrade from 2.x.y to 2.x.(y+1) will not break their running + systems. This means that, unless it is necessary to fix a bug, + the standard library should not change behavior, or worse yet, + APIs. + + Applicability of Prohibitions + + The above prohibitions and not-quite-prohibitions apply both + for a final release to a bugfix release (for instance, 2.4 to + 2.4.1) and for one bugfix release to the next in a series + (for instance 2.4.1 to 2.4.2). + + Following the prohibitions listed in this PEP should help keep + the community happy that a bug fix release is a painless and safe + upgrade. + + Helping the Bug Fix Releases Happen + + Here's a few pointers on helping the bug fix release process along. + + 1. Backport bug fixes. If you fix a bug, and it seems appropriate, + port it to the CVS branch for the current bug fix release. If + you're unwilling or unable to backport it yourself, make a note + in the commit message, with words like 'Bugfix candidate' or + 'Backport candidate'. + + 2. If you're not sure, ask. Ask the person managing the current bug + fix releases if they think a particular fix is appropriate. + + 3. If there's a particular bug you'd particularly like fixed in a + bug fix release, jump up and down and try to get it done. Do not + wait until 48 hours before a bug fix release is due, and then + start asking for bug fixes to be included. Version Numbers ! Starting with Python 2.0, all major releases are required to have ! a version number of the form X.Y; bugfix releases will always be of ! the form X.Y.Z. ! The current major release under development is referred to as ! release N; the just-released major version is referred to as N-1. + In CVS, the bug fix releases happen on a branch. For release 2.x, + the branch is named 'release2x-maint'. For example, the branch for + the 2.3 maintenance releases is release23-maint Procedure ! The process for managing bugfix releases is modeled in part on the Tcl ! system [1]. ! The Patch Czar is the counterpart to the BDFL for bugfix releases. However, the BDFL and designated appointees retain veto power over ! individual patches. A Patch Czar might only be looking after a single ! branch of development - it's quite possible that a different person ! might be maintaining the 2.3.x and the 2.4.x releases. ! As individual patches get contributed to the current trunk of CVS, ! each patch committer is requested to consider whether the patch is ! a bug fix suitable for inclusion in a bugfix release. If the patch is ! considered suitable, the committer can either commit the release to ! the maintenance branch, or else mark the patch in the commit message. In addition, anyone from the Python community is free to suggest ! patches for inclusion. Patches may be submitted specifically for ! bugfix releases; they should follow the guidelines in PEP 3 [2]. ! In general, though, it's probably better that a bug in a specific ! release also be fixed on the HEAD as well as the branch. ! The Patch Czar decides when there are a sufficient number of patches ! to warrant a release. The release gets packaged up, including a ! Windows installer, and made public. If any new bugs are found, they ! must be fixed immediately and a new bugfix release publicized (with ! an incremented version number). For the 2.3.x cycle, the Patch Czar ! (Anthony) has been trying for a release approximately every six ! months, but this should not be considered binding in any way on ! any future releases. + Bug fix releases are expected to occur at an interval of roughly + six months. This is only a guideline, however - obviously, if a + major bug is found, a bugfix release may be appropriate sooner. In + general, only the N-1 release will be under active maintenance at + any time. That is, during Python 2.4's development, Python 2.3 gets + bugfix releases. If, however, someone qualified wishes to continue + the work to maintain an older release, they should be encouraged. Patch Czar History *************** *** 115,132 **** - Issues To Be Resolved - - What is the equivalent of python-dev for people who are - responsible for maintaining Python? (Aahz proposes either - python-patch or python-maint, hosted at either python.org or - xs4all.net.) - - Does SourceForge make it possible to maintain both separate and - combined bug lists for multiple forks? If not, how do we mark - bugs fixed in different forks? (Simplest is to simply generate a - new bug for each fork that it gets fixed in, referring back to the - main bug number for details.) - - History --- 169,172 ---- *************** *** 137,155 **** Following feedback from the BDFL and others, the draft PEP was ! written containing an expanded patch release cycle that permitted ! any previous feature release to obtain patches and also relaxed the strict bug fix requirement (mainly due to the example of PEP 235 [3], which could be argued as either a bug fix or a feature). Discussion then mostly moved to python-dev, where BDFL finally ! issued a proclamation basing the Python patch release process on Tcl's, which essentially returned to the original proposal in terms of being only the N-1 release and only bug fixes, but ! allowing multiple patch releases until release N is published. References ! [1] http://dev.scriptics.com:8080/cgi-bin/tct/tip/28.html [2] PEP 3, Guidelines for Handling Bug Reports, Hylton --- 177,197 ---- Following feedback from the BDFL and others, the draft PEP was ! written containing an expanded bugfix release cycle that permitted ! any previous major release to obtain patches and also relaxed the strict bug fix requirement (mainly due to the example of PEP 235 [3], which could be argued as either a bug fix or a feature). Discussion then mostly moved to python-dev, where BDFL finally ! issued a proclamation basing the Python bugfix release process on Tcl's, which essentially returned to the original proposal in terms of being only the N-1 release and only bug fixes, but ! allowing multiple bugfix releases until release N is published. + Anthony Baxter then took this PEP and revised it, based on + lessons from the 2.3 release cycle. References ! [1] http://www.tcl.tk/cgi-bin/tct/tip/28.html [2] PEP 3, Guidelines for Handling Bug Reports, Hylton From rhettinger at users.sourceforge.net Thu Aug 19 09:49:59 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Aug 19 09:50:02 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal/telco - New directory Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal/telco In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12873/telco Log Message: Directory /cvsroot/python/python/nondist/sandbox/decimal/telco added to the repository From rhettinger at users.sourceforge.net Thu Aug 19 09:53:31 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Aug 19 09:53:34 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal/telco EXPON180.1E6, NONE, 1.1 telco.py, NONE, 1.1 telco.testb, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal/telco In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13201/telco Added Files: EXPON180.1E6 telco.py telco.testb Log Message: Provide a python implementation of the Telco benchmark for measuring decimal performance across machines and against other implementations. --- NEW FILE: EXPON180.1E6 --- (This appears to be a binary file; contents omitted.) --- NEW FILE: telco.py --- (This appears to be a binary file; contents omitted.) --- NEW FILE: telco.testb --- (This appears to be a binary file; contents omitted.) From tim_one at users.sourceforge.net Thu Aug 19 10:10:10 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 19 10:10:12 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.22, 1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16095/Lib/test Modified Files: test_doctest.py Log Message: Replaced the ELLIPSIS implementation with a worst-case linear-time one. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** test_doctest.py 19 Aug 2004 06:49:33 -0000 1.22 --- test_doctest.py 19 Aug 2004 08:10:08 -0000 1.23 *************** *** 781,791 **** (0, 1) ! ... should also match nothing gracefully: ! XXX This can be provoked into requiring exponential time by adding more ! XXX ellipses; the implementation should change. It's much easier to ! XXX provoke exponential time with expected output that doesn't match, ! XXX BTW (then multiple regexp .* thingies each try all possiblities, ! XXX multiplicatively, without hope of success). That's the real danger, ! XXX that a failing test will appear to be hung. >>> for i in range(100): --- 781,786 ---- (0, 1) ! ... should also match nothing gracefully (note that a regular-expression ! implementation of ELLIPSIS would take a loooong time to match this one!): >>> for i in range(100): *************** *** 795,807 **** 1 ... 36 ... ... 49 64 ! ...... 9801 ... The UNIFIED_DIFF flag causes failures that involve multi-line expected and actual outputs to be displayed using a unified diff: --- 790,819 ---- 1 ... + ...... + ... 36 ... ... + ... 49 64 ! ......... 9801 ... + ... can be surprising; e.g., this test passes: + + >>> for i in range(21): #doctest: +ELLIPSIS + ... print i + 0 + 1 + 2 + ... + 1 + ... + 2 + ... + 0 + The UNIFIED_DIFF flag causes failures that involve multi-line expected and actual outputs to be displayed using a unified diff: From tim_one at users.sourceforge.net Thu Aug 19 10:10:10 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 19 10:10:14 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.67,1.68 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16095/Lib Modified Files: doctest.py Log Message: Replaced the ELLIPSIS implementation with a worst-case linear-time one. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** doctest.py 19 Aug 2004 06:49:33 -0000 1.67 --- doctest.py 19 Aug 2004 08:10:07 -0000 1.68 *************** *** 363,366 **** --- 363,410 ---- del self.softspace + # Worst-case linear-time ellipsis matching. + def ellipsis_match(want, got): + if ELLIPSIS_MARKER not in want: + return want == got + # Remove \n from ...\n, else the newline will be required, + # and (for example) ... on a line by itself can't match + # nothing gracefully. + want = want.replace(ELLIPSIS_MARKER + '\n', ELLIPSIS_MARKER) + # Find "the real" strings. + ws = want.split(ELLIPSIS_MARKER) + assert len(ws) >= 2 + # Match. In general, we only need to find the leftmost non-overlapping + # match for each piece. "Real strings" at the start or end of `want` + # are special cases. + w = ws[0] + if w: + # An ellipsis didn't start `want`. We need to match exactly + # at the start. + if not got.startswith(w): + return False + pos = len(w) + del ws[0] + else: + pos = 0 + + for w in ws: + # w may be '' at times, if there are consecutive ellipses, or + # due to an ellipsis at the start or end of `want`. That's OK. + # Search for an empty string succeeds, and doesn't change pos. + pos = got.find(w, pos) + if pos < 0: + return False + pos += len(w) + + # If `want` ended with an ellipsis, the tail matches anything. + if ws[-1] == '': + return True + # Else `want` ended with a real string. If the last real match + # exhausted `got`, we win. + if pos == len(got): + return True + # Else maybe we matched the last real string too early. + return got.endswith(ws[-1]) + ###################################################################### ## 2. Example & DocTest *************** *** 1476,1495 **** # The ELLIPSIS flag says to let the sequence "..." in `want` ! # match any substring in `got`. We implement this by ! # transforming `want` into a regular expression. if optionflags & ELLIPSIS: ! # Remove \n from ...\n, else the newline will be required, ! # and (for example) ... on a line by itself can't match ! # nothing gracefully. ! want_re = want.replace(ELLIPSIS_MARKER + '\n', ELLIPSIS_MARKER) ! # Escape any special regexp characters ! want_re = re.escape(want_re) ! # Replace escaped ellipsis markers ('\.\.\.') with .* ! want_re = want_re.replace(re.escape(ELLIPSIS_MARKER), '.*') ! # Require that it matches the entire string; and set the ! # re.DOTALL flag (with '(?s)'). ! want_re = '(?s)^%s$' % want_re ! # Check if the `want_re` regexp matches got. ! if re.match(want_re, got): return True --- 1520,1526 ---- # The ELLIPSIS flag says to let the sequence "..." in `want` ! # match any substring in `got`. if optionflags & ELLIPSIS: ! if ellipsis_match(want, got): return True From loewis at users.sourceforge.net Thu Aug 19 13:07:52 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 19 13:07:55 2004 Subject: [Python-checkins] python/dist/src/Modules main.c,1.82,1.83 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9512/Modules Modified Files: main.c Log Message: Patch #1011822: Display errno/strerror for inaccessible files. Index: main.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/main.c,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** main.c 1 Mar 2004 15:44:05 -0000 1.82 --- main.c 19 Aug 2004 11:07:49 -0000 1.83 *************** *** 303,308 **** if (filename != NULL) { if ((fp = fopen(filename, "r")) == NULL) { ! fprintf(stderr, "%s: can't open file '%s'\n", ! argv[0], filename); return 2; } --- 303,313 ---- if (filename != NULL) { if ((fp = fopen(filename, "r")) == NULL) { ! #ifdef HAVE_STRERROR ! fprintf(stderr, "%s: can't open file '%s': [Errno %d] %s\n", ! argv[0], filename, errno, strerror(errno)); ! #else ! fprintf(stderr, "%s: can't open file '%s': Errno %d\n", ! argv[0], filename, errno); ! #endif return 2; } From loewis at users.sourceforge.net Thu Aug 19 13:31:59 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 19 13:32:04 2004 Subject: [Python-checkins] python/dist/src/Include pythonrun.h,2.63,2.64 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13464/Include Modified Files: pythonrun.h Log Message: Patch #900727: Add Py_InitializeEx to allow embedding without signals. Index: pythonrun.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pythonrun.h,v retrieving revision 2.63 retrieving revision 2.64 diff -C2 -d -r2.63 -r2.64 *** pythonrun.h 9 Aug 2004 15:02:30 -0000 2.63 --- pythonrun.h 19 Aug 2004 11:31:56 -0000 2.64 *************** *** 24,27 **** --- 24,28 ---- PyAPI_FUNC(void) Py_Initialize(void); + PyAPI_FUNC(void) Py_InitializeEx(int); PyAPI_FUNC(void) Py_Finalize(void); PyAPI_FUNC(int) Py_IsInitialized(void); From loewis at users.sourceforge.net Thu Aug 19 13:32:02 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 19 13:32:07 2004 Subject: [Python-checkins] python/dist/src/Python pythonrun.c,2.207,2.208 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13464/Python Modified Files: pythonrun.c Log Message: Patch #900727: Add Py_InitializeEx to allow embedding without signals. Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.207 retrieving revision 2.208 diff -C2 -d -r2.207 -r2.208 *** pythonrun.c 21 Jul 2004 05:35:02 -0000 2.207 --- pythonrun.c 19 Aug 2004 11:31:58 -0000 2.208 *************** *** 132,136 **** void ! Py_Initialize(void) { PyInterpreterState *interp; --- 132,136 ---- void ! Py_InitializeEx(int install_sigs) { PyInterpreterState *interp; *************** *** 209,213 **** _PyImportHooks_Init(); ! initsigs(); /* Signal handling stuff, including initintr() */ initmain(); /* Module __main__ */ --- 209,214 ---- _PyImportHooks_Init(); ! if (install_sigs) ! initsigs(); /* Signal handling stuff, including initintr() */ initmain(); /* Module __main__ */ *************** *** 277,280 **** --- 278,288 ---- } + void + Py_Initialize(void) + { + Py_InitializeEx(1); + } + + #ifdef COUNT_ALLOCS extern void dump_counts(void); From loewis at users.sourceforge.net Thu Aug 19 13:32:02 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 19 13:32:08 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1104,1.1105 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13464/Misc Modified Files: NEWS Log Message: Patch #900727: Add Py_InitializeEx to allow embedding without signals. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1104 retrieving revision 1.1105 diff -C2 -d -r1.1104 -r1.1105 *** NEWS 18 Aug 2004 15:13:41 -0000 1.1104 --- NEWS 19 Aug 2004 11:31:57 -0000 1.1105 *************** *** 13,16 **** --- 13,18 ---- ----------------- + - Py_InitializeEx has been added. + - Fix the order of application of decorators. The proper order is bottom-up; the first decorator listed is the last one called. From loewis at users.sourceforge.net Thu Aug 19 13:32:28 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 19 13:32:34 2004 Subject: [Python-checkins] python/dist/src/Doc/api init.tex,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13464/Doc/api Modified Files: init.tex Log Message: Patch #900727: Add Py_InitializeEx to allow embedding without signals. Index: init.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/init.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** init.tex 10 Jul 2004 13:48:54 -0000 1.19 --- init.tex 19 Aug 2004 11:31:55 -0000 1.20 *************** *** 24,27 **** --- 24,34 ---- \end{cfuncdesc} + \begin{cfuncdesc}{void}{Py_InitializeEx}{int initsigs} + This function works like \cfunction{Py_Initialize} if + \var{initsigs} is 1. If \var{initsigs} is 0, it skips + initialization registration of signal handlers, which + might be useful when Python is embedded. \versionadded{2.4} + \end{cfuncdesc} + \begin{cfuncdesc}{int}{Py_IsInitialized}{} Return true (nonzero) when the Python interpreter has been From tim_one at users.sourceforge.net Thu Aug 19 16:06:23 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 19 16:06:26 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.68,1.69 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10535/Lib Modified Files: doctest.py Log Message: ellipsis_match(): Changed treatment of start- and end-of-string exact matches to be symmetric. This makes the algorithm easier to understand. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** doctest.py 19 Aug 2004 08:10:07 -0000 1.68 --- doctest.py 19 Aug 2004 14:06:20 -0000 1.69 *************** *** 365,368 **** --- 365,373 ---- # Worst-case linear-time ellipsis matching. def ellipsis_match(want, got): + """ + Essentially the only subtle case: + >>> ellipsis_match('aa...aa', 'aaa') + False + """ if ELLIPSIS_MARKER not in want: return want == got *************** *** 371,409 **** # nothing gracefully. want = want.replace(ELLIPSIS_MARKER + '\n', ELLIPSIS_MARKER) # Find "the real" strings. ws = want.split(ELLIPSIS_MARKER) assert len(ws) >= 2 ! # Match. In general, we only need to find the leftmost non-overlapping ! # match for each piece. "Real strings" at the start or end of `want` ! # are special cases. w = ws[0] ! if w: ! # An ellipsis didn't start `want`. We need to match exactly ! # at the start. ! if not got.startswith(w): return False ! pos = len(w) ! del ws[0] ! else: ! pos = 0 for w in ws: # w may be '' at times, if there are consecutive ellipses, or # due to an ellipsis at the start or end of `want`. That's OK. ! # Search for an empty string succeeds, and doesn't change pos. ! pos = got.find(w, pos) ! if pos < 0: return False ! pos += len(w) ! # If `want` ended with an ellipsis, the tail matches anything. ! if ws[-1] == '': ! return True ! # Else `want` ended with a real string. If the last real match ! # exhausted `got`, we win. ! if pos == len(got): ! return True ! # Else maybe we matched the last real string too early. ! return got.endswith(ws[-1]) ###################################################################### --- 376,419 ---- # nothing gracefully. want = want.replace(ELLIPSIS_MARKER + '\n', ELLIPSIS_MARKER) + # Find "the real" strings. ws = want.split(ELLIPSIS_MARKER) assert len(ws) >= 2 ! ! # Deal with exact matches possibly needed at one or both ends. ! startpos, endpos = 0, len(got) w = ws[0] ! if w: # starts with exact match ! if got.startswith(w): ! startpos = len(w) ! del ws[0] ! else: return False ! w = ws[-1] ! if w: # ends with exact match ! if got.endswith(w): ! endpos -= len(w) ! del ws[-1] ! else: ! return False ! ! if startpos > endpos: ! # Exact end matches required more characters than we have, as in ! # ellipsis_match('aa...aa', 'aaa') ! return False + # For the rest, we only need to find the leftmost non-overlapping + # match for each piece. If there's no overall match that way alone, + # there's no overall match period. for w in ws: # w may be '' at times, if there are consecutive ellipses, or # due to an ellipsis at the start or end of `want`. That's OK. ! # Search for an empty string succeeds, and doesn't change startpos. ! startpos = got.find(w, startpos, endpos) ! if startpos < 0: return False ! startpos += len(w) ! return True ###################################################################### From jlgijsbers at users.sourceforge.net Thu Aug 19 17:11:53 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Thu Aug 19 17:11:57 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_zipfile.py, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23093 Modified Files: test_zipfile.py Log Message: Port test_zipfile to unittest (patch #736962). Index: test_zipfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_zipfile.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_zipfile.py 27 Jun 2003 22:25:03 -0000 1.10 --- test_zipfile.py 19 Aug 2004 15:11:50 -0000 1.11 *************** *** 1,99 **** ! import zlib # implied prerequisite ! import zipfile, os, StringIO, tempfile ! from test.test_support import TestFailed ! srcname = "junk9630"+os.extsep+"tmp" ! zipname = "junk9708"+os.extsep+"tmp" ! def zipTest(f, compression, srccontents): ! zip = zipfile.ZipFile(f, "w", compression) # Create the ZIP archive ! zip.write(srcname, "another"+os.extsep+"name") ! zip.write(srcname, srcname) ! zip.close() ! zip = zipfile.ZipFile(f, "r", compression) # Read the ZIP archive ! readData2 = zip.read(srcname) ! readData1 = zip.read("another"+os.extsep+"name") ! zip.close() ! if readData1 != srccontents or readData2 != srccontents: ! raise TestFailed, "Written data doesn't equal read data." ! try: ! fp = open(srcname, "wb") # Make a source file with some lines ! for i in range(0, 1000): ! fp.write("Test of zipfile line %d.\n" % i) ! fp.close() ! fp = open(srcname, "rb") ! writtenData = fp.read() ! fp.close() ! for file in (zipname, tempfile.TemporaryFile(), StringIO.StringIO()): ! zipTest(file, zipfile.ZIP_STORED, writtenData) ! for file in (zipname, tempfile.TemporaryFile(), StringIO.StringIO()): ! zipTest(file, zipfile.ZIP_DEFLATED, writtenData) ! finally: ! if os.path.isfile(srcname): # Remove temporary files ! os.unlink(srcname) ! if os.path.isfile(zipname): ! os.unlink(zipname) ! # This test checks that the ZipFile constructor closes the file object ! # it opens if there's an error in the file. If it doesn't, the traceback ! # holds a reference to the ZipFile object and, indirectly, the file object. ! # On Windows, this causes the os.unlink() call to fail because the ! # underlying file is still open. This is SF bug #412214. ! # ! fp = open(srcname, "w") ! fp.write("this is not a legal zip file\n") ! fp.close() ! try: ! zf = zipfile.ZipFile(srcname) ! except zipfile.BadZipfile: ! os.unlink(srcname) ! # make sure we don't raise an AttributeError when a partially-constructed ! # ZipFile instance is finalized; this tests for regression on SF tracker ! # bug #403871. ! try: ! zipfile.ZipFile(srcname) ! except IOError: ! # The bug we're testing for caused an AttributeError to be raised ! # when a ZipFile instance was created for a file that did not ! # exist; the .fp member was not initialized but was needed by the ! # __del__() method. Since the AttributeError is in the __del__(), ! # it is ignored, but the user should be sufficiently annoyed by ! # the message on the output that regression will be noticed ! # quickly. ! pass ! else: ! raise TestFailed("expected creation of readable ZipFile without\n" ! " a file to raise an IOError.") ! # Verify that testzip() doesn't swallow inappropriate exceptions. ! data = StringIO.StringIO() ! zipf = zipfile.ZipFile(data, mode="w") ! zipf.writestr("foo.txt", "O, for a Muse of Fire!") ! zipf.close() ! zipf = zipfile.ZipFile(data, mode="r") ! zipf.close() ! try: ! zipf.testzip() ! except RuntimeError: ! # 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. ! pass ! else: ! raise TestFailed("expected calling .testzip on a closed ZipFile" ! " to raise a RuntimeError") ! del data, zipf --- 1,99 ---- ! # We can test part of the module without zlib. ! try: ! import zlib ! except ImportError: ! zlib = None ! ! import zipfile, os, unittest ! from StringIO import StringIO ! from tempfile import TemporaryFile + from test.test_support import TESTFN, run_unittest ! TESTFN2 = TESTFN + "2" ! class TestsWithSourceFile(unittest.TestCase): ! def setUp(self): ! line_gen = ("Test of zipfile line %d." % i for i in range(0, 1000)) ! self.data = '\n'.join(line_gen) ! # Make a source file with some lines ! fp = open(TESTFN, "wb") ! fp.write(self.data) ! fp.close() + def zipTest(self, f, compression): + # Create the ZIP archive + zipfp = zipfile.ZipFile(f, "w", compression) + zipfp.write(TESTFN, "another"+os.extsep+"name") + zipfp.write(TESTFN, TESTFN) + zipfp.close() ! # Read the ZIP archive ! zipfp = zipfile.ZipFile(f, "r", compression) ! self.assertEqual(zipfp.read(TESTFN), self.data) ! self.assertEqual(zipfp.read("another"+os.extsep+"name"), self.data) ! zipfp.close() ! def testStored(self): ! for f in (TESTFN2, TemporaryFile(), StringIO()): ! self.zipTest(f, zipfile.ZIP_STORED) ! if zlib: ! def testDeflated(self): ! for f in (TESTFN2, TemporaryFile(), StringIO()): ! self.zipTest(f, zipfile.ZIP_DEFLATED) ! def tearDown(self): ! os.remove(TESTFN) ! os.remove(TESTFN2) ! class OtherTests(unittest.TestCase): ! def testCloseErroneousFile(self): ! # This test checks that the ZipFile constructor closes the file object ! # it opens if there's an error in the file. If it doesn't, the traceback ! # holds a reference to the ZipFile object and, indirectly, the file object. ! # On Windows, this causes the os.unlink() call to fail because the ! # underlying file is still open. This is SF bug #412214. ! # ! fp = open(TESTFN, "w") ! fp.write("this is not a legal zip file\n") ! fp.close() ! try: ! zf = zipfile.ZipFile(TESTFN) ! except zipfile.BadZipfile: ! os.unlink(TESTFN) + def testNonExistentFileRaisesIOError(self): + # make sure we don't raise an AttributeError when a partially-constructed + # ZipFile instance is finalized; this tests for regression on SF tracker + # bug #403871. ! # The bug we're testing for caused an AttributeError to be raised ! # when a ZipFile instance was created for a file that did not ! # exist; the .fp member was not initialized but was needed by the ! # __del__() method. Since the AttributeError is in the __del__(), ! # it is ignored, but the user should be sufficiently annoyed by ! # the message on the output that regression will be noticed ! # quickly. ! self.assertRaises(IOError, zipfile.ZipFile, TESTFN) + def testClosedZipRaisesRuntimeError(self): + # Verify that testzip() doesn't swallow inappropriate exceptions. + data = StringIO() + zipf = zipfile.ZipFile(data, mode="w") + zipf.writestr("foo.txt", "O, for a Muse of Fire!") + zipf.close() ! # 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. ! self.assertRaises(RuntimeError, zipf.testzip) + def test_main(): + run_unittest(TestsWithSourceFile, OtherTests) ! if __name__ == "__main__": ! test_main() From anthonybaxter at users.sourceforge.net Thu Aug 19 17:36:17 2004 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Aug 19 17:36:20 2004 Subject: [Python-checkins] python/nondist/peps pep-0318.txt,1.21,1.22 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28238 Modified Files: pep-0318.txt Log Message: checking in work-in-progress. this is by no means finished - I will attack it some more this weekend and attempt to finish it. Please feel free to fill out any bits you think I've missed. See the WarningWarningWarning section at the top. Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** pep-0318.txt 12 Aug 2004 20:33:02 -0000 1.21 --- pep-0318.txt 19 Aug 2004 15:36:14 -0000 1.22 *************** *** 5,9 **** Author: Kevin D. Smith , Jim Jewett , ! Skip Montanaro Status: Draft Type: Standards Track --- 5,10 ---- Author: Kevin D. Smith , Jim Jewett , ! Skip Montanaro , ! Anthony Baxter Status: Draft Type: Standards Track *************** *** 14,25 **** Abstract ======== ! The current method for declaring class and static methods is awkward ! and can lead to code that is difficult to understand. Ideally, these ! transformations should be made at the same point in the code where the ! declaration itself is made. This PEP introduces new syntax for ! transformations of a declaration. --- 15,37 ---- + WarningWarningWarning + ===================== + + This is not yet complete. This is still a work-in-progress. Feedback + to anthony. Please note that the point of this PEP is _not_ to provide + an open-slather of plusses and minuses for each syntax, but is instead + to justify the choice made. If, in 2.4a3, the syntax is changed, the + PEP will be updated to match this, complete with the arguments for the + change. + Abstract ======== ! The current method for transforming functions and methods (for instance, ! declaring them as a class or static method) is awkward and can lead to ! code that is difficult to understand. Ideally, these transformations ! should be made at the same point in the code where the declaration ! itself is made. This PEP introduces new syntax for transformations of a ! function or method declaration. *************** *** 62,67 **** metaclasses, but using metaclasses is sufficiently obscure that there is some attraction to having an easier way to make simple ! modifications to classes. For Python 2.4, only function decorators ! are being added. --- 74,79 ---- metaclasses, but using metaclasses is sufficiently obscure that there is some attraction to having an easier way to make simple ! modifications to classes. For Python 2.4, only function/method ! decorators are being added. *************** *** 75,79 **** extensions he proposed there "semi-jokingly". `Michael Hudson raised the topic`_ on ``python-dev`` shortly after the conference, ! attributing the bracketed syntax to an earlier proposal on ``comp.lang.python`` by `Gareth McCaughan`_. --- 87,91 ---- extensions he proposed there "semi-jokingly". `Michael Hudson raised the topic`_ on ``python-dev`` shortly after the conference, ! attributing the initial bracketed syntax to an earlier proposal on ``comp.lang.python`` by `Gareth McCaughan`_. *************** *** 93,100 **** The discussion continued on and off on python-dev from February 2002 ! through July 2004. Many hundreds of posts were made, with people proposing many possible syntax variations. Guido took a list of proposals to `EuroPython 2004`_, where a discussion took place. ! Subsequent to this, he decided that for 2.4a2 we'd have the Java-style @decorator syntax. Barry Warsaw named this the 'pie-decorator' syntax, in honor of the Pie-thon Parrot shootout which was announced --- 105,112 ---- The discussion continued on and off on python-dev from February 2002 ! through July 2004. Hundreds and hundreds of posts were made, with people proposing many possible syntax variations. Guido took a list of proposals to `EuroPython 2004`_, where a discussion took place. ! Subsequent to this, he decided that for 2.4a2 we'd have the `Java-style`_ @decorator syntax. Barry Warsaw named this the 'pie-decorator' syntax, in honor of the Pie-thon Parrot shootout which was announced *************** *** 112,115 **** --- 124,142 ---- http://mail.python.org/pipermail/python-dev/2004-August/046672.html + .. Java-style: + http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html + + On the name 'Decorator' + ======================= + + There's been a number of complaints about the choice of the name + 'decorator' for this feature. The major one is that the name is + not consistent with it's use in the `GoF book`_. The name 'decorator' + probably owes more to it's use in the compiler area - a syntax tree + is walked and annotated. It's quite possible that a better name may + turn up. + + .. GoF book: + http://patterndigest.com/patterns/Decorator.html Design Goals *************** *** 140,154 **** there`_" .. _toy parser tools out there: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=mailman.1010809396.32158.python-list%40python.org Andrew Kuchling has links to a bunch of the discussions about motivations ! `in his blog`_. .. _in his blog: http://www.amk.ca/diary/archives/cat_python.html#003255 ! Proposed Syntax ! =============== The current syntax for function decorators as implemented in Python --- 167,191 ---- there`_" + * move from the end of the function, where it's currently hidden, to + the front where it is more `in your face`_ + .. _toy parser tools out there: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=mailman.1010809396.32158.python-list%40python.org + .. in your face: + http://mail.python.org/pipermail/python-dev/2004-August/047112.html + Andrew Kuchling has links to a bunch of the discussions about motivations ! and use cases `in his blog`_. Particularly notable is `Jim Huginin's list ! of use cases`_. .. _in his blog: http://www.amk.ca/diary/archives/cat_python.html#003255 ! .. _Jim Huginin's list of use cases: ! http://mail.python.org/pipermail/python-dev/2004-April/044132.html ! ! Current Syntax ! ============== The current syntax for function decorators as implemented in Python *************** *** 176,183 **** --- 213,388 ---- http://mail.python.org/pipermail/python-dev/2004-August/046711.html + Syntax Alternatives + =================== + + There have been `a large number`_ of different syntaxes proposed - rather + than attempting to work through these individual syntaxes, it's worthwhile + to break the syntax discussion down into a number of areas. Attempting to + discuss `each possible syntax`_ individually would be an act of madness, + and produce a completely unwieldly PEP. + + .. a large number: + http://www.python.org/moin/PythonDecorators + .. each possible syntax: + http://ucsu.colorado.edu/~bethard/py/decorators-output.py + + Decorator Location + ------------------ + + The first syntax point is the location of the decorators. For the + following examples, we use the @syntax used in 2.4a2. + + Decorators before the def statement are the first alternative, + and the syntax used in 2.4a2:: + + @classmethod + def foo(arg1,arg2): + pass + + @accepts(int,int) + @returns(float) + def bar(low,high): + pass + + There have been a number of objections raised to this location - + the primary one is that it's the first real Python case where a + line of code has a result on a following line. The syntax that + will be in 2.4a3 will also require one decorator per line (in a2, + multiple decorators can be specified on the same line). + + Some of the advantages of this form are that the decorators live + outside the method body - they are obviously executed at the time + the function is defined + + The second form is the decorators between the def and the function + name, or the function name and the argument list:: + + def @classmethod foo(arg1,arg2): + pass + + def @accepts(int,int),@returns(float) bar(low,high): + pass + + def foo @classmethod (arg1,arg2): + pass + + def bar @accepts(int,int),@returns(float) (low,high): + pass + + There are a couple of objections to this form. + The first is that it breaks easily 'greppability' of the source - you + can no longer search for 'def foo(' and find the definition of the + function. The second, more serious, objection is that in the case + of multiple decorators, the syntax would be extremely unwieldy. + + The next form, which has had a number of strong proponents, is to + have the decorators between the argument list and the trailing ``:`` + in the 'def' line:: + + def foo(arg1,arg2) @classmethod: + pass + + def bar(low,high) @accepts(int,int),@returns(float): + pass + + Guido `summarised the arguments`_ against this form (many of which + also apply to the previous form) as: + + - it hides crucial information (e.g. that it is a static method) + after the signature, where it is easily missed + + - it's easy to miss the transition between a long argument list and a + long decorator list + + - it's cumbersome to cut and paste a decorator list for reuse, because + it starts and ends in the middle of a line + + .. summarised the arguments: + http://mail.python.org/pipermail/python-dev/2004-August/047112.html + + The next form is that the decorator syntax go inside the method + body at the start, in the same place that docstrings currently + live: + + def foo(arg1,arg2): + @classmethod + pass + + def bar(low,high): + @accepts(int,int) + @returns(float) + pass + + The primary objection to this form is that it requires "peeking inside" + the method body to determine the decorators. In addition, even though + the code is inside the method body, it is not executed when the method + is run. Guido felt that docstrings were not a good counter-example, and + that it was quite possible that a 'docstring' decorator could help move + the docstring to outside the function body. + + The final form is a new block that encloses the method's code. For this + example, we'll use a 'decorate' keyword, as it makes no sense with the + @syntax. + + decorate: + classmethod + def foo(arg1,arg2): + pass + + decorate: + accepts(int,int) + returns(float) + def bar(low,high): + pass + + This form would result in inconsistent indentation for decorated and + undecorated methods. In addition, a decorated method's body would start + three indent levels in. + + Syntax forms + ------------ + + @decorator + + The major objections against this syntax are that the @ symbol + is not currently used in Python (and is used in both IPython and + Leo), that the @ symbol is not meaningful, + + |decorator + + This is a variant on the @decorator syntax - it has the advantage + that it does not break IPython and Leo. It's major disadvantage + compared to the @syntax is that the | symbol looks like both a + capital I and a lowercase l. + + * list syntax + + The major objection to the list syntax is that it's currently + meaningful (when used in the form before the method). It's also + lacking any indication that the expression is a decorator. + + * list syntax using other brackets ( <...>, [[...]], ... ) + + + * decorate() + + The decorate() proposal was that no new syntax be implemented - + instead a magic function that used introspection to manipulate + the following function. Both Jp Calderone and Philip Eby produced + implementations of functions that did this. Guido was pretty firmly + against this - with no new syntax, the magicness of a function like + this is extremely high. + + * new keyword (and block) + + Alternate Proposals =================== + The text in this section will be integrated into the previous section. + They're here for hysterical raisins for now. + + Several other syntaxes have been proposed:: *************** *** 301,305 **** There is some history in Java using @ initially as a marker in ! `Javadoc comments`_ and later in ... mumble mumble ... The fact that @ was previously unused as a token in Python also means it's clear there is no possibility of such code being parsed by an earlier --- 506,511 ---- There is some history in Java using @ initially as a marker in ! `Javadoc comments`_ and later in Java 1.5 for `annotations`_, ! which are similar to Python decorators. The fact that @ was previously unused as a token in Python also means it's clear there is no possibility of such code being parsed by an earlier *************** *** 321,324 **** --- 527,533 ---- http://java.sun.com/j2se/javadoc/writingdoccomments/ + .. annotations: + http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html + Current Implementation ====================== From tim_one at users.sourceforge.net Thu Aug 19 18:39:00 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 19 18:39:04 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.23, 1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7200/Lib/test Modified Files: test_doctest.py Log Message: Now that they've settled down, document doctest directives. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** test_doctest.py 19 Aug 2004 08:10:08 -0000 1.23 --- test_doctest.py 19 Aug 2004 16:38:57 -0000 1.24 *************** *** 759,762 **** --- 759,767 ---- (0, 1) + An example from the docs: + >>> 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] + The ELLIPSIS flag causes ellipsis marker ("...") in the expected output to match any substring in the actual output: *************** *** 781,786 **** (0, 1) ! ... should also match nothing gracefully (note that a regular-expression ! implementation of ELLIPSIS would take a loooong time to match this one!): >>> for i in range(100): --- 786,791 ---- (0, 1) ! ... should also match nothing gracefully (note that a regular-expression ! implementation of ELLIPSIS would take a loooong time to match this one!): >>> for i in range(100): *************** *** 802,806 **** ... ! ... can be surprising; e.g., this test passes: >>> for i in range(21): #doctest: +ELLIPSIS --- 807,811 ---- ... ! ... can be surprising; e.g., this test passes: >>> for i in range(21): #doctest: +ELLIPSIS *************** *** 816,819 **** --- 821,833 ---- 0 + Examples from the docs: + + >>> print range(20) # doctest:+ELLIPSIS + [0, 1, ..., 18, 19] + + >>> print range(20) # doctest: +ELLIPSIS + ... # doctest: +NORMALIZE_WHITESPACE + [0, 1, ..., 18, 19] + The UNIFIED_DIFF flag causes failures that involve multi-line expected and actual outputs to be displayed using a unified diff: From tim_one at users.sourceforge.net Thu Aug 19 18:39:01 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 19 18:39:05 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7200/Doc/lib Modified Files: libdoctest.tex Log Message: Now that they've settled down, document doctest directives. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** libdoctest.tex 13 Aug 2004 21:55:21 -0000 1.27 --- libdoctest.tex 19 Aug 2004 16:38:58 -0000 1.28 *************** *** 299,308 **** ! \subsection{Option Flags and Directive Names\label{doctest-options}} A number of option flags control various aspects of doctest's comparison ! 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 doctest directives. \begin{datadesc}{DONT_ACCEPT_TRUE_FOR_1} --- 299,308 ---- ! \subsection{Option Flags and Directives\label{doctest-options}} A number of option flags control various aspects of doctest's comparison ! 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 doctest directives (see below). \begin{datadesc}{DONT_ACCEPT_TRUE_FOR_1} *************** *** 341,347 **** When specified, an ellipsis marker (\code{...}) in the expected output can match any substring in the actual output. This includes ! substrings that span line boundaries, so it's best to keep usage of ! this simple. Complicated uses can lead to the same kinds of ! surprises that \regexp{.*} is prone to in regular expressions. \end{datadesc} --- 341,348 ---- When specified, an ellipsis marker (\code{...}) in the expected output can match any substring in the actual output. This includes ! substrings that span line boundaries, and empty substrings, so it's ! best to keep usage of this simple. Complicated uses can lead to the ! same kinds of "oops, it matched too much!" surprises that \regexp{.*} ! is prone to in regular expressions. \end{datadesc} *************** *** 357,365 **** \versionchanged[Constants \constant{DONT_ACCEPT_BLANKLINE}, \constant{NORMALIZE_WHITESPACE}, \constant{ELLIPSIS}, \constant{UNIFIED_DIFF}, and \constant{CONTEXT_DIFF} ! were added, and by default \code{} in expected output ! matches an empty line in actual output]{2.4} \subsection{Advanced Usage} --- 358,423 ---- + A "doctest directive" is a trailing Python comment on a line of a doctest + example: + + \begin{productionlist}[doctest] + \production{directive} + {"#" "doctest:" \token{on_or_off} \token{directive_name}} + \production{on_or_off} + {"+" | "-"} + \production{directive_name} + {"DONT_ACCEPT_BLANKLINE" | "NORMALIZE_WHITESPACE" | ...} + \end{productionlist} + + Whitespace is not allowed between the \code{+} or \code{-} and the + directive name. The directive name can be any of the option names + explained above. + + The doctest directives appearing in a single example modify doctest's + behavior for that single example. Use \code{+} to enable the named + behavior, or \code{-} to disable it. + + For example, this test passes: + + \begin{verbatim} + >>> 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] + \end{verbatim} + + Without the directive it would fail, both because the actual output + doesn't have two blanks before the single-digit list elements, and + because the actual output is on a single line. This test also passes, + and requires a directive to do so: + + \begin{verbatim} + >>> print range(20) # doctest:+ELLIPSIS + [0, 1, ..., 18, 19] + \end{verbatim} + + Only one directive per physical line is accepted. If you want to + use multiple directives for a single example, you can add + \samp{...} lines to your example containing only directives: + + \begin{verbatim} + >>> print range(20) #doctest: +ELLIPSIS + ... #doctest: +NORMALIZE_WHITESPACE + [0, 1, ..., 18, 19] + \end{verbatim} + + Note that since all options are disabled by default, and directives apply + only to the example they appear in, enabling options (via \code{+} in a + directive) is usually the only meaningful choice. However, option flags + can also be passed to functions that run doctests, establishing different + defaults. In such cases, disabling an option via \code{-} in a directive + can be useful. + \versionchanged[Constants \constant{DONT_ACCEPT_BLANKLINE}, \constant{NORMALIZE_WHITESPACE}, \constant{ELLIPSIS}, \constant{UNIFIED_DIFF}, and \constant{CONTEXT_DIFF} ! were added; by default \code{} in expected output ! matches an empty line in actual output; and doctest directives ! were added]{2.4} ! \subsection{Advanced Usage} From perky at users.sourceforge.net Thu Aug 19 19:49:59 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Thu Aug 19 19:50:03 2004 Subject: [Python-checkins] python/dist/src/Modules/cjkcodecs README, 1.2, 1.3 _codecs_hk.c, 1.1, 1.2 _codecs_iso2022.c, 1.2, 1.3 cjkcodecs.h, 1.4, 1.5 multibytecodec.c, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules/cjkcodecs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19829 Modified Files: README _codecs_hk.c _codecs_iso2022.c cjkcodecs.h multibytecodec.c Log Message: Bug #1005737, #1007249: Fix several build problems and warnings found on legacy C compilers of HP-UX, IRIX and Tru64. (Reported by roadkill, Richard Townsend, Maik Hertha and Minsik Kim) Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cjkcodecs/README,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README 18 Jul 2004 03:06:27 -0000 1.2 --- README 19 Aug 2004 17:49:56 -0000 1.3 *************** *** 3,7 **** This directory contains source files for cjkcodecs extension modules. They are based on CJKCodecs (http://cjkpython.i18n.org/#CJKCodecs) ! as of Jul 18 2004 currently. --- 3,7 ---- This directory contains source files for cjkcodecs extension modules. They are based on CJKCodecs (http://cjkpython.i18n.org/#CJKCodecs) ! as of Aug 20 2004 currently. Index: _codecs_hk.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cjkcodecs/_codecs_hk.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** _codecs_hk.c 18 Jul 2004 03:06:27 -0000 1.1 --- _codecs_hk.c 19 Aug 2004 17:49:56 -0000 1.2 *************** *** 3,7 **** * * Written by Hye-Shik Chang ! * $CJKCodecs: _codecs_hk.c,v 1.3 2004/07/07 14:59:26 perky Exp $ */ --- 3,7 ---- * * Written by Hye-Shik Chang ! * $CJKCodecs: _codecs_hk.c,v 1.4 2004/07/18 04:44:27 perky Exp $ */ Index: _codecs_iso2022.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cjkcodecs/_codecs_iso2022.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** _codecs_iso2022.c 18 Jul 2004 04:34:33 -0000 1.2 --- _codecs_iso2022.c 19 Aug 2004 17:49:56 -0000 1.3 *************** *** 3,7 **** * * Written by Hye-Shik Chang ! * $CJKCodecs: _codecs_iso2022.c,v 1.18 2004/07/07 18:30:17 perky Exp $ */ --- 3,7 ---- * * Written by Hye-Shik Chang ! * $CJKCodecs: _codecs_iso2022.c,v 1.22 2004/08/19 17:08:13 perky Exp $ */ *************** *** 118,122 **** struct iso2022_config { int flags; ! const struct iso2022_designation designations[]; /* non-ascii desigs */ }; --- 118,122 ---- struct iso2022_config { int flags; ! const struct iso2022_designation *designations; /* non-ascii desigs */ }; *************** *** 198,202 **** #if Py_UNICODE_SIZE == 2 if (length == 2) { ! ucs4_t u4in[2] = {IN1, IN2}; encoded = dsg->encoder(u4in, &length); } else --- 198,204 ---- #if Py_UNICODE_SIZE == 2 if (length == 2) { ! ucs4_t u4in[2]; ! u4in[0] = (ucs4_t)IN1; ! u4in[1] = (ucs4_t)IN2; encoded = dsg->encoder(u4in, &length); } else *************** *** 421,425 **** { const struct iso2022_designation *dsgcache = NULL; ! while (inleft > 0) { unsigned char c = IN1; --- 423,427 ---- { const struct iso2022_designation *dsgcache = NULL; ! while (inleft > 0) { unsigned char c = IN1; *************** *** 1048,1095 **** NULL, dummy_decoder, dummy_encoder } #define REGISTRY_SENTINEL { 0, } ! static const struct iso2022_config iso2022_kr_config = { ! 0, ! { REGISTRY_KSX1001, REGISTRY_SENTINEL }, }; ! static const struct iso2022_config iso2022_jp_config = { ! NO_SHIFT | USE_JISX0208_EXT, ! { REGISTRY_JISX0208, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, ! REGISTRY_SENTINEL }, }; ! static const struct iso2022_config iso2022_jp_1_config = { ! NO_SHIFT | USE_JISX0208_EXT, ! { REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, ! REGISTRY_JISX0208_O, REGISTRY_SENTINEL }, }; ! static const struct iso2022_config iso2022_jp_2_config = { ! NO_SHIFT | USE_G2 | USE_JISX0208_EXT, ! { REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001, ! REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, ! REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL }, }; ! static const struct iso2022_config iso2022_jp_2004_config = { ! NO_SHIFT | USE_G2 | USE_JISX0208_EXT, ! { REGISTRY_JISX0213_2004_1_PAIRONLY, REGISTRY_JISX0208, ! REGISTRY_JISX0213_2004_1, REGISTRY_JISX0213_2004_2, ! REGISTRY_SENTINEL }, }; ! static const struct iso2022_config iso2022_jp_3_config = { ! NO_SHIFT | USE_JISX0208_EXT, ! { REGISTRY_JISX0213_2000_1_PAIRONLY, REGISTRY_JISX0208, ! REGISTRY_JISX0213_2000_1, REGISTRY_JISX0213_2000_2, ! REGISTRY_SENTINEL }, }; ! static const struct iso2022_config iso2022_jp_ext_config = { ! NO_SHIFT | USE_JISX0208_EXT, ! { REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, ! REGISTRY_JISX0201_K, REGISTRY_JISX0208_O, REGISTRY_SENTINEL }, }; --- 1050,1099 ---- NULL, dummy_decoder, dummy_encoder } #define REGISTRY_SENTINEL { 0, } + #define CONFIGDEF(var, attrs) \ + static const struct iso2022_config iso2022_##var##_config = { \ + attrs, iso2022_##var##_designations \ + }; ! static const struct iso2022_designation iso2022_kr_designations[] = { ! REGISTRY_KSX1001, REGISTRY_SENTINEL }; + CONFIGDEF(kr, 0) ! static const struct iso2022_designation iso2022_jp_designations[] = { ! REGISTRY_JISX0208, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, ! REGISTRY_SENTINEL }; + CONFIGDEF(jp, NO_SHIFT | USE_JISX0208_EXT) ! static const struct iso2022_designation iso2022_jp_1_designations[] = { ! REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, ! REGISTRY_JISX0208_O, REGISTRY_SENTINEL }; + CONFIGDEF(jp_1, NO_SHIFT | USE_JISX0208_EXT) ! static const struct iso2022_designation iso2022_jp_2_designations[] = { ! REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001, ! REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, ! REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL }; + CONFIGDEF(jp_2, NO_SHIFT | USE_G2 | USE_JISX0208_EXT) ! static const struct iso2022_designation iso2022_jp_2004_designations[] = { ! REGISTRY_JISX0213_2004_1_PAIRONLY, REGISTRY_JISX0208, ! REGISTRY_JISX0213_2004_1, REGISTRY_JISX0213_2004_2, REGISTRY_SENTINEL }; + CONFIGDEF(jp_2004, NO_SHIFT | USE_JISX0208_EXT) ! static const struct iso2022_designation iso2022_jp_3_designations[] = { ! REGISTRY_JISX0213_2000_1_PAIRONLY, REGISTRY_JISX0208, ! REGISTRY_JISX0213_2000_1, REGISTRY_JISX0213_2000_2, REGISTRY_SENTINEL }; + CONFIGDEF(jp_3, NO_SHIFT | USE_JISX0208_EXT) ! static const struct iso2022_designation iso2022_jp_ext_designations[] = { ! REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, ! REGISTRY_JISX0201_K, REGISTRY_JISX0208_O, REGISTRY_SENTINEL }; + CONFIGDEF(jp_ext, NO_SHIFT | USE_JISX0208_EXT) Index: cjkcodecs.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cjkcodecs/cjkcodecs.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** cjkcodecs.h 18 Jul 2004 15:02:45 -0000 1.4 --- cjkcodecs.h 19 Aug 2004 17:49:56 -0000 1.5 *************** *** 3,7 **** * * Written by Hye-Shik Chang ! * $CJKCodecs: cjkcodecs.h,v 1.5 2004/07/06 17:05:24 perky Exp $ */ --- 3,7 ---- * * Written by Hye-Shik Chang ! * $CJKCodecs: cjkcodecs.h,v 1.6 2004/07/18 15:22:31 perky Exp $ */ *************** *** 231,235 **** #define END_CODECS_LIST \ {"", NULL,} }; \ ! static const MultibyteCodec *codec_list = \ (const MultibyteCodec *)_codec_list; --- 231,235 ---- #define END_CODECS_LIST \ {"", NULL,} }; \ ! static const MultibyteCodec *codec_list = \ (const MultibyteCodec *)_codec_list; Index: multibytecodec.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cjkcodecs/multibytecodec.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** multibytecodec.c 18 Jul 2004 03:06:29 -0000 1.2 --- multibytecodec.c 19 Aug 2004 17:49:56 -0000 1.3 *************** *** 3,7 **** * * Written by Hye-Shik Chang ! * $CJKCodecs: multibytecodec.c,v 1.12 2004/06/27 19:24:13 perky Exp $ */ --- 3,7 ---- * * Written by Hye-Shik Chang ! * $CJKCodecs: multibytecodec.c,v 1.13 2004/08/19 16:57:19 perky Exp $ */ *************** *** 339,343 **** if (buf->excobj == NULL) { buf->excobj = PyUnicodeDecodeError_Create(codec->encoding, ! buf->inbuf_top, (int)(buf->inbuf_end - buf->inbuf_top), start, end, reason); --- 339,343 ---- if (buf->excobj == NULL) { buf->excobj = PyUnicodeDecodeError_Create(codec->encoding, ! (const char *)buf->inbuf_top, (int)(buf->inbuf_end - buf->inbuf_top), start, end, reason); *************** *** 966,970 **** { PyObject *wr, *ucvt, *r = NULL; ! Py_UNICODE *inbuf, *inbuf_end, *data, *inbuf_tmp = NULL; int datalen; --- 966,970 ---- { PyObject *wr, *ucvt, *r = NULL; ! Py_UNICODE *inbuf, *inbuf_end, *inbuf_tmp = NULL; int datalen; *************** *** 983,987 **** } - data = PyUnicode_AS_UNICODE(unistr); datalen = PyUnicode_GET_SIZE(unistr); if (datalen == 0) { --- 983,986 ---- From perky at users.sourceforge.net Thu Aug 19 19:52:40 2004 From: perky at users.sourceforge.net (perky@users.sourceforge.net) Date: Thu Aug 19 19:52:44 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1105,1.1106 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20917 Modified Files: NEWS Log Message: Bug #1005737, #1007249: Fix several build problems and warnings found on old/legacy C compilers of HP-UX, IRIX and Tru64. (Reported by roadkill, Richard Townsend, Maik Hertha and Minsik Kim) Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1105 retrieving revision 1.1106 diff -C2 -d -r1.1105 -r1.1106 *** NEWS 19 Aug 2004 11:31:57 -0000 1.1105 --- NEWS 19 Aug 2004 17:52:37 -0000 1.1106 *************** *** 127,130 **** --- 127,133 ---- GNU/k*BSD systems. + - bug #1005737, #1007249: Fixed several build problems and warnings + found on old/legacy C compilers of HP-UX, IRIX and Tru64. + C API ----- From edloper at users.sourceforge.net Thu Aug 19 21:19:20 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 19 21:19:24 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.69,1.70 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3641/dist/src/Lib Modified Files: doctest.py Log Message: Updated __all__ to include every non-underscored class, function, and constant defined by the module (except the test*() functions, which should be integrated into test/test_doctest.py, anyway). Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** doctest.py 19 Aug 2004 14:06:20 -0000 1.69 --- doctest.py 19 Aug 2004 19:19:03 -0000 1.70 *************** *** 171,187 **** __all__ = [ 'is_private', 'Example', 'DocTest', 'DocTestFinder', 'DocTestRunner', 'testmod', 'run_docstring_examples', 'Tester', 'DocTestCase', 'DocTestSuite', 'testsource', 'debug', - # 'master', ] --- 171,215 ---- __all__ = [ + # 0, Option Flags + 'register_optionflag', + 'DONT_ACCEPT_TRUE_FOR_1', + 'DONT_ACCEPT_BLANKLINE', + 'NORMALIZE_WHITESPACE', + 'ELLIPSIS', + 'UNIFIED_DIFF', + 'CONTEXT_DIFF', + # 1. Utility Functions 'is_private', + # 2. Example & DocTest 'Example', 'DocTest', + # 3. Doctest Parser + 'DocTestParser', + # 4. Doctest Finder 'DocTestFinder', + # 5. Doctest Runner 'DocTestRunner', + 'OutputChecker', + 'DocTestFailure', + 'UnexpectedException', + 'DebugRunner', + # 6. Test Functions 'testmod', 'run_docstring_examples', + # 7. Tester 'Tester', + # 8. Unittest Support 'DocTestCase', + 'nooutput', 'DocTestSuite', + 'DocFileCase', + 'DocFileTest', + 'DocFileSuite', + # 9. Debugging Support + 'script_from_examples', 'testsource', + 'debug_src', + 'debug_script', 'debug', ] *************** *** 527,531 **** ###################################################################### ! ## 2. DocTestParser ###################################################################### --- 555,559 ---- ###################################################################### ! ## 3. DocTestParser ###################################################################### From edloper at users.sourceforge.net Thu Aug 19 21:26:09 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 19 21:26:12 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.70,1.71 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4687/dist/src/Lib Modified Files: doctest.py Log Message: Got rid of nooutput() (was used by DocTestCase.debug()) It's redundant, since no output is written anyway: DebugRunner doesn't generate any output for failures and unexpected exceptions, and since verbose=False, it won't generate any output for non-failures either. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** doctest.py 19 Aug 2004 19:19:03 -0000 1.70 --- doctest.py 19 Aug 2004 19:26:06 -0000 1.71 *************** *** 201,205 **** # 8. Unittest Support 'DocTestCase', - 'nooutput', 'DocTestSuite', 'DocFileCase', --- 201,204 ---- *************** *** 2106,2110 **** runner = DebugRunner(optionflags=self._dt_optionflags, checker=self._dt_checker, verbose=False) ! runner.run(self._dt_test, out=nooutput) def id(self): --- 2105,2109 ---- runner = DebugRunner(optionflags=self._dt_optionflags, checker=self._dt_checker, verbose=False) ! runner.run(self._dt_test) def id(self): *************** *** 2120,2126 **** return "Doctest: " + self._dt_test.name - def nooutput(*args): - pass - def DocTestSuite(module=None, globs=None, extraglobs=None, optionflags=0, test_finder=None, --- 2119,2122 ---- From rhettinger at users.sourceforge.net Thu Aug 19 23:32:09 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Aug 19 23:32:12 2004 Subject: [Python-checkins] python/dist/src/Lib weakref.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26831 Modified Files: weakref.py Log Message: SF bug #1012315: weakref.WeakValueDictionary should override .has_key() * Check the found object for a None value during a contains/has_key lookup. Perhaps it will help the OP who is likely suffering from an occassional GC or threading object deletion after self.data is checked. * Complete the previous patch by removing the unnecessary indirection for weak dict iterators. Makes the code cleaner and more readable. Index: weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/weakref.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** weakref.py 13 Aug 2004 07:12:45 -0000 1.24 --- weakref.py 19 Aug 2004 21:32:06 -0000 1.25 *************** *** 58,61 **** --- 58,75 ---- return o + def __contains__(self, key): + try: + o = self.data[key]() + except KeyError: + return False + return o is not None + + def has_key(self, key): + try: + o = self.data[key]() + except KeyError: + return False + return o is not None + def __repr__(self): return "" % id(self) *************** *** 94,105 **** def iteritems(self): ! return WeakValuedItemIterator(self) def iterkeys(self): return self.data.iterkeys() ! __iter__ = iterkeys def itervalues(self): ! return WeakValuedValueIterator(self) def popitem(self): --- 108,127 ---- def iteritems(self): ! for wr in self.data.itervalues(): ! value = wr() ! if value is not None: ! yield wr.key, value def iterkeys(self): return self.data.iterkeys() ! ! def __iter__(self): ! return self.data.iterkeys() def itervalues(self): ! for wr in self.data.itervalues(): ! obj = wr() ! if obj is not None: ! yield obj def popitem(self): *************** *** 237,245 **** def iteritems(self): ! return WeakKeyedItemIterator(self) def iterkeys(self): ! return WeakKeyedKeyIterator(self) ! __iter__ = iterkeys def itervalues(self): --- 259,275 ---- def iteritems(self): ! for wr, value in self.data.iteritems(): ! key = wr() ! if key is not None: ! yield key, value def iterkeys(self): ! for wr in self.data.iterkeys(): ! obj = wr() ! if obj is not None: ! yield obj ! ! def __iter__(self): ! return self.iterkeys() def itervalues(self): *************** *** 276,302 **** if len(kwargs): self.update(kwargs) - - - def WeakKeyedKeyIterator(weakdict): - for wr in weakdict.data.iterkeys(): - obj = wr() - if obj is not None: - yield obj - - def WeakKeyedItemIterator(weakdict): - for wr, value in weakdict.data.iteritems(): - key = wr() - if key is not None: - yield key, value - - def WeakValuedValueIterator(weakdict): - for wr in weakdict.data.itervalues(): - obj = wr() - if obj is not None: - yield obj - - def WeakValuedItemIterator(weakdict): - for wr in weakdict.data.itervalues(): - value = wr() - if value is not None: - yield wr.key, value --- 306,307 ---- From rhettinger at users.sourceforge.net Fri Aug 20 00:39:58 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Aug 20 00:40:01 2004 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7575 Modified Files: decimal.py Log Message: Establish policies with respect to 2.3 compatibilty and treated spec updates as bugfixes. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** decimal.py 17 Aug 2004 06:39:37 -0000 1.22 --- decimal.py 19 Aug 2004 22:39:55 -0000 1.23 *************** *** 8,11 **** --- 8,20 ---- # and Tim Peters + # This module is currently Py2.3 compatible and should be kept that way + # unless a major compelling advantage arises. IOW, 2.3 compatibility is + # strongly preferred, but not guaranteed. + + # Also, this module should be kept in sync with the latest updates of + # the IBM specification as it evolves. Those updates will be treated + # as bug fixes (deviation from the spec is a compatibility, usability + # bug) and will be backported. At this point the spec is stabilizing + # and the updates are becoming fewer, smaller, and less significant. """ From bcannon at users.sourceforge.net Fri Aug 20 00:52:50 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Aug 20 00:52:57 2004 Subject: [Python-checkins] python/nondist/sandbox/string/tests test_pep292.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/string/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10167/tests Modified Files: test_pep292.py Log Message: Fix typo in test_suite() that mis-identified the class to make a TestSuite out of. Index: test_pep292.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/string/tests/test_pep292.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_pep292.py 12 Aug 2004 21:22:51 -0000 1.3 --- test_pep292.py 19 Aug 2004 22:52:47 -0000 1.4 *************** *** 50,54 **** def test_suite(): suite = unittest.TestSuite() ! suite.addTest(unittest.makeSuite(TestTemplates)) return suite --- 50,54 ---- def test_suite(): suite = unittest.TestSuite() ! suite.addTest(unittest.makeSuite(TestTemplate)) return suite From rhettinger at users.sourceforge.net Fri Aug 20 00:58:33 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Aug 20 00:58:36 2004 Subject: [Python-checkins] python/nondist/peps pep-0291.txt,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11181 Modified Files: pep-0291.txt Log Message: Establish update policies for the decimal module. Index: pep-0291.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0291.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pep-0291.txt 6 May 2004 00:29:47 -0000 1.9 --- pep-0291.txt 19 Aug 2004 22:58:30 -0000 1.10 *************** *** 81,84 **** --- 81,85 ---- Barry Warsaw compiler Jeremy Hylton 2.1 + decimal Raymond Hettinger 2.3 [2] distutils Andrew Kuchling 1.5.2 email Barry Warsaw 2.1 / 2.3 [1] *************** *** 105,108 **** --- 106,114 ---- need to remain compatible only with Python 2.3. + [2] Specification updates will be treated as bugfixes and backported. + Python 2.3 compatibility will be kept for at least Python 2.4. + The decision will be revisited for Python 2.5 and not changed + unless compelling advantages arise. + Copyright From goodger at users.sourceforge.net Fri Aug 20 03:14:26 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Fri Aug 20 03:14:29 2004 Subject: [Python-checkins] python/nondist/peps pep-0318.txt,1.22,1.23 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31018 Modified Files: pep-0318.txt Log Message: reST foo to the rescue! Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** pep-0318.txt 19 Aug 2004 15:36:14 -0000 1.22 --- pep-0318.txt 20 Aug 2004 01:14:23 -0000 1.23 *************** *** 18,37 **** ===================== ! This is not yet complete. This is still a work-in-progress. Feedback ! to anthony. Please note that the point of this PEP is _not_ to provide ! an open-slather of plusses and minuses for each syntax, but is instead ! to justify the choice made. If, in 2.4a3, the syntax is changed, the ! PEP will be updated to match this, complete with the arguments for the ! change. Abstract ======== ! The current method for transforming functions and methods (for instance, ! declaring them as a class or static method) is awkward and can lead to ! code that is difficult to understand. Ideally, these transformations ! should be made at the same point in the code where the declaration ! itself is made. This PEP introduces new syntax for transformations of a ! function or method declaration. --- 18,38 ---- ===================== ! This is not yet complete. This is still a work-in-progress. Feedback ! to anthony. Please note that the point of this PEP is _not_ to ! provide an open-slather of plusses and minuses for each syntax, but is ! instead to justify the choice made. If, in 2.4a3, the syntax is ! changed, the PEP will be updated to match this, complete with the ! arguments for the change. ! Abstract ======== ! The current method for transforming functions and methods (for ! instance, declaring them as a class or static method) is awkward and ! can lead to code that is difficult to understand. Ideally, these ! transformations should be made at the same point in the code where the ! declaration itself is made. This PEP introduces new syntax for ! transformations of a function or method declaration. *************** *** 74,78 **** metaclasses, but using metaclasses is sufficiently obscure that there is some attraction to having an easier way to make simple ! modifications to classes. For Python 2.4, only function/method decorators are being added. --- 75,79 ---- metaclasses, but using metaclasses is sufficiently obscure that there is some attraction to having an easier way to make simple ! modifications to classes. For Python 2.4, only function/method decorators are being added. *************** *** 105,143 **** The discussion continued on and off on python-dev from February 2002 ! through July 2004. Hundreds and hundreds of posts were made, with people ! proposing many possible syntax variations. Guido took a list of ! proposals to `EuroPython 2004`_, where a discussion took place. ! Subsequent to this, he decided that for 2.4a2 we'd have the `Java-style`_ ! @decorator syntax. Barry Warsaw named this the 'pie-decorator' ! syntax, in honor of the Pie-thon Parrot shootout which was announced ! about the same time as the decorator syntax, and because the @ looks a ! little like a pie. Guido `outlined his case`_ on Python-dev, ! including `this piece`_ on the various rejected forms. .. _EuroPython 2004: http://www.python.org/doc/essays/ppt/euro2004/euro2004.pdf - .. _outlined his case: http://mail.python.org/pipermail/python-dev/2004-August/author.html - .. _this piece: http://mail.python.org/pipermail/python-dev/2004-August/046672.html ! ! .. Java-style: http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html On the name 'Decorator' ======================= ! There's been a number of complaints about the choice of the name ! 'decorator' for this feature. The major one is that the name is ! not consistent with it's use in the `GoF book`_. The name 'decorator' ! probably owes more to it's use in the compiler area - a syntax tree ! is walked and annotated. It's quite possible that a better name may ! turn up. ! .. GoF book: http://patterndigest.com/patterns/Decorator.html Design Goals ============ --- 106,143 ---- The discussion continued on and off on python-dev from February 2002 ! through July 2004. Hundreds and hundreds of posts were made, with ! people proposing many possible syntax variations. Guido took a list ! of proposals to `EuroPython 2004`_, where a discussion took place. ! Subsequent to this, he decided that for 2.4a2 we'd have the ! `Java-style`_ @decorator syntax. Barry Warsaw named this the ! 'pie-decorator' syntax, in honor of the Pie-thon Parrot shootout which ! was announced about the same time as the decorator syntax, and because ! the @ looks a little like a pie. Guido `outlined his case`_ on ! Python-dev, including `this piece`_ on the various rejected forms. .. _EuroPython 2004: http://www.python.org/doc/essays/ppt/euro2004/euro2004.pdf .. _outlined his case: http://mail.python.org/pipermail/python-dev/2004-August/author.html .. _this piece: http://mail.python.org/pipermail/python-dev/2004-August/046672.html ! .. _Java-style: http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html + On the name 'Decorator' ======================= ! There's been a number of complaints about the choice of the name ! 'decorator' for this feature. The major one is that the name is not ! consistent with its use in the `GoF book`_. The name 'decorator' ! probably owes more to its use in the compiler area -- a syntax tree is ! walked and annotated. It's quite possible that a better name may turn ! up. ! .. _GoF book: http://patterndigest.com/patterns/Decorator.html + Design Goals ============ *************** *** 145,189 **** The new syntax should ! * work for arbitrary wrappers, including user-defined callables and ! the existing builtins ``classmethod()`` and ``staticmethod()`` ! * work with multiple wrappers per definition ! * make it obvious what is happening; at the very least it should be ! obvious that new users can safely ignore it when writing their own ! code ! * not make future extensions more difficult ! * be easy to type; programs that use it are expected to use it very ! frequently ! * not make it more difficult to scan through code quickly. It should ! still be easy to search for all definitions, a particular ! definition, or the arguments that a function accepts ! * not needlessly complicate secondary support tools such as ! language-sensitive editors and other "`toy parser tools out ! there`_" ! * move from the end of the function, where it's currently hidden, to ! the front where it is more `in your face`_ .. _toy parser tools out there: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=mailman.1010809396.32158.python-list%40python.org ! ! .. in your face: http://mail.python.org/pipermail/python-dev/2004-August/047112.html - - Andrew Kuchling has links to a bunch of the discussions about motivations - and use cases `in his blog`_. Particularly notable is `Jim Huginin's list - of use cases`_. - .. _in his blog: http://www.amk.ca/diary/archives/cat_python.html#003255 - .. _Jim Huginin's list of use cases: http://mail.python.org/pipermail/python-dev/2004-April/044132.html Current Syntax ============== --- 145,187 ---- The new syntax should ! * work for arbitrary wrappers, including user-defined callables and ! the existing builtins ``classmethod()`` and ``staticmethod()`` ! * work with multiple wrappers per definition ! * make it obvious what is happening; at the very least it should be ! obvious that new users can safely ignore it when writing their own ! code ! * not make future extensions more difficult ! * be easy to type; programs that use it are expected to use it very ! frequently ! * not make it more difficult to scan through code quickly. It should ! still be easy to search for all definitions, a particular ! definition, or the arguments that a function accepts ! * not needlessly complicate secondary support tools such as ! language-sensitive editors and other "`toy parser tools out ! there`_" ! * move from the end of the function, where it's currently hidden, to ! the front where it is more `in your face`_ ! ! Andrew Kuchling has links to a bunch of the discussions about ! motivations and use cases `in his blog`_. Particularly notable is `Jim ! Huginin's list of use cases`_. .. _toy parser tools out there: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=mailman.1010809396.32158.python-list%40python.org ! .. _in your face: http://mail.python.org/pipermail/python-dev/2004-August/047112.html .. _in his blog: http://www.amk.ca/diary/archives/cat_python.html#003255 .. _Jim Huginin's list of use cases: http://mail.python.org/pipermail/python-dev/2004-April/044132.html + Current Syntax ============== *************** *** 207,234 **** clear that something new is going on here. ! The decorator statement is limited in what it can accept - arbitrary ! expressions will not work. Guido preferred this because of a `gut feeling`_ .. _gut feeling: http://mail.python.org/pipermail/python-dev/2004-August/046711.html Syntax Alternatives =================== ! There have been `a large number`_ of different syntaxes proposed - rather ! than attempting to work through these individual syntaxes, it's worthwhile ! to break the syntax discussion down into a number of areas. Attempting to ! discuss `each possible syntax`_ individually would be an act of madness, ! and produce a completely unwieldly PEP. ! .. a large number: http://www.python.org/moin/PythonDecorators ! .. each possible syntax: http://ucsu.colorado.edu/~bethard/py/decorators-output.py Decorator Location ------------------ ! The first syntax point is the location of the decorators. For the following examples, we use the @syntax used in 2.4a2. --- 205,235 ---- clear that something new is going on here. ! The decorator statement is limited in what it can accept -- arbitrary ! expressions will not work. Guido preferred this because of a `gut ! feeling`_. .. _gut feeling: http://mail.python.org/pipermail/python-dev/2004-August/046711.html + Syntax Alternatives =================== ! There have been `a large number`_ of different syntaxes proposed -- ! rather than attempting to work through these individual syntaxes, it's ! worthwhile to break the syntax discussion down into a number of areas. ! Attempting to discuss `each possible syntax`_ individually would be an ! act of madness, and produce a completely unwieldly PEP. ! .. _a large number: http://www.python.org/moin/PythonDecorators ! .. _each possible syntax: http://ucsu.colorado.edu/~bethard/py/decorators-output.py + Decorator Location ------------------ ! The first syntax point is the location of the decorators. For the following examples, we use the @syntax used in 2.4a2. *************** *** 245,256 **** pass ! There have been a number of objections raised to this location - ! the primary one is that it's the first real Python case where a ! line of code has a result on a following line. The syntax that will be in 2.4a3 will also require one decorator per line (in a2, multiple decorators can be specified on the same line). Some of the advantages of this form are that the decorators live ! outside the method body - they are obviously executed at the time the function is defined --- 246,257 ---- pass ! There have been a number of objections raised to this location -- ! the primary one is that it's the first real Python case where a ! line of code has a result on a following line. The syntax that will be in 2.4a3 will also require one decorator per line (in a2, multiple decorators can be specified on the same line). Some of the advantages of this form are that the decorators live ! outside the method body -- they are obviously executed at the time the function is defined *************** *** 270,278 **** pass ! There are a couple of objections to this form. ! The first is that it breaks easily 'greppability' of the source - you ! can no longer search for 'def foo(' and find the definition of the ! function. The second, more serious, objection is that in the case ! of multiple decorators, the syntax would be extremely unwieldy. The next form, which has had a number of strong proponents, is to --- 271,279 ---- pass ! There are a couple of objections to this form. The first is that it ! breaks easily 'greppability' of the source -- you can no longer search ! for 'def foo(' and find the definition of the function. The second, ! more serious, objection is that in the case of multiple decorators, ! the syntax would be extremely unwieldy. The next form, which has had a number of strong proponents, is to *************** *** 298,302 **** it starts and ends in the middle of a line ! .. summarised the arguments: http://mail.python.org/pipermail/python-dev/2004-August/047112.html --- 299,303 ---- it starts and ends in the middle of a line ! .. _summarised the arguments: http://mail.python.org/pipermail/python-dev/2004-August/047112.html *************** *** 314,327 **** pass ! The primary objection to this form is that it requires "peeking inside" ! the method body to determine the decorators. In addition, even though ! the code is inside the method body, it is not executed when the method ! is run. Guido felt that docstrings were not a good counter-example, and ! that it was quite possible that a 'docstring' decorator could help move ! the docstring to outside the function body. ! The final form is a new block that encloses the method's code. For this ! example, we'll use a 'decorate' keyword, as it makes no sense with the ! @syntax. decorate: --- 315,328 ---- pass ! The primary objection to this form is that it requires "peeking ! inside" the method body to determine the decorators. In addition, ! even though the code is inside the method body, it is not executed ! when the method is run. Guido felt that docstrings were not a good ! counter-example, and that it was quite possible that a 'docstring' ! decorator could help move the docstring to outside the function body. ! The final form is a new block that encloses the method's code. For ! this example, we'll use a 'decorate' keyword, as it makes no sense ! with the @syntax. :: decorate: *************** *** 337,381 **** This form would result in inconsistent indentation for decorated and ! undecorated methods. In addition, a decorated method's body would start ! three indent levels in. Syntax forms ------------ ! @decorator ! The major objections against this syntax are that the @ symbol ! is not currently used in Python (and is used in both IPython and ! Leo), that the @ symbol is not meaningful, ! |decorator ! This is a variant on the @decorator syntax - it has the advantage ! that it does not break IPython and Leo. It's major disadvantage ! compared to the @syntax is that the | symbol looks like both a ! capital I and a lowercase l. * list syntax ! The major objection to the list syntax is that it's currently ! meaningful (when used in the form before the method). It's also ! lacking any indication that the expression is a decorator. ! ! * list syntax using other brackets ( <...>, [[...]], ... ) ! * decorate() ! The decorate() proposal was that no new syntax be implemented - ! instead a magic function that used introspection to manipulate ! the following function. Both Jp Calderone and Philip Eby produced ! implementations of functions that did this. Guido was pretty firmly ! against this - with no new syntax, the magicness of a function like ! this is extremely high. * new keyword (and block) - Alternate Proposals =================== --- 338,381 ---- This form would result in inconsistent indentation for decorated and ! undecorated methods. In addition, a decorated method's body would ! start three indent levels in. ! Syntax forms ------------ ! * ``@decorator`` ! The major objections against this syntax are that the @ symbol is ! not currently used in Python (and is used in both IPython and Leo), ! that the @ symbol is not meaningful, ! * ``|decorator`` ! This is a variant on the @decorator syntax -- it has the advantage ! that it does not break IPython and Leo. Its major disadvantage ! compared to the @syntax is that the | symbol looks like both a ! capital I and a lowercase l. * list syntax ! The major objection to the list syntax is that it's currently ! meaningful (when used in the form before the method). It's also ! lacking any indication that the expression is a decorator. + * list syntax using other brackets (``<...>``, ``[[...]]``, ...) ! * ``decorate()`` ! The ``decorate()`` proposal was that no new syntax be implemented -- ! instead a magic function that used introspection to manipulate the ! following function. Both Jp Calderone and Philip Eby produced ! implementations of functions that did this. Guido was pretty firmly ! against this -- with no new syntax, the magicness of a function like ! this is extremely high. * new keyword (and block) Alternate Proposals =================== *************** *** 393,423 **** decorators across multiple lines, and the keyword "as" doesn't have the same meaning as its use in the ``import`` statement. Plenty of ! `alternatives to "as"`_ have been proposed. :-) ! ! .. _alternatives to "as": ! http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=mailman.236.1079968472.742.python-list%40python.org&rnum=2&prev=/groups%3Fq%3Dpython%2Bpep%2B318%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3Dmailman.236.1079968472.742.python-list%2540python.org%26rnum%3D2 ! ! :: def [dec1, dec2, ...] func(arg1, arg2, ...): pass ! This form has the disadvantage that the decorators visually assume ! higher priority than the function name and argument list. ! :: def func [dec1, dec2, ...] (arg1, arg2, ...): pass ! Quixote's `Python Template Language`_ uses this form, but only supports a ! single decorator chosen from a restricted set. For short lists it ! works okay, but for long list it separates the argument list from the ! function name. ! ! .. _Python Template Language: ! http://www.mems-exchange.org/software/quixote/doc/PTL.html ! ! :: using: --- 393,414 ---- decorators across multiple lines, and the keyword "as" doesn't have the same meaning as its use in the ``import`` statement. Plenty of ! `alternatives to "as"`_ have been proposed. :-) :: def [dec1, dec2, ...] func(arg1, arg2, ...): pass ! .. _alternatives to "as": ! http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=mailman.236.1079968472.742.python-list%40python.org&rnum=2&prev=/groups%3Fq%3Dpython%2Bpep%2B318%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3Dmailman.236.1079968472.742.python-list%2540python.org%26rnum%3D2 ! This form has the disadvantage that the decorators visually assume ! higher priority than the function name and argument list. :: def func [dec1, dec2, ...] (arg1, arg2, ...): pass ! Quixote's `Python Template Language`_ uses this form, but only ! supports a single decorator chosen from a restricted set. For short ! lists it works okay, but for long list it separates the argument list ! from the function name. :: using: *************** *** 428,431 **** --- 419,425 ---- pass + .. _Python Template Language: + http://www.mems-exchange.org/software/quixote/doc/PTL.html + The function definition is not nested within the using: block making it impossible to tell which objects following the block will be *************** *** 435,441 **** it would require the introduction of a new keyword. ! The obvious alternative that nests the function within the block ! ! :: using: --- 429,433 ---- it would require the introduction of a new keyword. ! The obvious alternative that nests the function within the block :: using: *************** *** 460,466 **** pass ! For a while this was Guido's preferred solution, but negative sentiment ran ! high, mostly because that syntax, though useless except for side ! effects of the list, is already legal and thus creates a special case. .. _list of decorators: --- 452,459 ---- pass ! For a while this was Guido's preferred solution, but negative ! sentiment ran high, mostly because that syntax, though useless except ! for side effects of the list, is already legal and thus creates a ! special case. .. _list of decorators: *************** *** 482,486 **** no new syntax, but instead used some fairly advanced introspection to provide decorator-like behavoiur, but Guido was unimpressed by ! these, stating:: Using functions with "action-at-a-distance" through --- 475,479 ---- no new syntax, but instead used some fairly advanced introspection to provide decorator-like behavoiur, but Guido was unimpressed by ! these, stating: Using functions with "action-at-a-distance" through *************** *** 502,516 **** ! Why @? ------ There is some history in Java using @ initially as a marker in ! `Javadoc comments`_ and later in Java 1.5 for `annotations`_, ! which are similar to Python decorators. The fact that ! @ was previously unused as a token in Python also means it's clear ! there is no possibility of such code being parsed by an earlier ! version of Python, leading to possibly subtle semantic bugs. That ! said, @ is still a fairly arbitrary choice. Some have suggested using ! | instead. For syntax options which use a list-like syntax (no matter where it --- 495,508 ---- ! Why @? ------ There is some history in Java using @ initially as a marker in ! `Javadoc comments`_ and later in Java 1.5 for `annotations`_, which ! are similar to Python decorators. The fact that @ was previously ! unused as a token in Python also means it's clear there is no ! possibility of such code being parsed by an earlier version of Python, ! leading to possibly subtle semantic bugs. That said, @ is still a ! fairly arbitrary choice. Some have suggested using | instead. For syntax options which use a list-like syntax (no matter where it *************** *** 526,541 **** .. _Javadoc comments: http://java.sun.com/j2se/javadoc/writingdoccomments/ ! ! .. annotations: http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html Current Implementation ====================== Guido asked for a voluteer to implement his preferred syntax, and Mark ! Russell stepped up and posted a `patch`_ to SF. The syntax accepted for 2.4a2 is:: - @dec2 @dec1 --- 518,532 ---- .. _Javadoc comments: http://java.sun.com/j2se/javadoc/writingdoccomments/ ! .. _annotations: http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html + Current Implementation ====================== Guido asked for a voluteer to implement his preferred syntax, and Mark ! Russell stepped up and posted a `patch`_ to SF. The syntax accepted for 2.4a2 is:: @dec2 @dec1 *************** *** 543,547 **** pass ! is equivalent to:: def func(arg1, arg2, ...): --- 534,538 ---- pass ! This is equivalent to:: def func(arg1, arg2, ...): *************** *** 551,559 **** though without the intermediate creation of a variable named ``func``. - .. _patch: http://www.python.org/sf/979728 - A `previous patch`_ from Michael Hudson which implements the list-after-def syntax is also still kicking around. .. _previous patch: http://starship.python.net/crew/mwh/hacks/meth-syntax-sugar-3.diff --- 542,549 ---- though without the intermediate creation of a variable named ``func``. A `previous patch`_ from Michael Hudson which implements the list-after-def syntax is also still kicking around. + .. _patch: http://www.python.org/sf/979728 .. _previous patch: http://starship.python.net/crew/mwh/hacks/meth-syntax-sugar-3.diff *************** *** 569,575 **** 1. Define a function to be executed at exit. Note that the function ! isn't actually "wrapped" in the usual sense. ! ! :: def onexit(f): --- 559,563 ---- 1. Define a function to be executed at exit. Note that the function ! isn't actually "wrapped" in the usual sense. :: def onexit(f): *************** *** 585,589 **** disappears enterprising programmers would have to be more creative to create more instances. (From Shane Hathaway on ``python-dev``.) - :: --- 573,576 ---- *************** *** 601,607 **** 3. Add attributes to a function. (Based on an example posted by ! Anders Munch on ``python-dev``.) ! ! :: def attrs(**kwds): --- 588,592 ---- 3. Add attributes to a function. (Based on an example posted by ! Anders Munch on ``python-dev``.) :: def attrs(**kwds): *************** *** 619,625 **** 4. Enforce function argument and return types. (Note that this is not exactly correct, as the returned new_f doesn't have "func" as its ! func_name attribute.) ! ! :: def accepts(*types): --- 604,608 ---- 4. Enforce function argument and return types. (Note that this is not exactly correct, as the returned new_f doesn't have "func" as its ! func_name attribute.) :: def accepts(*types): *************** *** 651,659 **** 5. Declare that a class implements a particular (set of) interface(s). This is from a posting by Bob Ippolito on ``python-dev`` based on ! experience with `PyProtocols`_. ! ! .. _PyProtocols: http://peak.telecommunity.com/PyProtocols.html ! ! :: def provides(*interfaces): --- 634,638 ---- 5. Declare that a class implements a particular (set of) interface(s). This is from a posting by Bob Ippolito on ``python-dev`` based on ! experience with `PyProtocols`_. :: def provides(*interfaces): *************** *** 675,678 **** --- 654,659 ---- """Implement something here...""" + .. _PyProtocols: http://peak.telecommunity.com/PyProtocols.html + Of course, all these examples are possible today, though without syntactic support. *************** *** 685,689 **** into the language at this point. Guido expressed skepticism about the concept, but various people have made some `strong arguments`_ ! (search for ``PEP 318 - posting draft``) on their behalf in ``python-dev``. --- 666,670 ---- into the language at this point. Guido expressed skepticism about the concept, but various people have made some `strong arguments`_ ! (search for ``PEP 318 -- posting draft``) on their behalf in ``python-dev``. From goodger at users.sourceforge.net Fri Aug 20 03:18:27 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Fri Aug 20 03:18:31 2004 Subject: [Python-checkins] python/nondist/peps pep-0318.txt,1.23,1.24 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31622 Modified Files: pep-0318.txt Log Message: markup Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** pep-0318.txt 20 Aug 2004 01:14:23 -0000 1.23 --- pep-0318.txt 20 Aug 2004 01:18:24 -0000 1.24 *************** *** 19,23 **** This is not yet complete. This is still a work-in-progress. Feedback ! to anthony. Please note that the point of this PEP is _not_ to provide an open-slather of plusses and minuses for each syntax, but is instead to justify the choice made. If, in 2.4a3, the syntax is --- 19,23 ---- This is not yet complete. This is still a work-in-progress. Feedback ! to anthony. Please note that the point of this PEP is *not* to provide an open-slather of plusses and minuses for each syntax, but is instead to justify the choice made. If, in 2.4a3, the syntax is From nnorwitz at users.sourceforge.net Fri Aug 20 03:52:44 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Fri Aug 20 03:52:48 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libtarfile.tex,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3751/lib Modified Files: libtarfile.tex Log Message: Fix markup. versionchanged automatically adds a period, so remove the extra one. Index: libtarfile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtarfile.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** libtarfile.tex 18 Aug 2004 13:57:43 -0000 1.5 --- libtarfile.tex 20 Aug 2004 01:52:42 -0000 1.6 *************** *** 263,267 **** will not be \POSIX{} compliant, but can store files without any of the above restrictions. ! \versionchanged[\var{posix} defaults to false.]{2.4} \end{memberdesc} --- 263,267 ---- will not be \POSIX{} compliant, but can store files without any of the above restrictions. ! \versionchanged[\var{posix} defaults to \constant{False}]{2.4} \end{memberdesc} From tim_one at users.sourceforge.net Fri Aug 20 04:08:08 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 20 04:08:11 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.71,1.72 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5691 Modified Files: doctest.py Log Message: Gave _ellipsis_match() an attractive new leading underscore. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** doctest.py 19 Aug 2004 19:26:06 -0000 1.71 --- doctest.py 20 Aug 2004 02:08:04 -0000 1.72 *************** *** 391,398 **** # Worst-case linear-time ellipsis matching. ! def ellipsis_match(want, got): """ Essentially the only subtle case: ! >>> ellipsis_match('aa...aa', 'aaa') False """ --- 391,398 ---- # Worst-case linear-time ellipsis matching. ! def _ellipsis_match(want, got): """ Essentially the only subtle case: ! >>> _ellipsis_match('aa...aa', 'aaa') False """ *************** *** 427,431 **** if startpos > endpos: # Exact end matches required more characters than we have, as in ! # ellipsis_match('aa...aa', 'aaa') return False --- 427,431 ---- if startpos > endpos: # Exact end matches required more characters than we have, as in ! # _ellipsis_match('aa...aa', 'aaa') return False *************** *** 1559,1563 **** # match any substring in `got`. if optionflags & ELLIPSIS: ! if ellipsis_match(want, got): return True --- 1559,1563 ---- # match any substring in `got`. if optionflags & ELLIPSIS: ! if _ellipsis_match(want, got): return True From neal at metaslash.com Fri Aug 20 04:09:19 2004 From: neal at metaslash.com (Neal Norwitz) Date: Fri Aug 20 04:09:21 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.298, 1.299 In-Reply-To: References: Message-ID: <20040820020919.GG31470@epoch.metaslash.com> > Log Message: > Patch #1003700: Add socketpair function to socket module. > > Index: socketmodule.c > + #ifdef HAVE_SOCKETPAIR > + /* Create a pair of sockets using the socketpair() function. > + Arguments as for socket(). */ > + > + /*ARGSUSED*/ > + static PyObject * > + socket_socketpair(PyObject *self, PyObject *args) > + { > + PySocketSockObject *s0 = NULL, *s1 = NULL; > + SOCKET_T sv[2]; > + int family, type = SOCK_STREAM, proto = 0; > + PyObject *res = NULL; > + > + #if defined(AF_UNIX) > + family = AF_UNIX; > + #else > + family = AF_INET; > + #endif The docstring (below) states the arguments are the same as socket(). However, in sock_initobj() line 2496, the family is initialized to AF_INET. I think the #if defined(AF_UNIX) code above should be removed and family should be initialized to AF_INET. I didn't look to see if the documentation agrees with the docstring. > + if (!PyArg_ParseTuple(args, "|iii:socketpair", > + &family, &type, &proto)) > + return NULL; > + /* Create a pair of socket fds */ > + if (socketpair(family, type, proto, sv) < 0) > + return set_error(); > + #ifdef SIGPIPE > + (void) signal(SIGPIPE, SIG_IGN); > + #endif I don't think the #ifdef SIGPIPE code is correct. If the user installed a signal handler calling signal() will remove it. I think the call to signal() should be removed. Neal > + s0 = new_sockobject(sv[0], family, type, proto); > + if (s0 == NULL) > + goto finally; > + s1 = new_sockobject(sv[1], family, type, proto); > + if (s1 == NULL) > + goto finally; > + res = PyTuple_Pack(2, s0, s1); > + > + finally: > + if (res == NULL) { > + if (s0 == NULL) > + SOCKETCLOSE(sv[0]); > + if (s1 == NULL) > + SOCKETCLOSE(sv[1]); > + } > + Py_XDECREF(s0); > + Py_XDECREF(s1); > + return res; > + } > + > + PyDoc_STRVAR(socketpair_doc, > + "socketpair([family[, type[, proto]]]) -> (socket object, socket object)\n\ > + \n\ > + Create a pair of socket objects from the sockets returned by the platform\n\ > + socketpair() function.\n\ > + The arguments are the same as for socket()."); > + > + #endif /* HAVE_SOCKETPAIR */ From nnorwitz at users.sourceforge.net Fri Aug 20 04:36:29 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Fri Aug 20 04:36:32 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libunicodedata.tex, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9324/lib Modified Files: libunicodedata.tex Log Message: Try to improve grammar and use versionadded Index: libunicodedata.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libunicodedata.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** libunicodedata.tex 4 Aug 2004 07:38:33 -0000 1.6 --- libunicodedata.tex 20 Aug 2004 02:36:27 -0000 1.7 *************** *** 73,78 **** \begin{funcdesc}{east_asian_width}{unichr} ! Returns the east asian width of assigned to the Unicode character \var{unichr} as string. \end{funcdesc} --- 73,79 ---- \begin{funcdesc}{east_asian_width}{unichr} ! Returns the east asian width assigned to the Unicode character \var{unichr} as string. + \versionadded{2.4} \end{funcdesc} From tim_one at users.sourceforge.net Fri Aug 20 04:37:43 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 20 04:37:47 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_queue.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9355/Lib/test Modified Files: test_queue.py Log Message: Semantic-neutral format and comment changes. Index: test_queue.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_queue.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_queue.py 15 Nov 2002 19:08:50 -0000 1.4 --- test_queue.py 20 Aug 2004 02:37:25 -0000 1.5 *************** *** 1,4 **** # Some simple Queue module tests, plus some failure conditions ! # to ensure the Queue locks remain stable import Queue import sys --- 1,4 ---- # Some simple Queue module tests, plus some failure conditions ! # to ensure the Queue locks remain stable. import Queue import sys *************** *** 8,15 **** from test.test_support import verify, TestFailed, verbose ! queue_size = 5 ! # Execute a function that blocks, and in a seperate thread, a function that ! # triggers the release. Returns the result of the blocking function. class _TriggerThread(threading.Thread): def __init__(self, fn, args): --- 8,14 ---- from test.test_support import verify, TestFailed, verbose ! QUEUE_SIZE = 5 ! # A thread to run a function that unclogs a blocked Queue. class _TriggerThread(threading.Thread): def __init__(self, fn, args): *************** *** 18,21 **** --- 17,21 ---- self.startedEvent = threading.Event() threading.Thread.__init__(self) + def run(self): time.sleep(.1) *************** *** 23,26 **** --- 23,28 ---- self.fn(*self.args) + # Execute a function that blocks, and in a seperate thread, a function that + # triggers the release. Returns the result of the blocking function. def _doBlockingTest(block_func, block_args, trigger_func, trigger_args): t = _TriggerThread(trigger_func, trigger_args) *************** *** 61,65 **** if not q.empty(): raise RuntimeError, "Call this function with an empty queue" ! for i in range(queue_size-1): q.put(i) # Test a failing non-blocking put. --- 63,67 ---- if not q.empty(): raise RuntimeError, "Call this function with an empty queue" ! for i in range(QUEUE_SIZE-1): q.put(i) # Test a failing non-blocking put. *************** *** 81,85 **** q.fail_next_put = True try: ! _doBlockingTest( q.put, ("full",), q.get, ()) raise TestFailed("The queue didn't fail when it should have") except FailingQueueException: --- 83,87 ---- q.fail_next_put = True try: ! _doBlockingTest(q.put, ("full",), q.get, ()) raise TestFailed("The queue didn't fail when it should have") except FailingQueueException: *************** *** 91,95 **** q.fail_next_put = True try: ! _doBlockingTest( q.put, ("full", True, 0.2), q.get, ()) raise TestFailed("The queue didn't fail when it should have") except FailingQueueException: --- 93,97 ---- q.fail_next_put = True try: ! _doBlockingTest(q.put, ("full", True, 0.2), q.get, ()) raise TestFailed("The queue didn't fail when it should have") except FailingQueueException: *************** *** 106,110 **** _doBlockingTest( q.put, ("full",), q.get, ()) # Empty it ! for i in range(queue_size): q.get() verify(q.empty(), "Queue should be empty") --- 108,112 ---- _doBlockingTest( q.put, ("full",), q.get, ()) # Empty it ! for i in range(QUEUE_SIZE): q.get() verify(q.empty(), "Queue should be empty") *************** *** 145,149 **** verify(q.get() == 111 and q.get() == 222, "Didn't seem to queue the correct data!") ! for i in range(queue_size-1): q.put(i) verify(not q.full(), "Queue should not be full") --- 147,151 ---- verify(q.get() == 111 and q.get() == 222, "Didn't seem to queue the correct data!") ! for i in range(QUEUE_SIZE-1): q.put(i) verify(not q.full(), "Queue should not be full") *************** *** 161,168 **** pass # Test a blocking put ! _doBlockingTest( q.put, ("full",), q.get, ()) ! _doBlockingTest( q.put, ("full", True, 0.2), q.get, ()) # Empty it ! for i in range(queue_size): q.get() verify(q.empty(), "Queue should be empty") --- 163,170 ---- pass # Test a blocking put ! _doBlockingTest(q.put, ("full",), q.get, ()) ! _doBlockingTest(q.put, ("full", True, 0.2), q.get, ()) # Empty it ! for i in range(QUEUE_SIZE): q.get() verify(q.empty(), "Queue should be empty") *************** *** 182,186 **** def test(): ! q=Queue.Queue(queue_size) # Do it a couple of times on the same queue SimpleQueueTest(q) --- 184,188 ---- def test(): ! q = Queue.Queue(QUEUE_SIZE) # Do it a couple of times on the same queue SimpleQueueTest(q) *************** *** 188,192 **** if verbose: print "Simple Queue tests seemed to work" ! q = FailingQueue(queue_size) FailingQueueTest(q) FailingQueueTest(q) --- 190,194 ---- if verbose: print "Simple Queue tests seemed to work" ! q = FailingQueue(QUEUE_SIZE) FailingQueueTest(q) FailingQueueTest(q) From tim_one at users.sourceforge.net Fri Aug 20 05:27:16 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 20 05:27:24 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_queue.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14732/Lib/test Modified Files: test_queue.py Log Message: Stab at SF 1010777: test_queue fails occasionally test_queue has failed occasionally for years, and there's more than one cause. The primary cause in the SF report appears to be that the test driver really needs entirely different code for thread tests that expect to raise exceptions than for thread tests that are testing non-exceptional blocking semantics. So gave them entirely different code, and added a ton of explanation. Another cause is that the blocking thread tests relied in several places on the difference between sleep(.1) and sleep(.2) being long enough for the trigger thread to do its stuff sot that the blocking thread could make progress. That's just not reliable on a loaded machine. Boosted the 0.2's to 10.0's instead, which should be long enough under any non-catastrophic system conditions. That doesn't make the test take longer to run, the 10.0 is just how long the blocking thread is *willing* to wait for the trigger thread to do something. But if the Queue module is plain broken, such tests will indeed take 10 seconds to fail now. For similar (heavy load) reasons, changed threaded-test termination to be willing to wait 10 seconds for the signal thread to end too. Index: test_queue.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_queue.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_queue.py 20 Aug 2004 02:37:25 -0000 1.5 --- test_queue.py 20 Aug 2004 03:27:12 -0000 1.6 *************** *** 19,42 **** def run(self): ! time.sleep(.1) self.startedEvent.set() self.fn(*self.args) ! # Execute a function that blocks, and in a seperate thread, a function that # triggers the release. Returns the result of the blocking function. def _doBlockingTest(block_func, block_args, trigger_func, trigger_args): t = _TriggerThread(trigger_func, trigger_args) t.start() try: ! return block_func(*block_args) finally: ! # If we unblocked before our thread made the call, we failed! ! if not t.startedEvent.isSet(): ! raise TestFailed("blocking function '%r' appeared not to block" % ! block_func) ! t.join(1) # make sure the thread terminates if t.isAlive(): raise TestFailed("trigger function '%r' appeared to not return" % trigger_func) # A Queue subclass that can provoke failure at a moment's notice :) --- 19,78 ---- def run(self): ! # The sleep isn't necessary, but is intended to give the blocking ! # function in the main thread a chance at actually blocking before ! # we unclog it. But if the sleep is longer than the timeout-based ! # tests wait in their blocking functions, those tests will fail. ! # So we give them much longer timeout values compared to the ! # sleep here (I aimed at 10 seconds for blocking functions -- ! # they should never actually wait that long - they should make ! # progress as soon as we call self.fn()). ! time.sleep(0.1) self.startedEvent.set() self.fn(*self.args) ! # Execute a function that blocks, and in a separate thread, a function that # triggers the release. Returns the result of the blocking function. + # Caution: block_func must guarantee to block until trigger_func is + # called, and trigger_func must guarantee to change queue state so that + # block_func can make enough progress to return. In particular, a + # block_func that just raises an exception regardless of whether trigger_func + # is called will lead to timing-dependent sporadic failures, and one of + # those went rarely seen but undiagnosed for years. Now block_func + # must be unexceptional. If block_func is supposed to raise an exception, + # call _doExceptionalBlockingTest() instead. def _doBlockingTest(block_func, block_args, trigger_func, trigger_args): t = _TriggerThread(trigger_func, trigger_args) t.start() + result = block_func(*block_args) + # If block_func returned before our thread made the call, we failed! + if not t.startedEvent.isSet(): + raise TestFailed("blocking function '%r' appeared not to block" % + block_func) + t.join(10) # make sure the thread terminates + if t.isAlive(): + raise TestFailed("trigger function '%r' appeared to not return" % + trigger_func) + return result + + # Call this instead if block_func is supposed to raise an exception. + def _doExceptionalBlockingTest(block_func, block_args, trigger_func, + trigger_args, expected_exception_class): + t = _TriggerThread(trigger_func, trigger_args) + t.start() try: ! try: ! block_func(*block_args) ! except expected_exception_class: ! raise ! else: ! raise TestFailed("expected exception of kind %r" % ! expected_exception_class) finally: ! t.join(10) # make sure the thread terminates if t.isAlive(): raise TestFailed("trigger function '%r' appeared to not return" % trigger_func) + if not t.startedEvent.isSet(): + raise TestFailed("trigger thread ended but event never set") # A Queue subclass that can provoke failure at a moment's notice :) *************** *** 93,97 **** q.fail_next_put = True try: ! _doBlockingTest(q.put, ("full", True, 0.2), q.get, ()) raise TestFailed("The queue didn't fail when it should have") except FailingQueueException: --- 129,134 ---- q.fail_next_put = True try: ! _doExceptionalBlockingTest(q.put, ("full", True, 10), q.get, (), ! FailingQueueException) raise TestFailed("The queue didn't fail when it should have") except FailingQueueException: *************** *** 130,134 **** q.fail_next_get = True try: ! _doBlockingTest( q.get, (), q.put, ('empty',)) raise TestFailed("The queue didn't fail when it should have") except FailingQueueException: --- 167,172 ---- q.fail_next_get = True try: ! _doExceptionalBlockingTest(q.get, (), q.put, ('empty',), ! FailingQueueException) raise TestFailed("The queue didn't fail when it should have") except FailingQueueException: *************** *** 149,152 **** --- 187,191 ---- for i in range(QUEUE_SIZE-1): q.put(i) + verify(not q.empty(), "Queue should not be empty") verify(not q.full(), "Queue should not be full") q.put("last") *************** *** 158,162 **** pass try: ! q.put("full", timeout=0.1) raise TestFailed("Didn't appear to time-out with a full queue") except Queue.Full: --- 197,201 ---- pass try: ! q.put("full", timeout=0.01) raise TestFailed("Didn't appear to time-out with a full queue") except Queue.Full: *************** *** 164,168 **** # Test a blocking put _doBlockingTest(q.put, ("full",), q.get, ()) ! _doBlockingTest(q.put, ("full", True, 0.2), q.get, ()) # Empty it for i in range(QUEUE_SIZE): --- 203,207 ---- # Test a blocking put _doBlockingTest(q.put, ("full",), q.get, ()) ! _doBlockingTest(q.put, ("full", True, 10), q.get, ()) # Empty it for i in range(QUEUE_SIZE): *************** *** 175,179 **** pass try: ! q.get(timeout=0.1) raise TestFailed("Didn't appear to time-out with an empty queue") except Queue.Empty: --- 214,218 ---- pass try: ! q.get(timeout=0.01) raise TestFailed("Didn't appear to time-out with an empty queue") except Queue.Empty: *************** *** 181,185 **** # Test a blocking get _doBlockingTest(q.get, (), q.put, ('empty',)) ! _doBlockingTest(q.get, (True, 0.2), q.put, ('empty',)) def test(): --- 220,224 ---- # Test a blocking get _doBlockingTest(q.get, (), q.put, ('empty',)) ! _doBlockingTest(q.get, (True, 10), q.put, ('empty',)) def test(): From tim_one at users.sourceforge.net Fri Aug 20 05:47:15 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 20 05:47:18 2004 Subject: [Python-checkins] python/dist/src/Lib/compiler pycodegen.py, 1.72, 1.73 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18336/Lib/compiler Modified Files: pycodegen.py Log Message: Whitespace normalization. Index: pycodegen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/pycodegen.py,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** pycodegen.py 17 Aug 2004 17:29:14 -0000 1.72 --- pycodegen.py 20 Aug 2004 03:47:13 -0000 1.73 *************** *** 373,377 **** else: ndecorators = 0 ! gen = self.FunctionGen(node, self.scopes, isLambda, self.class_name, self.get_module()) --- 373,377 ---- else: ndecorators = 0 ! gen = self.FunctionGen(node, self.scopes, isLambda, self.class_name, self.get_module()) From tim_one at users.sourceforge.net Fri Aug 20 05:47:15 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 20 05:47:21 2004 Subject: [Python-checkins] python/dist/src/Lib posixpath.py,1.71,1.72 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18336/Lib Modified Files: posixpath.py Log Message: Whitespace normalization. Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** posixpath.py 14 Aug 2004 15:01:53 -0000 1.71 --- posixpath.py 20 Aug 2004 03:47:13 -0000 1.72 *************** *** 405,409 **** else: bits = filename.split('/') ! for i in range(2, len(bits)+1): component = join(*bits[0:i]) --- 405,409 ---- else: bits = filename.split('/') ! for i in range(2, len(bits)+1): component = join(*bits[0:i]) *************** *** 416,423 **** else: newpath = join(*([resolved] + bits[i:])) ! return realpath(newpath) return abspath(filename) ! def _resolve_link(path): --- 416,423 ---- else: newpath = join(*([resolved] + bits[i:])) ! return realpath(newpath) return abspath(filename) ! def _resolve_link(path): From tim_one at users.sourceforge.net Fri Aug 20 05:47:16 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 20 05:47:22 2004 Subject: [Python-checkins] python/dist/src/Lib/plat-freebsd6 IN.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-freebsd6 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18336/Lib/plat-freebsd6 Modified Files: IN.py Log Message: Whitespace normalization. Index: IN.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-freebsd6/IN.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IN.py 18 Aug 2004 15:13:41 -0000 1.1 --- IN.py 20 Aug 2004 03:47:14 -0000 1.2 *************** *** 2,12 **** # Included from sys/cdefs.h ! def __P(protos): return protos ! def __STRING(x): return #x ! def __XSTRING(x): return __STRING(x) ! def __P(protos): return () def __STRING(x): return "x" --- 2,12 ---- # Included from sys/cdefs.h ! def __P(protos): return protos ! def __STRING(x): return #x ! def __XSTRING(x): return __STRING(x) ! def __P(protos): return () def __STRING(x): return "x" From tim_one at users.sourceforge.net Fri Aug 20 05:47:16 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 20 05:47:24 2004 Subject: [Python-checkins] python/dist/src/Lib/lib-tk tkFont.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18336/Lib/lib-tk Modified Files: tkFont.py Log Message: Whitespace normalization. Index: tkFont.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/tkFont.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tkFont.py 18 Aug 2004 17:47:40 -0000 1.7 --- tkFont.py 20 Aug 2004 03:47:13 -0000 1.8 *************** *** 30,34 **** """ return Font(name=name, exists=True) ! class Font: --- 30,34 ---- """ return Font(name=name, exists=True) ! class Font: *************** *** 51,55 **** underline -- font underlining: false (0), true (1) overstrike -- font strikeout: false (0), true (1) ! """ --- 51,55 ---- underline -- font underlining: false (0), true (1) overstrike -- font strikeout: false (0), true (1) ! """ *************** *** 96,100 **** else: # create new font (raises TclError if the font exists) ! root.tk.call("font", "create", self.name, *font) self.delete_font = True # backlinks! --- 96,100 ---- else: # create new font (raises TclError if the font exists) ! root.tk.call("font", "create", self.name, *font) self.delete_font = True # backlinks! *************** *** 121,125 **** except (AttributeError, Tkinter.TclError): pass ! def copy(self): "Return a distinct copy of the current font" --- 121,125 ---- except (AttributeError, Tkinter.TclError): pass ! def copy(self): "Return a distinct copy of the current font" From tim_one at users.sourceforge.net Fri Aug 20 05:47:16 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 20 05:47:28 2004 Subject: [Python-checkins] python/dist/src/Lib/test test__locale.py, 1.5, 1.6 test_posixpath.py, 1.10, 1.11 test_zipfile.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18336/Lib/test Modified Files: test__locale.py test_posixpath.py test_zipfile.py Log Message: Whitespace normalization. Index: test__locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test__locale.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test__locale.py 14 Aug 2004 10:56:54 -0000 1.5 --- test__locale.py 20 Aug 2004 03:47:14 -0000 1.6 *************** *** 34,38 **** print "%r != %r" % (nl_radixchar, li_radixchar) if not saw_locale: ! raise ImportError, "None of the listed locales found" finally: setlocale(LC_NUMERIC, oldlocale) --- 34,38 ---- print "%r != %r" % (nl_radixchar, li_radixchar) if not saw_locale: ! raise ImportError, "None of the listed locales found" finally: setlocale(LC_NUMERIC, oldlocale) Index: test_posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_posixpath.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_posixpath.py 14 Aug 2004 15:01:53 -0000 1.10 --- test_posixpath.py 20 Aug 2004 03:47:14 -0000 1.11 *************** *** 398,402 **** self.assert_("foo" in realpath("foo")) self.assertRaises(TypeError, posixpath.realpath) ! if hasattr(os, "symlink"): def test_realpath_basic(self): --- 398,402 ---- self.assert_("foo" in realpath("foo")) self.assertRaises(TypeError, posixpath.realpath) ! if hasattr(os, "symlink"): def test_realpath_basic(self): *************** *** 407,411 **** finally: self.safe_remove(ABSTFN) ! def test_realpath_symlink_loops(self): # Bug #930024, return the path unchanged if we get into an infinite --- 407,411 ---- finally: self.safe_remove(ABSTFN) ! def test_realpath_symlink_loops(self): # Bug #930024, return the path unchanged if we get into an infinite *************** *** 430,434 **** self.safe_remove(ABSTFN+"2") ! def test_realpath_resolve_parents(self): # We also need to resolve any symlinks in the parents of a relative # path passed to realpath. E.g.: current working directory is --- 430,434 ---- self.safe_remove(ABSTFN+"2") ! def test_realpath_resolve_parents(self): # We also need to resolve any symlinks in the parents of a relative # path passed to realpath. E.g.: current working directory is Index: test_zipfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_zipfile.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_zipfile.py 19 Aug 2004 15:11:50 -0000 1.11 --- test_zipfile.py 20 Aug 2004 03:47:14 -0000 1.12 *************** *** 4,8 **** except ImportError: zlib = None ! import zipfile, os, unittest --- 4,8 ---- except ImportError: zlib = None ! import zipfile, os, unittest From hyeshik at gmail.com Fri Aug 20 05:49:37 2004 From: hyeshik at gmail.com (Hye-Shik Chang) Date: Fri Aug 20 05:49:39 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libunicodedata.tex, 1.6, 1.7 In-Reply-To: References: Message-ID: <4f0b69dc04081920497697833d@mail.gmail.com> On Thu, 19 Aug 2004 19:36:29 -0700, nnorwitz@users.sourceforge.net wrote: > Update of /cvsroot/python/python/dist/src/Doc/lib > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9324/lib > > Modified Files: > libunicodedata.tex > Log Message: > Try to improve grammar and use versionadded > > Index: libunicodedata.tex > =================================================================== > RCS file: /cvsroot/python/python/dist/src/Doc/lib/libunicodedata.tex,v > retrieving revision 1.6 > retrieving revision 1.7 > diff -C2 -d -r1.6 -r1.7 > *** libunicodedata.tex 4 Aug 2004 07:38:33 -0000 1.6 > --- libunicodedata.tex 20 Aug 2004 02:36:27 -0000 1.7 > *************** > *** 73,78 **** > > \begin{funcdesc}{east_asian_width}{unichr} > ! Returns the east asian width of assigned to the Unicode character > \var{unichr} as string. > \end{funcdesc} > Thanks for fixing it! In fact, I copy&pasted it from a description of unicodedata.mirror. Will it need to fix it as well? :) Hye-Shik From loewis at users.sourceforge.net Fri Aug 20 08:19:26 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Aug 20 08:19:31 2004 Subject: [Python-checkins] python/dist/src/Lib/lib-tk tkFont.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3884 Modified Files: tkFont.py Log Message: Remove debug print. Index: tkFont.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/tkFont.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tkFont.py 20 Aug 2004 03:47:13 -0000 1.8 --- tkFont.py 20 Aug 2004 06:19:23 -0000 1.9 *************** *** 92,96 **** # if font config info supplied, apply it if font: - print "font=%r" % font root.tk.call("font", "configure", self.name, *font) else: --- 92,95 ---- From loewis at users.sourceforge.net Fri Aug 20 08:27:01 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Aug 20 08:27:03 2004 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.75,2.76 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4734/Modules Modified Files: readline.c Log Message: Fail fatally if strdup fails. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.75 retrieving revision 2.76 diff -C2 -d -r2.75 -r2.76 *** readline.c 18 Aug 2004 13:34:00 -0000 2.75 --- readline.c 20 Aug 2004 06:26:59 -0000 2.76 *************** *** 676,679 **** --- 676,681 ---- #ifdef SAVE_LOCALE char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); + if (!saved_locale) + Py_FatalError("not enough memory to save locale"); #endif *************** *** 824,827 **** --- 826,831 ---- #ifdef SAVE_LOCALE char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); + if (!saved_locale) + Py_FatalError("not enough memory to save locale"); setlocale(LC_CTYPE, ""); #endif From loewis at users.sourceforge.net Fri Aug 20 08:29:17 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Aug 20 08:29:20 2004 Subject: [Python-checkins] python/dist/src/Modules readline.c, 2.64.6.2, 2.64.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5023 Modified Files: Tag: release23-maint readline.c Log Message: Fail fatally if strdup fails. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.64.6.2 retrieving revision 2.64.6.3 diff -C2 -d -r2.64.6.2 -r2.64.6.3 *** readline.c 18 Aug 2004 13:35:49 -0000 2.64.6.2 --- readline.c 20 Aug 2004 06:29:14 -0000 2.64.6.3 *************** *** 592,595 **** --- 592,597 ---- #ifdef SAVE_LOCALE char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); + if (!saved_locale) + Py_FatalError("not enough memory to save locale"); #endif *************** *** 656,659 **** --- 658,663 ---- #ifdef SAVE_LOCALE char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); + if (!saved_locale) + Py_FatalError("not enough memory to save locale"); setlocale(LC_CTYPE, ""); #endif From loewis at users.sourceforge.net Fri Aug 20 08:35:48 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Aug 20 08:35:51 2004 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5496 Modified Files: tarfile.py Log Message: Replace tricky and/or with straight-forward if:else: Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tarfile.py 18 Aug 2004 13:57:44 -0000 1.16 --- tarfile.py 20 Aug 2004 06:35:46 -0000 1.17 *************** *** 1138,1142 **** tarinfo.uid = statres.st_uid tarinfo.gid = statres.st_gid ! tarinfo.size = not stat.S_ISDIR(stmd) and statres.st_size or 0 tarinfo.mtime = statres.st_mtime tarinfo.type = type --- 1138,1146 ---- tarinfo.uid = statres.st_uid tarinfo.gid = statres.st_gid ! if stat.S_ISDIR(stmd): ! # For a directory, the size must be 0 ! tarinfo.size = 0 ! else: ! tarinfo.size = statres.st_size tarinfo.mtime = statres.st_mtime tarinfo.type = type From loewis at users.sourceforge.net Fri Aug 20 09:31:46 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Aug 20 09:31:50 2004 Subject: [Python-checkins] python/dist/src/Lib xmlrpclib.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12380 Modified Files: xmlrpclib.py Log Message: Bump minimum Python version to 2.1. Fixes #1009803. Index: xmlrpclib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** xmlrpclib.py 5 Jun 2004 12:35:58 -0000 1.33 --- xmlrpclib.py 20 Aug 2004 07:31:37 -0000 1.34 *************** *** 9,16 **** # # Notes: ! # this version is designed to work with Python 1.5.2 or newer. ! # unicode encoding support requires at least Python 1.6. ! # experimental HTTPS requires Python 2.0 built with SSL sockets. ! # expat parser support requires Python 2.0 with pyexpat support. # # History: --- 9,13 ---- # # Notes: ! # this version is designed to work with Python 2.1 or newer. # # History: *************** *** 52,55 **** --- 49,53 ---- # 2003-07-12 gp Correct marshalling of Faults # 2003-10-31 mvl Add multicall support + # 2004-08-20 mvl Bump minimum supported Python version to 2.1 # # Copyright (c) 1999-2002 by Secret Labs AB. From loewis at users.sourceforge.net Fri Aug 20 09:32:08 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Aug 20 09:32:12 2004 Subject: [Python-checkins] python/nondist/peps pep-0291.txt,1.10,1.11 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12412 Modified Files: pep-0291.txt Log Message: Bump minimum version for xmlrpclib to 2.1. Fixes #1009803 Index: pep-0291.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0291.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pep-0291.txt 19 Aug 2004 22:58:30 -0000 1.10 --- pep-0291.txt 20 Aug 2004 07:32:06 -0000 1.11 *************** *** 87,91 **** sre Fredrik Lundh 2.1 xml (PyXML) Martin v. Loewis 2.0 ! xmlrpclib Fredrik Lundh 1.5.2 modulefinder Thomas Heller 2.2 Just van Rossum --- 87,91 ---- sre Fredrik Lundh 2.1 xml (PyXML) Martin v. Loewis 2.0 ! xmlrpclib Fredrik Lundh 2.1 modulefinder Thomas Heller 2.2 Just van Rossum From akuchling at users.sourceforge.net Fri Aug 20 14:40:42 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Fri Aug 20 14:40:45 2004 Subject: [Python-checkins] python/nondist/peps pep-3000.txt,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25956 Added Files: pep-3000.txt Log Message: Add PEP 3000 --- NEW FILE: pep-3000.txt --- PEP: 3000 Title: Python 3.0 Plans Version: $Revision: 1.1 $ Last-Modified: $Date: 2004/08/20 12:40:40 $ Author: A.M. Kuchling , Brett Cannon Status: Draft Type: Informational Content-Type: text/x-rst Created: 20-Aug-2004 Post-History: Abstract ======== This PEP describes the changes currently envisioned in Python 3.0, a hypothetical future release of Python that can break backwards compatibility with the existing body of Python code. The list of features included in this document is subject to change and isn't binding on the Python development community; features may be added, removed, and modified at any time. The purpose of this list is to focus our language development effort on changes that are steps to 3.0, and to encourage people to invent ways to smooth the transition. This document is not a wish-list that anyone can extend. While there are two authors of this PEP, we're just supplying the text; the decisions for which changes are listed in this document are made by Guido van Rossum, who has chosen them as goals for Python 3.0. General goals ============= A general goal is to reduce feature duplication by removing old ways of doing things. A general principle of the design will be that one obvious way of doing something is enough. [1]_ Core language ============= * Remove distinction between int and long types. [1]_ * Make all strings be Unicode, and have a separate bytes() type. [1]_ * `exec` as a statement is not worth it -- make it a function * Add optional declarations for static typing * Support only new-style classes; classic classes will be gone. [1]_ * Add a 'with' statement:: with self: .foo = [1, 2, 3] .bar(4, .foo) * Return iterators instead of lists * `d.keys()`, `.values()`, `.items()` * `range()`, `zip()` * Replace `print` by a function: `write(x,y,z)`, `writeln(x,y,z)` [2]_ * Do something so you can catch multiple exceptions using `except E1, E2, E3:`. Maybe use `except E1, E2, E3 as err:` if you want the error variable? [3]_ To be removed: * The `lambda` statement [1]_ * String exceptions [2]_ * ``\`x\```: use `repr(x)` [2]_ Built-ins ========= Changes: * make `range()` return an iterator * Relevant functions should consume iterators (e.g. `min()`, `max()`) To be removed: * `apply()`: use `f(*args, **kw)` instead [2]_ * `buffer()`: must die (use a bytes() type instead) [2]_ * `callable()`: just call the object and catch the exception [2]_ * `compile()`: put in `sys` (or perhaps in a module of its own) [2]_ * `coerce()`: no longer needed [2]_ * `execfile()`, `reload()`: use `exec()` [2]_ * `input()`: use `eval(sys.stdin.readline())` [2]_ * `intern()`, `id()`: put in `sys` [2]_ * `map()`, `filter()`: use list comprehensions instead [1]_ * `raw_input()`: use `sys.stdin.readline()` [2]_ * `reduce()`: write a loop instead [2]_ * `xrange()`: use `range()` instead [1]_ Standard library ================ Reorganize the standard library into packages To be removed: * `string` and other deprecated modules [1]_ * `sys.exc_type`: not thread-safe; use `sys.exc_info` [2]_ References ========== .. [1] PyCon 2003 State of the Union: http://www.python.org/doc/essays/ppt/pycon2003/pycon2003.ppt .. [2] Python Regrets: http://www.python.org/doc/essays/ppt/regrets/PythonRegrets.pdf .. [3] Python Wiki: http://www.python.org/moin/Python3.0 Copyright ========= This document has been placed in the public domain. .. Local Variables: mode: indented-text indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 End: From akuchling at users.sourceforge.net Fri Aug 20 14:43:22 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Fri Aug 20 14:43:24 2004 Subject: [Python-checkins] python/nondist/peps pep-0000.txt,1.281,1.282 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26424 Modified Files: pep-0000.txt Log Message: Add PEP 3000 Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.281 retrieving revision 1.282 diff -C2 -d -r1.281 -r1.282 *** pep-0000.txt 18 Aug 2004 11:56:16 -0000 1.281 --- pep-0000.txt 20 Aug 2004 12:43:19 -0000 1.282 *************** *** 58,61 **** --- 58,62 ---- I 306 How to Change Python's Grammar Hudson I 320 Python 2.4 Release Schedule Warsaw + I 3000 Python 3.0 Plans Kuchling, Cannon Accepted PEPs (accepted; may not be implemented yet) *************** *** 358,361 **** --- 359,363 ---- SR 666 Reject Foolish Indentation Creighton S 754 IEEE 754 Floating Point Special Values Warnes + I 3000 Python 3.0 Plans Kuchling, Cannon *************** *** 384,387 **** --- 386,390 ---- Baxter, Anthony anthony@interlink.com.au Bellman, Thomas bellman+pep-divmod@lysator.liu.se + Cannon, Brett drifty@alum.berkeley.edu Carlson, Josiah jcarlson@uci.edu Carroll, W Isaac icarroll@pobox.com From bwarsaw at users.sourceforge.net Fri Aug 20 16:20:41 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri Aug 20 16:20:50 2004 Subject: [Python-checkins] python/nondist/peps pep-0292.txt,1.10,1.11 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12176 Modified Files: pep-0292.txt Log Message: The classes have been renamed Template and SafeTemplate. Also, a bunch of open issues have been added. Index: pep-0292.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0292.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- pep-0292.txt 11 Aug 2004 15:05:26 -0000 1.10 +++ pep-0292.txt 20 Aug 2004 14:20:38 -0000 1.11 @@ -43,9 +43,9 @@ A Simpler Proposal - We propose the addition of a new class -- called 'template', which + We propose the addition of a new class -- called 'Template', which will live in the string module -- derived from the built-in - unicode type. The template class supports new rules for string + unicode type. The Template class supports new rules for string substitution; its value contains placeholders, introduced with the $ character. The following rules for $-placeholders apply: @@ -64,39 +64,39 @@ If the $ character appears at the end of the line, or is followed by any other character than those described above, it is treated as if it had been escaped, appearing in the resulting string - unchanged. + unchanged. NOTE: see open issues below. No other characters have special meaning, however it is possible - to derive from the template class to define different rules for + to derive from the Template class to define different rules for the placeholder. For example, a derived class could allow for periods in the placeholder (e.g. to support a kind of dynamic namespace and attribute path lookup). - Once the template has been created, substitutions can be performed + Once the Template has been created, substitutions can be performed using traditional Python syntax. For example: - >>> from string import template + >>> from string import Template >>> mapping = dict(name='Guido', country='the Netherlands') - >>> s = template('${name} was born in ${country}') + >>> s = Template('${name} was born in ${country}') >>> print s % mapping Guido was born in the Netherlands - Another class is provided which derives from template. This class - is called 'safe_template' and supports rules identical to those - above. The difference between template instances and - safe_template instances is that if a placeholder is missing from + Another class is provided which derives from Template. This class + is called 'SafeTemplate' and supports rules identical to those + above. The difference between Template instances and SafeTemplate + instances is that in SafeTemplate if a placeholder is missing from the interpolation mapping, no KeyError is raised. Instead, the original placeholder is included in the result string unchanged. For example: - >>> from string import template, safe_template + >>> from string import Template, SafeTemplate >>> mapping = dict(name='Guido', country='the Netherlands') - >>> s = template('$who was born in $country') + >>> s = Template('$who was born in $country') >>> print s % mapping Traceback (most recent call last): [...traceback omitted...] KeyError: u'who' - >>> s = safe_template('$who was born in $country') + >>> s = SafeTemplate('$who was born in $country') >>> print s % mapping $who was born in the Netherlands @@ -135,12 +135,12 @@ quite complex, and make it more difficult to see the substitution placeholder in the original $-string. - The interesting thing is that the template class defined in this + The interesting thing is that the Template class defined in this PEP has nothing to say about the values that are substituted for the placeholders. Thus, with a little extra work, it's possible to support PEP 215's functionality using existing Python syntax. - For example, one could define subclasses of template and dict that + For example, one could define subclasses of Template and dict that allowed for a more complex placeholder syntax and a mapping that evaluated those placeholders. @@ -150,17 +150,69 @@ The implementation supports internationalization magic by keeping the original string value intact. In fact, all the work of the special substitution rules are implemented by overriding the - __mod__() operator. However the string value of a template (or - safe_template) is the string that was passed to its constructor. + __mod__() operator. However the string value of a Template (or + SafeTemplate) is the string that was passed to its constructor. This approach allows a gettext-based internationalized program to - use the template instance as a lookup into the catalog; in fact - gettext doesn't care that the catalog key is a template. Because - the value of the template is the original $-string, translators + use the Template instance as a lookup into the catalog; in fact + gettext doesn't care that the catalog key is a Template. Because + the value of the Template is the original $-string, translators also never need to use %-strings. The right thing will happen at run-time. +Open Issues + + - Should the Template and SafeTemplate classes convert mapping + values to strings (or unicodes)? I.e. what should this code do: + + >>> from string import Template + >>> Template('The cost was $amount euros') % {'amount': 7} + + Should this raise an exception such as TypeError, or should this + return the string 'The cose was 7 euros'? + + PEP author preference: no automatic stringification. + + - The pattern for placeholders in the Template and SafeTemplate + classes matches Python identifiers. Some people want to match + Python attribute paths, e.g. "$os.path.sep". This can be useful + in some applications, however note that it is up to the + interpolation mapping to provide namespace lookup for the + attribute paths. + + Should we include AttributeTemplate and SafeAttributeTemplate in + the standard library? What about more complex patterns such as + Python expressions? + + PEP author preference: No, we don't include them for now. Such + classes are easily derived, and besides, we're not proposing to + include any interpolation mappings, and without such a + specialized mapping, a pattern matching attribute paths or + expressions aren't useful. + + - Where does the Template and SafeTemplate classes live? Some + people have suggested creating a stringtools or stringlib module + to house these two classes. The PEP author has proposed a + re-organization of the existing string module, turning it into a + string package. + + PEP author preference: There seems little consensus around + either suggestion, and since the classes are just a few lines of + Python, I propose no string module re-organization, but to add + these two classes to string.py. + + - Should the $-placeholder rules be more strict? Specifically, + objections have been raised about 'magically' escaping $'s at + the end of strings, or in strings like '$100'. The suggestion + was that we add another matching group which matches bare $'s, + raising a ValueError if we find such a match. + + PEP author preference: This sounds fine to me, although because + the pattern is part of the public interface for the class, we + will have to document that 4 groups are expected instead of 3. + + References [1] String Formatting Operations From jlgijsbers at users.sourceforge.net Fri Aug 20 16:37:07 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Fri Aug 20 16:37:10 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15057 Modified Files: libdoctest.tex Log Message: Quote # as \# to make lib compile again. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- libdoctest.tex 19 Aug 2004 16:38:58 -0000 1.28 +++ libdoctest.tex 20 Aug 2004 14:37:05 -0000 1.29 @@ -362,7 +362,7 @@ \begin{productionlist}[doctest] \production{directive} - {"#" "doctest:" \token{on_or_off} \token{directive_name}} + {"\#" "doctest:" \token{on_or_off} \token{directive_name}} \production{on_or_off} {"+" | "-"} \production{directive_name} From jlgijsbers at users.sourceforge.net Fri Aug 20 16:38:59 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Fri Aug 20 16:39:01 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libimp.tex,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15442 Modified Files: libimp.tex Log Message: Correct argument specifications of load_compiled and load_source: the file argument is optional on both (the format string is "ss|O!"). Index: libimp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimp.tex,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- libimp.tex 12 Feb 2003 23:02:18 -0000 1.35 +++ libimp.tex 20 Aug 2004 14:38:56 -0000 1.36 @@ -192,7 +192,7 @@ no such module. \end{funcdesc} -\begin{funcdesc}{load_compiled}{name, pathname, file} +\begin{funcdesc}{load_compiled}{name, pathname, \optional{file}} \indexii{file}{byte-code} Load and initialize a module implemented as a byte-compiled code file and return its module object. If the module was already initialized, @@ -218,7 +218,7 @@ support it.) \end{funcdesc} -\begin{funcdesc}{load_source}{name, pathname, file} +\begin{funcdesc}{load_source}{name, pathname\optional{, file}} Load and initialize a module implemented as a Python source file and return its module object. If the module was already initialized, it will be initialized \emph{again}. The \var{name} argument is used to From goodger at users.sourceforge.net Fri Aug 20 17:05:42 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Fri Aug 20 17:05:45 2004 Subject: [Python-checkins] python/nondist/peps pep-3000.txt,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20020 Modified Files: pep-3000.txt Log Message: markup, wrapping Index: pep-3000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-3000.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- pep-3000.txt 20 Aug 2004 12:40:40 -0000 1.1 +++ pep-3000.txt 20 Aug 2004 15:05:39 -0000 1.2 @@ -2,13 +2,13 @@ Title: Python 3.0 Plans Version: $Revision$ Last-Modified: $Date$ -Author: A.M. Kuchling , +Author: A.M. Kuchling , Brett Cannon Status: Draft Type: Informational Content-Type: text/x-rst Created: 20-Aug-2004 -Post-History: +Post-History: Abstract @@ -16,7 +16,7 @@ This PEP describes the changes currently envisioned in Python 3.0, a hypothetical future release of Python that can break backwards -compatibility with the existing body of Python code. +compatibility with the existing body of Python code. The list of features included in this document is subject to change and isn't binding on the Python development community; features may be @@ -27,7 +27,8 @@ This document is not a wish-list that anyone can extend. While there are two authors of this PEP, we're just supplying the text; the decisions for which changes are listed in this document are made by -Guido van Rossum, who has chosen them as goals for Python 3.0. +Guido van Rossum, who has chosen them as goals for Python 3.0. + General goals ============= @@ -42,7 +43,7 @@ * Remove distinction between int and long types. [1]_ * Make all strings be Unicode, and have a separate bytes() type. [1]_ -* `exec` as a statement is not worth it -- make it a function +* ``exec`` as a statement is not worth it -- make it a function * Add optional declarations for static typing * Support only new-style classes; classic classes will be gone. [1]_ * Add a 'with' statement:: @@ -52,18 +53,19 @@ .bar(4, .foo) * Return iterators instead of lists -* `d.keys()`, `.values()`, `.items()` -* `range()`, `zip()` -* Replace `print` by a function: `write(x,y,z)`, `writeln(x,y,z)` [2]_ -* Do something so you can catch multiple exceptions using `except E1, - E2, E3:`. Maybe use `except E1, E2, E3 as err:` if you want the error - variable? [3]_ +* ``d.keys()``, ``.values()``, ``.items()`` +* ``range()``, ``zip()`` +* Replace ``print`` by a function: ``write(x,y,z)``, + ``writeln(x,y,z)`` [2]_ +* Do something so you can catch multiple exceptions using ``except E1, + E2, E3:``. Maybe use ``except E1, E2, E3 as err:`` if you want the + error variable? [3]_ To be removed: -* The `lambda` statement [1]_ +* The ``lambda`` statement [1]_ * String exceptions [2]_ -* ``\`x\```: use `repr(x)` [2]_ +* ```x```: use ``repr(x)`` [2]_ Built-ins @@ -71,24 +73,26 @@ Changes: -* make `range()` return an iterator -* Relevant functions should consume iterators (e.g. `min()`, `max()`) - +* make ``range()`` return an iterator +* Relevant functions should consume iterators (e.g. ``min()``, + ``max()``) + To be removed: -* `apply()`: use `f(*args, **kw)` instead [2]_ -* `buffer()`: must die (use a bytes() type instead) [2]_ -* `callable()`: just call the object and catch the exception [2]_ -* `compile()`: put in `sys` (or perhaps in a module of its own) [2]_ -* `coerce()`: no longer needed [2]_ -* `execfile()`, `reload()`: use `exec()` [2]_ -* `input()`: use `eval(sys.stdin.readline())` [2]_ -* `intern()`, `id()`: put in `sys` [2]_ -* `map()`, `filter()`: use list comprehensions instead [1]_ -* `raw_input()`: use `sys.stdin.readline()` [2]_ -* `reduce()`: write a loop instead [2]_ -* `xrange()`: use `range()` instead [1]_ +* ``apply()``: use ``f(*args, **kw)`` instead [2]_ +* ``buffer()``: must die (use a bytes() type instead) [2]_ +* ``callable()``: just call the object and catch the exception [2]_ +* ``compile()``: put in ``sys`` (or perhaps in a module of its own) + [2]_ +* ``coerce()``: no longer needed [2]_ +* ``execfile()``, ``reload()``: use ``exec()`` [2]_ +* ``input()``: use ``eval(sys.stdin.readline())`` [2]_ +* ``intern()``, ``id()``: put in ``sys`` [2]_ +* ``map()``, ``filter()``: use list comprehensions instead [1]_ +* ``raw_input()``: use ``sys.stdin.readline()`` [2]_ +* ``reduce()``: write a loop instead [2]_ +* ``xrange()``: use ``range()`` instead [1]_ Standard library @@ -98,20 +102,20 @@ To be removed: -* `string` and other deprecated modules [1]_ -* `sys.exc_type`: not thread-safe; use `sys.exc_info` [2]_ +* ``string`` and other deprecated modules [1]_ +* ``sys.exc_type``: not thread-safe; use ``sys.exc_info`` [2]_ References ========== -.. [1] PyCon 2003 State of the Union: +.. [1] PyCon 2003 State of the Union: http://www.python.org/doc/essays/ppt/pycon2003/pycon2003.ppt -.. [2] Python Regrets: +.. [2] Python Regrets: http://www.python.org/doc/essays/ppt/regrets/PythonRegrets.pdf -.. [3] Python Wiki: +.. [3] Python Wiki: http://www.python.org/moin/Python3.0 From nnorwitz at users.sourceforge.net Sat Aug 21 01:13:29 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sat Aug 21 01:13:36 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libunicodedata.tex, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22817/lib Modified Files: libunicodedata.tex Log Message: Fix grammar, spotted by Hye-Shik Chang Index: libunicodedata.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libunicodedata.tex,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- libunicodedata.tex 20 Aug 2004 02:36:27 -0000 1.7 +++ libunicodedata.tex 20 Aug 2004 23:13:26 -0000 1.8 @@ -78,7 +78,7 @@ \end{funcdesc} \begin{funcdesc}{mirrored}{unichr} - Returns the mirrored property of assigned to the Unicode character + Returns the mirrored property assigned to the Unicode character \var{unichr} as integer. Returns \code{1} if the character has been identified as a ``mirrored'' character in bidirectional text, \code{0} otherwise. From neal at metaslash.com Sat Aug 21 01:14:22 2004 From: neal at metaslash.com (Neal Norwitz) Date: Sat Aug 21 01:14:27 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libunicodedata.tex, 1.6, 1.7 In-Reply-To: <4f0b69dc04081920497697833d@mail.gmail.com> References: <4f0b69dc04081920497697833d@mail.gmail.com> Message-ID: <20040820231422.GL31470@epoch.metaslash.com> On Fri, Aug 20, 2004 at 12:49:37PM +0900, Hye-Shik Chang wrote: > > > > \begin{funcdesc}{east_asian_width}{unichr} > > ! Returns the east asian width of assigned to the Unicode character > > \var{unichr} as string. > > \end{funcdesc} > > Thanks for fixing it! In fact, I copy&pasted it from a description > of unicodedata.mirror. Will it need to fix it as well? :) I don't see why, it's only been in there since version 1.1, 13-Jun-2000. :-) I fixed that too. Thanks! Neal From tim_one at users.sourceforge.net Sat Aug 21 08:55:44 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Aug 21 08:55:49 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_StringIO.py, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13308/Lib/test Modified Files: test_StringIO.py Log Message: Patch 1012740: cStringIO's truncate doesn't truncate() left the stream position unchanged, which meant the "truncated" data didn't go away: >>> io.write('abc') >>> io.truncate(0) >>> io.write('xyz') >>> io.getvalue() 'abcxyz' Patch by Dima Dorfman. Index: test_StringIO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_StringIO.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- test_StringIO.py 8 Aug 2003 12:20:03 -0000 1.17 +++ test_StringIO.py 21 Aug 2004 06:55:42 -0000 1.18 @@ -49,9 +49,10 @@ f.seek(10) f.truncate() eq(f.getvalue(), 'abcdefghij') - f.seek(0) f.truncate(5) eq(f.getvalue(), 'abcde') + f.write('xyz') + eq(f.getvalue(), 'abcdexyz') f.close() self.assertRaises(ValueError, f.write, 'frobnitz') From tim_one at users.sourceforge.net Sat Aug 21 08:55:46 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Aug 21 08:55:51 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1106,1.1107 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13308/Misc Modified Files: NEWS Log Message: Patch 1012740: cStringIO's truncate doesn't truncate() left the stream position unchanged, which meant the "truncated" data didn't go away: >>> io.write('abc') >>> io.truncate(0) >>> io.write('xyz') >>> io.getvalue() 'abcxyz' Patch by Dima Dorfman. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1106 retrieving revision 1.1107 diff -u -d -r1.1106 -r1.1107 --- NEWS 19 Aug 2004 17:52:37 -0000 1.1106 +++ NEWS 21 Aug 2004 06:55:42 -0000 1.1107 @@ -41,6 +41,11 @@ Extension modules ----------------- +- Patch 1012740: truncate() on a writeable cStringIO now resets the + position to the end of the stream. This is consistent with the original + StringIO module and avoids inadvertently resurrecting data that was + supposed to have been truncated away. + - Added socket.socketpair(). Library @@ -59,7 +64,7 @@ - A new function tkFont.nametofont was added to return an existing font. The Font class constructor now has an additional exists argument which, if True, requests to return/configure an existing font, rather - than creating a new one. + than creating a new one. - Updated the decimal package's min() and max() methods to match the latest revision of the General Decimal Arithmetic Specification. From tim_one at users.sourceforge.net Sat Aug 21 08:55:46 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Aug 21 08:55:54 2004 Subject: [Python-checkins] python/dist/src/Modules cStringIO.c,2.48,2.49 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13308/Modules Modified Files: cStringIO.c Log Message: Patch 1012740: cStringIO's truncate doesn't truncate() left the stream position unchanged, which meant the "truncated" data didn't go away: >>> io.write('abc') >>> io.truncate(0) >>> io.write('xyz') >>> io.getvalue() 'abcxyz' Patch by Dima Dorfman. Index: cStringIO.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cStringIO.c,v retrieving revision 2.48 retrieving revision 2.49 diff -u -d -r2.48 -r2.49 --- cStringIO.c 27 Jun 2004 17:24:49 -0000 2.48 +++ cStringIO.c 21 Aug 2004 06:55:43 -0000 2.49 @@ -289,6 +289,7 @@ if (pos < 0) pos = self->pos; if (self->string_size > pos) self->string_size = pos; + self->pos = self->string_size; Py_INCREF(Py_None); return Py_None; From jlgijsbers at users.sourceforge.net Sat Aug 21 12:43:32 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 21 12:43:36 2004 Subject: [Python-checkins] python/dist/src/Lib SimpleHTTPServer.py, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17182 Modified Files: SimpleHTTPServer.py Log Message: Patch #1011123: Use urllib.quote() instead of cgi.escape() for encoding the href attribute in list_directory(). This fixes the links for legal Unix filenames such as 'a"b'. Index: SimpleHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/SimpleHTTPServer.py,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- SimpleHTTPServer.py 7 Aug 2004 19:02:19 -0000 1.21 +++ SimpleHTTPServer.py 21 Aug 2004 10:43:29 -0000 1.22 @@ -105,7 +105,7 @@ f.write("
\n
    \n") for name in list: fullname = os.path.join(path, name) - displayname = linkname = name = cgi.escape(name) + displayname = linkname = name # Append / for directories or @ for symbolic links if os.path.isdir(fullname): displayname = name + "/" @@ -113,7 +113,8 @@ if os.path.islink(fullname): displayname = name + "@" # Note: a link to a directory displays with @ and links with / - f.write('
  • %s\n' % (linkname, displayname)) + f.write('
  • %s\n' + % (urllib.quote(linkname), cgi.escape(displayname))) f.write("
\n
\n") length = f.tell() f.seek(0) From jlgijsbers at users.sourceforge.net Sat Aug 21 14:30:29 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Aug 21 14:30:34 2004 Subject: [Python-checkins] python/dist/src/Lib mailbox.py,1.43,1.44 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15151 Modified Files: mailbox.py Log Message: Patch #880621: the last message of a Babyl mailbox ends in '\037' instead of '\037\014\n' (see http://quimby.gnus.org/notes/BABYL) so look for that as well, so that applications won't get '\037' as the last line of the last message. Index: mailbox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailbox.py,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- mailbox.py 24 Jul 2004 19:54:44 -0000 1.43 +++ mailbox.py 21 Aug 2004 12:30:26 -0000 1.44 @@ -259,7 +259,7 @@ line = self.fp.readline() if not line: return - if line == '\037\014\n': + if line == '\037\014\n' or line == '\037': self.fp.seek(pos) return From nnorwitz at users.sourceforge.net Sat Aug 21 17:13:55 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sat Aug 21 17:13:59 2004 Subject: [Python-checkins] python/dist/src/Doc/texinputs python.sty, 1.109, 1.110 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29103/Doc/texinputs Modified Files: python.sty Log Message: sf #1009373, #1005936. fix underscores in index entries in PDF files. I couldn't test this, but it didn't break anything and the patch reported fixed the problem. Bugfix candidate. Index: python.sty =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.109 retrieving revision 1.110 diff -u -d -r1.109 -r1.110 --- python.sty 31 Mar 2004 08:08:34 -0000 1.109 +++ python.sty 21 Aug 2004 15:13:52 -0000 1.110 @@ -72,6 +72,7 @@ \py@OldContentsline{#1}{\py@linkToName{page\my@pageno}{#2}}{#3}% } \AtEndDocument{ + \def\_{\string_} \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{} } \newcommand{\py@target}[1]{% From nnorwitz at users.sourceforge.net Sat Aug 21 17:13:55 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sat Aug 21 17:14:01 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1107,1.1108 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29103/Misc Modified Files: NEWS Log Message: sf #1009373, #1005936. fix underscores in index entries in PDF files. I couldn't test this, but it didn't break anything and the patch reported fixed the problem. Bugfix candidate. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1107 retrieving revision 1.1108 diff -u -d -r1.1107 -r1.1108 --- NEWS 21 Aug 2004 06:55:42 -0000 1.1107 +++ NEWS 21 Aug 2004 15:13:51 -0000 1.1108 @@ -140,9 +140,12 @@ Documentation ------------- -- bug #990669: os.path.normpath may alter the meaning of a path if it contains -symbolic links. This has been documented in a comment since 1992, but is now in -the library reference as well. +- patch #1005936, bug #1009373: fix index entries which contain + an underscore when viewed with Acrobat. + +- bug #990669: os.path.normpath may alter the meaning of a path if + it contains symbolic links. This has been documented in a comment + since 1992, but is now in the library reference as well. New platforms ------------- From tim_one at users.sourceforge.net Sun Aug 22 03:47:54 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 22 03:48:00 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.72,1.73 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24857/Lib Modified Files: doctest.py Log Message: _ellipsis_match(): Removed special-casing of "...\n". The semantics are non-obvious either way because the newline character "is invisible", but it's still there all the same, and it's easier to explain/predict if that reality is left alone. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.72 retrieving revision 1.73 diff -u -d -r1.72 -r1.73 --- doctest.py 20 Aug 2004 02:08:04 -0000 1.72 +++ doctest.py 22 Aug 2004 01:47:51 -0000 1.73 @@ -398,10 +398,6 @@ """ if ELLIPSIS_MARKER not in want: return want == got - # Remove \n from ...\n, else the newline will be required, - # and (for example) ... on a line by itself can't match - # nothing gracefully. - want = want.replace(ELLIPSIS_MARKER + '\n', ELLIPSIS_MARKER) # Find "the real" strings. ws = want.split(ELLIPSIS_MARKER) From tim_one at users.sourceforge.net Sun Aug 22 03:47:54 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 22 03:48:02 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.24, 1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24857/Lib/test Modified Files: test_doctest.py Log Message: _ellipsis_match(): Removed special-casing of "...\n". The semantics are non-obvious either way because the newline character "is invisible", but it's still there all the same, and it's easier to explain/predict if that reality is left alone. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- test_doctest.py 19 Aug 2004 16:38:57 -0000 1.24 +++ test_doctest.py 22 Aug 2004 01:47:51 -0000 1.25 @@ -785,40 +785,17 @@ >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) (0, 1) - ... should also match nothing gracefully (note that a regular-expression - implementation of ELLIPSIS would take a loooong time to match this one!): + ... also matches nothing: >>> for i in range(100): - ... print i**2 #doctest: +ELLIPSIS - 0 - ... - 1 - ... - ...... - ... - 36 - ... - ... - ... - 49 - 64 - ......... - 9801 - ... + ... print i**2, #doctest: +ELLIPSIS + 0 1...4...9 16 ... 36 49 64 ... 9801 ... can be surprising; e.g., this test passes: >>> for i in range(21): #doctest: +ELLIPSIS - ... print i - 0 - 1 - 2 - ... - 1 - ... - 2 - ... - 0 + ... print i, + 0 1 2 ...1...2...0 Examples from the docs: From kbk at users.sourceforge.net Sun Aug 22 07:14:36 2004 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Sun Aug 22 07:14:41 2004 Subject: [Python-checkins] python/dist/src/Lib/idlelib Debugger.py, 1.21, 1.22 EditorWindow.py, 1.61, 1.62 FileList.py, 1.7, 1.8 NEWS.txt, 1.39, 1.40 PyShell.py, 1.90, 1.91 WindowList.py, 1.5, 1.6 idlever.py, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13140 Modified Files: Debugger.py EditorWindow.py FileList.py NEWS.txt PyShell.py WindowList.py idlever.py Log Message: 1. If user passes a non-existant filename on the commandline, just open a new file, don't raise a dialog. IDLEfork 954928. 2. Refactor EditorWindow.wakeup() to WindowList.ListedToplevel.wakeup() and clarify that the Toplevel of an EditorWindow is a WindowList.ListedToplevel. 3. Make a number of improvements to keyboard focus binding. Improve window raising, especially in the debugger. IDLEfork Bug 763524 (GvR list). 4. Bump idlever to 1.1a3 M Debugger.py M EditorWindow.py M FileList.py M NEWS.txt M PyShell.py M WindowList.py M idlever.py Index: Debugger.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/Debugger.py,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- Debugger.py 10 May 2003 00:09:52 -0000 1.21 +++ Debugger.py 22 Aug 2004 05:14:24 -0000 1.22 @@ -84,7 +84,7 @@ pyshell = self.pyshell self.flist = pyshell.flist self.root = root = pyshell.root - self.top = top =ListedToplevel(root) + self.top = top = ListedToplevel(root) self.top.wm_title("Debug Control") self.top.wm_iconname("Debug") top.wm_protocol("WM_DELETE_WINDOW", self.close) @@ -155,7 +155,6 @@ if self.vglobals.get(): self.show_globals() - def interaction(self, message, frame, info=None): self.frame = frame self.status.configure(text=message) @@ -191,7 +190,7 @@ for b in self.buttons: b.configure(state="normal") # - self.top.tkraise() + self.top.wakeup() self.root.mainloop() # for b in self.buttons: Index: EditorWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- EditorWindow.py 21 Jul 2004 03:33:58 -0000 1.61 +++ EditorWindow.py 22 Aug 2004 05:14:31 -0000 1.62 @@ -75,7 +75,7 @@ root = root or flist.root self.root = root self.menubar = Menu(root) - self.top = top = self.Toplevel(root, menu=self.menubar) + self.top = top = WindowList.ListedToplevel(root, menu=self.menubar) if flist: self.tkinter_vars = flist.vars #self.top.instance_dict makes flist.inversedict avalable to @@ -102,6 +102,7 @@ 'cursor',fgBg='fg'), width=self.width, height=idleConf.GetOption('main','EditorWindow','height') ) + self.top.focused_widget = self.text self.createmenubar() self.apply_bindings() @@ -236,13 +237,6 @@ self.status_bar.set_label('column', 'Col: %s' % column) self.status_bar.set_label('line', 'Ln: %s' % line) - def wakeup(self): - if self.top.wm_state() == "iconic": - self.top.wm_deiconify() - else: - self.top.tkraise() - self.text.focus_set() - menu_specs = [ ("file", "_File"), ("edit", "_Edit"), Index: FileList.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/FileList.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- FileList.py 12 Feb 2004 17:35:09 -0000 1.7 +++ FileList.py 22 Aug 2004 05:14:32 -0000 1.8 @@ -1,27 +1,12 @@ -# changes by dscherer@cmu.edu -# - FileList.open() takes an optional 3rd parameter action, which is -# called instead of creating a new EditorWindow. This enables -# things like 'open in same window'. - import os from Tkinter import * import tkMessageBox -import WindowList - -#$ event <> -#$ win -#$ unix - -# (This is labeled as 'Exit'in the File menu) -#$ event <> -#$ win -#$ unix class FileList: - from EditorWindow import EditorWindow - EditorWindow.Toplevel = WindowList.ListedToplevel # XXX Patch it! + from EditorWindow import EditorWindow # class variable, may be overridden + # e.g. by PyShellFileList def __init__(self, root): self.root = root @@ -33,25 +18,22 @@ assert filename filename = self.canonize(filename) if os.path.isdir(filename): + # This can happen when bad filename is passed on command line: tkMessageBox.showerror( - "Is A Directory", - "The path %r is a directory." % (filename,), + "File Error", + "%r is a directory." % (filename,), master=self.root) return None key = os.path.normcase(filename) if self.dict.has_key(key): edit = self.dict[key] - edit.wakeup() + edit.top.wakeup() return edit - if not os.path.exists(filename): - tkMessageBox.showinfo( - "New File", - "Opening non-existent file %r" % (filename,), - master=self.root) - if action is None: - return self.EditorWindow(self, filename, key) - else: + if action: + # Don't create window, perform 'action', e.g. open in same window return action(filename) + else: + return self.EditorWindow(self, filename, key) def gotofileline(self, filename, lineno=None): edit = self.open(filename) Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- NEWS.txt 5 Aug 2004 07:21:01 -0000 1.39 +++ NEWS.txt 22 Aug 2004 05:14:32 -0000 1.40 @@ -1,8 +1,24 @@ +What's New in IDLE 1.1a3? +========================= + +*Release date: 02-SEP-2004* + +- Improve keyboard focus binding, especially in Windows menu. Improve + window raising, especially in the Windows menu and in the debugger. + IDLEfork 763524. + +- If user passes a non-existant filename on the commandline, just + open a new file, don't raise a dialog. IDLEfork 854928. + + What's New in IDLE 1.1a2? ========================= *Release date: 05-AUG-2004* +- EditorWindow.py was not finding the .chm help file on Windows. Typo + at Rev 1.54. Python Bug 990954 + - checking sys.platform for substring 'win' was breaking IDLE docs on Mac (darwin). Also, Mac Safari browser requires full file:// URIs. SF 900580. Index: PyShell.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/PyShell.py,v retrieving revision 1.90 retrieving revision 1.91 diff -u -d -r1.90 -r1.91 --- PyShell.py 6 Jul 2004 21:53:27 -0000 1.90 +++ PyShell.py 22 Aug 2004 05:14:32 -0000 1.91 @@ -96,7 +96,7 @@ class PyShellEditorWindow(EditorWindow): - "Regular text edit window when a shell is present" + "Regular text edit window in IDLE, supports breakpoints" def __init__(self, *args): self.breakpoints = [] @@ -258,15 +258,17 @@ class PyShellFileList(FileList): - "Extend base class: file list when a shell is present" + "Extend base class: IDLE supports a shell and breakpoints" + # override FileList's class variable, instances return PyShellEditorWindow + # instead of EditorWindow when new edit windows are created. EditorWindow = PyShellEditorWindow pyshell = None def open_shell(self, event=None): if self.pyshell: - self.pyshell.wakeup() + self.pyshell.top.wakeup() else: self.pyshell = PyShell(self) if self.pyshell: @@ -802,7 +804,6 @@ text.bind("<>", self.eof_callback) text.bind("<>", self.open_stack_viewer) text.bind("<>", self.toggle_debugger) - text.bind("<>", self.flist.open_shell) text.bind("<>", self.toggle_jit_stack_viewer) if use_subprocess: text.bind("<>", self.view_restart_mark) Index: WindowList.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/WindowList.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- WindowList.py 6 Jun 2003 21:58:38 -0000 1.5 +++ WindowList.py 22 Aug 2004 05:14:32 -0000 1.6 @@ -60,6 +60,7 @@ def __init__(self, master, **kw): Toplevel.__init__(self, master, kw) registry.add(self) + self.focused_widget = self def destroy(self): registry.delete(self) @@ -79,10 +80,10 @@ def wakeup(self): try: if self.wm_state() == "iconic": + self.wm_withdraw() self.wm_deiconify() - else: - self.tkraise() - self.focus_set() + self.tkraise() + self.focused_widget.focus_set() except TclError: # This can happen when the window menu was torn off. # Simply ignore it. Index: idlever.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/idlever.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- idlever.py 15 Jul 2004 04:54:57 -0000 1.17 +++ idlever.py 22 Aug 2004 05:14:32 -0000 1.18 @@ -1 +1 @@ -IDLE_VERSION = "1.1a2" +IDLE_VERSION = "1.1a3" From loewis at users.sourceforge.net Sun Aug 22 15:13:43 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 15:13:47 2004 Subject: [Python-checkins] python/nondist/sandbox/msi msi.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19375 Modified Files: msi.py Log Message: Stop using icons for Up and New Index: msi.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/msi/msi.py,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- msi.py 17 Aug 2004 15:39:09 -0000 1.33 +++ msi.py 22 Aug 2004 13:13:40 -0000 1.34 @@ -296,8 +296,6 @@ raise "Run icons.mak in PC directory" add_data(db, "Binary", [("PythonWin", msilib.Binary(srcdir+r"\PCbuild\installer.bmp")), # 152x328 pixels - ("Up",msilib.Binary("Up.bin")), - ("New",msilib.Binary("New.bin")), ("py.ico",msilib.Binary(srcdir+r"\PC\py.ico")), ]) add_data(db, "Icon", @@ -534,9 +532,9 @@ seldlg.control("DirectoryList", "DirectoryList", 135, 90, 208, 136, 3, "TARGETDIR", None, "PathEdit", None) seldlg.control("PathEdit", "PathEdit", 135, 230, 206, 16, 3, "TARGETDIR", None, "Next", None) - c = seldlg.pushbutton("Up", 306, 70, 18, 18, 3670019, "Up", None) + c = seldlg.pushbutton("Up", 306, 70, 18, 18, 3, "Up", None) c.event("DirectoryListUp", "0") - c = seldlg.pushbutton("NewDir", 324, 70, 18, 18, 3670019, "New", None) + c = seldlg.pushbutton("NewDir", 324, 70, 30, 18, 3, "New", None) c.event("DirectoryListNew", "0") ##################################################################### From jccarv at hotmail.com Sun Aug 22 15:17:50 2004 From: jccarv at hotmail.com (John Stovas) Date: Sun Aug 22 15:17:51 2004 Subject: [Python-checkins] Olimpics Message-ID: <20040822131749.B89A51E4003@bag.python.org> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20040822/bfdf6539/attachment.html From loewis at users.sourceforge.net Sun Aug 22 15:33:22 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 15:33:25 2004 Subject: [Python-checkins] python/dist/src/Tools/msi - New directory Message-ID: Update of /cvsroot/python/python/dist/src/Tools/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25399/msi Log Message: Directory /cvsroot/python/python/dist/src/Tools/msi added to the repository From loewis at users.sourceforge.net Sun Aug 22 15:34:37 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 15:34:42 2004 Subject: [Python-checkins] python/dist/src/Tools/msi README.txt, NONE, 1.1 msi.py, NONE, 1.1 msilib.py, NONE, 1.1 schema.py, NONE, 1.1 sequence.py, NONE, 1.1 uisample.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25717/msi Added Files: README.txt msi.py msilib.py schema.py sequence.py uisample.py Log Message: Move msi from sandbox to Tools. --- NEW FILE: README.txt --- Packaging Python as a Microsoft Installer Package (MSI) ======================================================= Using this library, Python can be packaged as a MS-Windows MSI file. To generate an installer package, you need a build tree. By default, the build tree root directory is assumed to be in "../..". This location can be changed by adding a file config.py; see the beginning of msi.py for additional customization options. The packaging process assumes that binaries have been generated according to the instructions in PCBuild/README.txt, and that you have either Visual Studio or the Platform SDK installed. In addition, you need the Python COM extensions, either from PythonWin, or from ActivePython. To invoke the script, open a cmd.exe window which has cabarc.exe in its PATH (e.g. "Visual Studio .NET 2003 Command Prompt"). Then invoke msi.py If everything succeeds, pythonX.Y.Z.msi is generated in the current directory. --- NEW FILE: msi.py --- # Python MSI Generator # (C) 2003 Martin v. Loewis # See "FOO" in comments refers to MSDN sections with the title FOO. import msilib, schema, sequence, os, glob, time from msilib import Feature, CAB, Directory, Dialog, Binary, add_data import uisample from win32com.client import constants # Settings can be overridden in config.py below # 1 for Itanium build msilib.Win64 = 0 # 0 for official python.org releases # 1 for intermediate releases by anybody, with # a new product code for every package. snapshot = 1 # 1 means that file extension is px, not py, # and binaries start with x testpackage = 0 # Location of build tree [...1038 lines suppressed...] default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"), ("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation", htmlfiles.id, None, None, None, None, None, None, None), ## Non-advertised shortcuts: must be associated with a registry component ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY", SystemFolderName+"msiexec", "/x%s" % product_code, None, None, None, None, None, None), ]) db.Commit() db = build_database() try: add_features(db) add_ui(db) add_files(db) add_registry(db) remove_old_versions(db) db.Commit() finally: del db --- NEW FILE: msilib.py --- # Microsoft Installer Library # (C) 2003 Martin v. Loewis import win32com.client.gencache import win32com.client import pythoncom, pywintypes from win32com.client import constants import re, string, os, sets, glob, popen2, sys, _winreg Win64 = 0 # Partially taken from Wine datasizemask= 0x00ff type_valid= 0x0100 type_localizable= 0x0200 typemask= 0x0c00 type_long= 0x0000 type_short= 0x0400 type_string= 0x0c00 type_binary= 0x0800 type_nullable= 0x1000 type_key= 0x2000 # XXX temporary, localizable? knownbits = datasizemask | type_valid | type_localizable | \ typemask | type_nullable | type_key # Summary Info Property IDs PID_CODEPAGE=1 PID_TITLE=2 PID_SUBJECT=3 PID_AUTHOR=4 PID_KEYWORDS=5 PID_COMMENTS=6 PID_TEMPLATE=7 PID_LASTAUTHOR=8 PID_REVNUMBER=9 PID_LASTPRINTED=11 PID_CREATE_DTM=12 PID_LASTSAVE_DTM=13 PID_PAGECOUNT=14 PID_WORDCOUNT=15 PID_CHARCOUNT=16 PID_APPNAME=18 PID_SECURITY=19 def reset(): global _directories _directories = sets.Set() def EnsureMSI(): win32com.client.gencache.EnsureModule('{000C1092-0000-0000-C000-000000000046}', 1033, 1, 0) def EnsureMSM(): try: win32com.client.gencache.EnsureModule('{0ADDA82F-2C26-11D2-AD65-00A0C9AF11A6}', 0, 1, 0) except pywintypes.com_error: win32com.client.gencache.EnsureModule('{0ADDA82F-2C26-11D2-AD65-00A0C9AF11A6}', 0, 2, 0) _Installer=None def MakeInstaller(): global _Installer if _Installer is None: EnsureMSI() _Installer = win32com.client.Dispatch('WindowsInstaller.Installer', resultCLSID='{000C1090-0000-0000-C000-000000000046}') return _Installer _Merge=None def MakeMerge2(): global _Merge if _Merge is None: EnsureMSM() _Merge = win32com.client.Dispatch("Msm.Merge2.1") return _Merge class Table: def __init__(self, name): self.name = name self.fields = [] def add_field(self, index, name, type): self.fields.append((index,name,type)) def sql(self): fields = [] keys = [] self.fields.sort() fields = [None]*len(self.fields) for index, name, type in self.fields: index -= 1 unk = type & ~knownbits if unk: print "%s.%s unknown bits %x" % (self.name, name, unk) size = type & datasizemask dtype = type & typemask if dtype == type_string: if size: tname="CHAR(%d)" % size else: tname="CHAR" elif dtype == type_short: assert size==2 tname = "SHORT" elif dtype == type_long: assert size==4 tname="LONG" elif dtype == type_binary: assert size==0 tname="OBJECT" else: tname="unknown" print "%s.%sunknown integer type %d" % (self.name, name, size) if type & type_nullable: flags = "" else: flags = " NOT NULL" if type & type_localizable: flags += " LOCALIZABLE" fields[index] = "`%s` %s%s" % (name, tname, flags) if type & type_key: keys.append("`%s`" % name) fields = ", ".join(fields) keys = ", ".join(keys) return "CREATE TABLE %s (%s PRIMARY KEY %s)" % (self.name, fields, keys) def create(self, db): v = db.OpenView(self.sql()) v.Execute(None) v.Close() class Binary: def __init__(self, fname): self.name = fname def __repr__(self): return 'msilib.Binary(os.path.join(dirname,"%s"))' % self.name def gen_schema(destpath, schemapath): d = MakeInstaller() schema = d.OpenDatabase(schemapath, win32com.client.constants.msiOpenDatabaseModeReadOnly) # XXX ORBER BY v=schema.OpenView("SELECT * FROM _Columns") curtable=None tables = [] v.Execute(None) f = open(destpath, "wt") f.write("from msilib import Table\n") while 1: r=v.Fetch() if not r:break name=r.StringData(1) if curtable != name: f.write("\n%s = Table('%s')\n" % (name,name)) curtable = name tables.append(name) f.write("%s.add_field(%d,'%s',%d)\n" % (name, r.IntegerData(2), r.StringData(3), r.IntegerData(4))) v.Close() f.write("\ntables=[%s]\n\n" % (", ".join(tables))) # Fill the _Validation table f.write("_Validation_records = [\n") v = schema.OpenView("SELECT * FROM _Validation") v.Execute(None) while 1: r = v.Fetch() if not r:break # Table, Column, Nullable f.write("(%s,%s,%s," % (`r.StringData(1)`, `r.StringData(2)`, `r.StringData(3)`)) def put_int(i): if r.IsNull(i):f.write("None, ") else:f.write("%d," % r.IntegerData(i)) def put_str(i): if r.IsNull(i):f.write("None, ") else:f.write("%s," % `r.StringData(i)`) put_int(4) # MinValue put_int(5) # MaxValue put_str(6) # KeyTable put_int(7) # KeyColumn put_str(8) # Category put_str(9) # Set put_str(10)# Description f.write("),\n") f.write("]\n\n") f.close() def gen_sequence(destpath, msipath): dir = os.path.dirname(destpath) d = MakeInstaller() seqmsi = d.OpenDatabase(msipath, win32com.client.constants.msiOpenDatabaseModeReadOnly) v = seqmsi.OpenView("SELECT * FROM _Tables"); v.Execute(None) f = open(destpath, "w") print >>f, "import msilib,os;dirname=os.path.dirname(__file__)" tables = [] while 1: r = v.Fetch() if not r:break table = r.StringData(1) tables.append(table) f.write("%s = [\n" % table) v1 = seqmsi.OpenView("SELECT * FROM `%s`" % table) v1.Execute(None) info = v1.ColumnInfo(constants.msiColumnInfoTypes) while 1: r = v1.Fetch() if not r:break rec = [] for i in range(1,r.FieldCount+1): if r.IsNull(i): rec.append(None) elif info.StringData(i)[0] in "iI": rec.append(r.IntegerData(i)) elif info.StringData(i)[0] in "slSL": rec.append(r.StringData(i)) elif info.StringData(i)[0]=="v": size = r.DataSize(i) bytes = r.ReadStream(i, size, constants.msiReadStreamBytes) bytes = bytes.encode("latin-1") # binary data represented "as-is" if table == "Binary": fname = rec[0]+".bin" open(os.path.join(dir,fname),"wb").write(bytes) rec.append(Binary(fname)) else: rec.append(bytes) else: raise "Unsupported column type", info.StringData(i) f.write(repr(tuple(rec))+",\n") v1.Close() f.write("]\n\n") v.Close() f.write("tables=%s\n" % repr(map(str,tables))) f.close() class _Unspecified:pass def change_sequence(seq, action, seqno=_Unspecified, cond = _Unspecified): "Change the sequence number of an action in a sequence list" for i in range(len(seq)): if seq[i][0] == action: if cond is _Unspecified: cond = seq[i][1] if seqno is _Unspecified: seqno = seq[i][2] seq[i] = (action, cond, seqno) return raise ValueError, "Action not found in sequence" def add_data(db, table, values): d = MakeInstaller() v = db.OpenView("SELECT * FROM `%s`" % table) count = v.ColumnInfo(0).FieldCount r = d.CreateRecord(count) for value in values: assert len(value) == count, value for i in range(count): field = value[i] if isinstance(field, (int, long)): r.SetIntegerData(i+1,field) elif isinstance(field, basestring): r.SetStringData(i+1,field) elif field is None: pass elif isinstance(field, Binary): r.SetStream(i+1, field.name) else: raise TypeError, "Unsupported type %s" % field.__class__.__name__ v.Modify(win32com.client.constants.msiViewModifyInsert, r) r.ClearData() v.Close() def add_stream(db, name, path): d = MakeInstaller() v = db.OpenView("INSERT INTO _Streams (Name, Data) VALUES ('%s', ?)" % name) r = d.CreateRecord(1) r.SetStream(1, path) v.Execute(r) v.Close() def init_database(name, schema, ProductName, ProductCode, ProductVersion, Manufacturer): try: os.unlink(name) except OSError: pass ProductCode = ProductCode.upper() d = MakeInstaller() # Create the database db = d.OpenDatabase(name, win32com.client.constants.msiOpenDatabaseModeCreate) # Create the tables for t in schema.tables: t.create(db) # Fill the validation table add_data(db, "_Validation", schema._Validation_records) # Initialize the summary information, allowing atmost 20 properties si = db.GetSummaryInformation(20) si.SetProperty(PID_TITLE, "Installation Database") si.SetProperty(PID_SUBJECT, ProductName) si.SetProperty(PID_AUTHOR, Manufacturer) if Win64: si.SetProperty(PID_TEMPLATE, "Intel64;1033") else: si.SetProperty(PID_TEMPLATE, "Intel;1033") si.SetProperty(PID_REVNUMBER, ProductCode) # XXX should be package code si.SetProperty(PID_WORDCOUNT, 2) # long file names, compressed, original media si.SetProperty(PID_PAGECOUNT, 200) si.SetProperty(PID_APPNAME, "Python MSI Library") # XXX more properties si.Persist() add_data(db, "Property", [ ("ProductName", ProductName), ("ProductCode", ProductCode), ("ProductVersion", ProductVersion), ("Manufacturer", Manufacturer), ("ProductLanguage", "1033")]) db.Commit() return db def add_tables(db, module): for table in module.tables: add_data(db, table, getattr(module, table)) def make_id(str): #str = str.replace(".", "_") # colons are allowed str = str.replace(" ", "_") str = str.replace("-", "_") if str[0] in string.digits: str = "_"+str assert re.match("^[A-Za-z_][A-Za-z0-9_.]*$", str), "FILE"+str return str def gen_uuid(): return str(pythoncom.CreateGuid()) class CAB: def __init__(self, name): self.name = name self.file = open(name+".txt", "wt") self.filenames = sets.Set() self.index = 0 def gen_id(self, dir, file): logical = _logical = make_id(file) pos = 1 while logical in self.filenames: logical = "%s.%d" % (_logical, pos) pos += 1 self.filenames.add(logical) return logical def append(self, full, file, logical = None): if os.path.isdir(full): return if not logical: logical = self.gen_id(dir, file) self.index += 1 if full.find(" ")!=-1: print >>self.file, '"%s" %s' % (full, logical) else: print >>self.file, '%s %s' % (full, logical) return self.index, logical def commit(self, db): self.file.close() try: os.unlink(self.name+".cab") except OSError: pass for k, v in [(r"Software\Microsoft\VisualStudio\7.1\Setup\VS", "VS7CommonBinDir"), (r"Software\Microsoft\Win32SDK\Directories", "Install Dir")]: try: key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, k) except WindowsError: continue cabarc = os.path.join(_winreg.QueryValueEx(key, v)[0], r"Bin", "cabarc.exe") _winreg.CloseKey(key) if not os.path.exists(cabarc):continue break else: print "WARNING: cabarc.exe not found in registry" cabarc = "cabarc.exe" f = popen2.popen4(r'"%s" n %s.cab @%s.txt' % (cabarc, self.name, self.name))[0] for line in f: if line.startswith(" -- adding "): sys.stdout.write(".") else: sys.stdout.write(line) sys.stdout.flush() if not os.path.exists(self.name+".cab"): raise IOError, "cabarc failed" add_data(db, "Media", [(1, self.index, None, "#"+self.name, None, None)]) add_stream(db, self.name, self.name+".cab") os.unlink(self.name+".txt") os.unlink(self.name+".cab") db.Commit() _directories = sets.Set() class Directory: def __init__(self, db, cab, basedir, physical, _logical, default, componentflags=None): """Create a new directory in the Directory table. There is a current component at each point in time for the directory, which is either explicitly created through start_component, or implicitly when files are added for the first time. Files are added into the current component, and into the cab file. To create a directory, a base directory object needs to be specified (can be None), the path to the physical directory, and a logical directory name. Default specifies the DefaultDir slot in the directory table. componentflags specifies the default flags that new components get.""" index = 1 _logical = make_id(_logical) logical = _logical while logical in _directories: logical = "%s%d" % (_logical, index) index += 1 _directories.add(logical) self.db = db self.cab = cab self.basedir = basedir self.physical = physical self.logical = logical self.component = None self.short_names = sets.Set() self.ids = sets.Set() self.keyfiles = {} self.componentflags = componentflags if basedir: self.absolute = os.path.join(basedir.absolute, physical) blogical = basedir.logical else: self.absolute = physical blogical = None add_data(db, "Directory", [(logical, blogical, default)]) def start_component(self, component = None, feature = None, flags = None, keyfile = None): """Add an entry to the Component table, and make this component the current for this directory. If no component name is given, the directory name is used. If no feature is given, the current feature is used. If no flags are given, the directory's default flags are used. If no keyfile is given, the KeyPath is left null in the Component table.""" if flags is None: flags = self.componentflags uuid = gen_uuid() if component is None: component = self.logical self.component = component if Win64: flags |= 256 if keyfile: keyid = self.cab.gen_id(self.absolute, keyfile) self.keyfiles[keyfile] = keyid else: keyid = None add_data(self.db, "Component", [(component, uuid, self.logical, flags, None, keyid)]) if feature is None: feature = current_feature add_data(self.db, "FeatureComponents", [(feature.id, component)]) def make_short(self, file): parts = file.split(".") if len(parts)>1: suffix = parts[-1].upper() else: suffix = None prefix = parts[0].upper() if len(prefix) <= 8 and (not suffix or len(suffix)<=3): if suffix: file = prefix+"."+suffix else: file = prefix assert file not in self.short_names else: prefix = prefix[:6] if suffix: suffix = suffix[:3] pos = 1 while 1: if suffix: file = "%s~%d.%s" % (prefix, pos, suffix) else: file = "%s~%d" % (prefix, pos) if file not in self.short_names: break pos += 1 assert pos < 10000 if pos in (10, 100, 1000): prefix = prefix[:-1] self.short_names.add(file) assert not re.search(r'[\?|><:/*"+,;=\[\]]', file) # restrictions on short names return file 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 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.""" if not self.component: self.start_component(self.logical, current_feature) if not src: # Allow relative paths for file if src is not specified src = file file = os.path.basename(file) absolute = os.path.join(self.absolute, src) assert not re.search(r'[\?|><:/*]"', file) # restrictions on long names if self.keyfiles.has_key(file): logical = self.keyfiles[file] else: logical = None sequence, logical = self.cab.append(absolute, file, logical) assert logical not in self.ids self.ids.add(logical) short = self.make_short(file) full = "%s|%s" % (short, file) filesize = os.stat(absolute).st_size # constants.msidbFileAttributesVital # Compressed omitted, since it is the database default # could add r/o, system, hidden attributes = 512 add_data(self.db, "File", [(logical, self.component, full, filesize, version, language, attributes, sequence)]) if not version: # Add hash if the file is not versioned filehash = MakeInstaller().FileHash(absolute, 0) add_data(self.db, "MsiFileHash", [(logical, 0, filehash.IntegerData(1), filehash.IntegerData(2), filehash.IntegerData(3), filehash.IntegerData(4))]) # Automatically remove .pyc/.pyo files on uninstall (2) # XXX: adding so many RemoveFile entries makes installer unbelievably # slow. So instead, we have to use wildcard remove entries # if file.endswith(".py"): # add_data(self.db, "RemoveFile", # [(logical+"c", self.component, "%sC|%sc" % (short, file), # self.logical, 2), # (logical+"o", self.component, "%sO|%so" % (short, file), # self.logical, 2)]) def glob(self, pattern, exclude = None): """Add a list of files to the current component as specified in the glob pattern. Individual files can be excluded in the exclude list.""" files = glob.glob1(self.absolute, pattern) for f in files: if exclude and f in exclude: continue self.add_file(f) return files def remove_pyc(self): "Remove .pyc/.pyo files on uninstall" add_data(self.db, "RemoveFile", [(self.component+"c", self.component, "*.pyc", self.logical, 2), (self.component+"o", self.component, "*.pyo", self.logical, 2)]) class Feature: def __init__(self, db, id, title, desc, display, level = 1, parent=None, directory = None, attributes=0): self.id = id if parent: parent = parent.id add_data(db, "Feature", [(id, parent, title, desc, display, level, directory, attributes)]) def set_current(self): global current_feature current_feature = self class Control: def __init__(self, dlg, name): self.dlg = dlg self.name = name def event(self, ev, arg, cond = "1", order = None): add_data(self.dlg.db, "ControlEvent", [(self.dlg.name, self.name, ev, arg, cond, order)]) def mapping(self, ev, attr): add_data(self.dlg.db, "EventMapping", [(self.dlg.name, self.name, ev, attr)]) def condition(self, action, condition): add_data(self.dlg.db, "ControlCondition", [(self.dlg.name, self.name, action, condition)]) class RadioButtonGroup(Control): def __init__(self, dlg, name, property): self.dlg = dlg self.name = name self.property = property self.index = 1 def add(self, name, x, y, w, h, text, value = None): if value is None: value = name add_data(self.dlg.db, "RadioButton", [(self.property, self.index, value, x, y, w, h, text, None)]) self.index += 1 class Dialog: def __init__(self, db, name, x, y, w, h, attr, title, first, default, cancel): self.db = db self.name = name self.x, self.y, self.w, self.h = x,y,w,h add_data(db, "Dialog", [(name, x,y,w,h,attr,title,first,default,cancel)]) def control(self, name, type, x, y, w, h, attr, prop, text, next, help): add_data(self.db, "Control", [(self.name, name, type, x, y, w, h, attr, prop, text, next, help)]) return Control(self, name) def text(self, name, x, y, w, h, attr, text): return self.control(name, "Text", x, y, w, h, attr, None, text, None, None) def bitmap(self, name, x, y, w, h, text): return self.control(name, "Bitmap", x, y, w, h, 1, None, text, None, None) def line(self, name, x, y, w, h): return self.control(name, "Line", x, y, w, h, 1, None, None, None, None) def pushbutton(self, name, x, y, w, h, attr, text, next): return self.control(name, "PushButton", x, y, w, h, attr, None, text, next, None) def radiogroup(self, name, x, y, w, h, attr, prop, text, next): add_data(self.db, "Control", [(self.name, name, "RadioButtonGroup", x, y, w, h, attr, prop, text, next, None)]) return RadioButtonGroup(self, name, prop) def checkbox(self, name, x, y, w, h, attr, prop, text, next): return self.control(name, "CheckBox", x, y, w, h, attr, prop, text, next, None) --- NEW FILE: schema.py --- from msilib import Table _Validation = Table('_Validation') _Validation.add_field(1,'Table',11552) _Validation.add_field(2,'Column',11552) _Validation.add_field(3,'Nullable',3332) _Validation.add_field(4,'MinValue',4356) _Validation.add_field(5,'MaxValue',4356) _Validation.add_field(6,'KeyTable',7679) _Validation.add_field(7,'KeyColumn',5378) _Validation.add_field(8,'Category',7456) _Validation.add_field(9,'Set',7679) _Validation.add_field(10,'Description',7679) ActionText = Table('ActionText') ActionText.add_field(1,'Action',11592) ActionText.add_field(2,'Description',7936) ActionText.add_field(3,'Template',7936) [...969 lines suppressed...] (u'TypeLib',u'Language',u'N',0,32767,None, None, None, None, u'The language of the library.',), (u'TypeLib',u'Version',u'Y',0,16777215,None, None, None, None, u'The version of the library. The minor version is in the lower 8 bits of the integer. The major version is in the next 16 bits. ',), (u'TypeLib',u'Cost',u'Y',0,2147483647,None, None, None, None, u'The cost associated with the registration of the typelib. This column is currently optional.',), (u'TypeLib',u'LibID',u'N',None, None, None, None, u'Guid',None, u'The GUID that represents the library.',), (u'UIText',u'Text',u'Y',None, None, None, None, u'Text',None, u'The localized version of the string.',), (u'UIText',u'Key',u'N',None, None, None, None, u'Identifier',None, u'A unique key that identifies the particular string.',), (u'Upgrade',u'Attributes',u'N',0,2147483647,None, None, None, None, u'The attributes of this product set.',), (u'Upgrade',u'Language',u'Y',None, None, None, None, u'Language',None, u'A comma-separated list of languages for either products in this set or products not in this set.',), (u'Upgrade',u'ActionProperty',u'N',None, None, None, None, u'UpperCase',None, u'The property to set when a product in this set is found.',), (u'Upgrade',u'Remove',u'Y',None, None, None, None, u'Formatted',None, u'The list of features to remove when uninstalling a product from this set. The default is "ALL".',), (u'Upgrade',u'UpgradeCode',u'N',None, None, None, None, u'Guid',None, u'The UpgradeCode GUID belonging to the products in this set.',), (u'Upgrade',u'VersionMax',u'Y',None, None, None, None, u'Text',None, u'The maximum ProductVersion of the products in this set. The set may or may not include products with this particular version.',), (u'Upgrade',u'VersionMin',u'Y',None, None, None, None, u'Text',None, u'The minimum ProductVersion of the products in this set. The set may or may not include products with this particular version.',), (u'Verb',u'Sequence',u'Y',0,32767,None, None, None, None, u'Order within the verbs for a particular extension. Also used simply to specify the default verb.',), (u'Verb',u'Argument',u'Y',None, None, None, None, u'Formatted',None, u'Optional value for the command arguments.',), (u'Verb',u'Extension_',u'N',None, None, u'Extension',1,u'Text',None, u'The extension associated with the table row.',), (u'Verb',u'Verb',u'N',None, None, None, None, u'Text',None, u'The verb for the command.',), (u'Verb',u'Command',u'Y',None, None, None, None, u'Formatted',None, u'The command text.',), ] --- NEW FILE: sequence.py --- AdminExecuteSequence = [ (u'InstallInitialize', None, 1500), (u'InstallFinalize', None, 6600), (u'InstallFiles', None, 4000), (u'InstallAdminPackage', None, 3900), (u'FileCost', None, 900), (u'CostInitialize', None, 800), (u'CostFinalize', None, 1000), (u'InstallValidate', None, 1400), ] AdminUISequence = [ (u'FileCost', None, 900), (u'CostInitialize', None, 800), (u'CostFinalize', None, 1000), (u'ExecuteAction', None, 1300), (u'ExitDialog', None, -1), (u'FatalError', None, -3), (u'UserExit', None, -2), ] AdvtExecuteSequence = [ (u'InstallInitialize', None, 1500), (u'InstallFinalize', None, 6600), (u'CostInitialize', None, 800), (u'CostFinalize', None, 1000), (u'InstallValidate', None, 1400), (u'CreateShortcuts', None, 4500), (u'MsiPublishAssemblies', None, 6250), (u'PublishComponents', None, 6200), (u'PublishFeatures', None, 6300), (u'PublishProduct', None, 6400), (u'RegisterClassInfo', None, 4600), (u'RegisterExtensionInfo', None, 4700), (u'RegisterMIMEInfo', None, 4900), (u'RegisterProgIdInfo', None, 4800), ] InstallExecuteSequence = [ (u'InstallInitialize', None, 1500), (u'InstallFinalize', None, 6600), (u'InstallFiles', None, 4000), (u'FileCost', None, 900), (u'CostInitialize', None, 800), (u'CostFinalize', None, 1000), (u'InstallValidate', None, 1400), (u'CreateShortcuts', None, 4500), (u'MsiPublishAssemblies', None, 6250), (u'PublishComponents', None, 6200), (u'PublishFeatures', None, 6300), (u'PublishProduct', None, 6400), (u'RegisterClassInfo', None, 4600), (u'RegisterExtensionInfo', None, 4700), (u'RegisterMIMEInfo', None, 4900), (u'RegisterProgIdInfo', None, 4800), (u'AllocateRegistrySpace', u'NOT Installed', 1550), (u'AppSearch', None, 400), (u'BindImage', None, 4300), (u'CCPSearch', u'NOT Installed', 500), (u'CreateFolders', None, 3700), (u'DeleteServices', u'VersionNT', 2000), (u'DuplicateFiles', None, 4210), (u'FindRelatedProducts', None, 200), (u'InstallODBC', None, 5400), (u'InstallServices', u'VersionNT', 5800), (u'IsolateComponents', None, 950), (u'LaunchConditions', None, 100), (u'MigrateFeatureStates', None, 1200), (u'MoveFiles', None, 3800), (u'PatchFiles', None, 4090), (u'ProcessComponents', None, 1600), (u'RegisterComPlus', None, 5700), (u'RegisterFonts', None, 5300), (u'RegisterProduct', None, 6100), (u'RegisterTypeLibraries', None, 5500), (u'RegisterUser', None, 6000), (u'RemoveDuplicateFiles', None, 3400), (u'RemoveEnvironmentStrings', None, 3300), (u'RemoveExistingProducts', None, 6700), (u'RemoveFiles', None, 3500), (u'RemoveFolders', None, 3600), (u'RemoveIniValues', None, 3100), (u'RemoveODBC', None, 2400), (u'RemoveRegistryValues', None, 2600), (u'RemoveShortcuts', None, 3200), (u'RMCCPSearch', u'NOT Installed', 600), (u'SelfRegModules', None, 5600), (u'SelfUnregModules', None, 2200), (u'SetODBCFolders', None, 1100), (u'StartServices', u'VersionNT', 5900), (u'StopServices', u'VersionNT', 1900), (u'MsiUnpublishAssemblies', None, 1750), (u'UnpublishComponents', None, 1700), (u'UnpublishFeatures', None, 1800), (u'UnregisterClassInfo', None, 2700), (u'UnregisterComPlus', None, 2100), (u'UnregisterExtensionInfo', None, 2800), (u'UnregisterFonts', None, 2500), (u'UnregisterMIMEInfo', None, 3000), (u'UnregisterProgIdInfo', None, 2900), (u'UnregisterTypeLibraries', None, 2300), (u'ValidateProductID', None, 700), (u'WriteEnvironmentStrings', None, 5200), (u'WriteIniValues', None, 5100), (u'WriteRegistryValues', None, 5000), ] InstallUISequence = [ (u'FileCost', None, 900), (u'CostInitialize', None, 800), (u'CostFinalize', None, 1000), (u'ExecuteAction', None, 1300), (u'ExitDialog', None, -1), (u'FatalError', None, -3), (u'UserExit', None, -2), (u'AppSearch', None, 400), (u'CCPSearch', u'NOT Installed', 500), (u'FindRelatedProducts', None, 200), (u'IsolateComponents', None, 950), (u'LaunchConditions', None, 100), (u'MigrateFeatureStates', None, 1200), (u'RMCCPSearch', u'NOT Installed', 600), (u'ValidateProductID', None, 700), ] tables=['AdminExecuteSequence', 'AdminUISequence', 'AdvtExecuteSequence', 'InstallExecuteSequence', 'InstallUISequence'] --- NEW FILE: uisample.py --- import msilib,os;dirname=os.path.dirname(__file__) AdminExecuteSequence = [ (u'InstallValidate', None, 1400), (u'InstallInitialize', None, 1500), (u'InstallFinalize', None, 6600), (u'InstallFiles', None, 4000), (u'InstallAdminPackage', None, 3900), (u'FileCost', None, 900), (u'CostInitialize', None, 800), (u'CostFinalize', None, 1000), ] AdminUISequence = [ (u'AdminWelcomeDlg', None, 1230), (u'FileCost', None, 900), (u'CostInitialize', None, 800), (u'CostFinalize', None, 1000), (u'ExecuteAction', None, 1300), (u'ExitDialog', None, -1), [...1360 lines suppressed...] (1919, u'Error configuring ODBC data source: [4], ODBC error [2]: [3]. Verify that the file [4] exists and that you can access it.'), (1920, u"Service '[2]' ([3]) failed to start. Verify that you have sufficient privileges to start system services."), (1921, u"Service '[2]' ([3]) could not be stopped. Verify that you have sufficient privileges to stop system services."), (1922, u"Service '[2]' ([3]) could not be deleted. Verify that you have sufficient privileges to remove system services."), (1923, u"Service '[2]' ([3]) could not be installed. Verify that you have sufficient privileges to install system services."), (1924, u"Could not update environment variable '[2]'. Verify that you have sufficient privileges to modify environment variables."), (1925, u'You do not have sufficient privileges to complete this installation for all users of the machine. Log on as administrator and then retry this installation.'), (1926, u"Could not set file security for file '[3]'. Error: [2]. Verify that you have sufficient privileges to modify the security permissions for this file."), (1927, u'Component Services (COM+ 1.0) are not installed on this computer. This installation requires Component Services in order to complete successfully. Component Services are available on Windows 2000.'), (1928, u'Error registering COM+ Application. Contact your support personnel for more information.'), (1929, u'Error unregistering COM+ Application. Contact your support personnel for more information.'), (1930, u"The description for service '[2]' ([3]) could not be changed."), (1931, u'The Windows Installer service cannot update the system file [2] because the file is protected by Windows. You may need to update your operating system for this program to work correctly. {{Package version: [3], OS Protected version: [4]}}'), (1932, u'The Windows Installer service cannot update the protected Windows file [2]. {{Package version: [3], OS Protected version: [4], SFP Error: [5]}}'), (1933, u'The Windows Installer service cannot update one or more protected Windows files. {{SFP Error: [2]. List of protected files:\\r\\n[3]}}'), (1934, u'User installations are disabled via policy on the machine.'), (1935, u'An error occured during the installation of assembly component [2]. HRESULT: [3]. {{assembly interface: [4], function: [5], assembly name: [6]}}'), ] tables=['AdminExecuteSequence', 'AdminUISequence', 'AdvtExecuteSequence', 'BBControl', 'Billboard', 'Binary', 'CheckBox', 'Property', 'ComboBox', 'Control', 'ListBox', 'ActionText', 'ControlCondition', 'ControlEvent', 'Dialog', 'EventMapping', 'InstallExecuteSequence', 'InstallUISequence', 'ListView', 'RadioButton', 'TextStyle', 'UIText', '_Validation', 'Error'] From loewis at users.sourceforge.net Sun Aug 22 15:35:47 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 15:35:51 2004 Subject: [Python-checkins] python/nondist/sandbox/msi New.bin, 1.1.1.1, NONE README.txt, 1.2, NONE Up.bin, 1.1.1.1, NONE msi.py, 1.34, NONE msilib.py, 1.15, NONE schema.py, 1.1.1.1, NONE sequence.py, 1.3, NONE uisample.py, 1.1.1.1, NONE Message-ID: Update of /cvsroot/python/python/nondist/sandbox/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26064 Removed Files: New.bin README.txt Up.bin msi.py msilib.py schema.py sequence.py uisample.py Log Message: Move msi from sandbox to Tools. --- New.bin DELETED --- --- README.txt DELETED --- --- Up.bin DELETED --- --- msi.py DELETED --- --- msilib.py DELETED --- --- schema.py DELETED --- --- sequence.py DELETED --- --- uisample.py DELETED --- From dcjim at users.sourceforge.net Sun Aug 22 16:10:09 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Sun Aug 22 16:10:15 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2162/Lib/test Modified Files: test_doctest.py Log Message: Bugs fixed: - Test filenames sometimes had trailing .pyc or .pyo sufixes (when module __file__ did). - Trailing spaces spaces in expected output were dropped. New default failure format: - Separation of examples from file info makes examples easier to see - More vertical separation, improving readability - Emacs-recognized file info (also closer to Python exception format) Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- test_doctest.py 22 Aug 2004 01:47:51 -0000 1.25 +++ test_doctest.py 22 Aug 2004 14:10:00 -0000 1.26 @@ -267,11 +267,24 @@ will return a single test (for that function's docstring): >>> finder = doctest.DocTestFinder() + +We'll simulate a __file__ attr that ends in pyc: + + >>> import test.test_doctest + >>> old = test.test_doctest.__file__ + >>> test.test_doctest.__file__ = 'test_doctest.pyc' + >>> tests = finder.find(sample_func) >>> print tests # doctest: +ELLIPSIS [] + >>> tests[0].filename + 'test_doctest.py' + + >>> test.test_doctest.__file__ = old + + >>> e = tests[0].examples[0] >>> (e.source, e.want, e.lineno) ('print sample_func(22)\n', '44\n', 3) @@ -519,10 +532,13 @@ Trying: print x Expecting: 14 ********************************************************************** - Failure in example: print x - from line #2 of f - Expected: 14 - Got: 12 + Line 3, in f + Failed example: + print x + Expected: + 14 + Got: + 12 Trying: x/2 Expecting: 6 ok @@ -645,8 +661,9 @@ >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** - Failure in example: raise ValueError, 'message' - from line #1 of f + Line 2, in f + Failed example: + raise ValueError, 'message' Expected: Traceback (most recent call last): ValueError: wrong message @@ -668,11 +685,12 @@ >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** - Failure in example: 1/0 - from line #1 of f + Line 2, in f + Failed example: + 1/0 Exception raised: Traceback (most recent call last): - ... + ... ZeroDivisionError: integer division or modulo by zero (1, 1) """ @@ -700,10 +718,13 @@ >>> flags = doctest.DONT_ACCEPT_TRUE_FOR_1 >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ********************************************************************** - Failure in example: True - from line #0 of f - Expected: 1 - Got: True + Line 1, in f + Failed example: + True + Expected: + 1 + Got: + True (1, 1) The DONT_ACCEPT_BLANKLINE flag disables the match between blank lines @@ -722,8 +743,9 @@ >>> flags = doctest.DONT_ACCEPT_BLANKLINE >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ********************************************************************** - Failure in example: print "a\n\nb" - from line #0 of f + Line 1, in f + Failed example: + print "a\n\nb" Expected: a @@ -744,12 +766,14 @@ >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** - Failure in example: print 1, 2, 3 - from line #0 of f + Line 1, in f + Failed example: + print 1, 2, 3 Expected: 1 2 3 - Got: 1 2 3 + Got: + 1 2 3 (1, 1) >>> # With the flag: @@ -773,10 +797,13 @@ >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** - Failure in example: print range(15) - from line #0 of f - Expected: [0, 1, 2, ..., 14] - Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] + Line 1, in f + Failed example: + print range(15) + Expected: + [0, 1, 2, ..., 14] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] (1, 1) >>> # With the flag: @@ -825,8 +852,9 @@ >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** - Failure in example: print '\n'.join('abcdefg') - from line #1 of f + Line 2, in f + Failed example: + print '\n'.join('abcdefg') Expected: a B @@ -850,8 +878,9 @@ >>> flags = doctest.UNIFIED_DIFF >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ********************************************************************** - Failure in example: print '\n'.join('abcdefg') - from line #1 of f + Line 2, in f + Failed example: + print '\n'.join('abcdefg') Differences (unified diff): --- Expected +++ Got @@ -876,8 +905,9 @@ >>> flags = doctest.CONTEXT_DIFF >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ********************************************************************** - Failure in example: print '\n'.join('abcdefg') - from line #1 of f + Line 2, in f + Failed example: + print '\n'.join('abcdefg') Differences (context diff): *** Expected --- Got @@ -919,10 +949,13 @@ >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** - Failure in example: print range(10) # should fail: no ellipsis - from line #1 of f - Expected: [0, 1, ..., 9] - Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + Line 2, in f + Failed example: + print range(10) # should fail: no ellipsis + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (1, 2) To turn an option off for an example, follow that example with a @@ -940,10 +973,13 @@ >>> doctest.DocTestRunner(verbose=False, ... optionflags=doctest.ELLIPSIS).run(test) ********************************************************************** - Failure in example: print range(10) # doctest: -ELLIPSIS - from line #5 of f - Expected: [0, 1, ..., 9] - Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + Line 6, in f + Failed example: + print range(10) # doctest: -ELLIPSIS + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (1, 2) Option directives affect only the example that they appear with; they @@ -962,15 +998,21 @@ >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** - Failure in example: print range(10) # Should fail: no ellipsis - from line #1 of f - Expected: [0, 1, ..., 9] - Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + Line 2, in f + Failed example: + print range(10) # Should fail: no ellipsis + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ********************************************************************** - Failure in example: print range(10) # Should fail: no ellipsis - from line #7 of f - Expected: [0, 1, ..., 9] - Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + Line 8, in f + Failed example: + print range(10) # Should fail: no ellipsis + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (2, 3) Multiple options may be modified by a single option directive. They @@ -986,10 +1028,13 @@ >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** - Failure in example: print range(10) # Should fail - from line #1 of f - Expected: [0, 1, ..., 9] - Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + Line 2, in f + Failed example: + print range(10) # Should fail + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (1, 2) >>> def f(x): r''' @@ -1002,10 +1047,13 @@ >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** - Failure in example: print range(10) # Should fail - from line #1 of f - Expected: [0, 1, ..., 9] - Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + Line 2, in f + Failed example: + print range(10) # Should fail + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (1, 2) >>> def f(x): r''' @@ -1018,10 +1066,13 @@ >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ********************************************************************** - Failure in example: print range(10) # Should fail - from line #1 of f - Expected: [0, 1, ..., 9] - Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + Line 2, in f + Failed example: + print range(10) # Should fail + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] (1, 2) The option directive may be put on the line following the source, as @@ -1414,6 +1465,14 @@ """ +def test_trailing_space_in_test(): + """ + Trailing spaces in expcted output are significant: + + >>> x, y = 'foo', '' + >>> print x, y + foo \n + """ ###################################################################### ## Main From dcjim at users.sourceforge.net Sun Aug 22 16:10:32 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Sun Aug 22 16:10:36 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.73,1.74 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2162/Lib Modified Files: doctest.py Log Message: Bugs fixed: - Test filenames sometimes had trailing .pyc or .pyo sufixes (when module __file__ did). - Trailing spaces spaces in expected output were dropped. New default failure format: - Separation of examples from file info makes examples easier to see - More vertical separation, improving readability - Emacs-recognized file info (also closer to Python exception format) Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.73 retrieving revision 1.74 diff -u -d -r1.73 -r1.74 --- doctest.py 22 Aug 2004 01:47:51 -0000 1.73 +++ doctest.py 22 Aug 2004 14:09:58 -0000 1.74 @@ -740,7 +740,15 @@ # Divide want into lines; check that it's properly # indented; and then strip the indentation. - want_lines = m.group('want').rstrip().split('\n') + want = m.group('want') + + # Strip trailing newline and following spaces + l = len(want.rstrip()) + l = want.find('\n', l) + if l >= 0: + want = want[:l] + + want_lines = want.split('\n') self._check_prefix(want_lines, ' '*indent, name, lineno+len(source_lines)) want = '\n'.join([wl[indent:] for wl in want_lines]) @@ -1063,6 +1071,8 @@ filename = None else: filename = getattr(module, '__file__', module.__name__) + if filename[-4:] in (".pyc", ".pyo"): + filename = filename[:-1] return self._parser.get_doctest(docstring, globs, name, filename, lineno) @@ -1199,6 +1209,7 @@ verbose = '-v' in sys.argv self._verbose = verbose self.optionflags = optionflags + self.original_optionflags = optionflags # Keep track of the examples we've run. self.tries = 0 @@ -1246,20 +1257,22 @@ _tag_msg("Exception raised", _exception_traceback(exc_info))) def _failure_header(self, test, example): - s = (self.DIVIDER + "\n" + - _tag_msg("Failure in example", example.source)) - if test.filename is None: - # [XX] I'm not putting +1 here, to give the same output - # as the old version. But I think it *should* go here. - return s + ("from line #%s of %s\n" % - (example.lineno, test.name)) - elif test.lineno is None: - return s + ("from line #%s of %s in %s\n" % - (example.lineno+1, test.name, test.filename)) + out = [self.DIVIDER] + if test.filename: + if test.lineno is not None and example.lineno is not None: + lineno = test.lineno + example.lineno + 1 + else: + lineno = '?' + out.append('File "%s", line %s, in %s' % + (test.filename, lineno, test.name)) else: - lineno = test.lineno+example.lineno+1 - return s + ("from line #%s of %s (%s)\n" % - (lineno, test.filename, test.name)) + out.append('Line %s, in %s' % (example.lineno+1, test.name)) + out.append('Failed example:') + source = example.source + if source.endswith('\n'): + source = source[:-1] + out.append(' ' + '\n '.join(source.split('\n'))) + return '\n'.join(out)+'\n' #///////////////////////////////////////////////////////////////// # DocTest Running @@ -1568,6 +1581,7 @@ compare `want` and `got`. `indent` is the indentation of the original example. """ + # If s are being used, then replace blank lines # with in the actual output string. if not (optionflags & DONT_ACCEPT_BLANKLINE): @@ -1600,8 +1614,13 @@ # If we're not using diff, then simply list the expected # output followed by the actual output. - return (_tag_msg("Expected", want or "Nothing") + - _tag_msg("Got", got)) + if want.endswith('\n'): + want = want[:-1] + want = ' ' + '\n '.join(want.split('\n')) + if got.endswith('\n'): + got = got[:-1] + got = ' ' + '\n '.join(got.split('\n')) + return "Expected:\n%s\nGot:\n%s\n" % (want, got) class DocTestFailure(Exception): """A DocTest example has failed in debugging mode. @@ -1989,6 +2008,7 @@ def __init__(self, test, optionflags=0, setUp=None, tearDown=None, checker=None): + unittest.TestCase.__init__(self) self._dt_optionflags = optionflags self._dt_checker = checker @@ -2025,7 +2045,7 @@ if test.lineno is None: lineno = 'unknown line number' else: - lineno = 'line %s' % test.lineno + lineno = '%s' % test.lineno lname = '.'.join(test.name.split('.')[-1:]) return ('Failed doctest test for %s\n' ' File "%s", line %s, in %s\n\n%s' @@ -2150,9 +2170,7 @@ continue if not test.filename: filename = module.__file__ - if filename.endswith(".pyc"): - filename = filename[:-1] - elif filename.endswith(".pyo"): + if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] test.filename = filename suite.addTest(DocTestCase(test, optionflags, setUp, tearDown, @@ -2469,10 +2487,13 @@ ... 42 ... ''', 'XYZ') ********************************************************************** -Failure in example: print x -from line #2 of XYZ -Expected: 42 -Got: 84 +Line 3, in XYZ +Failed example: + print x +Expected: + 42 +Got: + 84 (1, 2) >>> t.runstring(">>> x = x * 2\n>>> print x\n84\n", 'example2') (0, 2) From rhettinger at users.sourceforge.net Sun Aug 22 17:24:38 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Aug 22 17:24:42 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.246,1.247 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24872 Modified Files: tut.tex Log Message: SF bug #1013760: Error in Chapter 4 of Tutorial Fit a nit. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.246 retrieving revision 1.247 diff -u -d -r1.246 -r1.247 --- tut.tex 16 Aug 2004 05:11:04 -0000 1.246 +++ tut.tex 22 Aug 2004 15:24:33 -0000 1.247 @@ -1339,7 +1339,7 @@ \begin{verbatim} >>> fib - + >>> f = fib >>> f(100) 1 1 2 3 5 8 13 21 34 55 89 From rhettinger at users.sourceforge.net Sun Aug 22 17:27:19 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Aug 22 17:27:23 2004 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex, 1.196.8.22, 1.196.8.23 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25940 Modified Files: Tag: release23-maint tut.tex Log Message: SF bug #1013760: Error in Chapter 4 of Tutorial Fit a nit. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.196.8.22 retrieving revision 1.196.8.23 diff -u -d -r1.196.8.22 -r1.196.8.23 --- tut.tex 21 Jul 2004 17:34:49 -0000 1.196.8.22 +++ tut.tex 22 Aug 2004 15:27:16 -0000 1.196.8.23 @@ -1339,7 +1339,7 @@ \begin{verbatim} >>> fib - + >>> f = fib >>> f(100) 1 1 2 3 5 8 13 21 34 55 89 From loewis at users.sourceforge.net Sun Aug 22 18:04:53 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 18:04:58 2004 Subject: [Python-checkins] python/dist/src/Lib xmlrpclib.py,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5224/Lib Modified Files: xmlrpclib.py Log Message: Replace yield with sequence class. Fixes #1009803. Index: xmlrpclib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- xmlrpclib.py 20 Aug 2004 07:31:37 -0000 1.34 +++ xmlrpclib.py 22 Aug 2004 16:04:50 -0000 1.35 @@ -892,15 +892,19 @@ def __call__(self, *args): self.__call_list.append((self.__name, args)) -def MultiCallIterator(results): +class MultiCallIterator: """Iterates over the results of a multicall. Exceptions are thrown in response to xmlrpc faults.""" - for i in results: - if type(i) == type({}): - raise Fault(i['faultCode'], i['faultString']) - elif type(i) == type([]): - yield i[0] + def __init__(self, results): + self.results = results + + def __getitem__(self, i): + item = self.results[i] + if type(item) == type({}): + raise Fault(item['faultCode'], item['faultString']) + elif type(item) == type([]): + return item[0] else: raise ValueError,\ "unexpected type in multicall result" @@ -1412,11 +1416,20 @@ # simple test program (from the XML-RPC specification) # server = ServerProxy("http://localhost:8000") # local server - server = ServerProxy("http://betty.userland.com") + server = ServerProxy("http://time.xmlrpc.com/RPC2") print server try: - print server.examples.getStateName(41) + print server.currentTime.getCurrentTime() + except Error, v: + print "ERROR", v + + multi = MultiCall(server) + multi.currentTime.getCurrentTime() + multi.currentTime.getCurrentTime() + try: + for response in multi(): + print response except Error, v: print "ERROR", v From loewis at users.sourceforge.net Sun Aug 22 18:08:08 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 18:08:11 2004 Subject: [Python-checkins] python/dist/src/Lib pydoc.py,1.95,1.96 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6320 Modified Files: pydoc.py Log Message: Patch #1009389: Make __credits__ a Unicode object. Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.95 retrieving revision 1.96 diff -u -d -r1.95 -r1.96 --- pydoc.py 17 Aug 2004 13:21:53 -0000 1.95 +++ pydoc.py 22 Aug 2004 16:08:04 -0000 1.96 @@ -37,7 +37,7 @@ __author__ = "Ka-Ping Yee " __date__ = "26 February 2001" __version__ = "$Revision$" -__credits__ = """Guido van Rossum, for an excellent programming language. +__credits__ = u"""Guido van Rossum, for an excellent programming language. Tommy Burnette, the original creator of manpy. Paul Prescod, for all his work on onlinehelp. Richard Chamberlain, for the first implementation of textdoc. From loewis at users.sourceforge.net Sun Aug 22 18:13:28 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 18:13:32 2004 Subject: [Python-checkins] python/dist/src/Lib pydoc.py,1.96,1.97 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7982 Modified Files: pydoc.py Log Message: Patch #997284: Allow pydoc to work with XP Themes (.manifest file) Will backport to 2.3. Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.96 retrieving revision 1.97 diff -u -d -r1.96 -r1.97 --- pydoc.py 22 Aug 2004 16:08:04 -0000 1.96 +++ pydoc.py 22 Aug 2004 16:13:26 -0000 1.97 @@ -2124,8 +2124,16 @@ import Tkinter try: - gui = GUI(Tkinter.Tk()) - Tkinter.mainloop() + root = Tkinter.Tk() + # Tk will crash if pythonw.exe has an XP .manifest + # file and the root has is not destroyed explicitly. + # If the problem is ever fixed in Tk, the explicit + # destroy can go. + try: + gui = GUI(root) + root.mainloop() + finally: + root.destroy() except KeyboardInterrupt: pass From loewis at users.sourceforge.net Sun Aug 22 18:14:57 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 18:15:00 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.143, 1.831.4.144 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8520/Misc Modified Files: Tag: release23-maint NEWS Log Message: Patch #997284: Allow pydoc to work with XP Themes (.manifest file) Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.143 retrieving revision 1.831.4.144 diff -u -d -r1.831.4.143 -r1.831.4.144 --- NEWS 18 Aug 2004 13:35:49 -0000 1.831.4.143 +++ NEWS 22 Aug 2004 16:14:52 -0000 1.831.4.144 @@ -49,6 +49,8 @@ Library ------- +- Patch #997284: Allow pydoc to work with XP Themes (.manifest file) + - Patch #808719: Ignore locale's encoding in IDLE if it is an empty string. - Patch #946153: Add wait_visibility before grab_set. From loewis at users.sourceforge.net Sun Aug 22 18:14:57 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 18:15:04 2004 Subject: [Python-checkins] python/dist/src/Lib pydoc.py,1.86.8.2,1.86.8.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8520/Lib Modified Files: Tag: release23-maint pydoc.py Log Message: Patch #997284: Allow pydoc to work with XP Themes (.manifest file) Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.86.8.2 retrieving revision 1.86.8.3 diff -u -d -r1.86.8.2 -r1.86.8.3 --- pydoc.py 19 Jun 2004 01:05:39 -0000 1.86.8.2 +++ pydoc.py 22 Aug 2004 16:14:53 -0000 1.86.8.3 @@ -2056,8 +2056,16 @@ import Tkinter try: - gui = GUI(Tkinter.Tk()) - Tkinter.mainloop() + root = Tkinter.Tk() + # Tk will crash if pythonw.exe has an XP .manifest + # file and the root has is not destroyed explicitly. + # If the problem is ever fixed in Tk, the explicit + # destroy can go. + try: + gui = GUI(root) + root.mainloop() + finally: + root.destroy() except KeyboardInterrupt: pass From loewis at users.sourceforge.net Sun Aug 22 19:10:19 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 19:10:24 2004 Subject: [Python-checkins] python/dist/src/Tools/msi msi.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24649 Modified Files: msi.py Log Message: Add acknowledgements to ExitDialog. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/msi/msi.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- msi.py 22 Aug 2004 13:34:34 -0000 1.1 +++ msi.py 22 Aug 2004 17:10:12 -0000 1.2 @@ -419,7 +419,15 @@ exit_dialog.title("Completing the [ProductName] Installer") exit_dialog.back("< Back", "Finish", active = 0) exit_dialog.cancel("Cancel", "Back", active = 0) - exit_dialog.text("Description", 135, 115, 220, 20, 0x30003, + exit_dialog.text("Acknowledgements", 135, 95, 220, 120, 0x30003, + "Special Windows thanks to:\n" + " LettError, Erik van Blokland, for the Python for Windows graphic.\n" + " http://www.letterror.com/\n" + "\n" + " Mark Hammond, without whose years of freely shared Windows\n" + " expertise, Python for Windows would still be Python for DOS.") + + exit_dialog.text("Description", 135, 235, 220, 20, 0x30003, "Click the Finish button to exit the Installer.") c = exit_dialog.next("Finish", "Cancel", name="Finish") c.event("EndDialog", "Return") From tim_one at users.sourceforge.net Sun Aug 22 19:35:01 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 22 19:35:17 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.74,1.75 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32261/Lib Modified Files: doctest.py Log Message: _parse_example(): Simplified new code to preserve trailing spaces before final newline. Anything to get rid of "l" as a variable name <0.5 wink>. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- doctest.py 22 Aug 2004 14:09:58 -0000 1.74 +++ doctest.py 22 Aug 2004 17:34:58 -0000 1.75 @@ -735,22 +735,18 @@ # indented; and then strip their indentation & prompts. source_lines = m.group('source').split('\n') self._check_prompt_blank(source_lines, indent, name, lineno) - self._check_prefix(source_lines[1:], ' '*indent+'.', name, lineno) + self._check_prefix(source_lines[1:], ' '*indent + '.', name, lineno) source = '\n'.join([sl[indent+4:] for sl in source_lines]) - # Divide want into lines; check that it's properly - # indented; and then strip the indentation. + # Divide want into lines; check that it's properly indented; and + # then strip the indentation. Spaces before the last newline should + # be preserved, so plain rstrip() isn't good enough. want = m.group('want') - - # Strip trailing newline and following spaces - l = len(want.rstrip()) - l = want.find('\n', l) - if l >= 0: - want = want[:l] - want_lines = want.split('\n') + if len(want_lines) > 1 and re.match(r' *$', want_lines[-1]): + del want_lines[-1] # forget final newline & spaces after it self._check_prefix(want_lines, ' '*indent, name, - lineno+len(source_lines)) + lineno + len(source_lines)) want = '\n'.join([wl[indent:] for wl in want_lines]) return source, want @@ -1581,7 +1577,7 @@ compare `want` and `got`. `indent` is the indentation of the original example. """ - + # If s are being used, then replace blank lines # with in the actual output string. if not (optionflags & DONT_ACCEPT_BLANKLINE): From tim_one at users.sourceforge.net Sun Aug 22 19:50:48 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 22 19:50:52 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.75,1.76 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4899/Lib Modified Files: doctest.py Log Message: Type in docstring. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.75 retrieving revision 1.76 diff -u -d -r1.75 -r1.76 --- doctest.py 22 Aug 2004 17:34:58 -0000 1.75 +++ doctest.py 22 Aug 2004 17:50:45 -0000 1.76 @@ -2135,7 +2135,7 @@ setUp=lambda: None, tearDown=lambda: None, checker=None): """ - Convert doctest tests for a mudule to a unittest test suite. + Convert doctest tests for a module to a unittest test suite. This converts each documentation string in a module that contains doctest tests to a unittest test case. If any of the From tim_one at users.sourceforge.net Sun Aug 22 21:42:59 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 22 21:43:03 2004 Subject: [Python-checkins] python/dist/src/Tools/msi msilib.py, 1.1, 1.2 schema.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6150/Tools/msi Modified Files: msilib.py schema.py Log Message: Whitespace normalization. Index: msilib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/msi/msilib.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- msilib.py 22 Aug 2004 13:34:34 -0000 1.1 +++ msilib.py 22 Aug 2004 19:42:56 -0000 1.2 @@ -188,7 +188,7 @@ f.write("),\n") f.write("]\n\n") - f.close() + f.close() def gen_sequence(destpath, msipath): dir = os.path.dirname(destpath) @@ -525,7 +525,7 @@ # constants.msidbFileAttributesVital # Compressed omitted, since it is the database default # could add r/o, system, hidden - attributes = 512 + attributes = 512 add_data(self.db, "File", [(logical, self.component, full, filesize, version, language, attributes, sequence)]) @@ -624,7 +624,7 @@ def bitmap(self, name, x, y, w, h, text): return self.control(name, "Bitmap", x, y, w, h, 1, None, text, None, None) - + def line(self, name, x, y, w, h): return self.control(name, "Line", x, y, w, h, 1, None, None, None, None) @@ -638,4 +638,4 @@ return RadioButtonGroup(self, name, prop) def checkbox(self, name, x, y, w, h, attr, prop, text, next): - return self.control(name, "CheckBox", x, y, w, h, attr, prop, text, next, None) \ No newline at end of file + return self.control(name, "CheckBox", x, y, w, h, attr, prop, text, next, None) Index: schema.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/msi/schema.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- schema.py 22 Aug 2004 13:34:34 -0000 1.1 +++ schema.py 22 Aug 2004 19:42:56 -0000 1.2 @@ -1005,4 +1005,3 @@ (u'Verb',u'Verb',u'N',None, None, None, None, u'Text',None, u'The verb for the command.',), (u'Verb',u'Command',u'Y',None, None, None, None, u'Formatted',None, u'The command text.',), ] - From tim_one at users.sourceforge.net Sun Aug 22 21:43:30 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 22 21:43:35 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6294/Doc/lib Modified Files: libdoctest.tex Log Message: Added NDIFF_DIFF option. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- libdoctest.tex 20 Aug 2004 14:37:05 -0000 1.29 +++ libdoctest.tex 22 Aug 2004 19:43:28 -0000 1.30 @@ -356,6 +356,15 @@ actual outputs will be displayed using a context diff. \end{datadesc} +\begin{datadesc}{NDIFF_DIFF} + When specified, differences are computed by \code{difflib.Differ}, + using the same algorithm as the popular \file{ndiff.py} utility. + This is the only method that marks differences within lines as + well as across lines. For example, if a line of expected output + contains digit \code{1} where actual output contains letter \code{l}, + a line is inserted with a caret marking the mismatching column + positions. +\end{datadesc} A "doctest directive" is a trailing Python comment on a line of a doctest example: @@ -414,7 +423,8 @@ \versionchanged[Constants \constant{DONT_ACCEPT_BLANKLINE}, \constant{NORMALIZE_WHITESPACE}, \constant{ELLIPSIS}, - \constant{UNIFIED_DIFF}, and \constant{CONTEXT_DIFF} + \constant{UNIFIED_DIFF}, \constant{CONTEXT_DIFF}, and + \constant{NDIFF_DIFF} were added; by default \code{} in expected output matches an empty line in actual output; and doctest directives were added]{2.4} From tim_one at users.sourceforge.net Sun Aug 22 21:43:32 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 22 21:43:39 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.26, 1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6294/Lib/test Modified Files: test_doctest.py Log Message: Added NDIFF_DIFF option. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- test_doctest.py 22 Aug 2004 14:10:00 -0000 1.26 +++ test_doctest.py 22 Aug 2004 19:43:28 -0000 1.27 @@ -283,7 +283,7 @@ 'test_doctest.py' >>> test.test_doctest.__file__ = old - + >>> e = tests[0].examples[0] >>> (e.source, e.want, e.lineno) @@ -931,7 +931,33 @@ g (1, 1) -""" + + +The NDIFF_DIFF flag causes failures to use the difflib.Differ algorithm +used by the popular ndiff.py utility. This does intraline difference +marking, as well as interline differences. + + >>> def f(x): + ... r''' + ... >>> print "a b c d e f g h i j k l m" + ... a b c d e f g h i j k 1 m + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.NDIFF_DIFF + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + ********************************************************************** + Line 2, in f + Failed example: + print "a b c d e f g h i j k l m" + Differences (ndiff with -expected +actual): + - a b c d e f g h i j k 1 m + ? ^ + + a b c d e f g h i j k l m + ? + ++ ^ + + (1, 1) + """ + def option_directives(): r""" Tests of `DocTestRunner`'s option directive mechanism. @@ -1468,7 +1494,7 @@ def test_trailing_space_in_test(): """ Trailing spaces in expcted output are significant: - + >>> x, y = 'foo', '' >>> print x, y foo \n From tim_one at users.sourceforge.net Sun Aug 22 21:43:31 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 22 21:43:40 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.76,1.77 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6294/Lib Modified Files: doctest.py Log Message: Added NDIFF_DIFF option. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.76 retrieving revision 1.77 diff -u -d -r1.76 -r1.77 --- doctest.py 22 Aug 2004 17:50:45 -0000 1.76 +++ doctest.py 22 Aug 2004 19:43:28 -0000 1.77 @@ -178,6 +178,7 @@ 'ELLIPSIS', 'UNIFIED_DIFF', 'CONTEXT_DIFF', + 'NDIFF_DIFF', # 1. Utility Functions 'is_private', # 2. Example & DocTest @@ -253,6 +254,7 @@ ELLIPSIS = register_optionflag('ELLIPSIS') UNIFIED_DIFF = register_optionflag('UNIFIED_DIFF') CONTEXT_DIFF = register_optionflag('CONTEXT_DIFF') +NDIFF_DIFF = register_optionflag('NDIFF_DIFF') # Special string markers for use in `want` strings: BLANKLINE_MARKER = '' @@ -1569,6 +1571,24 @@ # We didn't find any match; return false. return False + # Should we do a fancy diff? + def _do_a_fancy_diff(self, want, got, optionflags): + # Not unless they asked for a fancy diff. + if not optionflags & (UNIFIED_DIFF | + CONTEXT_DIFF | + NDIFF_DIFF): + return False + # If expected output uses ellipsis, a meaningful fancy diff is + # too hard. + if optionflags & ELLIPSIS and ELLIPSIS_MARKER in want: + return False + # ndiff does intraline difference marking, so can be useful even + # for 1-line inputs. + if optionflags & NDIFF_DIFF: + return True + # The other diff types need at least a few lines to be helpful. + return want.count('\n') > 2 and got.count('\n') > 2 + def output_difference(self, want, got, optionflags): """ Return a string describing the differences between the @@ -1586,9 +1606,7 @@ # Check if we should use diff. Don't use diff if the actual # or expected outputs are too short, or if the expected output # contains an ellipsis marker. - if ((optionflags & (UNIFIED_DIFF | CONTEXT_DIFF)) and - want.count('\n') > 2 and got.count('\n') > 2 and - not (optionflags & ELLIPSIS and '...' in want)): + if self._do_a_fancy_diff(want, got, optionflags): # Split want & got into lines. want_lines = [l+'\n' for l in want.split('\n')] got_lines = [l+'\n' for l in got.split('\n')] @@ -1596,16 +1614,20 @@ if optionflags & UNIFIED_DIFF: diff = difflib.unified_diff(want_lines, got_lines, n=2, fromfile='Expected', tofile='Got') - kind = 'unified' + kind = 'unified diff' elif optionflags & CONTEXT_DIFF: diff = difflib.context_diff(want_lines, got_lines, n=2, fromfile='Expected', tofile='Got') - kind = 'context' + kind = 'context diff' + elif optionflags & NDIFF_DIFF: + engine = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK) + diff = list(engine.compare(want_lines, got_lines)) + kind = 'ndiff with -expected +actual' else: assert 0, 'Bad diff option' # Remove trailing whitespace on diff output. diff = [line.rstrip() + '\n' for line in diff] - return _tag_msg("Differences (" + kind + " diff)", + return _tag_msg("Differences (" + kind + ")", ''.join(diff)) # If we're not using diff, then simply list the expected From tim_one at users.sourceforge.net Sun Aug 22 22:51:56 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 22 22:52:00 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.77,1.78 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26594/Lib Modified Files: doctest.py Log Message: Start deferring to the LaTeX docs for details. I'd like to move the docstrings toward being a lot shorter, and telling the whole truth in the manual instead. This change is an example: the manual has detailed explanations of the option names now, so it's Bad to repeat them in the docstring (two detailed descriptions are certain to get out of synch). Just listing the names has memory-jogging benefits, though, so that's still helpful in the docstring. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.77 retrieving revision 1.78 diff -u -d -r1.77 -r1.78 --- doctest.py 22 Aug 2004 19:43:28 -0000 1.77 +++ doctest.py 22 Aug 2004 20:51:53 -0000 1.78 @@ -1826,42 +1826,16 @@ detailed, else very brief (in fact, empty if all tests passed). Optional keyword arg "optionflags" or's together module constants, - and defaults to 0. This is new in 2.3. Possible values: + and defaults to 0. This is new in 2.3. Possible values (see the + docs for details): DONT_ACCEPT_TRUE_FOR_1 - By default, if an expected output block contains just "1", - an actual output block containing just "True" is considered - to be a match, and similarly for "0" versus "False". When - DONT_ACCEPT_TRUE_FOR_1 is specified, neither substitution - is allowed. - DONT_ACCEPT_BLANKLINE - By default, if an expected output block contains a line - containing only the string "", then that line - will match a blank line in the actual output. When - DONT_ACCEPT_BLANKLINE is specified, this substitution is - not allowed. - NORMALIZE_WHITESPACE - When NORMALIZE_WHITESPACE is specified, all sequences of - whitespace are treated as equal. I.e., any sequence of - whitespace within the expected output will match any - sequence of whitespace within the actual output. - ELLIPSIS - When ELLIPSIS is specified, then an ellipsis marker - ("...") in the expected output can match any substring in - the actual output. - UNIFIED_DIFF - When UNIFIED_DIFF is specified, failures that involve - multi-line expected and actual outputs will be displayed - using a unified diff. - CONTEXT_DIFF - When CONTEXT_DIFF is specified, failures that involve - multi-line expected and actual outputs will be displayed - using a context diff. + NDIFF_DIFF Optional keyword arg "raise_on_error" raises an exception on the first unexpected exception or failure. This allows failures to be From loewis at users.sourceforge.net Sun Aug 22 23:09:17 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 23:09:22 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_complex.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv511/Lib/test Modified Files: test_complex.py Log Message: Fix repr for negative imaginary part. Fixes #1013908. Index: test_complex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_complex.py,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- test_complex.py 5 Aug 2003 15:55:38 -0000 1.14 +++ test_complex.py 22 Aug 2004 21:09:14 -0000 1.15 @@ -286,6 +286,7 @@ def test_repr(self): self.assertEqual(repr(1+6j), '(1+6j)') + self.assertEqual(repr(1-6j), '(1-6j)') def test_neg(self): self.assertEqual(-(1+6j), -1-6j) From loewis at users.sourceforge.net Sun Aug 22 23:09:18 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 23:09:25 2004 Subject: [Python-checkins] python/dist/src/Objects complexobject.c, 2.71, 2.72 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv511/Objects Modified Files: complexobject.c Log Message: Fix repr for negative imaginary part. Fixes #1013908. Index: complexobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/complexobject.c,v retrieving revision 2.71 retrieving revision 2.72 diff -u -d -r2.71 -r2.72 --- complexobject.c 8 Jun 2004 18:52:53 -0000 2.71 +++ complexobject.c 22 Aug 2004 21:09:15 -0000 2.72 @@ -279,11 +279,15 @@ strncat(buf, "j", bufsz); } else { char re[64], im[64]; - + char *fmt; PyOS_snprintf(format, 32, "%%.%ig", precision); PyOS_ascii_formatd(re, 64, format, v->cval.real); PyOS_ascii_formatd(im, 64, format, v->cval.imag); - PyOS_snprintf(buf, bufsz, "(%s+%sj)", re, im); + if (v->cval.imag < 0.) + fmt = "(%s%sj)"; + else + fmt = "(%s+%sj)"; + PyOS_snprintf(buf, bufsz, fmt, re, im); } } From loewis at users.sourceforge.net Sun Aug 22 23:28:36 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 23:28:41 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_tarfile.py, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6079/Lib/test Modified Files: test_tarfile.py Log Message: Flush bz2 data even if nothing had been written so far. Fixes #1013882. Will backport to 2.3. Index: test_tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_tarfile.py,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- test_tarfile.py 20 Jul 2004 22:07:44 -0000 1.13 +++ test_tarfile.py 22 Aug 2004 21:28:33 -0000 1.14 @@ -177,7 +177,8 @@ def setUp(self): mode = self.mode + self.sep + self.comp self.src = tarfile.open(tarname(self.comp), 'r') - self.dst = tarfile.open(tmpname(), mode) + self.dstname = tmpname() + self.dst = tarfile.open(self.dstname, mode) def tearDown(self): self.src.close() @@ -191,6 +192,11 @@ self.dst.posix = 0 self._test() + def test_small(self): + self.dst.add(os.path.join(os.path.dirname(__file__),"cfgparser.1")) + self.dst.close() + self.assertNotEqual(os.stat(self.dstname).st_size, 0) + def _test(self): for tarinfo in self.src: if not tarinfo.isreg(): From loewis at users.sourceforge.net Sun Aug 22 23:28:35 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 23:28:44 2004 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6079/Lib Modified Files: tarfile.py Log Message: Flush bz2 data even if nothing had been written so far. Fixes #1013882. Will backport to 2.3. Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- tarfile.py 20 Aug 2004 06:35:46 -0000 1.17 +++ tarfile.py 22 Aug 2004 21:28:32 -0000 1.18 @@ -350,9 +350,9 @@ if self.closed: return + if self.mode == "w" and self.type != "tar": + self.buf += self.cmp.flush() if self.mode == "w" and self.buf: - if self.type != "tar": - self.buf += self.cmp.flush() self.fileobj.write(self.buf) self.buf = "" if self.type == "gz": From loewis at users.sourceforge.net Sun Aug 22 23:30:06 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 23:30:35 2004 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.8.12.2,1.8.12.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6596/Lib Modified Files: Tag: release23-maint tarfile.py Log Message: Flush bz2 data even if nothing had been written so far. Fixes #1013882 Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.8.12.2 retrieving revision 1.8.12.3 diff -u -d -r1.8.12.2 -r1.8.12.3 --- tarfile.py 6 Nov 2003 13:57:49 -0000 1.8.12.2 +++ tarfile.py 22 Aug 2004 21:30:03 -0000 1.8.12.3 @@ -350,9 +350,9 @@ if self.closed: return + if self.mode == "w" and self.type != "tar": + self.buf += self.cmp.flush() if self.mode == "w" and self.buf: - if self.type != "tar": - self.buf += self.cmp.flush() self.fileobj.write(self.buf) self.buf = "" if self.type == "gz": From loewis at users.sourceforge.net Sun Aug 22 23:30:08 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 22 23:30:37 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.144, 1.831.4.145 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6596/Misc Modified Files: Tag: release23-maint NEWS Log Message: Flush bz2 data even if nothing had been written so far. Fixes #1013882 Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.144 retrieving revision 1.831.4.145 diff -u -d -r1.831.4.144 -r1.831.4.145 --- NEWS 22 Aug 2004 16:14:52 -0000 1.831.4.144 +++ NEWS 22 Aug 2004 21:30:04 -0000 1.831.4.145 @@ -49,6 +49,8 @@ Library ------- +- Bug #1013882: Flush bz2 data even if nothing had been written so far. + - Patch #997284: Allow pydoc to work with XP Themes (.manifest file) - Patch #808719: Ignore locale's encoding in IDLE if it is an empty string. From nnorwitz at users.sourceforge.net Sun Aug 22 23:48:47 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sun Aug 22 23:48:51 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13028/lib Modified Files: libdoctest.tex Log Message: Add version info Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- libdoctest.tex 22 Aug 2004 19:43:28 -0000 1.30 +++ libdoctest.tex 22 Aug 2004 21:48:37 -0000 1.31 @@ -364,6 +364,7 @@ contains digit \code{1} where actual output contains letter \code{l}, a line is inserted with a caret marking the mismatching column positions. + \versionadded{2.4} \end{datadesc} A "doctest directive" is a trailing Python comment on a line of a doctest From tim_one at users.sourceforge.net Mon Aug 23 02:26:45 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 23 02:26:51 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27657/Doc/lib Modified Files: libdoctest.tex Log Message: Removed redundant versionadded{} for NDIFF_DIFF. Virtually everything in this section is new in 2.4, and that's all mentioned already in versionadded{} thingies at the end of the section. It hurts readability to have them after every line . Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- libdoctest.tex 22 Aug 2004 21:48:37 -0000 1.31 +++ libdoctest.tex 23 Aug 2004 00:26:42 -0000 1.32 @@ -364,7 +364,6 @@ contains digit \code{1} where actual output contains letter \code{l}, a line is inserted with a caret marking the mismatching column positions. - \versionadded{2.4} \end{datadesc} A "doctest directive" is a trailing Python comment on a line of a doctest From bwarsaw at users.sourceforge.net Mon Aug 23 05:31:48 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Mon Aug 23 05:31:53 2004 Subject: [Python-checkins] python/nondist/peps pep-0292.txt,1.11,1.12 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14356 Modified Files: pep-0292.txt Log Message: Latest update. Index: pep-0292.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0292.txt,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- pep-0292.txt 20 Aug 2004 14:20:38 -0000 1.11 +++ pep-0292.txt 23 Aug 2004 03:31:45 -0000 1.12 @@ -7,7 +7,7 @@ Type: Standards Track Created: 18-Jun-2002 Python-Version: 2.4 -Post-History: 18-Jun-2002, 23-Mar-2004 +Post-History: 18-Jun-2002, 23-Mar-2004, 22-Aug-2004 Abstract @@ -161,6 +161,12 @@ run-time. +Reference Implementation + + A SourceForge patch[4] is available which implements this + proposal, include unit tests and documentation changes. + + Open Issues - Should the Template and SafeTemplate classes convert mapping @@ -172,7 +178,7 @@ Should this raise an exception such as TypeError, or should this return the string 'The cose was 7 euros'? - PEP author preference: no automatic stringification. + Proposed resolution: no automatic stringification. - The pattern for placeholders in the Template and SafeTemplate classes matches Python identifiers. Some people want to match @@ -185,7 +191,7 @@ the standard library? What about more complex patterns such as Python expressions? - PEP author preference: No, we don't include them for now. Such + Proposed resolution: No, we don't include them for now. Such classes are easily derived, and besides, we're not proposing to include any interpolation mappings, and without such a specialized mapping, a pattern matching attribute paths or @@ -197,8 +203,8 @@ re-organization of the existing string module, turning it into a string package. - PEP author preference: There seems little consensus around - either suggestion, and since the classes are just a few lines of + Proposed resolution: There seems little consensus around either + suggestion, and since the classes are just a few lines of Python, I propose no string module re-organization, but to add these two classes to string.py. @@ -208,9 +214,8 @@ was that we add another matching group which matches bare $'s, raising a ValueError if we find such a match. - PEP author preference: This sounds fine to me, although because - the pattern is part of the public interface for the class, we - will have to document that 4 groups are expected instead of 3. + Proposed resolution: There seems to be consensus for strictness + on the grounds of explicit is better than implicit. References @@ -224,6 +229,8 @@ [3] Guido's python-dev posting from 21-Jul-2002 http://mail.python.org/pipermail/python-dev/2002-July/026397.html + [4] Reference Implementation + http://sourceforge.net/tracker/index.php?func=detail&aid=1014055&group_id=5470&atid=305470 Copyright From bwarsaw at users.sourceforge.net Mon Aug 23 05:41:24 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Mon Aug 23 05:41:29 2004 Subject: [Python-checkins] python/nondist/peps pep-0020.txt,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16885 Added Files: pep-0020.txt Log Message: The Zen of Python --- NEW FILE: pep-0020.txt --- PEP: 20 Title: The Zen of Python Version: $Revision: 1.1 $ Last-Modified: $Date: 2004/08/23 03:41:21 $ Author: tim@zope.com (Tim Peters) Status: Active Type: Informational Content-Type: text/plain Created: 19-Aug-2004 Post-History: 22-Aug-2004 Abstract Long time Pythoneer Tim Peters succinctly channels the BDFL's guiding principles for Python's design into 20 aphorisms, only 19 of which have been written down. The Zen of Python Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! Easter Egg >>> import this Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 End: From bwarsaw at users.sourceforge.net Mon Aug 23 05:41:59 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Mon Aug 23 05:42:05 2004 Subject: [Python-checkins] python/nondist/peps pep-0000.txt,1.282,1.283 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17067 Modified Files: pep-0000.txt Log Message: Added PEP 20, The Zen of Python Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.282 retrieving revision 1.283 diff -u -d -r1.282 -r1.283 --- pep-0000.txt 20 Aug 2004 12:43:19 -0000 1.282 +++ pep-0000.txt 23 Aug 2004 03:41:56 -0000 1.283 @@ -45,6 +45,7 @@ Other Informational PEPs + I 20 The Zen of Python Peters I 42 Feature Requests Hylton I 101 Doing Python Releases 101 Warsaw, GvR I 102 Doing Python Micro Releases Baxter, Warsaw, GvR @@ -218,6 +219,7 @@ I 10 Voting Guidelines Warsaw I 11 Removing support for little used platforms von Loewis I 12 Sample reStructuredText PEP Template Goodger, Warsaw + I 20 The Zen of Python Peters I 42 Feature Requests Hylton SF 100 Python Unicode Integration Lemburg From davecole at users.sourceforge.net Mon Aug 23 06:54:56 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Mon Aug 23 06:55:01 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.300, 1.301 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2142/Modules Modified Files: socketmodule.c Log Message: Removed unnecessary calls to signal() to ignore SIGPIPE. SIGPIPE is ignored in initsigs() inside pythonrun.c. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.300 retrieving revision 1.301 diff -u -d -r1.300 -r1.301 --- socketmodule.c 9 Aug 2004 13:25:59 -0000 1.300 +++ socketmodule.c 23 Aug 2004 04:54:53 -0000 1.301 @@ -2515,11 +2515,6 @@ return -1; } init_sockobject(s, fd, family, type, proto); - /* From now on, ignore SIGPIPE and let the error checking - do the work. */ -#ifdef SIGPIPE - (void) signal(SIGPIPE, SIG_IGN); -#endif return 0; @@ -3038,9 +3033,6 @@ /* Create a pair of socket fds */ if (socketpair(family, type, proto, sv) < 0) return set_error(); -#ifdef SIGPIPE - (void) signal(SIGPIPE, SIG_IGN); -#endif s0 = new_sockobject(sv[0], family, type, proto); if (s0 == NULL) goto finally; @@ -3091,11 +3083,6 @@ if (fd < 0) return set_error(); s = new_sockobject(fd, family, type, proto); - /* From now on, ignore SIGPIPE and let the error checking - do the work. */ -#ifdef SIGPIPE - (void) signal(SIGPIPE, SIG_IGN); -#endif return (PyObject *) s; } From davecole at users.sourceforge.net Mon Aug 23 07:16:25 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Mon Aug 23 07:16:29 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.86,1.87 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8009/Doc/lib Modified Files: libsocket.tex Log Message: Updated the socketpair() docstring and documentation to explain that the default famility is AF_UNIX if defined for the platform, otherwise the default is AF_INET. Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.86 retrieving revision 1.87 diff -u -d -r1.86 -r1.87 --- libsocket.tex 9 Aug 2004 05:59:09 -0000 1.86 +++ libsocket.tex 23 Aug 2004 05:16:22 -0000 1.87 @@ -307,8 +307,9 @@ 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 \function{socket()} function above. -Availability: \UNIX. -\versionadded{2.4} +The default family is AF_UNIX if defined for the platform, otherwise +the default is AF_INET. +Availability: \UNIX. \versionadded{2.4} \end{funcdesc} \begin{funcdesc}{fromfd}{fd, family, type\optional{, proto}} From davecole at users.sourceforge.net Mon Aug 23 07:16:26 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Mon Aug 23 07:16:31 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.301, 1.302 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8009/Modules Modified Files: socketmodule.c Log Message: Updated the socketpair() docstring and documentation to explain that the default famility is AF_UNIX if defined for the platform, otherwise the default is AF_INET. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.301 retrieving revision 1.302 diff -u -d -r1.301 -r1.302 --- socketmodule.c 23 Aug 2004 04:54:53 -0000 1.301 +++ socketmodule.c 23 Aug 2004 05:16:23 -0000 1.302 @@ -3011,7 +3011,8 @@ #ifdef HAVE_SOCKETPAIR /* Create a pair of sockets using the socketpair() function. - Arguments as for socket(). */ + Arguments as for socket() except the default family is AF_UNIX if + defined for the platform, otherwise the default is AF_INET. */ /*ARGSUSED*/ static PyObject * @@ -3058,7 +3059,8 @@ \n\ Create a pair of socket objects from the sockets returned by the platform\n\ socketpair() function.\n\ -The arguments are the same as for socket()."); +The arguments are the same as for socket() except the default family is\n\ +AF_UNIX if defined for the platform, otherwise the default is AF_INET."); #endif /* HAVE_SOCKETPAIR */ From paulagrassi203 at hotmail.com Mon Aug 23 18:15:42 2004 From: paulagrassi203 at hotmail.com (Paula O. Grassi) Date: Mon Aug 23 18:15:47 2004 Subject: [Python-checkins] =?iso-8859-1?q?email=2C_mala_direta=2C_propaga?= =?iso-8859-1?q?nda_e-mail=2C_marketing_por_e-mails_listas_de_divul?= =?iso-8859-1?q?ga=E7=E3o?= Message-ID: <20040823161545.D337F1E4005@bag.python.org> Visite agora: http://www.divulgamail.mx.gs mala direta e-mail, email regi?es, e-mails regi?o, mala direta por email, marketing e-mail, regi?es, cadastro e-mails, publicidade por email, emails regi?o, divulgar, enviar emails, campanha emails, propaganda emails, email cidade, envio an?nimo emails, email estados, divulgar e-mail, programas emails, e-mails por estados, e-mails cidade, cadastro e-mail, mala direta por e-mail, listas emails, e-mail regi?es, propaganda email, enviar email an?nimo, envio mala direta, estados, campanha, cidade, envio, publicidade e-mails, Visite agora: http://www.divulgamail.mx.gs campanhas e-mail, lista e-mail, programas e-mails, e-mails estado, publicidade emails, marketing digital, cidade, divulgar, lista email, emails estados, propaganda digital e-mails, e-mail por regi?es, e-mails por cidades, email cidades, campanha e-mail, e-mail estado, listas email, lista emails, propaganda por e-mails, mala direta email, publicidade, cidades, marketing emails, cidade, email por regi?es, envio propaganda, listas e-mails, e-mails regi?es, divulgar e-mails, envio mala-direta, e-mail cidades, email estado, e-mails por Visite agora: http://www.divulgamail.mx.gs regi?o, marketing por emails, propaganda, software email em massa, propaganda digital e-mail, programas email, email, mala direta, propaganda e-mail, marketing e-mails, e-mail, mala-direta email, propaganda digital, emails por regi?o, email segmentado, estado, campanhas e-mails, e-mails cidades, e-mails segmentados, email por estado, marketing por email, emails segmentado, divulga??o, e-mails estados, cidade, campanha e-mails, software, email segmentados, regi?o, enviar e-mails an?nimo, enviar emails an?nimo, mala direta emails, marketing email, emails segmentados, programas e-mail, e-mails por cidade, lista e-mails, propaganda, mala direta por e-mails, campanha email, software spam internet, Visite agora: http://www.divulgamail.mx.gs emails estado, publicidade e-mail, e-mail por cidades, enviar e-mail an?nimo, software propaganda internet, emails cidade, emails, campanhas emails, mala-direta e-mail, publicidade email, mala direta e-mails, e-mail regi?o, listas, listas segmentadas, marketing, marketing digital por emails, email regi?o, divulga??o e-mail, emails por cidade, mala-direta por email, marketing digital por e-mails, listas email, lista segmentada, cidades, cadastro email, divulgue seu produto, mala-direta por e-mails, e-mail por estado, segmentos, email por cidades, propaganda por e-mail, emails cidades, publicidade por emails, envio e-mail, e-mails por estado, mala direta, mala-direta, mala-direta por emails, e-mail segmentado, marketing digital emails, cidades, divulga??o e-mails, marketing, e-mail estados, cidades, marketing por e-mail, envio emails, marketing digital email, propaganda Visite agora: http://www.divulgamail.mx.gs por email, envio an?nimo email, divulgue sua propaganda, propaganda digital emails, cidade, emails por cidades, e-mails segmentado, propaganda por emails, divulgar email, e-mail cidade, enviar e-mails, e-mails, cadastro emails, e-mail por cidade, envio email, cadastro, lista, envio e-mails, propaganda digital email, publicidade por e-mails, marketing digital, e-mail por regi?o, email por estados, divulga??o, emails por estados, segmentados, mala-direta emails, envio publicidade, campanhas, mala direta por emails, e-mail por estados, marketing por e-mails, emails por estado, mala-direta e-mails, marketing digital e-mail, divulgar emails, emails regi?es, publicidade, email por regi?o, e-mails por regi?es, listas e-mail, divulga??o emails, mala-direta por e-mail, enviar e-mail, enviar email, Visite agora: http://www.divulgamail.mx.gs divulga??o email, cidades, publicidade por e-mail, enviar, emails por regi?es, marketing digital por e-mail, email por cidade, campanhas email, marketing digital por email, marketing digital e-mails, propaganda e-mails, e-mail segmentados, envio an?nimo e-mail, software publicidade internet, segmentados, envio an?nimo e-mails, lista mala direta, programa email an?nimo, mala direta internet, publicidade email, mala direta segmentada, emails segmentados, marketing digital, mala direta email, publicidade, spam, mala direta e-mail, email regi?es, e-mails regi?o, mala direta por email, marketing e-mail, regi?es, cadastro e-mails, publicidade por email, emails regi?o, divulgar, enviar emails, campanha emails, propaganda emails, email cidade, envio an?nimo emails, email estados, divulgar e-mail, programas emails, e-mails por estados, e-mails cidade, cadastro e-mail, mala direta por e-mail, listas emails, e-mail regi?es, propaganda email, enviar email an?nimo, envio Visite agora: http://www.divulgamail.mx.gs mala direta, estados, campanha, cidade, envio, publicidade e-mails, campanhas e-mail, lista e-mail, programas e-mails, e-mails estado, publicidade emails, marketing digital, cidade, divulgar, lista email, emails estados, propaganda digital e-mails, e-mail por regi?es, e-mails por cidades, email cidades, campanha e-mail, e-mail estado, listas email, lista emails, propaganda por e-mails, mala direta email, publicidade, cidades, marketing emails, cidade, email por regi?es, envio propaganda, listas e-mails, e-mails regi?es, divulgar e-mails, envio mala-direta, e-mail cidades, email estado, e-mails por regi?o, marketing por emails, propaganda, software email em massa, propaganda digital e-mail, programas email, email, mala direta, propaganda e-mail, marketing e-mails, e-mail, mala-direta email, propaganda Visite agora: http://www.divulgamail.mx.gs digital, emails por regi?o, email segmentado, estado, campanhas e-mails, e-mails cidades, e-mails segmentados, email por estado, marketing por email, emails segmentado, divulga??o, e-mails estados, cidade, campanha e-mails, software, email segmentados, regi?o, enviar e-mails an?nimo, enviar emails an?nimo, mala direta emails, marketing email, emails segmentados, programas e-mail, e-mails por cidade, lista e-mails, propaganda, mala direta por e-mails, campanha email, software spam internet, emails Visite agora: http://www.divulgamail.mx.gs estado, publicidade e-mail, e-mail por cidades, enviar e-mail an?nimo, software propaganda internet, emails cidade, emails, campanhas emails, mala-direta e-mail, publicidade email, mala direta e-mails, e-mail regi?o, listas, listas segmentadas, marketing, marketing digital por emails, email regi?o, divulga??o e-mail, emails por cidade, mala-direta por email, marketing digital por e-mails, listas email, lista segmentada, cidades, cadastro email, divulgue seu produto, mala-direta por e-mails, e-mail por estado, segmentos, email por cidades, propaganda por e-mail, emails cidades, publicidade por emails, envio e-mail, e- Visite agora: http://www.divulgamail.mx.gs mails por estado, mala direta, mala-direta, mala-direta por emails, e-mail segmentado, marketing digital emails, cidades, divulga??o e-mails, marketing, e-mail estados, cidades, marketing por e-mail, envio emails, marketing digital email, propaganda por email, envio an?nimo email, divulgue sua propaganda, propaganda digital emails, cidade, emails por cidades, e-mails segmentado, propaganda por emails, divulgar email, e-mail cidade, enviar e-mails, e-mails, cadastro emails, e-mail por cidade, envio email, cadastro, lista, envio e-mails, propaganda digital email, publicidade por e-mails, marketing digital, e-mail por regi?o, email por estados, divulga??o, emails por estados, segmentados, mala-direta emails, envio publicidade, campanhas, mala direta por emails, e-mail por estados, marketing por e- Visite agora: http://www.divulgamail.mx.gs mails, emails por estado, mala-direta e-mails, marketing digital e-mail, divulgar emails, emails regi?es, publicidade, email por regi?o, e-mails por regi?es, listas e-mail, divulga??o emails, mala-direta por e-mail, enviar e-mail, enviar email, divulga??o email, cidades, publicidade por e-mail, enviar, emails por regi?es, marketing digital por e-mail, email por cidade, campanhas email, marketing digital por email, marketing digital e-mails, propaganda e-mails, e-mail segmentados, envio an?nimo e-mail, software publicidade internet, segmentados, envio an?nimo e-mails, lista mala direta, programa email an?nimo, mala direta internet, publicidade email, mala direta segmentada, emails segmentados, marketing digital, mala direta email, publicidade, spam From akuchling at users.sourceforge.net Mon Aug 23 20:07:09 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon Aug 23 20:07:13 2004 Subject: [Python-checkins] python/nondist/peps pep-3000.txt,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12910 Modified Files: pep-3000.txt Log Message: Add <> operator Index: pep-3000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-3000.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- pep-3000.txt 20 Aug 2004 15:05:39 -0000 1.2 +++ pep-3000.txt 23 Aug 2004 18:07:06 -0000 1.3 @@ -66,6 +66,7 @@ * The ``lambda`` statement [1]_ * String exceptions [2]_ * ```x```: use ``repr(x)`` [2]_ +* The ``<>`` operator (use ``!=`` instead) [3] Built-ins From loewis at users.sourceforge.net Mon Aug 23 22:42:45 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Aug 23 22:42:53 2004 Subject: [Python-checkins] python/dist/src/Lib robotparser.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30066 Modified Files: robotparser.py Log Message: Patch #1014237: Consistently return booleans throughout. Index: robotparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/robotparser.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- robotparser.py 4 May 2004 09:21:43 -0000 1.19 +++ robotparser.py 23 Aug 2004 20:42:35 -0000 1.20 @@ -28,8 +28,8 @@ def __init__(self, url=''): self.entries = [] self.default_entry = None - self.disallow_all = 0 - self.allow_all = 0 + self.disallow_all = False + self.allow_all = False self.set_url(url) self.last_checked = 0 @@ -66,10 +66,10 @@ line = f.readline() self.errcode = opener.errcode if self.errcode == 401 or self.errcode == 403: - self.disallow_all = 1 + self.disallow_all = True _debug("disallow all") elif self.errcode >= 400: - self.allow_all = 1 + self.allow_all = True _debug("allow all") elif self.errcode == 200 and lines: _debug("parse lines") @@ -128,14 +128,14 @@ _debug("line %d: error: you must insert a user-agent:" " directive before this line" % linenumber) else: - entry.rulelines.append(RuleLine(line[1], 0)) + entry.rulelines.append(RuleLine(line[1], False)) state = 2 elif line[0] == "allow": if state==0: _debug("line %d: error: you must insert a user-agent:" " directive before this line" % linenumber) else: - entry.rulelines.append(RuleLine(line[1], 1)) + entry.rulelines.append(RuleLine(line[1], True)) else: _debug("line %d: warning: unknown key %s" % (linenumber, line[0])) @@ -175,12 +175,12 @@ class RuleLine: - """A rule line is a single "Allow:" (allowance==1) or "Disallow:" - (allowance==0) followed by a path.""" + """A rule line is a single "Allow:" (allowance==True) or "Disallow:" + (allowance==False) followed by a path.""" def __init__(self, path, allowance): if path == '' and not allowance: # an empty value means allow all - allowance = 1 + allowance = True self.path = urllib.quote(path) self.allowance = allowance @@ -226,7 +226,7 @@ _debug((filename, str(line), line.allowance)) if line.applies_to(filename): return line.allowance - return 1 + return True class URLopener(urllib.FancyURLopener): def __init__(self, *args): From tim_one at users.sourceforge.net Mon Aug 23 23:38:01 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 23 23:38:06 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.78,1.79 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15923/Lib Modified Files: doctest.py Log Message: debug_script(): I changed this in haste before to take out the use of NamedTemporaryFile (which can't work for this function's purposes on Windows). Leaving temp files behind wasn't a great idea either, though, so try to clean up. At least the test suite no longer leaves any of these guys behind now. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.78 retrieving revision 1.79 diff -u -d -r1.78 -r1.79 --- doctest.py 22 Aug 2004 20:51:53 -0000 1.78 +++ doctest.py 23 Aug 2004 21:37:56 -0000 1.79 @@ -2342,26 +2342,33 @@ "Debug a test script. `src` is the script, as a string." import pdb - srcfilename = tempfile.mktemp("doctestdebug.py") + # Note that tempfile.NameTemporaryFile() cannot be used. As the + # docs say, a file so created cannot be opened by name a second time + # on modern Windows boxes, and execfile() needs to open it. + srcfilename = tempfile.mktemp(".py", "doctestdebug") f = open(srcfilename, 'w') f.write(src) f.close() - if globs: - globs = globs.copy() - else: - globs = {} + try: + if globs: + globs = globs.copy() + else: + globs = {} - if pm: - try: - execfile(srcfilename, globs, globs) - except: - print sys.exc_info()[1] - pdb.post_mortem(sys.exc_info()[2]) - else: - # Note that %r is vital here. '%s' instead can, e.g., cause - # backslashes to get treated as metacharacters on Windows. - pdb.run("execfile(%r)" % srcfilename, globs, globs) + if pm: + try: + execfile(srcfilename, globs, globs) + except: + print sys.exc_info()[1] + pdb.post_mortem(sys.exc_info()[2]) + else: + # Note that %r is vital here. '%s' instead can, e.g., cause + # backslashes to get treated as metacharacters on Windows. + pdb.run("execfile(%r)" % srcfilename, globs, globs) + + finally: + os.remove(srcfilename) def debug(module, name, pm=False): """Debug a single doctest docstring. From tim_one at users.sourceforge.net Mon Aug 23 23:43:43 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Aug 23 23:43:50 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.79,1.80 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18129/Lib Modified Files: doctest.py Log Message: Misc cleanups. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.79 retrieving revision 1.80 diff -u -d -r1.79 -r1.80 --- doctest.py 23 Aug 2004 21:37:56 -0000 1.79 +++ doctest.py 23 Aug 2004 21:43:39 -0000 1.80 @@ -1555,7 +1555,7 @@ # This flag causes doctest to ignore any differences in the # contents of whitespace strings. Note that this can be used - # in conjunction with the ELLISPIS flag. + # in conjunction with the ELLIPSIS flag. if optionflags & NORMALIZE_WHITESPACE: got = ' '.join(got.split()) want = ' '.join(want.split()) @@ -2435,6 +2435,7 @@ >>> x + y, x * y (3, 2) """, + "bool-int equivalence": r""" In 2.2, boolean expressions displayed 0 or 1. By default, we still accept @@ -2450,30 +2451,32 @@ >>> 4 > 4 False """, + "blank lines": r""" - Blank lines can be marked with : - >>> print 'foo\n\nbar\n' - foo - - bar - + Blank lines can be marked with : + >>> print 'foo\n\nbar\n' + foo + + bar + + """, + + "ellipsis": r""" + If the ellipsis flag is used, then '...' can be used to + elide substrings in the desired output: + >>> print range(1000) #doctest: +ELLIPSIS + [0, 1, 2, ..., 999] """, - } -# "ellipsis": r""" -# If the ellipsis flag is used, then '...' can be used to -# elide substrings in the desired output: -# >>> print range(1000) -# [0, 1, 2, ..., 999] -# """, -# "whitespace normalization": r""" -# If the whitespace normalization flag is used, then -# differences in whitespace are ignored. -# >>> print range(30) -# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, -# 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, -# 27, 28, 29] -# """, -# } + + "whitespace normalization": r""" + If the whitespace normalization flag is used, then + differences in whitespace are ignored. + >>> print range(30) #doctest: +NORMALIZE_WHITESPACE + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29] + """, + } def test1(): r""" >>> warnings.filterwarnings("ignore", "class Tester", DeprecationWarning, @@ -2592,11 +2595,6 @@ """ def _test(): - #import doctest - #doctest.testmod(doctest, verbose=False, - # optionflags=ELLIPSIS | NORMALIZE_WHITESPACE | - # UNIFIED_DIFF) - #print '~'*70 r = unittest.TextTestRunner() r.run(DocTestSuite()) From tim_one at users.sourceforge.net Tue Aug 24 00:13:27 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 24 00:13:32 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.27, 1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27814/Lib/test Modified Files: test_doctest.py Log Message: Moved some test cases from doctest to test_doctest. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- test_doctest.py 22 Aug 2004 19:43:28 -0000 1.27 +++ test_doctest.py 23 Aug 2004 22:13:22 -0000 1.28 @@ -4,6 +4,7 @@ from test import test_support import doctest +import warnings ###################################################################### ## Sample Objects (used by test cases) @@ -277,7 +278,7 @@ >>> tests = finder.find(sample_func) >>> print tests # doctest: +ELLIPSIS - [] + [] >>> tests[0].filename 'test_doctest.py' @@ -1493,13 +1494,136 @@ def test_trailing_space_in_test(): """ - Trailing spaces in expcted output are significant: + Trailing spaces in expected output are significant: >>> x, y = 'foo', '' >>> print x, y foo \n """ +# old_test1, ... used to live in doctest.py, but cluttered it. Note +# that these use the deprecated doctest.Tester, so should go away (or +# be rewritten) someday. + +# Ignore all warnings about the use of class Tester in this module. +# Note that the name of this module may differ depending on how it's +# imported, so the use of __name__ is important. +warnings.filterwarnings("ignore", "class Tester", DeprecationWarning, + __name__, 0) + +def old_test1(): r""" +>>> from doctest import Tester +>>> t = Tester(globs={'x': 42}, verbose=0) +>>> t.runstring(r''' +... >>> x = x * 2 +... >>> print x +... 42 +... ''', 'XYZ') +********************************************************************** +Line 3, in XYZ +Failed example: + print x +Expected: + 42 +Got: + 84 +(1, 2) +>>> t.runstring(">>> x = x * 2\n>>> print x\n84\n", 'example2') +(0, 2) +>>> t.summarize() +********************************************************************** +1 items had failures: + 1 of 2 in XYZ +***Test Failed*** 1 failures. +(1, 4) +>>> t.summarize(verbose=1) +1 items passed all tests: + 2 tests in example2 +********************************************************************** +1 items had failures: + 1 of 2 in XYZ +4 tests in 2 items. +3 passed and 1 failed. +***Test Failed*** 1 failures. +(1, 4) +""" + +def old_test2(): r""" + >>> from doctest import Tester + >>> t = Tester(globs={}, verbose=1) + >>> test = r''' + ... # just an example + ... >>> x = 1 + 2 + ... >>> x + ... 3 + ... ''' + >>> t.runstring(test, "Example") + Running string Example + Trying: x = 1 + 2 + Expecting: nothing + ok + Trying: x + Expecting: 3 + ok + 0 of 2 examples failed in string Example + (0, 2) +""" + +def old_test3(): r""" + >>> from doctest import Tester + >>> t = Tester(globs={}, verbose=0) + >>> def _f(): + ... '''Trivial docstring example. + ... >>> assert 2 == 2 + ... ''' + ... return 32 + ... + >>> t.rundoc(_f) # expect 0 failures in 1 example + (0, 1) +""" + +def old_test4(): """ + >>> import new + >>> m1 = new.module('_m1') + >>> m2 = new.module('_m2') + >>> test_data = \""" + ... def _f(): + ... '''>>> assert 1 == 1 + ... ''' + ... def g(): + ... '''>>> assert 2 != 1 + ... ''' + ... class H: + ... '''>>> assert 2 > 1 + ... ''' + ... def bar(self): + ... '''>>> assert 1 < 2 + ... ''' + ... \""" + >>> exec test_data in m1.__dict__ + >>> exec test_data in m2.__dict__ + >>> m1.__dict__.update({"f2": m2._f, "g2": m2.g, "h2": m2.H}) + + Tests that objects outside m1 are excluded: + + >>> from doctest import Tester + >>> t = Tester(globs={}, verbose=0) + >>> t.rundict(m1.__dict__, "rundict_test", m1) # f2 and g2 and h2 skipped + (0, 4) + + Once more, not excluding stuff outside m1: + + >>> t = Tester(globs={}, verbose=0) + >>> t.rundict(m1.__dict__, "rundict_test_pvt") # None are skipped. + (0, 8) + + The exclusion of objects from outside the designated module is + meant to be invoked automagically by testmod. + + >>> doctest.testmod(m1, verbose=False) + (0, 4) +""" + ###################################################################### ## Main ###################################################################### From tim_one at users.sourceforge.net Tue Aug 24 00:13:27 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 24 00:13:35 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.80,1.81 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27814/Lib Modified Files: doctest.py Log Message: Moved some test cases from doctest to test_doctest. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.80 retrieving revision 1.81 diff -u -d -r1.80 -r1.81 --- doctest.py 23 Aug 2004 21:43:39 -0000 1.80 +++ doctest.py 23 Aug 2004 22:13:21 -0000 1.81 @@ -2478,122 +2478,6 @@ """, } -def test1(): r""" ->>> warnings.filterwarnings("ignore", "class Tester", DeprecationWarning, -... "doctest", 0) ->>> from doctest import Tester ->>> t = Tester(globs={'x': 42}, verbose=0) ->>> t.runstring(r''' -... >>> x = x * 2 -... >>> print x -... 42 -... ''', 'XYZ') -********************************************************************** -Line 3, in XYZ -Failed example: - print x -Expected: - 42 -Got: - 84 -(1, 2) ->>> t.runstring(">>> x = x * 2\n>>> print x\n84\n", 'example2') -(0, 2) ->>> t.summarize() -********************************************************************** -1 items had failures: - 1 of 2 in XYZ -***Test Failed*** 1 failures. -(1, 4) ->>> t.summarize(verbose=1) -1 items passed all tests: - 2 tests in example2 -********************************************************************** -1 items had failures: - 1 of 2 in XYZ -4 tests in 2 items. -3 passed and 1 failed. -***Test Failed*** 1 failures. -(1, 4) -""" - -def test2(): r""" - >>> warnings.filterwarnings("ignore", "class Tester", - ... DeprecationWarning, "doctest", 0) - >>> t = Tester(globs={}, verbose=1) - >>> test = r''' - ... # just an example - ... >>> x = 1 + 2 - ... >>> x - ... 3 - ... ''' - >>> t.runstring(test, "Example") - Running string Example - Trying: x = 1 + 2 - Expecting: nothing - ok - Trying: x - Expecting: 3 - ok - 0 of 2 examples failed in string Example - (0, 2) -""" -def test3(): r""" - >>> warnings.filterwarnings("ignore", "class Tester", - ... DeprecationWarning, "doctest", 0) - >>> t = Tester(globs={}, verbose=0) - >>> def _f(): - ... '''Trivial docstring example. - ... >>> assert 2 == 2 - ... ''' - ... return 32 - ... - >>> t.rundoc(_f) # expect 0 failures in 1 example - (0, 1) -""" -def test4(): """ - >>> import new - >>> m1 = new.module('_m1') - >>> m2 = new.module('_m2') - >>> test_data = \""" - ... def _f(): - ... '''>>> assert 1 == 1 - ... ''' - ... def g(): - ... '''>>> assert 2 != 1 - ... ''' - ... class H: - ... '''>>> assert 2 > 1 - ... ''' - ... def bar(self): - ... '''>>> assert 1 < 2 - ... ''' - ... \""" - >>> exec test_data in m1.__dict__ - >>> exec test_data in m2.__dict__ - >>> m1.__dict__.update({"f2": m2._f, "g2": m2.g, "h2": m2.H}) - - Tests that objects outside m1 are excluded: - - >>> warnings.filterwarnings("ignore", "class Tester", - ... DeprecationWarning, "doctest", 0) - >>> t = Tester(globs={}, verbose=0) - >>> t.rundict(m1.__dict__, "rundict_test", m1) # f2 and g2 and h2 skipped - (0, 4) - - Once more, not excluding stuff outside m1: - - >>> t = Tester(globs={}, verbose=0) - >>> t.rundict(m1.__dict__, "rundict_test_pvt") # None are skipped. - (0, 8) - - The exclusion of objects from outside the designated module is - meant to be invoked automagically by testmod. - - >>> testmod(m1, verbose=False) - (0, 4) -""" - def _test(): r = unittest.TextTestRunner() r.run(DocTestSuite()) From tim_one at users.sourceforge.net Tue Aug 24 00:38:08 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 24 00:38:13 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.28, 1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4476/Lib/test Modified Files: test_doctest.py Log Message: test_DocTestFinder(): This test failed when test_doctest was run directly, due to assuming a filename specific to running tests "the normal way". +ELLIPSIS to the rescue! Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- test_doctest.py 23 Aug 2004 22:13:22 -0000 1.28 +++ test_doctest.py 23 Aug 2004 22:38:05 -0000 1.29 @@ -280,8 +280,11 @@ >>> print tests # doctest: +ELLIPSIS [] - >>> tests[0].filename - 'test_doctest.py' +The exact name depends on how test_doctest was invoked, so allow for +leading path components. + + >>> tests[0].filename # doctest: +ELLIPSIS + '...test_doctest.py' >>> test.test_doctest.__file__ = old From tim_one at users.sourceforge.net Tue Aug 24 00:42:58 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Aug 24 00:43:02 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.81,1.82 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6151/Lib Modified Files: doctest.py Log Message: The attempt to shut up deprecation warnings for doctest's own use of is_private in its tests failed if doctest.py was run directly. Now it works. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.81 retrieving revision 1.82 diff -u -d -r1.81 -r1.82 --- doctest.py 23 Aug 2004 22:13:21 -0000 1.81 +++ doctest.py 23 Aug 2004 22:42:55 -0000 1.82 @@ -220,6 +220,11 @@ import warnings from StringIO import StringIO +# Don't whine about the deprecated is_private function in this +# module's tests. +warnings.filterwarnings("ignore", "is_private", DeprecationWarning, + __name__, 0) + real_pdb_set_trace = pdb.set_trace # There are 4 basic classes: @@ -287,8 +292,6 @@ Return true iff base begins with an (at least one) underscore, but does not both begin and end with (at least) two underscores. - >>> warnings.filterwarnings("ignore", "is_private", DeprecationWarning, - ... "doctest", 0) >>> is_private("a.b", "my_func") False >>> is_private("____", "_my_func") From rhettinger at users.sourceforge.net Tue Aug 24 01:23:56 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 24 01:24:01 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_string.py, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20193/Lib/test Modified Files: test_string.py Log Message: SF Patch #1007087: Return new string for single subclass joins (Bug #1001011) (Patch contributed by Nick Coghlan.) Now joining string subtypes will always return a string. Formerly, if there were only one item, it was returned unchanged. Index: test_string.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_string.py,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- test_string.py 1 May 2003 17:45:50 -0000 1.25 +++ test_string.py 23 Aug 2004 23:23:53 -0000 1.26 @@ -52,6 +52,29 @@ self.checkraises(TypeError, string_tests.BadSeq1(), 'join', ' ') self.checkequal('a b c', string_tests.BadSeq2(), 'join', ' ') + def test_bug1001011(self): + # Make sure join returns a NEW object for single item sequences + # involving a subclass + # Make sure that it is of the appropriate type + # Check the optimisation still occurs for standard objects + class str_subclass(str): pass + s1 = str_subclass('abcd') + s2 = ''.join([s1]) + self.failIf(s1 is s2) + self.assertEqual(type(s2), type('')) + s3 = 'abcd' + s4 = ''.join([s3]) + self.failUnless(s3 is s4) + if test_support.have_unicode: + class unicode_subclass(unicode): pass + u1 = unicode_subclass(u'abcd') + u2 = ''.join([u1]) + self.failIf(u1 is u2) + self.assertEqual(type(u2), type(u'')) + u3 = u'abcd' + u4 = ''.join([u3]) + self.failUnless(u3 is u4) + class ModuleTest(unittest.TestCase): def test_attrs(self): From rhettinger at users.sourceforge.net Tue Aug 24 01:23:57 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 24 01:24:03 2004 Subject: [Python-checkins] python/dist/src/Objects stringobject.c, 2.224, 2.225 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20193/Objects Modified Files: stringobject.c Log Message: SF Patch #1007087: Return new string for single subclass joins (Bug #1001011) (Patch contributed by Nick Coghlan.) Now joining string subtypes will always return a string. Formerly, if there were only one item, it was returned unchanged. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.224 retrieving revision 2.225 diff -u -d -r2.224 -r2.225 --- stringobject.c 7 Aug 2004 20:58:32 -0000 2.224 +++ stringobject.c 23 Aug 2004 23:23:54 -0000 2.225 @@ -1618,22 +1618,18 @@ } if (seqlen == 1) { item = PySequence_Fast_GET_ITEM(seq, 0); - if (!PyString_Check(item) && !PyUnicode_Check(item)) { - PyErr_Format(PyExc_TypeError, - "sequence item 0: expected string," - " %.80s found", - item->ob_type->tp_name); + if (PyString_CheckExact(item) || PyUnicode_CheckExact(item)) { + Py_INCREF(item); Py_DECREF(seq); - return NULL; + return item; } - Py_INCREF(item); - Py_DECREF(seq); - return item; } - /* There are at least two things to join. Do a pre-pass to figure out - * the total amount of space we'll need (sz), see whether any argument - * is absurd, and defer to the Unicode join if appropriate. + /* There are at least two things to join, or else we have a subclass + * of the builtin types in the sequence. + * Do a pre-pass to figure out the total amount of space we'll + * need (sz), see whether any argument is absurd, and defer to + * the Unicode join if appropriate. */ for (i = 0; i < seqlen; i++) { const size_t old_sz = sz; From rhettinger at users.sourceforge.net Tue Aug 24 01:30:24 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 24 01:30:29 2004 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.277,1.278 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22244 Modified Files: ACKS Log Message: Add Nick Coghlan for his patch solving an issue with joining string subclasses. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.277 retrieving revision 1.278 diff -u -d -r1.277 -r1.278 --- ACKS 7 Aug 2004 14:17:50 -0000 1.277 +++ ACKS 23 Aug 2004 23:30:20 -0000 1.278 @@ -113,6 +113,7 @@ Mike Clarkson Brad Clements Steve Clift +Nick Coghlan Josh Cogliati Dave Cole Benjamin Collar From rhettinger at users.sourceforge.net Tue Aug 24 01:37:51 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 24 01:37:56 2004 Subject: [Python-checkins] python/dist/src/Python compile.c, 2.320, 2.321 import.c, 2.236, 2.237 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23266/Python Modified Files: compile.c import.c Log Message: SF Patch #1013667: Cleanup Peepholer Output * Make a pass to eliminate NOPs. Produce code that is more readable, more compact, and a tiny bit faster. Makes the peepholer more flexible in the scope of allowable transformations. * With Guido's okay, bumped up the magic number so that this patch gets widely exercised before the alpha goes out. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.320 retrieving revision 2.321 diff -u -d -r2.320 -r2.321 --- compile.c 18 Aug 2004 05:22:06 -0000 2.320 +++ compile.c 23 Aug 2004 23:37:47 -0000 2.321 @@ -424,11 +424,14 @@ } static PyObject * -optimize_code(PyObject *code, PyObject* consts, PyObject *names) +optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *lineno_obj) { - int i, j, codelen; + int i, j, codelen, nops, h, adj; int tgt, tgttgt, opcode; - unsigned char *codestr; + unsigned char *codestr = NULL; + unsigned char *lineno; + int *addrmap = NULL; + int new_line, cum_orig_line, last_line, tabsiz; unsigned int *blocks; char *name; @@ -441,23 +444,27 @@ goto exitUnchanged; codestr = memcpy(codestr, PyString_AS_STRING(code), codelen); + /* Mapping to new jump targets after NOPs are removed */ + addrmap = PyMem_Malloc(codelen * sizeof(int)); + if (addrmap == NULL) + goto exitUnchanged; + /* Avoid situations where jump retargeting could overflow */ - if (codelen > 65000) + if (codelen > 32000) goto exitUnchanged; blocks = markblocks(codestr, codelen); - if (blocks == NULL) { - PyMem_Free(codestr); + if (blocks == NULL) goto exitUnchanged; - } assert(PyTuple_Check(consts)); - for (i=0 ; i a is not b @@ -482,9 +490,10 @@ if (j < 6 || j > 9 || codestr[i+3] != UNARY_NOT || !ISBASICBLOCK(blocks,i,4)) - continue; + continue; SETARG(codestr, i, (j^1)); codestr[i+3] = NOP; + nops++; break; /* Replace LOAD_GLOBAL/LOAD_NAME None with LOAD_CONST None */ @@ -503,43 +512,40 @@ } break; - /* Skip over LOAD_CONST trueconst JUMP_IF_FALSE xx POP_TOP. - Note, only the first opcode is changed, the others still - perform normally if they happen to be jump targets. */ + /* Skip over LOAD_CONST trueconst JUMP_IF_FALSE xx POP_TOP */ case LOAD_CONST: j = GETARG(codestr, i); if (codestr[i+3] != JUMP_IF_FALSE || codestr[i+6] != POP_TOP || + !ISBASICBLOCK(blocks,i,7) || !PyObject_IsTrue(PyTuple_GET_ITEM(consts, j))) continue; - codestr[i] = JUMP_FORWARD; - SETARG(codestr, i, 4); + memset(codestr+i, NOP, 7); + nops += 7; break; - /* Replace BUILD_SEQN 2 UNPACK_SEQN 2 with ROT2 JMP+2 NOP NOP. - Replace BUILD_SEQN 3 UNPACK_SEQN 3 with ROT3 ROT2 JMP+1 NOP. */ + /* Skip over BUILD_SEQN 1 UNPACK_SEQN 1. + Replace BUILD_SEQN 2 UNPACK_SEQN 2 with ROT2. + Replace BUILD_SEQN 3 UNPACK_SEQN 3 with ROT3 ROT2. */ case BUILD_TUPLE: case BUILD_LIST: - if (codestr[i+3] != UNPACK_SEQUENCE) - continue; - if (!ISBASICBLOCK(blocks,i,6)) + j = GETARG(codestr, i); + if (codestr[i+3] != UNPACK_SEQUENCE || + !ISBASICBLOCK(blocks,i,6) || + j != GETARG(codestr, i+3)) continue; - if (GETARG(codestr, i) == 2 && - GETARG(codestr, i+3) == 2) { + if (j == 1) { + memset(codestr+i, NOP, 6); + nops += 6; + } else if (j == 2) { codestr[i] = ROT_TWO; - codestr[i+1] = JUMP_FORWARD; - SETARG(codestr, i+1, 2); - codestr[i+4] = NOP; - codestr[i+5] = NOP; - continue; - } - if (GETARG(codestr, i) == 3 && - GETARG(codestr, i+3) == 3) { + memset(codestr+i+1, NOP, 5); + nops += 5; + } else if (j == 3) { codestr[i] = ROT_THREE; codestr[i+1] = ROT_TWO; - codestr[i+2] = JUMP_FORWARD; - SETARG(codestr, i+2, 1); - codestr[i+5] = NOP; + memset(codestr+i+2, NOP, 4); + nops += 4; } break; @@ -570,14 +576,73 @@ case EXTENDED_ARG: PyMem_Free(codestr); goto exitUnchanged; + + /* Replace RETURN LOAD_CONST None RETURN with just RETURN */ + case RETURN_VALUE: + if (i+4 >= codelen || + codestr[i+4] != RETURN_VALUE || + !ISBASICBLOCK(blocks,i,5)) + continue; + memset(codestr+i+1, NOP, 4); + nops += 4; + break; } } - code = PyString_FromStringAndSize((char *)codestr, codelen); + + /* Fixup linenotab */ + assert(PyString_Check(lineno_obj)); + lineno = PyString_AS_STRING(lineno_obj); + tabsiz = PyString_GET_SIZE(lineno_obj); + cum_orig_line = 0; + last_line = 0; + for (i=0 ; i < tabsiz ; i+=2) { + cum_orig_line += lineno[i]; + new_line = addrmap[cum_orig_line]; + lineno[i] =((unsigned char)(new_line - last_line)); + last_line = new_line; + } + + /* Remove NOPs and fixup jump targets */ + for (i=0, h=0 ; i Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23266/Lib/test Modified Files: test_dis.py Added Files: test_peepholer.py Log Message: SF Patch #1013667: Cleanup Peepholer Output * Make a pass to eliminate NOPs. Produce code that is more readable, more compact, and a tiny bit faster. Makes the peepholer more flexible in the scope of allowable transformations. * With Guido's okay, bumped up the magic number so that this patch gets widely exercised before the alpha goes out. --- NEW FILE: test_peepholer.py --- import dis import sys from cStringIO import StringIO import unittest def disassemble(func): f = StringIO() tmp = sys.stdout sys.stdout = f dis.dis(func) sys.stdout = tmp result = f.getvalue() f.close() return result def dis_single(line): return disassemble(compile(line, '', 'single')) class TestTranforms(unittest.TestCase): def test_unot(self): # UNARY_NOT JUMP_IF_FALSE POP_TOP --> JUMP_IF_TRUE POP_TOP' def unot(x): if not x == 2: del x asm = disassemble(unot) for elem in ('UNARY_NOT', 'JUMP_IF_FALSE'): self.assert_(elem not in asm) for elem in ('JUMP_IF_TRUE', 'POP_TOP'): self.assert_(elem in asm) def test_elim_inversion_of_is_or_in(self): for line, elem in ( ('not a is b', '(is not)',), ('not a in b', '(not in)',), ('not a is not b', '(is)',), ('not a not in b', '(in)',), ): asm = dis_single(line) self.assert_(elem in asm) def test_none_as_constant(self): # LOAD_GLOBAL None --> LOAD_CONST None def f(x): None return x asm = disassemble(f) for elem in ('LOAD_GLOBAL',): self.assert_(elem not in asm) for elem in ('LOAD_CONST', '(None)'): self.assert_(elem in asm) def test_while_one(self): # Skip over: LOAD_CONST trueconst JUMP_IF_FALSE xx POP_TOP def f(): while 1: pass return list asm = disassemble(f) for elem in ('LOAD_CONST', 'JUMP_IF_FALSE'): self.assert_(elem not in asm) for elem in ('JUMP_ABSOLUTE',): self.assert_(elem in asm) def test_pack_unpack(self): for line, elem in ( ('a, = 1,', 'LOAD_CONST',), ('a, b = 1, 2', 'ROT_TWO',), ('a, b, c = 1, 2, 3', 'ROT_THREE',), ): asm = dis_single(line) self.assert_(elem in asm) self.assert_('BUILD_TUPLE' not in asm) self.assert_('UNPACK_TUPLE' not in asm) def test_elim_extra_return(self): # RETURN LOAD_CONST None RETURN --> RETURN def f(x): return x asm = disassemble(f) self.assert_('LOAD_CONST' not in asm) self.assert_('(None)' not in asm) self.assertEqual(asm.split().count('RETURN_VALUE'), 1) def test_main(verbose=None): import sys from test import test_support test_classes = (TestTranforms,) test_support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in xrange(len(counts)): test_support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print counts if __name__ == "__main__": test_main(verbose=True) Index: test_dis.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_dis.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- test_dis.py 30 Apr 2003 08:42:19 -0000 1.4 +++ test_dis.py 23 Aug 2004 23:37:47 -0000 1.5 @@ -18,8 +18,6 @@ %-4d 5 LOAD_CONST 1 (1) 8 RETURN_VALUE - 9 LOAD_CONST 0 (None) - 12 RETURN_VALUE """%(_f.func_code.co_firstlineno + 1, _f.func_code.co_firstlineno + 2) From rhettinger at users.sourceforge.net Tue Aug 24 06:34:19 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Aug 24 06:34:24 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.321,2.322 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12031 Modified Files: compile.c Log Message: Incorporate review comments courtesy of Neal Norwitz: * Perform the code length check earlier. * Eliminate the extra PyMem_Free() upon hitting an EXTENDED_ARG. * Assert that the NOP count used in jump retargeting matches the NOPs eliminated in the final step. * Add an XXX note to indicate that more work is being to done to handle linenotab with intervals > 255. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.321 retrieving revision 2.322 diff -u -d -r2.321 -r2.322 --- compile.c 23 Aug 2004 23:37:47 -0000 2.321 +++ compile.c 24 Aug 2004 04:34:16 -0000 2.322 @@ -435,10 +435,15 @@ unsigned int *blocks; char *name; - /* Make a modifiable copy of the code string */ if (!PyString_Check(code)) goto exitUnchanged; + + /* Avoid situations where jump retargeting could overflow */ codelen = PyString_Size(code); + if (codelen > 32000) + goto exitUnchanged; + + /* Make a modifiable copy of the code string */ codestr = PyMem_Malloc(codelen); if (codestr == NULL) goto exitUnchanged; @@ -449,10 +454,6 @@ if (addrmap == NULL) goto exitUnchanged; - /* Avoid situations where jump retargeting could overflow */ - if (codelen > 32000) - goto exitUnchanged; - blocks = markblocks(codestr, codelen); if (blocks == NULL) goto exitUnchanged; @@ -574,7 +575,6 @@ break; case EXTENDED_ARG: - PyMem_Free(codestr); goto exitUnchanged; /* Replace RETURN LOAD_CONST None RETURN with just RETURN */ @@ -590,6 +590,7 @@ } /* Fixup linenotab */ + /* XXX make sure this handles intervals > 256 */ assert(PyString_Check(lineno_obj)); lineno = PyString_AS_STRING(lineno_obj); tabsiz = PyString_GET_SIZE(lineno_obj); @@ -631,6 +632,7 @@ while (adj--) codestr[h++] = codestr[i++]; } + assert(h + nops == codelen); code = PyString_FromStringAndSize((char *)codestr, h); PyMem_Free(addrmap); From bcannon at users.sourceforge.net Tue Aug 24 07:50:05 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Tue Aug 24 07:50:11 2004 Subject: [Python-checkins] python/nondist/peps pep-0318.txt,1.24,1.25 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30454 Modified Files: pep-0318.txt Log Message: Integrate points listed in python-dev Summary not covered in PEP. Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- pep-0318.txt 20 Aug 2004 01:18:24 -0000 1.24 +++ pep-0318.txt 24 Aug 2004 05:50:01 -0000 1.25 @@ -145,7 +145,9 @@ The new syntax should * work for arbitrary wrappers, including user-defined callables and - the existing builtins ``classmethod()`` and ``staticmethod()`` + the existing builtins ``classmethod()`` and ``staticmethod()``. This + requirement also means that a decorator syntax must support passing + arguments to the wrapper constructor * work with multiple wrappers per definition @@ -153,6 +155,8 @@ obvious that new users can safely ignore it when writing their own code +* be a syntax "that ... [is] easy to remember once explained" + * not make future extensions more difficult * be easy to type; programs that use it are expected to use it very @@ -166,6 +170,11 @@ language-sensitive editors and other "`toy parser tools out there`_" +* allow future compilers to optimize for decorators. With the hope of + a JIT compiler for Python coming into existence at some point this + tends to require the syntax for decorators to come before the + function definition + * move from the end of the function, where it's currently hidden, to the front where it is more `in your face`_ @@ -251,9 +260,20 @@ will be in 2.4a3 will also require one decorator per line (in a2, multiple decorators can be specified on the same line). +People also complained that the syntax got unwieldly quickly when +multiple decorators were used. The point was made, though, that the +chances of a large number of decorators being used on a single function +were small and thus this was not a large worry. + Some of the advantages of this form are that the decorators live outside the method body -- they are obviously executed at the time -the function is defined +the function is defined. + +Another advantage is that being prefix to the function definition fit the +idea of knowing about a change to the semantics of the code before the +code itself, thus knowing how to interpret the code's semantics +properly without having to go back and change your initial perceptions +if the syntax did not come before the function definition. The second form is the decorators between the def and the function name, or the function name and the argument list:: @@ -456,6 +476,13 @@ for side effects of the list, is already legal and thus creates a special case. +One attraction people later had to the syntax, though, was the +possibility of implementing a backwards-compatible implementation of +decorators so that versions prior to 2.4 (back to 2.2) could also use +the new syntax. But it was decided this was not a valid argument; +Since the feature is new it should not be restricted just so that +previous versions could possibly use it. + .. _list of decorators: http://python.org/sf/926860 @@ -502,8 +529,9 @@ are similar to Python decorators. The fact that @ was previously unused as a token in Python also means it's clear there is no possibility of such code being parsed by an earlier version of Python, -leading to possibly subtle semantic bugs. That said, @ is still a -fairly arbitrary choice. Some have suggested using | instead. +leading to possibly subtle semantic bugs. It also means that ambiguity +of what is a decorator and what isn't is removed. of That said, @ is +still a fairly arbitrary choice. Some have suggested using | instead. For syntax options which use a list-like syntax (no matter where it appears) to specify the decorators a few alternatives were proposed: From vsajip at users.sourceforge.net Tue Aug 24 11:36:27 2004 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Tue Aug 24 11:36:31 2004 Subject: [Python-checkins] python/dist/src/Lib/logging handlers.py, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29765 Modified Files: handlers.py Log Message: Fixed bug in DatagramHandler.send() Index: handlers.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- handlers.py 18 Aug 2004 12:27:40 -0000 1.17 +++ handlers.py 24 Aug 2004 09:36:23 -0000 1.18 @@ -450,6 +450,8 @@ when the network is busy - UDP does not guarantee delivery and can deliver packets out of sequence. """ + if self.sock is None: + self.createSocket() self.sock.sendto(s, (self.host, self.port)) class SysLogHandler(logging.Handler): From montanaro at users.sourceforge.net Tue Aug 24 16:26:46 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Tue Aug 24 16:26:50 2004 Subject: [Python-checkins] python/dist/src/Tools/scripts hotshotmain.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21902 Modified Files: hotshotmain.py Log Message: Keep option parser from gobbling up the filename to be profiled and the flags it accepts. It's too late to change optparse's default behavior now, but I find the default setting of allow_interspersed_args very weird. Index: hotshotmain.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/hotshotmain.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- hotshotmain.py 26 Jan 2004 19:44:48 -0000 1.1 +++ hotshotmain.py 24 Aug 2004 14:26:43 -0000 1.2 @@ -39,6 +39,7 @@ def main(args): parser = optparse.OptionParser(__doc__) + parser.disable_interspersed_args() parser.add_option("-p", "--profile", action="store", default=PROFILE, dest="profile", help='Specify profile file to use') (options, args) = parser.parse_args(args) From montanaro at users.sourceforge.net Tue Aug 24 20:56:13 2004 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Tue Aug 24 20:56:21 2004 Subject: [Python-checkins] python/nondist/peps pep-0318.txt,1.25,1.26 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11703 Modified Files: pep-0318.txt Log Message: List some possible reasons why arriving at consensus about decorators has been so hard (or impossible) to acheive. There are certainly more. Are these the killers? Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- pep-0318.txt 24 Aug 2004 05:50:01 -0000 1.25 +++ pep-0318.txt 24 Aug 2004 18:56:00 -0000 1.26 @@ -78,6 +78,41 @@ decorators are being added. +Why Is This So Hard? +-------------------- + +A couple decorators (``classmethod()`` and ``staticmethod()``) have +been available in Python since version 2.2. It's been assumed since +approximately that time that some syntactic support for them would +eventually be added to the language. Given this assumption, one might +wonder why it's been so difficult to arrive at a consensus. +Discussions have raged off-and-on at times in both comp.lang.python +and the python-dev mailing list about how best to implement function +decorators. There is no one clear reason why this should be so, but a +few problems seem to be most problematic. + +* Disagreement about where the "declaration of intent" belongs. + Almost everyone agrees that decorating/transforming a function at + the end of its definition is suboptimal. Beyond that there seems to + be no clear consensus where to place this information. + +* Syntactic constraints. Python is a syntactically simple language + with fairly strong constraints on what can and can't be done without + "messing things up" (both visually and with regards to the language + parser). There's no obvious way to structure this information so + that people new to the concept will think, "Oh yeah, I know what + you're doing." The best that seems possible is to keep new users + from creating a wildly incorrect mental model of what the syntax + means. + +* Overall unfamiliarity with the concept. For people who have a + passing acquaintance with algebra (or even basic arithmetic) or have + used at least one other programming language, much of Python is + intuitive. Very few people will have had any experience with the + decorator concept before encountering it in Python. There's just no + strong preexisting meme that captures the concept. + + Background ========== From doko at users.sourceforge.net Tue Aug 24 23:37:51 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Tue Aug 24 23:37:55 2004 Subject: [Python-checkins] python/dist/src/Lib/encodings koi8_u.py, 1.1, 1.1.18.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/encodings In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29460/Lib/encodings Modified Files: Tag: release23-maint koi8_u.py Log Message: - Bug #902501: fix unicode value of CYRILLIC CAPITAL LETTER UKRAINIAN IE in KOI8-U to unicode convertion table. Index: koi8_u.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/koi8_u.py,v retrieving revision 1.1 retrieving revision 1.1.18.1 diff -u -d -r1.1 -r1.1.18.1 --- koi8_u.py 17 Oct 2002 22:15:33 -0000 1.1 +++ koi8_u.py 24 Aug 2004 21:37:47 -0000 1.1.18.1 @@ -43,7 +43,7 @@ 0x00a6: 0x0456, # CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I 0x00a7: 0x0457, # CYRILLIC SMALL LETTER YI (UKRAINIAN) 0x00ad: 0x0491, # CYRILLIC SMALL LETTER UKRAINIAN GHE WITH UPTURN - 0x00b4: 0x0403, # CYRILLIC CAPITAL LETTER UKRAINIAN IE + 0x00b4: 0x0404, # CYRILLIC CAPITAL LETTER UKRAINIAN IE 0x00b6: 0x0406, # CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I 0x00b7: 0x0407, # CYRILLIC CAPITAL LETTER YI (UKRAINIAN) 0x00bd: 0x0490, # CYRILLIC CAPITAL LETTER UKRAINIAN GHE WITH UPTURN From doko at users.sourceforge.net Tue Aug 24 23:37:53 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Tue Aug 24 23:37:57 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.145, 1.831.4.146 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29460/Misc Modified Files: Tag: release23-maint NEWS Log Message: - Bug #902501: fix unicode value of CYRILLIC CAPITAL LETTER UKRAINIAN IE in KOI8-U to unicode convertion table. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.145 retrieving revision 1.831.4.146 diff -u -d -r1.831.4.145 -r1.831.4.146 --- NEWS 22 Aug 2004 21:30:04 -0000 1.831.4.145 +++ NEWS 24 Aug 2004 21:37:49 -0000 1.831.4.146 @@ -104,6 +104,9 @@ addition to CVS and RCS directories. .svn directories hold administrative files for the Subversion source control system. +- Bug #902501: fix unicode value of CYRILLIC CAPITAL LETTER UKRAINIAN IE + in KOI8-U to unicode convertion table. + Tools/Demos ----------- From doko at users.sourceforge.net Tue Aug 24 23:48:17 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Tue Aug 24 23:48:22 2004 Subject: [Python-checkins] python/dist/src/Modules _ssl.c,1.13.6.3,1.13.6.4 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31884/Modules Modified Files: Tag: release23-maint _ssl.c Log Message: [Patch #945642] Fix non-blocking SSL sockets, which blocked on reads/writes in Python 2.3. Taken from HEAD, tested as part of the unstable and testing Debian packages since May on various architectures. Index: _ssl.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_ssl.c,v retrieving revision 1.13.6.3 retrieving revision 1.13.6.4 diff -u -d -r1.13.6.3 -r1.13.6.4 --- _ssl.c 12 Jul 2004 13:10:47 -0000 1.13.6.3 +++ _ssl.c 24 Aug 2004 21:48:15 -0000 1.13.6.4 @@ -64,10 +64,18 @@ static PyTypeObject PySSL_Type; static PyObject *PySSL_SSLwrite(PySSLObject *self, PyObject *args); static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args); -static int wait_for_timeout(PySocketSockObject *s, int writing); +static int check_socket_and_wait_for_timeout(PySocketSockObject *s, int writing); #define PySSLObject_Check(v) ((v)->ob_type == &PySSL_Type) +typedef enum { + SOCKET_IS_NONBLOCKING, + SOCKET_IS_BLOCKING, + SOCKET_HAS_TIMED_OUT, + SOCKET_HAS_BEEN_CLOSED, + SOCKET_OPERATION_OK +} timeout_state; + /* XXX It might be helpful to augment the error message generated below with the name of the SSL function that generated the error. I expect it's obvious most of the time. @@ -170,7 +178,7 @@ char *errstr = NULL; int ret; int err; - int timedout; + int sockstate; self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new object */ if (self == NULL){ @@ -240,7 +248,7 @@ /* Actually negotiate SSL connection */ /* XXX If SSL_connect() returns 0, it's also a failure. */ - timedout = 0; + sockstate = 0; do { Py_BEGIN_ALLOW_THREADS ret = SSL_connect(self->ssl); @@ -250,13 +258,19 @@ goto fail; } if (err == SSL_ERROR_WANT_READ) { - timedout = wait_for_timeout(Sock, 0); + sockstate = check_socket_and_wait_for_timeout(Sock, 0); } else if (err == SSL_ERROR_WANT_WRITE) { - timedout = wait_for_timeout(Sock, 1); - } - if (timedout) { - errstr = "The connect operation timed out"; + sockstate = check_socket_and_wait_for_timeout(Sock, 1); + } else + sockstate = SOCKET_OPERATION_OK; + if (sockstate == SOCKET_HAS_TIMED_OUT) { + PyErr_SetString(PySSLErrorObject, "The connect operation timed out"); + goto fail; + } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) { + PyErr_SetString(PySSLErrorObject, "Underlying socket has been closed."); goto fail; + } else if (sockstate == SOCKET_IS_NONBLOCKING) { + break; } } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); if (ret <= 0) { @@ -335,22 +349,25 @@ /* If the socket has a timeout, do a select() on the socket. The argument writing indicates the direction. - Return non-zero if the socket timed out, zero otherwise. + Returns one of the possibilities in the timeout_state enum (above). */ + static int -wait_for_timeout(PySocketSockObject *s, int writing) +check_socket_and_wait_for_timeout(PySocketSockObject *s, int writing) { fd_set fds; struct timeval tv; int rc; /* Nothing to do unless we're in timeout mode (not non-blocking) */ - if (s->sock_timeout <= 0.0) - return 0; + if (s->sock_timeout < 0.0) + return SOCKET_IS_BLOCKING; + else if (s->sock_timeout == 0.0) + return SOCKET_IS_NONBLOCKING; /* Guard against closed socket */ if (s->sock_fd < 0) - return 0; + return SOCKET_HAS_BEEN_CLOSED; /* Construct the arguments to select */ tv.tv_sec = (int)s->sock_timeout; @@ -366,8 +383,9 @@ rc = select(s->sock_fd+1, &fds, NULL, NULL, &tv); Py_END_ALLOW_THREADS - /* Return 1 on timeout, 0 otherwise */ - return rc == 0; + /* Return SOCKET_TIMED_OUT on timeout, SOCKET_OPERATION_OK otherwise + (when we are able to write or when there's something to read) */ + return rc == 0 ? SOCKET_HAS_TIMED_OUT : SOCKET_OPERATION_OK; } static PyObject *PySSL_SSLwrite(PySSLObject *self, PyObject *args) @@ -375,16 +393,19 @@ char *data; int len; int count; - int timedout; + int sockstate; int err; if (!PyArg_ParseTuple(args, "s#:write", &data, &count)) return NULL; - timedout = wait_for_timeout(self->Socket, 1); - if (timedout) { + sockstate = check_socket_and_wait_for_timeout(self->Socket, 1); + if (sockstate == SOCKET_HAS_TIMED_OUT) { PyErr_SetString(PySSLErrorObject, "The write operation timed out"); return NULL; + } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) { + PyErr_SetString(PySSLErrorObject, "Underlying socket has been closed."); + return NULL; } do { err = 0; @@ -396,13 +417,19 @@ return NULL; } if (err == SSL_ERROR_WANT_READ) { - timedout = wait_for_timeout(self->Socket, 0); + sockstate = check_socket_and_wait_for_timeout(self->Socket, 0); } else if (err == SSL_ERROR_WANT_WRITE) { - timedout = wait_for_timeout(self->Socket, 1); - } - if (timedout) { + sockstate = check_socket_and_wait_for_timeout(self->Socket, 1); + } else + sockstate = SOCKET_OPERATION_OK; + if (sockstate == SOCKET_HAS_TIMED_OUT) { PyErr_SetString(PySSLErrorObject, "The write operation timed out"); return NULL; + } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) { + PyErr_SetString(PySSLErrorObject, "Underlying socket has been closed."); + return NULL; + } else if (sockstate == SOCKET_IS_NONBLOCKING) { + break; } } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); if (len > 0) @@ -422,7 +449,7 @@ PyObject *buf; int count = 0; int len = 1024; - int timedout; + int sockstate; int err; if (!PyArg_ParseTuple(args, "|i:read", &len)) @@ -431,8 +458,8 @@ if (!(buf = PyString_FromStringAndSize((char *) 0, len))) return NULL; - timedout = wait_for_timeout(self->Socket, 0); - if (timedout) { + sockstate = check_socket_and_wait_for_timeout(self->Socket, 0); + if (sockstate == SOCKET_HAS_TIMED_OUT) { PyErr_SetString(PySSLErrorObject, "The read operation timed out"); Py_DECREF(buf); return NULL; @@ -448,14 +475,17 @@ return NULL; } if (err == SSL_ERROR_WANT_READ) { - timedout = wait_for_timeout(self->Socket, 0); + sockstate = check_socket_and_wait_for_timeout(self->Socket, 0); } else if (err == SSL_ERROR_WANT_WRITE) { - timedout = wait_for_timeout(self->Socket, 1); - } - if (timedout) { + sockstate = check_socket_and_wait_for_timeout(self->Socket, 1); + } else + sockstate = SOCKET_OPERATION_OK; + if (sockstate == SOCKET_HAS_TIMED_OUT) { PyErr_SetString(PySSLErrorObject, "The read operation timed out"); Py_DECREF(buf); return NULL; + } else if (sockstate == SOCKET_IS_NONBLOCKING) { + break; } } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); if (count <= 0) { From doko at users.sourceforge.net Tue Aug 24 23:48:18 2004 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Tue Aug 24 23:48:23 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.146, 1.831.4.147 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31884/Misc Modified Files: Tag: release23-maint NEWS Log Message: [Patch #945642] Fix non-blocking SSL sockets, which blocked on reads/writes in Python 2.3. Taken from HEAD, tested as part of the unstable and testing Debian packages since May on various architectures. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.146 retrieving revision 1.831.4.147 diff -u -d -r1.831.4.146 -r1.831.4.147 --- NEWS 24 Aug 2004 21:37:49 -0000 1.831.4.146 +++ NEWS 24 Aug 2004 21:48:15 -0000 1.831.4.147 @@ -46,6 +46,8 @@ - Patch #909007: Enable a bunch of safe bug workarounds in OpenSSL, for the sake of compatibility with various broken SSL implementations. +- Patch #945642: Fix non-blocking SSL sockets, which blocked on reads/writes. + Library ------- From mhammond at users.sourceforge.net Wed Aug 25 00:24:17 2004 From: mhammond at users.sourceforge.net (mhammond@users.sourceforge.net) Date: Wed Aug 25 00:24:20 2004 Subject: [Python-checkins] python/dist/src/Modules threadmodule.c,2.58,2.59 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9226/Modules Modified Files: threadmodule.c Log Message: Fix for [ 1010677 ] thread Module Breaks PyGILState_Ensure(), and a test case. When booting a new thread, use the PyGILState API to manage the GIL. Index: threadmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/threadmodule.c,v retrieving revision 2.58 retrieving revision 2.59 diff -u -d -r2.58 -r2.59 --- threadmodule.c 14 Jul 2004 19:07:15 -0000 2.58 +++ threadmodule.c 24 Aug 2004 22:24:08 -0000 2.59 @@ -425,11 +425,10 @@ t_bootstrap(void *boot_raw) { struct bootstate *boot = (struct bootstate *) boot_raw; - PyThreadState *tstate; + PyGILState_STATE gstate; PyObject *res; - tstate = PyThreadState_New(boot->interp); - PyEval_AcquireThread(tstate); + gstate = PyGILState_Ensure(); res = PyEval_CallObjectWithKeywords( boot->func, boot->args, boot->keyw); if (res == NULL) { @@ -454,8 +453,7 @@ Py_DECREF(boot->args); Py_XDECREF(boot->keyw); PyMem_DEL(boot_raw); - PyThreadState_Clear(tstate); - PyThreadState_DeleteCurrent(); + PyGILState_Release(gstate); PyThread_exit_thread(); } From mhammond at users.sourceforge.net Wed Aug 25 00:24:18 2004 From: mhammond at users.sourceforge.net (mhammond@users.sourceforge.net) Date: Wed Aug 25 00:24:22 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_capi.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9226/Lib/test Modified Files: test_capi.py Log Message: Fix for [ 1010677 ] thread Module Breaks PyGILState_Ensure(), and a test case. When booting a new thread, use the PyGILState API to manage the GIL. Index: test_capi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_capi.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- test_capi.py 24 Apr 2003 16:02:51 -0000 1.6 +++ test_capi.py 24 Aug 2004 22:24:08 -0000 1.7 @@ -43,3 +43,7 @@ if have_thread_state: TestThreadState() + import threading + t=threading.Thread(target=TestThreadState) + t.start() + From nnorwitz at users.sourceforge.net Wed Aug 25 03:20:21 2004 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed Aug 25 03:20:24 2004 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.76,2.77 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13194/Modules Modified Files: readline.c Log Message: SF #1015517, get readline to compile with older compilers Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.76 retrieving revision 2.77 diff -u -d -r2.76 -r2.77 --- readline.c 20 Aug 2004 06:26:59 -0000 2.76 +++ readline.c 25 Aug 2004 01:20:18 -0000 2.77 @@ -823,15 +823,16 @@ static char * call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) { + size_t n; + char *p, *q; + int signal; + #ifdef SAVE_LOCALE char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); if (!saved_locale) Py_FatalError("not enough memory to save locale"); setlocale(LC_CTYPE, ""); #endif - size_t n; - char *p, *q; - int signal; rl_event_hook = PyOS_InputHook; From tim_one at users.sourceforge.net Wed Aug 25 03:58:05 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 25 03:58:08 2004 Subject: [Python-checkins] python/nondist/peps pep-0237.txt,1.17,1.18 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20235/peps Modified Files: pep-0237.txt Log Message: Note that Python stopped generating OverflowWarning in 2.4, a release after that was planned to occur. Index: pep-0237.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0237.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- pep-0237.txt 2 Dec 2003 01:22:50 -0000 1.17 +++ pep-0237.txt 25 Aug 2004 01:57:46 -0000 1.18 @@ -236,7 +236,13 @@ Here are the rules that guide warnings generated in situations that currently raise OverflowError. This applies to transition - phase A. + phase A. Historical note: despite that phase A was completed in + Python 2.2, and phase B0 in Python 2.3, nobody noticed that + OverflowWarning was still generated in Python 2.3. It was finally + disabled in Python 2.4. The Python builtin OverflowWarning, and + the corresponding C API PyExc_OverflowWarning, are no longer + generated or used in Python 2.4, but will remain for the (unlikely) + case of user code until Python 2.5. - A new warning category is introduced, OverflowWarning. This is a built-in name. From bwarsaw at users.sourceforge.net Wed Aug 25 04:02:11 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Wed Aug 25 04:02:15 2004 Subject: [Python-checkins] python/nondist/peps pep-0292.txt,1.12,1.13 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20928 Modified Files: pep-0292.txt Log Message: The open issues are resolved. Index: pep-0292.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0292.txt,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- pep-0292.txt 23 Aug 2004 03:31:45 -0000 1.12 +++ pep-0292.txt 25 Aug 2004 02:02:08 -0000 1.13 @@ -62,9 +62,10 @@ not part of the placeholder, e.g. "${noun}ification". If the $ character appears at the end of the line, or is followed - by any other character than those described above, it is treated - as if it had been escaped, appearing in the resulting string - unchanged. NOTE: see open issues below. + by any other character than those described above, a ValueError + will be raised at interpolation time. Values in the mapping will + be converted to Unicode strings by calling the built-in unicode() + function, using its default arguments. No other characters have special meaning, however it is possible to derive from the Template class to define different rules for @@ -167,57 +168,6 @@ proposal, include unit tests and documentation changes. -Open Issues - - - Should the Template and SafeTemplate classes convert mapping - values to strings (or unicodes)? I.e. what should this code do: - - >>> from string import Template - >>> Template('The cost was $amount euros') % {'amount': 7} - - Should this raise an exception such as TypeError, or should this - return the string 'The cose was 7 euros'? - - Proposed resolution: no automatic stringification. - - - The pattern for placeholders in the Template and SafeTemplate - classes matches Python identifiers. Some people want to match - Python attribute paths, e.g. "$os.path.sep". This can be useful - in some applications, however note that it is up to the - interpolation mapping to provide namespace lookup for the - attribute paths. - - Should we include AttributeTemplate and SafeAttributeTemplate in - the standard library? What about more complex patterns such as - Python expressions? - - Proposed resolution: No, we don't include them for now. Such - classes are easily derived, and besides, we're not proposing to - include any interpolation mappings, and without such a - specialized mapping, a pattern matching attribute paths or - expressions aren't useful. - - - Where does the Template and SafeTemplate classes live? Some - people have suggested creating a stringtools or stringlib module - to house these two classes. The PEP author has proposed a - re-organization of the existing string module, turning it into a - string package. - - Proposed resolution: There seems little consensus around either - suggestion, and since the classes are just a few lines of - Python, I propose no string module re-organization, but to add - these two classes to string.py. - - - Should the $-placeholder rules be more strict? Specifically, - objections have been raised about 'magically' escaping $'s at - the end of strings, or in strings like '$100'. The suggestion - was that we add another matching group which matches bare $'s, - raising a ValueError if we find such a match. - - Proposed resolution: There seems to be consensus for strictness - on the grounds of explicit is better than implicit. - - References [1] String Formatting Operations From tim_one at users.sourceforge.net Wed Aug 25 04:14:09 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 25 04:14:13 2004 Subject: [Python-checkins] python/dist/src/Lib warnings.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22424/Lib Modified Files: warnings.py Log Message: Stop producing or using OverflowWarning. PEP 237 thought this would happen in 2.3, but nobody noticed it still was getting generated (the warning was disabled by default). OverflowWarning and PyExc_OverflowWarning should be removed for 2.5, and left notes all over saying so. Index: warnings.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/warnings.py,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- warnings.py 21 Mar 2004 17:06:20 -0000 1.23 +++ warnings.py 25 Aug 2004 02:14:06 -0000 1.24 @@ -250,5 +250,6 @@ # Module initialization _processoptions(sys.warnoptions) +# XXX OverflowWarning should go away for Python 2.5. simplefilter("ignore", category=OverflowWarning, append=1) simplefilter("ignore", category=PendingDeprecationWarning, append=1) From tim_one at users.sourceforge.net Wed Aug 25 04:14:10 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 25 04:14:15 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1108,1.1109 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22424/Misc Modified Files: NEWS Log Message: Stop producing or using OverflowWarning. PEP 237 thought this would happen in 2.3, but nobody noticed it still was getting generated (the warning was disabled by default). OverflowWarning and PyExc_OverflowWarning should be removed for 2.5, and left notes all over saying so. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1108 retrieving revision 1.1109 diff -u -d -r1.1108 -r1.1109 --- NEWS 21 Aug 2004 15:13:51 -0000 1.1108 +++ NEWS 25 Aug 2004 02:14:07 -0000 1.1109 @@ -12,6 +12,12 @@ Core and builtins ----------------- +- OverflowWarning is no longer generated. PEP 237 scheduled this to + occur in Python 2.3, but since OverflowWarning was disabled by default, + nobody realized it was still being generated. On the chance that user + code is still using them, the Python builtin OverflowWarning, and + corresponding C API PyExc_OverflowWarning, will exist until Python 2.5. + - Py_InitializeEx has been added. - Fix the order of application of decorators. The proper order is bottom-up; From tim_one at users.sourceforge.net Wed Aug 25 04:14:12 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 25 04:14:19 2004 Subject: [Python-checkins] python/dist/src/Objects intobject.c,2.112,2.113 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22424/Objects Modified Files: intobject.c Log Message: Stop producing or using OverflowWarning. PEP 237 thought this would happen in 2.3, but nobody noticed it still was getting generated (the warning was disabled by default). OverflowWarning and PyExc_OverflowWarning should be removed for 2.5, and left notes all over saying so. Index: intobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v retrieving revision 2.112 retrieving revision 2.113 diff -u -d -r2.112 -r2.113 --- intobject.c 19 Jul 2004 16:29:16 -0000 2.112 +++ intobject.c 25 Aug 2004 02:14:08 -0000 2.113 @@ -10,19 +10,6 @@ return LONG_MAX; /* To initialize sys.maxint */ } -/* Return 1 if exception raised, 0 if caller should retry using longs */ -static int -err_ovf(char *msg) -{ - if (PyErr_Warn(PyExc_OverflowWarning, msg) < 0) { - if (PyErr_ExceptionMatches(PyExc_OverflowWarning)) - PyErr_SetString(PyExc_OverflowError, msg); - return 1; - } - else - return 0; -} - /* Integers are quite normal objects, to make object handling uniform. (Using odd pointers to represent integers would save much space but require extra checks for this special case throughout the code.) @@ -306,11 +293,8 @@ PyErr_SetString(PyExc_ValueError, buffer); return NULL; } - else if (errno != 0) { - if (err_ovf("string/unicode conversion")) - return NULL; + else if (errno != 0) return PyLong_FromString(s, pend, base); - } if (pend) *pend = end; return PyInt_FromLong(x); @@ -396,8 +380,6 @@ x = a + b; if ((x^a) >= 0 || (x^b) >= 0) return PyInt_FromLong(x); - if (err_ovf("integer addition")) - return NULL; return PyLong_Type.tp_as_number->nb_add((PyObject *)v, (PyObject *)w); } @@ -410,8 +392,6 @@ x = a - b; if ((x^a) >= 0 || (x^~b) >= 0) return PyInt_FromLong(x); - if (err_ovf("integer subtraction")) - return NULL; return PyLong_Type.tp_as_number->nb_subtract((PyObject *)v, (PyObject *)w); } @@ -475,8 +455,6 @@ 32 * absdiff <= absprod -- 5 good bits is "close enough" */ if (32.0 * absdiff <= absprod) return PyInt_FromLong(longprod); - else if (err_ovf("integer multiplication")) - return NULL; else return PyLong_Type.tp_as_number->nb_multiply(v, w); } @@ -501,11 +479,8 @@ return DIVMOD_ERROR; } /* (-sys.maxint-1)/-1 is the only overflow case. */ - if (y == -1 && x < 0 && x == -x) { - if (err_ovf("integer division")) - return DIVMOD_ERROR; + if (y == -1 && x < 0 && x == -x) return DIVMOD_OVERFLOW; - } xdivy = x / y; xmody = x - xdivy * y; /* If the signs of x and y differ, and the remainder is non-0, @@ -654,8 +629,6 @@ if (temp == 0) break; /* Avoid ix / 0 */ if (ix / temp != prev) { - if (err_ovf("integer exponentiation")) - return NULL; return PyLong_Type.tp_as_number->nb_power( (PyObject *)v, (PyObject *)w, @@ -666,9 +639,7 @@ if (iw==0) break; prev = temp; temp *= temp; /* Square the value of temp */ - if (prev!=0 && temp/prev!=prev) { - if (err_ovf("integer exponentiation")) - return NULL; + if (prev != 0 && temp / prev != prev) { return PyLong_Type.tp_as_number->nb_power( (PyObject *)v, (PyObject *)w, (PyObject *)z); } @@ -701,10 +672,7 @@ a = v->ob_ival; x = -a; if (a < 0 && x < 0) { - PyObject *o; - if (err_ovf("integer negation")) - return NULL; - o = PyLong_FromLong(a); + PyObject *o = PyLong_FromLong(a); if (o != NULL) { PyObject *result = PyNumber_Negative(o); Py_DECREF(o); From tim_one at users.sourceforge.net Wed Aug 25 04:14:11 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 25 04:14:21 2004 Subject: [Python-checkins] python/dist/src/Python exceptions.c,1.48,1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22424/Python Modified Files: exceptions.c Log Message: Stop producing or using OverflowWarning. PEP 237 thought this would happen in 2.3, but nobody noticed it still was getting generated (the warning was disabled by default). OverflowWarning and PyExc_OverflowWarning should be removed for 2.5, and left notes all over saying so. Index: exceptions.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- exceptions.c 12 Oct 2003 19:09:37 -0000 1.48 +++ exceptions.c 25 Aug 2004 02:14:08 -0000 1.49 @@ -1560,7 +1560,7 @@ "Base class for warnings about dubious syntax."); PyDoc_STRVAR(OverflowWarning__doc__, -"Base class for warnings about numeric overflow."); +"Base class for warnings about numeric overflow. Won't exist in Python 2.5."); PyDoc_STRVAR(RuntimeWarning__doc__, "Base class for warnings about dubious runtime behavior."); @@ -1635,6 +1635,7 @@ PyObject *PyExc_DeprecationWarning; PyObject *PyExc_PendingDeprecationWarning; PyObject *PyExc_SyntaxWarning; +/* PyExc_OverflowWarning should be removed for Python 2.5 */ PyObject *PyExc_OverflowWarning; PyObject *PyExc_RuntimeWarning; PyObject *PyExc_FutureWarning; @@ -1726,6 +1727,7 @@ {"PendingDeprecationWarning", &PyExc_PendingDeprecationWarning, &PyExc_Warning, PendingDeprecationWarning__doc__}, {"SyntaxWarning", &PyExc_SyntaxWarning, &PyExc_Warning, SyntaxWarning__doc__}, + /* OverflowWarning should be removed for Python 2.5 */ {"OverflowWarning", &PyExc_OverflowWarning, &PyExc_Warning, OverflowWarning__doc__}, {"RuntimeWarning", &PyExc_RuntimeWarning, &PyExc_Warning, From tim_one at users.sourceforge.net Wed Aug 25 04:14:10 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 25 04:14:22 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_exceptions.py, 1.19, 1.20 test_warnings.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22424/Lib/test Modified Files: test_exceptions.py test_warnings.py Log Message: Stop producing or using OverflowWarning. PEP 237 thought this would happen in 2.3, but nobody noticed it still was getting generated (the warning was disabled by default). OverflowWarning and PyExc_OverflowWarning should be removed for 2.5, and left notes all over saying so. Index: test_exceptions.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_exceptions.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- test_exceptions.py 10 May 2003 07:36:55 -0000 1.19 +++ test_exceptions.py 25 Aug 2004 02:14:06 -0000 1.20 @@ -85,15 +85,16 @@ r(OverflowError) # XXX -# Obscure: this test relies on int+int raising OverflowError if the -# ints are big enough. But ints no longer do that by default. This -# test will have to go away someday. For now, we can convert the -# transitional OverflowWarning into an error. +# Obscure: in 2.2 and 2.3, this test relied on changing OverflowWarning +# into an error, in order to trigger OverflowError. In 2.4, OverflowWarning +# should no longer be generated, so the focus of the test shifts to showing +# that OverflowError *isn't* generated. OverflowWarning should be gone +# in Python 2.5, and then the filterwarnings() call, and this comment, +# should go away. warnings.filterwarnings("error", "", OverflowWarning, __name__) x = 1 -try: - while 1: x = x+x -except OverflowError: pass +for dummy in range(128): + x += x # this simply shouldn't blow up r(RuntimeError) print '(not used any more?)' Index: test_warnings.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_warnings.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- test_warnings.py 13 Jul 2003 08:37:39 -0000 1.4 +++ test_warnings.py 25 Aug 2004 02:14:06 -0000 1.5 @@ -44,6 +44,7 @@ def test_warn_specific_category(self): text = 'None' + # XXX OverflowWarning should go away for Python 2.5. for category in [DeprecationWarning, FutureWarning, OverflowWarning, PendingDeprecationWarning, RuntimeWarning, SyntaxWarning, UserWarning, Warning]: From tim_one at users.sourceforge.net Wed Aug 25 04:14:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 25 04:14:41 2004 Subject: [Python-checkins] python/dist/src/Include pyerrors.h,2.65,2.66 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22424/Include Modified Files: pyerrors.h Log Message: Stop producing or using OverflowWarning. PEP 237 thought this would happen in 2.3, but nobody noticed it still was getting generated (the warning was disabled by default). OverflowWarning and PyExc_OverflowWarning should be removed for 2.5, and left notes all over saying so. Index: pyerrors.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pyerrors.h,v retrieving revision 2.65 retrieving revision 2.66 diff -u -d -r2.65 -r2.66 --- pyerrors.h 1 Jul 2003 20:15:21 -0000 2.65 +++ pyerrors.h 25 Aug 2004 02:14:06 -0000 2.66 @@ -74,6 +74,7 @@ PyAPI_DATA(PyObject *) PyExc_DeprecationWarning; PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning; PyAPI_DATA(PyObject *) PyExc_SyntaxWarning; +/* PyExc_OverflowWarning will go away for Python 2.5 */ PyAPI_DATA(PyObject *) PyExc_OverflowWarning; PyAPI_DATA(PyObject *) PyExc_RuntimeWarning; PyAPI_DATA(PyObject *) PyExc_FutureWarning; From tim_one at users.sourceforge.net Wed Aug 25 04:14:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Wed Aug 25 04:14:43 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libexcs.tex,1.53,1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22424/Doc/lib Modified Files: libexcs.tex Log Message: Stop producing or using OverflowWarning. PEP 237 thought this would happen in 2.3, but nobody noticed it still was getting generated (the warning was disabled by default). OverflowWarning and PyExc_OverflowWarning should be removed for 2.5, and left notes all over saying so. Index: libexcs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libexcs.tex,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- libexcs.tex 4 Aug 2003 08:33:50 -0000 1.53 +++ libexcs.tex 25 Aug 2004 02:14:06 -0000 1.54 @@ -460,7 +460,7 @@ +-- DeprecationWarning +-- PendingDeprecationWarning +-- SyntaxWarning - +-- OverflowWarning + +-- OverflowWarning (not generated in 2.4; won't exist in 2.5) +-- RuntimeWarning +-- FutureWarning \end{verbatim} From bwarsaw at users.sourceforge.net Wed Aug 25 04:22:32 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Wed Aug 25 04:22:34 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_pep292.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23842/Lib/test Added Files: test_pep292.py Log Message: PEP 292 classes Template and SafeTemplate are added to the string module. This patch includes test cases and documentation updates, as well as NEWS file updates. This patch also updates the sre modules so that they don't import the string module, breaking direct circular imports. --- NEW FILE: test_pep292.py --- # Copyright (C) 2004 Python Software Foundation # Author: barry@python.org (Barry Warsaw) # License: http://www.opensource.org/licenses/PythonSoftFoundation.php import unittest from string import Template, SafeTemplate class TestTemplate(unittest.TestCase): def test_regular_templates(self): s = Template('$who likes to eat a bag of $what worth $$100') self.assertEqual(s % dict(who='tim', what='ham'), 'tim likes to eat a bag of ham worth $100') self.assertRaises(KeyError, lambda s, d: s % d, s, dict(who='tim')) def test_regular_templates_with_braces(self): s = Template('$who likes ${what} for ${meal}') self.assertEqual(s % dict(who='tim', what='ham', meal='dinner'), 'tim likes ham for dinner') self.assertRaises(KeyError, lambda s, d: s % d, s, dict(who='tim', what='ham')) def test_escapes(self): eq = self.assertEqual s = Template('$who likes to eat a bag of $$what worth $$100') eq(s % dict(who='tim', what='ham'), 'tim likes to eat a bag of $what worth $100') s = Template('$who likes $$') eq(s % dict(who='tim', what='ham'), 'tim likes $') def test_percents(self): s = Template('%(foo)s $foo ${foo}') self.assertEqual(s % dict(foo='baz'), '%(foo)s baz baz') s = SafeTemplate('%(foo)s $foo ${foo}') self.assertEqual(s % dict(foo='baz'), '%(foo)s baz baz') def test_stringification(self): s = Template('tim has eaten $count bags of ham today') self.assertEqual(s % dict(count=7), 'tim has eaten 7 bags of ham today') s = SafeTemplate('tim has eaten $count bags of ham today') self.assertEqual(s % dict(count=7), 'tim has eaten 7 bags of ham today') s = SafeTemplate('tim has eaten ${count} bags of ham today') self.assertEqual(s % dict(count=7), 'tim has eaten 7 bags of ham today') def test_SafeTemplate(self): eq = self.assertEqual s = SafeTemplate('$who likes ${what} for ${meal}') eq(s % dict(who='tim'), 'tim likes ${what} for ${meal}') eq(s % dict(what='ham'), '$who likes ham for ${meal}') eq(s % dict(what='ham', meal='dinner'), '$who likes ham for dinner') eq(s % dict(who='tim', what='ham'), 'tim likes ham for ${meal}') eq(s % dict(who='tim', what='ham', meal='dinner'), 'tim likes ham for dinner') def test_invalid_placeholders(self): raises = self.assertRaises s = Template('$who likes $') raises(ValueError, lambda s, d: s % d, s, dict(who='tim')) s = Template('$who likes ${what)') raises(ValueError, lambda s, d: s % d, s, dict(who='tim')) s = Template('$who likes $100') raises(ValueError, lambda s, d: s % d, s, dict(who='tim')) def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestTemplate)) return suite def test_main(): from test import test_support test_support.run_suite(suite()) if __name__ == '__main__': unittest.main() From bwarsaw at users.sourceforge.net Wed Aug 25 04:22:32 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Wed Aug 25 04:22:38 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libstring.tex,1.58,1.59 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23842/Doc/lib Modified Files: libstring.tex Log Message: PEP 292 classes Template and SafeTemplate are added to the string module. This patch includes test cases and documentation updates, as well as NEWS file updates. This patch also updates the sre modules so that they don't import the string module, breaking direct circular imports. Index: libstring.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- libstring.tex 19 Jul 2004 16:34:01 -0000 1.58 +++ libstring.tex 25 Aug 2004 02:22:29 -0000 1.59 @@ -4,11 +4,23 @@ \declaremodule{standard}{string} \modulesynopsis{Common string operations.} +The \module{string} package contains a number of useful constants and classes, +as well as some deprecated legacy functions that are also available as methods +on strings. See the module \refmodule{re}\refstmodindex{re} for string +functions based on regular expressions. -This module defines some constants useful for checking character -classes and some useful string functions. See the module -\refmodule{re}\refstmodindex{re} for string functions based on regular -expressions. +In general, all of these objects are exposed directly in the \module{string} +package so users need only import the \module{string} package to begin using +these constants, classes, and functions. + +\begin{notice} +Starting with Python 2.4, the traditional \module{string} module was turned +into a package, however backward compatibility with existing code has been +retained. Code using the \module{string} module that worked prior to Python +2.4 should continue to work unchanged. +\end{notice} + +\subsection{String constants} The constants defined in this module are: @@ -86,11 +98,113 @@ is undefined. \end{datadesc} +\subsection{Template strings} -Many of the functions provided by this module are also defined as -methods of string and Unicode objects; see ``String Methods'' (section -\ref{string-methods}) for more information on those. -The functions defined in this module are: +Templates are Unicode strings that can be used to provide string substitutions +as described in \pep{292}. There is a \class{Template} class that is a +subclass of \class{unicode}, overriding the default \method{__mod__()} method. +Instead of the normal \samp{\%}-based substitutions, Template strings support +\samp{\$}-based substitutions, using the following rules: + +\begin{itemize} +\item \samp{\$\$} is an escape; it is replaced with a single \samp{\$}. + +\item \samp{\$identifier} names a substitution placeholder matching a mapping + key of "identifier". By default, "identifier" must spell a Python + identifier. The first non-identifier character after the \samp{\$} + character terminates this placeholder specification. + +\item \samp{\$\{identifier\}} is equivalent to \samp{\$identifier}. It is + required when valid identifier characters follow the placeholder but are + not part of the placeholder, e.g. "\$\{noun\}ification". +\end{itemize} + +Any other appearance of \samp{\$} in the string will result in a +\exception{ValueError} being raised. + +Template strings are used just like normal strings, in that the modulus +operator is used to interpolate a dictionary of values into a Template string, +e.g.: + +\begin{verbatim} +>>> from string import Template +>>> s = Template('$who likes $what') +>>> print s % dict(who='tim', what='kung pao') +tim likes kung pao +>>> Template('Give $who $100') % dict(who='tim') +Traceback (most recent call last): +[...] +ValueError: Invalid placeholder at index 10 +\end{verbatim} + +There is also a \class{SafeTemplate} class, derived from \class{Template} +which acts the same as \class{Template}, except that if placeholders are +missing in the interpolation dictionary, no \exception{KeyError} will be +raised. Instead the original placeholder (with or without the braces, as +appropriate) will be used: + +\begin{verbatim} +>>> from string import SafeTemplate +>>> s = SafeTemplate('$who likes $what for ${meal}') +>>> print s % dict(who='tim') +tim likes $what for ${meal} +\end{verbatim} + +The values in the mapping will automatically be converted to Unicode strings, +using the built-in \function{unicode()} function, which will be called without +optional arguments \var{encoding} or \var{errors}. + +Advanced usage: you can derive subclasses of \class{Template} or +\class{SafeTemplate} to use application-specific placeholder rules. To do +this, you override the class attribute \member{pattern}; the value must be a +compiled regular expression object with four named capturing groups. The +capturing groups correspond to the rules given above, along with the invalid +placeholder rule: + +\begin{itemize} +\item \var{escaped} -- This group matches the escape sequence, i.e. \samp{\$\$} + in the default pattern. +\item \var{named} -- This group matches the unbraced placeholder name; it + should not include the \samp{\$} in capturing group. +\item \var{braced} -- This group matches the brace delimited placeholder name; + it should not include either the \samp{\$} or braces in the capturing + group. +\item \var{bogus} -- This group matches any other \samp{\$}. It usually just + matches a single \samp{\$} and should appear last. +\end{itemize} + +\subsection{String functions} + +The following functions are available to operate on string and Unicode +objects. They are not available as string methods. + +\begin{funcdesc}{capwords}{s} + Split the argument into words using \function{split()}, capitalize + each word using \function{capitalize()}, and join the capitalized + words using \function{join()}. Note that this replaces runs of + whitespace characters by a single space, and removes leading and + trailing whitespace. +\end{funcdesc} + +\begin{funcdesc}{maketrans}{from, to} + Return a translation table suitable for passing to + \function{translate()} or \function{regex.compile()}, that will map + each character in \var{from} into the character at the same position + in \var{to}; \var{from} and \var{to} must have the same length. + + \warning{Don't use strings derived from \constant{lowercase} + and \constant{uppercase} as arguments; in some locales, these don't have + the same length. For case conversions, always use + \function{lower()} and \function{upper()}.} +\end{funcdesc} + +\subsection{Deprecated string functions} + +The following list of functions are also defined as methods of string and +Unicode objects; see ``String Methods'' (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.0. The functions defined in this module are: \begin{funcdesc}{atof}{s} \deprecated{2.0}{Use the \function{float()} built-in function.} @@ -138,14 +252,6 @@ Return a copy of \var{word} with only its first character capitalized. \end{funcdesc} -\begin{funcdesc}{capwords}{s} - Split the argument into words using \function{split()}, capitalize - each word using \function{capitalize()}, and join the capitalized - words using \function{join()}. Note that this replaces runs of - whitespace characters by a single space, and removes leading and - trailing whitespace. -\end{funcdesc} - \begin{funcdesc}{expandtabs}{s\optional{, tabsize}} Expand tabs in a string, i.e.\ replace them by one or more spaces, depending on the current column and the given tab size. The column @@ -188,18 +294,6 @@ lower case. \end{funcdesc} -\begin{funcdesc}{maketrans}{from, to} - Return a translation table suitable for passing to - \function{translate()} or \function{regex.compile()}, that will map - each character in \var{from} into the character at the same position - in \var{to}; \var{from} and \var{to} must have the same length. - - \warning{Don't use strings derived from \constant{lowercase} - and \constant{uppercase} as arguments; in some locales, these don't have - the same length. For case conversions, always use - \function{lower()} and \function{upper()}.} -\end{funcdesc} - \begin{funcdesc}{split}{s\optional{, sep\optional{, maxsplit}}} Return a list of the words of the string \var{s}. If the optional second argument \var{sep} is absent or \code{None}, the words are From bwarsaw at users.sourceforge.net Wed Aug 25 04:22:33 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Wed Aug 25 04:22:39 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1109,1.1110 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23842/Misc Modified Files: NEWS Log Message: PEP 292 classes Template and SafeTemplate are added to the string module. This patch includes test cases and documentation updates, as well as NEWS file updates. This patch also updates the sre modules so that they don't import the string module, breaking direct circular imports. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1109 retrieving revision 1.1110 diff -u -d -r1.1109 -r1.1110 --- NEWS 25 Aug 2004 02:14:07 -0000 1.1109 +++ NEWS 25 Aug 2004 02:22:30 -0000 1.1110 @@ -57,6 +57,8 @@ Library ------- +- PEP 292 classes Template and SafeTemplate are added to the string module. + - tarfile now generates GNU tar files by default. - HTTPResponse has now a getheaders method. From bwarsaw at users.sourceforge.net Wed Aug 25 04:22:32 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Wed Aug 25 04:22:41 2004 Subject: [Python-checkins] python/dist/src/Lib sre.py, 1.49, 1.50 sre_constants.py, 1.34, 1.35 sre_parse.py, 1.60, 1.61 string.py, 1.71, 1.72 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23842/Lib Modified Files: sre.py sre_constants.py sre_parse.py string.py Log Message: PEP 292 classes Template and SafeTemplate are added to the string module. This patch includes test cases and documentation updates, as well as NEWS file updates. This patch also updates the sre modules so that they don't import the string module, breaking direct circular imports. Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- sre.py 7 Aug 2004 17:41:54 -0000 1.49 +++ sre.py 25 Aug 2004 02:22:29 -0000 1.50 @@ -105,9 +105,6 @@ __version__ = "2.2.1" -# this module works under 1.5.2 and later. don't use string methods -import string - # flags I = IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE # ignore case L = LOCALE = sre_compile.SRE_FLAG_LOCALE # assume current 8-bit locale @@ -201,7 +198,7 @@ s[i] = "\\000" else: s[i] = "\\" + c - return _join(s, pattern) + return pattern[:0].join(s) # -------------------------------------------------------------------- # internals @@ -213,10 +210,6 @@ _MAXCACHE = 100 -def _join(seq, sep): - # internal: join into string having the same type as sep - return string.join(seq, sep[:0]) - def _compile(*key): # internal: compile pattern cachekey = (type(key[0]),) + key Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- sre_constants.py 17 Oct 2003 22:13:16 -0000 1.34 +++ sre_constants.py 25 Aug 2004 02:22:29 -0000 1.35 @@ -217,12 +217,11 @@ SRE_INFO_CHARSET = 4 # pattern starts with character from given set if __name__ == "__main__": - import string def dump(f, d, prefix): items = d.items() items.sort(key=lambda a: a[1]) for k, v in items: - f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) + f.write("#define %s_%s %s\n" % (prefix, k.upper(), v)) f = open("sre_constants.h", "w") f.write("""\ /* Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- sre_parse.py 26 Mar 2004 23:24:00 -0000 1.60 +++ sre_parse.py 25 Aug 2004 02:22:29 -0000 1.61 @@ -12,8 +12,7 @@ # XXX: show string offset and offending character for all errors -# this module works under 1.5.2 and later. don't use string methods -import string, sys +import sys from sre_constants import * @@ -63,13 +62,6 @@ "u": SRE_FLAG_UNICODE, } -# figure out best way to convert hex/octal numbers to integers -try: - int("10", 8) - atoi = int # 2.0 and later -except TypeError: - atoi = string.atoi # 1.5.2 - class Pattern: # master pattern object. keeps track of global attributes def __init__(self): @@ -233,7 +225,7 @@ def _group(escape, groups): # check if the escape string represents a valid group try: - gid = atoi(escape[1:]) + gid = int(escape[1:]) if gid and gid < groups: return gid except ValueError: @@ -256,13 +248,13 @@ escape = escape[2:] if len(escape) != 2: raise error, "bogus escape: %s" % repr("\\" + escape) - return LITERAL, atoi(escape, 16) & 0xff + return LITERAL, int(escape, 16) & 0xff elif escape[1:2] in OCTDIGITS: # octal escape (up to three digits) while source.next in OCTDIGITS and len(escape) < 5: escape = escape + source.get() escape = escape[1:] - return LITERAL, atoi(escape, 8) & 0xff + return LITERAL, int(escape, 8) & 0xff if len(escape) == 2: return LITERAL, ord(escape[1]) except ValueError: @@ -284,12 +276,12 @@ escape = escape + source.get() if len(escape) != 4: raise ValueError - return LITERAL, atoi(escape[2:], 16) & 0xff + return LITERAL, int(escape[2:], 16) & 0xff elif escape[1:2] == "0": # octal escape while source.next in OCTDIGITS and len(escape) < 4: escape = escape + source.get() - return LITERAL, atoi(escape[1:], 8) & 0xff + return LITERAL, int(escape[1:], 8) & 0xff elif escape[1:2] in DIGITS: # octal escape *or* decimal group reference (sigh) if source.next in DIGITS: @@ -298,7 +290,7 @@ source.next in OCTDIGITS): # got three octal digits; this is an octal escape escape = escape + source.get() - return LITERAL, atoi(escape[1:], 8) & 0xff + return LITERAL, int(escape[1:], 8) & 0xff # got at least one decimal digit; this is a group reference group = _group(escape, state.groups) if group: @@ -503,9 +495,9 @@ source.seek(here) continue if lo: - min = atoi(lo) + min = int(lo) if hi: - max = atoi(hi) + max = int(hi) if max < min: raise error, "bad repeat interval" else: @@ -617,7 +609,7 @@ raise error, "unknown group name" else: try: - condgroup = atoi(condname) + condgroup = int(condname) except ValueError: raise error, "bad character in group name" else: @@ -730,7 +722,7 @@ if not name: raise error, "bad group name" try: - index = atoi(name) + index = int(name) except ValueError: if not isname(name): raise error, "bad character in group name" @@ -754,7 +746,7 @@ break if not code: this = this[1:] - code = LITERAL, makechar(atoi(this[-6:], 8) & 0xff) + code = LITERAL, makechar(int(this[-6:], 8) & 0xff) if code[0] is LITERAL: literal(code[1]) else: @@ -793,4 +785,4 @@ raise IndexError except IndexError: raise error, "empty group" - return string.join(literals, sep) + return sep.join(literals) Index: string.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/string.py,v retrieving revision 1.71 retrieving revision 1.72 diff -u -d -r1.71 -r1.72 --- string.py 15 Dec 2003 18:49:19 -0000 1.71 +++ string.py 25 Aug 2004 02:22:29 -0000 1.72 @@ -35,10 +35,116 @@ # Case conversion helpers # Use str to convert Unicode literal in case of -U +# Note that Cookie.py bogusly uses _idmap :( l = map(chr, xrange(256)) _idmap = str('').join(l) del l +# Functions which aren't available as string methods. + +# Capitalize the words in a string, e.g. " aBc dEf " -> "Abc Def". +# See also regsub.capwords(). +def capwords(s, sep=None): + """capwords(s, [sep]) -> string + + Split the argument into words using split, capitalize each + word using capitalize, and join the capitalized words using + join. Note that this replaces runs of whitespace characters by + a single space. + + """ + return (sep or ' ').join([x.capitalize() for x in s.split(sep)]) + + +# Construct a translation string +_idmapL = None +def maketrans(fromstr, tostr): + """maketrans(frm, to) -> string + + Return a translation table (a string of 256 bytes long) + suitable for use in string.translate. The strings frm and to + must be of the same length. + + """ + if len(fromstr) != len(tostr): + raise ValueError, "maketrans arguments must have same length" + global _idmapL + if not _idmapL: + _idmapL = map(None, _idmap) + L = _idmapL[:] + fromstr = map(ord, fromstr) + for i in range(len(fromstr)): + L[fromstr[i]] = tostr[i] + return ''.join(L) + + + +import re as _re + +class Template(unicode): + """A string class for supporting $-substitutions.""" + __slots__ = [] + + # Search for $$, $identifier, ${identifier}, and any bare $'s + pattern = _re.compile(r""" +# Match exactly two $'s -- this is the escape sequence +(?P\${2})| +# Match a $ followed by a Python identifier +\$(?P[_a-z][_a-z0-9]*)| +# Match a $ followed by a brace delimited identifier +\${(?P[_a-z][_a-z0-9]*)}| +# Match any other $'s +(?P\$) +""", _re.IGNORECASE | _re.VERBOSE) + + def __mod__(self, mapping): + def convert(mo): + groups = mo.groupdict() + if groups.get('escaped') is not None: + return '$' + if groups.get('bogus') is not None: + raise ValueError('Invalid placeholder at index %d' % + mo.start('bogus')) + val = mapping[groups.get('named') or groups.get('braced')] + return unicode(val) + return self.pattern.sub(convert, self) + + +class SafeTemplate(Template): + """A string class for supporting $-substitutions. + + This class is 'safe' in the sense that you will never get KeyErrors if + there are placeholders missing from the interpolation dictionary. In that + case, you will get the original placeholder in the value string. + """ + __slots__ = [] + + def __mod__(self, mapping): + def convert(mo): + groups = mo.groupdict() + if groups.get('escaped') is not None: + return '$' + if groups.get('bogus') is not None: + raise ValueError('Invalid placeholder at index %d' % + mo.start('bogus')) + named = groups.get('named') + if named is not None: + try: + return unicode(mapping[named]) + except KeyError: + return '$' + named + braced = groups.get('braced') + try: + return unicode(mapping[braced]) + except KeyError: + return '${' + braced + '}' + return self.pattern.sub(convert, self) + + + +# NOTE: Everything below here is deprecated. Use string methods instead. +# This stuff will go away in Python 3.0. + # Backward compatible names for exceptions index_error = ValueError atoi_error = ValueError @@ -336,40 +442,6 @@ """ return s.capitalize() -# Capitalize the words in a string, e.g. " aBc dEf " -> "Abc Def". -# See also regsub.capwords(). -def capwords(s, sep=None): - """capwords(s, [sep]) -> string - - Split the argument into words using split, capitalize each - word using capitalize, and join the capitalized words using - join. Note that this replaces runs of whitespace characters by - a single space. - - """ - return join(map(capitalize, s.split(sep)), sep or ' ') - -# Construct a translation string -_idmapL = None -def maketrans(fromstr, tostr): - """maketrans(frm, to) -> string - - Return a translation table (a string of 256 bytes long) - suitable for use in string.translate. The strings frm and to - must be of the same length. - - """ - if len(fromstr) != len(tostr): - raise ValueError, "maketrans arguments must have same length" - global _idmapL - if not _idmapL: - _idmapL = map(None, _idmap) - L = _idmapL[:] - fromstr = map(ord, fromstr) - for i in range(len(fromstr)): - L[fromstr[i]] = tostr[i] - return join(L, "") - # Substring replacement (global) def replace(s, old, new, maxsplit=-1): """replace (str, old, new[, maxsplit]) -> string From bwarsaw at users.sourceforge.net Wed Aug 25 05:10:01 2004 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Wed Aug 25 05:10:03 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libstring.tex,1.59,1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31386 Modified Files: libstring.tex Log Message: Ah whoops, we didn't turn string into a package (thanks Neal!) Index: libstring.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- libstring.tex 25 Aug 2004 02:22:29 -0000 1.59 +++ libstring.tex 25 Aug 2004 03:09:58 -0000 1.60 @@ -4,22 +4,11 @@ \declaremodule{standard}{string} \modulesynopsis{Common string operations.} -The \module{string} package contains a number of useful constants and classes, +The \module{string} module contains a number of useful constants and classes, as well as some deprecated legacy functions that are also available as methods on strings. See the module \refmodule{re}\refstmodindex{re} for string functions based on regular expressions. -In general, all of these objects are exposed directly in the \module{string} -package so users need only import the \module{string} package to begin using -these constants, classes, and functions. - -\begin{notice} -Starting with Python 2.4, the traditional \module{string} module was turned -into a package, however backward compatibility with existing code has been -retained. Code using the \module{string} module that worked prior to Python -2.4 should continue to work unchanged. -\end{notice} - \subsection{String constants} The constants defined in this module are: From rhettinger at users.sourceforge.net Wed Aug 25 05:18:33 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Aug 25 05:18:36 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.322,2.323 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32534 Modified Files: compile.c Log Message: Simplify chains of conditional jumps. (Suggested by Neal Norwitz.) Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.322 retrieving revision 2.323 diff -u -d -r2.322 -r2.323 --- compile.c 24 Aug 2004 04:34:16 -0000 2.322 +++ compile.c 25 Aug 2004 03:18:29 -0000 2.323 @@ -550,11 +550,34 @@ } break; + /* Simplify conditional jump to conditional jump where the + result of the first test implies the success of a similar + test or the failure of the opposite test. + Arises in code like: + "a and b or c" + "a and b and c" + x:JUMP_IF_FALSE y y:JUMP_IF_FALSE z --> x:JUMP_IF_FALSE z + x:JUMP_IF_FALSE y y:JUMP_IF_FALSE z --> x:JUMP_IF_FALSE y+3 + */ + case JUMP_IF_FALSE: + case JUMP_IF_TRUE: + tgt = GETJUMPTGT(codestr, i); + j = codestr[tgt]; + if (j == JUMP_IF_FALSE || j == JUMP_IF_TRUE) { + if (j == opcode) { + tgttgt = GETJUMPTGT(codestr, tgt) - i - 3; + SETARG(codestr, i, tgttgt); + } else { + tgt -= i; + SETARG(codestr, i, tgt); + } + break; + } + /* Intentional fallthrough */ + /* Replace jumps to unconditional jumps */ case FOR_ITER: case JUMP_FORWARD: - case JUMP_IF_FALSE: - case JUMP_IF_TRUE: case JUMP_ABSOLUTE: case CONTINUE_LOOP: case SETUP_LOOP: From loewis at users.sourceforge.net Wed Aug 25 08:25:00 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 08:25:03 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.302, 1.303 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30627 Modified Files: socketmodule.c Log Message: Back out 1.289, which breaks platforms needing addrinfo.h, and 1.293, 1.298, and 1.300, which have tried to fix this for specific platforms. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.302 retrieving revision 1.303 diff -u -d -r1.302 -r1.303 --- socketmodule.c 23 Aug 2004 05:16:23 -0000 1.302 +++ socketmodule.c 25 Aug 2004 06:24:58 -0000 1.303 @@ -61,10 +61,6 @@ */ -#if defined(__sgi) && _COMPILER_VERSION>700 && !_SGIAPI -#define _BSD_TYPES -#endif - #include "Python.h" #undef MAX @@ -196,18 +192,8 @@ /* XXX Using _SGIAPI is the wrong thing, but I don't know what the right thing is. */ -#undef _SGIAPI /* to avoid warning */ #define _SGIAPI 1 -#undef _XOPEN_SOURCE -#include -#include -#include -#ifdef _SS_ALIGNSIZE -#define HAVE_GETADDRINFO 1 -#define HAVE_GETNAMEINFO 1 -#endif - #define HAVE_INET_PTON #include #endif @@ -271,24 +257,7 @@ # define O_NONBLOCK O_NDELAY #endif -#if defined(__sgi) && _COMPILER_VERSION>700 \ - && !defined(_SS_ALIGNSIZE) /* defined in sys/socket.h */ - /* by some newer versions of IRIX */ - /* (e.g. not by 6.5.10 but by 6.5.21) */ -#include "addrinfo.h" -#endif - -#if defined(PYOS_OS2) && defined(PYCC_GCC) #include "addrinfo.h" -#endif - -#if defined(_MSC_VER) && _MSC_VER == 1200 -#include "addrinfo.h" -#endif - -#if defined(__CYGWIN__) -#include "addrinfo.h" -#endif #ifndef HAVE_INET_PTON int inet_pton(int af, const char *src, void *dst); From loewis at users.sourceforge.net Wed Aug 25 12:42:47 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 12:42:50 2004 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.317,2.318 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6708/Python Modified Files: bltinmodule.c Log Message: Patch #1015021: Stop claiming that coerce can return None. Will backport to 2.3. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.317 retrieving revision 2.318 diff -u -d -r2.317 -r2.318 --- bltinmodule.c 12 Aug 2004 14:42:37 -0000 2.317 +++ bltinmodule.c 25 Aug 2004 10:42:41 -0000 2.318 @@ -322,11 +322,11 @@ } PyDoc_STRVAR(coerce_doc, -"coerce(x, y) -> None or (x1, y1)\n\ +"coerce(x, y) -> (x1, y1)\n\ \n\ -When x and y can be coerced to values of the same type, return a tuple\n\ -containing the coerced values. When they can't be coerced, return None."); - +Return a tuple consisting of the two numeric arguments converted to\n\ +a common type, using the same rules as used by arithmetic operations.\n\ +If coercion is not possible, raise TypeError."); static PyObject * builtin_compile(PyObject *self, PyObject *args) From loewis at users.sourceforge.net Wed Aug 25 12:43:13 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 12:43:15 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.173,1.174 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6708/Doc/lib Modified Files: libfuncs.tex Log Message: Patch #1015021: Stop claiming that coerce can return None. Will backport to 2.3. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.173 retrieving revision 1.174 diff -u -d -r1.173 -r1.174 --- libfuncs.tex 17 Aug 2004 02:21:45 -0000 1.173 +++ libfuncs.tex 25 Aug 2004 10:42:39 -0000 1.174 @@ -1180,7 +1180,7 @@ \begin{funcdesc}{coerce}{x, y} Return a tuple consisting of the two numeric arguments converted to a common type, using the same rules as used by arithmetic - operations. + operations. If coercion is not possible, raise \exception{TypeError}. \end{funcdesc} \begin{funcdesc}{intern}{string} From loewis at users.sourceforge.net Wed Aug 25 12:43:48 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 12:43:50 2004 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c, 2.292.10.5, 2.292.10.6 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7010/Python Modified Files: Tag: release23-maint bltinmodule.c Log Message: Patch #1015021: Stop claiming that coerce can return None. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.292.10.5 retrieving revision 2.292.10.6 diff -u -d -r2.292.10.5 -r2.292.10.6 --- bltinmodule.c 29 Mar 2004 11:57:01 -0000 2.292.10.5 +++ bltinmodule.c 25 Aug 2004 10:43:32 -0000 2.292.10.6 @@ -326,11 +326,11 @@ } PyDoc_STRVAR(coerce_doc, -"coerce(x, y) -> None or (x1, y1)\n\ +"coerce(x, y) -> (x1, y1)\n\ \n\ -When x and y can be coerced to values of the same type, return a tuple\n\ -containing the coerced values. When they can't be coerced, return None."); - +Return a tuple consisting of the two numeric arguments converted to\n\ +a common type, using the same rules as used by arithmetic operations.\n\ +If coercion is not possible, raise TypeError."); static PyObject * builtin_compile(PyObject *self, PyObject *args) From loewis at users.sourceforge.net Wed Aug 25 12:44:05 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 12:44:07 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex, 1.143.8.11, 1.143.8.12 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7010/Doc/lib Modified Files: Tag: release23-maint libfuncs.tex Log Message: Patch #1015021: Stop claiming that coerce can return None. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.143.8.11 retrieving revision 1.143.8.12 diff -u -d -r1.143.8.11 -r1.143.8.12 --- libfuncs.tex 20 Mar 2004 18:26:42 -0000 1.143.8.11 +++ libfuncs.tex 25 Aug 2004 10:43:32 -0000 1.143.8.12 @@ -1086,7 +1086,7 @@ \begin{funcdesc}{coerce}{x, y} Return a tuple consisting of the two numeric arguments converted to a common type, using the same rules as used by arithmetic - operations. + operations. If coercion is not possible, raise \exception{TypeError}. \end{funcdesc} \begin{funcdesc}{intern}{string} From loewis at users.sourceforge.net Wed Aug 25 12:53:01 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 12:53:03 2004 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8425 Modified Files: tarfile.py Log Message: Patch #1014992: Never return more than a line from readline. Will backport to 2.3. Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- tarfile.py 22 Aug 2004 21:28:32 -0000 1.18 +++ tarfile.py 25 Aug 2004 10:52:58 -0000 1.19 @@ -509,14 +509,12 @@ nl = min(nl, size) else: size -= len(self.linebuffer) - while nl < 0: + while (nl < 0 and size > 0): buf = self.read(min(size, 100)) if not buf: break self.linebuffer += buf size -= len(buf) - if size <= 0: - break nl = self.linebuffer.find("\n") if nl == -1: s = self.linebuffer From loewis at users.sourceforge.net Wed Aug 25 12:53:33 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 12:53:35 2004 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.8.12.3,1.8.12.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8538/Lib Modified Files: Tag: release23-maint tarfile.py Log Message: Patch #1014992: Never return more than a line from readline. Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.8.12.3 retrieving revision 1.8.12.4 diff -u -d -r1.8.12.3 -r1.8.12.4 --- tarfile.py 22 Aug 2004 21:30:03 -0000 1.8.12.3 +++ tarfile.py 25 Aug 2004 10:53:30 -0000 1.8.12.4 @@ -509,14 +509,12 @@ nl = min(nl, size) else: size -= len(self.linebuffer) - while nl < 0: + while (nl < 0 and size > 0): buf = self.read(min(size, 100)) if not buf: break self.linebuffer += buf size -= len(buf) - if size <= 0: - break nl = self.linebuffer.find("\n") if nl == -1: s = self.linebuffer From loewis at users.sourceforge.net Wed Aug 25 12:53:34 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 12:53:38 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.147, 1.831.4.148 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8538/Misc Modified Files: Tag: release23-maint NEWS Log Message: Patch #1014992: Never return more than a line from readline. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.147 retrieving revision 1.831.4.148 diff -u -d -r1.831.4.147 -r1.831.4.148 --- NEWS 24 Aug 2004 21:48:15 -0000 1.831.4.147 +++ NEWS 25 Aug 2004 10:53:30 -0000 1.831.4.148 @@ -51,6 +51,8 @@ Library ------- +- Patch #1014992: In tarfile.readline, never return more than a line. + - Bug #1013882: Flush bz2 data even if nothing had been written so far. - Patch #997284: Allow pydoc to work with XP Themes (.manifest file) From loewis at users.sourceforge.net Wed Aug 25 13:24:45 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 13:24:48 2004 Subject: [Python-checkins] python/dist/src/Doc/lib liburllib2.tex,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14002 Modified Files: liburllib2.tex Log Message: Patch #798244: More urllib2 examples. Index: liburllib2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liburllib2.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- liburllib2.tex 11 Jul 2004 02:13:17 -0000 1.20 +++ liburllib2.tex 25 Aug 2004 11:24:42 -0000 1.21 @@ -150,7 +150,7 @@ If \var{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 \var{protocol}_proxy. +variables \envvar{_proxy}. \end{classdesc} \begin{classdesc}{HTTPPasswordMgr}{} @@ -790,3 +790,64 @@ data = sys.stdin.read() print 'Content-type: text-plain\n\nGot Data: "%s"' % data \end{verbatim} + + +Use of Basic HTTP Authentication: + +\begin{verbatim} +import urllib2 +# Create an OpenerDirector with support for Basic HTTP Authentication... +auth_handler = urllib2.HTTPBasicAuthHandler() +auth_handler.add_password('realm', 'host', 'username', 'password') +opener = urllib2.build_opener(auth_handler) +# ...and install it globally so it can be used with urlopen. +urllib2.install_opener(opener) +urllib2.urlopen('http://www.example.com/login.html') +\end{verbatim} + +\function{build_opener()} provides many handlers by default, including a +\class{ProxyHandler}. By default, \class{ProxyHandler} uses the +environment variables named \code{_proxy}, where \code{} +is the URL scheme involved. For example, the \envvar{http_proxy} +environment variable is read to obtain the HTTP proxy's URL. + +This example replaces the default \class{ProxyHandler} with one that uses +programatically-supplied proxy URLs, and adds proxy authorization support +with \class{ProxyBasicAuthHandler}. + +\begin{verbatim} +proxy_handler = urllib2.ProxyHandler({'http': 'http://www.example.com:3128/'}) +proxy_auth_handler = urllib2.HTTPBasicAuthHandler() +proxy_auth_handler.add_password('realm', 'host', 'username', 'password') + +opener = build_opener(proxy_handler, proxy_auth_handler) +# This time, rather than install the OpenerDirector, we use it directly: +opener.open('http://www.example.com/login.html') +\end{verbatim} + + +Adding HTTP headers: + +Use the \var{headers} argument to the \class{Request} constructor, or: + +\begin{verbatim} +import urllib2 +req = urllib2.Request('http://www.example.com/') +req.add_header('Referer', 'http://www.python.org/') +r = urllib2.urlopen(req) +\end{verbatim} + +\class{OpenerDirector} automatically adds a \mailheader{User-Agent} +header to every \class{Request}. To change this: + +\begin{verbatim} +import urllib2 +opener = urllib2.build_opener() +opener.addheaders = [('User-agent', 'Mozilla/5.0')] +opener.open('http://www.example.com/') +\end{verbatim} + +Also, remember that a few standard headers +(\mailheader{Content-Length}, \mailheader{Content-Type} and +\mailheader{Host}) are added when the \class{Request} is passed to +\function{urlopen()} (or \method{OpenerDirector.open()}). From loewis at users.sourceforge.net Wed Aug 25 13:37:45 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 13:37:48 2004 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.84,1.85 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16100/Doc/dist Modified Files: dist.tex Log Message: Patch #736857, #736859: Add -e option to build_scripts. Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.84 retrieving revision 1.85 diff -u -d -r1.84 -r1.85 --- dist.tex 13 Aug 2004 02:56:16 -0000 1.84 +++ dist.tex 25 Aug 2004 11:37:42 -0000 1.85 @@ -640,7 +640,9 @@ anything very complicated. The only clever feature is that if the first line of the script starts with \code{\#!} and contains the word ``python'', the Distutils will adjust the first line to refer to the -current interpreter location. +current interpreter location. By default, it is replaced with the +current interpreter location. The '--executable=/-e' switch will +allow the interpreter path to be explicitly overridden. The \option{scripts} option simply is a list of files to be handled in this way. From the PyXML setup script: From loewis at users.sourceforge.net Wed Aug 25 13:37:46 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 13:37:52 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command build.py, 1.34, 1.35 build_scripts.py, 1.23, 1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16100/Lib/distutils/command Modified Files: build.py build_scripts.py Log Message: Patch #736857, #736859: Add -e option to build_scripts. Index: build.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build.py,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- build.py 19 Nov 2002 13:12:28 -0000 1.34 +++ build.py 25 Aug 2004 11:37:43 -0000 1.35 @@ -40,6 +40,8 @@ "compile extensions and libraries with debugging information"), ('force', 'f', "forcibly build everything (ignore file timestamps)"), + ('executable=', 'e', + "specify final destination interpreter path (build.py)"), ] boolean_options = ['debug', 'force'] @@ -61,6 +63,7 @@ self.compiler = None self.debug = None self.force = 0 + self.executable = None def finalize_options (self): @@ -93,6 +96,8 @@ self.build_scripts = os.path.join(self.build_base, 'scripts-' + sys.version[0:3]) + if self.executable is None: + self.executable = os.path.normpath(sys.executable) # finalize_options () Index: build_scripts.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_scripts.py,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- build_scripts.py 18 Jul 2004 06:14:43 -0000 1.23 +++ build_scripts.py 25 Aug 2004 11:37:43 -0000 1.24 @@ -24,6 +24,7 @@ user_options = [ ('build-dir=', 'd', "directory to \"build\" (copy) to"), ('force', 'f', "forcibly build everything (ignore file timestamps"), + ('executable=', 'e', "specify final destination interpreter path"), ] boolean_options = ['force'] @@ -33,12 +34,14 @@ self.build_dir = None self.scripts = None self.force = None + self.executable = None self.outfiles = None def finalize_options (self): self.set_undefined_options('build', ('build_scripts', 'build_dir'), - ('force', 'force')) + ('force', 'force'), + ('executable', 'executable')) self.scripts = self.distribution.scripts def get_source_files(self): @@ -95,7 +98,7 @@ outf = open(outfile, "w") if not sysconfig.python_build: outf.write("#!%s%s\n" % - (os.path.normpath(sys.executable), + (self.executable, post_interp)) else: outf.write("#!%s%s\n" % From loewis at users.sourceforge.net Wed Aug 25 13:37:46 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 13:37:54 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1110,1.1111 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16100/Misc Modified Files: NEWS Log Message: Patch #736857, #736859: Add -e option to build_scripts. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1110 retrieving revision 1.1111 diff -u -d -r1.1110 -r1.1111 --- NEWS 25 Aug 2004 02:22:30 -0000 1.1110 +++ NEWS 25 Aug 2004 11:37:43 -0000 1.1111 @@ -57,6 +57,9 @@ Library ------- +- distutils build/build_scripts now has an -e option to specify the + path to the Python interpreter for installed scripts. + - PEP 292 classes Template and SafeTemplate are added to the string module. - tarfile now generates GNU tar files by default. From loewis at users.sourceforge.net Wed Aug 25 15:00:38 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 15:00:41 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_rpm.py, 1.38, 1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30258/Lib/distutils/command Modified Files: bdist_rpm.py Log Message: Patch #970019: Include version and release in the BuildRoot. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_rpm.py,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- bdist_rpm.py 11 Jun 2004 17:16:46 -0000 1.38 +++ bdist_rpm.py 25 Aug 2004 13:00:33 -0000 1.39 @@ -361,7 +361,7 @@ spec_file.extend([ 'License: ' + self.distribution.get_license(), 'Group: ' + self.group, - 'BuildRoot: %{_tmppath}/%{name}-buildroot', + 'BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot', 'Prefix: %{_prefix}', ]) # noarch if no extension modules From loewis at users.sourceforge.net Wed Aug 25 15:00:39 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 15:00:45 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1111,1.1112 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30258/Misc Modified Files: NEWS Log Message: Patch #970019: Include version and release in the BuildRoot. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1111 retrieving revision 1.1112 diff -u -d -r1.1111 -r1.1112 --- NEWS 25 Aug 2004 11:37:43 -0000 1.1111 +++ NEWS 25 Aug 2004 13:00:34 -0000 1.1112 @@ -57,6 +57,8 @@ Library ------- +- bdist_rpm now includes version and release in the BuildRoot. + - distutils build/build_scripts now has an -e option to specify the path to the Python interpreter for installed scripts. From loewis at users.sourceforge.net Wed Aug 25 15:04:55 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 15:04:57 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1112,1.1113 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31563/Misc Modified Files: NEWS Log Message: Patch #970015: Replace - by _ in version and release. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1112 retrieving revision 1.1113 diff -u -d -r1.1112 -r1.1113 --- NEWS 25 Aug 2004 13:00:34 -0000 1.1112 +++ NEWS 25 Aug 2004 13:04:53 -0000 1.1113 @@ -57,7 +57,8 @@ Library ------- -- bdist_rpm now includes version and release in the BuildRoot. +- bdist_rpm now includes version and release in the BuildRoot, and + replaces - by ``_`` in version and release. - distutils build/build_scripts now has an -e option to specify the path to the Python interpreter for installed scripts. From loewis at users.sourceforge.net Wed Aug 25 15:04:55 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Aug 25 15:05:00 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_rpm.py, 1.39, 1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31563/Lib/distutils/command Modified Files: bdist_rpm.py Log Message: Patch #970015: Replace - by _ in version and release. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_rpm.py,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- bdist_rpm.py 25 Aug 2004 13:00:33 -0000 1.39 +++ bdist_rpm.py 25 Aug 2004 13:04:52 -0000 1.40 @@ -332,8 +332,8 @@ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), - '%define version ' + self.distribution.get_version(), - '%define release ' + self.release, + '%define version ' + self.distribution.get_version().replace('-','_'), + '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ] From akuchling at users.sourceforge.net Wed Aug 25 15:38:49 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Aug 25 15:38:52 2004 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.87, 1.88 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5761 Modified Files: whatsnew24.tex Log Message: Add various items Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- whatsnew24.tex 9 Aug 2004 14:48:28 -0000 1.87 +++ whatsnew24.tex 25 Aug 2004 13:38:46 -0000 1.88 @@ -179,6 +179,67 @@ implemented by Jiwon Seo with early efforts steered by Hye-Shik Chang.} \end{seealso} + +%====================================================================== +\section{PEP 292: Simpler String Substitutions} + +Some new classes in the standard library provide a +alternative mechanism for substituting variables into strings that's +better-suited for applications where untrained users need to edit templates. + +The usual way of substituting variables by name is the \code{\%} +operator: + +\begin{verbatim} +>>> '%(page)i: %(title)s' % {'page':2, 'title': 'The Best of Times'} +'2: The Best of Times' +\end{verbatim} + +When writing the template string, it can be easy to forget the +\samp{i} or \samp{s} after the closing parenthesis. This isn't a big +problem if the template is in a Python module, because you run the +code, get an ``Unsupported format character'' \exception{ValueError}, +and fix the problem. However, consider an application such as Mailman +where template strings or translations are being edited by users who +aren't aware of the Python language; the syntax is complicated to +explain to such users, and if they make a mistake, it's difficult to +provide helpful feedback to them. + +PEP 292 adds a \class{Template} class to the \module{string} module +that uses \samp{\$} to indicate a substitution. \class{Template} is a +subclass of the built-in Unicode type, so the result is always a +Unicode string: + +\begin{verbatim} +>>> import string +>>> t = string.Template('$page: $title') +>>> t % {'page':2, 'title': 'The Best of Times'} +u'2: The Best of Times' +>>> t2 % {'cost':42.50, 'action':'polish'} +u'$ 42.5: polishing' +\end{verbatim} + +% $ Terminate $-mode for Emacs + +If a key is missing from the dictionary, the \class{Template} class +will raise a \exception{KeyError}. There's also a \class{SafeTemplate} +class that ignores missing keys: + +\begin{verbatim} +>>> t = string.SafeTemplate('$page: $title') +>>> t % {'page':3} +u'3: $title' +\end{verbatim} + +Because templates are Unicode strings, you can use a template with the +\module{gettext} module to look up translated versions of a message. + +\begin{seealso} +\seepep{292}{Simpler String Substitutions}{Written and implemented +by Barry Warsaw.} +\end{seealso} + + %====================================================================== \section{PEP 318: Decorators for Functions, Methods and Classes} @@ -306,6 +367,11 @@ Getting this right can be slightly brain-bending, but it's not too difficult. +A small related change makes the \member{func_name} attribute of +functions writable. This attribute is used to display function names +in tracebacks, so decorators should change the name of any new +function that's constructed and returned. + The new syntax was provisionally added in 2.4alpha2, and is subject to change during the 2.4alpha release cycle depending on the Python community's reaction. Post-2.4 versions of Python will preserve @@ -744,6 +810,9 @@ yellow 5 \end{verbatim} +\item Integer operations will no longer trigger an \exception{OverflowWarning}. +The \exception{OverflowWarning} warning will disappear in Python 2.5. + \item The \function{eval(\var{expr}, \var{globals}, \var{locals})} and \function{execfile(\var{filename}, \var{globals}, \var{locals})} functions and the \keyword{exec} statement now accept any mapping type @@ -869,7 +938,8 @@ \item Korean: cp949, euc-kr, johab, iso-2022-kr \end{itemize} -\item Some other new encodings were added: ISO_8859-11, ISO_8859-16, PCTP-154, +\item Some other new encodings were added: HP Roman8, +ISO_8859-11, ISO_8859-16, PCTP-154, and TIS-620. \item There is a new \module{collections} module for @@ -1071,11 +1141,20 @@ the group didn't match, the pattern \var{B} will be used instead. \item A new \function{socketpair()} function was added to the - \module{socket} module, returning a pair of connected sockets. - (Contributed by Dave Cole.) +\module{socket} module, returning a pair of connected sockets. +(Contributed by Dave Cole.) % XXX sre is now non-recursive. +\item The \function{sys.exitfunc()} function has been deprecated. Code +should be using the existing \module{atexit} module, which correctly +handles calling multiple exit functions. Eventually +\function{sys.exitfunc()} will become a purely internal interface, +accessed only by \module{atexit}. + +\item The \module{tarfile} module now generates GNU-format tar files +by default. + \item The \module{threading} module now has an elegantly simple way to support thread-local data. The module contains a \class{local} class whose attribute values are local to different threads. @@ -1125,6 +1204,13 @@ \class{HTTPCookieProcessor} manages a cookie jar that is used when accessing URLs. +\subsection{doctest} + +The \module{doctest} module underwent considerable refactoring thanks +to Edward Loper and Tim Peters. + +% XXX describe this + % ====================================================================== \section{Build and C API Changes} @@ -1158,13 +1244,16 @@ same name. This can halve the access time for a method such as \method{set.__contains__()}. - \item Python can now be built with additional profiling for the interpreter - itself. This is intended for people developing on the Python core. - Providing \longprogramopt{--enable-profiling} to the - \program{configure} script will let you profile the interpreter with - \program{gprof}, and providing the \longprogramopt{--with-tsc} switch - enables profiling using the Pentium's Time-Stamp-Counter register. - + \item Python can now be built with additional profiling for the + interpreter itself. This is intended for people developing on the + Python core. Providing \longprogramopt{--enable-profiling} to the + \program{configure} script will let you profile the interpreter with + \program{gprof}, and providing the \longprogramopt{--with-tsc} + switch enables profiling using the Pentium's Time-Stamp-Counter + register. The switch is slightly misnamed, because the profiling + feature also works on the PowerPC platform, though that processor + architecture doesn't called that register the TSC. + \item The \ctype{tracebackobject} type has been renamed to \ctype{PyTracebackObject}. \end{itemize} @@ -1226,6 +1315,9 @@ \item \function{fcntl.ioctl} now warns if the \var{mutate} argument is omitted and relevant. +\item The \module{tarfile} module now generates GNU-format tar files +by default. + \end{itemize} From akuchling at users.sourceforge.net Wed Aug 25 15:47:31 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed Aug 25 15:47:34 2004 Subject: [Python-checkins] python/nondist/peps pep-0318.txt,1.26,1.27 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7162 Modified Files: pep-0318.txt Log Message: Wording tweak Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- pep-0318.txt 24 Aug 2004 18:56:00 -0000 1.26 +++ pep-0318.txt 25 Aug 2004 13:47:29 -0000 1.27 @@ -81,7 +81,7 @@ Why Is This So Hard? -------------------- -A couple decorators (``classmethod()`` and ``staticmethod()``) have +Two decorators (``classmethod()`` and ``staticmethod()``) have been available in Python since version 2.2. It's been assumed since approximately that time that some syntactic support for them would eventually be added to the language. Given this assumption, one might From fdrake at users.sourceforge.net Wed Aug 25 16:01:36 2004 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Aug 25 16:01:39 2004 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.85,1.86 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10011 Modified Files: dist.tex Log Message: clean up markup for --executable description Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.85 retrieving revision 1.86 diff -u -d -r1.85 -r1.86 --- dist.tex 25 Aug 2004 11:37:42 -0000 1.85 +++ dist.tex 25 Aug 2004 14:01:32 -0000 1.86 @@ -641,8 +641,9 @@ first line of the script starts with \code{\#!} and contains the word ``python'', the Distutils will adjust the first line to refer to the current interpreter location. By default, it is replaced with the -current interpreter location. The '--executable=/-e' switch will -allow the interpreter path to be explicitly overridden. +current interpreter location. The \longprogramopt{executable} (or +\programopt{-e}) option will allow the interpreter path to be +explicitly overridden. The \option{scripts} option simply is a list of files to be handled in this way. From the PyXML setup script: From rhettinger at users.sourceforge.net Wed Aug 25 17:16:02 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Aug 25 17:16:06 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.323,2.324 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24552 Modified Files: compile.c Log Message: Fix typo in comment and add clarification. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.323 retrieving revision 2.324 diff -u -d -r2.323 -r2.324 --- compile.c 25 Aug 2004 03:18:29 -0000 2.323 +++ compile.c 25 Aug 2004 15:15:56 -0000 2.324 @@ -557,7 +557,8 @@ "a and b or c" "a and b and c" x:JUMP_IF_FALSE y y:JUMP_IF_FALSE z --> x:JUMP_IF_FALSE z - x:JUMP_IF_FALSE y y:JUMP_IF_FALSE z --> x:JUMP_IF_FALSE y+3 + x:JUMP_IF_FALSE y y:JUMP_IF_TRUE z --> x:JUMP_IF_FALSE y+3 + where y+3 is the instruction following the second test. */ case JUMP_IF_FALSE: case JUMP_IF_TRUE: From rhettinger at users.sourceforge.net Wed Aug 25 19:19:40 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Aug 25 19:19:43 2004 Subject: [Python-checkins] python/dist/src/Python compile.c,2.324,2.325 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15834 Modified Files: compile.c Log Message: Bypass peepholing of code with lineno tables having intervals >= 255. Allows the lineno fixup code to remain simple and not have to deal with multibyte codings. * Add an assertion to that effect. * Remove the XXX comment on the subject. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.324 retrieving revision 2.325 diff -u -d -r2.324 -r2.325 --- compile.c 25 Aug 2004 15:15:56 -0000 2.324 +++ compile.c 25 Aug 2004 17:19:38 -0000 2.325 @@ -435,6 +435,13 @@ unsigned int *blocks; char *name; + /* Bypass optimization when the lineno table is too complex */ + assert(PyString_Check(lineno_obj)); + lineno = PyString_AS_STRING(lineno_obj); + tabsiz = PyString_GET_SIZE(lineno_obj); + if (memchr(lineno, 255, tabsiz) != NULL) + goto exitUnchanged; + if (!PyString_Check(code)) goto exitUnchanged; @@ -614,15 +621,12 @@ } /* Fixup linenotab */ - /* XXX make sure this handles intervals > 256 */ - assert(PyString_Check(lineno_obj)); - lineno = PyString_AS_STRING(lineno_obj); - tabsiz = PyString_GET_SIZE(lineno_obj); cum_orig_line = 0; last_line = 0; for (i=0 ; i < tabsiz ; i+=2) { cum_orig_line += lineno[i]; new_line = addrmap[cum_orig_line]; + assert (new_line - last_line < 255); lineno[i] =((unsigned char)(new_line - last_line)); last_line = new_line; } From rhettinger at users.sourceforge.net Wed Aug 25 21:42:14 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Aug 25 21:42:16 2004 Subject: [Python-checkins] python/dist/src/Objects enumobject.c,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13990 Modified Files: enumobject.c Log Message: Fix docstring typo. Index: enumobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/enumobject.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- enumobject.c 12 Apr 2004 18:10:01 -0000 1.16 +++ enumobject.c 25 Aug 2004 19:42:12 -0000 1.17 @@ -238,7 +238,7 @@ } PyDoc_STRVAR(reversed_doc, -"reverse(sequence) -> reverse iterator over values of the sequence\n" +"reversed(sequence) -> reverse iterator over values of the sequence\n" "\n" "Return a reverse iterator"); From edloper at users.sourceforge.net Thu Aug 26 01:07:05 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 01:07:08 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23763/dist/src/Doc/lib Modified Files: libdoctest.tex Log Message: Only recognize the expected output as an exception if it *starts* with a traceback message. I.e., examples that raise exceptions may no longer generate pre-exception output. This restores the behavior of doctest in python 2.3. The ability to check pre-exception output is being removed because it makes the documentation simpler; and because there are very few use cases for it. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- libdoctest.tex 23 Aug 2004 00:26:42 -0000 1.32 +++ libdoctest.tex 25 Aug 2004 23:07:02 -0000 1.33 @@ -235,57 +235,57 @@ ValueError: list.remove(x): x not in list \end{verbatim} -That doctest succeeds if, and only if, \exception{ValueError} is raised, -with the \samp{list.remove(x): x not in list} detail as shown. +That doctest succeeds if \exception{ValueError} is raised, with the +\samp{list.remove(x): x not in list} detail as shown.\footnote{The + doctest also succeeds if it prints the exact text of the traceback + message; otherwise, it fails.} -The expected output for an exception is divided into four parts. -First, an example may produce some normal output before an exception -is raised, although that's unusual. The "normal output" is taken to -be everything until the first "Traceback" line, and is usually an -empty string. Next, the traceback line must be one of these two, and -indented the same as the first line in the example: +The expected output for an exception must start with a traceback +header, which may be either of the following two lines, indented the +same as the first line of the example: \begin{verbatim} Traceback (most recent call last): Traceback (innermost last): \end{verbatim} -The most interesting part is the last part: the line(s) starting with the -exception type and detail. This is usually the last line of a traceback, -but can extend across any number of lines. After the "Traceback" line, -doctest simply ignores everything until the first line indented the same as -the first line of the example, \emph{and} starting with an alphanumeric -character. This example illustrates the complexities that are possible: +The traceback header is followed by an optional traceback stack, whose +contents are ignored by doctest. Each line of the traceback stack +must be indented further than the first line of the example, \emph{or} +start with a non-alphanumeric character. Typically, the traceback +stack is either omitted or copied verbatim from an interactive +session. + +The traceback stack is followed by the most interesting part: the +line(s) containing the exception type and detail. This is usually the +last line of a traceback, but can extend across multiple lines if the +exception has a multi-line detail, as illustrated in the following +example: \begin{verbatim} ->>> print 1, 2; raise ValueError('printed 1\nand 2\n but not 3') -1 2 +>>> raise ValueError('multi\n line\ndetail') Traceback (most recent call last): -... indented the same, but doesn't start with an alphanumeric - not indented the same, so ignored too - File "/Python23/lib/doctest.py", line 442, in _run_examples_inner - compileflags, 1) in globs - File "", line 1, in ? # and all these are ignored -ValueError: printed 1 -and 2 - but not 3 + File "", line 1, in ? +ValueError: multi + line +detail \end{verbatim} -The first (\samp{1 2}) and last three (starting with -\exception{ValueError}) lines are compared, and the rest are ignored. +The last three (starting with \exception{ValueError}) lines are +compared against the exception's type and detail, and the rest are +ignored. -Best practice is to omit the ``File'' lines, unless they add +Best practice is to omit the traceback stack, unless it adds significant documentation value to the example. So the example above is probably better as: \begin{verbatim} ->>> print 1, 2; raise ValueError('printed 1\nand 2\n but not 3') -1 2 +>>> raise ValueError('multi\n line\ndetail') Traceback (most recent call last): - ... -ValueError: printed 1 -and 2 - but not 3 + ... +ValueError: multi + line +detail \end{verbatim} Note the tracebacks are treated very specially. In particular, in the @@ -293,11 +293,6 @@ \constant{ELLIPSIS} option. The ellipsis in that example could be left out, or could just as well be three (or three hundred) commas. -\versionchanged[The abilities to check both normal output and an - exception in a single example, and to have a multi-line - exception detail, were added]{2.4} - - \subsection{Option Flags and Directives\label{doctest-options}} A number of option flags control various aspects of doctest's comparison @@ -634,7 +629,7 @@ \end{verbatim} Otherwise, the backslash will be interpreted as part of the string. - E.g., the "\textbackslash" above would be interpreted as a newline + E.g., the "{\textbackslash}" above would be interpreted as a newline character. Alternatively, you can double each backslash in the doctest version (and not use a raw string): From edloper at users.sourceforge.net Thu Aug 26 01:07:05 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 01:07:10 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.29, 1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23763/dist/src/Lib/test Modified Files: test_doctest.py Log Message: Only recognize the expected output as an exception if it *starts* with a traceback message. I.e., examples that raise exceptions may no longer generate pre-exception output. This restores the behavior of doctest in python 2.3. The ability to check pre-exception output is being removed because it makes the documentation simpler; and because there are very few use cases for it. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- test_doctest.py 23 Aug 2004 22:38:05 -0000 1.29 +++ test_doctest.py 25 Aug 2004 23:07:03 -0000 1.30 @@ -623,8 +623,10 @@ >>> doctest.DocTestRunner(verbose=False).run(test) (0, 2) -An example may generate output before it raises an exception; if it -does, then the output must match the expected output: +An example may not generate output before it raises an exception; if +it does, then the traceback message will not be recognized as +signaling an expected exception, so the example will be reported as an +unexpected exception: >>> def f(x): ... ''' @@ -636,7 +638,15 @@ ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) - (0, 2) + ... # doctest: +ELLIPSIS + ********************************************************************** + Line 3, in f + Failed example: + print 'pre-exception output', x/0 + Exception raised: + ... + ZeroDivisionError: integer division or modulo by zero + (1, 2) Exception messages may contain newlines: From edloper at users.sourceforge.net Thu Aug 26 01:07:05 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 01:07:12 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.82,1.83 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23763/dist/src/Lib Modified Files: doctest.py Log Message: Only recognize the expected output as an exception if it *starts* with a traceback message. I.e., examples that raise exceptions may no longer generate pre-exception output. This restores the behavior of doctest in python 2.3. The ability to check pre-exception output is being removed because it makes the documentation simpler; and because there are very few use cases for it. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.82 retrieving revision 1.83 diff -u -d -r1.82 -r1.83 --- doctest.py 23 Aug 2004 22:42:55 -0000 1.82 +++ doctest.py 25 Aug 2004 23:07:02 -0000 1.83 @@ -1281,15 +1281,14 @@ # A regular expression for handling `want` strings that contain # expected exceptions. It divides `want` into three pieces: - # - the pre-exception output (`want`) # - the traceback header line (`hdr`) + # - the traceback stack (`stack`) # - the exception message (`msg`), as generated by # traceback.format_exception_only() # `msg` may have multiple lines. We assume/require that the # exception message is the first non-indented line starting with a word # character following the traceback header line. _EXCEPTION_RE = re.compile(r""" - (?P .*?) # suck up everything until traceback header # Grab the traceback header. Different versions of Python have # said different things on the first traceback line. ^(?P Traceback\ \( @@ -1297,9 +1296,9 @@ | innermost\ last ) \) : ) - \s* $ # toss trailing whitespace on traceback header - .*? # don't blink: absorb stuff until a line *starts* with \w - ^ (?P \w+ .*) + \s* $ # toss trailing whitespace on the header. + (?P .*?) # don't blink: absorb stuff until... + ^ (?P \w+ .*) # a line *starts* with alphanum. """, re.VERBOSE | re.MULTILINE | re.DOTALL) def __run(self, test, compileflags, out): @@ -1374,13 +1373,10 @@ exc_info) failures += 1 else: - e_want, e_msg = m.group('want', 'msg') - # The test passes iff the pre-exception output and - # the exception description match the values given - # in `want`. - if (self._checker.check_output(e_want, got, - self.optionflags) and - self._checker.check_output(e_msg, exc_msg, + # The test passes iff the expected exception + # message (`m.group('msg')`) matches the actual + # exception message (`exc_msg`). + if (self._checker.check_output(m.group('msg'), exc_msg, self.optionflags)): self.report_success(out, test, example, got + _exception_traceback(exc_info)) From tmick at users.sourceforge.net Thu Aug 26 01:56:02 2004 From: tmick at users.sourceforge.net (tmick@users.sourceforge.net) Date: Thu Aug 26 01:56:05 2004 Subject: [Python-checkins] python/dist/src configure.in,1.467,1.468 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31727 Modified Files: configure.in Log Message: Apply patch #1016224: configure.in change to allow build of _bsddb module on AIX 5.1. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.467 retrieving revision 1.468 diff -u -d -r1.467 -r1.468 --- configure.in 16 Aug 2004 11:35:50 -0000 1.467 +++ configure.in 25 Aug 2004 23:55:59 -0000 1.468 @@ -161,11 +161,16 @@ # This should hopefully be fixed in FreeBSD 4.9 FreeBSD/4.8* | Darwin/6* ) define_xopen_source=no;; - # On AIX 4, 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. + # 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 + ;; esac if test $define_xopen_source = yes From tmick at users.sourceforge.net Thu Aug 26 01:59:42 2004 From: tmick at users.sourceforge.net (tmick@users.sourceforge.net) Date: Thu Aug 26 01:59:47 2004 Subject: [Python-checkins] python/dist/src configure,1.454,1.455 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32729 Modified Files: configure Log Message: Re-generate configure with recent configure.in change (for patch #1016224). Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.454 retrieving revision 1.455 diff -u -d -r1.454 -r1.455 --- configure 16 Aug 2004 11:35:49 -0000 1.454 +++ configure 25 Aug 2004 23:59:39 -0000 1.455 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.466 . +# From configure.in Revision: 1.467 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.4. # @@ -976,7 +976,7 @@ else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi - cd "$ac_popdir" [...2039 lines suppressed...] + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ @@ -20777,12 +20995,6 @@ fi;; esac done` || { (exit 1); exit 1; } - - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub From edloper at users.sourceforge.net Thu Aug 26 02:05:46 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 02:05:48 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.30, 1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1773/dist/src/Lib/test Modified Files: test_doctest.py Log Message: Added an "exc_msg" attribute to Example (containing the expected exception message, or None if no exception is expected); and moved exception parsing from DocTestRunner to DocTestParser. This is architecturally cleaner, since it moves all parsing work to DocTestParser; and it should make it easier for code outside DocTestRunner (notably debugging code) to properly handle expected exceptions. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- test_doctest.py 25 Aug 2004 23:07:03 -0000 1.30 +++ test_doctest.py 26 Aug 2004 00:05:43 -0000 1.31 @@ -123,46 +123,107 @@ def test_Example(): r""" Unit tests for the `Example` class. -Example is a simple container class that holds a source code string, -an expected output string, and a line number (within the docstring): +Example is a simple container class that holds: + - `source`: A source string. + - `want`: An expected output string. + - `exc_msg`: An expected exception message string (or None if no + exception is expected). + - `lineno`: A line number (within the docstring). + - `indent`: The example's indentation in the input string. + - `options`: An option dictionary, mapping option flags to True or + False. - >>> example = doctest.Example('print 1', '1\n', 0) - >>> (example.source, example.want, example.lineno) - ('print 1\n', '1\n', 0) +These attributes are set by the constructor. `source` and `want` are +required; the other attributes all have default values: -The `source` string ends in a newline: + >>> example = doctest.Example('print 1', '1\n') + >>> (example.source, example.want, example.exc_msg, + ... example.lineno, example.indent, example.options) + ('print 1\n', '1\n', None, 0, 0, {}) + +The first three attributes (`source`, `want`, and `exc_msg`) may be +specified positionally; the remaining arguments should be specified as +keyword arguments: + + >>> exc_msg = 'IndexError: pop from an empty list' + >>> example = doctest.Example('[].pop()', '', exc_msg, + ... lineno=5, indent=4, + ... options={doctest.ELLIPSIS: True}) + >>> (example.source, example.want, example.exc_msg, + ... example.lineno, example.indent, example.options) + ('[].pop()\n', '', 'IndexError: pop from an empty list\n', 5, 4, {8: True}) + +The constructor normalizes the `source` string to end in a newline: Source spans a single line: no terminating newline. - >>> e = doctest.Example('print 1', '1\n', 0) + >>> e = doctest.Example('print 1', '1\n') >>> e.source, e.want ('print 1\n', '1\n') - >>> e = doctest.Example('print 1\n', '1\n', 0) + >>> e = doctest.Example('print 1\n', '1\n') >>> e.source, e.want ('print 1\n', '1\n') Source spans multiple lines: require terminating newline. - >>> e = doctest.Example('print 1;\nprint 2\n', '1\n2\n', 0) + >>> e = doctest.Example('print 1;\nprint 2\n', '1\n2\n') >>> e.source, e.want ('print 1;\nprint 2\n', '1\n2\n') - >>> e = doctest.Example('print 1;\nprint 2', '1\n2\n', 0) + >>> e = doctest.Example('print 1;\nprint 2', '1\n2\n') >>> e.source, e.want ('print 1;\nprint 2\n', '1\n2\n') -The `want` string ends with a newline, unless it's the empty string: + Empty source string (which should never appear in real examples) + >>> e = doctest.Example('', '') + >>> e.source, e.want + ('\n', '') - >>> e = doctest.Example('print 1', '1\n', 0) +The constructor normalizes the `want` string to end in a newline, +unless it's the empty string: + + >>> e = doctest.Example('print 1', '1\n') >>> e.source, e.want ('print 1\n', '1\n') - >>> e = doctest.Example('print 1', '1', 0) + >>> e = doctest.Example('print 1', '1') >>> e.source, e.want ('print 1\n', '1\n') - >>> e = doctest.Example('print', '', 0) + >>> e = doctest.Example('print', '') >>> e.source, e.want ('print\n', '') + +The constructor normalizes the `exc_msg` string to end in a newline, +unless it's `None`: + + Message spans one line + >>> exc_msg = 'IndexError: pop from an empty list' + >>> e = doctest.Example('[].pop()', '', exc_msg) + >>> e.exc_msg + 'IndexError: pop from an empty list\n' + + >>> exc_msg = 'IndexError: pop from an empty list\n' + >>> e = doctest.Example('[].pop()', '', exc_msg) + >>> e.exc_msg + 'IndexError: pop from an empty list\n' + + Message spans multiple lines + >>> exc_msg = 'ValueError: 1\n 2' + >>> e = doctest.Example('raise ValueError("1\n 2")', '', exc_msg) + >>> e.exc_msg + 'ValueError: 1\n 2\n' + + >>> exc_msg = 'ValueError: 1\n 2\n' + >>> e = doctest.Example('raise ValueError("1\n 2")', '', exc_msg) + >>> e.exc_msg + 'ValueError: 1\n 2\n' + + Empty (but non-None) exception message (which should never appear + in real examples) + >>> exc_msg = '' + >>> e = doctest.Example('raise X()', '', exc_msg) + >>> e.exc_msg + '\n' """ def test_DocTest(): r""" From edloper at users.sourceforge.net Thu Aug 26 02:05:46 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 02:05:50 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.83,1.84 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1773/dist/src/Lib Modified Files: doctest.py Log Message: Added an "exc_msg" attribute to Example (containing the expected exception message, or None if no exception is expected); and moved exception parsing from DocTestRunner to DocTestParser. This is architecturally cleaner, since it moves all parsing work to DocTestParser; and it should make it easier for code outside DocTestRunner (notably debugging code) to properly handle expected exceptions. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.83 retrieving revision 1.84 diff -u -d -r1.83 -r1.84 --- doctest.py 25 Aug 2004 23:07:02 -0000 1.83 +++ doctest.py 26 Aug 2004 00:05:43 -0000 1.84 @@ -469,6 +469,14 @@ with a newline unless it's empty, in which case it's an empty string. The constructor adds a newline if needed. + - exc_msg: The exception message generated by the example, if + the example is expected to generate an exception; or `None` if + it is not expected to generate an exception. This exception + message is compared against the return value of + `traceback.format_exception_only()`. `exc_msg` ends with a + newline unless it's `None`. The constructor adds a newline + if needed. + - lineno: The line number within the DocTest string containing this Example where the Example begins. This line number is zero-based, with respect to the beginning of the DocTest. @@ -483,12 +491,15 @@ are left at their default value (as specified by the DocTestRunner's optionflags). By default, no options are set. """ - def __init__(self, source, want, lineno, indent=0, options=None): + def __init__(self, source, want, exc_msg=None, lineno=0, indent=0, + options=None): # Normalize inputs. if not source.endswith('\n'): source += '\n' if want and not want.endswith('\n'): want += '\n' + if exc_msg is not None and not exc_msg.endswith('\n'): + exc_msg += '\n' # Store properties. self.source = source self.want = want @@ -496,6 +507,7 @@ self.indent = indent if options is None: options = {} self.options = options + self.exc_msg = exc_msg class DocTest: """ @@ -579,6 +591,28 @@ )*) ''', re.MULTILINE | re.VERBOSE) + # A regular expression for handling `want` strings that contain + # expected exceptions. It divides `want` into three pieces: + # - the traceback header line (`hdr`) + # - the traceback stack (`stack`) + # - the exception message (`msg`), as generated by + # traceback.format_exception_only() + # `msg` may have multiple lines. We assume/require that the + # exception message is the first non-indented line starting with a word + # character following the traceback header line. + _EXCEPTION_RE = re.compile(r""" + # Grab the traceback header. Different versions of Python have + # said different things on the first traceback line. + ^(?P Traceback\ \( + (?: most\ recent\ call\ last + | innermost\ last + ) \) : + ) + \s* $ # toss trailing whitespace on the header. + (?P .*?) # don't blink: absorb stuff until... + ^ (?P \w+ .*) # a line *starts* with alphanum. + """, re.VERBOSE | re.MULTILINE | re.DOTALL) + # A callable returning a true value iff its argument is a blank line # or contains a single comment. _IS_BLANK_OR_COMMENT = re.compile(r'^[ ]*(#.*)?$').match @@ -631,13 +665,15 @@ # Update lineno (lines before this example) lineno += string.count('\n', charno, m.start()) # Extract source/want from the regexp match. - (source, want) = self._parse_example(m, name, lineno) + (source, want, exc_msg) = self._parse_example(m, name, lineno) # Extract extra options from the source. options = self._find_options(source, name, lineno) # Create an Example, and add it to the list. if not self._IS_BLANK_OR_COMMENT(source): - examples.append( Example(source, want, lineno, - len(m.group('indent')), options) ) + examples.append( Example(source, want, exc_msg, + lineno=lineno, + indent=len(m.group('indent')), + options=options) ) # Update lineno (lines inside this example) lineno += string.count('\n', m.start(), m.end()) # Update charno. @@ -700,7 +736,7 @@ lineno += len(lines) # Extract source/want from the regexp match. - (source, want) = self._parse_example(m, name, lineno) + (source, want, exc_msg) = self._parse_example(m, name, lineno) # Display the source output.append(source) # Display the expected output, if any @@ -754,7 +790,14 @@ lineno + len(source_lines)) want = '\n'.join([wl[indent:] for wl in want_lines]) - return source, want + # If `want` contains a traceback message, then extract it. + m = self._EXCEPTION_RE.match(want) + if m: + exc_msg = m.group('msg') + else: + exc_msg = None + + return source, want, exc_msg # This regular expression looks for option directives in the # source code of an example. Option directives are comments @@ -1279,28 +1322,6 @@ # DocTest Running #///////////////////////////////////////////////////////////////// - # A regular expression for handling `want` strings that contain - # expected exceptions. It divides `want` into three pieces: - # - the traceback header line (`hdr`) - # - the traceback stack (`stack`) - # - the exception message (`msg`), as generated by - # traceback.format_exception_only() - # `msg` may have multiple lines. We assume/require that the - # exception message is the first non-indented line starting with a word - # character following the traceback header line. - _EXCEPTION_RE = re.compile(r""" - # Grab the traceback header. Different versions of Python have - # said different things on the first traceback line. - ^(?P Traceback\ \( - (?: most\ recent\ call\ last - | innermost\ last - ) \) : - ) - \s* $ # toss trailing whitespace on the header. - (?P .*?) # don't blink: absorb stuff until... - ^ (?P \w+ .*) # a line *starts* with alphanum. - """, re.VERBOSE | re.MULTILINE | re.DOTALL) - def __run(self, test, compileflags, out): """ Run the examples in `test`. Write the outcome of each example @@ -1365,25 +1386,23 @@ exc_info = sys.exc_info() exc_msg = traceback.format_exception_only(*exc_info[:2])[-1] - # Search the `want` string for an exception. If we don't - # find one, then report an unexpected exception. - m = self._EXCEPTION_RE.match(example.want) - if m is None: + # If `example.exc_msg` is None, then we weren't + # expecting an exception. + if example.exc_msg is None: self.report_unexpected_exception(out, test, example, exc_info) failures += 1 + # If `example.exc_msg` matches the actual exception + # message (`exc_msg`), then the example succeeds. + elif (self._checker.check_output(example.exc_msg, exc_msg, + self.optionflags)): + self.report_success(out, test, example, + got + _exception_traceback(exc_info)) + # Otherwise, the example fails. else: - # The test passes iff the expected exception - # message (`m.group('msg')`) matches the actual - # exception message (`exc_msg`). - if (self._checker.check_output(m.group('msg'), exc_msg, - self.optionflags)): - self.report_success(out, test, example, - got + _exception_traceback(exc_info)) - else: - self.report_failure(out, test, example, - got + _exception_traceback(exc_info)) - failures += 1 + self.report_failure(out, test, example, + got + _exception_traceback(exc_info)) + failures += 1 # Restore the option flags (in case they were modified) self.optionflags = original_optionflags From rhettinger at users.sourceforge.net Thu Aug 26 02:21:16 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Aug 26 02:21:21 2004 Subject: [Python-checkins] python/dist/src/Lib string.py,1.72,1.73 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4946 Modified Files: string.py Log Message: Minor improvements to the template code. * Add comment bars segregating this code from the rest. * Improve readability of the re pattern with indentation and comments on the same line. * Replace the groupdict() and get() pair with a direct call to group() which does the same thing. Index: string.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/string.py,v retrieving revision 1.72 retrieving revision 1.73 diff -u -d -r1.72 -r1.73 --- string.py 25 Aug 2004 02:22:29 -0000 1.72 +++ string.py 26 Aug 2004 00:21:13 -0000 1.73 @@ -79,6 +79,7 @@ +#################################################################### import re as _re class Template(unicode): @@ -87,25 +88,20 @@ # Search for $$, $identifier, ${identifier}, and any bare $'s pattern = _re.compile(r""" -# Match exactly two $'s -- this is the escape sequence -(?P\${2})| -# Match a $ followed by a Python identifier -\$(?P[_a-z][_a-z0-9]*)| -# Match a $ followed by a brace delimited identifier -\${(?P[_a-z][_a-z0-9]*)}| -# Match any other $'s -(?P\$) -""", _re.IGNORECASE | _re.VERBOSE) + (?P\${2})| # Escape sequence of two $ signs + \$(?P[_a-z][_a-z0-9]*)| # $ and a Python identifier + \${(?P[_a-z][_a-z0-9]*)}| # $ and a brace delimited identifier + (?P\$) # Other ill-formed $ expressions + """, _re.IGNORECASE | _re.VERBOSE) def __mod__(self, mapping): def convert(mo): - groups = mo.groupdict() - if groups.get('escaped') is not None: + if mo.group('escaped') is not None: return '$' - if groups.get('bogus') is not None: + if mo.group('bogus') is not None: raise ValueError('Invalid placeholder at index %d' % mo.start('bogus')) - val = mapping[groups.get('named') or groups.get('braced')] + val = mapping[mo.group('named') or mo.group('braced')] return unicode(val) return self.pattern.sub(convert, self) @@ -121,27 +117,28 @@ def __mod__(self, mapping): def convert(mo): - groups = mo.groupdict() - if groups.get('escaped') is not None: + if mo.group('escaped') is not None: return '$' - if groups.get('bogus') is not None: + if mo.group('bogus') is not None: raise ValueError('Invalid placeholder at index %d' % mo.start('bogus')) - named = groups.get('named') + named = mo.group('named') if named is not None: try: return unicode(mapping[named]) except KeyError: return '$' + named - braced = groups.get('braced') + braced = mo.group('braced') try: return unicode(mapping[braced]) except KeyError: return '${' + braced + '}' return self.pattern.sub(convert, self) +del _re +#################################################################### # NOTE: Everything below here is deprecated. Use string methods instead. # This stuff will go away in Python 3.0. From davecole at users.sourceforge.net Thu Aug 26 02:37:32 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Thu Aug 26 02:37:34 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libpyexpat.tex,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8986/Doc/lib Modified Files: libpyexpat.tex Log Message: Patch #1014930. Expose current parse location to XMLParser. Index: libpyexpat.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpyexpat.tex,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- libpyexpat.tex 10 Aug 2004 17:18:32 -0000 1.23 +++ libpyexpat.tex 26 Aug 2004 00:37:30 -0000 1.24 @@ -257,6 +257,26 @@ Line number at which an error occurred. \end{memberdesc} +The following attributes contain values relating to the current parse +location in an \class{xmlparser} object. During a callback reporting +a parse event they indicate the location of the first of the sequence +of characters that generated the event. When called outside of a +callback, the position indicated will be just past the last parse +event (regardless of whether there was an associated callback). +\versionadded{2.4} + +\begin{memberdesc}[xmlparser]{CurrentByteIndex} +Current byte index in the parser input. +\end{memberdesc} + +\begin{memberdesc}[xmlparser]{CurrentColumnNumber} +Current column number in the parser input. +\end{memberdesc} + +\begin{memberdesc}[xmlparser]{CurrentLineNumber} +Current line number in the parser input. +\end{memberdesc} + Here is the list of handlers that can be set. To set a handler on an \class{xmlparser} object \var{o}, use \code{\var{o}.\var{handlername} = \var{func}}. \var{handlername} must From davecole at users.sourceforge.net Thu Aug 26 02:37:33 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Thu Aug 26 02:37:37 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_pyexpat.py, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8986/Lib/test Modified Files: test_pyexpat.py Log Message: Patch #1014930. Expose current parse location to XMLParser. Index: test_pyexpat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyexpat.py,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- test_pyexpat.py 13 Aug 2004 03:09:07 -0000 1.15 +++ test_pyexpat.py 26 Aug 2004 00:37:30 -0000 1.16 @@ -326,3 +326,42 @@ print "Expected RuntimeError for element 'a'; found %r" % e.args[0] else: print "Expected RuntimeError for 'a'" + +# Test Current* members: +class PositionTest: + + def __init__(self, expected_list, parser): + self.parser = parser + self.parser.StartElementHandler = self.StartElementHandler + self.parser.EndElementHandler = self.EndElementHandler + self.expected_list = expected_list + self.upto = 0 + + def StartElementHandler(self, name, attrs): + self.check_pos('s') + + def EndElementHandler(self, name): + self.check_pos('e') + + def check_pos(self, event): + pos = (event, + self.parser.CurrentByteIndex, + self.parser.CurrentLineNumber, + self.parser.CurrentColumnNumber) + require(self.upto < len(self.expected_list), + 'too many parser events') + expected = self.expected_list[self.upto] + require(pos == expected, + 'expected position %s, got %s' % (expected, pos)) + self.upto += 1 + + +parser = expat.ParserCreate() +handler = PositionTest([('s', 0, 1, 0), ('s', 5, 2, 1), ('s', 11, 3, 2), + ('e', 15, 3, 6), ('e', 17, 4, 1), ('e', 22, 5, 0)], + parser) +parser.Parse(''' + + + +''', 1) From davecole at users.sourceforge.net Thu Aug 26 02:37:34 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Thu Aug 26 02:37:40 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1113,1.1114 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8986/Misc Modified Files: NEWS Log Message: Patch #1014930. Expose current parse location to XMLParser. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1113 retrieving revision 1.1114 diff -u -d -r1.1113 -r1.1114 --- NEWS 25 Aug 2004 13:04:53 -0000 1.1113 +++ NEWS 26 Aug 2004 00:37:30 -0000 1.1114 @@ -54,6 +54,9 @@ - Added socket.socketpair(). +- Added CurrentByteIndex, CurrentColumnNumber, CurrentLineNumber + members to xml.parsers.expat.XMLParser object. + Library ------- From davecole at users.sourceforge.net Thu Aug 26 02:37:34 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Thu Aug 26 02:37:42 2004 Subject: [Python-checkins] python/dist/src/Modules pyexpat.c,2.87,2.88 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8986/Modules Modified Files: pyexpat.c Log Message: Patch #1014930. Expose current parse location to XMLParser. Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.87 retrieving revision 2.88 diff -u -d -r2.87 -r2.88 --- pyexpat.c 13 Aug 2004 03:12:57 -0000 2.87 +++ pyexpat.c 26 Aug 2004 00:37:31 -0000 2.88 @@ -1455,6 +1455,17 @@ return PyInt_FromLong((long) XML_GetErrorByteIndex(self->itself)); } + if (name[0] == 'C') { + if (strcmp(name, "CurrentLineNumber") == 0) + return PyInt_FromLong((long) + XML_GetCurrentLineNumber(self->itself)); + if (strcmp(name, "CurrentColumnNumber") == 0) + return PyInt_FromLong((long) + XML_GetCurrentColumnNumber(self->itself)); + if (strcmp(name, "CurrentByteIndex") == 0) + return PyInt_FromLong((long) + XML_GetCurrentByteIndex(self->itself)); + } if (name[0] == 'b') { if (strcmp(name, "buffer_size") == 0) return PyInt_FromLong((long) self->buffer_size); @@ -1503,6 +1514,9 @@ APPEND(rc, "ErrorLineNumber"); APPEND(rc, "ErrorColumnNumber"); APPEND(rc, "ErrorByteIndex"); + APPEND(rc, "CurrentLineNumber"); + APPEND(rc, "CurrentColumnNumber"); + APPEND(rc, "CurrentByteIndex"); APPEND(rc, "buffer_size"); APPEND(rc, "buffer_text"); APPEND(rc, "buffer_used"); From davecole at users.sourceforge.net Thu Aug 26 02:51:18 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Thu Aug 26 02:51:20 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.87,1.88 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11692/Doc/lib Modified Files: libsocket.tex Log Message: Patch #1015012. Improve markup and punctuation in libsocket.tex Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- libsocket.tex 23 Aug 2004 05:16:22 -0000 1.87 +++ libsocket.tex 26 Aug 2004 00:51:16 -0000 1.88 @@ -305,10 +305,10 @@ \begin{funcdesc}{socketpair}{\optional{family\optional{, type\optional{, proto}}}} Build a pair of connected socket objects using the given address -family, socket type and protocol number. Address family, socket type +family, socket type, and protocol number. Address family, socket type, and protocol number are as for the \function{socket()} function above. -The default family is AF_UNIX if defined for the platform, otherwise -the default is AF_INET. +The default family is \constant{AF_UNIX} if defined on the platform; +otherwise, the default is \constant{AF_INET}. Availability: \UNIX. \versionadded{2.4} \end{funcdesc} From davecole at users.sourceforge.net Thu Aug 26 02:51:19 2004 From: davecole at users.sourceforge.net (davecole@users.sourceforge.net) Date: Thu Aug 26 02:51:23 2004 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c, 1.303, 1.304 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11692/Modules Modified Files: socketmodule.c Log Message: Patch #1015012. Improve markup and punctuation in libsocket.tex Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.303 retrieving revision 1.304 diff -u -d -r1.303 -r1.304 --- socketmodule.c 25 Aug 2004 06:24:58 -0000 1.303 +++ socketmodule.c 26 Aug 2004 00:51:16 -0000 1.304 @@ -2981,7 +2981,7 @@ #ifdef HAVE_SOCKETPAIR /* Create a pair of sockets using the socketpair() function. Arguments as for socket() except the default family is AF_UNIX if - defined for the platform, otherwise the default is AF_INET. */ + defined on the platform; otherwise, the default is AF_INET. */ /*ARGSUSED*/ static PyObject * @@ -3029,7 +3029,7 @@ Create a pair of socket objects from the sockets returned by the platform\n\ socketpair() function.\n\ The arguments are the same as for socket() except the default family is\n\ -AF_UNIX if defined for the platform, otherwise the default is AF_INET."); +AF_UNIX if defined on the platform; otherwise, the default is AF_INET."); #endif /* HAVE_SOCKETPAIR */ From tim_one at users.sourceforge.net Thu Aug 26 03:02:16 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 26 03:02:19 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13272/Doc/lib Modified Files: libdoctest.tex Log Message: Restored half of a \versionadded only half of which should have been deleted. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- libdoctest.tex 25 Aug 2004 23:07:02 -0000 1.33 +++ libdoctest.tex 26 Aug 2004 01:02:08 -0000 1.34 @@ -293,6 +293,9 @@ \constant{ELLIPSIS} option. The ellipsis in that example could be left out, or could just as well be three (or three hundred) commas. +\versionchanged[The ability to handle a multi-line exception detail + was added]{2.4} + \subsection{Option Flags and Directives\label{doctest-options}} A number of option flags control various aspects of doctest's comparison From edloper at users.sourceforge.net Thu Aug 26 03:19:53 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 03:19:55 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.31, 1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15972/dist/src/Lib/test Modified Files: test_doctest.py Log Message: - Changed the output of report_start() and report_unexpected_exception() to be more consistent with report_failure() - If `want` or `got` is empty, then print "Expected nothing\n" or "Got nothing\n" rather than "Expected:\n" or "Got:\n" - Got rid of _tag_msg Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- test_doctest.py 26 Aug 2004 00:05:43 -0000 1.31 +++ test_doctest.py 26 Aug 2004 01:19:50 -0000 1.32 @@ -591,11 +591,14 @@ ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=True).run(test) - Trying: x = 12 - Expecting: nothing + Trying: + x = 12 + Expecting nothing ok - Trying: print x - Expecting: 14 + Trying: + print x + Expecting: + 14 ********************************************************************** Line 3, in f Failed example: @@ -604,8 +607,10 @@ 14 Got: 12 - Trying: x/2 - Expecting: 6 + Trying: + x/2 + Expecting: + 6 ok (1, 3) """ @@ -624,14 +629,19 @@ >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=True).run(test) - Trying: x = 12 - Expecting: nothing + Trying: + x = 12 + Expecting nothing ok - Trying: print x - Expecting: 12 + Trying: + print x + Expecting: + 12 ok - Trying: x/2 - Expecting: 6 + Trying: + x/2 + Expecting: + 6 ok (0, 3) @@ -649,14 +659,19 @@ >>> # If -v does appear in sys.argv, then output is verbose. >>> sys.argv = ['test', '-v'] >>> doctest.DocTestRunner().run(test) - Trying: x = 12 - Expecting: nothing + Trying: + x = 12 + Expecting nothing ok - Trying: print x - Expecting: 12 + Trying: + print x + Expecting: + 12 ok - Trying: x/2 - Expecting: 6 + Trying: + x/2 + Expecting: + 6 ok (0, 3) @@ -1633,11 +1648,14 @@ ... ''' >>> t.runstring(test, "Example") Running string Example - Trying: x = 1 + 2 - Expecting: nothing + Trying: + x = 1 + 2 + Expecting nothing ok - Trying: x - Expecting: 3 + Trying: + x + Expecting: + 3 ok 0 of 2 examples failed in string Example (0, 2) From edloper at users.sourceforge.net Thu Aug 26 03:19:52 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 03:19:57 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.84,1.85 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15972/dist/src/Lib Modified Files: doctest.py Log Message: - Changed the output of report_start() and report_unexpected_exception() to be more consistent with report_failure() - If `want` or `got` is empty, then print "Expected nothing\n" or "Got nothing\n" rather than "Expected:\n" or "Got:\n" - Got rid of _tag_msg Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.84 retrieving revision 1.85 diff -u -d -r1.84 -r1.85 --- doctest.py 26 Aug 2004 00:05:43 -0000 1.84 +++ doctest.py 26 Aug 2004 01:19:50 -0000 1.85 @@ -343,25 +343,13 @@ else: raise TypeError("Expected a module, string, or None") -def _tag_msg(tag, msg, indent=' '): +def _indent(s, indent=4): """ - Return a string that displays a tag-and-message pair nicely, - keeping the tag and its message on the same line when that - makes sense. If the message is displayed on separate lines, - then `indent` is added to the beginning of each line. + Add the given number of space characters to the beginning every + non-blank line in `s`, and return the result. """ - # If the message doesn't end in a newline, then add one. - if msg[-1:] != '\n': - msg += '\n' - # If the message is short enough, and contains no internal - # newlines, then display it on the same line as the tag. - # Otherwise, display the tag on its own line. - if (len(tag) + len(msg) < 75 and - msg.find('\n', 0, len(msg)-1) == -1): - return '%s: %s' % (tag, msg) - else: - msg = '\n'.join([indent+l for l in msg[:-1].split('\n')]) - return '%s:\n%s\n' % (tag, msg) + # This regexp matches the start of non-blank lines: + return re.sub('(?m)^(?!$)', indent*' ', s) def _exception_traceback(exc_info): """ @@ -1273,8 +1261,12 @@ example. (Only displays a message if verbose=True) """ if self._verbose: - out(_tag_msg("Trying", example.source) + - _tag_msg("Expecting", example.want or "nothing")) + if example.want: + out('Trying:\n' + _indent(example.source) + + 'Expecting:\n' + _indent(example.want)) + else: + out('Trying:\n' + _indent(example.source) + + 'Expecting nothing\n') def report_success(self, out, test, example, got): """ @@ -1298,7 +1290,7 @@ Report that the given example raised an unexpected exception. """ out(self._failure_header(test, example) + - _tag_msg("Exception raised", _exception_traceback(exc_info))) + 'Exception raised:\n' + _indent(_exception_traceback(exc_info))) def _failure_header(self, test, example): out = [self.DIVIDER] @@ -1313,10 +1305,8 @@ out.append('Line %s, in %s' % (example.lineno+1, test.name)) out.append('Failed example:') source = example.source - if source.endswith('\n'): - source = source[:-1] - out.append(' ' + '\n '.join(source.split('\n'))) - return '\n'.join(out)+'\n' + out.append(_indent(source)) + return '\n'.join(out) #///////////////////////////////////////////////////////////////// # DocTest Running @@ -1612,10 +1602,8 @@ Return a string describing the differences between the expected output for an example (`want`) and the actual output (`got`). `optionflags` is the set of option flags used to - compare `want` and `got`. `indent` is the indentation of the - original example. + compare `want` and `got`. """ - # If s are being used, then replace blank lines # with in the actual output string. if not (optionflags & DONT_ACCEPT_BLANKLINE): @@ -1645,18 +1633,18 @@ assert 0, 'Bad diff option' # Remove trailing whitespace on diff output. diff = [line.rstrip() + '\n' for line in diff] - return _tag_msg("Differences (" + kind + ")", - ''.join(diff)) + return 'Differences (%s):\n' % kind + _indent(''.join(diff)) # If we're not using diff, then simply list the expected # output followed by the actual output. - if want.endswith('\n'): - want = want[:-1] - want = ' ' + '\n '.join(want.split('\n')) - if got.endswith('\n'): - got = got[:-1] - got = ' ' + '\n '.join(got.split('\n')) - return "Expected:\n%s\nGot:\n%s\n" % (want, got) + if want and got: + return 'Expected:\n%sGot:\n%s' % (_indent(want), _indent(got)) + elif want: + return 'Expected:\n%sGot nothing\n' % _indent(want) + elif got: + return 'Expected nothing\nGot:\n%s' % _indent(got) + else: + return 'Expected nothing\nGot nothing\n' class DocTestFailure(Exception): """A DocTest example has failed in debugging mode. From edloper at users.sourceforge.net Thu Aug 26 03:31:59 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 03:32:01 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.85,1.86 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17857/dist/src/Lib Modified Files: doctest.py Log Message: Shortened diff output for unified & context diffs Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.85 retrieving revision 1.86 diff -u -d -r1.85 -r1.86 --- doctest.py 26 Aug 2004 01:19:50 -0000 1.85 +++ doctest.py 26 Aug 2004 01:31:56 -0000 1.86 @@ -1618,13 +1618,13 @@ got_lines = [l+'\n' for l in got.split('\n')] # Use difflib to find their differences. if optionflags & UNIFIED_DIFF: - diff = difflib.unified_diff(want_lines, got_lines, n=2, - fromfile='Expected', tofile='Got') - kind = 'unified diff' + diff = difflib.unified_diff(want_lines, got_lines, n=2) + diff = list(diff)[2:] # strip the diff header + kind = 'unified diff with -expected +actual' elif optionflags & CONTEXT_DIFF: - diff = difflib.context_diff(want_lines, got_lines, n=2, - fromfile='Expected', tofile='Got') - kind = 'context diff' + diff = difflib.context_diff(want_lines, got_lines, n=2) + diff = list(diff)[2:] # strip the diff header + kind = 'context diff with expected followed by actual' elif optionflags & NDIFF_DIFF: engine = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK) diff = list(engine.compare(want_lines, got_lines)) From edloper at users.sourceforge.net Thu Aug 26 03:31:59 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 03:32:03 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.32, 1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17857/dist/src/Lib/test Modified Files: test_doctest.py Log Message: Shortened diff output for unified & context diffs Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- test_doctest.py 26 Aug 2004 01:19:50 -0000 1.32 +++ test_doctest.py 26 Aug 2004 01:31:56 -0000 1.33 @@ -971,9 +971,7 @@ Line 2, in f Failed example: print '\n'.join('abcdefg') - Differences (unified diff): - --- Expected - +++ Got + Differences (unified diff with -expected +actual): @@ -1,8 +1,8 @@ a -B @@ -998,9 +996,7 @@ Line 2, in f Failed example: print '\n'.join('abcdefg') - Differences (context diff): - *** Expected - --- Got + Differences (context diff with expected followed by actual): *************** *** 1,8 **** a From edloper at users.sourceforge.net Thu Aug 26 03:41:53 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 03:41:55 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19362/dist/src/Doc/lib Modified Files: libdoctest.tex Log Message: Renamed UNIFIED_DIFF->REPORT_UDIFF; CONTEXT_DIFF->REPORT_CDIFF; and NDIFF_DIFF->REPORT_NDIFF. This establishes the naming convention that all reporting options should begin with "REPORT_" (since reporting options are a different class from output comparison options; but they are both set in optionflags). Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- libdoctest.tex 26 Aug 2004 01:02:08 -0000 1.34 +++ libdoctest.tex 26 Aug 2004 01:41:50 -0000 1.35 @@ -344,17 +344,17 @@ is prone to in regular expressions. \end{datadesc} -\begin{datadesc}{UNIFIED_DIFF} +\begin{datadesc}{REPORT_UDIFF} When specified, failures that involve multi-line expected and actual outputs are displayed using a unified diff. \end{datadesc} -\begin{datadesc}{CONTEXT_DIFF} +\begin{datadesc}{REPORT_CDIFF} When specified, failures that involve multi-line expected and actual outputs will be displayed using a context diff. \end{datadesc} -\begin{datadesc}{NDIFF_DIFF} +\begin{datadesc}{REPORT_NDIFF} When specified, differences are computed by \code{difflib.Differ}, using the same algorithm as the popular \file{ndiff.py} utility. This is the only method that marks differences within lines as @@ -421,8 +421,8 @@ \versionchanged[Constants \constant{DONT_ACCEPT_BLANKLINE}, \constant{NORMALIZE_WHITESPACE}, \constant{ELLIPSIS}, - \constant{UNIFIED_DIFF}, \constant{CONTEXT_DIFF}, and - \constant{NDIFF_DIFF} + \constant{REPORT_UDIFF}, \constant{REPORT_CDIFF}, and + \constant{REPORT_NDIFF} were added; by default \code{} in expected output matches an empty line in actual output; and doctest directives were added]{2.4} From edloper at users.sourceforge.net Thu Aug 26 03:41:53 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 03:41:59 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.86,1.87 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19362/dist/src/Lib Modified Files: doctest.py Log Message: Renamed UNIFIED_DIFF->REPORT_UDIFF; CONTEXT_DIFF->REPORT_CDIFF; and NDIFF_DIFF->REPORT_NDIFF. This establishes the naming convention that all reporting options should begin with "REPORT_" (since reporting options are a different class from output comparison options; but they are both set in optionflags). Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.86 retrieving revision 1.87 diff -u -d -r1.86 -r1.87 --- doctest.py 26 Aug 2004 01:31:56 -0000 1.86 +++ doctest.py 26 Aug 2004 01:41:51 -0000 1.87 @@ -176,9 +176,9 @@ 'DONT_ACCEPT_BLANKLINE', 'NORMALIZE_WHITESPACE', 'ELLIPSIS', - 'UNIFIED_DIFF', - 'CONTEXT_DIFF', - 'NDIFF_DIFF', + 'REPORT_UDIFF', + 'REPORT_CDIFF', + 'REPORT_NDIFF', # 1. Utility Functions 'is_private', # 2. Example & DocTest @@ -257,9 +257,9 @@ DONT_ACCEPT_BLANKLINE = register_optionflag('DONT_ACCEPT_BLANKLINE') NORMALIZE_WHITESPACE = register_optionflag('NORMALIZE_WHITESPACE') ELLIPSIS = register_optionflag('ELLIPSIS') -UNIFIED_DIFF = register_optionflag('UNIFIED_DIFF') -CONTEXT_DIFF = register_optionflag('CONTEXT_DIFF') -NDIFF_DIFF = register_optionflag('NDIFF_DIFF') +REPORT_UDIFF = register_optionflag('REPORT_UDIFF') +REPORT_CDIFF = register_optionflag('REPORT_CDIFF') +REPORT_NDIFF = register_optionflag('REPORT_NDIFF') # Special string markers for use in `want` strings: BLANKLINE_MARKER = '' @@ -1582,9 +1582,9 @@ # Should we do a fancy diff? def _do_a_fancy_diff(self, want, got, optionflags): # Not unless they asked for a fancy diff. - if not optionflags & (UNIFIED_DIFF | - CONTEXT_DIFF | - NDIFF_DIFF): + if not optionflags & (REPORT_UDIFF | + REPORT_CDIFF | + REPORT_NDIFF): return False # If expected output uses ellipsis, a meaningful fancy diff is # too hard. @@ -1592,7 +1592,7 @@ return False # ndiff does intraline difference marking, so can be useful even # for 1-line inputs. - if optionflags & NDIFF_DIFF: + if optionflags & REPORT_NDIFF: return True # The other diff types need at least a few lines to be helpful. return want.count('\n') > 2 and got.count('\n') > 2 @@ -1617,15 +1617,15 @@ want_lines = [l+'\n' for l in want.split('\n')] got_lines = [l+'\n' for l in got.split('\n')] # Use difflib to find their differences. - if optionflags & UNIFIED_DIFF: + if optionflags & REPORT_UDIFF: diff = difflib.unified_diff(want_lines, got_lines, n=2) diff = list(diff)[2:] # strip the diff header kind = 'unified diff with -expected +actual' - elif optionflags & CONTEXT_DIFF: + elif optionflags & REPORT_CDIFF: diff = difflib.context_diff(want_lines, got_lines, n=2) diff = list(diff)[2:] # strip the diff header kind = 'context diff with expected followed by actual' - elif optionflags & NDIFF_DIFF: + elif optionflags & REPORT_NDIFF: engine = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK) diff = list(engine.compare(want_lines, got_lines)) kind = 'ndiff with -expected +actual' @@ -1839,9 +1839,9 @@ DONT_ACCEPT_BLANKLINE NORMALIZE_WHITESPACE ELLIPSIS - UNIFIED_DIFF - CONTEXT_DIFF - NDIFF_DIFF + REPORT_UDIFF + REPORT_CDIFF + REPORT_NDIFF Optional keyword arg "raise_on_error" raises an exception on the first unexpected exception or failure. This allows failures to be From edloper at users.sourceforge.net Thu Aug 26 03:41:53 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 03:42:01 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.33, 1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19362/dist/src/Lib/test Modified Files: test_doctest.py Log Message: Renamed UNIFIED_DIFF->REPORT_UDIFF; CONTEXT_DIFF->REPORT_CDIFF; and NDIFF_DIFF->REPORT_NDIFF. This establishes the naming convention that all reporting options should begin with "REPORT_" (since reporting options are a different class from output comparison options; but they are both set in optionflags). Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- test_doctest.py 26 Aug 2004 01:31:56 -0000 1.33 +++ test_doctest.py 26 Aug 2004 01:41:51 -0000 1.34 @@ -923,7 +923,7 @@ ... # doctest: +NORMALIZE_WHITESPACE [0, 1, ..., 18, 19] -The UNIFIED_DIFF flag causes failures that involve multi-line expected +The REPORT_UDIFF flag causes failures that involve multi-line expected and actual outputs to be displayed using a unified diff: >>> def f(x): @@ -965,7 +965,7 @@ >>> # With the flag: >>> test = doctest.DocTestFinder().find(f)[0] - >>> flags = doctest.UNIFIED_DIFF + >>> flags = doctest.REPORT_UDIFF >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ********************************************************************** Line 2, in f @@ -985,12 +985,12 @@ (1, 1) -The CONTEXT_DIFF flag causes failures that involve multi-line expected +The REPORT_CDIFF flag causes failures that involve multi-line expected and actual outputs to be displayed using a context diff: - >>> # Reuse f() from the UNIFIED_DIFF example, above. + >>> # Reuse f() from the REPORT_UDIFF example, above. >>> test = doctest.DocTestFinder().find(f)[0] - >>> flags = doctest.CONTEXT_DIFF + >>> flags = doctest.REPORT_CDIFF >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ********************************************************************** Line 2, in f @@ -1019,7 +1019,7 @@ (1, 1) -The NDIFF_DIFF flag causes failures to use the difflib.Differ algorithm +The REPORT_NDIFF flag causes failures to use the difflib.Differ algorithm used by the popular ndiff.py utility. This does intraline difference marking, as well as interline differences. @@ -1029,7 +1029,7 @@ ... a b c d e f g h i j k 1 m ... ''' >>> test = doctest.DocTestFinder().find(f)[0] - >>> flags = doctest.NDIFF_DIFF + >>> flags = doctest.REPORT_NDIFF >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ********************************************************************** Line 2, in f From bcannon at users.sourceforge.net Thu Aug 26 03:44:09 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Aug 26 03:44:12 2004 Subject: [Python-checkins] python/dist/src setup.py,1.198,1.199 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19437 Modified Files: setup.py Log Message: When building with --disable-toolbox-glue under Darwin, skip building any Mac-specific modules. Before all modules were compiled but would fail thanks to a dependence on the code included when Python was built without the compiler flag. Closes bug #991962. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.198 retrieving revision 1.199 diff -u -d -r1.198 -r1.199 --- setup.py 18 Aug 2004 15:13:39 -0000 1.198 +++ setup.py 26 Aug 2004 01:44:06 -0000 1.199 @@ -119,7 +119,8 @@ # Platform-dependent module source and include directories platform = self.get_platform() - if platform in ('darwin', 'mac'): + if platform in ('darwin', 'mac') 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(os.getcwd(), srcdir, 'Mac/Modules') moddirlist.append(macmoddir) @@ -789,7 +790,8 @@ # SunOS specific modules exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) ) - if platform == 'darwin': + if platform == 'darwin' and ("--disable-toolbox-glue" not in + sysconfig.get_config_var("CONFIG_ARGS")): # Mac OS X specific modules. exts.append( Extension('_CF', ['cf/_CFmodule.c', 'cf/pycfbridge.c'], extra_link_args=['-framework', 'CoreFoundation']) ) From bcannon at users.sourceforge.net Thu Aug 26 03:44:09 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Aug 26 03:44:14 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1114,1.1115 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19437/Misc Modified Files: NEWS Log Message: When building with --disable-toolbox-glue under Darwin, skip building any Mac-specific modules. Before all modules were compiled but would fail thanks to a dependence on the code included when Python was built without the compiler flag. Closes bug #991962. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1114 retrieving revision 1.1115 diff -u -d -r1.1114 -r1.1115 --- NEWS 26 Aug 2004 00:37:30 -0000 1.1114 +++ NEWS 26 Aug 2004 01:44:07 -0000 1.1115 @@ -139,6 +139,9 @@ Build ----- +- bug #991962: When building with --disable-toolbox-glue on Darwin no + attempt to build Mac-specific modules occurs. + - The --with-tsc flag to configure to enable VM profiling with the processor's timestamp counter now works on PPC platforms. From edloper at users.sourceforge.net Thu Aug 26 04:45:53 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 04:45:57 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29428/dist/src/Doc/lib Modified Files: libdoctest.tex Log Message: Added REPORT_ONLY_FIRST_FAILURE flag, which supresses output after the first failing example in each test. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- libdoctest.tex 26 Aug 2004 01:41:50 -0000 1.35 +++ libdoctest.tex 26 Aug 2004 02:45:50 -0000 1.36 @@ -364,6 +364,17 @@ positions. \end{datadesc} +\begin{datadesc}{REPORT_ONLY_FIRST_FAILURE} + When specified, display the first failing example in each doctest, + but suppress output for all remaining examples. This will prevent + doctest from reporting correct examples that break because of + earlier failures; but it might also hide incorrect examples that + fail independently of the first failure. When + \constant{REPORT_ONLY_FIRST_FAILURE} is specified, the remaining + examples are still run, and still count towards the total number of + failures reported; only the output is suppressed. +\end{datadesc} + A "doctest directive" is a trailing Python comment on a line of a doctest example: @@ -421,8 +432,8 @@ \versionchanged[Constants \constant{DONT_ACCEPT_BLANKLINE}, \constant{NORMALIZE_WHITESPACE}, \constant{ELLIPSIS}, - \constant{REPORT_UDIFF}, \constant{REPORT_CDIFF}, and - \constant{REPORT_NDIFF} + \constant{REPORT_UDIFF}, \constant{REPORT_CDIFF}, + \constant{REPORT_NDIFF}, and \constant{REPORT_ONLY_FIRST_FAILURE} were added; by default \code{} in expected output matches an empty line in actual output; and doctest directives were added]{2.4} From edloper at users.sourceforge.net Thu Aug 26 04:45:53 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 04:45:59 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.87,1.88 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29428/dist/src/Lib Modified Files: doctest.py Log Message: Added REPORT_ONLY_FIRST_FAILURE flag, which supresses output after the first failing example in each test. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- doctest.py 26 Aug 2004 01:41:51 -0000 1.87 +++ doctest.py 26 Aug 2004 02:45:50 -0000 1.88 @@ -260,6 +260,7 @@ REPORT_UDIFF = register_optionflag('REPORT_UDIFF') REPORT_CDIFF = register_optionflag('REPORT_CDIFF') REPORT_NDIFF = register_optionflag('REPORT_NDIFF') +REPORT_ONLY_FIRST_FAILURE = register_optionflag('REPORT_ONLY_FIRST_FAILURE') # Special string markers for use in `want` strings: BLANKLINE_MARKER = '' @@ -1280,7 +1281,6 @@ """ Report that the given example failed. """ - # Print an error message. out(self._failure_header(test, example) + self._checker.output_difference(example.want, got, self.optionflags)) @@ -1331,6 +1331,11 @@ # Process each example. for example in test.examples: + # If REPORT_ONLY_FIRST_FAILURE is set, then supress + # reporting after the first failure. + quiet = (self.optionflags & REPORT_ONLY_FIRST_FAILURE and + failures > 0) + # Merge in the example's options. self.optionflags = original_optionflags if example.options: @@ -1342,7 +1347,8 @@ # Record that we started this example. tries += 1 - self.report_start(out, test, example) + if not quiet: + self.report_start(out, test, example) # Run the example in the given context (globs), and record # any exception that gets raised. (But don't intercept @@ -1365,9 +1371,11 @@ if exception is None: if self._checker.check_output(example.want, got, self.optionflags): - self.report_success(out, test, example, got) + if not quiet: + self.report_success(out, test, example, got) else: - self.report_failure(out, test, example, got) + if not quiet: + self.report_failure(out, test, example, got) failures += 1 # If the example raised an exception, then check if it was @@ -1379,19 +1387,22 @@ # If `example.exc_msg` is None, then we weren't # expecting an exception. if example.exc_msg is None: - self.report_unexpected_exception(out, test, example, - exc_info) + if not quiet: + self.report_unexpected_exception(out, test, example, + exc_info) failures += 1 # If `example.exc_msg` matches the actual exception # message (`exc_msg`), then the example succeeds. elif (self._checker.check_output(example.exc_msg, exc_msg, self.optionflags)): - self.report_success(out, test, example, - got + _exception_traceback(exc_info)) + if not quiet: + got += _exception_traceback(exc_info) + self.report_success(out, test, example, got) # Otherwise, the example fails. else: - self.report_failure(out, test, example, - got + _exception_traceback(exc_info)) + if not quiet: + got += _exception_traceback(exc_info) + self.report_failure(out, test, example, got) failures += 1 # Restore the option flags (in case they were modified) @@ -1842,6 +1853,7 @@ REPORT_UDIFF REPORT_CDIFF REPORT_NDIFF + REPORT_ONLY_FIRST_FAILURE Optional keyword arg "raise_on_error" raises an exception on the first unexpected exception or failure. This allows failures to be From edloper at users.sourceforge.net Thu Aug 26 04:45:53 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 04:46:01 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.34, 1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29428/dist/src/Lib/test Modified Files: test_doctest.py Log Message: Added REPORT_ONLY_FIRST_FAILURE flag, which supresses output after the first failing example in each test. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- test_doctest.py 26 Aug 2004 01:41:51 -0000 1.34 +++ test_doctest.py 26 Aug 2004 02:45:51 -0000 1.35 @@ -1042,6 +1042,87 @@ ? + ++ ^ (1, 1) + +The REPORT_ONLY_FIRST_FAILURE supresses result output after the first +failing example: + + >>> def f(x): + ... r''' + ... >>> print 1 # first success + ... 1 + ... >>> print 2 # first failure + ... 200 + ... >>> print 3 # second failure + ... 300 + ... >>> print 4 # second success + ... 4 + ... >>> print 5 # third failure + ... 500 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.REPORT_ONLY_FIRST_FAILURE + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + ********************************************************************** + Line 4, in f + Failed example: + print 2 # first failure + Expected: + 200 + Got: + 2 + (3, 5) + +However, output from `report_start` is not supressed: + + >>> doctest.DocTestRunner(verbose=True, optionflags=flags).run(test) + Trying: + print 1 # first success + Expecting: + 1 + ok + Trying: + print 2 # first failure + Expecting: + 200 + ********************************************************************** + Line 4, in f + Failed example: + print 2 # first failure + Expected: + 200 + Got: + 2 + (3, 5) + +For the purposes of REPORT_ONLY_FIRST_FAILURE, unexpected exceptions +count as failures: + + >>> def f(x): + ... r''' + ... >>> print 1 # first success + ... 1 + ... >>> raise ValueError(2) # first failure + ... 200 + ... >>> print 3 # second failure + ... 300 + ... >>> print 4 # second success + ... 4 + ... >>> print 5 # third failure + ... 500 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.REPORT_ONLY_FIRST_FAILURE + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + Line 4, in f + Failed example: + raise ValueError(2) # first failure + Exception raised: + ... + ValueError: 2 + (3, 5) + """ def option_directives(): r""" From edloper at users.sourceforge.net Thu Aug 26 05:00:34 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 05:00:37 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.88,1.89 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31499/dist/src/Lib Modified Files: doctest.py Log Message: Changed OutputChecker.output_difference to expect an Example object, rather than an expected output string. This gives the output_difference method access to more information, such as the indentation of the example, which might be useful. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.88 retrieving revision 1.89 diff -u -d -r1.88 -r1.89 --- doctest.py 26 Aug 2004 02:45:50 -0000 1.88 +++ doctest.py 26 Aug 2004 03:00:24 -0000 1.89 @@ -1282,8 +1282,7 @@ Report that the given example failed. """ out(self._failure_header(test, example) + - self._checker.output_difference(example.want, got, - self.optionflags)) + self._checker.output_difference(example, got, self.optionflags)) def report_unexpected_exception(self, out, test, example, exc_info): """ @@ -1608,13 +1607,14 @@ # The other diff types need at least a few lines to be helpful. return want.count('\n') > 2 and got.count('\n') > 2 - def output_difference(self, want, got, optionflags): + def output_difference(self, example, got, optionflags): """ Return a string describing the differences between the - expected output for an example (`want`) and the actual output - (`got`). `optionflags` is the set of option flags used to - compare `want` and `got`. + expected output for a given example (`example`) and the actual + output (`got`). `optionflags` is the set of option flags used + to compare `want` and `got`. """ + want = example.want # If s are being used, then replace blank lines # with in the actual output string. if not (optionflags & DONT_ACCEPT_BLANKLINE): From rhettinger at users.sourceforge.net Thu Aug 26 05:11:58 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Aug 26 05:12:00 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv627 Modified Files: libdecimal.tex Log Message: Small wording fixups. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- libdecimal.tex 16 Aug 2004 16:12:23 -0000 1.17 +++ libdecimal.tex 26 Aug 2004 03:11:56 -0000 1.18 @@ -839,7 +839,7 @@ The effects of round-off error can be amplified by the addition or subtraction of nearly offsetting quantities resulting in loss of significance. Knuth provides two instructive examples where rounded floating point arithmetic with -insufficient precision causes the break down of the associative and +insufficient precision causes the breakdown of the associative and distributive properties of addition: \begin{verbatim} @@ -893,7 +893,7 @@ where they get treated as very large, indeterminate numbers. For instance, adding a constant to infinity gives another infinite result. -Some operations are indeterminate and return \constant{NaN} or when the +Some operations are indeterminate and return \constant{NaN}, or if the \exception{InvalidOperation} signal is trapped, raise an exception. For example, \code{0/0} returns \constant{NaN} which means ``not a number''. This variety of \constant{NaN} is quiet and, once created, will flow through other @@ -909,11 +909,11 @@ The signed zeros can result from calculations that underflow. They keep the sign that would have resulted if the calculation had been carried out to greater precision. Since their magnitude is -zero, the positive and negative zero are treated as equal and their +zero, both positive and negative zeros are treated as equal and their sign is informational. -In addition to the two signed zeros which are distinct, yet equal, -there are various representations of zero with differing precisions, +In addition to the two signed zeros which are distinct yet equal, +there are various representations of zero with differing precisions yet equivalent in value. This takes a bit of getting used to. For an eye accustomed to normalized floating point representations, it is not immediately obvious that the following calculation returns From rhettinger at users.sourceforge.net Thu Aug 26 06:29:49 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Aug 26 06:29:53 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_deque.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12089 Modified Files: test_deque.py Log Message: Remove unnecessary line. Index: test_deque.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_deque.py,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- test_deque.py 9 Jul 2004 04:10:20 -0000 1.13 +++ test_deque.py 26 Aug 2004 04:29:47 -0000 1.14 @@ -579,7 +579,6 @@ def test_main(verbose=None): import sys - from test import test_sets test_classes = ( TestBasic, TestVariousIteratorArgs, From tim_one at users.sourceforge.net Thu Aug 26 06:47:33 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 26 06:47:36 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13629/Doc/lib Modified Files: libdoctest.tex Log Message: Reorg of exception section. Now that there are fewer details needing explanation, it's easier to push the remaining insufferably anal details into a "fine print" section at the bottom. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- libdoctest.tex 26 Aug 2004 02:45:50 -0000 1.36 +++ libdoctest.tex 26 Aug 2004 04:47:31 -0000 1.37 @@ -221,12 +221,13 @@ \subsection{What About Exceptions?} -No problem: just paste in the expected traceback. Since -tracebacks contain details that are likely to change -rapidly (for example, exact file paths and line numbers), this is one -case where doctest works hard to be flexible in what it accepts. -This makes the full story involved, but you really don't have -to remember much. Simple example: +No problem, provided that the traceback is the only output produced by +the example: just paste in the traceback. Since tracebacks contain +details that are likely to change rapidly (for example, exact file paths +and line numbers), this is one case where doctest works hard to be +flexible in what it accepts. + +Simple example: \begin{verbatim} >>> [1, 2, 3].remove(42) @@ -236,9 +237,7 @@ \end{verbatim} That doctest succeeds if \exception{ValueError} is raised, with the -\samp{list.remove(x): x not in list} detail as shown.\footnote{The - doctest also succeeds if it prints the exact text of the traceback - message; otherwise, it fails.} +\samp{list.remove(x): x not in list} detail as shown. The expected output for an exception must start with a traceback header, which may be either of the following two lines, indented the @@ -250,17 +249,13 @@ \end{verbatim} The traceback header is followed by an optional traceback stack, whose -contents are ignored by doctest. Each line of the traceback stack -must be indented further than the first line of the example, \emph{or} -start with a non-alphanumeric character. Typically, the traceback -stack is either omitted or copied verbatim from an interactive -session. +contents are ignored by doctest. The traceback stack is typically +omitted, or copied verbatim from an interactive session. -The traceback stack is followed by the most interesting part: the +The traceback stack is followed by the most interesting part: the line(s) containing the exception type and detail. This is usually the last line of a traceback, but can extend across multiple lines if the -exception has a multi-line detail, as illustrated in the following -example: +exception has a multi-line detail: \begin{verbatim} >>> raise ValueError('multi\n line\ndetail') @@ -276,7 +271,7 @@ ignored. Best practice is to omit the traceback stack, unless it adds -significant documentation value to the example. So the example above +significant documentation value to the example. So the last example is probably better as: \begin{verbatim} @@ -288,14 +283,36 @@ detail \end{verbatim} -Note the tracebacks are treated very specially. In particular, in the +Note that tracebacks are treated very specially. In particular, in the rewritten example, the use of \samp{...} is independent of doctest's -\constant{ELLIPSIS} option. The ellipsis in that example could -be left out, or could just as well be three (or three hundred) commas. +\constant{ELLIPSIS} option. The ellipsis in that example could be left +out, or could just as well be three (or three hundred) commas or digits, +or an indented transcript of a Monty Python skit. + +Some details you should read once, but won't need to remember: + +\begin{itemize} + +\item Doctest can't guess whether your expected output came from an + exception traceback or from ordinary printing. So, e.g., an example + that expects \samp{ValueError: 42 is prime} will pass whether + \exception{ValueError} is actually raised or if the example merely + prints that traceback text. In practice, ordinary output rarely begins + with a traceback header line, so this doesn't create real problems. + +\item Each line of the traceback stack (if present) must be indented + further than the first line of the example, \emph{or} start with a + non-alphanumeric character. The first line following the traceback + header indented the same and starting with an alphanumeric is taken + to be the start of the exception detail. Of course this does the + right thing for genuine tracebacks. + +\end{itemize} \versionchanged[The ability to handle a multi-line exception detail was added]{2.4} + \subsection{Option Flags and Directives\label{doctest-options}} A number of option flags control various aspects of doctest's comparison @@ -303,6 +320,10 @@ which can be or'ed together and passed to various functions. The names can also be used in 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: + \begin{datadesc}{DONT_ACCEPT_TRUE_FOR_1} By default, if an expected output block contains just \code{1}, an actual output block containing just \code{1} or just @@ -344,6 +365,8 @@ is prone to in regular expressions. \end{datadesc} +The second group of options controls how test failures are displayed: + \begin{datadesc}{REPORT_UDIFF} When specified, failures that involve multi-line expected and actual outputs are displayed using a unified diff. @@ -406,7 +429,7 @@ Without the directive it would fail, both because the actual output doesn't have two blanks before the single-digit list elements, and because the actual output is on a single line. This test also passes, -and requires a directive to do so: +and also requires a directive to do so: \begin{verbatim} >>> print range(20) # doctest:+ELLIPSIS From tim_one at users.sourceforge.net Thu Aug 26 06:50:40 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 26 06:50:42 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14876/Doc/lib Modified Files: libdoctest.tex Log Message: Thinko repair. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- libdoctest.tex 26 Aug 2004 04:47:31 -0000 1.37 +++ libdoctest.tex 26 Aug 2004 04:50:38 -0000 1.38 @@ -315,7 +315,7 @@ \subsection{Option Flags and Directives\label{doctest-options}} -A number of option flags control various aspects of doctest's comparison +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 doctest directives (see below). From tim_one at users.sourceforge.net Thu Aug 26 06:52:48 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 26 06:52:50 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdoctest.tex,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15277/Doc/lib Modified Files: libdoctest.tex Log Message: Fine tune a word. Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- libdoctest.tex 26 Aug 2004 04:50:38 -0000 1.38 +++ libdoctest.tex 26 Aug 2004 04:52:46 -0000 1.39 @@ -365,7 +365,7 @@ is prone to in regular expressions. \end{datadesc} -The second group of options controls how test failures are displayed: +The second group of options controls how test failures are reported: \begin{datadesc}{REPORT_UDIFF} When specified, failures that involve multi-line expected and From tim_one at users.sourceforge.net Thu Aug 26 07:22:01 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 26 07:22:04 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.89,1.90 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18753/Lib Modified Files: doctest.py Log Message: _do_a_fancy_diff(): Pay no attention to the ellipses behind the curtain. While a fancy diff can be confusing in the presence of ellipses, so far I'm finding (2-0-0) that it's much more a major aid in narrowing down the possibilities when an ellipsis-slinging test fails. So we no longer refuse to do a fancy diff just because of ellipses. This isn't ideal; it's just better. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.89 retrieving revision 1.90 diff -u -d -r1.89 -r1.90 --- doctest.py 26 Aug 2004 03:00:24 -0000 1.89 +++ doctest.py 26 Aug 2004 05:21:59 -0000 1.90 @@ -1596,14 +1596,20 @@ REPORT_CDIFF | REPORT_NDIFF): return False + # If expected output uses ellipsis, a meaningful fancy diff is - # too hard. - if optionflags & ELLIPSIS and ELLIPSIS_MARKER in want: - return False + # too hard ... or maybe not. In two real-life failures Tim saw, + # a diff was a major help anyway, so this is commented out. + # [todo] _ellipsis_match() knows which pieces do and don't match, + # and could be the basis for a kick-ass diff in this case. + ##if optionflags & ELLIPSIS and ELLIPSIS_MARKER in want: + ## return False + # ndiff does intraline difference marking, so can be useful even - # for 1-line inputs. + # for 1-line differences. if optionflags & REPORT_NDIFF: return True + # The other diff types need at least a few lines to be helpful. return want.count('\n') > 2 and got.count('\n') > 2 @@ -1620,9 +1626,7 @@ if not (optionflags & DONT_ACCEPT_BLANKLINE): got = re.sub('(?m)^[ ]*(?=\n)', BLANKLINE_MARKER, got) - # Check if we should use diff. Don't use diff if the actual - # or expected outputs are too short, or if the expected output - # contains an ellipsis marker. + # Check if we should use diff. if self._do_a_fancy_diff(want, got, optionflags): # Split want & got into lines. want_lines = [l+'\n' for l in want.split('\n')] From tim_one at users.sourceforge.net Thu Aug 26 07:23:21 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 26 07:23:25 2004 Subject: [Python-checkins] python/dist/src setup.py,1.199,1.200 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19472 Modified Files: setup.py Log Message: Whitespace normalization. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.199 retrieving revision 1.200 diff -u -d -r1.199 -r1.200 --- setup.py 26 Aug 2004 01:44:06 -0000 1.199 +++ setup.py 26 Aug 2004 05:23:19 -0000 1.200 @@ -119,7 +119,7 @@ # Platform-dependent module source and include directories platform = self.get_platform() - if platform in ('darwin', 'mac') and ("--disable-toolbox-glue" not in + if platform in ('darwin', 'mac') 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(os.getcwd(), srcdir, 'Mac/Modules') @@ -790,7 +790,7 @@ # SunOS specific modules exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) ) - if platform == 'darwin' and ("--disable-toolbox-glue" not in + if platform == 'darwin' and ("--disable-toolbox-glue" not in sysconfig.get_config_var("CONFIG_ARGS")): # Mac OS X specific modules. exts.append( Extension('_CF', ['cf/_CFmodule.c', 'cf/pycfbridge.c'], From tim_one at users.sourceforge.net Thu Aug 26 07:23:22 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 26 07:23:27 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_capi.py, 1.7, 1.8 test_peepholer.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19472/Lib/test Modified Files: test_capi.py test_peepholer.py Log Message: Whitespace normalization. Index: test_capi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_capi.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- test_capi.py 24 Aug 2004 22:24:08 -0000 1.7 +++ test_capi.py 26 Aug 2004 05:23:19 -0000 1.8 @@ -46,4 +46,3 @@ import threading t=threading.Thread(target=TestThreadState) t.start() - Index: test_peepholer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_peepholer.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- test_peepholer.py 23 Aug 2004 23:37:47 -0000 1.1 +++ test_peepholer.py 26 Aug 2004 05:23:19 -0000 1.2 @@ -42,8 +42,8 @@ def test_none_as_constant(self): # LOAD_GLOBAL None --> LOAD_CONST None def f(x): - None - return x + None + return x asm = disassemble(f) for elem in ('LOAD_GLOBAL',): self.assert_(elem not in asm) @@ -53,9 +53,9 @@ def test_while_one(self): # Skip over: LOAD_CONST trueconst JUMP_IF_FALSE xx POP_TOP def f(): - while 1: - pass - return list + while 1: + pass + return list asm = disassemble(f) for elem in ('LOAD_CONST', 'JUMP_IF_FALSE'): self.assert_(elem not in asm) From tim_one at users.sourceforge.net Thu Aug 26 07:23:22 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 26 07:23:29 2004 Subject: [Python-checkins] python/dist/src/Tools/msi msi.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19472/Tools/msi Modified Files: msi.py Log Message: Whitespace normalization. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/msi/msi.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- msi.py 22 Aug 2004 17:10:12 -0000 1.2 +++ msi.py 26 Aug 2004 05:23:19 -0000 1.3 @@ -111,7 +111,7 @@ '_winreg.pyd', 'datetime.pyd' 'mmap.pyd', - 'parser.pyd', + 'parser.pyd', ]) if testpackage: @@ -151,7 +151,7 @@ w64 = ".ia64" else: w64 = "" - db = msilib.init_database("python-%s%s.msi" % (full_current_version, w64), + db = msilib.init_database("python-%s%s.msi" % (full_current_version, w64), schema, ProductName="Python "+full_current_version, ProductCode=product_code, ProductVersion=current_version, @@ -196,10 +196,10 @@ # a release, we remove all snapshots, and all earlier releases. if snapshot: add_data(db, "Upgrade", - [(upgrade_code_snapshot, start, + [(upgrade_code_snapshot, start, current_version, None, # Ignore language - migrate_features, + migrate_features, None, # Migrate ALL features "REMOVEOLDSNAPSHOT")]) props = "REMOVEOLDSNAPSHOT" @@ -400,7 +400,7 @@ # to the action, and optionally the condition for the event, and the order # of events. c.event("EndDialog", "Exit") - + user_exit=PyDialog(db, "UserExit", x, y, w, h, modal, title, "Finish", "Finish", "Finish") user_exit.title("[ProductName] Installer was interrupted") @@ -413,7 +413,7 @@ "Click the Finish button to exit the Installer.") c = user_exit.next("Finish", "Cancel", name="Finish") c.event("EndDialog", "Exit") - + exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title, "Finish", "Finish", "Finish") exit_dialog.title("Completing the [ProductName] Installer") @@ -426,7 +426,7 @@ "\n" " Mark Hammond, without whose years of freely shared Windows\n" " expertise, Python for Windows would still be Python for DOS.") - + exit_dialog.text("Description", 135, 235, 220, 20, 0x30003, "Click the Finish button to exit the Installer.") c = exit_dialog.next("Finish", "Cancel", name="Finish") @@ -475,13 +475,13 @@ # Global "Query Cancel" dialog cancel = Dialog(db, "CancelDlg", 50, 10, 260, 85, 3, title, "No", "No", "No") - cancel.text("Text", 48, 15, 194, 30, 3, + cancel.text("Text", 48, 15, 194, 30, 3, "Are you sure you want to cancel [ProductName] installation?") cancel.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None, "py.ico", None, None) c=cancel.pushbutton("Yes", 72, 57, 56, 17, 3, "Yes", "No") c.event("EndDialog", "Exit") - + c=cancel.pushbutton("No", 132, 57, 56, 17, 3, "No", "Yes") c.event("EndDialog", "Return") @@ -566,14 +566,14 @@ c=features.cancel("Cancel", "Tree") c.event("SpawnDialog", "CancelDlg") - # The browse property is not used, since we have only a single target path (selected already) + # The browse property is not used, since we have only a single target path (selected already) features.control("Tree", "SelectionTree", 135, 75, 220, 95, 7, "_BrowseProperty", "Tree of selections", "Back", None) #c=features.pushbutton("Reset", 42, 243, 56, 17, 3, "Reset", "DiskCost") #c.mapping("SelectionNoItems", "Enabled") #c.event("Reset", "0") - + features.control("Box", "GroupBox", 135, 170, 225, 90, 1, None, None, None, None) c=features.xbutton("DiskCost", "Disk &Usage", None, 0.10) @@ -586,7 +586,7 @@ 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, 210, 210, 45, 3, "The size of the currently selected item.") c.mapping("SelectionSize", "Text") @@ -629,7 +629,7 @@ g.add("ALL", 0, 5, 150, 20, "Install for all users") g.add("JUSTME", 0, 25, 150, 20, "Install just for me") - whichusers.back("Back", None, active=0) + whichusers.back("Back", None, active=0) c = whichusers.next("Next >", "Cancel") c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1) @@ -637,7 +637,7 @@ c = whichusers.cancel("Cancel", "AdminInstall") c.event("SpawnDialog", "CancelDlg") - + ##################################################################### # Advanced Dialog. advanced = PyDialog(db, "AdvancedDlg", x, y, w, h, modal, title, @@ -652,9 +652,9 @@ c = advanced.cancel("Cancel", "CompilePyc") c.event("SpawnDialog", "CancelDlg") - + ##################################################################### - # Existing Directory dialog + # Existing Directory dialog dlg = Dialog(db, "ExistingDirectoryDlg", 50, 30, 200, 80, modal, title, "No", "No", "No") dlg.text("Title", 10, 20, 180, 40, 3, @@ -702,7 +702,7 @@ g.add("Change", 0, 0, 200, 17, "&Change [ProductName]") g.add("Repair", 0, 18, 200, 17, "&Repair [ProductName]") g.add("Remove", 0, 36, 200, 17, "Re&move [ProductName]") - + maint.back("< Back", None, active=False) c=maint.next("Finish", "Cancel") # Change installation: Change progress dialog to "Change", then ask @@ -724,12 +724,12 @@ c.event("[Progress2]", "removes", 'MaintenanceForm_Action="Remove"', 13) c.event("Remove", "ALL", 'MaintenanceForm_Action="Remove"', 14) - # Close dialog when maintenance action scheduled + # Close dialog when maintenance action scheduled c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20) c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21) - + maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg") - + # See "Feature Table". The feature level is 1 for all features, # and the feature attributes are 0 for the DefaultFeature, and @@ -765,12 +765,12 @@ htmlfiles = Feature(db, "Documentation", "Documentation", "Python HTMLHelp File", 7, parent = default_feature) tools = Feature(db, "Tools", "Utility Scripts", - "Python utility scripts (Tools/", 9, + "Python utility scripts (Tools/", 9, parent = default_feature, attributes=2) testsuite = Feature(db, "Testsuite", "Test suite", "Python test suite (Lib/test/)", 11, parent = default_feature, attributes=2|8) - + def extract_msvcr71(): import _winreg @@ -840,7 +840,7 @@ dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"), version=version, language=lang) tmpfiles.append("msvcr71.dll") - + # Add all .py files in Lib, except lib-tk, test dirs={} pydirs = [(root,"Lib")] @@ -925,7 +925,7 @@ if f.endswith("_d.pyd"): continue # debug version if f in dlls: continue print "WARNING: Unknown extension", f - + # Add headers default_feature.set_current() lib = PyDirectory(db, cab, root, "include", "include", "INCLUDE|include") @@ -1022,7 +1022,7 @@ [("Python.File", None, None, "Python File", "python_icon.exe", 0), ("Python.NoConFile", None, None, "Python File (no console)", "python_icon.exe", 0), ("Python.CompiledFile", None, None, "Compiled Python File", "python_icon.exe", 1)]) - + # Non-advertised verbs: for advertised verbs, we would need to invoke the same # executable for both open and "Edit with IDLE". This cannot work, as we want # to use pythonw.exe in either case @@ -1035,7 +1035,7 @@ r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"', "REGISTRY.tcl"), ]) - + # Registry keys prefix = r"Software\%sPython\PythonCore\%s" % (testprefix, short_version) add_data(db, "Registry", From loewis at users.sourceforge.net Thu Aug 26 07:44:04 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Aug 26 07:44:08 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils/tests test_build_scripts.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22127/Lib/distutils/tests Modified Files: test_build_scripts.py Log Message: Add missing executable option to DummyCommand. Index: test_build_scripts.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/tests/test_build_scripts.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- test_build_scripts.py 3 Aug 2004 18:53:07 -0000 1.3 +++ test_build_scripts.py 26 Aug 2004 05:44:02 -0000 1.4 @@ -39,11 +39,13 @@ self.assert_(name in built) def get_build_scripts_cmd(self, target, scripts): + import sys dist = Distribution() dist.scripts = scripts dist.command_obj["build"] = support.DummyCommand( build_scripts=target, - force=1 + force=1, + executable=sys.executable ) return build_scripts(dist) From tim_one at users.sourceforge.net Thu Aug 26 07:44:29 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 26 07:44:32 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.90,1.91 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21813/Lib Modified Files: doctest.py Log Message: output_difference(): In fancy-diff cases, the way this split expected & actual output into lines created spurious empty lines at the ends of each. Those matched, but the fancy diffs had surprising line counts (1 larger than expected), and tests kept having to slam into the expected output to account for this. Using the splitlines() string method with keepends=True instead accomplishes what was intended directly. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.90 retrieving revision 1.91 diff -u -d -r1.90 -r1.91 --- doctest.py 26 Aug 2004 05:21:59 -0000 1.90 +++ doctest.py 26 Aug 2004 05:44:27 -0000 1.91 @@ -1629,8 +1629,8 @@ # Check if we should use diff. if self._do_a_fancy_diff(want, got, optionflags): # Split want & got into lines. - want_lines = [l+'\n' for l in want.split('\n')] - got_lines = [l+'\n' for l in got.split('\n')] + want_lines = want.splitlines(True) # True == keep line ends + got_lines = got.splitlines(True) # Use difflib to find their differences. if optionflags & REPORT_UDIFF: diff = difflib.unified_diff(want_lines, got_lines, n=2) From tim_one at users.sourceforge.net Thu Aug 26 07:44:29 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Aug 26 07:44:34 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.35, 1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21813/Lib/test Modified Files: test_doctest.py Log Message: output_difference(): In fancy-diff cases, the way this split expected & actual output into lines created spurious empty lines at the ends of each. Those matched, but the fancy diffs had surprising line counts (1 larger than expected), and tests kept having to slam into the expected output to account for this. Using the splitlines() string method with keepends=True instead accomplishes what was intended directly. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- test_doctest.py 26 Aug 2004 02:45:51 -0000 1.35 +++ test_doctest.py 26 Aug 2004 05:44:27 -0000 1.36 @@ -972,7 +972,7 @@ Failed example: print '\n'.join('abcdefg') Differences (unified diff with -expected +actual): - @@ -1,8 +1,8 @@ + @@ -1,7 +1,7 @@ a -B +b @@ -982,7 +982,6 @@ f g -h - (1, 1) The REPORT_CDIFF flag causes failures that involve multi-line expected @@ -998,7 +997,7 @@ print '\n'.join('abcdefg') Differences (context diff with expected followed by actual): *************** - *** 1,8 **** + *** 1,7 **** a ! B c @@ -1006,8 +1005,7 @@ f g - h - - --- 1,8 ---- + --- 1,7 ---- a ! b c @@ -1015,7 +1013,6 @@ + e f g - (1, 1) @@ -1040,7 +1037,6 @@ ? ^ + a b c d e f g h i j k l m ? + ++ ^ - (1, 1) The REPORT_ONLY_FIRST_FAILURE supresses result output after the first From jlgijsbers at users.sourceforge.net Thu Aug 26 12:40:15 2004 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Thu Aug 26 12:40:19 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libcgitb.tex,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3063 Modified Files: libcgitb.tex Log Message: Correct incorrect "it's" to "its". Index: libcgitb.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcgitb.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- libcgitb.tex 17 Jun 2003 12:58:31 -0000 1.4 +++ libcgitb.tex 26 Aug 2004 10:40:12 -0000 1.5 @@ -13,7 +13,7 @@ \index{tracebacks!in CGI scripts} The \module{cgitb} module provides a special exception handler for Python -scripts. (It's name is a bit misleading. It was originally designed to +scripts. (Its name is a bit misleading. It was originally designed to display extensive traceback information in HTML for CGI scripts. It was later generalized to also display this information in plain text.) After this module is activated, if an uncaught exception occurs, a detailed, From doerwalter at users.sourceforge.net Thu Aug 26 18:53:07 2004 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu Aug 26 18:53:10 2004 Subject: [Python-checkins] python/dist/src/Lib/test string_tests.py, 1.39, 1.40 test_str.py, 1.3, 1.4 test_string.py, 1.26, 1.27 test_unicode.py, 1.92, 1.93 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9674/Lib/test Modified Files: string_tests.py test_str.py test_string.py test_unicode.py Log Message: Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that it can be used for str and unicode. Drop the test for "".join([s]) is s because this is an implementation detail (and doesn't work for unicode) Index: string_tests.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- string_tests.py 4 Aug 2004 07:38:33 -0000 1.39 +++ string_tests.py 26 Aug 2004 16:53:04 -0000 1.40 @@ -648,6 +648,7 @@ else: self.checkcall(format, "__mod__", value) + class MixinStrStringUserStringTest: # Additional tests for 8bit strings, i.e. str, UserString and # the string module @@ -695,3 +696,21 @@ self.checkraises(TypeError, 'xyz', 'decode', 42) self.checkraises(TypeError, 'xyz', 'encode', 42) + + +class MixinStrUnicodeTest: + # Additional tests that only work with + # str and unicode + + def test_bug1001011(self): + # Make sure join returns a NEW object for single item sequences + # involving a subclass + # Make sure that it is of the appropriate type + # Check the optimisation still occurs for standard objects + t = self.type2test + class subclass(t): + pass + s1 = subclass("abcd") + s2 = t().join([s1]) + self.assert_(s1 is not s2) + self.assert_(type(s2) is t) Index: test_str.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_str.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- test_str.py 1 May 2003 17:45:50 -0000 1.3 +++ test_str.py 26 Aug 2004 16:53:04 -0000 1.4 @@ -5,7 +5,8 @@ class StrTest( string_tests.CommonTest, string_tests.MixinStrUnicodeUserStringTest, - string_tests.MixinStrUserStringTest + string_tests.MixinStrUserStringTest, + string_tests.MixinStrUnicodeTest, ): type2test = str Index: test_string.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_string.py,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- test_string.py 23 Aug 2004 23:23:53 -0000 1.26 +++ test_string.py 26 Aug 2004 16:53:04 -0000 1.27 @@ -52,28 +52,6 @@ self.checkraises(TypeError, string_tests.BadSeq1(), 'join', ' ') self.checkequal('a b c', string_tests.BadSeq2(), 'join', ' ') - def test_bug1001011(self): - # Make sure join returns a NEW object for single item sequences - # involving a subclass - # Make sure that it is of the appropriate type - # Check the optimisation still occurs for standard objects - class str_subclass(str): pass - s1 = str_subclass('abcd') - s2 = ''.join([s1]) - self.failIf(s1 is s2) - self.assertEqual(type(s2), type('')) - s3 = 'abcd' - s4 = ''.join([s3]) - self.failUnless(s3 is s4) - if test_support.have_unicode: - class unicode_subclass(unicode): pass - u1 = unicode_subclass(u'abcd') - u2 = ''.join([u1]) - self.failIf(u1 is u2) - self.assertEqual(type(u2), type(u'')) - u3 = u'abcd' - u4 = ''.join([u3]) - self.failUnless(u3 is u4) class ModuleTest(unittest.TestCase): Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.92 retrieving revision 1.93 diff -u -d -r1.92 -r1.93 --- test_unicode.py 4 Aug 2004 07:38:33 -0000 1.92 +++ test_unicode.py 26 Aug 2004 16:53:04 -0000 1.93 @@ -11,7 +11,8 @@ class UnicodeTest( string_tests.CommonTest, - string_tests.MixinStrUnicodeUserStringTest + string_tests.MixinStrUnicodeUserStringTest, + string_tests.MixinStrUnicodeTest, ): type2test = unicode From edloper at users.sourceforge.net Thu Aug 26 20:05:12 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 20:05:15 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.36, 1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25636/dist/src/Lib/test Modified Files: test_doctest.py Log Message: - Added DocTestParser.parse(), which parses a docstring into Examples and intervening text strings. - Removed DocTestParser.get_program(): use script_from_examples() instead. - Fixed bug in DocTestParser._INDENT_RE - Fixed bug in DocTestParser._min_indent - Moved _want_comment() to the utility function section Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- test_doctest.py 26 Aug 2004 05:44:27 -0000 1.36 +++ test_doctest.py 26 Aug 2004 18:05:07 -0000 1.37 @@ -283,7 +283,7 @@ ... ''' >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): - ValueError: line 4 of the docstring for some_test has inconsistent leading whitespace: ' indentation' + ValueError: line 4 of the docstring for some_test has inconsistent leading whitespace: 'indentation' If the docstring contains inconsistent leading whitespace on continuation lines, then `DocTest` will raise a ValueError: @@ -295,7 +295,7 @@ ... ''' >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): - ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: ' ... 2)' + ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: '... 2)' If there's no blank space after a PS1 prompt ('>>>'), then `DocTest` will raise a ValueError: @@ -553,6 +553,61 @@ [1, 9, 12] """ +def test_DocTestParser(): r""" +Unit tests for the `DocTestParser` class. + +DocTestParser is used to parse docstrings containing doctest examples. + +The `parse` method divides a docstring into examples and intervening +text: + + >>> s = ''' + ... >>> x, y = 2, 3 # no output expected + ... >>> if 1: + ... ... print x + ... ... print y + ... 2 + ... 3 + ... + ... Some text. + ... >>> x+y + ... 5 + ... ''' + >>> parser = doctest.DocTestParser() + >>> for piece in parser.parse(s): + ... if isinstance(piece, doctest.Example): + ... print 'Example:', (piece.source, piece.want, piece.lineno) + ... else: + ... print ' Text:', `piece` + Text: '\n' + Example: ('x, y = 2, 3 # no output expected\n', '', 1) + Text: '' + Example: ('if 1:\n print x\n print y\n', '2\n3\n', 2) + Text: '\nSome text.\n' + Example: ('x+y\n', '5\n', 9) + Text: '' + +The `get_examples` method returns just the examples: + + >>> for piece in parser.get_examples(s): + ... print (piece.source, piece.want, piece.lineno) + ('x, y = 2, 3 # no output expected\n', '', 1) + ('if 1:\n print x\n print y\n', '2\n3\n', 2) + ('x+y\n', '5\n', 9) + +The `get_doctest` method creates a Test from the examples, along with the +given arguments: + + >>> test = parser.get_doctest(s, {}, 'name', 'filename', lineno=5) + >>> (test.name, test.filename, test.lineno) + ('name', 'filename', 5) + >>> for piece in test.examples: + ... print (piece.source, piece.want, piece.lineno) + ('x, y = 2, 3 # no output expected\n', '', 1) + ('if 1:\n print x\n print y\n', '2\n3\n', 2) + ('x+y\n', '5\n', 9) +""" + class test_DocTestRunner: def basics(): r""" Unit tests for the `DocTestRunner` class. From edloper at users.sourceforge.net Thu Aug 26 20:05:40 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Thu Aug 26 20:05:43 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.91,1.92 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25636/dist/src/Lib Modified Files: doctest.py Log Message: - Added DocTestParser.parse(), which parses a docstring into Examples and intervening text strings. - Removed DocTestParser.get_program(): use script_from_examples() instead. - Fixed bug in DocTestParser._INDENT_RE - Fixed bug in DocTestParser._min_indent - Moved _want_comment() to the utility function section Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.91 retrieving revision 1.92 diff -u -d -r1.91 -r1.92 --- doctest.py 26 Aug 2004 05:44:27 -0000 1.91 +++ doctest.py 26 Aug 2004 18:05:06 -0000 1.92 @@ -433,6 +433,14 @@ return True +def _comment_line(line): + "Return a commented form of the given line" + line = line.rstrip() + if line: + return '# '+line + else: + return '#' + ###################################################################### ## 2. Example & DocTest ###################################################################### @@ -606,6 +614,45 @@ # or contains a single comment. _IS_BLANK_OR_COMMENT = re.compile(r'^[ ]*(#.*)?$').match + def parse(self, string, name=''): + """ + Divide the given string into examples and intervening text, + and return them as a list of alternating Examples and strings. + Line numbers for the Examples are 0-based. The optional + argument `name` is a name identifying this string, and is only + used for error messages. + """ + string = string.expandtabs() + # If all lines begin with the same indentation, then strip it. + min_indent = self._min_indent(string) + if min_indent > 0: + string = '\n'.join([l[min_indent:] for l in string.split('\n')]) + + output = [] + charno, lineno = 0, 0 + # Find all doctest examples in the string: + for m in self._EXAMPLE_RE.finditer(string.expandtabs()): + # Add the pre-example text to `output`. + output.append(string[charno:m.start()]) + # Update lineno (lines before this example) + lineno += string.count('\n', charno, m.start()) + # Extract info from the regexp match. + (source, options, want, exc_msg) = \ + self._parse_example(m, name, lineno) + # Create an Example, and add it to the list. + if not self._IS_BLANK_OR_COMMENT(source): + output.append( Example(source, want, exc_msg, + lineno=lineno, + indent=min_indent+len(m.group('indent')), + options=options) ) + # Update lineno (lines inside this example) + lineno += string.count('\n', m.start(), m.end()) + # Update charno. + charno = m.end() + # Add any remaining post-example text to `output`. + output.append(string[charno:]) + return output + def get_doctest(self, string, globs, name, filename, lineno): """ Extract all doctest examples from the given string, and @@ -628,124 +675,9 @@ The optional argument `name` is a name identifying this string, and is only used for error messages. - - >>> text = ''' - ... >>> x, y = 2, 3 # no output expected - ... >>> if 1: - ... ... print x - ... ... print y - ... 2 - ... 3 - ... - ... Some text. - ... >>> x+y - ... 5 - ... ''' - >>> for x in DocTestParser().get_examples(text): - ... print (x.source, x.want, x.lineno) - ('x, y = 2, 3 # no output expected\\n', '', 1) - ('if 1:\\n print x\\n print y\\n', '2\\n3\\n', 2) - ('x+y\\n', '5\\n', 9) """ - examples = [] - charno, lineno = 0, 0 - # Find all doctest examples in the string: - for m in self._EXAMPLE_RE.finditer(string.expandtabs()): - # Update lineno (lines before this example) - lineno += string.count('\n', charno, m.start()) - # Extract source/want from the regexp match. - (source, want, exc_msg) = self._parse_example(m, name, lineno) - # Extract extra options from the source. - options = self._find_options(source, name, lineno) - # Create an Example, and add it to the list. - if not self._IS_BLANK_OR_COMMENT(source): - examples.append( Example(source, want, exc_msg, - lineno=lineno, - indent=len(m.group('indent')), - options=options) ) - # Update lineno (lines inside this example) - lineno += string.count('\n', m.start(), m.end()) - # Update charno. - charno = m.end() - return examples - - def get_program(self, string, name=""): - """ - Return an executable program from the given string, as a string. - - The format of this isn't rigidly defined. In general, doctest - examples become the executable statements in the result, and - their expected outputs become comments, preceded by an \"#Expected:\" - comment. Everything else (text, comments, everything not part of - a doctest test) is also placed in comments. - - The optional argument `name` is a name identifying this - string, and is only used for error messages. - - >>> text = ''' - ... >>> x, y = 2, 3 # no output expected - ... >>> if 1: - ... ... print x - ... ... print y - ... 2 - ... 3 - ... - ... Some text. - ... >>> x+y - ... 5 - ... ''' - >>> print DocTestParser().get_program(text) - x, y = 2, 3 # no output expected - if 1: - print x - print y - # Expected: - ## 2 - ## 3 - # - # Some text. - x+y - # Expected: - ## 5 - """ - string = string.expandtabs() - # If all lines begin with the same indentation, then strip it. - min_indent = self._min_indent(string) - if min_indent > 0: - string = '\n'.join([l[min_indent:] for l in string.split('\n')]) - - output = [] - charnum, lineno = 0, 0 - # Find all doctest examples in the string: - for m in self._EXAMPLE_RE.finditer(string.expandtabs()): - # Add any text before this example, as a comment. - if m.start() > charnum: - lines = string[charnum:m.start()-1].split('\n') - output.extend([self._comment_line(l) for l in lines]) - lineno += len(lines) - - # Extract source/want from the regexp match. - (source, want, exc_msg) = self._parse_example(m, name, lineno) - # Display the source - output.append(source) - # Display the expected output, if any - if want: - output.append('# Expected:') - output.extend(['## '+l for l in want.split('\n')]) - - # Update the line number & char number. - lineno += string.count('\n', m.start(), m.end()) - charnum = m.end() - # Add any remaining text, as comments. - output.extend([self._comment_line(l) - for l in string[charnum:].split('\n')]) - # Trim junk on both ends. - while output and output[-1] == '#': - output.pop() - while output and output[0] == '#': - output.pop(0) - # Combine the output, and return it. - return '\n'.join(output) + return [x for x in self.parse(string, name) + if isinstance(x, Example)] def _parse_example(self, m, name, lineno): """ @@ -786,7 +718,10 @@ else: exc_msg = None - return source, want, exc_msg + # Extract options from the source. + options = self._find_options(source, name, lineno) + + return source, options, want, exc_msg # This regular expression looks for option directives in the # source code of an example. Option directives are comments @@ -826,19 +761,15 @@ # This regular expression finds the indentation of every non-blank # line in a string. - _INDENT_RE = re.compile('^([ ]+)(?=\S)', re.MULTILINE) + _INDENT_RE = re.compile('^([ ]*)(?=\S)', re.MULTILINE) def _min_indent(self, s): "Return the minimum indentation of any non-blank line in `s`" - return min([len(indent) for indent in self._INDENT_RE.findall(s)]) - - def _comment_line(self, line): - "Return a commented form of the given line" - line = line.rstrip() - if line: - return '# '+line + indents = [len(indent) for indent in self._INDENT_RE.findall(s)] + if len(indents) > 0: + return min(indents) else: - return '#' + return 0 def _check_prompt_blank(self, lines, indent, name, lineno): """ @@ -2319,25 +2250,31 @@ if 0: blah blah - # # Ho hum """ + output = [] + for piece in DocTestParser().parse(s): + if isinstance(piece, Example): + # Add the example's source code (strip trailing NL) + output.append(piece.source[:-1]) + # Add the expected output: + want = piece.want + if want: + output.append('# Expected:') + output += ['## '+l for l in want.split('\n')[:-1]] + else: + # Add non-example text. + output += [_comment_line(l) + for l in piece.split('\n')[:-1]] - return DocTestParser().get_program(s) - -def _want_comment(example): - """ - Return a comment containing the expected output for the given example. - """ - # Return the expected output, if any - want = example.want - if want: - if want[-1] == '\n': - want = want[:-1] - want = "\n# ".join(want.split("\n")) - want = "\n# Expected:\n# %s" % want - return want + # Trim junk on both ends. + while output and output[-1] == '#': + output.pop() + while output and output[0] == '#': + output.pop(0) + # Combine the output, and return it. + return '\n'.join(output) def testsource(module, name): """Extract the test sources from a doctest docstring as a script. From tim_one at users.sourceforge.net Fri Aug 27 03:49:35 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 27 03:49:40 2004 Subject: [Python-checkins] python/dist/src/Objects unicodeobject.c, 2.219, 2.220 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15103/Objects Modified Files: unicodeobject.c Log Message: PyUnicode_Join(): Two primary aims: 1. u1.join([u2]) is u2 2. Be more careful about C-level int overflow. Since PySequence_Fast() isn't needed to achieve #1, it's not used -- but the code could sure be simpler if it were. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.219 retrieving revision 2.220 diff -u -d -r2.219 -r2.220 --- unicodeobject.c 4 Aug 2004 07:38:35 -0000 2.219 +++ unicodeobject.c 27 Aug 2004 01:49:32 -0000 2.220 @@ -3975,49 +3975,110 @@ return 1; } -PyObject *PyUnicode_Join(PyObject *separator, - PyObject *seq) +PyObject * +PyUnicode_Join(PyObject *separator, PyObject *seq) { + PyObject *internal_separator = NULL; Py_UNICODE *sep; - int seplen; + size_t seplen; PyUnicodeObject *res = NULL; - int reslen = 0; - Py_UNICODE *p; - int sz = 100; + size_t sz; /* # allocated bytes for string in res */ + size_t reslen; /* # used bytes */ + Py_UNICODE *p; /* pointer to free byte in res's string area */ + PyObject *it; /* iterator */ + PyObject *item; int i; - PyObject *it; + PyObject *temp; it = PyObject_GetIter(seq); if (it == NULL) return NULL; + item = PyIter_Next(it); + if (item == NULL) { + if (PyErr_Occurred()) + goto onError; + /* empty sequence; return u"" */ + res = _PyUnicode_New(0); + goto Done; + } + + /* If this is the only item, maybe we can get out cheap. */ + res = (PyUnicodeObject *)item; + item = PyIter_Next(it); + if (item == NULL) { + if (PyErr_Occurred()) + goto onError; + /* There's only one item in the sequence. */ + if (PyUnicode_CheckExact(res)) /* whatever.join([u]) -> u */ + goto Done; + } + + /* There are at least two to join (item != NULL), or there's only + * one but it's not an exact Unicode (item == NULL). res needs + * conversion to Unicode in either case. + * Caution: we may need to ensure a copy is made, and that's trickier + * than it sounds because, e.g., PyUnicode_FromObject() may return + * a shared object (which must not be mutated). + */ + if (! PyUnicode_Check(res) && ! PyString_Check(res)) { + PyErr_Format(PyExc_TypeError, + "sequence item 0: expected string or Unicode," + " %.80s found", + res->ob_type->tp_name); + Py_XDECREF(item); + goto onError; + } + temp = PyUnicode_FromObject((PyObject *)res); + if (temp == NULL) { + Py_XDECREF(item); + goto onError; + } + Py_DECREF(res); + if (item == NULL) { + /* res was the only item */ + res = (PyUnicodeObject *)temp; + goto Done; + } + /* There are at least two items. As above, temp may be a shared object, + * so we need to copy it. + */ + reslen = PyUnicode_GET_SIZE(temp); + sz = reslen + 100; /* breathing room */ + if (sz < reslen || sz > INT_MAX) /* overflow -- no breathing room */ + sz = reslen; + res = _PyUnicode_New(sz); + if (res == NULL) { + Py_DECREF(item); + goto onError; + } + p = PyUnicode_AS_UNICODE(res); + Py_UNICODE_COPY(p, PyUnicode_AS_UNICODE(temp), (int)reslen); + p += reslen; + Py_DECREF(temp); + if (separator == NULL) { Py_UNICODE blank = ' '; sep = ␣ seplen = 1; } else { - separator = PyUnicode_FromObject(separator); - if (separator == NULL) + internal_separator = PyUnicode_FromObject(separator); + if (internal_separator == NULL) { + Py_DECREF(item); goto onError; - sep = PyUnicode_AS_UNICODE(separator); - seplen = PyUnicode_GET_SIZE(separator); + } + sep = PyUnicode_AS_UNICODE(internal_separator); + seplen = PyUnicode_GET_SIZE(internal_separator); } - res = _PyUnicode_New(sz); - if (res == NULL) - goto onError; - p = PyUnicode_AS_UNICODE(res); - reslen = 0; + i = 1; + do { + size_t itemlen; + size_t newreslen; - for (i = 0; ; ++i) { - int itemlen; - PyObject *item = PyIter_Next(it); - if (item == NULL) { - if (PyErr_Occurred()) - goto onError; - break; - } + /* Catenate the separator, then item. */ + /* First convert item to Unicode. */ if (!PyUnicode_Check(item)) { PyObject *v; if (!PyString_Check(item)) { @@ -4034,36 +4095,55 @@ if (item == NULL) goto onError; } + /* Make sure we have enough space for the separator and the item. */ itemlen = PyUnicode_GET_SIZE(item); - while (reslen + itemlen + seplen >= sz) { - if (_PyUnicode_Resize(&res, sz*2) < 0) { + newreslen = reslen + seplen + itemlen; + if (newreslen < reslen || newreslen > INT_MAX) + goto Overflow; + if (newreslen > sz) { + do { + size_t oldsize = sz; + sz += sz; + if (sz < oldsize || sz > INT_MAX) + goto Overflow; + } while (newreslen > sz); + if (_PyUnicode_Resize(&res, (int)sz) < 0) { Py_DECREF(item); goto onError; } - sz *= 2; - p = PyUnicode_AS_UNICODE(res) + reslen; - } - if (i > 0) { - Py_UNICODE_COPY(p, sep, seplen); - p += seplen; - reslen += seplen; + p = PyUnicode_AS_UNICODE(res) + reslen; } - Py_UNICODE_COPY(p, PyUnicode_AS_UNICODE(item), itemlen); + Py_UNICODE_COPY(p, sep, (int)seplen); + p += seplen; + Py_UNICODE_COPY(p, PyUnicode_AS_UNICODE(item), (int)itemlen); p += itemlen; - reslen += itemlen; Py_DECREF(item); - } - if (_PyUnicode_Resize(&res, reslen) < 0) + reslen = newreslen; + + ++i; + item = PyIter_Next(it); + } while (item != NULL); + if (PyErr_Occurred()) goto onError; - Py_XDECREF(separator); + if (_PyUnicode_Resize(&res, (int)reslen) < 0) + goto onError; + + Done: + Py_XDECREF(internal_separator); Py_DECREF(it); return (PyObject *)res; + Overflow: + PyErr_SetString(PyExc_OverflowError, + "join() is too long for a Python string"); + Py_DECREF(item); + /* fall through */ + onError: - Py_XDECREF(separator); - Py_XDECREF(res); + Py_XDECREF(internal_separator); Py_DECREF(it); + Py_XDECREF(res); return NULL; } From edloper at users.sourceforge.net Fri Aug 27 04:07:48 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Fri Aug 27 04:07:51 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.92,1.93 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18298/dist/src/Lib Modified Files: doctest.py Log Message: - Removed redundant call to expandtabs in DocTestParesr. - Improvements to interactive debugging support: - Changed the replacement pdb.set_trace to redirect stdout to the real stdout *only* during interactive debugging; stdout from code continues to go to the fake stdout. - When the interactive debugger gets to the end of an example, automatically continue. - Use a replacement linecache.getlines that will return source lines from doctest examples; this makes the source available to the debugger for interactive debugging. - In test_doctest, use a specialized _FakeOutput class instead of a temporary file to fake stdin for the interactive interpreter. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.92 retrieving revision 1.93 diff -u -d -r1.92 -r1.93 --- doctest.py 26 Aug 2004 18:05:06 -0000 1.92 +++ doctest.py 27 Aug 2004 02:07:45 -0000 1.93 @@ -441,6 +441,28 @@ else: return '#' +class _OutputRedirectingPdb(pdb.Pdb): + """ + A specialized version of the python debugger that redirects stdout + to a given stream when interacting with the user. Stdout is *not* + redirected when traced code is executed. + """ + def __init__(self, out): + self.__out = out + pdb.Pdb.__init__(self) + + def trace_dispatch(self, *args): + # Redirect stdout to the given stream. + save_stdout = sys.stdout + sys.stdout = self.__out + # Call Pdb's trace dispatch method. + pdb.Pdb.trace_dispatch(self, *args) + # Restore stdout. + sys.stdout = save_stdout + + def resume(self): + self._resume = 1 + ###################################################################### ## 2. Example & DocTest ###################################################################### @@ -631,7 +653,7 @@ output = [] charno, lineno = 0, 0 # Find all doctest examples in the string: - for m in self._EXAMPLE_RE.finditer(string.expandtabs()): + for m in self._EXAMPLE_RE.finditer(string): # Add the pre-example text to `output`. output.append(string[charno:m.start()]) # Update lineno (lines before this example) @@ -1260,7 +1282,8 @@ original_optionflags = self.optionflags # Process each example. - for example in test.examples: + for examplenum, example in enumerate(test.examples): + # If REPORT_ONLY_FIRST_FAILURE is set, then supress # reporting after the first failure. quiet = (self.optionflags & REPORT_ONLY_FIRST_FAILURE and @@ -1280,18 +1303,25 @@ if not quiet: self.report_start(out, test, example) + # Use a special filename for compile(), so we can retrieve + # the source code during interactive debugging (see + # __patched_linecache_getlines). + filename = '' % (test.name, examplenum) + # Run the example in the given context (globs), and record # any exception that gets raised. (But don't intercept # keyboard interrupts.) try: # Don't blink! This is where the user's code gets run. - exec compile(example.source, "", "single", + exec compile(example.source, filename, "single", compileflags, 1) in test.globs + self.debugger.set_continue() # ==== Example Finished ==== exception = None except KeyboardInterrupt: raise except: exception = sys.exc_info() + self.debugger.set_continue() # ==== Example Finished ==== got = self._fakeout.getvalue() # the actual output self._fakeout.truncate(0) @@ -1352,6 +1382,17 @@ self.failures += f self.tries += t + __LINECACHE_FILENAME_RE = re.compile(r'[\w\.]+)' + r'\[(?P\d+)\]>$') + def __patched_linecache_getlines(self, filename): + m = self.__LINECACHE_FILENAME_RE.match(filename) + if m and m.group('name') == self.test.name: + example = self.test.examples[int(m.group('examplenum'))] + return example.source.splitlines(True) + else: + return self.save_linecache_getlines(filename) + def run(self, test, compileflags=None, out=None, clear_globs=True): """ Run the examples in `test`, and display the results using the @@ -1372,6 +1413,8 @@ `DocTestRunner.check_output`, and the results are formatted by the `DocTestRunner.report_*` methods. """ + self.test = test + if compileflags is None: compileflags = _extract_future_flags(test.globs) @@ -1380,25 +1423,27 @@ out = save_stdout.write sys.stdout = self._fakeout - # Patch pdb.set_trace to restore sys.stdout, so that interactive - # debugging output is visible (not still redirected to self._fakeout). - # Note that we run "the real" pdb.set_trace (captured at doctest - # import time) in our replacement. Because the current run() may - # run another doctest (and so on), the current pdb.set_trace may be - # our set_trace function, which changes sys.stdout. If we called - # a chain of those, we wouldn't be left with the save_stdout - # *this* run() invocation wants. - def set_trace(): - sys.stdout = save_stdout - real_pdb_set_trace() - + # Patch pdb.set_trace to restore sys.stdout during interactive + # debugging (so it's not still redirected to self._fakeout). + # Note that the interactive output will go to *our* + # save_stdout, even if that's not the real sys.stdout; this + # allows us to write test cases for the set_trace behavior. save_set_trace = pdb.set_trace - pdb.set_trace = set_trace + self.debugger = _OutputRedirectingPdb(save_stdout) + self.debugger.reset() + pdb.set_trace = self.debugger.set_trace + + # Patch linecache.getlines, so we can see the example's source + # when we're inside the debugger. + self.save_linecache_getlines = linecache.getlines + linecache.getlines = self.__patched_linecache_getlines + try: return self.__run(test, compileflags, out) finally: sys.stdout = save_stdout pdb.set_trace = save_set_trace + linecache.getlines = self.save_linecache_getlines if clear_globs: test.globs.clear() From edloper at users.sourceforge.net Fri Aug 27 04:07:49 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Fri Aug 27 04:07:54 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.37, 1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18298/dist/src/Lib/test Modified Files: test_doctest.py Log Message: - Removed redundant call to expandtabs in DocTestParesr. - Improvements to interactive debugging support: - Changed the replacement pdb.set_trace to redirect stdout to the real stdout *only* during interactive debugging; stdout from code continues to go to the fake stdout. - When the interactive debugger gets to the end of an example, automatically continue. - Use a replacement linecache.getlines that will return source lines from doctest examples; this makes the source available to the debugger for interactive debugging. - In test_doctest, use a specialized _FakeOutput class instead of a temporary file to fake stdin for the interactive interpreter. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- test_doctest.py 26 Aug 2004 18:05:07 -0000 1.37 +++ test_doctest.py 27 Aug 2004 02:07:46 -0000 1.38 @@ -117,6 +117,25 @@ return self.val ###################################################################### +## Fake stdin (for testing interactive debugging) +###################################################################### + +class _FakeInput: + """ + A fake input stream for pdb's interactive debugger. Whenever a + line is read, print it (to simulate the user typing it), and then + return it. The set of lines to return is specified in the + constructor; they should not have trailing newlines. + """ + def __init__(self, lines): + self.lines = lines + + def readline(self): + line = self.lines.pop(0) + print line + return line+'\n' + +###################################################################### ## Test Cases ###################################################################### @@ -1436,31 +1455,28 @@ Create some fake stdin input, to feed to the debugger: >>> import tempfile - >>> fake_stdin = tempfile.TemporaryFile(mode='w+') - >>> fake_stdin.write('\n'.join(['next', 'print x', 'continue', ''])) - >>> fake_stdin.seek(0) >>> real_stdin = sys.stdin - >>> sys.stdin = fake_stdin + >>> sys.stdin = _FakeInput(['next', 'print x', 'continue']) Run the debugger on the docstring, and then restore sys.stdin. - >>> try: - ... doctest.debug_src(s) - ... finally: - ... sys.stdin = real_stdin - ... fake_stdin.close() - ... # doctest: +NORMALIZE_WHITESPACE + >>> try: doctest.debug_src(s) + ... finally: sys.stdin = real_stdin > (1)?() - (Pdb) 12 + (Pdb) next + 12 --Return-- > (1)?()->None - (Pdb) 12 - (Pdb) + (Pdb) print x + 12 + (Pdb) continue """ def test_pdb_set_trace(): - r"""Using pdb.set_trace from a doctest + # Note: this should *not* be an r'...' string, because we need + # to use '\t' for the output of ... + """Using pdb.set_trace from a doctest You can use pdb.set_trace from a doctest. To do so, you must retrieve the set_trace function from the pdb module at the time @@ -1481,29 +1497,21 @@ captures our debugger input: >>> import tempfile - >>> fake_stdin = tempfile.TemporaryFile(mode='w+') - >>> fake_stdin.write('\n'.join([ - ... 'up', # up out of pdb.set_trace - ... 'up', # up again to get out of our wrapper + >>> real_stdin = sys.stdin + >>> sys.stdin = _FakeInput([ ... 'print x', # print data defined by the example ... 'continue', # stop debugging - ... ''])) - >>> fake_stdin.seek(0) - >>> real_stdin = sys.stdin - >>> sys.stdin = fake_stdin + ... '']) - >>> runner.run(test) # doctest: +ELLIPSIS + >>> try: runner.run(test) + ... finally: sys.stdin = real_stdin --Return-- - > ...set_trace()->None - -> Pdb().set_trace() - (Pdb) > ...set_trace() - -> real_pdb_set_trace() - (Pdb) > (1)?() - (Pdb) 42 - (Pdb) (0, 2) - - >>> sys.stdin = real_stdin - >>> fake_stdin.close() + > (1)?()->None + -> import pdb; pdb.set_trace() + (Pdb) print x + 42 + (Pdb) continue + (0, 2) You can also put pdb.set_trace in a function called from a test: @@ -1516,30 +1524,85 @@ ... >>> calls_set_trace() ... ''' >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) - >>> fake_stdin = tempfile.TemporaryFile(mode='w+') - >>> fake_stdin.write('\n'.join([ - ... 'up', # up out of pdb.set_trace - ... 'up', # up again to get out of our wrapper + >>> real_stdin = sys.stdin + >>> sys.stdin = _FakeInput([ ... 'print y', # print data defined in the function ... 'up', # out of function ... 'print x', # print data defined by the example ... 'continue', # stop debugging - ... ''])) - >>> fake_stdin.seek(0) - >>> real_stdin = sys.stdin - >>> sys.stdin = fake_stdin + ... '']) - >>> runner.run(test) # doctest: +ELLIPSIS + >>> try: runner.run(test) + ... finally: sys.stdin = real_stdin --Return-- - > ...set_trace()->None - -> Pdb().set_trace() - (Pdb) ...set_trace() - -> real_pdb_set_trace() - (Pdb) > (3)calls_set_trace() - (Pdb) 2 - (Pdb) > (1)?() - (Pdb) 1 - (Pdb) (0, 2) + > (3)calls_set_trace()->None + -> import pdb; pdb.set_trace() + (Pdb) print y + 2 + (Pdb) up + > (1)?() + -> calls_set_trace() + (Pdb) print x + 1 + (Pdb) continue + (0, 2) + + During interactive debugging, source code is shown, even for + doctest examples: + + >>> doc = ''' + ... >>> def f(x): + ... ... g(x*2) + ... >>> def g(x): + ... ... print x+3 + ... ... import pdb; pdb.set_trace() + ... >>> f(3) + ... ''' + >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) + >>> real_stdin = sys.stdin + >>> sys.stdin = _FakeInput([ + ... 'list', # list source from example 2 + ... 'next', # return from g() + ... 'list', # list source from example 1 + ... 'next', # return from f() + ... 'list', # list source from example 3 + ... 'continue', # stop debugging + ... '']) + >>> try: runner.run(test) + ... finally: sys.stdin = real_stdin + ... # doctest: +NORMALIZE_WHITESPACE + --Return-- + > (3)g()->None + -> import pdb; pdb.set_trace() + (Pdb) list + 1 def g(x): + 2 print x+3 + 3 -> import pdb; pdb.set_trace() + [EOF] + (Pdb) next + --Return-- + > (2)f()->None + -> g(x*2) + (Pdb) list + 1 def f(x): + 2 -> g(x*2) + [EOF] + (Pdb) next + --Return-- + > (1)?()->None + -> f(3) + (Pdb) list + 1 -> f(3) + [EOF] + (Pdb) continue + ********************************************************************** + File "foo.py", line 7, in foo + Failed example: + f(3) + Expected nothing + Got: + 9 + (1, 3) """ def test_DocTestSuite(): From edloper at users.sourceforge.net Fri Aug 27 06:29:27 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Fri Aug 27 06:29:30 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.93,1.94 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6903/dist/src/Lib Modified Files: doctest.py Log Message: Remove unused method _OutputRedirectingPdb.resume Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.93 retrieving revision 1.94 diff -u -d -r1.93 -r1.94 --- doctest.py 27 Aug 2004 02:07:45 -0000 1.93 +++ doctest.py 27 Aug 2004 04:29:23 -0000 1.94 @@ -460,9 +460,6 @@ # Restore stdout. sys.stdout = save_stdout - def resume(self): - self._resume = 1 - ###################################################################### ## 2. Example & DocTest ###################################################################### From bcannon at users.sourceforge.net Fri Aug 27 07:00:25 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Aug 27 07:00:29 2004 Subject: [Python-checkins] python/dist/src/Modules _localemodule.c, 2.48, 2.49 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11482/Modules Modified Files: _localemodule.c Log Message: Fix the spelling of Fredrik Lundh's last name (unless there really is a "Fredrik Lund" who contributed the code in question). Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.48 retrieving revision 2.49 diff -u -d -r2.48 -r2.49 --- _localemodule.c 22 Jul 2004 18:44:01 -0000 2.48 +++ _localemodule.c 27 Aug 2004 05:00:22 -0000 2.49 @@ -408,7 +408,7 @@ #if defined(__APPLE__) /* ** Find out what the current script is. -** Donated by Fredrik Lund. +** Donated by Fredrik Lundh. */ static char *mac_getscript(void) { From tim_one at users.sourceforge.net Fri Aug 27 07:08:39 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 27 07:08:40 2004 Subject: [Python-checkins] python/dist/src/Objects unicodeobject.c, 2.220, 2.221 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12912/Objects Modified Files: unicodeobject.c Log Message: PyUnicode_Join(): Missed a spot where I intended a cast from size_t to int. I sure wish MS would gripe about that! Whatever, note that the statement above it guarantees that the cast loses no info. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.220 retrieving revision 2.221 diff -u -d -r2.220 -r2.221 --- unicodeobject.c 27 Aug 2004 01:49:32 -0000 2.220 +++ unicodeobject.c 27 Aug 2004 05:08:36 -0000 2.221 @@ -4047,7 +4047,7 @@ sz = reslen + 100; /* breathing room */ if (sz < reslen || sz > INT_MAX) /* overflow -- no breathing room */ sz = reslen; - res = _PyUnicode_New(sz); + res = _PyUnicode_New((int)sz); if (res == NULL) { Py_DECREF(item); goto onError; From bcannon at users.sourceforge.net Fri Aug 27 07:24:06 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Aug 27 07:24:09 2004 Subject: [Python-checkins] python/nondist/peps pep-3000.txt,1.3,1.4 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14990 Modified Files: pep-3000.txt Log Message: Mention Python 3000 name. Fix bullet points under things to return iterators. Mention true division, True, False, and as becoming keywords and the removal of __cmp__ . Index: pep-3000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-3000.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pep-3000.txt 23 Aug 2004 18:07:06 -0000 1.3 +++ pep-3000.txt 27 Aug 2004 05:24:03 -0000 1.4 @@ -14,7 +14,8 @@ Abstract ======== -This PEP describes the changes currently envisioned in Python 3.0, a +This PEP describes the changes currently envisioned in Python 3.0 +(also called Python 3000), a hypothetical future release of Python that can break backwards compatibility with the existing body of Python code. @@ -42,6 +43,7 @@ ============= * Remove distinction between int and long types. [1]_ +* True division becomes default behavior * Make all strings be Unicode, and have a separate bytes() type. [1]_ * ``exec`` as a statement is not worth it -- make it a function * Add optional declarations for static typing @@ -53,13 +55,17 @@ .bar(4, .foo) * Return iterators instead of lists -* ``d.keys()``, ``.values()``, ``.items()`` -* ``range()``, ``zip()`` + - ``dict.keys()``, ``.values()``, ``.items()`` + - ``range()``, ``zip()`` * Replace ``print`` by a function: ``write(x,y,z)``, ``writeln(x,y,z)`` [2]_ * Do something so you can catch multiple exceptions using ``except E1, E2, E3:``. Maybe use ``except E1, E2, E3 as err:`` if you want the error variable? [3]_ +* ``True`` and ``False`` become keywords [4]_ +* ``as`` becomes a keyword [5]_ +* Remove ``__cmp__`` as a magic method -- rich comparisons make + ``__cmp__`` conflict with TOOWTDI [6]_ To be removed: @@ -119,6 +125,15 @@ .. [3] Python Wiki: http://www.python.org/moin/Python3.0 +.. [4] python-dev email ("Constancy of None") + http://mail.python.org/pipermail/python-dev/2004-July/046294.html + +.. [5] python-dev email (" "as" to be a keyword?") + http://mail.python.org/pipermail/python-dev/2004-July/046316.html + +.. [6] python-dev email ("lists vs. tuples") + http://mail.python.org/pipermail/python-dev/2003-March/034073.html + Copyright ========= From tim_one at users.sourceforge.net Fri Aug 27 07:36:10 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 27 07:36:13 2004 Subject: [Python-checkins] python/dist/src/Lib/test string_tests.py, 1.40, 1.41 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16557/Lib/test Modified Files: string_tests.py Log Message: test_bug1001011(): Verify that s.join([t]) is t for (s, t) in (str, str), (unicode, unicode), and (str, unicode). For (unicode, str), verify that it's *not* t (the result is promoted to unicode instead). Also verify that when t is a subclass of str or unicode that "the right thing" happens. Index: string_tests.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- string_tests.py 26 Aug 2004 16:53:04 -0000 1.40 +++ string_tests.py 27 Aug 2004 05:36:07 -0000 1.41 @@ -699,14 +699,13 @@ class MixinStrUnicodeTest: - # Additional tests that only work with - # str and unicode + # Additional tests that only work with str and unicode. def test_bug1001011(self): # Make sure join returns a NEW object for single item sequences - # involving a subclass - # Make sure that it is of the appropriate type - # Check the optimisation still occurs for standard objects + # involving a subclass. + # Make sure that it is of the appropriate type. + # Check the optimisation still occurs for standard objects. t = self.type2test class subclass(t): pass @@ -714,3 +713,32 @@ s2 = t().join([s1]) self.assert_(s1 is not s2) self.assert_(type(s2) is t) + + s1 = t("abcd") + s2 = t().join([s1]) + self.assert_(s1 is s2) + + # Should also test mixed-type join. + if t is unicode: + s1 = subclass("abcd") + s2 = "".join([s1]) + self.assert_(s1 is not s2) + self.assert_(type(s2) is t) + + s1 = t("abcd") + s2 = "".join([s1]) + self.assert_(s1 is s2) + + elif t is str: + s1 = subclass("abcd") + s2 = u"".join([s1]) + self.assert_(s1 is not s2) + self.assert_(type(s2) is unicode) # promotes! + + s1 = t("abcd") + s2 = u"".join([s1]) + self.assert_(s1 is not s2) + self.assert_(type(s2) is unicode) # promotes! + + else: + self.fail("unexpected type for MixinStrUnicodeTest %r" % t) From tim_one at users.sourceforge.net Fri Aug 27 07:44:54 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 27 07:44:57 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_generators.py, 1.40, 1.41 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18110/Lib/test Modified Files: test_generators.py Log Message: Fixed 6 failures due to doctest changes. Index: test_generators.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- test_generators.py 9 Aug 2004 02:03:30 -0000 1.40 +++ test_generators.py 27 Aug 2004 05:44:51 -0000 1.41 @@ -649,28 +649,28 @@ syntax_tests = """ ->>> def f(): +>>> def f(): #doctest: +ELLIPSIS ... return 22 ... yield 1 Traceback (most recent call last): - ... -SyntaxError: 'return' with argument inside generator (, line 2) + .. +SyntaxError: 'return' with argument inside generator (..., line 2) ->>> def f(): +>>> def f(): #doctest: +ELLIPSIS ... yield 1 ... return 22 Traceback (most recent call last): - ... -SyntaxError: 'return' with argument inside generator (, line 3) + .. +SyntaxError: 'return' with argument inside generator (..., line 3) "return None" is not the same as "return" in a generator: ->>> def f(): +>>> def f(): #doctest: +ELLIPSIS ... yield 1 ... return None Traceback (most recent call last): - ... -SyntaxError: 'return' with argument inside generator (, line 3) + .. +SyntaxError: 'return' with argument inside generator (..., line 3) This one is fine: @@ -678,16 +678,16 @@ ... yield 1 ... return ->>> def f(): +>>> def f(): #doctest: +ELLIPSIS ... try: ... yield 1 ... finally: ... pass Traceback (most recent call last): - ... -SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (, line 3) + .. +SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (..., line 3) ->>> def f(): +>>> def f(): #doctest: +ELLIPSIS ... try: ... try: ... 1//0 @@ -699,7 +699,7 @@ ... pass Traceback (most recent call last): ... -SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (, line 6) +SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (..., line 6) But this is fine: @@ -794,7 +794,7 @@ ->>> def f(): +>>> def f(): #doctest: +ELLIPSIS ... if 0: ... lambda x: x # shouldn't trigger here ... return # or here @@ -805,7 +805,7 @@ ... if 0: ... yield 2 # because it's a generator Traceback (most recent call last): -SyntaxError: 'return' with argument inside generator (, line 8) +SyntaxError: 'return' with argument inside generator (..., line 8) This one caused a crash (see SF bug 567538): From mal at egenix.com Fri Aug 27 11:20:50 2004 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Aug 27 11:20:57 2004 Subject: [Python-checkins] python/dist/src/Objects unicodeobject.c, 2.219, 2.220 In-Reply-To: References: Message-ID: <412EFCF2.4030608@egenix.com> tim_one@users.sourceforge.net wrote: > Update of /cvsroot/python/python/dist/src/Objects > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15103/Objects > > Modified Files: > unicodeobject.c > Log Message: > PyUnicode_Join(): Two primary aims: > > 1. u1.join([u2]) is u2 > 2. Be more careful about C-level int overflow. > > Since PySequence_Fast() isn't needed to achieve #1, it's not used -- but > the code could sure be simpler if it were. Hmm, you've now made PyUnicode_Join() to work with iterators whereas PyString_Join() only works for sequences. What are the performance implications of this for PyUnicode_Join() ? Since the string and Unicode implementations have to be in sync, we'd also need to convert PyString_Join() to work on iterators. Which brings up the second question: What are the performance implications of this for PyString_Join() ? The join operation is a widely used method, so both implementations need to be as fast as possible. It may be worthwhile making the PySequence_Fast() approach a special case in both routines and using the iterator approach as fallback if no sequence is found. Note that PyString_Join() with iterator support will also have to be careful about not trying to iterate twice, so it will have to use a similiar logic to the one applied in PyString_Format() where the work already done up to the point where it finds a Unicode string is reused when calling PyUnicode_Format(). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Aug 27 2004) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From goodger at users.sourceforge.net Fri Aug 27 15:16:34 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Fri Aug 27 15:16:39 2004 Subject: [Python-checkins] python/nondist/peps pep-3000.txt,1.4,1.5 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8386 Modified Files: pep-3000.txt Log Message: markup Index: pep-3000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-3000.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- pep-3000.txt 27 Aug 2004 05:24:03 -0000 1.4 +++ pep-3000.txt 27 Aug 2004 13:16:31 -0000 1.5 @@ -55,8 +55,10 @@ .bar(4, .foo) * Return iterators instead of lists + - ``dict.keys()``, ``.values()``, ``.items()`` - ``range()``, ``zip()`` + * Replace ``print`` by a function: ``write(x,y,z)``, ``writeln(x,y,z)`` [2]_ * Do something so you can catch multiple exceptions using ``except E1, From goodger at users.sourceforge.net Fri Aug 27 15:29:50 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Fri Aug 27 15:29:53 2004 Subject: [Python-checkins] python/nondist/peps pep-0309.txt,1.6,1.7 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10607 Modified Files: pep-0309.txt Log Message: update from Peter Harris; minor edits Index: pep-0309.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0309.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- pep-0309.txt 4 Apr 2004 02:37:34 -0000 1.6 +++ pep-0309.txt 27 Aug 2004 13:29:47 -0000 1.7 @@ -1,5 +1,5 @@ PEP: 309 -Title: Partial Function Application +Title: Partial Function Application Version: $Revision$ Last-Modified: $Date$ Author: Peter Harris @@ -18,15 +18,18 @@ callable to be constructed from a callable and a partial argument list (including positional and keyword arguments). -I propose a standard library module called "functional", to hold useful -higher-order functions, including the implementation of partial(). +I propose a standard library module called "functional", to hold +useful higher-order functions, including the implementation of +partial(). + +An implementation has been submitted to SourceForge [2]_. Motivation ========== In functional programming, function currying is a way of implementing -multi-argument functions in terms of single-argument functions. A +multi-argument functions in terms of single-argument functions. A function with N arguments is really a function with 1 argument that returns another function taking (N-1) arguments. Function application in languages like Haskell and ML works such that a function call:: @@ -38,7 +41,7 @@ (((f x) y) z) This would be only an obscure theoretical issue except that in actual -programming it turns out to be very useful. Expressing a function in +programming it turns out to be very useful. Expressing a function in terms of partial application of arguments to another function can be both elegant and powerful, and in functional languages it is heavily used. @@ -52,8 +55,9 @@ thing when presented with a functor and less arguments than expected. Python does not implement multi-argument functions by currying, so if -you want a function with partially-applied arguments you would probably -use a lambda as above, or define a named function for each instance. +you want a function with partially-applied arguments you would +probably use a lambda as above, or define a named function for each +instance. However, lambda syntax is not to everyone's taste, so say the least. Furthermore, Python's flexible parameter passing using both positional @@ -61,11 +65,11 @@ application and do things that lambda cannot. -Rationale -========= +Example Implementation +====================== Here is one way to do a create a callable with partially-applied -arguments in Python. The implementation below is based on improvements +arguments in Python. The implementation below is based on improvements provided by Scott David Daniels:: class partial(object): @@ -90,6 +94,9 @@ constructor, and keyword arguments override and augment those provided to the constructor. +Positional arguments, keyword arguments or both can be supplied at +when creating the object and when calling it. + Examples of Use =============== @@ -97,8 +104,8 @@ So ``partial(operator.add, 1)`` is a bit like ``(lambda x: 1 + x)``. Not an example where you see the benefits, of course. -Note too, that you could wrap a class in the same way, since -classes themselves are callable factories for objects. So in some cases, +Note too, that you could wrap a class in the same way, since classes +themselves are callable factories for objects. So in some cases, rather than defining a subclass, you can specialise classes by partial application of the arguments to the constructor. @@ -115,9 +122,10 @@ win = Tk() c = Canvas(win,width=200,height=50) c.pack() - + for colour in sys.argv[1:]: - b = Button(win, text=colour, command=partial(c.config,bg=colour)) + b = Button(win, text=colour, + command=partial(c.config, bg=colour)) b.pack(side='left') win.mainloop() @@ -129,16 +137,13 @@ I originally suggested the syntax ``fn@(*args, **kw)``, meaning the same as ``partial(fn, *args, **kw)``. -At least there are no backwards-compatibility issues because the @ -character isn't a legal operator in any previous versions of Python. - The @ sign is used in some assembly languages to imply register indirection, and the use here is also a kind of indirection. -``f@(x)`` is not ``f(x)`` , but a thing that becomes ``f(x)`` when you +``f@(x)`` is not ``f(x)``, but a thing that becomes ``f(x)`` when you call it. -It has not been well-received, so I have withdrawn this part of the -proposal. +It was not well-received, so I have withdrawn this part of the +proposal. In any case, @ has been taken for the new decorator syntax. Feedback from comp.lang.python and python-dev @@ -157,7 +162,7 @@ * A curry class would indeed be a useful addition to the standard library. -* It isn't function currying, but partial application. Hence the +* It isn't function currying, but partial application. Hence the name is now proposed to be partial(). * It maybe isn't useful enough to be in the built-ins. @@ -181,7 +186,7 @@ concerned it's a dead parrot. I concur with calling the class partial rather than curry or closure, -so I have amended the proposal in this PEP accordingly. But not +so I have amended the proposal in this PEP accordingly. But not throughout: some incorrect references to 'curry' have been left in since that's where the discussion was at the time. @@ -199,12 +204,10 @@ return fn(*(cargs + fargs), **d) return call_fn -which he assures me is more efficient. You lose introspection and -sub-classing that way, but these are maybe only marginal benefits and -not worth a performance hit, so this would also do as a reference -implementation. +which he assures me is more efficient. -I also coded the class in Pyrex:: +I also coded the class in Pyrex, to estimate how the performance +might be improved by coding it in C:: cdef class curry: @@ -238,10 +241,16 @@ A standard library module ``functional`` should contain an implementation of ``partial``, and any other higher-order functions -the community want. Other functions that might belong there fall +the community want. Other functions that might belong there fall outside the scope of this PEP though. -The @ syntax proposal has been withrawn. +Patches for the implementation, documentation and unit tests (SF +patches 931005_, 931007_, and 931010_ respectively) have been +submitted but not yet checked in. + +A C implementation by Hye-Shik Chang has also been submitted, although +it is not expected to be included until after the Python +implementation has proven itself useful enough to be worth optimising. References @@ -249,6 +258,12 @@ .. [1] http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52549 +.. [2] Patches 931005_, 931007_, and 931010_. + +.. _931005: http://www.python.org/sf/931005 +.. _931007: http://www.python.org/sf/931007 +.. _931010: http://www.python.org/sf/931010 + Copyright ========= From goodger at users.sourceforge.net Fri Aug 27 15:44:40 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Fri Aug 27 15:44:43 2004 Subject: [Python-checkins] python/nondist/peps pep-0332.txt, NONE, 1.1 pep-0000.txt, 1.283, 1.284 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13095 Modified Files: pep-0000.txt Added Files: pep-0332.txt Log Message: added PEP 332, "Byte vectors and String/Unicode Unification", by Skip Montanaro --- NEW FILE: pep-0332.txt --- PEP: 332 Title: Byte vectors and String/Unicode Unification Version: $Revision: 1.1 $ Last-Modified: $Date: 2004/08/27 13:44:37 $ Author: Skip Montanaro Status: Draft Type: Standards Track Content-Type: text/x-rst Created: 11-Aug-2004 Python-Version: 2.5 Post-History: Abstract ======== This PEP outlines the introduction of a raw ``bytes`` sequence object and the unification of the current ``str`` and ``unicode`` objects. Rationale ========= Python's current string objects are overloaded. They serve both to hold ASCII and non-ASCII character data and to also hold sequences of raw bytes which have no reasonable interpretation as displayable character sequences. This overlap hasn't been a big problem in the past, but as Python moves closer to requiring source code to be properly encoded, the use of strings to represent raw byte sequences will be more problematic. In addition, as Python's Unicode support has improved, it's easier to consider strings as ASCII-encoded Unicode objects. Proposed Implementation ======================= The number in parentheses indicates the Python version in which the feature will be introduced. - Add a ``bytes`` builtin which is just a synonym for ``str``. (2.5) - Add a ``b"..."`` string literal which is equivalent to raw string literals, with the exception that values which conflict with the source encoding of the containing file not generate warnings. (2.5) - Warn about the use of variables named "bytes". (2.5 or 2.6) - Introduce a ``bytes`` builtin which refers to a sequence distinct from the ``str`` type. (2.6) - Make ``str`` a synonym for ``unicode``. (3.0) Bytes Object API ================ TBD. Issues ====== - Can this be accomplished before Python 3.0? - Should ``bytes`` objects be mutable or immutable? (Guido seems to like them to be mutable.) Copyright ========= This document has been placed in the public domain. .. Local Variables: mode: indented-text indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 End: Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.283 retrieving revision 1.284 diff -u -d -r1.283 -r1.284 --- pep-0000.txt 23 Aug 2004 03:41:56 -0000 1.283 +++ pep-0000.txt 27 Aug 2004 13:44:37 -0000 1.284 @@ -121,6 +121,7 @@ S 325 Resource-Release Support for Generators Pedroni S 330 Python Bytecode Verification Pelletier S 331 Locale-Independent Float/String conversions Reis + S 332 Byte vectors and String/Unicode Unification Montanaro S 754 IEEE 754 Floating Point Special Values Warnes Finished PEPs (done, implemented in CVS) @@ -358,6 +359,7 @@ SR 329 Treating Builtins as Constants in the Standard Library Hettinger S 330 Python Bytecode Verification Pelletier S 331 Locale-Independent Float/String conversions Reis + S 332 Byte vectors and String/Unicode Unification Montanaro SR 666 Reject Foolish Indentation Creighton S 754 IEEE 754 Floating Point Special Values Warnes I 3000 Python 3.0 Plans Kuchling, Cannon From edloper at users.sourceforge.net Fri Aug 27 16:57:01 2004 From: edloper at users.sourceforge.net (edloper@users.sourceforge.net) Date: Fri Aug 27 16:57:05 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.38, 1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26744/dist/src/Lib/test Modified Files: test_doctest.py Log Message: Removed outdated comment Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- test_doctest.py 27 Aug 2004 02:07:46 -0000 1.38 +++ test_doctest.py 27 Aug 2004 14:56:58 -0000 1.39 @@ -1474,8 +1474,6 @@ """ def test_pdb_set_trace(): - # Note: this should *not* be an r'...' string, because we need - # to use '\t' for the output of ... """Using pdb.set_trace from a doctest You can use pdb.set_trace from a doctest. To do so, you must From tim_one at users.sourceforge.net Fri Aug 27 17:12:52 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 27 17:12:57 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_generators.py, 1.41, 1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29150/Lib/test Modified Files: test_generators.py Log Message: Don't really need ellipsis doctests for the syntax errors, because this module imports itself explicitly from test (so the "file names" current doctest synthesizes for examples don't vary depending on how test_generators is run). Index: test_generators.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- test_generators.py 27 Aug 2004 05:44:51 -0000 1.41 +++ test_generators.py 27 Aug 2004 15:12:49 -0000 1.42 @@ -649,28 +649,28 @@ syntax_tests = """ ->>> def f(): #doctest: +ELLIPSIS +>>> def f(): ... return 22 ... yield 1 Traceback (most recent call last): .. -SyntaxError: 'return' with argument inside generator (..., line 2) +SyntaxError: 'return' with argument inside generator (, line 2) ->>> def f(): #doctest: +ELLIPSIS +>>> def f(): ... yield 1 ... return 22 Traceback (most recent call last): .. -SyntaxError: 'return' with argument inside generator (..., line 3) +SyntaxError: 'return' with argument inside generator (, line 3) "return None" is not the same as "return" in a generator: ->>> def f(): #doctest: +ELLIPSIS +>>> def f(): ... yield 1 ... return None Traceback (most recent call last): .. -SyntaxError: 'return' with argument inside generator (..., line 3) +SyntaxError: 'return' with argument inside generator (, line 3) This one is fine: @@ -678,16 +678,16 @@ ... yield 1 ... return ->>> def f(): #doctest: +ELLIPSIS +>>> def f(): ... try: ... yield 1 ... finally: ... pass Traceback (most recent call last): .. -SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (..., line 3) +SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (, line 3) ->>> def f(): #doctest: +ELLIPSIS +>>> def f(): ... try: ... try: ... 1//0 @@ -699,7 +699,7 @@ ... pass Traceback (most recent call last): ... -SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (..., line 6) +SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (, line 6) But this is fine: @@ -794,7 +794,7 @@ ->>> def f(): #doctest: +ELLIPSIS +>>> def f(): ... if 0: ... lambda x: x # shouldn't trigger here ... return # or here @@ -805,7 +805,7 @@ ... if 0: ... yield 2 # because it's a generator Traceback (most recent call last): -SyntaxError: 'return' with argument inside generator (..., line 8) +SyntaxError: 'return' with argument inside generator (, line 8) This one caused a crash (see SF bug 567538): From tim_one at users.sourceforge.net Fri Aug 27 17:30:01 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 27 17:30:22 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_generators.py, 1.42, 1.43 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32536/Lib/test Modified Files: test_generators.py Log Message: Removed old "if 0:" block for leak detection; wouldn't work anymore anyway. Index: test_generators.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- test_generators.py 27 Aug 2004 15:12:49 -0000 1.42 +++ test_generators.py 27 Aug 2004 15:29:59 -0000 1.43 @@ -1397,15 +1397,8 @@ # Note that doctest and regrtest both look in sys.argv for a "-v" argument, # so this works as expected in both ways of running regrtest. def test_main(verbose=None): - import doctest from test import test_support, test_generators - if 0: # change to 1 to run forever (to check for leaks) - while 1: - doctest.master = None - test_support.run_doctest(test_generators, verbose) - print ".", - else: - test_support.run_doctest(test_generators, verbose) + test_support.run_doctest(test_generators, verbose) # This part isn't needed for regrtest, but for running the test directly. if __name__ == "__main__": From goodger at users.sourceforge.net Fri Aug 27 19:30:14 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Fri Aug 27 19:30:19 2004 Subject: [Python-checkins] python/nondist/peps pep-0333.txt, NONE, 1.1 pep-0000.txt, 1.284, 1.285 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22736 Modified Files: pep-0000.txt Added Files: pep-0333.txt Log Message: added PEP 333, "Python Web Server Gateway Interface v1.0", by Phillip J. Eby --- NEW FILE: pep-0333.txt --- PEP: 333 Title: Python Web Server Gateway Interface v1.0 Version: $Revision: 1.1 $ Last-Modified: $Date: 2004/08/27 17:30:09 $ Author: Phillip J. Eby Discussions-To: Python Web-SIG Status: Draft Type: Informational Content-Type: text/x-rst Created: 07-Dec-2003 Post-History: 07-Dec-2003, 08-Aug-2004, 20-Aug-2004 Abstract ======== This document specifies a proposed standard interface between web servers and Python web applications or frameworks, to promote web application portability across a variety of web servers. [...980 lines suppressed...] (http://cgi-spec.golux.com/draft-coar-cgi-v11-03.txt) .. [3] Hypertext Transfer Protocol -- HTTP/1.1, section 3.6.1 (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1) Copyright ========= This document has been placed in the public domain. .. Local Variables: mode: indented-text indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 End: Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.284 retrieving revision 1.285 diff -u -d -r1.284 -r1.285 --- pep-0000.txt 27 Aug 2004 13:44:37 -0000 1.284 +++ pep-0000.txt 27 Aug 2004 17:30:09 -0000 1.285 @@ -58,6 +58,7 @@ I 291 Backward Compatibility for Standard Library Norwitz I 306 How to Change Python's Grammar Hudson I 320 Python 2.4 Release Schedule Warsaw + I 333 Python Web Server Gateway Interface v1.0 Eby I 3000 Python 3.0 Plans Kuchling, Cannon Accepted PEPs (accepted; may not be implemented yet) @@ -360,6 +361,7 @@ S 330 Python Bytecode Verification Pelletier S 331 Locale-Independent Float/String conversions Reis S 332 Byte vectors and String/Unicode Unification Montanaro + I 333 Python Web Server Gateway Interface v1.0 Eby SR 666 Reject Foolish Indentation Creighton S 754 IEEE 754 Floating Point Special Values Warnes I 3000 Python 3.0 Plans Kuchling, Cannon @@ -398,6 +400,7 @@ Dörwald, Walter Drake, Fred fdrake@acm.org Dubois, Paul F. paul@pfdubois.com + Eby, Phillip J. pje@telecommunity.com Epler, Jeff jepler@unpythonic.net Eppstein, David eppstein@ics.uci.edu Evans, Clark C. cce@clarkevans.com From akuchling at users.sourceforge.net Fri Aug 27 20:11:26 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Fri Aug 27 20:11:30 2004 Subject: [Python-checkins] python/nondist/peps pep-0273.txt,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31514 Modified Files: pep-0273.txt Log Message: Add historical note Index: pep-0273.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0273.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- pep-0273.txt 21 Dec 2002 11:38:47 -0000 1.9 +++ pep-0273.txt 27 Aug 2004 18:11:22 -0000 1.10 @@ -11,12 +11,22 @@ Abstract + This PEP adds the ability to import Python modules *.py, *.py[co] and packages from zip archives. The same code is used to speed up normal directory imports provided os.listdir is available. +Note + + Zip imports were added to Python 2.3, but the final implementation + uses an approach different from the one described in this PEP. + The 2.3 implementation is SourceForge patch #652586, which adds + new import hooks described in PEP 302. + + The rest of this PEP is therefore only of historical interest. + Specification Currently, sys.path is a list of directory names as strings. If From akuchling at users.sourceforge.net Fri Aug 27 20:13:51 2004 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Fri Aug 27 20:13:55 2004 Subject: [Python-checkins] python/nondist/peps pep-0000.txt, 1.285, 1.286 pep-0273.txt, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31957 Modified Files: pep-0000.txt pep-0273.txt Log Message: Mark PEP 273 as final Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.285 retrieving revision 1.286 diff -u -d -r1.285 -r1.286 --- pep-0000.txt 27 Aug 2004 17:30:09 -0000 1.285 +++ pep-0000.txt 27 Aug 2004 18:13:48 -0000 1.286 @@ -89,7 +89,6 @@ S 266 Optimizing Global Variable/Attribute Access Montanaro S 267 Optimized Access to Module Namespaces Hylton S 268 Extended HTTP functionality and WebDAV Stein - S 273 Import Modules from Zip Archives Ahlstrom S 274 Dict Comprehensions Warsaw S 275 Switching on Multiple Values Lemburg S 276 Simple Iterator for ints Althoff @@ -157,6 +156,7 @@ SF 261 Support for "wide" Unicode characters Prescod SF 263 Defining Python Source Code Encodings Lemburg SF 264 Future statements in simulated shells Hudson + SF 273 Import Modules from Zip Archives Ahlstrom SF 277 Unicode file name support for Windows NT Hodgson SF 279 The enumerate() built-in function Hettinger SF 282 A Logging System Sajip, Mick @@ -302,7 +302,7 @@ SR 270 uniq method for list objects Petrone SR 271 Prefixing sys.path by command line option Giacometti IF 272 API for Block Encryption Algorithms v1.0 Kuchling - S 273 Import Modules from Zip Archives Ahlstrom + SF 273 Import Modules from Zip Archives Ahlstrom S 274 Dict Comprehensions Warsaw S 275 Switching on Multiple Values Lemburg S 276 Simple Iterator for ints Althoff Index: pep-0273.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0273.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- pep-0273.txt 27 Aug 2004 18:11:22 -0000 1.10 +++ pep-0273.txt 27 Aug 2004 18:13:48 -0000 1.11 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: jim@interet.com (James C. Ahlstrom) -Status: Draft +Status: Final Type: Standards Track Created: 11-Oct-2001 Post-History: 26-Oct-2001 From bcannon at users.sourceforge.net Fri Aug 27 20:43:35 2004 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Aug 27 20:43:40 2004 Subject: [Python-checkins] python/nondist/peps pep-3000.txt,1.5,1.6 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4984 Modified Files: pep-3000.txt Log Message: Remove __cmp__ mention. Add about list comps being syntactic sugar for genexps to list(). Reword mention of stdlib reorg. Mention comparisons other than == and != between disparate types will raise an error unless excplicitly allowed. Index: pep-3000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-3000.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- pep-3000.txt 27 Aug 2004 13:16:31 -0000 1.5 +++ pep-3000.txt 27 Aug 2004 18:43:32 -0000 1.6 @@ -66,8 +66,10 @@ error variable? [3]_ * ``True`` and ``False`` become keywords [4]_ * ``as`` becomes a keyword [5]_ -* Remove ``__cmp__`` as a magic method -- rich comparisons make - ``__cmp__`` conflict with TOOWTDI [6]_ +* Have list comprehensions be syntactic sugar for passing an + equivalent generator expression to ``list()``. +* Comparisons other than ``==`` and ``!=`` between disparate types + will raise an exception unless explicitly supported by the type To be removed: @@ -86,7 +88,6 @@ * Relevant functions should consume iterators (e.g. ``min()``, ``max()``) - To be removed: * ``apply()``: use ``f(*args, **kw)`` instead [2]_ @@ -107,7 +108,7 @@ Standard library ================ -Reorganize the standard library into packages +* Reorganize the standard library to not be as shallow To be removed: @@ -133,9 +134,6 @@ .. [5] python-dev email (" "as" to be a keyword?") http://mail.python.org/pipermail/python-dev/2004-July/046316.html -.. [6] python-dev email ("lists vs. tuples") - http://mail.python.org/pipermail/python-dev/2003-March/034073.html - Copyright ========= From rhettinger at users.sourceforge.net Fri Aug 27 22:29:01 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Aug 27 22:29:06 2004 Subject: [Python-checkins] python/nondist/peps pep-0000.txt, 1.286, 1.287 pep-0218.txt, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23309 Modified Files: pep-0000.txt pep-0218.txt Log Message: Update and finalize PEP 218 (builtin set types): * List the additional methods and operators that are supported. * List differences between sets.py and the built-in types. * Mark the {-} syntax as rejected by Guido until Python 3000. * Note that genexps make set comprehensions moot. * Mark the pep as final and implemented. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.286 retrieving revision 1.287 diff -u -d -r1.286 -r1.287 --- pep-0000.txt 27 Aug 2004 18:13:48 -0000 1.286 +++ pep-0000.txt 27 Aug 2004 20:28:57 -0000 1.287 @@ -73,7 +73,6 @@ I 206 2.0 Batteries Included Zadka S 209 Adding Multidimensional Arrays Barrett, Oliphant S 215 String Interpolation Yee - S 218 Adding a Built-In Set Object Type Wilson S 228 Reworking Python's Numeric Model Zadka, GvR S 237 Unifying Long Integers and Integers Zadka, GvR S 239 Adding a Rational Type to Python Craig, Zadka @@ -137,6 +136,7 @@ SF 208 Reworking the Coercion Model Schemenauer, Lemburg SF 214 Extended Print Statement Warsaw SF 217 Display Hook for Interactive Use Zadka + SF 218 Adding a Built-In Set Object Type Wilson, Hettinger SF 221 Import As Wouters SF 223 Change the Meaning of \x Escapes Peters I 226 Python 2.1 Release Schedule Hylton @@ -247,7 +247,7 @@ SD 215 String Interpolation Yee IR 216 Docstring Format Zadka SF 217 Display Hook for Interactive Use Zadka - S 218 Adding a Built-In Set Object Type Wilson + SF 218 Adding a Built-In Set Object Type Wilson, Hettinger SD 219 Stackless Python McMillan ID 220 Coroutines, Generators, Continuations McMillan SF 221 Import As Wouters Index: pep-0218.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0218.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- pep-0218.txt 15 Oct 2002 00:24:12 -0000 1.8 +++ pep-0218.txt 27 Aug 2004 20:28:58 -0000 1.9 @@ -1,8 +1,8 @@ PEP: 218 Title: Adding a Built-In Set Object Type Version: $Revision$ -Author: gvwilson@ddj.com (Greg Wilson) -Status: Draft +Author: gvwilson at ddj.com (Greg Wilson), python at rcn.com (Raymond Hettinger) +Status: Final Type: Standards Track Python-Version: 2.2 Created: 31-Jul-2000 @@ -16,11 +16,9 @@ module is widely used. After explaining why sets are desirable, and why the common idiom of using dictionaries in their place is inadequate, we describe how we intend built-in sets to work, and - then how the preliminary Set module will behave. The penultimate + then how the preliminary Set module will behave. The last section discusses the mutability (or otherwise) of sets and set elements, and the solution which the Set module will implement. - The last section then looks at alternatives that were considered, - but discarded. Rationale @@ -45,21 +43,12 @@ dictionaries containing key/value pairs. -Long-Term Proposal +Proposal The long-term goal of this PEP is to add a built-in set type to Python. This type will be an unordered collection of unique values, just as a dictionary is an unordered collection of - key/value pairs. Constant sets will be represented using the - usual mathematical notation, so that "{1, 2, 3}" will be a set of - three integers. - - In order to avoid ambiguity, the empty set will be written "{-}", - rather than "{}" (which is already used to represent empty - dictionaries). We feel that this notation is as reasonable as the - use of "(3,)" to represent single-element tuples; a more radical - strategy is discussed in the "Alternatives" section, and more - readable than the earlier proposal "{,}". + key/value pairs. Iteration and comprehension will be implemented in the obvious ways, so that: @@ -68,7 +57,7 @@ will step through the elements of S in arbitrary order, while: - {x**2 for x in S} + set(x**2 for x in S) will produce a set containing the squares of all elements in S, Membership will be tested using "in" and "not in", and basic set @@ -79,6 +68,9 @@ & intersection ^ symmetric difference - asymmetric difference + == != equality and inequality tests + < <= >= > subset and superset tests + and methods: @@ -99,11 +91,21 @@ S.clear() Remove all elements from this set. - and one new built-in conversion function: + S.copy() Make a new set. + + s.issuperset() Check for a superset relationship. + + s.issubset() Check for a subset relationship. + + + and two new built-in conversion functions: set(x) Create a set containing the elements of the collection "x". + frozenset(x) Create an immutable set containing the elements + of the collection "x". + Notes: 1. We propose using the bitwise operators "|&" for intersection @@ -117,44 +119,39 @@ of "add" will also avoid confusion between that operation and set union. - 3. Sets raise "LookupError" exceptions, rather than "KeyError" or - "ValueError", because set elements are neither keys nor values. +Set Notation -Open Issues for the Long-Term Proposal + The PEP originally proposed {1,2,3} as the set notation and {-} for + the empty set. Experience with Python 2.3's sets.py showed that + the notation was not necessary. Also, there was some risk of making + dictionaries less instantly recognizable. - Earlier drafts of PEP 218 had only a single set type, but the - sets.py implementation in Python 2.3 has two, Set and - ImmutableSet. The long-term proposal has a single built-in - conversion function, set(iterable); how should instances of a - built-in immutable set type be created? Possibilities include a - second immutable_set() built-in, or perhaps the set() function - could take an additional argument, - e.g. set(iterable, immutable=True)? + It was also contemplated that the braced notation would support set + comprehensions; however, Python 2.4 provided generator expressions + which fully met that need and did so it a more general way. + (See PEP 289 for details on generator expressions). - The PEP proposes {1,2,3} as the set notation and {-} for the empty - set. Would there be different syntax for an immutable and a - mutable set? Perhaps the built-in syntax would only be for - mutable sets, and an immutable set would be created from a mutable - set using the appropriate built-in function, - e.g. immutable_set({1,2,3}). + So, Guido ruled that there would not be a set syntax; however, the + issue could be revisited for Python 3000 (see PEP 3000). -Short-Term Proposal +History - In order to determine whether there is enough demand for sets to - justify making them a built-in type, and to give users a chance to - try out the semantics we propose for sets, our short-term proposal - is to add a "Set" class to the standard Python library. This - class will have the operators and methods described above; it will - also have named methods corresponding to all of the operations: a - "union" method for "|", and a "union_update" method for "|=", and - so on. + To gain experience with sets, a pure python module was introduced + in Python 2.3. Based on that implementation, the set and frozenset + types were introduced in Python 2.4. The improvements are: - This class will use a dictionary internally to contain set values. - To avoid having to duplicate values (e.g. for iteration through - the set), the class will rely on the iterators added in Python - 2.2. + * Better hash algorithm for frozensets + * More compact pickle format (storing only an element list + instead of a dictionary of key:value pairs where the value + is always True). + * Use a __reduce__ function so that deep copying is automatic. + * The BaseSet concept was eliminated. + * The union_update() method became just update(). + * Auto-conversion between mutable and immutable sets was dropped. + * The _repr method was dropped (the need is met by the new + sorted() built-in function). Tim Peters believes that the class's constructor should take a single sequence as an argument, and populate the set with that @@ -173,10 +170,8 @@ >>> Set(1, 2, 3, 4) # case 2 - On the other, other hand, if Python does adopt a dictionary-like - notation for sets in the future, then case 2 will become - redundant. We have therefore adopted the first strategy, in which - the initializer takes a single iterable argument. + Ultimately, we adopted the first strategy in which the initializer + takes a single iterable argument. Mutability @@ -188,26 +183,19 @@ to be immutable, this would preclude sets of sets (which are widely used in graph algorithms and other applications). + Earlier drafts of PEP 218 had only a single set type, but the + sets.py implementation in Python 2.3 has two, Set and + ImmutableSet. For Python 2.4, the new built-in types were named + set and frozenset which are slightly less cumbersome. + There are two classes implemented in the "sets" module. Instances of the Set class can be modified by the addition or removal of elements, and the ImmutableSet class is "frozen", with an unchangeable collection of elements. Therefore, an ImmutableSet may be used as a dictionary key or as a set element, but cannot be updated. Both types of set require that their elements are - immutable, hashable objects. - - -Alternatives - - An alternative to the notation "{-}" for the empty set would be to - re-define "{}" to be the empty collection, rather than the empty - dictionary. Operations which made this object non-empty would - silently convert it to either a dictionary or a set; it would then - retain that type for the rest of its existence. This idea was - rejected because of its potential impact on existing Python - programs. A similar proposal to modify "dict.keys" and - "dict.values" to return sets, rather than lists, was rejected for - the same reasons. + immutable, hashable objects. Parallel comments apply to the "set" + and "frozenset" built-in types. Copyright From pje at users.sourceforge.net Fri Aug 27 23:14:45 2004 From: pje at users.sourceforge.net (pje@users.sourceforge.net) Date: Fri Aug 27 23:14:50 2004 Subject: [Python-checkins] python/nondist/peps pep-0333.txt,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32203 Modified Files: pep-0333.txt Log Message: Fix a formatting problem, and add today's posting date. Index: pep-0333.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0333.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- pep-0333.txt 27 Aug 2004 17:30:09 -0000 1.1 +++ pep-0333.txt 27 Aug 2004 21:14:42 -0000 1.2 @@ -8,7 +8,7 @@ Type: Informational Content-Type: text/x-rst Created: 07-Dec-2003 -Post-History: 07-Dec-2003, 08-Aug-2004, 20-Aug-2004 +Post-History: 07-Dec-2003, 08-Aug-2004, 20-Aug-2004, 27-Aug-2004 Abstract @@ -941,7 +941,7 @@ however, application developers will still have the option of using it as a helper class. For example, the code below works with the current WSGI spec, by passing the message object's ``items()`` (a list of -tuples) to ``start_response()``: +tuples) to ``start_response()``:: def application(environ, start_response): headers = Message() From goodger at users.sourceforge.net Fri Aug 27 23:19:50 2004 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Fri Aug 27 23:19:52 2004 Subject: [Python-checkins] python/nondist/peps pep-0001.txt,1.44,1.45 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv544 Modified Files: pep-0001.txt Log Message: clarifications Index: pep-0001.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0001.txt,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- pep-0001.txt 16 Jul 2004 19:27:23 -0000 1.44 +++ pep-0001.txt 27 Aug 2004 21:19:48 -0000 1.45 @@ -324,15 +324,16 @@ directly to the PEP author. For more mature, or finished PEPs you may want to submit corrections to the SourceForge `bug manager`_ or better yet, the SourceForge `patch manager`_ so that your changes don't get -lost. If the PEP author is a SF developer, assign the bug/patch to -him, otherwise assign it to the PEP editor. +lost. If the PEP author is a SourceForge developer, assign the +bug/patch to him, otherwise assign it to the PEP editor. When in doubt about where to send your changes, please check first with the PEP author and/or PEP editor. -PEP authors who are also SF committers, can update the PEPs themselves -by using "cvs commit" to commit their changes. Remember to also push -the formatted PEP text out to the web by doing the following:: +PEP authors who are also Python/SourceForge committers can update the +PEPs themselves by using "cvs commit" to commit their changes. PEP +authors with python.org access should also remember to push the +formatted PEP text out to the web by doing the following:: % python pep2html.py -i NUM From tim_one at users.sourceforge.net Fri Aug 27 23:32:08 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Aug 27 23:32:11 2004 Subject: [Python-checkins] python/dist/src/Objects unicodeobject.c, 2.221, 2.222 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2321/Objects Modified Files: unicodeobject.c Log Message: PyUnicode_Join(): Rewrote to use PySequence_Fast(). This doesn't do much to reduce the size of the code, but greatly improves its clarity. It's also quicker in what's probably the most common case (the argument iterable is a list). Against it, if the iterable isn't a list or a tuple, a temp tuple is materialized containing the entire input sequence, and that's a bigger temp memory burden. Yawn. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.221 retrieving revision 2.222 diff -u -d -r2.221 -r2.222 --- unicodeobject.c 27 Aug 2004 05:08:36 -0000 2.221 +++ unicodeobject.c 27 Aug 2004 21:32:02 -0000 2.222 @@ -3979,159 +3979,129 @@ PyUnicode_Join(PyObject *separator, PyObject *seq) { PyObject *internal_separator = NULL; - Py_UNICODE *sep; + const Py_UNICODE *sep; size_t seplen; - PyUnicodeObject *res = NULL; - size_t sz; /* # allocated bytes for string in res */ - size_t reslen; /* # used bytes */ - Py_UNICODE *p; /* pointer to free byte in res's string area */ - PyObject *it; /* iterator */ + PyUnicodeObject *res = NULL; /* the result */ + size_t res_alloc = 100; /* # allocated bytes for string in res */ + size_t res_used; /* # used bytes */ + Py_UNICODE *res_p; /* pointer to free byte in res's string area */ + PyObject *fseq; /* PySequence_Fast(seq) */ + int seqlen; /* len(fseq) -- number of items in sequence */ + const Py_UNICODE blank = ' '; PyObject *item; int i; - PyObject *temp; - - it = PyObject_GetIter(seq); - if (it == NULL) - return NULL; - - item = PyIter_Next(it); - if (item == NULL) { - if (PyErr_Occurred()) - goto onError; - /* empty sequence; return u"" */ - res = _PyUnicode_New(0); - goto Done; - } - /* If this is the only item, maybe we can get out cheap. */ - res = (PyUnicodeObject *)item; - item = PyIter_Next(it); - if (item == NULL) { - if (PyErr_Occurred()) - goto onError; - /* There's only one item in the sequence. */ - if (PyUnicode_CheckExact(res)) /* whatever.join([u]) -> u */ - goto Done; + fseq = PySequence_Fast(seq, ""); + if (fseq == NULL) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) + PyErr_Format(PyExc_TypeError, + "sequence expected, %.80s found", + seq->ob_type->tp_name); + return NULL; } - /* There are at least two to join (item != NULL), or there's only - * one but it's not an exact Unicode (item == NULL). res needs - * conversion to Unicode in either case. - * Caution: we may need to ensure a copy is made, and that's trickier - * than it sounds because, e.g., PyUnicode_FromObject() may return - * a shared object (which must not be mutated). - */ - if (! PyUnicode_Check(res) && ! PyString_Check(res)) { - PyErr_Format(PyExc_TypeError, - "sequence item 0: expected string or Unicode," - " %.80s found", - res->ob_type->tp_name); - Py_XDECREF(item); - goto onError; - } - temp = PyUnicode_FromObject((PyObject *)res); - if (temp == NULL) { - Py_XDECREF(item); - goto onError; - } - Py_DECREF(res); - if (item == NULL) { - /* res was the only item */ - res = (PyUnicodeObject *)temp; - goto Done; + seqlen = PySequence_Fast_GET_SIZE(fseq); + /* If empty sequence, return u"". */ + if (seqlen == 0) { + res = _PyUnicode_New(0); /* empty sequence; return u"" */ + goto Done; } - /* There are at least two items. As above, temp may be a shared object, - * so we need to copy it. - */ - reslen = PyUnicode_GET_SIZE(temp); - sz = reslen + 100; /* breathing room */ - if (sz < reslen || sz > INT_MAX) /* overflow -- no breathing room */ - sz = reslen; - res = _PyUnicode_New((int)sz); - if (res == NULL) { - Py_DECREF(item); - goto onError; + /* If singleton sequence with an exact Unicode, return that. */ + if (seqlen == 1) { + item = PySequence_Fast_GET_ITEM(fseq, 0); + if (PyUnicode_CheckExact(item)) { + Py_INCREF(item); + res = (PyUnicodeObject *)item; + goto Done; + } } - p = PyUnicode_AS_UNICODE(res); - Py_UNICODE_COPY(p, PyUnicode_AS_UNICODE(temp), (int)reslen); - p += reslen; - Py_DECREF(temp); - if (separator == NULL) { - Py_UNICODE blank = ' '; - sep = ␣ - seplen = 1; - } - else { - internal_separator = PyUnicode_FromObject(separator); - if (internal_separator == NULL) { - Py_DECREF(item); - goto onError; - } - sep = PyUnicode_AS_UNICODE(internal_separator); - seplen = PyUnicode_GET_SIZE(internal_separator); + /* At least two items to join, or one that isn't exact Unicode. */ + if (seqlen > 1) { + /* Set up sep and seplen -- they're needed. */ + if (separator == NULL) { + sep = ␣ + seplen = 1; + } + else { + internal_separator = PyUnicode_FromObject(separator); + if (internal_separator == NULL) + goto onError; + sep = PyUnicode_AS_UNICODE(internal_separator); + seplen = PyUnicode_GET_SIZE(internal_separator); + } } - i = 1; - do { + /* Get space. */ + res = _PyUnicode_New((int)res_alloc); + if (res == NULL) + goto onError; + res_p = PyUnicode_AS_UNICODE(res); + res_used = 0; + + for (i = 0; i < seqlen; ++i) { size_t itemlen; - size_t newreslen; + size_t new_res_used; - /* Catenate the separator, then item. */ - /* First convert item to Unicode. */ - if (!PyUnicode_Check(item)) { - PyObject *v; - if (!PyString_Check(item)) { - PyErr_Format(PyExc_TypeError, - "sequence item %i: expected string or Unicode," - " %.80s found", - i, item->ob_type->tp_name); - Py_DECREF(item); - goto onError; - } - v = PyUnicode_FromObject(item); - Py_DECREF(item); - item = v; - if (item == NULL) - goto onError; + item = PySequence_Fast_GET_ITEM(fseq, i); + /* Convert item to Unicode. */ + if (! PyUnicode_Check(item) && ! PyString_Check(item)) { + PyErr_Format(PyExc_TypeError, + "sequence item %i: expected string or Unicode," + " %.80s found", + i, item->ob_type->tp_name); + goto onError; } + item = PyUnicode_FromObject(item); + if (item == NULL) + goto onError; + /* We own a reference to item from here on. */ + /* Make sure we have enough space for the separator and the item. */ itemlen = PyUnicode_GET_SIZE(item); - newreslen = reslen + seplen + itemlen; - if (newreslen < reslen || newreslen > INT_MAX) + new_res_used = res_used + itemlen; + if (new_res_used < res_used || new_res_used > INT_MAX) goto Overflow; - if (newreslen > sz) { + if (i < seqlen - 1) { + new_res_used += seplen; + if (new_res_used < res_used || new_res_used > INT_MAX) + goto Overflow; + } + if (new_res_used > res_alloc) { + /* double allocated size until it's big enough */ do { - size_t oldsize = sz; - sz += sz; - if (sz < oldsize || sz > INT_MAX) + size_t oldsize = res_alloc; + res_alloc += res_alloc; + if (res_alloc < oldsize || res_alloc > INT_MAX) goto Overflow; - } while (newreslen > sz); - if (_PyUnicode_Resize(&res, (int)sz) < 0) { + } while (new_res_used > res_alloc); + if (_PyUnicode_Resize(&res, (int)res_alloc) < 0) { Py_DECREF(item); goto onError; } - p = PyUnicode_AS_UNICODE(res) + reslen; + res_p = PyUnicode_AS_UNICODE(res) + res_used; } - Py_UNICODE_COPY(p, sep, (int)seplen); - p += seplen; - Py_UNICODE_COPY(p, PyUnicode_AS_UNICODE(item), (int)itemlen); - p += itemlen; - Py_DECREF(item); - reslen = newreslen; - ++i; - item = PyIter_Next(it); - } while (item != NULL); - if (PyErr_Occurred()) - goto onError; + /* Copy item, and maybe the separator. */ + Py_UNICODE_COPY(res_p, PyUnicode_AS_UNICODE(item), (int)itemlen); + res_p += itemlen; + if (i < seqlen - 1) { + Py_UNICODE_COPY(res_p, sep, (int)seplen); + res_p += seplen; + } + Py_DECREF(item); + res_used = new_res_used; + } - if (_PyUnicode_Resize(&res, (int)reslen) < 0) + /* Shrink res to match the used area; this probably can't fail, + * but it's cheap to check. + */ + if (_PyUnicode_Resize(&res, (int)res_used) < 0) goto onError; Done: Py_XDECREF(internal_separator); - Py_DECREF(it); + Py_DECREF(fseq); return (PyObject *)res; Overflow: @@ -4142,7 +4112,7 @@ onError: Py_XDECREF(internal_separator); - Py_DECREF(it); + Py_DECREF(fseq); Py_XDECREF(res); return NULL; } From tim_one at users.sourceforge.net Sat Aug 28 00:35:53 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Aug 28 00:35:56 2004 Subject: [Python-checkins] python/dist/src/Objects unicodeobject.c, 2.222, 2.223 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12843/Objects Modified Files: unicodeobject.c Log Message: PyUnicode_Join(): Bozo Alert. While this is chugging along, it may need to convert str objects from the iterable to unicode. So, if someone set the system default encoding to something nasty enough, the conversion process could mutate the input iterable as a side effect, and PySequence_Fast doesn't hide that from us if the input was a list. IOW, can't assume the size of PySequence_Fast's result is invariant across PyUnicode_FromObject() calls. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.222 retrieving revision 2.223 diff -u -d -r2.222 -r2.223 --- unicodeobject.c 27 Aug 2004 21:32:02 -0000 2.222 +++ unicodeobject.c 27 Aug 2004 22:35:44 -0000 2.223 @@ -4000,6 +4000,13 @@ return NULL; } + /* Grrrr. A codec may be invoked to convert str objects to + * Unicode, and so it's possible to call back into Python code + * during PyUnicode_FromObject(), and so it's possible for a sick + * codec to change the size of fseq (if seq is a list). Therefore + * we have to keep refetching the size -- can't assume seqlen + * is invariant. + */ seqlen = PySequence_Fast_GET_SIZE(fseq); /* If empty sequence, return u"". */ if (seqlen == 0) { @@ -4029,6 +4036,8 @@ goto onError; sep = PyUnicode_AS_UNICODE(internal_separator); seplen = PyUnicode_GET_SIZE(internal_separator); + /* In case PyUnicode_FromObject() mutated seq. */ + seqlen = PySequence_Fast_GET_SIZE(fseq); } } @@ -4057,6 +4066,9 @@ goto onError; /* We own a reference to item from here on. */ + /* In case PyUnicode_FromObject() mutated seq. */ + seqlen = PySequence_Fast_GET_SIZE(fseq); + /* Make sure we have enough space for the separator and the item. */ itemlen = PyUnicode_GET_SIZE(item); new_res_used = res_used + itemlen; From dcjim at users.sourceforge.net Sat Aug 28 16:57:58 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Sat Aug 28 16:58:04 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.39, 1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19515/Lib/test Modified Files: test_doctest.py Log Message: - setUp and tearDown functions are now passed the test object - Added a set_unittest_reportflags to set default reporting flags used when running doctests under unittest control. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- test_doctest.py 27 Aug 2004 14:56:58 -0000 1.39 +++ test_doctest.py 28 Aug 2004 14:57:56 -0000 1.40 @@ -1653,11 +1653,11 @@ You can supply setUp and tearDown functions: - >>> def setUp(): + >>> def setUp(t): ... import test.test_doctest ... test.test_doctest.sillySetup = True - >>> def tearDown(): + >>> def tearDown(t): ... import test.test_doctest ... del test.test_doctest.sillySetup @@ -1676,6 +1676,21 @@ ... AttributeError: 'module' object has no attribute 'sillySetup' + The setUp and tearDown funtions are passed test objects. Here + we'll use the setUp function to supply the missing variable y: + + >>> def setUp(test): + ... test.globs['y'] = 1 + + >>> suite = doctest.DocTestSuite('test.sample_doctest', setUp=setUp) + >>> suite.run(unittest.TestResult()) + + + Here, we didn't need to use a tearDown function because we + modified the test globals, which are a copy of the + sample_doctest module dictionary. The test globals are + automatically cleared for us after a test. + Finally, you can provide an alternate test finder. Here we'll use a custom test_finder to to run just the test named bar. However, the test in the module docstring, and the two tests @@ -1744,11 +1759,11 @@ You can supply setUp and teatDoen functions: - >>> def setUp(): + >>> def setUp(t): ... import test.test_doctest ... test.test_doctest.sillySetup = True - >>> def tearDown(): + >>> def tearDown(t): ... import test.test_doctest ... del test.test_doctest.sillySetup @@ -1768,7 +1783,22 @@ ... AttributeError: 'module' object has no attribute 'sillySetup' - """ + The setUp and tearDown funtions are passed test objects. + Here, we'll use a setUp function to set the favorite color in + test_doctest.txt: + + >>> def setUp(test): + ... test.globs['favorite_color'] = 'blue' + + >>> suite = doctest.DocFileSuite('test_doctest.txt', setUp=setUp) + >>> suite.run(unittest.TestResult()) + + + Here, we didn't need to use a tearDown function because we + modified the test globals. The test globals are + automatically cleared for us after a test. + + """ def test_trailing_space_in_test(): """ @@ -1779,6 +1809,82 @@ foo \n """ + +def test_unittest_reportflags(): + """Default unittest reporting flags can be set to control reporting + + Here, we'll set the REPORT_ONLY_FIRST_FAILURE option so we see + only the first failure of each test. First, we'll look at the + output without the flag. The file test_doctest.txt file has two + tests. They both fail if blank lines are disabled: + + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... optionflags=doctest.DONT_ACCEPT_BLANKLINE) + >>> import unittest + >>> result = suite.run(unittest.TestResult()) + >>> print result.failures[0][1] # doctest: +ELLIPSIS + Traceback ... + Failed example: + favorite_color + ... + Failed example: + if 1: + ... + + Note that we see both failures displayed. + + >>> old = doctest.set_unittest_reportflags( + ... doctest.REPORT_ONLY_FIRST_FAILURE) + + Now, when we run the test: + + >>> result = suite.run(unittest.TestResult()) + >>> print result.failures[0][1] # doctest: +ELLIPSIS + Traceback ... + Failed example: + favorite_color + Exception raised: + ... + NameError: name 'favorite_color' is not defined + + + + We get only the first failure. + + If we give any reporting options when we set up the tests, + however: + + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... optionflags=doctest.DONT_ACCEPT_BLANKLINE | doctest.REPORT_NDIFF) + + Then the default eporting options are ignored: + + >>> result = suite.run(unittest.TestResult()) + >>> print result.failures[0][1] # doctest: +ELLIPSIS + Traceback ... + Failed example: + favorite_color + ... + Failed example: + if 1: + print 'a' + print + print 'b' + Differences (ndiff with -expected +actual): + a + - + + + b + + + + + Test runners can restore the formatting flags after they run: + + >>> ignored = doctest.set_unittest_reportflags(old) + + """ + # old_test1, ... used to live in doctest.py, but cluttered it. Note # that these use the deprecated doctest.Tester, so should go away (or # be rewritten) someday. From dcjim at users.sourceforge.net Sat Aug 28 16:58:14 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Sat Aug 28 16:58:18 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.94,1.95 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19515/Lib Modified Files: doctest.py Log Message: - setUp and tearDown functions are now passed the test object - Added a set_unittest_reportflags to set default reporting flags used when running doctests under unittest control. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.94 retrieving revision 1.95 diff -u -d -r1.94 -r1.95 --- doctest.py 27 Aug 2004 04:29:23 -0000 1.94 +++ doctest.py 28 Aug 2004 14:57:55 -0000 1.95 @@ -179,6 +179,7 @@ 'REPORT_UDIFF', 'REPORT_CDIFF', 'REPORT_NDIFF', + 'REPORT_ONLY_FIRST_FAILURE', # 1. Utility Functions 'is_private', # 2. Example & DocTest @@ -1991,6 +1992,65 @@ ## 8. Unittest Support ###################################################################### +_unittest_reportflags = 0 +valid_unittest_reportflags = ( + REPORT_CDIFF | + REPORT_UDIFF | + REPORT_NDIFF | + REPORT_ONLY_FIRST_FAILURE + ) +def set_unittest_reportflags(flags): + """Sets the unit test option flags + + The old flag is returned so that a runner could restore the old + value if it wished to: + + >>> old = _unittest_reportflags + >>> set_unittest_reportflags(REPORT_NDIFF | + ... REPORT_ONLY_FIRST_FAILURE) == old + True + + >>> import doctest + >>> doctest._unittest_reportflags == (REPORT_NDIFF | + ... REPORT_ONLY_FIRST_FAILURE) + True + + Only reporting flags can be set: + + >>> set_unittest_reportflags(ELLIPSIS) + Traceback (most recent call last): + ... + ValueError: ('Invalid flags passed', 8) + + >>> set_unittest_reportflags(old) == (REPORT_NDIFF | + ... REPORT_ONLY_FIRST_FAILURE) + True + + """ + + # extract the valid reporting flags: + rflags = flags & valid_unittest_reportflags + + # Now remove these flags from the given flags + nrflags = flags ^ rflags + + if nrflags: + raise ValueError("Invalid flags passed", flags) + + global _unittest_reportflags + old = _unittest_reportflags + _unittest_reportflags = flags + return old + + +class FakeModule: + """Fake module created by tests + """ + + def __init__(self, dict, name): + self.__dict__ = dict + self.__name__ = name + class DocTestCase(unittest.TestCase): def __init__(self, test, optionflags=0, setUp=None, tearDown=None, @@ -2004,23 +2064,37 @@ self._dt_tearDown = tearDown def setUp(self): + test = self._dt_test + if self._dt_setUp is not None: - self._dt_setUp() + self._dt_setUp(test) def tearDown(self): + test = self._dt_test + if self._dt_tearDown is not None: - self._dt_tearDown() + self._dt_tearDown(test) + + test.globs.clear() def runTest(self): test = self._dt_test old = sys.stdout new = StringIO() - runner = DocTestRunner(optionflags=self._dt_optionflags, + optionflags = self._dt_optionflags + + if not (optionflags & valid_unittest_reportflags): + # The option flags don't include any reporting flags, + # so add the default reporting flags + optionflags |= _unittest_reportflags + + runner = DocTestRunner(optionflags=optionflags, checker=self._dt_checker, verbose=False) try: runner.DIVIDER = "-"*70 - failures, tries = runner.run(test, out=new.write) + failures, tries = runner.run( + test, out=new.write, clear_globs=False) finally: sys.stdout = old @@ -2105,9 +2179,11 @@ """ + self.setUp() runner = DebugRunner(optionflags=self._dt_optionflags, checker=self._dt_checker, verbose=False) runner.run(self._dt_test) + self.tearDown() def id(self): return self._dt_test.name @@ -2121,10 +2197,8 @@ def shortDescription(self): return "Doctest: " + self._dt_test.name -def DocTestSuite(module=None, globs=None, extraglobs=None, - optionflags=0, test_finder=None, - setUp=lambda: None, tearDown=lambda: None, - checker=None): +def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, + **options): """ Convert doctest tests for a module to a unittest test suite. @@ -2138,6 +2212,32 @@ can be either a module or a module name. If no argument is given, the calling module is used. + + A number of options may be provided as keyword arguments: + + package + The name of a Python package. Text-file paths will be + interpreted relative to the directory containing this package. + The package may be supplied as a package object or as a dotted + package name. + + setUp + The name of a set-up function. This is called before running the + tests in each file. The setUp function will be passed a DocTest + object. The setUp function can access the test globals as the + globs attribute of the test passed. + + tearDown + The name of a tear-down function. This is called after running the + tests in each file. The tearDown function will be passed a DocTest + object. The tearDown function can access the test globals as the + globs attribute of the test passed. + + globs + A dictionary containing initial global variables for the tests. + + optionflags + A set of doctest option flags expressed as an integer. """ if test_finder is None: @@ -2147,7 +2247,9 @@ tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) if globs is None: globs = module.__dict__ - if not tests: # [XX] why do we want to do this? + if not tests: + # Why do we want to do this? Because it reveals a bug that might + # otherwise be hidden. raise ValueError(module, "has no tests") tests.sort() @@ -2160,8 +2262,7 @@ if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] test.filename = filename - suite.addTest(DocTestCase(test, optionflags, setUp, tearDown, - checker)) + suite.addTest(DocTestCase(test, **options)) return suite @@ -2179,9 +2280,7 @@ % (self._dt_test.name, self._dt_test.filename, err) ) -def DocFileTest(path, package=None, globs=None, - setUp=None, tearDown=None, - optionflags=0): +def DocFileTest(path, package=None, globs=None, **options): package = _normalize_module(package) name = path.split('/')[-1] dir = os.path.split(package.__file__)[0] @@ -2193,7 +2292,7 @@ test = DocTestParser().get_doctest(doc, globs, name, path, 0) - return DocFileCase(test, optionflags, setUp, tearDown) + return DocFileCase(test, **options) def DocFileSuite(*paths, **kw): """Creates a suite of doctest files. @@ -2213,14 +2312,22 @@ setUp The name of a set-up function. This is called before running the - tests in each file. + tests in each file. The setUp function will be passed a DocTest + object. The setUp function can access the test globals as the + globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the - tests in each file. + tests in each file. The tearDown function will be passed a DocTest + object. The tearDown function can access the test globals as the + globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. + + optionflags + A set of doctest option flags expressed as an integer. + """ suite = unittest.TestSuite() From dcjim at users.sourceforge.net Sat Aug 28 16:58:34 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Sat Aug 28 16:58:37 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_threading_local.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19674/Lib/test Modified Files: test_threading_local.py Log Message: setUp and tearDown functions are now passed the test object Index: test_threading_local.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_threading_local.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- test_threading_local.py 14 Jul 2004 19:07:15 -0000 1.1 +++ test_threading_local.py 28 Aug 2004 14:58:31 -0000 1.2 @@ -12,9 +12,9 @@ else: import _threading_local local_orig = _threading_local.local - def setUp(): + def setUp(test): _threading_local.local = _local - def tearDown(): + def tearDown(test): _threading_local.local = local_orig suite.addTest(DocTestSuite('_threading_local', setUp=setUp, tearDown=tearDown) From dcjim at users.sourceforge.net Sat Aug 28 17:22:15 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Sat Aug 28 17:22:17 2004 Subject: [Python-checkins] python/dist/src/Lib unittest.py,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23211/Lib Modified Files: unittest.py Log Message: Added an __iter__ method for test suites. Index: unittest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/unittest.py,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- unittest.py 12 Feb 2004 17:35:07 -0000 1.34 +++ unittest.py 28 Aug 2004 15:22:12 -0000 1.35 @@ -400,6 +400,9 @@ __str__ = __repr__ + def __iter__(self): + return iter(self._tests) + def countTestCases(self): cases = 0 for test in self._tests: From dcjim at users.sourceforge.net Sat Aug 28 17:22:14 2004 From: dcjim at users.sourceforge.net (dcjim@users.sourceforge.net) Date: Sat Aug 28 17:22:20 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_unittest.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23211/Lib/test Added Files: test_unittest.py Log Message: Added an __iter__ method for test suites. --- NEW FILE: test_unittest.py --- """Test script for unittest. This just includes tests for new features. We really need a full set of tests. """ import unittest def test_TestSuite_iter(): """ >>> test1 = unittest.FunctionTestCase(lambda: None) >>> test2 = unittest.FunctionTestCase(lambda: None) >>> suite = unittest.TestSuite((test1, test2)) >>> tests = [] >>> for test in suite: ... tests.append(test) >>> tests == [test1, test2] True """ ###################################################################### ## Main ###################################################################### def test_main(): from test import test_support, test_unittest test_support.run_doctest(test_unittest, verbosity=True) if __name__ == '__main__': test_main() From rhettinger at users.sourceforge.net Sat Aug 28 21:12:48 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Aug 28 21:12:51 2004 Subject: [Python-checkins] python/nondist/sandbox/string alt292.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/string In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28248 Added Files: alt292.py Log Message: Proposed improvements to the PEP292 implementation. * Returns a str if all inputs are a string. * Error messages now include line number and token. * Allows mapping in the form of keyword arguments. * Use of locale specific alphabets for identifiers is now trapped and reported. Formley it would match the ASCII substring and either raise a KeyError, make the wrong substitution, or be skipped. * Improve presentation and commenting of the regular expression. * Simplified the implementation where possible. * Implement as a function rather than a class: - Eliminates separate (and possibly remote) instantiation and application - Allows the function to be self documenting and more referencable that % - Necessay for implementing correct return type and keyword arguments - Makes the code clearer and better serves as a model for other code. * Add doctests to illustrate the improvements. --- NEW FILE: alt292.py --- r''' Doctests for PEP 292's string template functions First, it is now a function and accepts either mappings or keyword arguments: >>> dollarsub('the $xxx and', {'xxx':10}) 'the 10 and' >>> dollarsub('the $xxx and', xxx='10') 'the 10 and' Next, it makes sure the return type is a str if all the inputs are a str. Any unicode components will cause a unicode output. This matches the behavior of other re and string ops: >>> dollarsub('the $xxx and', xxx='10') 'the 10 and' >>> dollarsub(u'the $xxx and', xxx='10') u'the 10 and' >>> dollarsub('the $xxx and', xxx=u'10') u'the 10 and' >>> dollarsub(u'the $xxx and', xxx=u'10') u'the 10 and' Non-strings are coerced to the type of the template: >>> dollarsub('the $xxx and', xxx=10) 'the 10 and' >>> dollarsub(u'the $xxx and', xxx=10) u'the 10 and' The ValueErrors are now more specific. They include the line number and the mismatched token: >>> t = """line one ... line two ... the $@malformed token ... line four""" >>> dollarsub(t, {}) Traceback (most recent call last): . . . ValueError: Invalid placeholder on line 3: '@malformed' Also, the re pattern was changed just a bit to catch an important class of locale specific errors where a user may use a non-ASCII identifier. The previous implementation would match up to the first non-ASCII character and then return a KeyError if the abbreviated is (hopefully) found. Now, it returns a value error highlighting the problem identifier. Note, we still only accept Python identifiers but have improved error detection: >>> import locale >>> savloc = locale.setlocale(locale.LC_ALL) >>> _ = locale.setlocale(locale.LC_ALL, 'spanish') >>> t = u'Returning $ma\u00F1ana or later.' >>> dollarsub(t, {}) Traceback (most recent call last): . . . ValueError: Invalid placeholder on line 1: u'ma\xf1ana' >>> _ = locale.setlocale(locale.LC_ALL, savloc) ''' import re as _re # Search for $$, $identifier, ${identifier}, and any bare $'s _pattern = _re.compile(r""" \$(\$)| # Escape sequence of two $ signs \$([_a-z][_a-z0-9]*(?!\w))| # $ and a Python identifier \${([_a-z][_a-z0-9]*)}| # $ and a brace delimited identifier \$(\S*) # Catchall for ill-formed $ expressions """, _re.IGNORECASE | _re.VERBOSE | _re.LOCALE) # Pattern notes: # # The pattern for $identifier includes a negative lookahead assertion # to make sure that the identifier is not followed by a locale specific # alphanumeric character other than [_a-z0-9]. The idea is to make sure # not to partially match an ill-formed identifiers containing characters # from other alphabets. Without the assertion the Spanish word for # tomorrow "ma~nana" (where ~n is 0xF1) would improperly match of "ma" # much to the surprise of the end-user (possibly an non-programmer). # # The catchall pattern has to come last because it captures non-space # characters after a dollar sign not matched by a previous group. Those # captured characters make the error messages more informative. # # The substitution functions rely on the first three patterns matching # with a non-empty string. If that changes, then change lines like # "if named" to "if named is not None". del _re def dollarsub(template, mapping=None, **kwds): """A function for supporting $-substitutions.""" if mapping is None: mapping = kwds def convert(mo): escaped, named, braced, catchall = mo.groups() if named or braced: return '%s' % mapping[named or braced] elif escaped: return '$' lineno = template.count('\n', 0, mo.start(4)) + 1 raise ValueError('Invalid placeholder on line %d: %r' % (lineno, catchall)) return _pattern.sub(convert, template) def safedollarsub(template, mapping=None, **kwds): """A function for $-substitutions. This function is 'safe' in the sense that you will never get KeyErrors if there are placeholders missing from the interpolation dictionary. In that case, you will get the original placeholder in the value string. """ if mapping is None: mapping = kwds def convert(mo): escaped, named, braced, catchall = mo.groups() if named: try: return '%s' % mapping[named] except KeyError: return '$' + named elif braced: try: return '%s' % mapping[braced] except KeyError: return '${' + braced + '}' elif escaped: return '$' lineno = template.count('\n', 0, mo.start(4)) + 1 raise ValueError('Invalid placeholder on line %d: %r' % (lineno, catchall)) return _pattern.sub(convert, template) if __name__ == '__main__': import doctest print 'Doctest results: ', doctest.testmod() From tim_one at users.sourceforge.net Sun Aug 29 02:38:19 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 29 02:38:22 2004 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.95,1.96 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12322/Lib Modified Files: doctest.py Log Message: Whitespace normalization. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.95 retrieving revision 1.96 diff -u -d -r1.95 -r1.96 --- doctest.py 28 Aug 2004 14:57:55 -0000 1.95 +++ doctest.py 29 Aug 2004 00:38:16 -0000 1.96 @@ -2014,7 +2014,7 @@ >>> doctest._unittest_reportflags == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True - + Only reporting flags can be set: >>> set_unittest_reportflags(ELLIPSIS) @@ -2036,17 +2036,17 @@ if nrflags: raise ValueError("Invalid flags passed", flags) - + global _unittest_reportflags old = _unittest_reportflags _unittest_reportflags = flags return old - + class FakeModule: """Fake module created by tests """ - + def __init__(self, dict, name): self.__dict__ = dict self.__name__ = name @@ -2065,7 +2065,7 @@ def setUp(self): test = self._dt_test - + if self._dt_setUp is not None: self._dt_setUp(test) @@ -2082,12 +2082,12 @@ old = sys.stdout new = StringIO() optionflags = self._dt_optionflags - + if not (optionflags & valid_unittest_reportflags): # The option flags don't include any reporting flags, # so add the default reporting flags optionflags |= _unittest_reportflags - + runner = DocTestRunner(optionflags=optionflags, checker=self._dt_checker, verbose=False) @@ -2327,7 +2327,7 @@ optionflags A set of doctest option flags expressed as an integer. - + """ suite = unittest.TestSuite() From tim_one at users.sourceforge.net Sun Aug 29 02:38:19 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 29 02:38:25 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_doctest.py, 1.40, 1.41 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12322/Lib/test Modified Files: test_doctest.py Log Message: Whitespace normalization. Index: test_doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- test_doctest.py 28 Aug 2004 14:57:56 -0000 1.40 +++ test_doctest.py 29 Aug 2004 00:38:17 -0000 1.41 @@ -1797,7 +1797,7 @@ Here, we didn't need to use a tearDown function because we modified the test globals. The test globals are automatically cleared for us after a test. - + """ def test_trailing_space_in_test(): @@ -1848,7 +1848,7 @@ NameError: name 'favorite_color' is not defined - + We get only the first failure. If we give any reporting options when we set up the tests, From facundobatista at users.sourceforge.net Sun Aug 29 03:03:33 2004 From: facundobatista at users.sourceforge.net (facundobatista@users.sourceforge.net) Date: Sun Aug 29 03:03:35 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal/telco telco.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal/telco In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15615 Modified Files: telco.py Log Message: Fixed URL Index: telco.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/telco/telco.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- telco.py 19 Aug 2004 07:53:28 -0000 1.1 +++ telco.py 29 Aug 2004 01:03:29 -0000 1.2 @@ -1,6 +1,6 @@ """ Telco Benchmark for measuring the performance of decimal calculations -http://http://www2.hursley.ibm.com/decimal/telco.html +http://www2.hursley.ibm.com/decimal/telco.html http://www2.hursley.ibm.com/decimal/telcoSpec.html A call type indicator, c, is set from the bottom (least significant) bit of the duration (hence c is 0 or 1). From rhettinger at users.sourceforge.net Sun Aug 29 09:50:45 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Aug 29 09:50:55 2004 Subject: [Python-checkins] python/dist/src/Modules arraymodule.c,2.96,2.97 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv772/Modules Modified Files: arraymodule.c Log Message: SF feature request #992967: array.array objects should support sequences. Made the constructor accept general iterables. Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.96 retrieving revision 2.97 diff -u -d -r2.96 -r2.97 --- arraymodule.c 31 May 2004 00:35:52 -0000 2.96 +++ arraymodule.c 29 Aug 2004 07:50:42 -0000 2.97 @@ -1772,7 +1772,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { char c; - PyObject *initial = NULL; + PyObject *initial = NULL, *it = NULL; struct arraydescr *descr; if (kwds != NULL) { @@ -1793,9 +1793,15 @@ if (!(initial == NULL || PyList_Check(initial) || PyString_Check(initial) || PyTuple_Check(initial) || (c == 'u' && PyUnicode_Check(initial)))) { - PyErr_SetString(PyExc_TypeError, - "array initializer must be list or string"); - return NULL; + it = PyObject_GetIter(initial); + if (it == NULL) + return NULL; + /* We set initial to NULL so that the subsequent code + will create an empty array of the appropriate type + and afterwards we can use array_iter_extend to populate + the array. + */ + initial = NULL; } for (descr = descriptors; descr->typecode != '\0'; descr++) { if (descr->typecode == c) { @@ -1859,6 +1865,14 @@ } #endif } + if (it != NULL) { + if (array_iter_extend((arrayobject *)a, it) == -1) { + Py_DECREF(it); + Py_DECREF(a); + return NULL; + } + Py_DECREF(it); + } return a; } } @@ -1899,8 +1913,8 @@ "array(typecode [, initializer]) -> array\n\ \n\ Return a new array whose items are restricted by typecode, and\n\ -initialized from the optional initializer value, which must be a list\n\ -or a string.\n\ +initialized from the optional initializer value, which must be a list,\n\ +string. or iterable over elements of the appropriate type.\n\ \n\ Arrays represent basic values and behave very much like lists, except\n\ the type of objects stored in them is constrained.\n\ From rhettinger at users.sourceforge.net Sun Aug 29 09:50:45 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Aug 29 09:50:57 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1115,1.1116 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv772/Misc Modified Files: NEWS Log Message: SF feature request #992967: array.array objects should support sequences. Made the constructor accept general iterables. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1115 retrieving revision 1.1116 diff -u -d -r1.1115 -r1.1116 --- NEWS 26 Aug 2004 01:44:07 -0000 1.1115 +++ NEWS 29 Aug 2004 07:50:42 -0000 1.1116 @@ -732,8 +732,8 @@ - array objects now support the copy module. Also, their resizing scheme has been updated to match that used for list objects. This improves the performance (speed and memory usage) of append() operations. - Also, array.extend() now accepts any iterable argument for repeated - appends without needing to create another temporary array. + Also, array.array() and array.extend() now accept any iterable argument + for repeated appends without needing to create another temporary array. - cStringIO.writelines() now accepts any iterable argument and writes the lines one at a time rather than joining them and writing once. From rhettinger at users.sourceforge.net Sun Aug 29 09:50:46 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Aug 29 09:50:59 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libarray.tex,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv772/Doc/lib Modified Files: libarray.tex Log Message: SF feature request #992967: array.array objects should support sequences. Made the constructor accept general iterables. Index: libarray.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libarray.tex,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- libarray.tex 14 Mar 2004 05:43:58 -0000 1.37 +++ libarray.tex 29 Aug 2004 07:50:43 -0000 1.38 @@ -41,10 +41,14 @@ \begin{funcdesc}{array}{typecode\optional{, initializer}} Return a new array whose items are restricted by \var{typecode}, and initialized from the optional \var{initializer} value, which -must be a list or a string. The list or string is passed to the +must be a list, string, or iterable over elements of the +appropriate type. +\versionchanged[Formerly, only lists or strings were accepted]{2.4} +If given a list or string, the initializer is passed to the new array's \method{fromlist()}, \method{fromstring()}, or \method{fromunicode()} method (see below) to add initial items to -the array. +the array. Otherwise, the iterable initializer is passed to the +\method{extend()} method. \end{funcdesc} \begin{datadesc}{ArrayType} From rhettinger at users.sourceforge.net Sun Aug 29 09:50:45 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Aug 29 09:51:01 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_array.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv772/Lib/test Modified Files: test_array.py Log Message: SF feature request #992967: array.array objects should support sequences. Made the constructor accept general iterables. Index: test_array.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_array.py,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- test_array.py 31 May 2004 00:35:52 -0000 1.29 +++ test_array.py 29 Aug 2004 07:50:43 -0000 1.30 @@ -600,6 +600,26 @@ array.array(self.typecode, self.example+self.example[::-1]) ) + def test_constructor_with_iterable_argument(self): + a = array.array(self.typecode, iter(self.example)) + b = array.array(self.typecode, self.example) + self.assertEqual(a, b) + + # non-iterable argument + self.assertRaises(TypeError, array.array, self.typecode, 10) + + # pass through errors raised in __iter__ + class A: + def __iter__(self): + raise UnicodeError + self.assertRaises(UnicodeError, array.array, self.typecode, A()) + + # pass through errors raised in next() + def B(): + raise UnicodeError + yield None + self.assertRaises(UnicodeError, array.array, self.typecode, B()) + def test_coveritertraverse(self): try: import gc @@ -904,8 +924,20 @@ minitemsize = 8 tests.append(DoubleTest) -def test_main(): +def test_main(verbose=None): + import sys + test_support.run_unittest(*tests) -if __name__=="__main__": - test_main() + # verify reference counting + if verbose and hasattr(sys, "gettotalrefcount"): + import gc + counts = [None] * 5 + for i in xrange(len(counts)): + test_support.run_unittest(*tests) + gc.collect() + counts[i] = sys.gettotalrefcount() + print counts + +if __name__ == "__main__": + test_main(verbose=True) From rhettinger at users.sourceforge.net Sun Aug 29 09:57:23 2004 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Aug 29 09:57:26 2004 Subject: [Python-checkins] python/nondist/sandbox/decimal/telco EXPON180.1E6, 1.1, NONE Message-ID: Update of /cvsroot/python/python/nondist/sandbox/decimal/telco In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1641 Removed Files: EXPON180.1E6 Log Message: Remove the full sized timing dataset. It was huge, 8Mb and easily available from other sources. Also, it wasn't properly configured with a binary flag. --- EXPON180.1E6 DELETED --- From loewis at users.sourceforge.net Sun Aug 29 17:46:36 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 17:46:40 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.140,1.141 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13928/Doc/lib Modified Files: libos.tex Log Message: Patch #934711: Expose platform-specific entropy. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.140 retrieving revision 1.141 diff -u -d -r1.140 -r1.141 --- libos.tex 26 Jul 2004 00:42:41 -0000 1.140 +++ libos.tex 29 Aug 2004 15:46:20 -0000 1.141 @@ -1828,3 +1828,22 @@ Also available via \module{os.path}. \versionadded{2.4} \end{datadesc} + + +\subsection{Miscellaneous Functions \label{os-miscfunc}} + +\begin{funcdesc}{urandom}{n} +Return a string of \var{n} random bytes suitable for cryptographic use. + +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, \exception{NotImplementedError} will be raised. +\versionadded{2.4} +\end{funcdesc} + + + + From loewis at users.sourceforge.net Sun Aug 29 17:46:36 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 17:46:42 2004 Subject: [Python-checkins] python/dist/src/Lib os.py,1.77,1.78 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13928/Lib Modified Files: os.py Log Message: Patch #934711: Expose platform-specific entropy. Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.77 retrieving revision 1.78 diff -u -d -r1.77 -r1.78 --- os.py 8 Jun 2004 08:29:32 -0000 1.77 +++ os.py 29 Aug 2004 15:46:34 -0000 1.78 @@ -656,3 +656,24 @@ _make_statvfs_result) except NameError: # statvfs_result may not exist pass + +if not _exists("urandom"): + _urandomfd = None + def urandom(n): + """urandom(n) -> str + + Return a string of n random bytes suitable for cryptographic use. + + """ + global _urandomfd + if not _urandomfd: + try: + _urandomfd = open("/dev/urandom", O_RDONLY) + except: + _urandomfd = NotImplementedError + if _urandomfd is NotImplementedError: + raise NotImplementedError("/dev/urandom (or equivalent) not found") + bytes = "" + while len(bytes) < n: + bytes += read(_urandomfd, n - len(bytes)) + return bytes From loewis at users.sourceforge.net Sun Aug 29 17:46:38 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 17:46:45 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1116,1.1117 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13928/Misc Modified Files: NEWS Log Message: Patch #934711: Expose platform-specific entropy. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1116 retrieving revision 1.1117 diff -u -d -r1.1116 -r1.1117 --- NEWS 29 Aug 2004 07:50:42 -0000 1.1116 +++ NEWS 29 Aug 2004 15:46:34 -0000 1.1117 @@ -47,6 +47,9 @@ Extension modules ----------------- +- os.urandom has been added for systems that support sources of random + data. + - Patch 1012740: truncate() on a writeable cStringIO now resets the position to the end of the stream. This is consistent with the original StringIO module and avoids inadvertently resurrecting data that was From loewis at users.sourceforge.net Sun Aug 29 17:46:39 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 17:46:47 2004 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c, 2.321, 2.322 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13928/Modules Modified Files: posixmodule.c Log Message: Patch #934711: Expose platform-specific entropy. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.321 retrieving revision 2.322 diff -u -d -r2.321 -r2.322 --- posixmodule.c 15 Jun 2004 18:49:58 -0000 2.321 +++ posixmodule.c 29 Aug 2004 15:46:35 -0000 2.322 @@ -228,7 +228,7 @@ #include #include #include "osdefs.h" -#define WIN32_LEAN_AND_MEAN +#define _WIN32_WINNT 0x0400 /* Needed for CryptoAPI on some systems */ #include #include /* for ShellExecute() */ #define popen _popen @@ -7221,6 +7221,74 @@ } #endif +#ifdef MS_WINDOWS + +PyDoc_STRVAR(win32_urandom__doc__, +"urandom(n) -> str\n\n\ +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; +static HCRYPTPROV hCryptProv = 0; + +static PyObject* win32_urandom(PyObject *self, PyObject *args) +{ + int howMany = 0; + unsigned char* bytes = NULL; + PyObject* returnVal = NULL; + + /* Read arguments */ + if (!PyArg_ParseTuple(args, "i", &howMany)) + return(NULL); + + if (hCryptProv == 0) { + HINSTANCE hAdvAPI32 = NULL; + CRYPTACQUIRECONTEXTA pCryptAcquireContext = NULL; + + /* Obtain handle to the DLL containing CryptoAPI + This should not fail */ + if( (hAdvAPI32 = GetModuleHandle("advapi32.dll")) == 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"); + pCryptGenRandom=(CRYPTGENRANDOM)GetProcAddress(hAdvAPI32,\ + "CryptGenRandom"); + + if (pCryptAcquireContext == NULL || 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 */ + if ((bytes = (unsigned char*)PyMem_Malloc(howMany)) == NULL) + return PyErr_NoMemory(); + + /* Get random data */ + if (!pCryptGenRandom(hCryptProv, howMany, bytes)) { + PyMem_Free(bytes); + return win32_error("CryptGenRandom", NULL); + } + + /* Build return value */ + returnVal = PyString_FromStringAndSize(bytes, howMany); + PyMem_Free(bytes); + + return returnVal; +} +#endif static PyMethodDef posix_methods[] = { {"access", posix_access, METH_VARARGS, posix_access__doc__}, @@ -7506,6 +7574,9 @@ #ifdef HAVE_GETLOADAVG {"getloadavg", posix_getloadavg, METH_NOARGS, posix_getloadavg__doc__}, #endif + #ifdef MS_WINDOWS + {"urandom", win32_urandom, METH_VARARGS, win32_urandom__doc__}, + #endif {NULL, NULL} /* Sentinel */ }; From loewis at users.sourceforge.net Sun Aug 29 17:46:37 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 17:46:52 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_os.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13928/Lib/test Modified Files: test_os.py Log Message: Patch #934711: Expose platform-specific entropy. Index: test_os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_os.py,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- test_os.py 8 Jun 2004 20:34:34 -0000 1.25 +++ test_os.py 29 Aug 2004 15:46:34 -0000 1.26 @@ -343,6 +343,16 @@ self.assertEqual(f.read(), '') f.close() +class URandomTests (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) + except NotImplementedError: + pass + def test_main(): test_support.run_unittest( TemporaryFileTests, @@ -351,6 +361,7 @@ WalkTests, MakedirTests, DevNullTests, + URandomTests ) if __name__ == "__main__": From loewis at users.sourceforge.net Sun Aug 29 17:51:55 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 17:51:58 2004 Subject: [Python-checkins] python/dist/src/Python ceval.c,2.415,2.416 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14959 Modified Files: ceval.c Log Message: Centralize WITH_TSC processing. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.415 retrieving revision 2.416 diff -u -d -r2.415 -r2.416 --- ceval.c 12 Aug 2004 18:19:07 -0000 2.415 +++ ceval.c 29 Aug 2004 15:51:52 -0000 2.416 @@ -16,7 +16,9 @@ #include -#ifdef WITH_TSC +#ifndef WITH_TSC +#define rdtscll(var) +#else /*WITH_TSC defined*/ typedef unsigned long long uint64; @@ -868,9 +870,7 @@ #endif /* Main switch on opcode */ -#ifdef WITH_TSC rdtscll(inst0); -#endif switch (opcode) { @@ -1629,13 +1629,9 @@ v = SECOND(); u = THIRD(); STACKADJ(-3); -#ifdef WITH_TSC rdtscll(intr0); -#endif err = exec_statement(f, u, v, w); -#ifdef WITH_TSC rdtscll(intr1); -#endif Py_DECREF(u); Py_DECREF(v); Py_DECREF(w); @@ -2011,13 +2007,9 @@ x = NULL; break; } -#ifdef WITH_TSC rdtscll(intr0); -#endif x = PyEval_CallObject(x, w); -#ifdef WITH_TSC rdtscll(intr1); -#endif Py_DECREF(w); SET_TOP(x); if (x != NULL) continue; @@ -2031,13 +2023,9 @@ "no locals found during 'import *'"); break; } -#ifdef WITH_TSC rdtscll(intr0); -#endif err = import_all_from(x, v); -#ifdef WITH_TSC rdtscll(intr1); -#endif PyFrame_LocalsToFast(f, 0); Py_DECREF(v); if (err == 0) continue; @@ -2046,13 +2034,9 @@ case IMPORT_FROM: w = GETITEM(names, oparg); v = TOP(); -#ifdef WITH_TSC rdtscll(intr0); -#endif x = import_from(v, w); -#ifdef WITH_TSC rdtscll(intr1); -#endif PUSH(x); if (x != NULL) continue; break; @@ -2206,13 +2190,9 @@ } else Py_INCREF(func); sp = stack_pointer; -#ifdef WITH_TSC rdtscll(intr0); -#endif x = ext_do_call(func, &sp, flags, na, nk); -#ifdef WITH_TSC rdtscll(intr1); -#endif stack_pointer = sp; Py_DECREF(func); @@ -2325,9 +2305,7 @@ on_error: -#ifdef WITH_TSC rdtscll(inst1); -#endif /* Quickly continue if no error occurred */ @@ -2340,9 +2318,7 @@ "XXX undetected error\n"); else { #endif -#ifdef WITH_TSC rdtscll(loop1); -#endif continue; /* Normal, fast path */ #ifdef CHECKEXC } @@ -2461,9 +2437,7 @@ if (why != WHY_NOT) break; -#ifdef WITH_TSC rdtscll(loop1); -#endif } /* main loop */ @@ -3560,13 +3534,9 @@ else { PyObject *callargs; callargs = load_args(pp_stack, na); -#ifdef WITH_TSC rdtscll(*pintr0); -#endif C_TRACE(x=PyCFunction_Call(func,callargs,NULL)); -#ifdef WITH_TSC rdtscll(*pintr1); -#endif Py_XDECREF(callargs); } } else { @@ -3584,16 +3554,12 @@ n++; } else Py_INCREF(func); -#ifdef WITH_TSC rdtscll(*pintr0); -#endif if (PyFunction_Check(func)) x = fast_function(func, pp_stack, n, na, nk); else x = do_call(func, pp_stack, na, nk); -#ifdef WITH_TSC rdtscll(*pintr1); -#endif Py_DECREF(func); } From loewis at users.sourceforge.net Sun Aug 29 18:34:42 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 18:34:45 2004 Subject: [Python-checkins] python/dist/src/Doc/lib libdifflib.tex,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22983/Doc/lib Modified Files: libdifflib.tex Log Message: Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option. Index: libdifflib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdifflib.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- libdifflib.tex 21 Jan 2004 18:30:28 -0000 1.17 +++ libdifflib.tex 29 Aug 2004 16:34:39 -0000 1.18 @@ -52,6 +52,79 @@ characters. \end{classdesc*} +\begin{classdesc*}{HtmlDiff} + + This class can be used to create an HTML table (or a complete HTML file + containing the table) showing a side by side, line by line comparision + of text with inter-line and intra-line change highlights. The table can + be generated in either full or contextual difference mode. + + The constructor for this class is: + + \begin{funcdesc}{__init__}{ + \optional{, tabsize + \optional{, wrapcolumn + \optional{, linejunk + \optional{, charjunk}}}}} + + Initializes instance of \class{HtmlDiff}. + + \var{tabsize} is an optional keyword argument to specify tab stop spacing + and defaults to \code{8}. + + \var{wrapcolumn} is an optional keyword to specify column number where + lines are broken and wrapped, defaults to \code{None} where lines are not + wrapped. + + \var{linejunk} and \var{charjunk} are optional keyword arguments passed + into \code{ndiff()} (used to by \class{HtmlDiff} to generate the + side by side HTML differences). See \code{ndiff()} documentation for + argument default values and descriptions. + \end{funcdesc} + + The following methods are public: + + \begin{funcdesc}{make_file}{fromlines, tolines + \optional{, fromdesc + \optional{, todesc + \optional{, context + \optional{, numlines}}}}} + Compares \var{fromlines} and \var{tolines} (lists of strings) and returns + a string which is a complete HTML file containing a table showing line by + line differences with inter-line and intra-line changes highlighted. + + \var{fromdesc} and \var{todesc} are optional keyword arguments to specify + from/to file column header strings (both default to an empty string). + + \var{context} and \var{numlines} are both optional keyword arguments. + Set \var{context} to \code{True} when contextual differences are to be + shown, else the default is \code{False} to show the full files. + \var{numlines} defaults to \code{5}. When \var{context} is \code{True} + \var{numlines} controls the number of context lines which surround the + difference highlights. When \var{context} is \code{False} \var{numlines} + controls the number of lines which are shown before a difference + highlight when using the "next" hyperlinks (setting to zero would cause + the "next" hyperlinks to place the next difference highlight at the top of + the browser without any leading context). + \end{funcdesc} + + \begin{funcdesc}{make_table}{fromlines, tolines + \optional{, fromdesc + \optional{, todesc + \optional{, context}}}} + Compares \var{fromlines} and \var{tolines} (lists of strings) and returns + a string which is a complete HTML table showing line by line differences + with inter-line and intra-line changes highlighted. + + The arguments of this method are a subset of those for the + \code{make_file} method. Refer to the \code{make_file} method + documentation. + \end{funcdesc} + + \file{Tools/scripts/ndiff.py} is a command-line front-end to this class + and contains a good example of its use. +\end{classdesc*} + \begin{funcdesc}{context_diff}{a, b\optional{, fromfile\optional{, tofile \optional{, fromfiledate\optional{, tofiledate\optional{, n \optional{, lineterm}}}}}}} From loewis at users.sourceforge.net Sun Aug 29 18:34:42 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 18:34:48 2004 Subject: [Python-checkins] python/dist/src/Lib difflib.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22983/Lib Modified Files: difflib.py Log Message: Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option. Index: difflib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/difflib.py,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- difflib.py 31 Jul 2004 00:19:43 -0000 1.22 +++ difflib.py 29 Aug 2004 16:34:39 -0000 1.23 @@ -23,11 +23,14 @@ Class Differ: For producing human-readable deltas from sequences of lines of text. + +Class HtmlDiff: + For producing HTML side by side comparison with change highlights. """ __all__ = ['get_close_matches', 'ndiff', 'restore', 'SequenceMatcher', 'Differ','IS_CHARACTER_JUNK', 'IS_LINE_JUNK', 'context_diff', - 'unified_diff'] + 'unified_diff', 'HtmlDiff'] import heapq @@ -1101,8 +1104,6 @@ return ch in ws -del re - def unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'): @@ -1277,6 +1278,678 @@ """ return Differ(linejunk, charjunk).compare(a, b) +def _mdiff(fromlines, tolines, context=None, linejunk=None, + charjunk=IS_CHARACTER_JUNK): + """Returns generator yielding marked up from/to side by side differences. + + Arguments: + fromlines -- list of text lines to compared to tolines + tolines -- list of text lines to be compared to fromlines + context -- number of context lines to display on each side of difference, + if None, all from/to text lines will be generated. + linejunk -- passed on to ndiff (see ndiff documentation) + charjunk -- passed on to ndiff (see ndiff documentation) + + This function returns an interator which returns a tuple: + (from line tuple, to line tuple, boolean flag) + + from/to line tuple -- (line num, line text) + line num -- integer or None (to indicate a context seperation) + line text -- original line text with following markers inserted: + '\0+' -- marks start of added text + '\0-' -- marks start of deleted text + '\0^' -- marks start of changed text + '\1' -- marks end of added/deleted/changed text + + boolean flag -- None indicates context separation, True indicates + either "from" or "to" line contains a change, otherwise False. + + This function/iterator was originally developed to generate side by side + file difference for making HTML pages (see HtmlDiff class for example + usage). + + Note, this function utilizes the ndiff function to generate the side by + side difference markup. Optional ndiff arguments may be passed to this + function and they in turn will be passed to ndiff. + """ + import re + + # regular expression for finding intraline change indices + change_re = re.compile('(\++|\-+|\^+)') + + # create the difference iterator to generate the differences + diff_lines_iterator = ndiff(fromlines,tolines,linejunk,charjunk) + + def _make_line(lines, format_key, side, num_lines=[0,0]): + """Returns line of text with user's change markup and line formatting. + + lines -- list of lines from the ndiff generator to produce a line of + text from. When producing the line of text to return, the + lines used are removed from this list. + format_key -- '+' return first line in list with "add" markup around + the entire line. + '-' return first line in list with "delete" markup around + the entire line. + '?' return first line in list with add/delete/change + intraline markup (indices obtained from second line) + None return first line in list with no markup + side -- indice into the num_lines list (0=from,1=to) + num_lines -- from/to current line number. This is NOT intended to be a + passed parameter. It is present as a keyword argument to + maintain memory of the current line numbers between calls + of this function. + + Note, this function is purposefully not defined at the module scope so + that data it needs from its parent function (within whose context it + is defined) does not need to be of module scope. + """ + num_lines[side] += 1 + # Handle case where no user markup is to be added, just return line of + # text with user's line format to allow for usage of the line number. + if format_key is None: + return (num_lines[side],lines.pop(0)[2:]) + # Handle case of intraline changes + if format_key == '?': + text, markers = lines.pop(0), lines.pop(0) + # find intraline changes (store change type and indices in tuples) + sub_info = [] + def record_sub_info(match_object,sub_info=sub_info): + sub_info.append([match_object.group(1)[0],match_object.span()]) + return match_object.group(1) + change_re.sub(record_sub_info,markers) + # process each tuple inserting our special marks that won't be + # noticed by an xml/html escaper. + for key,(begin,end) in sub_info[::-1]: + text = text[0:begin]+'\0'+key+text[begin:end]+'\1'+text[end:] + text = text[2:] + # Handle case of add/delete entire line + else: + text = lines.pop(0)[2:] + # if line of text is just a newline, insert a space so there is + # something for the user to highlight and see. + if len(text) <= 1: + text = ' '+text + # insert marks that won't be noticed by an xml/html escaper. + text = '\0' + format_key + text + '\1' + # Return line of text, first allow user's line formatter to do it's + # thing (such as adding the line number) then replace the special + # marks with what the user's change markup. + return (num_lines[side],text) + + def _line_iterator(): + """Yields from/to lines of text with a change indication. + + This function is an iterator. It itself pulls lines from a + differencing iterator, processes them and yields them. When it can + it yields both a "from" and a "to" line, otherwise it will yield one + or the other. In addition to yielding the lines of from/to text, a + boolean flag is yielded to indicate if the text line(s) have + differences in them. + + Note, this function is purposefully not defined at the module scope so + that data it needs from its parent function (within whose context it + is defined) does not need to be of module scope. + """ + lines = [] + num_blanks_pending, num_blanks_to_yield = 0, 0 + while True: + # Load up next 4 lines so we can look ahead, create strings which + # are a concatenation of the first character of each of the 4 lines + # so we can do some very readable comparisons. + while len(lines) < 4: + try: + lines.append(diff_lines_iterator.next()) + except StopIteration: + lines.append('X') + s = ''.join([line[0] for line in lines]) + if s.startswith('X'): + # When no more lines, pump out any remaining blank lines so the + # corresponding add/delete lines get a matching blank line so + # all line pairs get yielded at the next level. + num_blanks_to_yield = num_blanks_pending + elif s.startswith('-?+?'): + # simple intraline change + yield _make_line(lines,'?',0), _make_line(lines,'?',1), True + continue + elif s.startswith('--++'): + # in delete block, add block coming: we do NOT want to get + # caught up on blank lines yet, just process the delete line + num_blanks_pending -= 1 + yield _make_line(lines,'-',0), None, True + continue + elif s.startswith('--?+') or s.startswith('--+') or \ + s.startswith('- '): + # in delete block and see a intraline change or unchanged line + # coming: yield the delete line and then blanks + from_line,to_line = _make_line(lines,'-',0), None + num_blanks_to_yield,num_blanks_pending = num_blanks_pending-1,0 + elif s.startswith('-+?'): + # intraline change + yield _make_line(lines,None,0), _make_line(lines,'?',1), True + continue + elif s.startswith('-?+'): + # intraline change + yield _make_line(lines,'?',0), _make_line(lines,None,1), True + continue + elif s.startswith('-'): + # delete FROM line + num_blanks_pending -= 1 + yield _make_line(lines,'-',0), None, True + continue + elif s.startswith('+--'): + # in add block, delete block coming: we do NOT want to get + # caught up on blank lines yet, just process the add line + num_blanks_pending += 1 + yield None, _make_line(lines,'+',1), True + continue + elif s.startswith('+ ') or s.startswith('+-'): + # will be leaving an add block: yield blanks then add line + from_line, to_line = None, _make_line(lines,'+',1) + num_blanks_to_yield,num_blanks_pending = num_blanks_pending+1,0 + elif s.startswith('+'): + # inside an add block, yield the add line + num_blanks_pending += 1 + yield None, _make_line(lines,'+',1), True + continue + elif s.startswith(' '): + # unchanged text, yield it to both sides + yield _make_line(lines[:],None,0),_make_line(lines,None,1),False + continue + # Catch up on the blank lines so when we yield the next from/to + # pair, they are lined up. + while(num_blanks_to_yield < 0): + num_blanks_to_yield += 1 + yield None,('','\n'),True + while(num_blanks_to_yield > 0): + num_blanks_to_yield -= 1 + yield ('','\n'),None,True + if s.startswith('X'): + raise StopIteration + else: + yield from_line,to_line,True + + def _line_pair_iterator(): + """Yields from/to lines of text with a change indication. + + This function is an iterator. It itself pulls lines from the line + iterator. It's difference from that iterator is that this function + always yields a pair of from/to text lines (with the change + indication). If necessary it will collect single from/to lines + until it has a matching pair from/to pair to yield. + + Note, this function is purposefully not defined at the module scope so + that data it needs from its parent function (within whose context it + is defined) does not need to be of module scope. + """ + line_iterator = _line_iterator() + fromlines,tolines=[],[] + while True: + # Collecting lines of text until we have a from/to pair + while (len(fromlines)==0 or len(tolines)==0): + from_line, to_line, found_diff =line_iterator.next() + if from_line is not None: + fromlines.append((from_line,found_diff)) + if to_line is not None: + tolines.append((to_line,found_diff)) + # Once we have a pair, remove them from the collection and yield it + from_line, fromDiff = fromlines.pop(0) + to_line, to_diff = tolines.pop(0) + yield (from_line,to_line,fromDiff or to_diff) + + # Handle case where user does not want context differencing, just yield + # them up without doing anything else with them. + line_pair_iterator = _line_pair_iterator() + if context is None: + while True: + yield line_pair_iterator.next() + # Handle case where user wants context differencing. We must do some + # storage of lines until we know for sure that they are to be yielded. + else: + context += 1 + lines_to_write = 0 + while True: + # Store lines up until we find a difference, note use of a + # circular queue because we only need to keep around what + # we need for context. + index, contextLines = 0, [None]*(context) + found_diff = False + while(found_diff is False): + from_line, to_line, found_diff = line_pair_iterator.next() + i = index % context + contextLines[i] = (from_line, to_line, found_diff) + index += 1 + # Yield lines that we have collected so far, but first yield + # the user's separator. + if index > context: + yield None, None, None + lines_to_write = context + else: + lines_to_write = index + index = 0 + while(lines_to_write): + i = index % context + index += 1 + yield contextLines[i] + lines_to_write -= 1 + # Now yield the context lines after the change + lines_to_write = context-1 + while(lines_to_write): + from_line, to_line, found_diff = line_pair_iterator.next() + # If another change within the context, extend the context + if found_diff: + lines_to_write = context-1 + else: + lines_to_write -= 1 + yield from_line, to_line, found_diff + + +_file_template = """ + + + + + + + + + + + + %(table)s%(legend)s + + +""" + +_styles = """ + table.diff {font-family:Courier; border:medium;} + .diff_header {background-color:#e0e0e0} + td.diff_header {text-align:right} + .diff_next {background-color:#c0c0c0} + .diff_add {background-color:#aaffaa} + .diff_chg {background-color:#ffff77} + .diff_sub {background-color:#ffaaaa}""" + +_table_template = """ + + + + %(header_row)s + +%(data_rows)s +
""" + +_legend = """ + + + + +
Legends
+ + + + +
Colors
 Added 
Changed
Deleted
+ + + + +
Links
(f)irst change
(n)ext change
(t)op
""" + +class HtmlDiff(object): + """For producing HTML side by side comparison with change highlights. + + This class can be used to create an HTML table (or a complete HTML file + containing the table) showing a side by side, line by line comparision + of text with inter-line and intra-line change highlights. The table can + be generated in either full or contextual difference mode. + + The following methods are provided for HTML generation: + + make_table -- generates HTML for a single side by side table + make_file -- generates complete HTML file with a single side by side table + + See tools/scripts/diff.py for an example usage of this class. + """ + + _file_template = _file_template + _styles = _styles + _table_template = _table_template + _legend = _legend + _default_prefix = 0 + + def __init__(self,tabsize=8,wrapcolumn=None,linejunk=None, + charjunk=IS_CHARACTER_JUNK): + """HtmlDiff instance initializer + + Arguments: + tabsize -- tab stop spacing, defaults to 8. + wrapcolumn -- column number where lines are broken and wrapped, + defaults to None where lines are not wrapped. + linejunk,charjunk -- keyword arguments passed into ndiff() (used to by + HtmlDiff() to generate the side by side HTML differences). See + ndiff() documentation for argument default values and descriptions. + """ + self._tabsize = tabsize + self._wrapcolumn = wrapcolumn + self._linejunk = linejunk + self._charjunk = charjunk + + def make_file(self,fromlines,tolines,fromdesc='',todesc='',context=False, + numlines=5): + """Returns HTML file of side by side comparison with change highlights + + Arguments: + fromlines -- list of "from" lines + tolines -- list of "to" lines + fromdesc -- "from" file column header string + todesc -- "to" file column header string + context -- set to True for contextual differences (defaults to False + which shows full differences). + numlines -- number of context lines. When context is set True, + controls number of lines displayed before and after the change. + When context is False, controls the number of lines to place + the "next" link anchors before the next change (so click of + "next" link jumps to just before the change). + """ + + return self._file_template % dict( + styles = self._styles, + legend = self._legend, + table = self.make_table(fromlines,tolines,fromdesc,todesc, + context=context,numlines=numlines)) + + def _tab_newline_replace(self,fromlines,tolines): + """Returns from/to line lists with tabs expanded and newlines removed. + + Instead of tab characters being replaced by the number of spaces + needed to fill in to the next tab stop, this function will fill + the space with tab characters. This is done so that the difference + algorithms can identify changes in a file when tabs are replaced by + spaces and vice versa. At the end of the HTML generation, the tab + characters will be replaced with a nonbreakable space. + """ + def expand_tabs(line): + # hide real spaces + line = line.replace(' ','\0') + # expand tabs into spaces + line = line.expandtabs(self._tabsize) + # relace spaces from expanded tabs back into tab characters + # (we'll replace them with markup after we do differencing) + line = line.replace(' ','\t') + return line.replace('\0',' ').rstrip('\n') + fromlines = [expand_tabs(line) for line in fromlines] + tolines = [expand_tabs(line) for line in tolines] + return fromlines,tolines + + def _split_line(self,data_list,line_num,text): + """Builds list of text lines by splitting text lines at wrap point + + This function will determine if the input text line needs to be + wrapped (split) into separate lines. If so, the first wrap point + will be determined and the first line appended to the output + text line list. This function is used recursively to handle + the second part of the split line to further split it. + """ + # if blank line or context separator, just add it to the output list + if not line_num: + data_list.append((line_num,text)) + return + + # if line text doesn't need wrapping, just add it to the output list + size = len(text) + max = self._wrapcolumn + if (size <= max) or ((size -(text.count('\0')*3)) <= max): + data_list.append((line_num,text)) + return + + # scan text looking for the wrap point, keeping track if the wrap + # point is inside markers + i = 0 + n = 0 + mark = '' + while n < max and i < size: + if text[i] == '\0': + i += 1 + mark = text[i] + i += 1 + elif text[i] == '\1': + i += 1 + mark = '' + else: + i += 1 + n += 1 + + # wrap point is inside text, break it up into separate lines + line1 = text[:i] + line2 = text[i:] + + # if wrap point is inside markers, place end marker at end of first + # line and start marker at beginning of second line because each + # line will have its own table tag markup around it. + if mark: + line1 = line1 + '\1' + line2 = '\0' + mark + line2 + + # tack on first line onto the output list + data_list.append((line_num,line1)) + + # use this routine again to wrap the remaining text + self._split_line(data_list,'>',line2) + + def _line_wrapper(self,diffs): + """Returns iterator that splits (wraps) mdiff text lines""" + + # pull from/to data and flags from mdiff iterator + for fromdata,todata,flag in diffs: + # check for context separators and pass them through + if flag is None: + yield fromdata,todata,flag + continue + (fromline,fromtext),(toline,totext) = fromdata,todata + # for each from/to line split it at the wrap column to form + # list of text lines. + fromlist,tolist = [],[] + self._split_line(fromlist,fromline,fromtext) + self._split_line(tolist,toline,totext) + # yield from/to line in pairs inserting blank lines as + # necessary when one side has more wrapped lines + while fromlist or tolist: + if fromlist: + fromdata = fromlist.pop(0) + else: + fromdata = ('',' ') + if tolist: + todata = tolist.pop(0) + else: + todata = ('',' ') + yield fromdata,todata,flag + + def _collect_lines(self,diffs): + """Collects mdiff output into separate lists + + Before storing the mdiff from/to data into a list, it is converted + into a single line of text with HTML markup. + """ + + fromlist,tolist,flaglist = [],[],[] + # pull from/to data and flags from mdiff style iterator + for fromdata,todata,flag in diffs: + try: + # store HTML markup of the lines into the lists + fromlist.append(self._format_line(0,flag,*fromdata)) + tolist.append(self._format_line(1,flag,*todata)) + except TypeError: + # exceptions occur for lines where context separators go + fromlist.append(None) + tolist.append(None) + flaglist.append(flag) + return fromlist,tolist,flaglist + + def _format_line(self,side,flag,linenum,text): + """Returns HTML markup of "from" / "to" text lines + + side -- 0 or 1 indicating "from" or "to" text + flag -- indicates if difference on line + linenum -- line number (used for line number column) + text -- line text to be marked up + """ + try: + linenum = '%d' % linenum + id = ' id="%s%s"' % (self._prefix[side],linenum) + except TypeError: + # handle blank lines where linenum is '>' or '' + id = '' + # replace those things that would get confused with HTML symbols + text=text.replace("&","&").replace(">",">").replace("<","<") + + # make space non-breakable so they don't get compressed or line wrapped + text = text.replace(' ',' ').rstrip() + + return '%s%s' \ + % (id,linenum,text) + + def _make_prefix(self): + """Create unique anchor prefixes""" + + # Generate a unique anchor prefix so multiple tables + # can exist on the same HTML page without conflicts. + fromprefix = "from%d_" % HtmlDiff._default_prefix + toprefix = "to%d_" % HtmlDiff._default_prefix + HtmlDiff._default_prefix += 1 + # store prefixes so line format method has access + self._prefix = [fromprefix,toprefix] + + def _convert_flags(self,fromlist,tolist,flaglist,context,numlines): + """Makes list of "next" links""" + + # all anchor names will be generated using the unique "to" prefix + toprefix = self._prefix[1] + + # process change flags, generating middle column of next anchors/links + next_id = ['']*len(flaglist) + next_href = ['']*len(flaglist) + num_chg, in_change = 0, False + last = 0 + for i,flag in enumerate(flaglist): + if flag: + if not in_change: + in_change = True + last = i + # at the beginning of a change, drop an anchor a few lines + # (the context lines) before the change for the previous + # link + i = max([0,i-numlines]) + next_id[i] = ' id="difflib_chg_%s_%d"' % (toprefix,num_chg) + # at the beginning of a change, drop a link to the next + # change + num_chg += 1 + next_href[last] = 'n' % ( + toprefix,num_chg) + else: + in_change = False + # check for cases where there is no content to avoid exceptions + if not flaglist: + flaglist = [False] + next_id = [''] + next_href = [''] + last = 0 + if context: + fromlist = [' No Differences Found '] + tolist = fromlist + else: + fromlist = tolist = [' Empty File '] + # if not a change on first line, drop a link + if not flaglist[0]: + next_href[0] = 'f' % toprefix + # redo the last link to link to the top + next_href[last] = 't' % (toprefix) + + return fromlist,tolist,flaglist,next_href,next_id + + def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False, + numlines=5): + """Returns HTML table of side by side comparison with change highlights + + Arguments: + fromlines -- list of "from" lines + tolines -- list of "to" lines + fromdesc -- "from" file column header string + todesc -- "to" file column header string + context -- set to True for contextual differences (defaults to False + which shows full differences). + numlines -- number of context lines. When context is set True, + controls number of lines displayed before and after the change. + When context is False, controls the number of lines to place + the "next" link anchors before the next change (so click of + "next" link jumps to just before the change). + """ + + # make unique anchor prefixes so that multiple tables may exist + # on the same page without conflict. + self._make_prefix() + + # change tabs to spaces before it gets more difficult after we insert + # markkup + fromlines,tolines = self._tab_newline_replace(fromlines,tolines) + + # create diffs iterator which generates side by side from/to data + if context: + context_lines = numlines + else: + context_lines = None + diffs = _mdiff(fromlines,tolines,context_lines,linejunk=self._linejunk, + charjunk=self._charjunk) + + # set up iterator to wrap lines that exceed desired width + if self._wrapcolumn: + diffs = self._line_wrapper(diffs) + + # collect up from/to lines and flags into lists (also format the lines) + fromlist,tolist,flaglist = self._collect_lines(diffs) + + # process change flags, generating middle column of next anchors/links + fromlist,tolist,flaglist,next_href,next_id = self._convert_flags( + fromlist,tolist,flaglist,context,numlines) + + import cStringIO + s = cStringIO.StringIO() + fmt = ' %s%s' + \ + '%s%s\n' + for i in range(len(flaglist)): + if flaglist[i] is None: + # mdiff yields None on separator lines skip the bogus ones + # generated for the first line + if i > 0: + s.write(' \n \n') + else: + s.write( fmt % (next_id[i],next_href[i],fromlist[i], + next_href[i],tolist[i])) + if fromdesc or todesc: + header_row = '%s%s%s%s' % ( + '
', + '%s' % fromdesc, + '
', + '%s' % todesc) + else: + header_row = '' + + table = self._table_template % dict( + data_rows=s.getvalue(), + header_row=header_row, + prefix=self._prefix[1]) + + return table.replace('\0+',''). \ + replace('\0-',''). \ + replace('\0^',''). \ + replace('\1',''). \ + replace('\t',' ') + +del re + def restore(delta, which): r""" Generate one of the two sequences that generated a delta. From loewis at users.sourceforge.net Sun Aug 29 18:34:43 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 18:34:50 2004 Subject: [Python-checkins] python/dist/src/Tools/scripts diff.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22983/Tools/scripts Modified Files: diff.py Log Message: Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option. Index: diff.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/diff.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- diff.py 9 Aug 2004 17:27:55 -0000 1.3 +++ diff.py 29 Aug 2004 16:34:40 -0000 1.4 @@ -1,8 +1,9 @@ -""" Command line interface to difflib.py providing diffs in three formats: +""" Command line interface to difflib.py providing diffs in four formats: * ndiff: lists every line and highlights interline changes. -* context: highlights clusters of changes in a before/after format +* context: highlights clusters of changes in a before/after format. * unified: highlights clusters of changes in an inline format. +* html: generates side by side comparison with change highlights. """ @@ -14,6 +15,7 @@ parser = optparse.OptionParser(usage) parser.add_option("-c", action="store_true", default=False, help='Produce a context format diff (default)') parser.add_option("-u", action="store_true", default=False, help='Produce a unified format diff') + parser.add_option("-m", action="store_true", default=False, help='Produce HTML side by side diff (can use -c and -l in conjunction)') parser.add_option("-n", action="store_true", default=False, help='Produce a ndiff format diff') parser.add_option("-l", "--lines", type="int", default=3, help='Set number of context lines (default 3)') (options, args) = parser.parse_args() @@ -36,6 +38,8 @@ diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n) elif options.n: diff = difflib.ndiff(fromlines, tolines) + elif options.m: + diff = difflib.HtmlDiff().make_file(fromlines,tolines,fromfile,tofile,context=options.c,numlines=n) else: diff = difflib.context_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n) From loewis at users.sourceforge.net Sun Aug 29 18:34:43 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 18:34:52 2004 Subject: [Python-checkins] python/dist/src/Misc ACKS, 1.278, 1.279 NEWS, 1.1117, 1.1118 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22983/Misc Modified Files: ACKS NEWS Log Message: Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.278 retrieving revision 1.279 diff -u -d -r1.278 -r1.279 --- ACKS 23 Aug 2004 23:30:20 -0000 1.278 +++ ACKS 29 Aug 2004 16:34:40 -0000 1.279 @@ -201,6 +201,7 @@ Nitin Ganatra Fred Gansevles Lars Marius Garshol +Dan Gass Andrew Gaul Stephen M. Gava Harry Henry Gebel Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1117 retrieving revision 1.1118 diff -u -d -r1.1117 -r1.1118 --- NEWS 29 Aug 2004 15:46:34 -0000 1.1117 +++ NEWS 29 Aug 2004 16:34:40 -0000 1.1118 @@ -47,6 +47,8 @@ Extension modules ----------------- +- difflib now supports HTML side-by-side diff. + - os.urandom has been added for systems that support sources of random data. @@ -63,6 +65,8 @@ Library ------- +- difflib and diff.py can now generate HTML. + - bdist_rpm now includes version and release in the BuildRoot, and replaces - by ``_`` in version and release. From loewis at users.sourceforge.net Sun Aug 29 18:34:42 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 18:34:54 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_difflib_expect.html, NONE, 1.1 test_difflib.py, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22983/Lib/test Modified Files: test_difflib.py Added Files: test_difflib_expect.html Log Message: Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option. --- NEW FILE: test_difflib_expect.html ---

from
to
f1f1
n2   1. Beautiful is beTTer than ugly.n2   1. Beautiful is better than ugly.
3   2. Explicit is better than implicit.
4   3. Simple is better than complex.3   3.   Simple is better than complex.
5   4. Complex is better than complicated.4   4. Complicated is better than complex.
5   5. Flat is better than nested.
61236123
71237123
81238123
91239123
1012310123
1112311123
1212312123
1312313123
1412314123
1512315123
1616
n17   1. Beautiful is beTTer than ugly.n17   1. Beautiful is better than ugly.
18   2. Explicit is better than implicit.
19   3. Simple is better than complex.18   3.   Simple is better than complex.
20   4. Complex is better than complicated.19   4. Complicated is better than complex.
20   5. Flat is better than nested.
2112321123
2212322123
2312323123
2412324123
2512325123
2612326123
2712327123
2812328123
2912329123
3012330123
3131
t32   1. Beautiful is beTTer than ugly.t32   1. Beautiful is better than ugly.
33   2. Explicit is better than implicit.
34   3. Simple is better than complex.33   3.   Simple is better than complex.
35   4. Complex is better than complicated.34   4. Complicated is better than complex.
35   5. Flat is better than nested.
3612336123
3712337123
3812338123
3912339123
4012340123
4112341123
4212342123
4312343123
4412344123
4512345123
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

Context (first diff within numlines=5(default))


from
to
f1f1
n2   1. Beautiful is beTTer than ugly.n2   1. Beautiful is better than ugly.
3   2. Explicit is better than implicit.
4   3. Simple is better than complex.3   3.   Simple is better than complex.
5   4. Complex is better than complicated.4   4. Complicated is better than complex.
5   5. Flat is better than nested.
61236123
71237123
81238123
91239123
1012310123
1212312123
1312313123
1412314123
1512315123
1616
n17   1. Beautiful is beTTer than ugly.n17   1. Beautiful is better than ugly.
18   2. Explicit is better than implicit.
19   3. Simple is better than complex.18   3.   Simple is better than complex.
20   4. Complex is better than complicated.19   4. Complicated is better than complex.
20   5. Flat is better than nested.
2112321123
2212322123
2312323123
2412324123
2512325123
2712327123
2812328123
2912329123
3012330123
3131
t32   1. Beautiful is beTTer than ugly.t32   1. Beautiful is better than ugly.
33   2. Explicit is better than implicit.
34   3. Simple is better than complex.33   3.   Simple is better than complex.
35   4. Complex is better than complicated.34   4. Complicated is better than complex.
35   5. Flat is better than nested.
3612336123
3712337123
3812338123
3912339123
4012340123

Context (first diff after numlines=5(default))


from
to
74567456
84568456
94569456
1045610456
1111
n12   1. Beautiful is beTTer than ugly.n12   1. Beautiful is better than ugly.
13   2. Explicit is better than implicit.
14   3. Simple is better than complex.13   3.   Simple is better than complex.
15   4. Complex is better than complicated.14   4. Complicated is better than complex.
15   5. Flat is better than nested.
1612316123
1712317123
1812318123
1912319123
2012320123
2212322123
2312323123
2412324123
2512325123
2626
n27   1. Beautiful is beTTer than ugly.n27   1. Beautiful is better than ugly.
28   2. Explicit is better than implicit.
29   3. Simple is better than complex.28   3.   Simple is better than complex.
30   4. Complex is better than complicated.29   4. Complicated is better than complex.
30   5. Flat is better than nested.
3112331123
3212332123
3312333123
3412334123
3512335123
3712337123
3812338123
3912339123
4012340123
4141
t42   1. Beautiful is beTTer than ugly.t42   1. Beautiful is better than ugly.
43   2. Explicit is better than implicit.
44   3. Simple is better than complex.43   3.   Simple is better than complex.
45   4. Complex is better than complicated.44   4. Complicated is better than complex.
45   5. Flat is better than nested.
4612346123
4712347123
4812348123
4912349123
5012350123

Context (numlines=6)


from
to
f1f1
n2   1. Beautiful is beTTer than ugly.n2   1. Beautiful is better than ugly.
3   2. Explicit is better than implicit.
4   3. Simple is better than complex.3   3.   Simple is better than complex.
5   4. Complex is better than complicated.4   4. Complicated is better than complex.
5   5. Flat is better than nested.
61236123
71237123
81238123
91239123
1012310123
1112311123
1212312123
1312313123
1412314123
1512315123
1616
n17   1. Beautiful is beTTer than ugly.n17   1. Beautiful is better than ugly.
18   2. Explicit is better than implicit.
19   3. Simple is better than complex.18   3.   Simple is better than complex.
20   4. Complex is better than complicated.19   4. Complicated is better than complex.
20   5. Flat is better than nested.
2112321123
2212322123
2312323123
2412324123
2512325123
2612326123
2712327123
2812328123
2912329123
3012330123
3131
t32   1. Beautiful is beTTer than ugly.t32   1. Beautiful is better than ugly.
33   2. Explicit is better than implicit.
34   3. Simple is better than complex.33   3.   Simple is better than complex.
35   4. Complex is better than complicated.34   4. Complicated is better than complex.
35   5. Flat is better than nested.
3612336123
3712337123
3812338123
3912339123
4012340123
4112341123

Context (numlines=0)


from
to
n2   1. Beautiful is beTTer than ugly.n2   1. Beautiful is better than ugly.
3   2. Explicit is better than implicit.
4   3. Simple is better than complex.3   3.   Simple is better than complex.
5   4. Complex is better than complicated.4   4. Complicated is better than complex.
5   5. Flat is better than nested.
n17   1. Beautiful is beTTer than ugly.n17   1. Beautiful is better than ugly.
18   2. Explicit is better than implicit.
19   3. Simple is better than complex.18   3.   Simple is better than complex.
20   4. Complex is better than complicated.19   4. Complicated is better than complex.
20   5. Flat is better than nested.
t32   1. Beautiful is beTTer than ugly.t32   1. Beautiful is better than ugly.
33   2. Explicit is better than implicit.
34   3. Simple is better than complex.33   3.   Simple is better than complex.
35   4. Complex is better than complicated.34   4. Complicated is better than complex.
35   5. Flat is better than nested.

Same Context


from
to
t No Differences Found t No Differences Found 

Same Full


from
to
t1t1
2   1. Beautiful is beTTer than ugly.2   1. Beautiful is beTTer than ugly.
3   2. Explicit is better than implicit.3   2. Explicit is better than implicit.
4   3. Simple is better than complex.4   3. Simple is better than complex.
5   4. Complex is better than complicated.5   4. Complex is better than complicated.
61236123
71237123
81238123
91239123
1012310123
1112311123
1212312123
1312313123
1412314123
1512315123
1616
17   1. Beautiful is beTTer than ugly.17   1. Beautiful is beTTer than ugly.
18   2. Explicit is better than implicit.18   2. Explicit is better than implicit.
19   3. Simple is better than complex.19   3. Simple is better than complex.
20   4. Complex is better than complicated.20   4. Complex is better than complicated.
2112321123
2212322123
2312323123
2412324123
2512325123
2612326123
2712327123
2812328123
2912329123
3012330123
3131
32   1. Beautiful is beTTer than ugly.32   1. Beautiful is beTTer than ugly.
33   2. Explicit is better than implicit.33   2. Explicit is better than implicit.
34   3. Simple is better than complex.34   3. Simple is better than complex.
35   4. Complex is better than complicated.35   4. Complex is better than complicated.
3612336123
3712337123
3812338123
3912339123
4012340123
4112341123
4212342123
4312343123
4412344123
4512345123

Empty Context


from
to
t No Differences Found t No Differences Found 

Empty Full


from
to
t Empty File t Empty File 

tabsize=2

f1f1
t2    Line 1: preceeded by from:[tt] to:[ssss]t2    Line 1: preceeded by from:[tt] to:[ssss]
3      Line 2: preceeded by from:[sstt] to:[sssst]3      Line 2: preceeded by from:[sstt] to:[sssst]
4      Line 3: preceeded by from:[sstst] to:[ssssss]4      Line 3: preceeded by from:[sstst] to:[ssssss]
5Line 4:   has from:[sst] to:[sss] after :5Line 4:   has from:[sst] to:[sss] after :
6Line 5: has from:[t] to:[ss] at end 6Line 5: has from:[t] to:[ss] at end  

tabsize=default

f1f1
t2                Line 1: preceeded by from:[tt] to:[ssss]t2    Line 1: preceeded by from:[tt] to:[ssss]
3                Line 2: preceeded by from:[sstt] to:[sssst]3        Line 2: preceeded by from:[sstt] to:[sssst]
4                Line 3: preceeded by from:[sstst] to:[ssssss]4      Line 3: preceeded by from:[sstst] to:[ssssss]
5Line 4:         has from:[sst] to:[sss] after :5Line 4:   has from:[sst] to:[sss] after :
6Line 5: has from:[t] to:[ss] at end     6Line 5: has from:[t] to:[ss] at end  

Context (wrapcolumn=14,numlines=0)

n4line 2n4line 2    adde
 >d
n6line 4   changn6line 4   chanG
>e>E
7line 5   chang7line 5a  chanG
>ed >ed 
8line 6   chang8line 6a  chang
>e>E
n10line 8  subtran10line 8
>cted 
t1212345678901234t121234567890
>56789012345689 
>012345 
13short line13another long l
 >ine that needs
 > to be wrapped
14just fits in!!14just fitS in!!
15just fits in t15just fits in t
>wo lines yup!!>wo lineS yup!!

wrapcolumn=14,splitlines()

f1line 0f1line 0
212345678901234212345678901234
>56789012345689>56789012345689
>012345>012345
3line 13line 1
n4line 2n4line 2    adde
 >d
5line 35line 3
n6line 4   changn6line 4   chanG
>e>E
7line 5   chang7line 5a  chanG
>ed >ed 
8line 6   chang8line 6a  chang
>e>E
9line 79line 7
n10line 8  subtran10line 8
>cted 
11line 911line 9
t1212345678901234t121234567890
>56789012345689 
>012345 
13short line13another long l
 >ine that needs
 > to be wrapped
14just fits in!!14just fitS in!!
15just fits in t15just fits in t
>wo lines yup!!>wo lineS yup!!
16the end16the end

wrapcolumn=14,splitlines(True)

f1line 0f1line 0
212345678901234212345678901234
>56789012345689>56789012345689
>012345>012345
3line 13line 1
n4line 2n4line 2    adde
 >d
5line 35line 3
n6line 4   changn6line 4   chanG
>e>E
7line 5   chang7line 5a  chanG
>ed >ed 
8line 6   chang8line 6a  chang
>e>E
9line 79line 7
n10line 8  subtran10line 8
>cted 
11line 911line 9
t1212345678901234t121234567890
>56789012345689 
>012345 
13short line13another long l
 >ine that needs
 > to be wrapped
14just fits in!!14just fitS in!!
15just fits in t15just fits in t
>wo lines yup!!>wo lineS yup!!
16the end16the end
Index: test_difflib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_difflib.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- test_difflib.py 10 Jul 2004 23:54:07 -0000 1.10 +++ test_difflib.py 29 Aug 2004 16:34:40 -0000 1.11 @@ -1,5 +1,5 @@ import difflib -from test import test_support +from test.test_support import run_unittest, findfile import unittest import doctest @@ -19,6 +19,130 @@ diff_gen = difflib.unified_diff([], []) self.assertRaises(StopIteration, diff_gen.next) +patch914575_from1 = """ + 1. Beautiful is beTTer than ugly. + 2. Explicit is better than implicit. + 3. Simple is better than complex. + 4. Complex is better than complicated. +""" + +patch914575_to1 = """ + 1. Beautiful is better than ugly. + 3. Simple is better than complex. + 4. Complicated is better than complex. + 5. Flat is better than nested. +""" + +patch914575_from2 = """ +\t\tLine 1: preceeded by from:[tt] to:[ssss] + \t\tLine 2: preceeded by from:[sstt] to:[sssst] + \t \tLine 3: preceeded by from:[sstst] to:[ssssss] +Line 4: \thas from:[sst] to:[sss] after : +Line 5: has from:[t] to:[ss] at end\t +""" + +patch914575_to2 = """ + Line 1: preceeded by from:[tt] to:[ssss] + \tLine 2: preceeded by from:[sstt] to:[sssst] + Line 3: preceeded by from:[sstst] to:[ssssss] +Line 4: has from:[sst] to:[sss] after : +Line 5: has from:[t] to:[ss] at end +""" + +patch914575_from3 = """line 0 +1234567890123456789012345689012345 +line 1 +line 2 +line 3 +line 4 changed +line 5 changed +line 6 changed +line 7 +line 8 subtracted +line 9 +1234567890123456789012345689012345 +short line +just fits in!! +just fits in two lines yup!! +the end""" + +patch914575_to3 = """line 0 +1234567890123456789012345689012345 +line 1 +line 2 added +line 3 +line 4 chanGEd +line 5a chanGed +line 6a changEd +line 7 +line 8 +line 9 +1234567890 +another long line that needs to be wrapped +just fitS in!! +just fits in two lineS yup!! +the end""" + +class TestSFpatches(unittest.TestCase): + + def test_html_diff(self): + # Check SF patch 914575 for generating HTML differences + f1a = ((patch914575_from1 + '123\n'*10)*3) + t1a = (patch914575_to1 + '123\n'*10)*3 + f1b = '456\n'*10 + f1a + t1b = '456\n'*10 + t1a + f1a = f1a.splitlines() + t1a = t1a.splitlines() + f1b = f1b.splitlines() + t1b = t1b.splitlines() + f2 = patch914575_from2.splitlines() + t2 = patch914575_to2.splitlines() + f3 = patch914575_from3 + t3 = patch914575_to3 + i = difflib.HtmlDiff() + j = difflib.HtmlDiff(tabsize=2) + k = difflib.HtmlDiff(wrapcolumn=14) + + full = i.make_file(f1a,t1a,'from','to',context=False,numlines=5) + tables = '\n'.join( + [ + '

Context (first diff within numlines=5(default))

', + i.make_table(f1a,t1a,'from','to',context=True), + '

Context (first diff after numlines=5(default))

', + i.make_table(f1b,t1b,'from','to',context=True), + '

Context (numlines=6)

', + i.make_table(f1a,t1a,'from','to',context=True,numlines=6), + '

Context (numlines=0)

', + i.make_table(f1a,t1a,'from','to',context=True,numlines=0), + '

Same Context

', + i.make_table(f1a,f1a,'from','to',context=True), + '

Same Full

', + i.make_table(f1a,f1a,'from','to',context=False), + '

Empty Context

', + i.make_table([],[],'from','to',context=True), + '

Empty Full

', + i.make_table([],[],'from','to',context=False), + '

tabsize=2

', + j.make_table(f2,t2), + '

tabsize=default

', + i.make_table(f2,t2), + '

Context (wrapcolumn=14,numlines=0)

', + k.make_table(f3.splitlines(),t3.splitlines(),context=True,numlines=0), + '

wrapcolumn=14,splitlines()

', + k.make_table(f3.splitlines(),t3.splitlines()), + '

wrapcolumn=14,splitlines(True)

', + k.make_table(f3.splitlines(True),t3.splitlines(True)), + ]) + actual = full.replace('','\n%s\n' % tables) + # temporarily uncomment next three lines to baseline this test + #f = open('test_difflib_expect.html','w') + #f.write(actual) + #f.close() + expect = open(findfile('test_difflib_expect.html')).read() + + + self.assertEqual(actual,expect) + Doctests = doctest.DocTestSuite(difflib) -test_support.run_unittest(TestSFbugs, Doctests) +run_unittest(TestSFpatches, TestSFbugs, Doctests) From loewis at users.sourceforge.net Sun Aug 29 18:41:14 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 18:41:16 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils ccompiler.py, 1.59, 1.60 unixccompiler.py, 1.55, 1.56 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24086/Lib/distutils Modified Files: ccompiler.py unixccompiler.py Log Message: Patch #973204: Use -rpath instead of -R on Irix and Tru64. Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/ccompiler.py,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- ccompiler.py 18 Jul 2004 06:14:42 -0000 1.59 +++ ccompiler.py 29 Aug 2004 16:40:55 -0000 1.60 @@ -1241,7 +1241,11 @@ lib_opts.append (compiler.library_dir_option (dir)) for dir in runtime_library_dirs: - lib_opts.append (compiler.runtime_library_dir_option (dir)) + opt = compiler.runtime_library_dir_option (dir) + if type(opt) is ListType: + lib_opts = lib_opts + opt + else: + lib_opts.append (opt) # XXX it's important that we *not* remove redundant library mentions! # sometimes you really do have to say "-lfoo -lbar -lfoo" in order to Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- unixccompiler.py 18 Jul 2004 06:14:42 -0000 1.55 +++ unixccompiler.py 29 Aug 2004 16:40:55 -0000 1.56 @@ -205,6 +205,8 @@ return "-L" + dir elif sys.platform[:5] == "hp-ux": return "+s -L" + dir + elif sys.platform[:7] == "irix646" or sys.platform[:6] == "osf1V5": + return ["-rpath", dir] elif compiler[:3] == "gcc" or compiler[:3] == "g++": return "-Wl,-R" + dir else: From loewis at users.sourceforge.net Sun Aug 29 18:45:15 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 18:45:18 2004 Subject: [Python-checkins] python/dist/src/Lib/distutils ccompiler.py, 1.57, 1.57.10.1 unixccompiler.py, 1.54, 1.54.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24834/Lib/distutils Modified Files: Tag: release23-maint ccompiler.py unixccompiler.py Log Message: Patch #973204: Use -rpath instead of -R on Irix and True64. Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/ccompiler.py,v retrieving revision 1.57 retrieving revision 1.57.10.1 diff -u -d -r1.57 -r1.57.10.1 --- ccompiler.py 24 Apr 2003 19:49:23 -0000 1.57 +++ ccompiler.py 29 Aug 2004 16:45:13 -0000 1.57.10.1 @@ -1237,7 +1237,11 @@ lib_opts.append (compiler.library_dir_option (dir)) for dir in runtime_library_dirs: - lib_opts.append (compiler.runtime_library_dir_option (dir)) + opt = compiler.runtime_library_dir_option (dir) + if type(opt) is ListType: + lib_opts = lib_opts + opt + else: + lib_opts.append (opt) # XXX it's important that we *not* remove redundant library mentions! # sometimes you really do have to say "-lfoo -lbar -lfoo" in order to Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v retrieving revision 1.54 retrieving revision 1.54.8.1 diff -u -d -r1.54 -r1.54.8.1 --- unixccompiler.py 1 Jun 2003 19:27:40 -0000 1.54 +++ unixccompiler.py 29 Aug 2004 16:45:13 -0000 1.54.8.1 @@ -205,6 +205,8 @@ return "-L" + dir elif sys.platform[:5] == "hp-ux": return "+s -L" + dir + elif sys.platform[:7] == "irix646" or sys.platform[:6] == "osf1V5": + return ["-rpath", dir] elif compiler[:3] == "gcc" or compiler[:3] == "g++": return "-Wl,-R" + dir else: From loewis at users.sourceforge.net Sun Aug 29 18:45:16 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 18:45:20 2004 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.148, 1.831.4.149 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24834/Misc Modified Files: Tag: release23-maint NEWS Log Message: Patch #973204: Use -rpath instead of -R on Irix and True64. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.148 retrieving revision 1.831.4.149 diff -u -d -r1.831.4.148 -r1.831.4.149 --- NEWS 25 Aug 2004 10:53:30 -0000 1.831.4.148 +++ NEWS 29 Aug 2004 16:45:13 -0000 1.831.4.149 @@ -119,6 +119,9 @@ Build ----- +- Patch #973204: Use -rpath instead of -R for runtime_library_dirs + on Irix and True64. + - Bug #978645: Modules/getpath.c now builds properly under --disable-framework build under OS X. From loewis at users.sourceforge.net Sun Aug 29 18:53:29 2004 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Aug 29 18:53:33 2004 Subject: [Python-checkins] python/dist/src/Lib CGIHTTPServer.py,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26279/Lib Modified Files: CGIHTTPServer.py Log Message: Patch #727483: Add AUTH_TYPE and REMOTE_USER. Index: CGIHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/CGIHTTPServer.py,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- CGIHTTPServer.py 20 Mar 2004 22:18:03 -0000 1.35 +++ CGIHTTPServer.py 29 Aug 2004 16:53:26 -0000 1.36 @@ -153,8 +153,21 @@ if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] - # XXX AUTH_TYPE - # XXX REMOTE_USER + authorization = self.headers.getheader("authorization") + if authorization: + authorization = authorization.split() + if len(authorization) == 2: + import base64, binascii + env['AUTH_TYPE'] = authorization[0] + if authorization[0].lower() == "basic": + try: + authorization = base64.decodestring(authorization[1]) + except binascii.Error: + pass + else: + authorization = authorization.split(':') + if len(authorization) == 2: + env['REMOTE_USER'] = authorization[0] # XXX REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type From tim_one at users.sourceforge.net Sun Aug 29 20:47:34 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 29 20:47:36 2004 Subject: [Python-checkins] python/dist/src/Lib/test test_difflib.py, 1.11, 1.12 test_os.py, 1.26, 1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13279/Lib/test Modified Files: test_difflib.py test_os.py Log Message: Whitespace normalization. Index: test_difflib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_difflib.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- test_difflib.py 29 Aug 2004 16:34:40 -0000 1.11 +++ test_difflib.py 29 Aug 2004 18:47:31 -0000 1.12 @@ -46,7 +46,7 @@ \tLine 2: preceeded by from:[sstt] to:[sssst] Line 3: preceeded by from:[sstst] to:[ssssss] Line 4: has from:[sst] to:[sss] after : -Line 5: has from:[t] to:[ss] at end +Line 5: has from:[t] to:[ss] at end """ patch914575_from3 = """line 0 @@ -54,9 +54,9 @@ line 1 line 2 line 3 -line 4 changed -line 5 changed -line 6 changed +line 4 changed +line 5 changed +line 6 changed line 7 line 8 subtracted line 9 @@ -71,9 +71,9 @@ line 1 line 2 added line 3 -line 4 chanGEd -line 5a chanGed -line 6a changEd +line 4 chanGEd +line 5a chanGed +line 6a changEd line 7 line 8 line 9 @@ -102,21 +102,21 @@ i = difflib.HtmlDiff() j = difflib.HtmlDiff(tabsize=2) k = difflib.HtmlDiff(wrapcolumn=14) - + full = i.make_file(f1a,t1a,'from','to',context=False,numlines=5) tables = '\n'.join( [ - '

Context (first diff within numlines=5(default))

', + '

Context (first diff within numlines=5(default))

', i.make_table(f1a,t1a,'from','to',context=True), - '

Context (first diff after numlines=5(default))

', + '

Context (first diff after numlines=5(default))

', i.make_table(f1b,t1b,'from','to',context=True), - '

Context (numlines=6)

', + '

Context (numlines=6)

', i.make_table(f1a,t1a,'from','to',context=True,numlines=6), - '

Context (numlines=0)

', + '

Context (numlines=0)

', i.make_table(f1a,t1a,'from','to',context=True,numlines=0), - '

Same Context

', + '

Same Context

', i.make_table(f1a,f1a,'from','to',context=True), - '

Same Full

', + '

Same Full

', i.make_table(f1a,f1a,'from','to',context=False), '

Empty Context

', i.make_table([],[],'from','to',context=True), @@ -139,8 +139,8 @@ #f.write(actual) #f.close() expect = open(findfile('test_difflib_expect.html')).read() - - + + self.assertEqual(actual,expect) Doctests = doctest.DocTestSuite(difflib) Index: test_os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_os.py,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- test_os.py 29 Aug 2004 15:46:34 -0000 1.26 +++ test_os.py 29 Aug 2004 18:47:31 -0000 1.27 @@ -361,7 +361,7 @@ WalkTests, MakedirTests, DevNullTests, - URandomTests + URandomTests ) if __name__ == "__main__": From tim_one at users.sourceforge.net Sun Aug 29 20:47:33 2004 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun Aug 29 20:47:39 2004 Subject: [Python-checkins] python/dist/src/Lib difflib.py, 1.23, 1.24 os.py, 1.78, 1.79 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13279/Lib Modified Files: difflib.py os.py Log Message: Whitespace normalization. Index: difflib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/difflib.py,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- difflib.py 29 Aug 2004 16:34:39 -0000 1.23 +++ difflib.py 29 Aug 2004 18:47:31 -0000 1.24 @@ -1289,7 +1289,7 @@ if None, all from/to text lines will be generated. linejunk -- passed on to ndiff (see ndiff documentation) charjunk -- passed on to ndiff (see ndiff documentation) - + This function returns an interator which returns a tuple: (from line tuple, to line tuple, boolean flag) @@ -1300,7 +1300,7 @@ '\0-' -- marks start of deleted text '\0^' -- marks start of changed text '\1' -- marks end of added/deleted/changed text - + boolean flag -- None indicates context separation, True indicates either "from" or "to" line contains a change, otherwise False. @@ -1310,13 +1310,13 @@ Note, this function utilizes the ndiff function to generate the side by side difference markup. Optional ndiff arguments may be passed to this - function and they in turn will be passed to ndiff. + function and they in turn will be passed to ndiff. """ - import re + import re # regular expression for finding intraline change indices change_re = re.compile('(\++|\-+|\^+)') - + # create the difference iterator to generate the differences diff_lines_iterator = ndiff(fromlines,tolines,linejunk,charjunk) @@ -1375,7 +1375,7 @@ # thing (such as adding the line number) then replace the special # marks with what the user's change markup. return (num_lines[side],text) - + def _line_iterator(): """Yields from/to lines of text with a change indication. @@ -1392,7 +1392,7 @@ """ lines = [] num_blanks_pending, num_blanks_to_yield = 0, 0 - while True: + while True: # Load up next 4 lines so we can look ahead, create strings which # are a concatenation of the first character of each of the 4 lines # so we can do some very readable comparisons. @@ -1550,7 +1550,7 @@ -