Compare commits

...

7 Commits

Author SHA1 Message Date
Miss Islington (bot) 3966e2ea41
bpo-42655: Fix subprocess extra_groups gid conversion (GH-23762)
(cherry picked from commit 0159e5efee)

Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
2020-12-29 05:22:13 -08:00
Miss Islington (bot) cc7f745e80
bpo-42700: Swap descriptions in pyexpat.errors (GH-23876)
The descriptions of the `codes` and `messages` dictionaries in
`xml.parsers.expat.errors` were swapped, and this commit swaps them
back. For example, `codes` maps string descriptions of errors to numeric
error codes, not the other way around.
(cherry picked from commit 84402eb110)

Co-authored-by: Michael Wayne Goodman <goodman.m.w@gmail.com>
2020-12-29 04:55:33 -08:00
Miss Islington (bot) df794406a8
Allow / character in username,password fields in _PROXY envvars. (GH-23973)
(cherry picked from commit 030a713183)

Co-authored-by: Senthil Kumaran <senthil@uthcode.com>
2020-12-29 04:46:05 -08:00
Miss Islington (bot) 1ceb097cec
[doc] Fix missing commas in signatures (GH-23693)
* Fix star in signatures

* Fix comma in signatures
(cherry picked from commit 60eccd0956)

Co-authored-by: Andre Delfino <adelfino@gmail.com>
2020-12-29 04:28:58 -08:00
Miss Islington (bot) 71d73900eb
bpo-16396: fix BPO number in changelog (GH-23951) (GH-23956)
Automerge-Triggered-By: GH:jaraco
(cherry picked from commit 7865f516f3)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2020-12-29 13:52:12 +02:00
Miss Islington (bot) 578caafabe
bpo-42759: Fix equality comparison of Variable and Font in Tkinter (GH-23968)
Objects which belong to different Tcl interpreters are now always
different, even if they have the same name.
(cherry picked from commit 1df56bc059)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-12-29 03:18:26 -08:00
Miss Islington (bot) 7bdb3e0825
bpo-42749: Use dynamic version to test for unsupported bignum in Tk (GH-23966)
Tk can internally support bignum even if Tkinter is built without
support of bignum.
(cherry picked from commit 156b7f7052)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-12-29 03:17:43 -08:00
17 changed files with 58 additions and 31 deletions

View File

@ -1219,7 +1219,7 @@ Instance methods:
.. method:: datetime.replace(year=self.year, month=self.month, day=self.day, \
hour=self.hour, minute=self.minute, second=self.second, microsecond=self.microsecond, \
tzinfo=self.tzinfo, * fold=0)
tzinfo=self.tzinfo, *, fold=0)
Return a datetime with the same attributes, except for those attributes given
new values by whichever keyword arguments are specified. Note that
@ -1783,7 +1783,7 @@ Other constructor:
Instance methods:
.. method:: time.replace(hour=self.hour, minute=self.minute, second=self.second, \
microsecond=self.microsecond, tzinfo=self.tzinfo, * fold=0)
microsecond=self.microsecond, tzinfo=self.tzinfo, *, fold=0)
Return a :class:`.time` with the same value, except for those attributes given
new values by whichever keyword arguments are specified. Note that

View File

