New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'x' mode to lzma.open() #63400
Comments
I love the 'x' mode open in recent versions of Python. I just discovered that lzma.open doesn't support it. It seems there's an elif that explicitly checks the modes allowed. I added "x" and "xb" to the choices and now it works as I would like. |
Looks good. Being strict this would be 3.4 material, but patch is trivial and looks like a oversight. We should check other compression modules like gzip, bzip2, etc. |
Why? The patch is trivial, I don't how it could cause a regression. If you don't want regression, add a unit test to test_lzma.py. |
Here is the unit test for Tim Heaney's work. There is a test that explicitly tests that we get error when opening in 'x' mode. Also, this test is only for lzma. I think we should create separate tickets for other compression methods. |
Okay, I just made similar issues for gzip (bpo-19222) and bz2 On Thu, Oct 10, 2013 at 6:31 AM, Vajrasky Kok <report@bugs.python.org>wrote:
|
Is there any reason why the order of characters matters here? |
Also tarfile.open() could support "x" mode. |
The bug versus feature issue does not depend on whether the patch could cause a regression. (I think feature patches might actually be less likely than bug fixes to cause regressions, but it does not matter.) Nor is oversight, not adding a feature when it could have been added, a bug. The point is that adding a new feature in a bug-fix release makes it a feature release, and this is a new feature. Code that uses the new feature will not run on previous releases of the same version. The doc for lzma.open says "The mode argument can be any of "r", "rb", "w", "wb", "a" or "ab" for binary mode, or "rt", "wt", or "at" for text mode. The default is "rb"." (I assume that) the code does just what the doc says. (If it did not, *that* would be a bug). Arfrever's point about the order of characters makes me wonder why mode strings (as opposed to characters in the strings) are being checked. The following tests that exactly one of w, a, x appear in mode. |
Added doc. Revamped the test. The patch did not cater to the order of modes ("wb" is equal to "bw"?). I think that deserves a separate ticket. |
Stopped the leaking after running the test by adding self.addCleanup. |
New changeset b7948aaca1dd by Nadeem Vawda in branch 'default': |
Fix committed. Thanks for the patches! As Jesús and Terry have said, this won't be backported to 3.3/2.7, since [oylenshpeegul] Mostly because they were written at different times, by different people, |
[terry.reedy] There are two separate questions here - how rigid we are about modes I don't think there's any point in passing through unrecognized chars On the first point, the code only accepts modes like 'r' and 'rb' (but |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: