Skip to content

pyrepl help modules displays a print statement from test_sqlite3 #139743

Closed

Description

@mpkocher

Bug report

Bug description:

When using pyrepl, there's a random print statement from sqlite when calling help then modules.

test_sqlite3: testing with SQLite version 3.51.0

Python 3.15.0a0 (heads/main:c53c55b6ed9, Oct  7 2025, 18:49:00) [Clang 17.0.0 (clang-1700.3.19.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> help

(snip...)

To quit this help utility and return to the interpreter,
enter "q", "quit" or "exit".

help> modules

Please wait a moment while I gather a list of all available modules...

test_sqlite3: testing with SQLite version 3.51.0
__future__          _sre                ensurepip           quopri
__hello__           _ssl                enum                random
__phello__          _stat               errno               re
_abc                _statistics         faulthandler        readline

Also, it's not clear to me why all of these internal _ prefixed internal modules are being displayed.

CPython versions tested on:

3.15

Operating systems tested on:

macOS

Linked PRs

Activity

  1. yihong0618 commented on Oct 8, 2025

    @yihong0618
    Contributor

    this is becase this line

    print(f"test_sqlite3: testing with SQLite version {sqlite3.sqlite_version}")

    modules will load all of the modules can load
    then it load test_sqlite3 in this the verbose is 1 so will print it.

    it is not because pyrepl you can run python3.12 in cpython dir
    then help -> modules it will also print it

    ➜  cpython git:(main) python3.12
    Python 3.12.9 (main, Feb  4 2025, 14:38:38) [Clang 16.0.0 (clang-1600.0.26.6)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> help()
    Welcome to Python 3.12's help utility! If this is your first time using
    Python, you should definitely check out the tutorial at
    https://docs.python.org/3.12/tutorial/.
    
    Enter the name of any module, keyword, or topic to get help on writing
    Python programs and using Python modules.  To get a list of available
    modules, keywords, symbols, or topics, enter "modules", "keywords",
    "symbols", or "topics".
    
    Each module also comes with a one-line summary of what it does; to list
    the modules whose name or summary contain a given string such as "spam",
    enter "modules spam".
    
    To quit this help utility and return to the interpreter,
    enter "q" or "quit".
    
    help> modules
    
    Please wait a moment while I gather a list of all available modules...
    
    test_sqlite3: testing with SQLite version 3.49.1
    

    how to fix it

    maybe this diff can fix it but not sure

    diff --git a/Lib/test/test_sqlite3/__init__.py b/Lib/test/test_sqlite3/__init__.py
    index d777fca82d..b4d95f1365 100644
    --- a/Lib/test/test_sqlite3/__init__.py
    +++ b/Lib/test/test_sqlite3/__init__.py
    @@ -8,8 +8,8 @@
     
     # Implement the unittest "load tests" protocol.
     def load_tests(*args):
    +    if verbose:
    +        print(f"test_sqlite3: testing with SQLite version {sqlite3.sqlite_version}")
         pkg_dir = os.path.dirname(__file__)
         return load_package_tests(pkg_dir, *args)
     
    -if verbose:
    -    print(f"test_sqlite3: testing with SQLite version {sqlite3.sqlite_version}")
    
  2. ttw225 commented on Oct 8, 2025

    @ttw225
    Contributor

    Hi all — I reproduced this locally and it matches @yihong0618’s observation. @yihong0618 are you planning to open a PR for this fix? If not, I’m happy to open one adopting your approach (with credit).

    Also, it might be worth considering a focused test for help('modules') in a separate PR to prevent regressions.

  3. yihong0618 commented on Oct 8, 2025

    @yihong0618
    Contributor

    Hi all — I reproduced this locally and it matches @yihong0618’s observation. @yihong0618 are you planning to open a PR for this fix? If not, I’m happy to open one adopting your approach (with credit).

    Also, it might be worth considering a focused test for help('modules') in a separate PR to prevent regressions.

    I am not planning that just go haha

  4. added a commit that references this issue on Oct 9, 2025
  5. added 2 commits that reference this issue on Oct 9, 2025
  6. added 2 commits that reference this issue on Oct 9, 2025
  7. yihong0618 commented on Nov 16, 2025

    @yihong0618
    Contributor

    After this patch the help print is fixed
    but it will print the message twice in test

    ➜  cpython git:(main) ./python.exe -m test test_sqlite3 -v
    == CPython 3.15.0a1+ (heads/main:ed73c909f2, Nov 16 2025, 15:29:51) [Clang 17.0.0 (clang-1700.0.13.5)]
    == macOS-15.3.2-arm64-arm-64bit-Mach-O little-endian
    == Python build: release
    == cwd: /Users/yihong/repos/cpython/build/test_python_worker_36303æ
    == CPU count: 10
    == encodings: locale=UTF-8 FS=utf-8
    == resources: all test resources are disabled, use -u option to unskip tests
    
    Using random seed: 610242821
    0:00:00 load avg: 2.83 Run 1 test sequentially in a single process
    0:00:00 load avg: 2.83 [1/1] test_sqlite3
    test_sqlite3: testing with SQLite version 3.43.2
    test_sqlite3: testing with SQLite version 3.43.2
    test_bad_source_closed_connection (test.test_sqlite3.test_backup.BackupTests.test_bad_source_closed_connection) ... ok
    

    cc @serhiy-storchaka

  8. added a commit that references this issue on Dec 17, 2025
  9. added 2 commits that reference this issue on Dec 17, 2025
  10. added 2 commits that reference this issue on Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shelltopic-sqlite3type-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions