]> granicus.if.org Git - python/commitdiff
Issue #26243: Only the level argument to zlib.compress() is keyword argument
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 25 Jun 2016 19:43:05 +0000 (22:43 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 25 Jun 2016 19:43:05 +0000 (22:43 +0300)
now.  The first argument is positional-only.

Doc/library/zlib.rst
Lib/test/test_zlib.py
Misc/NEWS
Modules/clinic/zlibmodule.c.h
Modules/zlibmodule.c

index 111fb9ec9037df9459c010dbb30d1816a7d8482f..6d8a467a49f72f0e7ca0d67f4ead0b1324b8e9a6 100644 (file)
@@ -58,7 +58,7 @@ The available exception and functions in this module are:
    Raises the :exc:`error` exception if any error occurs.
 
    .. versionchanged:: 3.6
-      Keyword arguments are now supported.
+      *level* is now supported as keyword arguments.
 
 
 .. function:: compressobj(level=-1, method=DEFLATED, wbits=15, memLevel=8, strategy=Z_DEFAULT_STRATEGY[, zdict])
index 4d3611c4a6948fa5da4374ebc2635ca3f3468d60..bb9292bac4501c85b0eb401aa63c5b047e91873d 100644 (file)
@@ -163,8 +163,10 @@ class CompressTestCase(BaseCompressTestCase, unittest.TestCase):
         self.assertEqual(zlib.decompress(x), HAMLET_SCENE)
 
     def test_keywords(self):
-        x = zlib.compress(data=HAMLET_SCENE, level=3)
+        x = zlib.compress(HAMLET_SCENE, level=3)
         self.assertEqual(zlib.decompress(x), HAMLET_SCENE)
+        with self.assertRaises(TypeError):
+            zlib.compress(data=HAMLET_SCENE, level=3)
 
     def test_speech128(self):
         # compress more data
index 53537126631977b5fd5a811a5c1f7dfd01679168..58b774e39b7fb2c51095dcd50e09e885952707e0 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.6.0 alpha 3
 Library
 -------
 
+- Issue #26243: Only the level argument to zlib.compress() is keyword argument
+  now.  The first argument is positional-only.
+
 - Issue #27038: Expose the DirEntry type as os.DirEntry. Code patch by
   Jelle Zijlstra.
 
index c657bcb6449c5e4b3aa872007ff94a1e9ba07ef5..dcaeef81e6c8edbd1ddea34b90c32449a37e9225 100644 (file)
@@ -3,7 +3,7 @@ preserve
 [clinic start generated code]*/
 
 PyDoc_STRVAR(zlib_compress__doc__,
-"compress($module, /, data, level=Z_DEFAULT_COMPRESSION)\n"
+"compress($module, data, /, level=Z_DEFAULT_COMPRESSION)\n"
 "--\n"
 "\n"
 "Returns a bytes object containing compressed data.\n"
@@ -23,7 +23,7 @@ static PyObject *
 zlib_compress(PyModuleDef *module, PyObject *args, PyObject *kwargs)
 {
     PyObject *return_value = NULL;
-    static char *_keywords[] = {"data", "level", NULL};
+    static char *_keywords[] = {"", "level", NULL};
     Py_buffer data = {NULL, NULL};
     int level = Z_DEFAULT_COMPRESSION;
 
@@ -460,4 +460,4 @@ exit:
 #ifndef ZLIB_COMPRESS_COPY_METHODDEF
     #define ZLIB_COMPRESS_COPY_METHODDEF
 #endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */
-/*[clinic end generated code: output=9bd8a093baa653b2 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ba904dec30cc1a1a input=a9049054013a1b77]*/
index ad6f28d7bc6bd639be0e6f3197bf138953dcaa45..3a459a58f45f5ff92c3f0df59044e9176b6c47c1 100644 (file)
@@ -143,6 +143,7 @@ zlib.compress
 
     data: Py_buffer
         Binary data to be compressed.
+    /
     level: int(c_default="Z_DEFAULT_COMPRESSION") = Z_DEFAULT_COMPRESSION
         Compression level, in 0-9 or -1.
 
@@ -151,7 +152,7 @@ Returns a bytes object containing compressed data.
 
 static PyObject *
 zlib_compress_impl(PyModuleDef *module, Py_buffer *data, int level)
-/*[clinic end generated code: output=1b97589132b203b4 input=abed30f4fa14e213]*/
+/*[clinic end generated code: output=1b97589132b203b4 input=638d54b6315dbed3]*/
 {
     PyObject *ReturnVal = NULL;
     Byte *input, *output = NULL;