| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Add a dict importlib.util.EXPECTED_MAGIC_NUMBERS which details the initial and expected pyc magic number for each minor release. This gives a mechanism for users to check if the magic number has changed within a release and for a test to ensure procedure is followed if a change is necessary. Add a test to check the current MAGIC_NUMBER against the expected number for the release if the current release is at candidate or final level. On test failure, describe to the developer the procedure for changing the magic number.
There was a problem hiding this comment.
The general approach in the test case looks like it will give affected maintainers useful guidance, but the impact can be reduced by moving the EXPECTED_MAGIC_NUMBERS table into the test case itself (the test case will complain when it needs updating, so it's OK to have it separated from the list of actual magic numbers in the importlib code)
Sorry, something went wrong.
| (2, 7): 62211, | ||
| (3, 5): 3350, | ||
| (3, 6): 3379 | ||
| } |
There was a problem hiding this comment.
I'd put this table in the test suite rather than in the code - there's no need to have it other than the bytecode stability test case, and if it hasn't been updated when it needs to be we'll get a test failure anyway.
Sorry, something went wrong.
There was a problem hiding this comment.
Simplifed to a sigle entry in the test case in 9ea7c52
Sorry, something went wrong.
| from ._bootstrap import _resolve_name | ||
| from ._bootstrap import spec_from_loader | ||
| from ._bootstrap import _find_spec | ||
| from ._bootstrap_external import EXPECTED_MAGIC_NUMBERS |
There was a problem hiding this comment.
With the table moved to the test suite, this won't be needed any more.
Sorry, something went wrong.
There was a problem hiding this comment.
removed in 9ea7c52
Sorry, something went wrong.
|
|
||
| In exceptional cases, it may be required to change the MAGIC_NUMBER | ||
| for a maintenance release. In this case the change should be | ||
| discussed in dev-python. If a change is required, community |
There was a problem hiding this comment.
dev-python -> python-dev
Sorry, something went wrong.
There was a problem hiding this comment.
fixed in 9ea7c52
Sorry, something went wrong.
|
|
||
| EXPECTED_MAGIC_NUMBERS = { | ||
| (2, 7): 62211, | ||
| (3, 5): 3350, |
There was a problem hiding this comment.
Does this mean we're reverting the magic number bump from 3.5.3?
Sorry, something went wrong.
There was a problem hiding this comment.
No, but the current special case from the test should just be moved directly into the table of expected magic numbers with a suitable comment.
Sorry, something went wrong.
Simplify the magic number release test by removing EXPECTED_MAGIC_NUMBERS table and making the expected magic number self-contained within the test. BPO: 29514
There was a problem hiding this comment.
This is looking pretty close now, just a couple of suggestions around details of the test execution.
Sorry, something went wrong.
| ) = util.test_both(PEP3147Tests, util=importlib_util) | ||
|
|
||
|
|
||
| class MagicNumberTests: |
There was a problem hiding this comment.
Inherit from unittest.TestCase here
Sorry, something went wrong.
There was a problem hiding this comment.
I initially avoided this and followed the test machinery as I wasn't sure about directly importing importlib.util within this test module, but after looking at the way the test specialization works I don't see how this is an issue. Changed in 1e32a1b.
Sorry, something went wrong.
There was a problem hiding this comment.
Yeah, this module does some interesting things to create "real" test classes in different configurations, but we don't need those kinds of tricks for the new test.
Sorry, something went wrong.
| adjustment to this test case. | ||
| """ | ||
| if sys.version_info.releaselevel not in ('final', 'candidate'): | ||
| return |
There was a problem hiding this comment.
This can change to a unittest.skipUnless decorator on the testmethod:
@unittest.skipUnless(sys.version_info.release in ('final', 'release'), 'Only check magic number stability for release candidates and later')
Sorry, something went wrong.
There was a problem hiding this comment.
Done in 1e32a1b
Sorry, something went wrong.
| actual = int.from_bytes(self.util.MAGIC_NUMBER[:2], 'little') | ||
|
|
||
| msg = ( | ||
| "Candidate and final releases require the current " |
There was a problem hiding this comment.
I'd start this message with "To avoid breaking backwards compatibility with cached bytecode files that can't be automatically regenerated by the current user, ..."
Sorry, something went wrong.
There was a problem hiding this comment.
Added in 1e32a1b
Sorry, something went wrong.
Improve the execution of the magic number test by using skipUnless for alpha and beta releases, and directly inheriting from unittest.TestCase rather than using the machinery for the other tests. Also improve the error message to explain the reason for caution in changing the magic number. BPO: 29514
Codecov Report
@@ Coverage Diff @@
## master #54 +/- ##
==========================================
- Coverage 82.37% 82.37% -0.01%
==========================================
Files 1427 1428 +1
Lines 350948 350968 +20
==========================================
+ Hits 289093 289102 +9
- Misses 61855 61866 +11Continue to review full report at Codecov.
|
Sorry, something went wrong.
| actual = int.from_bytes(importlib.util.MAGIC_NUMBER[:2], 'little') | ||
|
|
||
| msg = ( | ||
| "To avoid breaking backwards compatibility with cached bytecode " |
There was a problem hiding this comment.
Wouldn't be better to use a multiline string literal if you want such verbose error message?
But I think that "broken *.pyc files compatibility" would be enough.
Sorry, something went wrong.
There was a problem hiding this comment.
Then you'd have to dedent it, etc. This message is perfectly legible to me.
Sorry, something went wrong.
| ) | ||
| def test_magic_number(self): | ||
| """ | ||
| Each python minor release should generally have a MAGIC_NUMBER |
There was a problem hiding this comment.
I think it would be better to write this as a comment rather than a docstring. If you want, add a one-line docstring, but most test methods don't have docstrings.
Sorry, something went wrong.
|
Sorry @appeltel and @ambv, I had trouble checking out the 3.6 backport branch. |
Sorry, something went wrong.
|
Sorry, @appeltel and @ambv, I could not cleanly backport this to 2.7 due to a conflict. |
Sorry, something went wrong.
Sorry, something went wrong.
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
The versions checked here are 20 years old. Also dllwrap has started to emit a deprecation warning in the latest release spamming the build logs. Fixes python#54
| Back | FazBrowse Home | New Git URL |
Add a test to check the current MAGIC_NUMBER against the
expected number for the release if the current release is
at candidate or final level. On test failure, describe to
the developer the procedure for changing the magic number.
https://bugs.python.org/issue29514