@ -116,7 +116,7 @@ Currently the email package provides only one concrete content manager,
decoding the payload to unicode. The default error handler is
``replace``.
.. method:: set_content(msg, <'str'>, subtype="plain", charset='utf-8' \
.. method:: set_content(msg, <'str'>, subtype="plain", charset='utf-8', \
cte=None, \
disposition=None, filename=None, cid=None, \
params=None, headers=None)

View File

@ -665,14 +665,14 @@ The ``errors`` module has the following attributes:
.. data:: codes
A dictionary mapping numeric error codes to their string descriptions.
A dictionary mapping string descriptions to their error codes.
.. versionadded:: 3.2
.. data:: messages
A dictionary mapping string descriptions to their error codes.
A dictionary mapping numeric error codes to their string descriptions.
.. versionadded:: 3.2

View File

@ -447,7 +447,7 @@ class TclTest(unittest.TestCase):
else:
self.assertEqual(result, str(i))
self.assertIsInstance(result, str)
if tcl_version < (8, 5): # bignum was added in Tcl 8.5
if get_tk_patchlevel() < (8, 5): # bignum was added in Tcl 8.5
self.assertRaises(TclError, tcl.call, 'expr', str(2**1000))
def test_passing_values(self):

View File

@ -1849,9 +1849,17 @@ class MiscTests(unittest.TestCase):
('ftp', 'joe', 'password', 'proxy.example.com')),
# Test for no trailing '/' case
('http://joe:password@proxy.example.com',
('http', 'joe', 'password', 'proxy.example.com'))
('http', 'joe', 'password', 'proxy.example.com')),
# Testcases with '/' character in username, password
('http://user/name:password@localhost:22',
('http', 'user/name', 'password', 'localhost:22')),
('http://username:pass/word@localhost:22',
('http', 'username', 'pass/word', 'localhost:22')),
('http://user/name:pass/word@localhost:22',
('http', 'user/name', 'pass/word', 'localhost:22')),
]
for tc, expected in parse_proxy_test_cases:
self.assertEqual(_parse_proxy(tc), expected)

View File

@ -491,15 +491,11 @@ class Variable:
self._tk.call("trace", "vinfo", self._name))]
def __eq__(self, other):
"""Comparison for equality (==).
Note: if the Variable's master matters to behavior
also compare self._master == other._master
"""
if not isinstance(other, Variable):
return NotImplemented
return self.__class__.__name__ == other.__class__.__name__ \
and self._name == other._name
return (self._name == other._name
and self.__class__.__name__ == other.__class__.__name__
and self._tk == other._tk)
class StringVar(Variable):

View File

@ -103,7 +103,7 @@ class Font:
def __eq__(self, other):
if not isinstance(other, Font):
return NotImplemented
return self.name == other.name
return self.name == other.name and self._tk == other._tk
def __getitem__(self, key):
return self.cget(key)

View File

@ -63,15 +63,22 @@ class FontTest(AbstractTkTest, unittest.TestCase):
self.assertEqual(self.font.name, fontname)
self.assertEqual(str(self.font), fontname)
def test_eq(self):
def test_equality(self):
font1 = font.Font(root=self.root, name=fontname, exists=True)
font2 = font.Font(root=self.root, name=fontname, exists=True)
self.assertIsNot(font1, font2)
self.assertEqual(font1, font2)
self.assertNotEqual(font1, font1.copy())
self.assertNotEqual(font1, 0)
self.assertEqual(font1, ALWAYS_EQ)
root2 = tkinter.Tk()
self.addCleanup(root2.destroy)
font3 = font.Font(root=root2, name=fontname, exists=True)
self.assertEqual(str(font1), str(font3))
self.assertNotEqual(font1, font3)
def test_measure(self):
self.assertIsInstance(self.font.measure('abc'), int)

View File

@ -58,22 +58,32 @@ class TestVariable(TestBase):
del v2
self.assertFalse(self.info_exists("name"))
def test___eq__(self):
def test_equality(self):
# values doesn't matter, only class and name are checked
v1 = Variable(self.root, name="abc")
v2 = Variable(self.root, name="abc")
self.assertIsNot(v1, v2)
self.assertEqual(v1, v2)
v3 = StringVar(self.root, name="abc")
v3 = Variable(self.root, name="cba")
self.assertNotEqual(v1, v3)
v4 = StringVar(self.root, name="abc")
self.assertEqual(str(v1), str(v4))
self.assertNotEqual(v1, v4)
V = type('Variable', (), {})
self.assertNotEqual(v1, V())
self.assertNotEqual(v1, object())
self.assertEqual(v1, ALWAYS_EQ)
root2 = tkinter.Tk()
self.addCleanup(root2.destroy)
v5 = Variable(root2, name="abc")
self.assertEqual(str(v1), str(v5))
self.assertNotEqual(v1, v5)
def test_invalid_name(self):
with self.assertRaises(TypeError):
Variable(self.root, name=123)

View File

@ -771,7 +771,11 @@ def _parse_proxy(proxy):
raise ValueError("proxy URL with no authority: %r" % proxy)
# We have an authority, so for RFC 3986-compliant URLs (by ss 3.
# and 3.3.), path is empty or starts with '/'
end = r_scheme.find("/", 2)
if '@' in r_scheme:
host_separator = r_scheme.find('@')
end = r_scheme.find("/", host_separator)
else:
end = r_scheme.find("/", 2)
if end == -1:
end = None
authority = r_scheme[2:end]

View File

@ -475,7 +475,7 @@ compression header.
..
.. bpo: 16936
.. bpo: 16396
.. date: 2020-07-08-09-45-00
.. nonce: z8o8Pn
.. section: Library

View File

@ -0,0 +1,2 @@
:mod:`subprocess` *extra_groups* is now correctly passed into setgroups()
system call.

View File

@ -0,0 +1 @@
Allow / character in username, password fields on _PROXY envars.

View File

@ -0,0 +1,3 @@
Fixed equality comparison of :class:`tkinter.Variable` and
:class:`tkinter.font.Font`. Objects which belong to different Tcl
interpreters are now always different, even if they have the same name.

View File

@ -753,7 +753,7 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
if (groups_list != Py_None) {
#ifdef HAVE_SETGROUPS
Py_ssize_t i;
unsigned long gid;
gid_t gid;
if (!PyList_Check(groups_list)) {
PyErr_SetString(PyExc_TypeError,
@ -787,10 +787,6 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
Py_DECREF(elem);
goto cleanup;
} else {
/* In posixmodule.c UnsignedLong is used as a fallback value
* if the value provided does not fit in a Long. Since we are
* already doing the bounds checking on the Python side, we
* can go directly to an UnsignedLong here. */
if (!_Py_Gid_Converter(elem, &gid)) {
Py_DECREF(elem);
PyErr_SetString(PyExc_ValueError, "invalid group id");

View File

@ -632,7 +632,7 @@ _PyLong_FromGid(gid_t gid)
}
int
_Py_Uid_Converter(PyObject *obj, void *p)
_Py_Uid_Converter(PyObject *obj, uid_t *p)
{
uid_t uid;
PyObject *index;
@ -719,7 +719,7 @@ _Py_Uid_Converter(PyObject *obj, void *p)
success:
Py_DECREF(index);
*(uid_t *)p = uid;
*p = uid;
return 1;
underflow:
@ -738,7 +738,7 @@ fail:
}
int
_Py_Gid_Converter(PyObject *obj, void *p)
_Py_Gid_Converter(PyObject *obj, gid_t *p)
{
gid_t gid;
PyObject *index;
@ -826,7 +826,7 @@ _Py_Gid_Converter(PyObject *obj, void *p)
success:
Py_DECREF(index);
*(gid_t *)p = gid;
*p = gid;
return 1;
underflow:

View File

@ -14,8 +14,8 @@ extern "C" {
#ifndef MS_WINDOWS
PyAPI_FUNC(PyObject *) _PyLong_FromUid(uid_t);
PyAPI_FUNC(PyObject *) _PyLong_FromGid(gid_t);
PyAPI_FUNC(int) _Py_Uid_Converter(PyObject *, void *);
PyAPI_FUNC(int) _Py_Gid_Converter(PyObject *, void *);
PyAPI_FUNC(int) _Py_Uid_Converter(PyObject *, uid_t *);
PyAPI_FUNC(int) _Py_Gid_Converter(PyObject *, gid_t *);
#endif /* MS_WINDOWS */
#if defined(PYPTHREAD_SIGMASK) || defined(HAVE_SIGWAIT) || \