[Python-Dev] Backward-incompatible change to random.randrange in 2.7.6

Barry Warsaw barry at python.org
Tue Dec 17 19:55:46 CET 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Dec 17, 2013, at 01:18 PM, Tres Seaver wrote:

>http://hg.python.org/cpython/rev/b1e94e332ec8
>
>Do we really want to change an undocumented-but-effectively-public API in
>a late-in-the-release-cycle third dot release?  It caused, ZODB's tests
>to fail, for instance.
>
>While the docstring said, "Don't use the 'int', 'default', and 'maxwidth'
>arguments", their names were not intrinsically private.  In particular,
>passing in the 'int' argument was a strategy for generating compatible
>long values when straddling Python 2.x / Python 3.x.

Being quite sensitive to complaints about API breaks in patch releases, it
does seem like a bad idea to change these in a backward incompatible way.

It's true the docstring warns against it, and that the module does not
document those arguments, but they're still there and changing them breaks
existing code.  That should be enough to revert and rewrite the change.

I don't think the API *has* to change in a backward incompatible way either.
The methods could be given **kws with a bit of hackery to figure out whether
the old API was being used (keys: int, default, maxwidth) or the new API was
being used (keys: _int and _maxwidth).  Yeah it's ugly, but we serve our users
better by doing it that way.

Cheers,
- -Barry
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (GNU/Linux)

iQIcBAEBCAAGBQJSsJ4yAAoJEBJutWOnSwa/7EsP/1P3VaaeWdLnWkQKa06e4TpY
oXHG3YUMAQ4AjrBFTc5KL1GQtSkg1m6pQKZf937XYhi9d4xfwbaSBqCBWYPkNdrx
DR2Ix0Y/HwVPQvlqgfLWPS6TaZIrA2ssCVoOgWL2kmX+5KugIUy3O521OOre14jo
jCQZTOL2sloT+/TlX1PSImYRrJnK9yklW0CW13OVnj5BsvjzQPtsL0z1ueSrebqu
awTRCI7O8gpBcw7vcXnB6ZAfuA4urLQ+AnBXF1p5Rsxs3tGW9HS7L+QYWBM7sktV
Hmb5ZIdH+4+gkCws2LSowt+06M3WEyLkGhwOH1gNU3WTgywcJ4L9sh7WwLZN5eCe
Wz37LQ1fVFjpJhX2zOtI6djqL5r+6xpBxtuig0ezNJbAc1mhhvkPkTjMyvXqQzwX
HJQ7OMthiHqVnNJRZQZs4tSeCPgRDkDSNe/RWSyh6gYr6Gn6wwDcbW20RrbbbU4y
eKyY2VHQ0MKD283HVb3nfgelN96OgqWbpG/uk6mRPwPU1oIUyDDuhyyzNabggTSV
n97lPsHvOJyPehKdu+QKxpFULlX6KEmTCLJsUIWsjMCVIUnHjobkpOqW20KveLr+
cPcSHDGIPKv4qnFJuihYWBz9NPbUT2xebaP02bL7Wu5UVDFxQ3t0P/wuhLoNjRzU
vkUJ8m7CnRDFGuGPy6NQ
=lw3q
-----END PGP SIGNATURE-----


More information about the Python-Dev mailing list