summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cmd_line_script.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-43950: Print columns in tracebacks (PEP 657) (GH-26958)Ammar Askar2021-07-041-2/+2
| | | | | | | | The traceback.c and traceback.py mechanisms now utilize the newly added code.co_positions and PyCode_Addr2Location to print carets on the specific expressions involved in a traceback. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Ammar Askar <ammar@ammaraskar.com> Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>
* fix: use unambiguous punction in 'invalid escape sequence' message (GH-26582)Ned Batchelder2021-06-081-1/+1
|
* bpo-43914: Highlight invalid ranges in SyntaxErrors (#25525)Pablo Galindo2021-04-231-5/+5
| | | | | | | | | | | | | | | | | To improve the user experience understanding what part of the error messages associated with SyntaxErrors is wrong, we can highlight the whole error range and not only place the caret at the first character. In this way: >>> foo(x, z for z in range(10), t, w) File "<stdin>", line 1 foo(x, z for z in range(10), t, w) ^ SyntaxError: Generator expression must be parenthesized becomes >>> foo(x, z for z in range(10), t, w) File "<stdin>", line 1 foo(x, z for z in range(10), t, w) ^^^^^^^^^^^^^^^^^^^^ SyntaxError: Generator expression must be parenthesized
* bpo-43797: Improve syntax error for invalid comparisons (#25317)Pablo Galindo2021-04-121-4/+4
| | | | | | | | | | | | | * bpo-43797: Improve syntax error for invalid comparisons * Update Lib/test/test_fstring.py Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> * Apply review comments * can't -> cannot Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
* bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25145)Inada Naoki2021-04-041-3/+3
| | | | | | | | | | | | | | | | | | | * test_asyncio * test_bz2 * test_math * test_cmath * test_cmd_line * test_cmd_line_script * test_compile * test_contextlib * test_profile * ctypes/test/test_find * test_multiprocessing * test_configparser * test_csv * test_dbm_dumb * test_decimal * test_difflib * os.fdopen() calls io.text_encoding() to emit EncodingWarning for right place.
* bpo-41731: Make test_cmd_line_script pass with -vv (GH-22206)Terry Jan Reedy2020-09-121-1/+1
| | | | | Argument script_exec_args is usually an absolute file name, but twice has form ['-m', 'module_name'].
* bpo-40275: Use new test.support helper submodules in tests (GH-21412)Hai Shi2020-07-091-49/+51
|
* bpo-40612: Fix SyntaxError edge cases in traceback formatting (GH-20072)Guido van Rossum2020-05-151-1/+1
| | | | | | | | | | | | | This fixes both the traceback.py module and the C code for formatting syntax errors (in Python/pythonrun.c). They now both consistently do the following: - Suppress caret if it points left of text - Allow caret pointing just past end of line - If caret points past end of line, clip to *just* past end of line The syntax error formatting code in traceback.py was mostly rewritten; small, subtle changes were applied to the C code in pythonrun.c. There's still a difference when the text contains embedded newlines. Neither handles these very well, and I don't think the case occurs in practice. Automerge-Triggered-By: @gvanrossum
* bpo-40334: Fix error location upon parsing an invalid string literal (GH-19962)Lysandros Nikolaou2020-05-071-1/+1
| | | | | | | When parsing a string with an invalid escape, the old parser used to point to the beginning of the invalid string. This commit changes the new parser to match that behaviour, since it's currently pointing to the end of the string (or to be more precise, to the beginning of the next token).
* bpo-40334: Improve column offsets for thrown syntax errors by Pegen (GH-19782)Batuhan Taskaya2020-05-011-3/+3
|
* bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)Pablo Galindo2020-04-221-10/+9
| | | | Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* bpo-40108: Improve the error message in runpy when importing a module that ↵Pablo Galindo2020-03-311-0/+10
| | | | includes the extension (GH-19239)
* bpo-20443: No longer make sys.argv[0] absolute for script (GH-17534)Victor Stinner2019-12-091-2/+3
| | | | | In Python 3.9.0a1, sys.argv[0] was made an asolute path if a filename was specified on the command line. Revert this change, since most users expect sys.argv to be unmodified.
* bpo-38991: Remove test.support.strip_python_stderr() (GH-17490)Victor Stinner2019-12-081-2/+2
| | | | | test.support: run_python_until_end(), assert_python_ok() and assert_python_failure() functions no longer strip whitespaces from stderr.
* Fix typos mostly in comments, docs and test names (GH-15209)Min ho Kim2019-08-301-1/+1
|
* Fix typos in comments, docs and test names (#15018)Min ho Kim2019-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * Fix typos in comments, docs and test names * Update test_pyparse.py account for change in string length * Apply suggestion: splitable -> splittable Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Apply suggestion: splitable -> splittable Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Apply suggestion: Dealloccte -> Deallocate Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Update posixmodule checksum. * Reverse idlelib changes.
* Add additional test for multi-line SyntaxError (GH-15003)Anthony Sottile2019-07-291-0/+16
|
* Fix `SyntaxError` indicator printing too many spaces for multi-line strings ↵Anthony Sottile2019-07-291-0/+14
| | | | (GH-14433)
* bpo-20443: _PyConfig_Read() gets the absolute path of run_filename (GH-14053)Victor Stinner2019-06-251-1/+13
| | | | | | | | | | | | Python now gets the absolute path of the script filename specified on the command line (ex: "python3 script.py"): the __file__ attribute of the __main__ module, sys.argv[0] and sys.path[0] become an absolute path, rather than a relative path. * Add _Py_isabs() and _Py_abspath() functions. * _PyConfig_Read() now tries to get the absolute path of run_filename, but keeps the relative path if _Py_abspath() fails. * Reimplement os._getfullpathname() using _Py_abspath(). * Use _Py_isabs() in getpath.c.
* bpo-20844: open script file with "rb" mode (GH-12616)Inada Naoki2019-04-011-0/+17
|
* bpo-34726: Fix handling of hash-based pycs in zipimport. (GH-10327)Elvis Pranskevichus2018-11-071-2/+24
| | | | | | | | Current support for hash-based bytecode files in `zipimport` is rather sparse, which leads to test failures when the test suite is ran with the ``SOURCE_DATE_EPOCH`` environment variable set. This teaches zipimport to handle hash-based pycs properly.
* bpo-32236: open() emits RuntimeWarning if buffering=1 for binary mode (GH-4842)Alexey Izbyshev2018-10-201-2/+2
| | | | | | | | | If buffering=1 is specified for open() in binary mode, it is silently treated as buffering=-1 (i.e., the default buffer size). Coupled with the fact that line buffering is always supported in Python 2, such behavior caused several issues (e.g., bpo-10344, bpo-21332). Warn that line buffering is not supported if open() is called with binary mode and buffering=1.
* bpo-34783: Fix test_nonexisting_script() (GH-9896)Victor Stinner2018-10-151-8/+1
| | | | | | Fix test_cmd_line_script.test_nonexisting_script(): the test must not rely on sys.executable, since main.c uses config->program which can be different than sys.executable in many cases (for example, on macOS when using the framework).
* bpo-34783: Disable test_nonexisting_script for macOS framework builds (GH-9831)Ned Deily2018-10-131-0/+4
| | | | | | | | | With macOS framework builds, test case test_nonexisting_script in test_nonexisting_script fails because the test case assumes that the file name in sys.executable will appear in the error message. For macOS framework builds, sys.executable is the file name of the stub launcher and its file name bears no relationship to the file name of the actual python executable. For now, skip the test in this case.
* bpo-34783: Add test_cmd_line_script.test_nonexisting_script() (GH-9535)Victor Stinner2018-09-241-0/+19
| | | | Make sure that "./python script.py" does not crash if the script file doesn't exist.
* bpo-33053: Remove test_cmd_line_script debugging print (GH-6237)Nick Coghlan2018-03-251-2/+0
| | | | I noticed this had slipped into the original commit when resolving a merge conflict for the backport to 3.7.
* bpo-33053: -m now adds *starting* directory to sys.path (GH-6231)Nick Coghlan2018-03-251-56/+48
| | | | | | | | | | | | Historically, -m added the empty string as sys.path zero, meaning it resolved imports against the current working directory, the same way -c and the interactive prompt do. This changes the sys.path initialisation to add the *starting* working directory as sys.path[0] instead, such that changes to the working directory while the program is running will have no effect on imports when using the -m switch.
* bpo-30436: Raise ModuleNotFoundError for importlib.util.find_spec() when ↵Milan Oberkirch2017-06-141-1/+1
| | | | | parent isn't a package (GH-1899) Previously AttributeError was raised, but that's not very reflective of the fact that the requested module can't be found since the specified parent isn't actually a package.
* bpo-29723: Consistently configure sys.path[0] (#575)Nick Coghlan2017-03-121-0/+67
| | | | | | | | | | | | | | | | | | | | | | Directory and zipfile execution previously added the parent directory of the directory or zipfile as sys.path[0] and then subsequently overwrote it with the directory or zipfile itself. This caused problems in isolated mode, as it overwrote the "stdlib as a zip archive" entry in sys.path, as the parent directory was never added. The attempted fix to that issue in bpo-29319 created the opposite problem in *non*-isolated mode, by potentially leaving the parent directory on sys.path instead of overwriting it. This change fixes the root cause of the problem by removing the whole "add-and-overwrite" dance for sys.path[0], and instead simply never adds the parent directory to sys.path in the first place.
* Issue #25677: Merge SyntaxError caret positioning from 3.5Martin Panter2016-12-191-0/+33
|\
| * Issue #25677: Correct syntax error caret for indented blocks.Martin Panter2016-12-111-0/+33
| | | | | | | | Based on patch by Michael Layzell.
* | Issue #15767: Use ModuleNotFoundError.Eric Snow2016-09-071-1/+1
| |
* | Issue #27487: Merge runpy warning from 3.5Martin Panter2016-08-211-3/+5
|\ \ | |/
| * Issue #27487: Warn if submodule already imported before runpy executionMartin Panter2016-08-211-3/+5
| | | | | | | | Also try to clarify the find_spec() error message.
* | Backed out changeset af29d89083b3 (closes #25548) (closes #27498)Benjamin Peterson2016-07-141-8/+1
| |
* | Issue #25548: Showing memory address of class objects in replKushal Das2016-06-041-1/+8
| |
* | Issue #26304: Merge doc wording from 3.5Martin Panter2016-02-101-1/+1
|\ \ | |/
| * Issue #26304: Change "allows to <verb>" to "allows <verb>ing" or similarMartin Panter2016-02-101-1/+1
| | | | | | | | | | The original form is incorrect grammar and feels awkward, even though the meaning is clear.
* | subprocess._optim_args_from_interpreter_flags()Victor Stinner2016-01-181-3/+2
|/ | | | | | | | | | | | Issue #26100: * Add subprocess._optim_args_from_interpreter_flags() * Add test.support.optim_args_from_interpreter_flags() * Use new functions in distutils, test_cmd_line_script, test_compileall and test_inspect The change enables test_details() test of test_inspect when -O or -OO command line option is used.
* Issue #19771: Omit irrelevant message if package could not be initializedMartin Panter2015-12-121-0/+13
|
* Issue #14285: Do not catch exceptions initializing any ancestor packageMartin Panter2015-12-101-0/+1
| | | | | | | | The previous fix only handled the case of the parent package of __main__ failing to initialize. Also make the "Error while finding spec" formatting slightly more appealing, and document and test that the module name must be absolute.
* Issue #14285: Do not catch __init__.py exceptions in runpyMartin Panter2015-12-031-9/+62
| | | | | | | | | | Initialize package before calling find_spec() for __main__, so that we do not incorrectly handle exceptions from __init__.py. When runpy is used from the Python CLI, use an internal exception rather than ImportError, to avoid catching unexpected exceptions. Also remove exception message rewriting in _run_module_as_main(), because it seems to be redundant with the _get_main_module_details() function.
* Issue #9517: Move script_helper to the support package.Berker Peksag2015-05-061-24/+23
| | | | Patch by Christie Wilson.
* Fixed bytes warnings when run tests with -vv.Serhiy Storchaka2015-03-241-5/+5
|
* Issue #21425: Fix flushing of standard streams in the interactive interpreter.Antoine Pitrou2014-05-111-0/+49
|
* Close #20500: Don't trigger PyObject_Str assertion at shutdownNick Coghlan2014-02-091-0/+18
|
* Issue #19700: set __spec__ appropriately in runpyNick Coghlan2013-12-151-1/+18
| | | | | | | | Note that __spec__.name is not currently guaranteed to be in sys.modules when the code is running, only __name__ is. The "running module is in sys.modules" invariant will be expanded to also cover __spec__.name in a subsequent patch.
* Close #18754: Run Python child processes in isolated more in the test suite.Victor Stinner2013-10-121-4/+6
|
* Close #15415: Factor out temp dir helpers to test.supportNick Coghlan2013-07-281-4/+4
| | | | Patch by Chris Jerdonek
* (Merge 3.2) Issue #16218, #16414, #16444: Backport FS_NONASCII,Victor Stinner2013-01-031-5/+4
|\ | | | | | | | | TESTFN_UNDECODABLE, TESTFN_NONASCII of test.support from Python 3.4. Backport tests on non-ASCII paths.