]> granicus.if.org Git - python/commitdiff
Issue #20262: Warnings are raised now when duplicate names are added in the
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 20 Jan 2014 19:59:33 +0000 (21:59 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 20 Jan 2014 19:59:33 +0000 (21:59 +0200)
ZIP file or too long ZIP file comment is truncated.

1  2 
Lib/test/test_zipfile.py
Lib/zipfile.py
Misc/NEWS

index 33602cff55c49678177386da55e366d01bdd760e,12a0f71f5d438e0d5303f11712c61b919f58567d..1bef5750a1520769750f26c02cee2c0225ffe1b1
@@@ -626,34 -622,6 +626,34 @@@ class PyZipFileTests(unittest.TestCase)
              self.assertCompiledIn('email/__init__.py', names)
              self.assertCompiledIn('email/mime/text.py', names)
  
-             with captured_stdout() as reportSIO:
 +    def test_write_filtered_python_package(self):
 +        import test
 +        packagedir = os.path.dirname(test.__file__)
 +
 +        with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
 +
 +            # first make sure that the test folder gives error messages
 +            # (on the badsyntax_... files)
 +            with captured_stdout() as reportSIO:
 +                zipfp.writepy(packagedir)
 +            reportStr = reportSIO.getvalue()
 +            self.assertTrue('SyntaxError' in reportStr)
 +
 +            # then check that the filter works on the whole package
 +            with captured_stdout() as reportSIO:
 +                zipfp.writepy(packagedir, filterfunc=lambda whatever: False)
 +            reportStr = reportSIO.getvalue()
 +            self.assertTrue('SyntaxError' not in reportStr)
 +
 +            # then check that the filter works on individual files
++            with captured_stdout() as reportSIO, self.assertWarns(UserWarning):
 +                zipfp.writepy(packagedir, filterfunc=lambda fn:
 +                                                     'bad' not in fn)
 +            reportStr = reportSIO.getvalue()
 +            if reportStr:
 +                print(reportStr)
 +            self.assertTrue('SyntaxError' not in reportStr)
 +
      def test_write_with_optimization(self):
          import email
          packagedir = os.path.dirname(email.__file__)
diff --cc Lib/zipfile.py
Simple merge
diff --cc Misc/NEWS
index 19e2a6e9f1f40469b5ea0dd42ec7e3da48af8780,62ffaa508a3b2bc4b40f605dec388a1614279e8d..66d65f084f7bb10fe38d1c28e08c851f31faa9e8
+++ b/Misc/NEWS
@@@ -25,9 -25,27 +25,12 @@@ Core and Builtin
  Library
  -------
  
+ - Issue #20262: Warnings are raised now when duplicate names are added in the
+   ZIP file or too long ZIP file comment is truncated.
 +- Issue #20165: The unittest module no longer considers tests marked with
 +  @expectedFailure successful if they pass.
 +
  - Issue #18574: Added missing newline in 100-Continue reply from
    http.server.BaseHTTPRequestHandler. Patch by Nikolaus Rath.