Commit Graph

225 Commits

Author SHA1 Message Date
Victor Stinner 3bb09947ec
bpo-43916: Add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag (GH-25721)
Add a new Py_TPFLAGS_DISALLOW_INSTANTIATION type flag to disallow
creating type instances: set tp_new to NULL and don't create the
"__new__" key in the type dictionary.

The flag is set automatically on static types if tp_base is NULL or
&PyBaseObject_Type and tp_new is NULL.

Use the flag on the following types:

* _curses.ncurses_version type
* _curses_panel.panel
* _tkinter.Tcl_Obj
* _tkinter.tkapp
* _tkinter.tktimertoken
* _xxsubinterpretersmodule.ChannelID
* sys.flags type
* sys.getwindowsversion() type
* sys.version_info type

Update MyStr example in the C API documentation to use
Py_TPFLAGS_DISALLOW_INSTANTIATION.

Add _PyStructSequence_InitType() function to create a structseq type
with the Py_TPFLAGS_DISALLOW_INSTANTIATION flag set.

type_new() calls _PyType_CheckConsistency() at exit.
2021-04-30 12:46:15 +02:00
Serhiy Storchaka b1dc1aacf8
bpo-43084: Return bool instead of int from curses.window.enclose() (GH-24398) 2021-04-05 16:50:24 +03:00
Pablo Galindo bb739ec922
bpo-43108: Fix a reference leak in the curses module (GH-24420) 2021-02-02 20:38:26 +00:00
Hai Shi 2f12a1b7ec
bpo-41798: Allocate the _curses._C_API on the heap memory (GH-24186) 2021-01-22 11:06:43 +01:00
Zackery Spytz 14cfa325c2
bpo-39273: Expose BUTTON5_* constants in the curses module if available (GH-17996) 2021-01-14 11:40:09 +02:00
Serhiy Storchaka 59f9b4e450
bpo-42681: Fix test_curses failures related to color pairs (GH-24089)
On ncurses 6.1 pair numbers are limited by SHORT_MAX-1, even
with extended color support.

Improve error reporting and tests for color functions.
2021-01-05 09:13:15 +02:00
Serhiy Storchaka 1470edd613
bpo-42681: Fix range checks for color and pair numbers in curses (GH-23874) 2021-01-03 22:51:11 +02:00
Victor Stinner 32bd68c839
bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587)
No longer use deprecated aliases to functions:

* Replace PyObject_MALLOC() with PyObject_Malloc()
* Replace PyObject_REALLOC() with PyObject_Realloc()
* Replace PyObject_FREE() with PyObject_Free()
* Replace PyObject_Del() with PyObject_Free()
* Replace PyObject_DEL() with PyObject_Free()
2020-12-01 10:37:39 +01:00
Victor Stinner 37834136d0
bpo-42161: Modules/ uses _PyLong_GetZero() and _PyLong_GetOne() (GH-22998)
Use _PyLong_GetZero() and _PyLong_GetOne() in Modules/ directory.

_cursesmodule.c and zoneinfo.c are now built with
Py_BUILD_CORE_MODULE macro defined.
2020-10-27 17:12:53 +01:00
Hans Petter Jansson da4e09fff6
bpo-36982: Add support for extended color functions in ncurses 6.1 (GH-17536)
Co-authored-by: Jeffrey Kintscher <websurfer@surf2c.net>
2020-08-03 23:51:33 -04:00
Victor Stinner 4804b5b3df
bpo-39465: Don't access directly _Py_Identifier members (GH-20043)
* Replace id->object with _PyUnicode_FromId(&id)
* Use _Py_static_string_init(str) macro to initialize statically
  name_op in typeobject.c.
2020-05-12 01:43:38 +02:00
Serhiy Storchaka 8f87eefe7f
bpo-39943: Add the const qualifier to pointers on non-mutable PyBytes data. (GH-19472) 2020-04-12 14:58:27 +03:00
Victor Stinner 9205520d8c
bpo-40170: PyObject_NEW() becomes an alias to PyObject_New() (GH-19379)
The PyObject_NEW() macro becomes an alias to the PyObject_New()
macro, and the PyObject_NEW_VAR() macro becomes an alias to the
PyObject_NewVar() macro, to hide implementation details. They no
longer access directly the PyTypeObject.tp_basicsize member.

