[Checkins] SVN: zc.buildout/branches/python-3/ checkpoint

Jim Fulton jim at zope.com
Wed Mar 16 17:01:00 EDT 2011


Log message for revision 120988:
  checkpoint

Changed:
  U   zc.buildout/branches/python-3/src/zc/buildout/buildout.py
  U   zc.buildout/branches/python-3/src/zc/buildout/download.py
  U   zc.buildout/branches/python-3/src/zc/buildout/download.txt
  U   zc.buildout/branches/python-3/src/zc/buildout/downloadcache.txt
  U   zc.buildout/branches/python-3/src/zc/buildout/easy_install.txt
  U   zc.buildout/branches/python-3/src/zc/buildout/testing.py
  U   zc.buildout/branches/python-3/src/zc/buildout/tests.py
  U   zc.buildout/branches/python-3/src/zc/buildout/update.txt
  U   zc.buildout/branches/python-3/src/zc/buildout/upgrading_distribute.txt
  U   zc.buildout/branches/python-3/zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt

-=-
Modified: zc.buildout/branches/python-3/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/branches/python-3/src/zc/buildout/buildout.py	2011-03-16 16:43:39 UTC (rev 120987)
+++ zc.buildout/branches/python-3/src/zc/buildout/buildout.py	2011-03-16 21:00:59 UTC (rev 120988)
@@ -70,7 +70,7 @@
     """
 
     def __str__(self):
-        return "The referenced section, %r, was not defined." % self[0]
+        return "The referenced section, %r, was not defined." % self.args[0]
 
 
 def _annotate_section(section, note):

Modified: zc.buildout/branches/python-3/src/zc/buildout/download.py
===================================================================
--- zc.buildout/branches/python-3/src/zc/buildout/download.py	2011-03-16 16:43:39 UTC (rev 120987)
+++ zc.buildout/branches/python-3/src/zc/buildout/download.py	2011-03-16 21:00:59 UTC (rev 120988)
@@ -23,6 +23,7 @@
 import os.path
 import re
 import shutil
+import sys
 import tempfile
 import urllib.request, urllib.parse, urllib.error
 import urllib.parse
@@ -175,18 +176,15 @@
         urllib.request._urlopener = url_opener
         handle, tmp_path = tempfile.mkstemp(prefix='buildout-')
         try:
-            try:
-                tmp_path, headers = urllib.request.urlretrieve(url, tmp_path)
-                if not check_md5sum(tmp_path, md5sum):
-                    raise ChecksumError(
-                        'MD5 checksum mismatch downloading %r' % url)
-            finally:
-                os.close(handle)
+            tmp_path, headers = urllib.request.urlretrieve(url, tmp_path)
+            if not check_md5sum(tmp_path, md5sum):
+                raise ChecksumError(
+                    'MD5 checksum mismatch downloading %r' % url)
         except IOError:
             e = sys.exc_info()[1]
             os.remove(tmp_path)
             raise zc.buildout.UserError("Error downloading extends for URL "
-                              "%s: %r" % (url, e[1:3]))
+                              "%s:\n%s" % (url, e))
         except Exception:
             os.remove(tmp_path)
             raise
@@ -204,7 +202,7 @@
 
         """
         if self.hash_name:
-            return md5(url).hexdigest()
+            return md5(url.encode('utf8')).hexdigest()
         else:
             if re.match(r"^[A-Za-z]:\\", url):
                 url = 'file:' + url

Modified: zc.buildout/branches/python-3/src/zc/buildout/download.txt
===================================================================
--- zc.buildout/branches/python-3/src/zc/buildout/download.txt	2011-03-16 16:43:39 UTC (rev 120987)
+++ zc.buildout/branches/python-3/src/zc/buildout/download.txt	2011-03-16 21:00:59 UTC (rev 120988)
@@ -75,27 +75,25 @@
 ... except ImportError: from md5 import new as md5
 
 >>> path, is_temp = download(server_url+'foo.txt',
-...                          md5('This is a foo text.').hexdigest())
+...                   md5('This is a foo text.'.encode()).hexdigest())
 >>> is_temp
 True
 >>> remove(path)
 
->>> download(server_url+'foo.txt',
-...          md5('The wrong text.').hexdigest())
-Traceback (most recent call last):
-ChecksumError: MD5 checksum mismatch downloading 'http://localhost/foo.txt'
+>>> print(raises('ChecksumError', download, server_url+'foo.txt',
+...                 md5('The wrong text.'.encode()).hexdigest()))
+MD5 checksum mismatch downloading 'http://localhost/foo.txt'
 
 The error message in the event of an MD5 checksum mismatch for a local file
 reads somewhat differently:
 
 >>> download(join(server_data, 'foo.txt'),
-...               md5('This is a foo text.').hexdigest())
+...               md5('This is a foo text.'.encode()).hexdigest())
 ('/sample_files/foo.txt', False)
 
->>> download(join(server_data, 'foo.txt'),
-...          md5('The wrong text.').hexdigest())
-Traceback (most recent call last):
-ChecksumError: MD5 checksum mismatch for local resource at '/sample_files/foo.txt'.
+>>> print(raises('ChecksumError', download, join(server_data, 'foo.txt'),
+...          md5('The wrong text.'.encode()).hexdigest()))
+MD5 checksum mismatch for local resource at '/sample_files/foo.txt'.
 
 Finally, we can download the file to a specified place in the file system:
 
@@ -112,9 +110,8 @@
 Trying to download a file in offline mode will result in an error:
 
 >>> download = Download(cache=None, offline=True)
->>> download(server_url+'foo.txt')
-Traceback (most recent call last):
-UserError: Couldn't download 'http://localhost/foo.txt' in offline mode.
+>>> print(raises('UserError', download, server_url+'foo.txt'))
+Couldn't download 'http://localhost/foo.txt' in offline mode.
 
 As an exception to this rule, file system paths and URLs in the ``file``
 scheme will still work:
@@ -168,10 +165,11 @@
 If we specify an MD5 checksum for a file that is already in the cache, the
 cached copy's checksum will be verified:
 
->>> download(server_url+'foo.txt', md5('The wrong text.').hexdigest())
-Traceback (most recent call last):
-ChecksumError: MD5 checksum mismatch for cached download
-               from 'http://localhost/foo.txt' at '/download-cache/foo.txt'
+>>> print(raises('ChecksumError', download, server_url+'foo.txt',
+...       md5('The wrong text.'.encode()).hexdigest()))
+... # doctest: +NORMALIZE_WHITESPACE
+MD5 checksum mismatch for cached download
+from 'http://localhost/foo.txt' at '/download-cache/foo.txt'
 
 Trying to access another file at a different URL which has the same base name
 will result in the cached copy being used:
@@ -247,26 +245,28 @@
 
 However, resources with checksum mismatches will not be copied to the cache:
 
->>> download(server_url+'foo.txt', md5('The wrong text.').hexdigest())
-Traceback (most recent call last):
-ChecksumError: MD5 checksum mismatch downloading 'http://localhost/foo.txt'
+>>> print(raises('ChecksumError', download, server_url+'foo.txt',
+... md5('The wrong text.'.encode()).hexdigest()))
+MD5 checksum mismatch downloading 'http://localhost/foo.txt'
+
 >>> ls(cache)
 
 >>> remove(path)
 
 If the file is completely missing it should notify the user of the error:
 
->>> download(server_url+'bar.txt')
-Traceback (most recent call last):
-UserError: Error downloading extends for URL http://localhost/bar.txt: (404, 'Not Found')
+>>> print(raises('UserError', download, server_url+'bar.txt'))
+Error downloading extends for URL http://localhost/bar.txt:
+HTTP Error 404: Not Found
+
 >>> ls(cache)
 
 Finally, let's see what happens if the download cache to be used doesn't exist
 as a directory in the file system yet:
 
->>> Download(cache=join(cache, 'non-existent'))(server_url+'foo.txt')
-Traceback (most recent call last):
-UserError: The directory:
+>>> print(raises('UserError',
+...    Download(cache=join(cache, 'non-existent')), server_url+'foo.txt'))
+The directory:
 '/download-cache/non-existent'
 to be used as a download cache doesn't exist.
 
@@ -344,7 +344,8 @@
 the test is run, so we don't actually know the full URL of the file. Let's
 check that the checksum actually belongs to the particular URL used:
 
->>> path.lower() == join(cache, md5(server_url+'foo.txt').hexdigest()).lower()
+>>> path.lower() == join(
+...    cache, md5((server_url+'foo.txt').encode('utf8')).hexdigest()).lower()
 True
 
 The cached copy is used when downloading the file again:
@@ -366,7 +367,9 @@
 /download-cache/537b6d73267f8f4447586989af8c470e
 >>> path == path2
 False
->>> path2.lower() == join(cache, md5(server_url+'other/foo.txt').hexdigest()).lower()
+>>> path2.lower() == join(
+...   cache,
+...   md5((server_url+'other/foo.txt').encode('utf8')).hexdigest()).lower()
 True
 >>> cat(path)
 This is a foo text.
@@ -446,9 +449,10 @@
 copy will neither be used nor overwritten:
 
 >>> write(server_data, 'foo.txt', 'This is a foo text.')
->>> download(server_url+'foo.txt', md5('The wrong text.').hexdigest())
-Traceback (most recent call last):
-ChecksumError: MD5 checksum mismatch downloading 'http://localhost/foo.txt'
+>>> print(raises('ChecksumError', download, server_url+'foo.txt',
+...          md5('The wrong text.'.encode()).hexdigest()))
+MD5 checksum mismatch downloading 'http://localhost/foo.txt'
+
 >>> cat(cache, 'foo.txt')
 The wrong text.
 
@@ -537,9 +541,9 @@
 requires text files to be treated as binary to avoid implicit line-ending
 conversions:
 
->>> text = 'First line of text.\r\nSecond line.\r\n'
+>>> text = 'First line of text.\r\nSecond line.\r\n'.encode()
 >>> f = open(join(server_data, 'foo.txt'), 'wb')
->>> f.write(text)
+>>> _ = f.write(text)
 >>> f.close()
 >>> path, is_temp = Download()(server_url+'foo.txt', md5(text).hexdigest())
 >>> remove(path)

Modified: zc.buildout/branches/python-3/src/zc/buildout/downloadcache.txt
===================================================================
--- zc.buildout/branches/python-3/src/zc/buildout/downloadcache.txt	2011-03-16 16:43:39 UTC (rev 120987)
+++ zc.buildout/branches/python-3/src/zc/buildout/downloadcache.txt	2011-03-16 21:00:59 UTC (rev 120988)
@@ -31,7 +31,7 @@
 We specified a link server that has some distributions available for
 download:
 
-    >>> print_(get(link_server).decode())
+    >>> print_(get(link_server))
     <html><body>
     <a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
     <a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>

Modified: zc.buildout/branches/python-3/src/zc/buildout/easy_install.txt
===================================================================
--- zc.buildout/branches/python-3/src/zc/buildout/easy_install.txt	2011-03-16 16:43:39 UTC (rev 120987)
+++ zc.buildout/branches/python-3/src/zc/buildout/easy_install.txt	2011-03-16 21:00:59 UTC (rev 120988)
@@ -107,7 +107,7 @@
 
 We have a link server that has a number of eggs:
 
-    >>> print_(get(link_server).decode())
+    >>> print_(get(link_server))
     <html><body>
     <a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
     <a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
@@ -313,13 +313,11 @@
     >>> import logging
     >>> logging.getLogger('zc.buildout.easy_install').propagate = False
 
-    >>> ws = zc.buildout.easy_install.install(
+    >>> _ = raises('IncompatibleVersionError',
+    ...     zc.buildout.easy_install.install,
     ...     ['demo >0.2'], dest, links=[link_server],
     ...     index=link_server+'index/',
     ...     versions = dict(demo='0.2', demoneeded='1.0'))
-    Traceback (most recent call last):
-    ...
-    IncompatibleVersionError: Bad version 0.2
 
     >>> print(handler)
     zc.buildout.easy_install DEBUG
@@ -362,12 +360,10 @@
 
 (The old setting is returned.)
 
-    >>> ws = zc.buildout.easy_install.install(
+    >>> print(raises('UserError', zc.buildout.easy_install.install,
     ...     ['demo'], dest, links=[link_server], index=link_server+'index/',
-    ...     )
-    Traceback (most recent call last):
-    ...
-    UserError: Picked: demo = 0.3
+    ...     ))
+    Picked: demo = 0.3
 
     >>> zc.buildout.easy_install.allow_picked_versions(True)
     False
@@ -455,12 +451,11 @@
     >>> zc.buildout.easy_install.clear_index_cache()
     >>> rmdir(example_dest)
     >>> example_dest = tmpdir('site-packages-example-install')
-    >>> workingset = zc.buildout.easy_install.install(
+    >>> print(raises('MissingDistribution', zc.buildout.easy_install.install,
     ...     ['demoneeded'], example_dest, links=[], executable=py_path,
-    ...     index=None)
-    Traceback (most recent call last):
-        ...
-    MissingDistribution: Couldn't find a distribution for 'demoneeded'.
+    ...     index=None))
+    Couldn't find a distribution for 'demoneeded'.
+
     >>> zc.buildout.easy_install.clear_index_cache()
 
 Now we'll reset the default.
@@ -775,7 +770,7 @@
             sys.argv[:] = _args
             __file__ = _args[0]
             del _options, _args
-            execfile(__file__)
+            exec(compile(open(__file__).read(), __file__, "exec"))
     <BLANKLINE>
     if _interactive:
         del _interactive
@@ -786,7 +781,7 @@
     >>> write('ascript', '''
     ... "demo doc"
     ... print(sys.argv)
-    ... print(__name__, __file__, __doc__)
+    ... print((__name__, __file__, __doc__))
     ... ''')
     >>> run(join(bin, 'py')+' ascript a b c')
     ['ascript', 'a', 'b', 'c']
@@ -795,8 +790,8 @@
 For Python 2.5 and higher, you can also use the -m option to run a
 module:
 
-    >>> run(join(bin, 'py')+' -m pdb')
-    usage: pdb.py scriptfile [arg] ...
+    >>> run(join(bin, 'py')+' -m pdb') # doctest: +ELLIPSIS
+    usage: pdb.py ...
 
     >>> run(join(bin, 'py')+' -m pdb what')
     Error: what does not exist
@@ -979,7 +974,7 @@
             if _opt == '-i':
                 _interactive = True
             elif _opt == '-c':
-                exec(_va)
+                exec(_val)
             elif _opt == '-m':
                 sys.argv[1:] = _args
                 _args = []
@@ -990,7 +985,7 @@
             sys.argv[:] = _args
             __file__ = _args[0]
             del _options, _args
-            execfile(__file__)
+            exec(compile(open(__file__).read(), __file__, "exec"))
     <BLANKLINE>
     if _interactive:
         del _interactive
@@ -1110,10 +1105,12 @@
 
 Here are some examples of the interpreter in use.
 
-    >>> print_(call_py(interpreter_path, "print(16+26)").decode())
+    >>> print_(call_py(interpreter_path, "print(16+26)"))
     42
 
-    >>> res = call_py(interpreter_path, "import sys; print(sys.path)")
+    >>> res = call_py(
+    ...    interpreter_path,
+    ...    "import sys; print([s for s in sys.path])")
     >>> print(res) # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
     ['',
      '/interpreter/parts/interpreter',
@@ -1144,7 +1141,8 @@
     >>> cat(sitecustomize_path)
     import os
     os.environ['FOO'] = 'bar baz bing shazam'
-    >>> print(call_py(interpreter_path, "import os; print(os.environ['FOO'])"))
+    >>> print(call_py(interpreter_path,
+    ...      "import os; print(os.environ['FOO'])"))
     bar baz bing shazam
     <BLANKLINE>
 
@@ -1195,7 +1193,7 @@
 The paths resolve in practice as you would expect.
 
     >>> print(call_py(interpreter_path,
-    ...               "import sys, pprint; pprint.pprint(sys.path)"))
+    ...   "import sys, pprint; pprint.pprint([s for s in sys.path])"))
     ... # doctest: +ELLIPSIS
     ['',
      '/interpreter/parts/interpreter',
@@ -1679,7 +1677,7 @@
 Let's update our link server with a new version of extdemo:
 
     >>> update_extdemo()
-    >>> print_(get(link_server).decode())
+    >>> print_(get(link_server))
     <html><body>
     <a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
     <a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>

Modified: zc.buildout/branches/python-3/src/zc/buildout/testing.py
===================================================================
--- zc.buildout/branches/python-3/src/zc/buildout/testing.py	2011-03-16 16:43:39 UTC (rev 120987)
+++ zc.buildout/branches/python-3/src/zc/buildout/testing.py	2011-03-16 21:00:59 UTC (rev 120988)
@@ -57,6 +57,8 @@
     names = os.listdir(dir)
     names.sort()
     for name in names:
+        if name == '__pycache__':
+            continue
         if os.path.isdir(os.path.join(dir, name)):
             print('d ', end=' ')
         elif os.path.islink(os.path.join(dir, name)):
@@ -107,13 +109,13 @@
     result = o.read() + e.read()
     o.close()
     e.close()
-    return result
+    return result.decode()
 
 def print_(*args):
     sys.stdout.write(' '.join(map(str, args)))
 
 def run(command, input=''):
-    sys.stdout.write(system(command, input).decode())
+    sys.stdout.write(system(command, input))
 
 def call_py(interpreter, cmd, flags=None):
     if sys.platform == 'win32':
@@ -126,7 +128,7 @@
             ' '.join(arg for arg in (interpreter, flags, '-c', cmd) if arg))
 
 def get(url):
