Commit 9203501b authored by Benjamin Peterson's avatar Benjamin Peterson

Merged revisions...

Merged revisions 67889-67892,67895,67898,67904-67907,67912,67918,67920-67921,67923-67924,67926-67927,67930,67943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

................
  r67889 | benjamin.peterson | 2008-12-20 19:04:32 -0600 (Sat, 20 Dec 2008) | 1 line

  sphinx.web is long gone
................
  r67890 | benjamin.peterson | 2008-12-20 19:12:26 -0600 (Sat, 20 Dec 2008) | 1 line

  update readme
................
  r67891 | benjamin.peterson | 2008-12-20 19:14:47 -0600 (Sat, 20 Dec 2008) | 1 line

  there are way too many places which need to have the current version added
................
  r67892 | benjamin.peterson | 2008-12-20 19:29:32 -0600 (Sat, 20 Dec 2008) | 9 lines

  Merged revisions 67809 via svnmerge from
  svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3

  ........
    r67809 | benjamin.peterson | 2008-12-15 21:54:45 -0600 (Mon, 15 Dec 2008) | 1 line

    fix logic error
  ........
................
  r67895 | neal.norwitz | 2008-12-21 08:28:32 -0600 (Sun, 21 Dec 2008) | 2 lines

  Add Tarek for work on distutils.
................
  r67898 | benjamin.peterson | 2008-12-21 15:00:53 -0600 (Sun, 21 Dec 2008) | 1 line

  compute DISTVERSION with patchlevel.py
................
  r67904 | benjamin.peterson | 2008-12-22 14:44:58 -0600 (Mon, 22 Dec 2008) | 1 line

  less attitude
................
  r67905 | benjamin.peterson | 2008-12-22 14:51:15 -0600 (Mon, 22 Dec 2008) | 1 line

  fix #4720: the format to PyArg_ParseTupleAndKeywords can now start with '|'
................
  r67906 | benjamin.peterson | 2008-12-22 14:52:53 -0600 (Mon, 22 Dec 2008) | 1 line

  add NEWS note
................
  r67907 | benjamin.peterson | 2008-12-22 16:12:19 -0600 (Mon, 22 Dec 2008) | 1 line

  silence compiler warning
................
  r67912 | georg.brandl | 2008-12-23 06:37:21 -0600 (Tue, 23 Dec 2008) | 2 lines

  Fix missing "svn" command.
................
  r67918 | georg.brandl | 2008-12-23 09:44:25 -0600 (Tue, 23 Dec 2008) | 2 lines

  Markup fix.
................
  r67920 | benjamin.peterson | 2008-12-23 14:09:28 -0600 (Tue, 23 Dec 2008) | 1 line

  use a global variable, so the compiler doesn't optimize the assignment out
................
  r67921 | benjamin.peterson | 2008-12-23 14:12:33 -0600 (Tue, 23 Dec 2008) | 1 line

  make global static
................
  r67923 | benjamin.peterson | 2008-12-24 09:10:27 -0600 (Wed, 24 Dec 2008) | 1 line

  #4736 BufferRWPair.closed shouldn't try to call another property as a function
................
  r67924 | benjamin.peterson | 2008-12-24 10:10:05 -0600 (Wed, 24 Dec 2008) | 1 line

  pretend exceptions don't exist a while longer
................
  r67926 | tarek.ziade | 2008-12-24 13:10:05 -0600 (Wed, 24 Dec 2008) | 1 line

  fixed #4400 : distutils .pypirc default generated file was broken.
................
  r67927 | benjamin.peterson | 2008-12-26 17:26:30 -0600 (Fri, 26 Dec 2008) | 1 line

  python version is included in file name now
................
  r67930 | hirokazu.yamamoto | 2008-12-26 22:19:48 -0600 (Fri, 26 Dec 2008) | 2 lines

  Issue #4740: Use HIGHEST_PROTOCOL in pickle test.
  (There is no behavior difference in 2.x because HIGHEST_PROTOCOL == 2)
