Skip to content
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

gh-99894: Ensure the local names don't collide with the test file in traceback suggestion error checking #99895

Merged
merged 4 commits into from Dec 1, 2022

Conversation

@vstinner
Copy link
Member

This branch doesn't work for me:

vstinner@mona$ ./python -m test test_traceback -j20 -F -m test_import_from_error_bad_suggestions_do_not_trigger_for_small_names -v
(...)
0:00:07 load avg: 8.01 [ 36/1] test_traceback failed (1 failure)
test_import_from_error_bad_suggestions_do_not_trigger_for_small_names (test.test_traceback.CPythonSuggestionFormattingTests.test_import_from_error_bad_suggestions_do_not_trigger_for_small_names) ... 
  test_import_from_error_bad_suggestions_do_not_trigger_for_small_names (test.test_traceback.CPythonSuggestionFormattingTests.test_import_from_error_bad_suggestions_do_not_trigger_for_small_names) (name='py') ... FAIL
test_import_from_error_bad_suggestions_do_not_trigger_for_small_names (test.test_traceback.PurePythonSuggestionFormattingTests.test_import_from_error_bad_suggestions_do_not_trigger_for_small_names) ... ok

======================================================================
FAIL: test_import_from_error_bad_suggestions_do_not_trigger_for_small_names (test.test_traceback.CPythonSuggestionFormattingTests.test_import_from_error_bad_suggestions_do_not_trigger_for_small_names) (name='py')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vstinner/python/main/Lib/test/test_traceback.py", line 3172, in test_import_from_error_bad_suggestions_do_not_trigger_for_small_names
    self.assertNotIn("vvv", actual)
AssertionError: 'vvv' unexpectedly found in "ImportError: cannot import name 'py' from 'NkosMVLvvvpdqPze' (/tmp/test_python_xfxl02nj/tmp7l231ock/NkosMVLvvvpdqPze.py)"

$ git show
commit 5612e561a96f4da735e966f527e1e01265564ae1 (HEAD -> pr/99895)
Author: Pablo Galindo <pablogsal@gmail.com>
Date:   Wed Nov 30 11:22:49 2022 +0000

    gh-99894: Ensure the local names don't collide with the test file in traceback suggestion error checking

@vstinner
Copy link
Member

Ah, this PR changes test_getattr_error_bad_suggestions_do_not_trigger_for_small_names(), but not test_import_from_error_bad_suggestions_do_not_trigger_for_small_names().

You should also change test_import_from_error_bad_suggestions_do_not_trigger_for_small_names(), no?

…test file in traceback suggestion error checking
@pablogsal
Copy link
Member Author

Ah, this PR changes test_getattr_error_bad_suggestions_do_not_trigger_for_small_names(), but not test_import_from_error_bad_suggestions_do_not_trigger_for_small_names().

You should also change test_import_from_error_bad_suggestions_do_not_trigger_for_small_names(), no?

Done!

@vstinner
Copy link
Member

I ran ./python -m test test_traceback -j20 -F -m test_import_from_error_bad_suggestions_do_not_trigger_for_small_names -v for 9 min 24 sec: 3669 tests OK.

@vstinner
Copy link
Member

Another test: ./python -m test test_traceback -j20 -F -v ran for 4 min 50 sec: 52 tests OK.

@vstinner
Copy link
Member

Another test: ./python -m test test_traceback -j20 -F -m test_getattr_error_bad_suggestions_do_not_trigger_for_small_names -v ran for 9 min 28 sec: 5086 tests OK.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM: I tested functionnaly the change, it does fix #99894

I have a minor suggestion.

@@ -2979,8 +2979,8 @@ class MyClass:
with self.subTest(name=name):
actual = self.get_suggestion(MyClass, name)
self.assertNotIn("you mean", actual)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe check for Did you mean? Same remark for the other test.

Other test_traceback tests check for this (a little bit longer) pattern.

Lib/test/test_traceback.py Outdated Show resolved Hide resolved
Lib/test/test_traceback.py Outdated Show resolved Hide resolved
@vstinner
Copy link
Member

vstinner commented Dec 1, 2022

test_threading of "Address sanitizer" failed (env changed). I re-ran this CI job.

@vstinner vstinner merged commit 0563be2 into python:main Dec 1, 2022
@vstinner
Copy link
Member

vstinner commented Dec 1, 2022

Python 3.10 and 3.11 are not affected.

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot ARM Raspbian 3.x has failed when building commit 0563be2.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/424/builds/3060) and take a look at the build logs.
  4. Check if the failure is related to this commit (0563be2) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/424/builds/3060

Summary of the results of the build (if available):

== Tests result: ENV CHANGED ==

411 tests OK.

