Commit Graph

190 Commits

Author SHA1 Message Date
Zackery Spytz 99d56b5356 bpo-35441: Remove dead and buggy code related to PyList_SetItem(). (GH-11033)
In _localemodule.c and selectmodule.c, remove dead code that would
cause double decrefs if run.

In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases
where a new list is populated and there is no possibility of an error.

In addition, check if the list changed size in the loop in array_array_fromlist().
2018-12-08 16:16:55 +02:00
Victor Stinner 1600f60414
Fix compiler warning in call_readline() (GH-10820)
Replace strncpy() with memcpy() in call_readline() to fix the
following warning, the NUL byte is written manually just after:

Modules/readline.c: In function ‘call_readline’:
Modules/readline.c:1303:9: warning: ‘strncpy’ output truncated before
terminating nul copying as many bytes from a string as its length
[-Wstringop-truncation]
         strncpy(p, q, n);
         ^~~~~~~~~~~~~~~~
Modules/readline.c:1279:9: note: length computed here
     n = strlen(p);
         ^~~~~~~~~
2018-11-30 15:03:53 +01:00
Zvezdan Petkovic c2f082e9d1 bpo-13631: Fix the order of initialization for readline libedit on macOS. (GH-6915)
The editline emulation needs to be initialized *after* the name is
defined. This fixes the long open issue.
2018-05-17 02:45:10 -04:00
Victor Stinner 7ed7aead95
bpo-29240: Fix locale encodings in UTF-8 Mode (#5170)
Modify locale.localeconv(), time.tzname, os.strerror() and other
functions to ignore the UTF-8 Mode: always use the current locale
encoding.

Changes:

* Add _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx(). On decoding or
  encoding error, they return the position of the error and an error
  message which are used to raise Unicode errors in
  PyUnicode_DecodeLocale() and PyUnicode_EncodeLocale().
* Replace _Py_DecodeCurrentLocale() with _Py_DecodeLocaleEx().
* PyUnicode_DecodeLocale() now uses _Py_DecodeLocaleEx() for all
  cases, especially for the strict error handler.
* Add _Py_DecodeUTF8Ex(): return more information on decoding error
  and supports the strict error handler.
* Rename _Py_EncodeUTF8_surrogateescape() to _Py_EncodeUTF8Ex().
* Replace _Py_EncodeCurrentLocale() with _Py_EncodeLocaleEx().
* Ignore the UTF-8 mode to encode/decode localeconv(), strerror()
  and time zone name.
* Remove PyUnicode_DecodeLocale(), PyUnicode_DecodeLocaleAndSize()
  and PyUnicode_EncodeLocale() now ignore the UTF-8 mode: always use
  the "current" locale.
* Remove _PyUnicode_DecodeCurrentLocale(),
  _PyUnicode_DecodeCurrentLocaleAndSize() and
  _PyUnicode_EncodeCurrentLocale().
2018-01-15 10:45:49 +01:00
Victor Stinner cb3ae5588b
bpo-29240: Ignore UTF-8 Mode in time module (#5148)
time.strftime() must use the current LC_CTYPE encoding, not UTF-8
if the UTF-8 mode is enabled.

Add _PyUnicode_DecodeCurrentLocale() function.
2018-01-11 10:37:59 +01:00
Victor Stinner 2cba6b8579
bpo-29240: readline now ignores the UTF-8 Mode (#5145)
Add new fuctions ignoring the UTF-8 mode:

* _Py_DecodeCurrentLocale()
* _Py_EncodeCurrentLocale()
* _PyUnicode_DecodeCurrentLocaleAndSize()
* _PyUnicode_EncodeCurrentLocale()

Modify the readline module to use these functions.

Re-enable test_readline.test_nonascii().
2018-01-10 22:46:15 +01:00
Victor Stinner 0efc0249ca
Fix CID-1414686: PyInit_readline() handles errors (#4647)
Handle PyModule_AddIntConstant() and PyModule_AddStringConstant()
failures. Add also constants before calling setup_readline(), since
setup_readline() registers callbacks which uses a reference to the
module, whereas the module is destroyed if adding constants fails.

Fix Coverity warning:

CID 1414686: Unchecked return value (CHECKED_RETURN)
2. check_return: Calling PyModule_AddStringConstant without checking
return value (as is done elsewhere 45 out of 55 times).
2017-11-30 17:21:07 +01:00
xdegaye 1588be66d7
bpo-28180: Fix the implementation of PEP 538 on Android (GH-4334) 2017-11-12 12:45:59 +01:00
Antoine Pitrou a6a4dc816d bpo-31370: Remove support for threads-less builds (#3385)
* Remove Setup.config
* Always define WITH_THREAD for compatibility.
2017-09-07 18:56:24 +02:00
Antoine Pitrou f474c5a3f3 bpo-30946: Remove obsolete fallback code in readline module (#2738)
* Remove obsolete fallback code in readline module

* Add NEWS

* Remove obsolete include

* Fix macro on Windows
2017-07-18 17:05:03 +02:00
Victor Stinner 1881befb90 bpo-29854: test_readline logs versions (#2619)
* test_readline logs the versions of libreadline when run in verbose
  mode
* Add also readline._READLINE_LIBRARY_VERSION
2017-07-07 16:06:58 +02:00
Nir Soffer fae8f4a9cb bpo-29854: Fix segfault in call_readline() (GH-728)
If history-length is set in .inputrc, and the history file is double the
history size (or more), history_get(N) returns NULL, and python
segfaults. Fix that by checking for NULL return value.

It seems that the root cause is incorrect handling of bigger history in
readline, but Python should not segfault even if readline returns
unexpected value.

This issue affects only GNU readline. When using libedit emulation
system history size option does not work.
2017-07-07 09:10:46 +03:00
Serhiy Storchaka 55fe1ae970 bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
Victor Stinner 4778eab1f2 Replace PyObject_CallFunction() with fastcall
Replace
    PyObject_CallFunction(func, "O", arg)
and
    PyObject_CallFunction(func, "O", arg, NULL)
with
    _PyObject_CallArg1(func, arg)

Replace
    PyObject_CallFunction(func, NULL)
with
    _PyObject_CallNoArg(func)

_PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate
memory on the C stack.
2016-12-01 14:51:04 +01:00
Benjamin Peterson 9d1e4a54f7 merge 3.5 2016-09-05 18:26:26 -07:00
Benjamin Peterson 1bb0c0bd30 explicitly cast away constness to silence compiler warning 2016-09-05 18:26:19 -07:00
Martin Panter aac9b71632 Issue #19884: Merge Readline updates from 3.5 2016-08-27 04:03:26 +00:00
Martin Panter c427b8d517 Issue #19884: Avoid spurious output on OS X with Gnu Readline
Also adjust the test condition, because enable-meta-key was only added in
6.1, not 6.0.
2016-08-27 03:23:11 +00:00
Martin Panter 4074f93b33 Issue #16182: Merge readline locale fix from 3.5 2016-06-14 02:47:56 +00:00
Martin Panter f00c49df10 Issue #16182: Fix readline begidx, endidx, and use locale encoding
Based on patch by Serhiy Storchaka.
2016-06-14 01:16:16 +00:00
Martin Panter 0b7d84de6b Issue #27171: Merge typo fixes from 3.5 2016-06-02 10:11:18 +00:00
Martin Panter e26da7c03a Issue #27171: Fix typos in documentation, comments, and test function names 2016-06-02 10:07:09 +00:00
Martin Panter f0dbf7a6ab Issue #26870: Add readline.set_auto_history(), originally by Tyler Crompton 2016-05-15 01:26:25 +00:00
Serhiy Storchaka ec39756960 Issue #22570: Renamed Py_SETREF to Py_XSETREF. 2016-04-06 09:50:03 +03:00
Martin Panter b15c304984 Issue #6953: Merge readline doc from 3.5 2016-04-05 10:17:38 +00:00
Martin Panter 0f7673943a Issue #6953: Rearrange and expand Readline module documentation
* Group functions into six new subsections
* Document the underlying Readline function or variable accessed
* get_history_length() returns the history file limit
* clear_history() is conditionally compiled in
* Clarify zero and one bases for history item indexes
* parse_and_bind() uses its argument directly as an init line
* Change "command line" to "line buffer" for consistency
* read_init_file() also executes the file
* read_history_file() replaces the previous history
* write_history_file() overwrites any existing file
* Differentiate history file lines from history list items, which could be
  multi-line
* Add more information about completion, also addressing Issue #10796
* libedit (Editline) may be used on any platform; detection is OS X specific
2016-04-05 07:37:22 +00:00
Martin Panter 9ad764601b Issue #23735: Merge sighandler_t fix from 3.5 2016-04-03 08:04:35 +00:00
Martin Panter 28f35b24b6 Issue #23735: Avoid sighandler_t Gnu-ism 2016-04-03 08:00:49 +00:00
Martin Panter a3506005b3 Issue #23735: Merge Readline resize handling from 3.5 2016-04-03 03:19:27 +00:00
Martin Panter 5dbbf1abba Issue #23735: Add SIGWINCH handler for Readline 6.3+ support, by Eric Price 2016-04-03 02:54:58 +00:00
Martin Panter 0b2d71bc70 Issue #24266: Merge readline Ctrl+C handling from 3.5 2016-03-22 09:28:58 +00:00
Martin Panter d6990d221b Issue #24266: Cancel history search mode with Ctrl+C in Readline 7 2016-03-22 07:24:05 +00:00
Martin Panter 12eb2ab490 Issue #15699: Merge readline fixup from 3.5 2016-03-22 02:26:18 +00:00
Martin Panter f6e9f47aa7 Issue #15699: Reunite comment with variable 2016-03-22 02:19:29 +00:00
Serhiy Storchaka 576f132b98 Issue #20440: Cleaning up the code by using Py_SETREF. 2016-01-05 21:27:54 +02:00
Martin Panter e56a919100 Issue #25523: Merge a-to-an corrections from 3.5 2015-11-02 04:27:17 +00:00
Martin Panter 2eb819f7a8 Issue #25523: Merge "a" to "an" fixes from 3.4 into 3.5 2015-11-02 04:04:57 +00:00
Martin Panter 7462b64911 Issue #25523: Correct "a" article to "an" article
This changes the main documentation, doc strings, source code comments, and a
couple error messages in the test suite. In some cases the word was removed
or edited some other way to fix the grammar.
2015-11-02 03:37:02 +00:00
Serhiy Storchaka a6c5d53eec Issue #25203: Failed readline.set_completer_delims() no longer left the
module in inconsistent state.
2015-09-27 22:38:33 +03:00
Serhiy Storchaka 36aff2db4a Issue #25203: Failed readline.set_completer_delims() no longer left the
module in inconsistent state.
2015-09-27 22:38:01 +03:00
Serhiy Storchaka 1138439376 Issue #25203: Failed readline.set_completer_delims() no longer left the
module in inconsistent state.
2015-09-27 22:34:59 +03:00
Serhiy Storchaka 56f6e76c68 Issue #15989: Fixed some scarcely probable integer overflows.
It is very unlikely that they can occur in real code for now.
2015-09-06 21:25:30 +03:00
Benjamin Peterson fc9d6f600e merge 3.4 (#24058) 2015-04-26 15:56:23 -04:00
Benjamin Peterson 0c6a5d1deb remove extern definition, since it's in a header file (closes #24058) 2015-04-26 15:55:06 -04:00
Ned Deily 8007cbc4d5 Issue 22940: fixes to editline support 2014-11-26 13:02:33 -08:00
Benjamin Peterson d1e22ba7db only support append_history if readline has it 2014-11-26 14:35:12 -06:00
Benjamin Peterson 33f8f15bdd add readline.append_history_file (closes #22940)
patch by "bru"
2014-11-26 13:58:16 -06:00
Antoine Pitrou 7e8b8678f1 Issue #22773: fix failing test with old readline versions due to issue #19884. 2014-11-04 14:52:10 +01:00
Victor Stinner 92639cce35 Issue #19884, readline: calling rl_variable_bind ("enable-meta-key", "off")
does crash on Mac OS X which uses libedit instead of readline.
2014-07-24 22:11:38 +02:00
Victor Stinner a3c80ce8b7 Issue #19884: readline: Disable the meta modifier key if stdout is not a
terminal to not write the ANSI sequence "\033[1034h" into stdout. This sequence
is used on some terminal (ex: TERM=xterm-256color") to enable support of 8 bit
characters.
2014-07-24 12:23:56 +02:00