................
  r67943 | alexandre.vassalotti | 2008-12-27 04:02:59 -0600 (Sat, 27 Dec 2008) | 2 lines

  Fix bogus unicode tests in pickletester.
................
parent db5fe667
...@@ -9,7 +9,7 @@ SVNROOT = http://svn.python.org/projects ...@@ -9,7 +9,7 @@ SVNROOT = http://svn.python.org/projects
SPHINXOPTS = SPHINXOPTS =
PAPER = PAPER =
SOURCES = SOURCES =
DISTVERSION = DISTVERSION = $(shell $(PYTHON) tools/sphinxext/patchlevel.py)
ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \ ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \
$(SPHINXOPTS) . build/$(BUILDER) $(SOURCES) $(SPHINXOPTS) . build/$(BUILDER) $(SOURCES)
...@@ -111,33 +111,33 @@ dist: ...@@ -111,33 +111,33 @@ dist:
# archive the HTML # archive the HTML
make html make html
cp -pPR build/html dist/python$(DISTVERSION)-docs-html cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
tar -C dist -cf dist/python$(DISTVERSION)-docs-html.tar python$(DISTVERSION)-docs-html tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
bzip2 -9 -k dist/python$(DISTVERSION)-docs-html.tar bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
(cd dist; zip -q -r -9 python$(DISTVERSION)-docs-html.zip python$(DISTVERSION)-docs-html) (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
rm -r dist/python$(DISTVERSION)-docs-html rm -r dist/python-$(DISTVERSION)-docs-html
rm dist/python$(DISTVERSION)-docs-html.tar rm dist/python-$(DISTVERSION)-docs-html.tar
# archive the text build # archive the text build
make text make text
cp -pPR build/text dist/python$(DISTVERSION)-docs-text cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
tar -C dist -cf dist/python$(DISTVERSION)-docs-text.tar python$(DISTVERSION)-docs-text tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
bzip2 -9 -k dist/python$(DISTVERSION)-docs-text.tar bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
(cd dist; zip -q -r -9 python$(DISTVERSION)-docs-text.zip python$(DISTVERSION)-docs-text) (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
rm -r dist/python$(DISTVERSION)-docs-text rm -r dist/python-$(DISTVERSION)-docs-text
rm dist/python$(DISTVERSION)-docs-text.tar rm dist/python-$(DISTVERSION)-docs-text.tar
# archive the A4 latex # archive the A4 latex
-rm -r build/latex -rm -r build/latex
make latex PAPER=a4 make latex PAPER=a4
(cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2) (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
cp build/latex/docs-pdf.zip dist/python$(DISTVERSION)-docs-pdf-a4.zip cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
cp build/latex/docs-pdf.tar.bz2 dist/python$(DISTVERSION)-docs-pdf-a4.tar.bz2 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
# archive the letter latex # archive the letter latex
rm -r build/latex rm -r build/latex
make latex PAPER=letter make latex PAPER=letter
(cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2) (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
cp build/latex/docs-pdf.zip dist/python$(DISTVERSION)-docs-pdf-letter.zip cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
cp build/latex/docs-pdf.tar.bz2 dist/python$(DISTVERSION)-docs-pdf-letter.tar.bz2 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
...@@ -81,8 +81,7 @@ You'll need to checkout the Sphinx package to the `tools/` directory:: ...@@ -81,8 +81,7 @@ You'll need to checkout the Sphinx package to the `tools/` directory::
svn co http://svn.python.org/projects/doctools/trunk/sphinx tools/sphinx svn co http://svn.python.org/projects/doctools/trunk/sphinx tools/sphinx
Then, you need to install Docutils 0.4 (the SVN snapshot won't work), either Then, you need to install Docutils, either by checking it out via ::
by checking it out via ::
svn co http://svn.python.org/projects/external/docutils-0.4/docutils tools/docutils svn co http://svn.python.org/projects/external/docutils-0.4/docutils tools/docutils
...@@ -99,19 +98,18 @@ Then, make an output directory, e.g. under `build/`, and run :: ...@@ -99,19 +98,18 @@ Then, make an output directory, e.g. under `build/`, and run ::
python tools/sphinx-build.py -b<builder> . build/<outputdirectory> python tools/sphinx-build.py -b<builder> . build/<outputdirectory>
where `<builder>` is one of html, web or htmlhelp (for explanations see the make where `<builder>` is one of html, text, latex, or htmlhelp (for explanations see
targets above). the make targets above).
Contributing Contributing
============ ============
For bugs in the content, the online version at http://docs.python.org/ has a Bugs in the content should be reported to the Python bug tracker at
"suggest change" facility that can be used to correct errors in the source text http://bugs.python.org.
and submit them as a patch to the maintainers.
Bugs in the toolset should be reported in the Python bug tracker at Bugs in the toolset should be reported in the Sphinx bug tracker at
http://bugs.python.org/. http://www.bitbucket.org/birkenfeld/sphinx/issues/.
You can also send a mail to the Python Documentation Team at docs@python.org, You can also send a mail to the Python Documentation Team at docs@python.org,
and we will process your request as soon as possible. and we will process your request as soon as possible.
......
...@@ -305,8 +305,8 @@ inside nested parentheses. They are: ...@@ -305,8 +305,8 @@ inside nested parentheses. They are:
``;`` ``;``
The list of format units ends here; the string after the semicolon is used as The list of format units ends here; the string after the semicolon is used as
the error message *instead* of the default error message. Clearly, ``:`` and the error message *instead* of the default error message. ``:`` and ``;``
``;`` mutually exclude each other. mutually exclude each other.
Note that any Python object references which are provided to the caller are Note that any Python object references which are provided to the caller are
*borrowed* references; do not decrement their reference count! *borrowed* references; do not decrement their reference count!
......
...@@ -31,6 +31,7 @@ All Python releases are Open Source (see http://www.opensource.org/ for the Open ...@@ -31,6 +31,7 @@ All Python releases are Open Source (see http://www.opensource.org/ for the Open
Source Definition). Historically, most, but not all, Python releases have also Source Definition). Historically, most, but not all, Python releases have also
been GPL-compatible; the table below summarizes the various releases. been GPL-compatible; the table below summarizes the various releases.
<<<<<<< .working
+----------------+--------------+------------+------------+-----------------+ +----------------+--------------+------------+------------+-----------------+
| Release | Derived from | Year | Owner | GPL compatible? | | Release | Derived from | Year | Owner | GPL compatible? |
+================+==============+============+============+=================+ +================+==============+============+============+=================+
...@@ -90,9 +91,12 @@ been GPL-compatible; the table below summarizes the various releases. ...@@ -90,9 +91,12 @@ been GPL-compatible; the table below summarizes the various releases.
+----------------+--------------+------------+------------+-----------------+ +----------------+--------------+------------+------------+-----------------+
| 2.6 | 2.5 | 2008 | PSF | yes | | 2.6 | 2.5 | 2008 | PSF | yes |
+----------------+--------------+------------+------------+-----------------+ +----------------+--------------+------------+------------+-----------------+
| 2.6.1 | 2.6 | 2008 | PSF | yes |
+----------------+--------------+------------+------------+-----------------+
| 3.0 | 2.6 | 2008 | PSF | yes | | 3.0 | 2.6 | 2008 | PSF | yes |
+----------------+--------------+------------+------------+-----------------+ +----------------+--------------+------------+------------+-----------------+
.. note:: .. note::
GPL-compatible doesn't mean that we're distributing Python under the GPL. All GPL-compatible doesn't mean that we're distributing Python under the GPL. All
......
# -*- coding: utf-8 -*-
"""
Sphinx - Python documentation webserver
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:copyright: 2007 by Georg Brandl.
:license: Python license.
"""
import sys
if __name__ == '__main__':
from sphinx.web import main
sys.exit(main(sys.argv))
...@@ -19,20 +19,20 @@ in the table are the size of the download files in megabytes.</p> ...@@ -19,20 +19,20 @@ in the table are the size of the download files in megabytes.</p>
<table class="docutils"> <table class="docutils">
<tr><th>Format</th><th>Packed as .zip</th><th>Packed as .tar.bz2</th></tr> <tr><th>Format</th><th>Packed as .zip</th><th>Packed as .tar.bz2</th></tr>
<tr><td>PDF (US-Letter paper size)</td> <tr><td>PDF (US-Letter paper size)</td>
<td><a href="{{ dlbase }}/python-docs-pdf-letter.zip">Download</a> (ca. 8 MB)</td> <td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-letter.zip">Download</a> (ca. 8 MB)</td>
<td><a href="{{ dlbase }}/python-docs-pdf-letter.tar.bz2">Download</a> (ca. 8 MB)</td> <td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-letter.tar.bz2">Download</a> (ca. 8 MB)</td>
</tr> </tr>
<tr><td>PDF (A4 paper size)</td> <tr><td>PDF (A4 paper size)</td>
<td><a href="{{ dlbase }}/python-docs-pdf-a4.zip">Download</a> (ca. 8 MB)</td> <td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-a4.zip">Download</a> (ca. 8 MB)</td>
<td><a href="{{ dlbase }}/python-docs-pdf-a4.tar.bz2">Download</a> (ca. 8 MB)</td> <td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-a4.tar.bz2">Download</a> (ca. 8 MB)</td>
</tr> </tr>
<tr><td>HTML</td> <tr><td>HTML</td>
<td><a href="{{ dlbase }}/python-docs-html.zip">Download</a> (ca. 6 MB)</td> <td><a href="{{ dlbase }}/python-{{ release }}-docs-html.zip">Download</a> (ca. 6 MB)</td>
<td><a href="{{ dlbase }}/python-docs-html.tar.bz2">Download</a> (ca. 4 MB)</td> <td><a href="{{ dlbase }}/python-{{ release }}-docs-html.tar.bz2">Download</a> (ca. 4 MB)</td>
</tr> </tr>
<tr><td>Plain Text</td> <tr><td>Plain Text</td>
<td><a href="{{ dlbase }}/python-docs-text.zip">Download</a> (ca. 2 MB)</td> <td><a href="{{ dlbase }}/python-docs-text.zip">Download</a> (ca. 2 MB)</td>
<td><a href="{{ dlbase }}/python-docs-text.tar.bz2">Download</a> (ca. 1.5 MB)</td> <td><a href="{{ dlbase }}/python-{{ release }}-docs-text.tar.bz2">Download</a> (ca. 1.5 MB)</td>
</tr> </tr>
</table> </table>
......
...@@ -200,42 +200,20 @@ required syntactically but the program requires no action. For example:: ...@@ -200,42 +200,20 @@ required syntactically but the program requires no action. For example::
... pass # Busy-wait for keyboard interrupt (Ctrl+C) ... pass # Busy-wait for keyboard interrupt (Ctrl+C)
... ...
This is commonly used for creating minimal classes such as exceptions, or This is commonly used for creating minimal classes::
for ignoring unwanted exceptions::
>>> class ParserError(Exception): >>> class MyEmptyClass:
... pass ... pass
... ...
>>> try:
... import audioop
... except ImportError:
... pass
...
Another place :keyword:`pass` can be used is as a place-holder for a function or Another place :keyword:`pass` can be used is as a place-holder for a function or
conditional body when you are working on new code, allowing you to keep conditional body when you are working on new code, allowing you to keep thinking
thinking at a more abstract level. However, as :keyword:`pass` is silently at a more abstract level. The :keyword:`pass` is silently ignored::
ignored, a better choice may be to raise a :exc:`NotImplementedError`
exception::
>>> def initlog(*args): >>> def initlog(*args):
... raise NotImplementedError # Open logfile if not already open ... pass # Remember to implement this!
... if not logfp:
... raise NotImplementedError # Set up dummy log back-end
... raise NotImplementedError('Call log initialization handler')
... ...
If :keyword:`pass` were used here and you later ran tests, they may fail
without indicating why. Using :exc:`NotImplementedError` causes this code
to raise an exception, telling you exactly where the incomplete code
is. Note the two calling styles of the exceptions above.
The first style, with no message but with an accompanying comment,
lets you easily leave the comment when you remove the exception,
which ideally would be a good description for
the block of code the exception is a placeholder for. However, the
third example, providing a message for the exception, will produce
a more useful traceback.
.. _tut-functions: .. _tut-functions:
Defining Functions Defining Functions
......
...@@ -140,8 +140,8 @@ Editors ...@@ -140,8 +140,8 @@ Editors
Vim and Emacs are excellent editors which support Python very well. For more Vim and Emacs are excellent editors which support Python very well. For more
information on how to code in python in these editors, look at: information on how to code in python in these editors, look at:
http://www.vim.org/scripts/script.php?script_id=790 * http://www.vim.org/scripts/script.php?script_id=790
http://sourceforge.net/projects/python-mode * http://sourceforge.net/projects/python-mode
Geany is an excellent IDE with support for a lot of languages. For more Geany is an excellent IDE with support for a lot of languages. For more
information, read: http://geany.uvena.de/ information, read: http://geany.uvena.de/
......
...@@ -143,13 +143,14 @@ class register(PyPIRCCommand): ...@@ -143,13 +143,14 @@ class register(PyPIRCCommand):
# get the user's login info # get the user's login info
choices = '1 2 3 4'.split() choices = '1 2 3 4'.split()
while choice not in choices: while choice not in choices:
print('''We need to know who you are, so please choose either: self.announce('''\
We need to know who you are, so please choose either:
1. use your existing login, 1. use your existing login,
2. register as a new user, 2. register as a new user,
3. have the server generate a new password for you (and email it to you), or 3. have the server generate a new password for you (and email it to you), or
4. quit 4. quit
Your selection [default 1]: ''', end=' ') Your selection [default 1]: ''', log.INFO)
choice = input() choice = raw_input()
if not choice: if not choice:
choice = '1' choice = '1'
elif choice not in choices: elif choice not in choices:
...@@ -169,12 +170,16 @@ Your selection [default 1]: ''', end=' ') ...@@ -169,12 +170,16 @@ Your selection [default 1]: ''', end=' ')
# send the info to the server and report the result # send the info to the server and report the result
code, result = self.post_to_server(self.build_post_data('submit'), code, result = self.post_to_server(self.build_post_data('submit'),
auth) auth)
print('Server response (%s): %s'%(code, result)) self.announce('Server response (%s): %s' % (code, result),
log.INFO)
# possibly save the login # possibly save the login
if not self.has_config and code == 200: if not self.has_config and code == 200:
print('I can store your PyPI login so future submissions will be faster.') self.announce(('I can store your PyPI login so future '
print('(the login will be stored in %s)' % self._get_rc_file()) 'submissions will be faster.'), log.INFO)
self.announce('(the login will be stored in %s)' % \
self._get_rc_file(), log.INFO)
choice = 'X' choice = 'X'
while choice.lower() not in 'yn': while choice.lower() not in 'yn':
choice = input('Save your login (y/N)?') choice = input('Save your login (y/N)?')
......
...@@ -10,8 +10,8 @@ from configparser import ConfigParser ...@@ -10,8 +10,8 @@ from configparser import ConfigParser
from distutils.cmd import Command from distutils.cmd import Command
DEFAULT_PYPIRC = """\ DEFAULT_PYPIRC = """\
[pypirc] [distutils]
servers = index-servers =
pypi pypi
[pypi] [pypi]
......
...@@ -5,6 +5,8 @@ import unittest ...@@ -5,6 +5,8 @@ import unittest
from distutils.core import PyPIRCCommand from distutils.core import PyPIRCCommand
from distutils.core import Distribution from distutils.core import Distribution
from distutils.log import set_threshold
from distutils.log import WARN
from distutils.tests import support from distutils.tests import support
...@@ -32,6 +34,17 @@ username:tarek ...@@ -32,6 +34,17 @@ username:tarek
password:secret password:secret
""" """
WANTED = """\
[distutils]
index-servers =
pypi
[pypi]
username:tarek
password:xxx
"""
class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase): class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
def setUp(self): def setUp(self):
...@@ -53,6 +66,7 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase): ...@@ -53,6 +66,7 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
finalize_options = initialize_options finalize_options = initialize_options
self._cmd = command self._cmd = command
self.old_threshold = set_threshold(WARN)
def tearDown(self): def tearDown(self):
"""Removes the patch.""" """Removes the patch."""
...@@ -62,6 +76,7 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase): ...@@ -62,6 +76,7 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
os.environ['HOME'] = self._old_home os.environ['HOME'] = self._old_home
if os.path.exists(self.rc): if os.path.exists(self.rc):
os.remove(self.rc) os.remove(self.rc)
set_threshold(self.old_threshold)
def test_server_registration(self): def test_server_registration(self):
# This test makes sure PyPIRCCommand knows how to: # This test makes sure PyPIRCCommand knows how to:
...@@ -96,6 +111,20 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase): ...@@ -96,6 +111,20 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
('server', 'server-login'), ('username', 'tarek')] ('server', 'server-login'), ('username', 'tarek')]
self.assertEquals(config, waited) self.assertEquals(config, waited)
def test_server_empty_registration(self):
cmd = self._cmd(self.dist)
rc = cmd._get_rc_file()
self.assert_(not os.path.exists(rc))
cmd._store_pypirc('tarek', 'xxx')
self.assert_(os.path.exists(rc))
content = open(rc).read()
self.assertEquals(content, WANTED)
def test_suite(): def test_suite():
return unittest.makeSuite(PyPIRCCommandTestCase) return unittest.makeSuite(PyPIRCCommandTestCase)
......
"""Tests for distutils.command.register."""
import sys
import os
import unittest
from distutils.command.register import register
from distutils.core import Distribution
from distutils.tests import support
from distutils.tests.test_config import PYPIRC, PyPIRCCommandTestCase
class RawInputs(object):
"""Fakes user inputs."""
def __init__(self, *answers):
self.answers = answers
self.index = 0
def __call__(self, prompt=''):
try:
return self.answers[self.index]
finally:
self.index += 1
WANTED_PYPIRC = """\
[distutils]
index-servers =
pypi
[pypi]
username:tarek
password:xxx
"""
class registerTestCase(PyPIRCCommandTestCase):
def test_create_pypirc(self):
# this test makes sure a .pypirc file
# is created when requested.
# let's create a fake distribution
# and a register instance
dist = Distribution()
dist.metadata.url = 'xxx'
dist.metadata.author = 'xxx'
dist.metadata.author_email = 'xxx'
dist.metadata.name = 'xxx'
dist.metadata.version = 'xxx'
cmd = register(dist)
# we shouldn't have a .pypirc file yet
self.assert_(not os.path.exists(self.rc))
# patching raw_input and getpass.getpass
# so register gets happy
#
# Here's what we are faking :
# use your existing login (choice 1.)
# Username : 'tarek'
# Password : 'xxx'
# Save your login (y/N)? : 'y'
inputs = RawInputs('1', 'tarek', 'y')
from distutils.command import register as register_module
register_module.raw_input = inputs.__call__
def _getpass(prompt):
return 'xxx'
register_module.getpass.getpass = _getpass
class FakeServer(object):
def __init__(self):
self.calls = []
def __call__(self, *args):
# we want to compare them, so let's store
# something comparable
els = args[0].items()
els.sort()
self.calls.append(tuple(els))
return 200, 'OK'
cmd.post_to_server = pypi_server = FakeServer()
# let's run the command
cmd.run()
# we should have a brand new .pypirc file
self.assert_(os.path.exists(self.rc))
# with the content similar to WANTED_PYPIRC
content = open(self.rc).read()
self.assertEquals(content, WANTED_PYPIRC)
# now let's make sure the .pypirc file generated
# really works : we shouldn't be asked anything
# if we run the command again
def _no_way(prompt=''):
raise AssertionError(prompt)
register_module.raw_input = _no_way
cmd.run()
# let's see what the server received : we should
# have 2 similar requests
self.assert_(len(pypi_server.calls), 2)
self.assert_(pypi_server.calls[0], pypi_server.calls[1])
def test_suite():
return unittest.makeSuite(registerTestCase)
if __name__ == "__main__":
unittest.main(defaultTest="test_suite")
...@@ -1157,7 +1157,7 @@ class BufferedRWPair(BufferedIOBase): ...@@ -1157,7 +1157,7 @@ class BufferedRWPair(BufferedIOBase):
@property @property
def closed(self): def closed(self):
return self.writer.closed() return self.writer.closed
class BufferedRandom(BufferedWriter, BufferedReader): class BufferedRandom(BufferedWriter, BufferedReader):
......
...@@ -40,7 +40,8 @@ class StdoutRefactoringTool(refactor.RefactoringTool): ...@@ -40,7 +40,8 @@ class StdoutRefactoringTool(refactor.RefactoringTool):
# Actually write the new file # Actually write the new file
super(StdoutRefactoringTool, self).write_file(new_text, super(StdoutRefactoringTool, self).write_file(new_text,
filename, old_text) filename, old_text)
shutil.copymode(filename, backup) if not self.nobackups:
shutil.copymode(filename, backup)
def print_output(self, lines): def print_output(self, lines):
for line in lines: for line in lines:
......
...@@ -484,8 +484,8 @@ class AbstractPickleTests(unittest.TestCase): ...@@ -484,8 +484,8 @@ class AbstractPickleTests(unittest.TestCase):
self.assertRaises(ValueError, self.loads, buf) self.assertRaises(ValueError, self.loads, buf)
def test_unicode(self): def test_unicode(self):
endcases = ['', '<\\u>', '<\\\u1234>', '<\n>', '<\\>', endcases = [u'', u'<\\u>', u'<\\\u1234>', u'<\n>',
'<\\\U00012345>'] u'<\\>', u'<\\\U00012345>']
for proto in protocols: for proto in protocols:
for u in endcases: for u in endcases:
p = self.dumps(u, proto) p = self.dumps(u, proto)
......
...@@ -553,8 +553,9 @@ class BufferedRWPairTest(unittest.TestCase): ...@@ -553,8 +553,9 @@ class BufferedRWPairTest(unittest.TestCase):
r = MockRawIO(()) r = MockRawIO(())
w = MockRawIO() w = MockRawIO()
pair = io.BufferedRWPair(r, w) pair = io.BufferedRWPair(r, w)
self.assertFalse(pair.closed)
# XXX need implementation # XXX More Tests
class BufferedRandomTest(unittest.TestCase): class BufferedRandomTest(unittest.TestCase):
......
...@@ -17,6 +17,9 @@ the format to accommodate documentation needs as they arise. ...@@ -17,6 +17,9 @@ the format to accommodate documentation needs as they arise.
Permissions History Permissions History
------------------- -------------------
- Tarek Ziadé as given SVN access on Decmeber 21 2008 by NCN,
for maintenance of distutils.
- Hirokazu Yamamoto was given SVN access on August 12 2008 by MvL, - Hirokazu Yamamoto was given SVN access on August 12 2008 by MvL,
for contributions to the Windows build. for contributions to the Windows build.
......
...@@ -508,6 +508,8 @@ test_s_code(PyObject *self) ...@@ -508,6 +508,8 @@ test_s_code(PyObject *self)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static volatile int x;
/* Test the u and u# codes for PyArg_ParseTuple. May leak memory in case /* Test the u and u# codes for PyArg_ParseTuple. May leak memory in case
of an error. of an error.
*/ */
...@@ -522,7 +524,6 @@ test_u_code(PyObject *self) ...@@ -522,7 +524,6 @@ test_u_code(PyObject *self)
/* issue4122: Undefined reference to _Py_ascii_whitespace on Windows */ /* issue4122: Undefined reference to _Py_ascii_whitespace on Windows */
/* Just use the macro and check that it compiles */ /* Just use the macro and check that it compiles */
x = Py_UNICODE_ISSPACE(25); x = Py_UNICODE_ISSPACE(25);
x = x;
tuple = PyTuple_New(1); tuple = PyTuple_New(1);
if (tuple == NULL) if (tuple == NULL)
...@@ -607,6 +608,32 @@ test_Z_code(PyObject *self) ...@@ -607,6 +608,32 @@ test_Z_code(PyObject *self)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static PyObject *
test_empty_argparse(PyObject *self)
{
/* Test that formats can begin with '|'. See issue #4720. */
PyObject *tuple, *dict = NULL;
static char *kwlist[] = {NULL};
int result;
tuple = PyTuple_New(0);
if (!tuple)
return NULL;
if ((result = PyArg_ParseTuple(tuple, "|:test_empty_argparse")) < 0)
goto done;
dict = PyDict_New();
if (!dict)
goto done;
result = PyArg_ParseTupleAndKeywords(tuple, dict, "|:test_empty_argparse", kwlist);
done:
Py_DECREF(tuple);
Py_XDECREF(dict);
if (result < 0)
return NULL;
else {
Py_RETURN_NONE;
}
}
static PyObject * static PyObject *
codec_incrementalencoder(PyObject *self, PyObject *args) codec_incrementalencoder(PyObject *self, PyObject *args)
{ {
...@@ -1012,6 +1039,7 @@ static PyMethodDef TestMethods[] = { ...@@ -1012,6 +1039,7 @@ static PyMethodDef TestMethods[] = {
{"test_long_api", (PyCFunction)test_long_api, METH_NOARGS}, {"test_long_api", (PyCFunction)test_long_api, METH_NOARGS},
{"test_long_numbits", (PyCFunction)test_long_numbits, METH_NOARGS}, {"test_long_numbits", (PyCFunction)test_long_numbits, METH_NOARGS},
{"test_k_code", (PyCFunction)test_k_code, METH_NOARGS}, {"test_k_code", (PyCFunction)test_k_code, METH_NOARGS},
{"test_empty_argparse", (PyCFunction)test_empty_argparse,METH_NOARGS},
{"test_null_strings", (PyCFunction)test_null_strings, METH_NOARGS}, {"test_null_strings", (PyCFunction)test_null_strings, METH_NOARGS},
{"test_string_from_format", (PyCFunction)test_string_from_format, METH_NOARGS}, {"test_string_from_format", (PyCFunction)test_string_from_format, METH_NOARGS},
{"test_with_docstring", (PyCFunction)test_with_docstring, METH_NOARGS, {"test_with_docstring", (PyCFunction)test_with_docstring, METH_NOARGS,
......
...@@ -1649,7 +1649,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format, ...@@ -1649,7 +1649,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
} }
} }
if (!IS_END_OF_FORMAT(*format)) { if (!IS_END_OF_FORMAT(*format) && *format != '|') {
PyErr_Format(PyExc_RuntimeError, PyErr_Format(PyExc_RuntimeError,
"more argument specifiers than keyword list entries " "more argument specifiers than keyword list entries "
"(remaining format:'%s')", format); "(remaining format:'%s')", format);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment