Title: test_pyrepl doesn't ignore PYTHONSTARTUP · Issue #121271 · python/cpython · GitHub
Open Graph Title: test_pyrepl doesn't ignore PYTHONSTARTUP · Issue #121271 · python/cpython
X Title: test_pyrepl doesn't ignore PYTHONSTARTUP · Issue #121271 · python/cpython
Description: 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 PYTH...
Open Graph Description: 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 aff...
X Description: 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 aff...
Opengraph URL: https://github.com/python/cpython/issues/121271
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test_pyrepl doesn't ignore PYTHONSTARTUP","articleBody":"# Bug report\n\n### Bug description:\n\ntest_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.\n\n```\n% cat $PYTHONSTARTUP\n#!/usr/bin/env python\n\nfrom __future__ import division\n\nimport readline\nimport rlcompleter\n\nreadline.parse_and_bind('tab: complete')\n% ./python -m test test_pyrepl -u all\nUsing random seed: 1113277385\n0:00:00 load avg: 0.17 Run 1 test sequentially in a single process\n0:00:00 load avg: 0.17 [1/1] test_pyrepl\ntest test_pyrepl failed -- Traceback (most recent call last):\n File \"Lib/test/support/__init__.py\", line 2622, in wrapper\n return func(*args, **kwargs)\n File \"Lib/test/test_pyrepl/test_pyrepl.py\", line 865, in test_exposed_globals_in_repl\n self.assertTrue(case1 or case2 or case3 or case4, output)\n ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nAssertionError: False is not true : sorted(dir())\nexit\n\nPython 3.14.0a0 (heads/main-dirty:1dc9a4f6b2, Jul 2 2024, 16:58:02) [GCC 12.2.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\n\n>>>\n>>> s\n>>> so\n>>> sor\n>>> sort\n>>> sorte\n\n>>> sorted\n\n>>> sorted(\n>>> sorted(d\n>>> sorted(di\n>>> sorted(dir\n>>> sorted(dir(\n>>> sorted(dir()\n>>> sorted(dir())\n\n\n['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'division', 'readline', 'rlcompleter']\n\n\n>>>\n>>> e\n>>> ex\n\n>>> exi\n>>> exit\n\n\n\ntest_pyrepl failed (1 failure)\n\n== Tests result: FAILURE ==\n\n1 test failed:\n test_pyrepl\n\nTotal duration: 2.6 sec\nTotal tests: run=117 failures=1 skipped=1\nTotal test files: run=1/1 failed=1\nResult: FAILURE\n\n\n### CPython versions tested on:\n\n3.13, CPython main branch\n\n### Operating systems tested on:\n\nLinux","author":{"url":"https://github.com/Yhg1s","@type":"Person","name":"Yhg1s"},"datePublished":"2024-07-02T15:13:23Z","url":"https://github.com/python/cpython/issues/121271"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:42e17501-f634-b5fc-ec9b-30c4454c8b7f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9A68:323204:1AAD75F:2324BB0:6B021B76 |
| html-safe-nonce | d32105acdc2f542b2fb91f36dac185019d0eedfe6a19ee7e2b58fd1cf05b803b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTY4OjMyMzIwNDoxQUFENzVGOjIzMjRCQjA6NkIwMjFCNzYiLCJ2aXNpdG9yX2lkIjoiNTcyNzgxOTQ4OTI2MTc4ODAyMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 96092ea1e6e719de4c05b8859d84df3a3902c16f60c1618be07569e9f4748816 |
| hovercard-subject-tag | issue:2386527494 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/121271/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2373a89980fd2e1146a0a2b37092525f187240f3d2b1e269c45957ab0ce818ad/python/cpython/issues/121271 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2373a89980fd2e1146a0a2b37092525f187240f3d2b1e269c45957ab0ce818ad/python/cpython/issues/121271 |
| og:image:alt | 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 aff... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Yhg1s |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width