8000 test_pyrepl doesn't ignore PYTHONSTARTUP · Issue #121271 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

test_pyrepl doesn't ignore PYTHONSTARTUP #121271

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

Closed
Yhg1s opened this issue Jul 2, 2024 · 2 comments
Closed

test_pyrepl doesn't ignore PYTHONSTARTUP #121271

Yhg1s opened this issue Jul 2, 2024 · 2 comments
Assignees
Labels
3.13 bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@Yhg1s
Copy link
Member
Yhg1s commented Jul 2, 2024

Bug report

Bug description:

test_pyrepl starts a new Python process in order to test repl output, but it does not correctly isolate the interpreter from user-set environment variables that will affect the output, like PYTHONPATH and PYTHONSTARTUP. All other places in the testsuite that run python do so with -I or -E to avoid this problem.

% cat $PYTHONSTARTUP
#!/usr/bin/env python

from __future__ import division

import readline
import rlcompleter

readline.parse_and_bind('tab: complete')
% ./python -m test test_pyrepl -u all
Using random seed: 1113277385
0:00:00 load avg: 0.17 Run 1 test sequentially in a single process
0:00:00 load avg: 0.17 [1/1] test_pyrepl
test test_pyrepl failed -- Traceback (most recent call last):
  File "Lib/test/support/__init__.py", line 2622, in wrapper
    return func(*args, **kwargs)
  File "Lib/test/test_pyrepl/test_pyrepl.py", line 865, 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-dirty:1dc9a4f6b2, Jul  2 2024, 16:58:02) [GCC 12.2.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())


['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'division', 'readline', 'rlcompleter']


>>>
>>> e
>>> ex

>>> exi
>>> exit



test_pyrepl failed (1 failure)

== Tests result: FAILURE ==

1 test failed:
    test_pyrepl

Total duration: 2.6 sec
Total tests: run=117 failures=1 skipped=1
Total test files: run=1/1 failed=1
Result: FAILURE


### CPython versions tested on:

3.13, CPython main branch

### Operating systems tested on:

Linux
@Yhg1s Yhg1s added type-bug An unexpected behavior, bug, or error 3.13 bugs and security fixes labels Jul 2, 2024
@skirpichev
Copy link
Contributor

Probably, that can be optional. Some repl tests may depend on changing PYTHON* environment variables. E.g. see #121259.

@vstinner
Copy link
Member
vstinner commented Jul 8, 2024

Fixed by 6239d41.

@vstinner vstinner closed this as completed Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

5 participants
0