10 slowest tests:

  • test_venv: 12 min 28 sec
  • test_largefile: 8 min 51 sec
  • test_lib2to3: 6 min 28 sec
  • test_multiprocessing_spawn: 4 min 2 sec
  • test_concurrent_futures: 3 min 19 sec
  • test_asyncio: 3 min
  • test_tokenize: 2 min 5 sec
  • test_multiprocessing_forkserver: 1 min 56 sec
  • test_gdb: 1 min 42 sec
  • test_cppext: 1 min 39 sec

1 test altered the execution environment:
test_concurrent_futures

21 tests skipped:
test_check_c_globals test_devpoll test_idle test_ioctl test_kqueue
test_launcher test_msilib test_peg_generator test_perf_profiler
test_startfile test_tcl test_tix test_tkinter test_ttk
test_ttk_textonly test_turtle test_winconsoleio test_winreg
test_winsound test_wmi test_zipfile64

Total duration: 29 min 44 sec

Click to see traceback logs
remote: Enumerating objects: 9, done.        
remote: Counting objects:  11% (1/9)        
remote: Counting objects:  22% (2/9)        
remote: Counting objects:  33% (3/9)        
remote: Counting objects:  44% (4/9)        
remote: Counting objects:  55% (5/9)        
remote: Counting objects:  66% (6/9)        
remote: Counting objects:  77% (7/9)        
remote: Counting objects:  88% (8/9)        
remote: Counting objects: 100% (9/9)        
remote: Counting objects: 100% (9/9), done.        
remote: Compressing objects:  20% (1/5)        
remote: Compressing objects:  40% (2/5)        
remote: Compressing objects:  60% (3/5)        
remote: Compressing objects:  80% (4/5)        
remote: Compressing objects: 100% (5/5)        
remote: Compressing objects: 100% (5/5), done.        
remote: Total 5 (delta 4), reused 0 (delta 0), pack-reused 0        
From https://github.com/python/cpython
 * branch                  main       -> FETCH_HEAD
Note: switching to '0563be23a557917228a8b48cbb31bda285a3a815'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 0563be23a5 gh-99894: Ensure the local names don't collide with the test file in traceback suggestion error checking (#99895)
Switched to and reset branch 'main'

Objects/obmalloc.c:776:1: warning: ‘always_inline’ function might not be inlinable [-Wattributes]
  776 | arena_map_get(pymem_block *p, int create)
      | ^~~~~~~~~~~~~

make: *** [Makefile:1889: buildbottest] Error 3

carljm added a commit to carljm/cpython that referenced this pull request Dec 1, 2022
* main: (112 commits)
  pythongh-99894: Ensure the local names don't collide with the test file in traceback suggestion error checking (python#99895)
  pythongh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data (pythonGH-99613)
  Doc: Add summary line to isolation_level & autocommit sqlite3.connect params (python#99917)
  pythonGH-98906 ```re``` module: ```search() vs. match()``` section should mention ```fullmatch()``` (pythonGH-98916)
  pythongh-89189: More compact range iterator (pythonGH-27986)
  bpo-47220: Document the optional callback parameter of weakref.WeakMethod (pythonGH-25491)
  pythonGH-99905: Fix output of misses in summarize_stats.py execution counts (pythonGH-99906)
  pythongh-99845: PEP 670: Convert PyObject macros to functions (python#99850)
  pythongh-99845: Use size_t type in __sizeof__() methods (python#99846)
  pythonGH-99877)
  Fix typo in exception message in `multiprocessing.pool` (python#99900)
  pythongh-87092: move all localsplus preparation into separate function called from assembler stage (pythonGH-99869)
  pythongh-99891: Fix infinite recursion in the tokenizer when showing warnings (pythonGH-99893)
  pythongh-99824: Document that sqlite3.connect implicitly open a transaction if autocommit=False (python#99825)
  pythonGH-81057: remove static state from suggestions.c (python#99411)
  Improve zip64 limit error message (python#95892)
  pythongh-98253: Break potential reference cycles in external code worsened by typing.py lru_cache (python#98591)
  pythongh-99127: Allow some features of syslog to the main interpreter only (pythongh-99128)
  pythongh-82836: fix private network check (python#97733)
  Docs: improve accuracy of socketserver reference (python#24767)
  ...
self.assertNotIn("vvv", actual)
self.assertNotIn("mom", actual)
self.assertNotIn("Did you mean", actual)
self.assertNotIn("'vvv", actual)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this has any effect but there is a ' missing here

sobolevn added a commit to sobolevn/cpython that referenced this pull request Dec 28, 2022
… test file in traceback suggestion error checking (python#99895)"

This reverts commit 0563be2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants