◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
2 changes: 2 additions & 0 deletions Lib/ctypes/test/test_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def test_load_library(self):
windll["kernel32"].GetModuleHandleW
windll.LoadLibrary("kernel32").GetModuleHandleW
WinDLL("kernel32").GetModuleHandleW

@unittest.skipUnless(os.name == "nt",
'test specific to Windows')
Expand Down
11 changes: 10 additions & 1 deletion Lib/test/test_curses.py
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ def test_window_funcs(self):
win2 = curses.newwin(15,15, 5,5)

for meth in [stdscr.addch, stdscr.addstr]:
for args in [('a'), ('a', curses.A_BOLD),
(4,4, 'a'), (5,5, 'a', curses.A_BOLD)]:
with self.subTest(meth=meth.__qualname__, args=args):
meth(*args)
Expand Down Expand Up @@ -194,6 +194,15 @@ def test_window_funcs(self):
self.assertRaises(ValueError, stdscr.instr, -2)
self.assertRaises(ValueError, stdscr.instr, 2, 3, -2)


def test_module_funcs(self):
"Test module-level functions"
2 changes: 2 additions & 0 deletions Lib/test/test_grp.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def test_errors(self):
self.assertRaises(TypeError, grp.getgrgid)
self.assertRaises(TypeError, grp.getgrnam)
self.assertRaises(TypeError, grp.getgrall, 42)

# try to get some errors
bynames = {}
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ def test_multiple_calls_to_get_data(self):
loader.get_data(imp.__file__) # File should be closed
loader.get_data(imp.__file__) # Will need to create a newly opened file


class ReloadTests(unittest.TestCase):

Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,14 @@ def test_strcoll(self):
self.assertLess(locale.strcoll('a', 'b'), 0)
self.assertEqual(locale.strcoll('a', 'a'), 0)
self.assertGreater(locale.strcoll('b', 'a'), 0)

def test_strxfrm(self):
self.assertLess(locale.strxfrm('a'), locale.strxfrm('b'))


class TestEnUSCollation(BaseLocalizedTest, TestCollation):
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ def test_strftime(self):
except ValueError:
self.fail('conversion specifier: %r failed.' % format)

def _bounds_checking(self, func):
# Make sure that strftime() checks the bounds of the various parts
# of the time tuple (0 is valid for *all* values).
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_winsound.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def test_errors(self):
self.assertRaises(TypeError, winsound.PlaySound, "bad",
winsound.SND_MEMORY)
self.assertRaises(TypeError, winsound.PlaySound, 1, 0)

def test_keyword_args(self):
safe_PlaySound(flags=winsound.SND_ALIAS, sound="SystemExit")
Expand Down
5 changes: 3 additions & 2 deletions Modules/_ctypes/callproc.c
Original file line number Diff line number Diff line change
@@ -1253,10 +1253,11 @@ static PyObject *load_library(PyObject *self, PyObject *args)
PyObject *nameobj;
PyObject *ignored;
HMODULE hMod;
if (!PyArg_ParseTuple(args, "O|O:LoadLibrary", &nameobj, &ignored))
return NULL;

name = PyUnicode_AsUnicode(nameobj);
if (!name)
return NULL;

Expand Down
10 changes: 10 additions & 0 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,11 @@ static int
PyCurses_ConvertToString(PyCursesWindowObject *win, PyObject *obj,
PyObject **bytes, wchar_t **wstr)
{
if (PyUnicode_Check(obj)) {
#ifdef HAVE_NCURSESW
assert (wstr != NULL);
*wstr = PyUnicode_AsWideCharString(obj, NULL);
if (*wstr == NULL)
return 0;
Expand All @@ -353,12 +355,20 @@ PyCurses_ConvertToString(PyCursesWindowObject *win, PyObject *obj,
*bytes = PyUnicode_AsEncodedString(obj, win->encoding, NULL);
if (*bytes == NULL)
return 0;
return 1;
#endif
}
else if (PyBytes_Check(obj)) {
Py_INCREF(obj);
*bytes = obj;
return 1;
}

Expand Down
5 changes: 5 additions & 0 deletions Modules/_localemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
s = PyUnicode_AsWideCharString(str, &n1);
if (s == NULL)
goto exit;

/* assume no change in size, first */
n1 = n1 + 1;
Expand Down
1 change: 1 addition & 0 deletions Modules/nismodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ nis_match (PyObject *self, PyObject *args, PyObject *kwdict)
return NULL;
if ((bkey = PyUnicode_EncodeFSDefault(ukey)) == NULL)
return NULL;
if (PyBytes_AsStringAndSize(bkey, &key, &keylen) == -1) {
Py_DECREF(bkey);
return NULL;
Expand Down
18 changes: 12 additions & 6 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
@@ -3757,7 +3757,7 @@ os__getfinalpathname_impl(PyObject *module, PyObject *path)
PyObject *result;
const wchar_t *path_wchar;

path_wchar = PyUnicode_AsUnicode(path);
if (path_wchar == NULL)
return NULL;

Expand Down Expand Up @@ -7209,7 +7209,7 @@ win_readlink(PyObject *self, PyObject *args, PyObject *kwargs)
))
return NULL;

path = PyUnicode_AsUnicode(po);
if (path == NULL)
return NULL;

Expand Down Expand Up @@ -9002,6 +9002,7 @@ os_putenv_impl(PyObject *module, PyObject *name, PyObject *value)
/*[clinic end generated code: output=d29a567d6b2327d2 input=ba586581c2e6105f]*/
{
const wchar_t *env;

/* Search from index 1 because on Windows starting '=' is allowed for
defining hidden environment variables. */
Expand All @@ -9015,16 +9016,21 @@ os_putenv_impl(PyObject *module, PyObject *name, PyObject *value)
if (unicode == NULL) {
return NULL;
}
if (_MAX_ENV < PyUnicode_GET_LENGTH(unicode)) {
PyErr_Format(PyExc_ValueError,
"the environment variable is longer than %u characters",
_MAX_ENV);
goto error;
}

env = PyUnicode_AsUnicode(unicode);
if (env == NULL)
goto error;
if (_wputenv(env)) {
posix_error();
goto error;
14 changes: 14 additions & 0 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -4133,6 +4133,20 @@ PyUnicode_AsUnicode(PyObject *unicode)
return PyUnicode_AsUnicodeAndSize(unicode, NULL);
}


Py_ssize_t
PyUnicode_GetSize(PyObject *unicode)
Expand Down
Loading
Toggle all file notes Toggle all file annotations