cpython
cpython copied to clipboard
test_pyrepl.test_exposed_globals_in_repl failure
Bug report
Bug description:
I'm seeing this on a Dell laptop running XUbuntu 22.04 and MacBook Pro M1 running MacOS 14.5. In both cases, Python was built on main with the following sequence:
git fetch --all
git pull
git clean -fdx
./configure
nice make -j test
On the Mac, I also tested on the 3.13 branch and see the same failure (same out as below, save for the printed interpreter version details).
Dell:
======================================================================
FAIL: test_exposed_globals_in_repl (test.test_pyrepl.test_pyrepl.TestMain.test_exposed_globals_in_repl)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/skip/src/python/cpython/Lib/test/support/__init__.py", line 2622, in wrapper
return func(*args, **kwargs)
File "/home/skip/src/python/cpython/Lib/test/test_pyrepl/test_pyrepl.py", line 868, in test_exposed_globals_in_repl
self.assertTrue(case1 or case2 or case3 or case4, output)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: False is not true : sorted(dir())
exit
Python 3.14.0a0 (heads/main:19d1e43e43d, Jul 4 2024, 06:49:38) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> s
>>> so
>>> sor
>>> sort
>>> sorte
>>> sorted
>>> sorted(
>>> sorted(d
>>> sorted(di
>>> sorted(dir
>>> sorted(dir(
>>> sorted(dir()
>>> sorted(dir())
['__class__', '__class_getitem__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__ior__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__or__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__ror__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
>>>
>>> e
>>> ex
>>> exi
>>> exit
Mac:
======================================================================
FAIL: test_exposed_globals_in_repl (test.test_pyrepl.test_pyrepl.TestMain.test_exposed_globals_in_repl)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/skip/src/python/cpython/Lib/test/support/__init__.py", line 2622, in wrapper
return func(*args, **kwargs)
File "/Users/skip/src/python/cpython/Lib/test/test_pyrepl/test_pyrepl.py", line 868, in test_exposed_globals_in_repl
self.assertTrue(case1 or case2 or case3 or case4, output)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: False is not true : sorted(dir())
exit
Python 3.14.0a0 (heads/main:19d1e43e43d, Jul 4 2024, 06:49:28) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> s
>>> sor
>>> sorted(
>>> sorted(d
>>> sorted(di
>>> sorted(dir())
['__class__', '__class_getitem__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__ior__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__or__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__ror__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
>>> ex
>>> exit
CPython versions tested on:
3.13, CPython main branch
Operating systems tested on:
Linux, macOS
I should point out that I have long had my own dir() function:
% ./python.exe -S -E
Python 3.14.0a0 (heads/main:19d1e43e43d, Jul 4 2024, 06:49:28) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
>>> sorted(dir())
['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__']
>>> type(dir)
<class 'builtin_function_or_method'>
>>>
Contrast that with mine:
% ./python.exe
Python 3.14.0a0 (heads/main:19d1e43e43d, Jul 4 2024, 06:49:28) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> type(dir)
<class 'function'>
>>>
Shouldn't test_pyrepl be running the interpreter with something like -S -E?
Edit: Sorry, forgot to include the output of sorted(dir()) above:
>>> sorted(dir())
['__class__', '__class_getitem__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__ior__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__or__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__ror__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
I should point out that I have long had my own dir() function
How is it installed?
I have a ~/misc/python directory with some stuff at that level, other version-specific stuff in pythonN subdirectories, where N is 1, 2, or 3 (I've been at this a while). The appropriate directories are tacked onto sys.path in my PYTHONSTARTUP file.
On Thu, Jul 4, 2024, 10:53 AM Victor Stinner @.***> wrote:
I should point out that I have long had my own dir() function
How is it installed?
— Reply to this email directly, view it on GitHub https://github.com/python/cpython/issues/121359#issuecomment-2209273113, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2E3IIFKIDBOHDF55JRL3LZKVVYNAVCNFSM6AAAAABKLMZMHWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBZGI3TGMJRGM . You are receiving this because you authored the thread.Message ID: @.***>
Unsetting PYTHONSTARTUP worked:
(python312) ~/src/python/cpython% env | grep PYTHON
PYTHONSTARTUP=/Users/skip/.python.py
CONDA_PYTHON_EXE=/Users/skip/miniconda3/bin/python
(python312) ~/src/python/cpython% PYTHONSTARTUP= ./python.exe -E -m test --fast-ci --timeout= -v test_pyrepl
+ ./python.exe -u -W default -bb -E -m test --fast-ci --timeout= -v test_pyrepl --dont-add-python-opts
== CPython 3.14.0a0 (heads/main:d4faa7bd321, Jul 5 2024, 11:13:24) [Clang 15.0.0 (clang-1500.3.9.4)]
== macOS-14.5-arm64-arm-64bit-Mach-O little-endian
== Python build: release
== cwd: /Users/skip/src/python/cpython/build/test_python_worker_63965æ
== CPU count: 8
== encodings: locale=UTF-8 FS=utf-8
== resources: all,-cpu
Using random seed: 725582968
0:00:00 load avg: 1.41 Run 1 test in parallel using 1 worker process (timeout: 10 min, worker timeout: 15 min)
0:00:03 load avg: 1.62 [1/1] test_pyrepl passed
== Tests result: SUCCESS ==
10 slowest tests:
- test_pyrepl: 3.7 sec
1 test OK.
Total duration: 3.7 sec
Total tests: run=118 skipped=1
Total test files: run=1/1
Result: SUCCESS
Shouldn't test_pyrepl be running the interpreter with something like -S -E?
I wrote PR https://github.com/python/cpython/pull/121414 to pass -I option to Python. Can you test the PR with your startup file?
PR https://github.com/python/cpython/pull/121672 is available for review. I think this should finally fix this issue.
@ambv, probably this may be closed
I believe that this issue was fixed in the main branch. If not, open a new issue, or reopen the issue.