Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/tabnanny.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def main():
if o == '-v':
verbose = verbose + 1
if not args:
errprint("Usage:", sys.argv[0], "[-v] file_or_directory ...")
errprint(f"Usage: {sys.executable} -m tabnanny [-v] file_or_directory ...")
for arg in args:
check(arg)

Expand Down
5 changes: 4 additions & 1 deletion Lib/test/test_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,10 @@ def default(self, line):
for input in [b"! h\t\n", b"!h\t\n"]:
with self.subTest(input=input):
output = run_pty(script, input)
self.assertIn(b'hello', output)
# libedit redraws only the untyped suffix after a
# cursor-forward escape, unlike GNU readline which retypes
# the whole completed word, so check the common suffix.
self.assertIn(b'ello', output)
self.assertIn(b'tab completion success', output)

def load_tests(loader, tests, pattern):
Expand Down
7 changes: 3 additions & 4 deletions Lib/test/test_tabnanny.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from unittest import TestCase, main, mock
import errno
import os
import sys
import tabnanny
import tokenize
import tempfile
import textwrap
from test.support import (captured_stderr, captured_stdout, script_helper,
findfile)
from test.support import captured_stderr, captured_stdout, script_helper
from test.support.os_helper import unlink


Expand Down Expand Up @@ -328,8 +328,7 @@ def test_with_error_free_file(self):

def test_command_usage(self):
"""Should display usage on no arguments."""
path = findfile('tabnanny.py')
stderr = f"Usage: {path} [-v] file_or_directory ..."
stderr = f"Usage: {sys.executable} -m tabnanny [-v] file_or_directory ..."
self.validate_cmd(stderr=stderr, expect_failure=True)

def test_quiet_flag(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix the link of ``Programs/_freeze_module`` when extension modules are built
in (``MODULE_BUILDTYPE=static``) and the test modules are enabled:
``Modules/getpath_noop.c`` now defines ``_Py_Get_Getpath_CodeObject()``,
which ``_testinternalcapi`` uses.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The usage message printed by ``python -m tabnanny`` when no arguments are
given now suggests ``python -m`` instead of the source file.
13 changes: 12 additions & 1 deletion Modules/getpath_noop.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
/* Implements the getpath API for compiling with no functionality */

#include "Python.h"
#include "pycore_pathconfig.h"
#include "pycore_initconfig.h" // _Py_Get_Getpath_CodeObject()
#include "pycore_pathconfig.h" // _PyConfig_InitPathConfig()

PyStatus
_PyConfig_InitPathConfig(PyConfig *config, int compute_path_config)
{
return PyStatus_Error("path configuration is unsupported");
}

/* Used by _testinternalcapi, which is linked into Programs/_freeze_module
when extension modules are built in (MODULE_BUILDTYPE=static). */
PyObject *
_Py_Get_Getpath_CodeObject(void)
{
PyErr_SetString(PyExc_RuntimeError,
"path configuration is unsupported");
return NULL;
}
Loading