-    return urllib.request.urlopen(url).read()
+    return urllib.request.urlopen(url).read().decode()
 
 def _runsetup(setup, executable, *args):
     if os.path.isdir(setup):
@@ -166,7 +168,7 @@
 
 def find_python(version):
     env_friendly_version = ''.join(version.split('.'))
-    
+
     e = os.environ.get('PYTHON%s' % env_friendly_version)
     if e is not None:
         return e
@@ -234,6 +236,26 @@
         time.sleep(0.01)
     raise ValueError('Timed out waiting for: '+label)
 
+def raises(exc_type, callable, *args, **kw):
+    if isinstance(exc_type, str):
+        E = Exception
+    else:
+        E = exc_type
+
+    try:
+        callable(*args, **kw)
+    except E:
+        v = sys.exc_info()[1]
+        if E is exc_type:
+            return v
+
+        if exc_type == v.__class__.__name__:
+            return v
+        else:
+            raise
+
+    raise AssertionError("Expected %r" % exc_type)
+
 def get_installer_values():
     """Get the current values for the easy_install module.
 
@@ -406,6 +428,7 @@
         write = write,
         system = system,
         run = run,
+        raises = raises,
         print_ = print_,
         call_py = call_py,
         get = get,
@@ -468,9 +491,7 @@
             os.path.exists(path)
             ):
             self.send_response(404, 'Not Found')
-            #self.send_response(200)
-            out = '<html><body>Not Found</body></html>'
-            #out = '\n'.join(self.tree, self.path, path)
+            out = '<html><body>Not Found</body></html>'.encode()
             self.send_header('Content-Length', str(len(out)))
             self.send_header('Content-Type', 'text/html')
             self.end_headers()

Modified: zc.buildout/branches/python-3/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/branches/python-3/src/zc/buildout/tests.py	2011-03-16 16:43:39 UTC (rev 120987)
+++ zc.buildout/branches/python-3/src/zc/buildout/tests.py	2011-03-16 21:00:59 UTC (rev 120988)
@@ -108,17 +108,13 @@
     >>> os.chdir(sample_buildout)
     >>> import zc.buildout.buildout
     >>> buildout = zc.buildout.buildout.Buildout('buildout.cfg', [])
-    >>> buildout['eek']
-    Traceback (most recent call last):
-    ...
-    MissingSection: The referenced section, 'eek', was not defined.
+    >>> print(raises('MissingSection', buildout.__getitem__, 'eek'))
+    The referenced section, 'eek', was not defined.
 
 Asking for an option that doesn't exist, a MissingOption error is raised:
 
-    >>> buildout['buildout']['eek']
-    Traceback (most recent call last):
-    ...
-    MissingOption: Missing option: buildout:eek
+    >>> print(raises('MissingOption', buildout['buildout'].__getitem__, 'eek'))
+    Missing option: buildout:eek
 
 It is an error to create a variable-reference cycle:
 
@@ -128,7 +124,10 @@
     ... parts =
     ... x = ${buildout:y}
     ... y = ${buildout:z}
-    ... z = ${runprint system(os.path.join(sample_buildout, 'bin', 'buildout'))
+    ... z = ${buildout:x}
+    ... ''')
+
+    >>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
     ... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
     While:
       Initializing.
@@ -874,7 +873,7 @@
     ...     ])]
     ['foox', 'setuptools']
 
-    >>> print_(handler.decode())
+    >>> print_(handler)
 
 We get the same behavior if the it is a depedency that uses a
 namespace package.
@@ -907,7 +906,7 @@
     ...     ])]
     ['bar', 'foox', 'setuptools']
 
-    >>> print_(handler.decode())
+    >>> print_(handler)
     zc.buildout.easy_install WARNING
       Develop distribution: foox 0.0.0
     uses namespace packages but the distribution does not require setuptools.
@@ -1851,7 +1850,7 @@
     >>> print_(call_py(
     ...     py_path,
     ...     "import tellmy.version; print(tellmy.version.__version__)"
-    ...     ).decode())
+    ...     ))
     1.1
 
 Now here's a setup that would expose the bug, using the
@@ -1889,9 +1888,8 @@
     >>> print_(call_py(
     ...     py_path,
     ...     "import tellmy.version; print(tellmy.version.__version__)"
-    ...     ).decode())
+    ...     ))
     1.1
-    <BLANKLINE>
 
 Now we will create a buildout that creates a script and a faux-Python script.
 We want to see that both can successfully import the specified versions of
@@ -2014,9 +2012,9 @@
     >>> print_(call_py(
     ...     py_path,
     ...     "import tellmy.version; print(tellmy.version.__version__)"
-    ...     ).decode())
+    ...     ))
     1.0
-    <BLANKLINE>
+
     >>> write('buildout.cfg',
     ... '''
     ... [buildout]
@@ -2226,26 +2224,22 @@
     >>> zc.buildout.easy_install.clear_index_cache()
     >>> rmdir(example_dest)
     >>> example_dest = tmpdir('site-packages-example-install')
-    >>> workingset = zc.buildout.easy_install.install(
+    >>> print(raises('MissingDistribution', zc.buildout.easy_install.install,
     ...     ['demoneeded'], example_dest, links=[], executable=py_path,
     ...     index=None,
-    ...     allowed_eggs_from_site_packages=['demo'])
-    Traceback (most recent call last):
-        ...
-    MissingDistribution: Couldn't find a distribution for 'demoneeded'.
+    ...     allowed_eggs_from_site_packages=['demo']))
+    Couldn't find a distribution for 'demoneeded'.
 
 Here's the same, but with an empty list.
 
     >>> zc.buildout.easy_install.clear_index_cache()
     >>> rmdir(example_dest)
     >>> example_dest = tmpdir('site-packages-example-install')
-    >>> workingset = zc.buildout.easy_install.install(
+    >>> print(raises('MissingDistribution', zc.buildout.easy_install.install,
     ...     ['demoneeded'], example_dest, links=[], executable=py_path,
     ...     index=None,
-    ...     allowed_eggs_from_site_packages=[])
-    Traceback (most recent call last):
-        ...
-    MissingDistribution: Couldn't find a distribution for 'demoneeded'.
+    ...     allowed_eggs_from_site_packages=[]))
+    Couldn't find a distribution for 'demoneeded'.
 
 Of course, this doesn't stop us from getting a package from elsewhere.  Here,
 we add a link server.
@@ -2269,13 +2263,11 @@
     >>> zc.buildout.easy_install.clear_index_cache()
     >>> rmdir(example_dest)
     >>> example_dest = tmpdir('site-packages-example-install')
-    >>> workingset = zc.buildout.easy_install.install(
+    >>> print(raises('MissingDistribution', zc.buildout.easy_install.install,
     ...     ['demoneeded'], example_dest, links=[], executable=py_path,
     ...     index=None, include_site_packages=False,
-    ...     allowed_eggs_from_site_packages=['demoneeded'])
-    Traceback (most recent call last):
-        ...
-    MissingDistribution: Couldn't find a distribution for 'demoneeded'.
+    ...     allowed_eggs_from_site_packages=['demoneeded']))
+    Couldn't find a distribution for 'demoneeded'.
 
     """
 