Exclude _PyObject_SIZE() and _PyObject_VAR_SIZE() macros from
the limited C API.

Replace PyObject_NEW() with PyObject_New() and replace
PyObject_NEW_VAR() with PyObject_NewVar().
2020-04-08 00:38:15 +02:00
Dong-hee Na 37fcbb65d4
bpo-40024: Update C extension modules to use PyModule_AddType() (GH-19119)
Update _asyncio, _bz2, _csv, _curses, _datetime,
_io, _operator, _pickle, _queue, blake2,
multibytecodec and overlapped C extension modules
to use PyModule_AddType().
2020-03-24 23:08:51 +01:00
Batuhan Taşkaya 4991cf47c4
bpo-39802: Only expose set_escdelay and set_tabsize when curses extensions are activated (GH-18705) 2020-03-03 02:00:10 +00:00
Victor Stinner daa9756cb6
bpo-39573: Use Py_TYPE() macro in Modules directory (GH-18393)
Replace direct access to PyObject.ob_type with Py_TYPE().
2020-02-07 03:37:06 +01:00
Zackery Spytz 2bc343417a bpo-36589: Fix the error handling in curses.update_lines_cols(). (GH-12766)
Return None instead of 1.
2019-11-17 19:10:13 +02:00
Anthony Sottile b32cb97bce bpo-38312: Add curses.{get,set}_escdelay and curses.{get,set}_tabsize. (GH-16938) 2019-10-31 11:13:48 +02:00
Serhiy Storchaka 279f44678c
bpo-37206: Unrepresentable default values no longer represented as None. (GH-13933)
In ArgumentClinic, value "NULL" should now be used only for unrepresentable default values
(like in the optional third parameter of getattr). "None" should be used if None is accepted
as argument and passing None has the same effect as not passing the argument at all.
2019-09-14 12:24:05 +03:00
Victor Stinner 077af8c2c9
bpo-37738: Fix curses addch(str, color_pair) (GH-15071)
Fix the implementation of curses addch(str, color_pair): pass the
color pair to setcchar(), instead of always passing 0 as the color
pair.
2019-08-14 12:31:43 +02:00
Anthony Sottile c9345e382c bpo-37695: Correct unget_wch error message. (GH-14986) 2019-07-31 15:11:24 +03:00
Jeroen Demeyer 762f93ff2e bpo-37337: Add _PyObject_CallMethodNoArgs() (GH-14267) 2019-07-08 17:19:25 +09:00
Jeroen Demeyer 530f506ac9 bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async (GH-13464)
Automatically replace
tp_print -> tp_vectorcall_offset
tp_compare -> tp_as_async
tp_reserved -> tp_as_async
2019-05-30 19:13:39 -07:00
Serhiy Storchaka d4f9cf5545
bpo-33029: Fix signatures of getter and setter functions. (GH-10746)
Fix also return type for few other functions (clear, releasebuffer).
2018-11-27 19:34:35 +02:00
Serhiy Storchaka 81524022d0
bpo-33012: Fix signatures of METH_NOARGS funstions. (GH-10736) 2018-11-27 13:05:02 +02:00
Serhiy Storchaka b232df9197
bpo-31680: Add curses.ncurses_version. (GH-4217)
Use curses.ncurses_version for conditionally skipping a test.
2018-10-30 13:22:42 +02:00
Xiang Zhang 44742e94c8
suppress compiler warnings in _cursesmodule.c (#7860) 2018-06-23 12:29:30 +08:00
Serhiy Storchaka b00854caa0
bpo-20171: Convert the _curses and _curses_panel modules to Argument Clinic. (GH-4251) 2018-05-10 11:27:23 +03:00
Srinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి) 83cb778b4a correct the typos (#4950) 2017-12-20 23:36:10 +02:00
Serhiy Storchaka e2f92de6a9
Add the const qualifier to "char *" variables that refer to literal strings. (#4370) 2017-11-11 13:06:26 +02:00
Serhiy Storchaka 4f469c0966
bpo-27666: Fixed stack corruption in curses.box() and curses.ungetmouse(). (#4220) 2017-11-01 20:48:49 +02:00
Serhiy Storchaka 7e68790f3d
bpo-15037: Add a workaround for getkey() in curses for ncurses 5.7 and earlier. (#3826)
Skip a test for unget_wch()/get_wch() on OpenBSD since they are broken
in ncurses 5.7.
2017-11-01 16:03:40 +02:00
Serhiy Storchaka 894ebd065e
bpo-31919: Fix building the curses module on OpenIndiana. (#4211) 2017-11-01 14:34:20 +02:00
Masayuki Yamamoto 8bc7d63560 bpo-25720: Fix the method for checking pad state of curses WINDOW (#4164)
Modify the code to use ncurses is_pad() instead of checking WINDOW
_flags field.  If your platform does not provide the is_pad(), the
existing way that checks the field will be enabled.

Note: This change does not drop support for platforms where do not
have both WINDOW _flags field and is_pad().
2017-11-01 14:05:26 +02:00
Serhiy Storchaka baac01e629
bpo-31891: Fix building the curses module on NetBSD. (#4165) 2017-10-31 13:56:44 +02:00
Serhiy Storchaka f7eae0adfc [security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302)
Based on patch by Victor Stinner.

Add private C API function _PyUnicode_AsUnicode() which is similar to
PyUnicode_AsUnicode(), but checks for null characters.
2017-06-28 08:30:06 +03:00
Xiang Zhang 116dd5eba6 bpo-30176: Add missing curses cell attributes constants (GH-1302) 2017-06-15 20:20:07 -07:00
Eijebong ab7886b785 bpo-30101: Add support for curses.A_ITALIC. (#1015) 2017-04-26 23:17:12 +08:00
Serhiy Storchaka 0b3ec19225 Use NULL rather than 0. (#778)
There was few cases of using literal 0 instead of NULL in the context of
pointers.  While this was a legitimate C code, using NULL rather than 0 makes
the code clearer.
2017-03-23 17:53:47 +02:00
Christian Heimes 2b221b78d6 bpo-29176 Use tmpfile() in curses module (#235)
The curses module used mkstemp() + fopen() to create a temporary file in
/tmp. The /tmp directory does not exist on Android. The tmpfile()
function simplifies the task a lot. It creates a temporary file in a
correct directory, takes care of cleanup and returns FILE*.

tmpfile is supported on all platforms (C89, POSIX 2001, Android,
Windows).

Signed-off-by: Christian Heimes <christian@python.org>
2017-03-02 11:09:01 +01:00
Victor Stinner 61e2bc74df bpo-29176: Fix name of the _curses.window class (#52)
Set name to "_curses.window" instead of "_curses.curses window" (with
a space!?).
2017-02-12 23:42:02 +01:00
Serhiy Storchaka 228b12edcc Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever
possible.  Patch is writen with Coccinelle.
2017-01-23 09:47:21 +02:00
Victor Stinner b110dad9ab Initialize variables to fix compiler warnings
Warnings seen on the "AMD64 Debian PGO 3.x" buildbot. Warnings are false
positive, but variable initialization should not harm performances.
2016-12-09 17:06:43 +01:00
Serhiy Storchaka a0d9c685d0 Issue #28549: Fixed segfault in curses's addch() with ncurses6. 2016-10-30 22:53:09 +02:00
Serhiy Storchaka 0bcd89b859 Issue #28549: Fixed segfault in curses's addch() with ncurses6. 2016-10-30 22:52:06 +02:00
Serhiy Storchaka 802426f99b Issue #28526: Use PyUnicode_AsEncodedString() instead of
PyUnicode_AsEncodedObject() in _curese to ensure that the result
is a bytes object.
2016-10-27 19:33:05 +03:00
Serhiy Storchaka b29cee40ee Issue #28526: Use PyUnicode_AsEncodedString() instead of
PyUnicode_AsEncodedObject() in _curese to ensure that the result
is a bytes object.
2016-10-27 19:31:49 +03:00
Victor Stinner 3466bde1cc Avoid calling functions with an empty string as format string
Directly pass NULL rather than an empty string.
2016-09-05 18:16:01 -07:00
Benjamin Peterson b1c6bdc76a merge 3.4 2016-08-15 21:43:57 -07:00
Benjamin Peterson 432ea4ff37 fail when negative values are passed to instr() 2016-08-15 21:40:14 -07:00