@@ -2416,8 +2408,7 @@
 
 This also works for the generated interpreter, with identical results.
 
-    >>> print_(call_py(join(interpreter_bin_dir, 'py'), test
-    ... ).decode())
+    >>> print_(call_py(join(interpreter_bin_dir, 'py'), test))
     ... # doctest: +ELLIPSIS
     ['',
      '/interpreter/parts/interpreter',
@@ -3699,7 +3690,7 @@
         tmp, 'eggrecipedemo.py',
         'import eggrecipedemoneeded\n'
         'x=%s\n'
-        'def main(): print(x), eggrecipedemoneeded.y\n'
+        'def main(): print(x, eggrecipedemoneeded.y)\n'
         % minor_version)
     write(
         tmp, 'setup.py',
@@ -3762,7 +3753,7 @@
     finally:
         shutil.rmtree(tmp)
 
-extdemo_c = """
+extdemo_c2 = """
 #include <Python.h>
 #include <extdemo.h>
 
@@ -3781,6 +3772,37 @@
 }
 """
 
+extdemo_c3 = """
+#include <Python.h>
+#include <extdemo.h>
+
+static PyMethodDef methods[] = {{NULL}};
+
+#define MOD_DEF(ob, name, doc, methods) \
+	  static struct PyModuleDef moduledef = { \
+	    PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \
+	  ob = PyModule_Create(&moduledef);
+
+#define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
+
+MOD_INIT(extdemo)
+{
+    PyObject *m;
+
+    MOD_DEF(m, "extdemo", "", methods);
+
+#ifdef TWO
+    PyModule_AddObject(m, "val", PyLong_FromLong(2));
+#else
+    PyModule_AddObject(m, "val", PyLong_FromLong(EXTDEMO));
+#endif
+
+    return m;
+}
+"""
+
+extdemo_c = sys.version_info[0] < 3 and extdemo_c2 or extdemo_c3
+
 extdemo_setup_py = """
 import os
 from distutils.core import setup, Extension

Modified: zc.buildout/branches/python-3/src/zc/buildout/update.txt
===================================================================
--- zc.buildout/branches/python-3/src/zc/buildout/update.txt	2011-03-16 16:43:39 UTC (rev 120987)
+++ zc.buildout/branches/python-3/src/zc/buildout/update.txt	2011-03-16 21:00:59 UTC (rev 120988)
@@ -268,8 +268,7 @@
     >>> version = sys.version_info[0:2]
     >>> egg = new_releases + '/zc.buildout-99.99-py%s.%s.egg ' % version
     >>> copy_egg = new_releases + '/zc.buildout-1000-py%s.%s.egg ' % version
-    >>> system('cp ' + egg  + copy_egg)
-    ''
+    >>> run('cp ' + egg  + copy_egg)
 
 Create a broken egg
 

Modified: zc.buildout/branches/python-3/src/zc/buildout/upgrading_distribute.txt
===================================================================
--- zc.buildout/branches/python-3/src/zc/buildout/upgrading_distribute.txt	2011-03-16 16:43:39 UTC (rev 120987)
+++ zc.buildout/branches/python-3/src/zc/buildout/upgrading_distribute.txt	2011-03-16 21:00:59 UTC (rev 120988)
@@ -50,7 +50,5 @@
     ...     executable=sys.executable,
     ...     always_unzip=True)
     >>> installer._get_dist = mock_get_dist
-    >>> installer._call_easy_install('setuptools', None, dest, dist)
-    Traceback (most recent call last):
-    ...
-    UserError: Couldn't install: nonexisting.tgz
+    >>> print(raises('UserError', installer._call_easy_install, 'setuptools', None, dest, dist))
+    Couldn't install: nonexisting.tgz

Modified: zc.buildout/branches/python-3/zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt
===================================================================
--- zc.buildout/branches/python-3/zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt	2011-03-16 16:43:39 UTC (rev 120987)
+++ zc.buildout/branches/python-3/zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt	2011-03-16 21:00:59 UTC (rev 120988)
@@ -131,7 +131,7 @@
             sys.argv[:] = _args
             __file__ = _args[0]
             del _options, _args
-            execfile(__file__)
+            exec(compile(open(__file__).read(), __file__, "exec"))
     <BLANKLINE>
     if _interactive:
         del _interactive



More information about the checkins mailing list