Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c4bbc8d

Browse files
committed
Merged revisions 68884,68973,68978,69003,69083,69112-69113 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r68884 | kristjan.jonsson | 2009-01-24 04:52:26 -0600 (Sat, 24 Jan 2009) | 1 line Add a test for UNC import paths, see issue 3677 ........ r68973 | georg.brandl | 2009-01-26 15:29:38 -0600 (Mon, 26 Jan 2009) | 2 lines Copy over docs on advanced role features from Sphinx docs. ........ r68978 | mark.dickinson | 2009-01-26 15:51:56 -0600 (Mon, 26 Jan 2009) | 3 lines Issue #5073: Fix occasional failure of bsddb/test/test_lock.py. Thanks Hirokazu Yamamoto for the patch. ........ r69003 | benjamin.peterson | 2009-01-26 21:07:53 -0600 (Mon, 26 Jan 2009) | 1 line excellent place to use a set() #5069 ........ r69083 | benjamin.peterson | 2009-01-28 21:03:00 -0600 (Wed, 28 Jan 2009) | 1 line fix download url ........ r69112 | benjamin.peterson | 2009-01-29 20:02:25 -0600 (Thu, 29 Jan 2009) | 1 line pep8tify conditionals ........ r69113 | benjamin.peterson | 2009-01-29 20:24:39 -0600 (Thu, 29 Jan 2009) | 1 line make _tkinter._flatten check the result of PySequence_Size for errors #3880 ........
1 parent 90eaaf6 commit c4bbc8d

6 files changed

Lines changed: 89 additions & 37 deletions

File tree

Doc/documenting/markup.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,22 @@ they should be marked simply with ``*var*``.
290290

291291
For all other roles, you have to write ``:rolename:`content```.
292292

293-
.. note::
293+
There are some additional facilities that make cross-referencing roles more
294+
versatile:
295+
296+
* You may supply an explicit title and reference target, like in reST direct
297+
hyperlinks: ``:role:`title <target>``` will refer to *target*, but the link
298+
text will be *title*.
299+
300+
* If you prefix the content with ``!``, no reference/hyperlink will be created.
301+
302+
* For the Python object roles, if you prefix the content with ``~``, the link
303+
text will only be the last component of the target. For example,
304+
``:meth:`~Queue.Queue.get``` will refer to ``Queue.Queue.get`` but only
305+
display ``get`` as the link text.
294306

295-
For all cross-referencing roles, if you prefix the content with ``!``, no
296-
reference/hyperlink will be created.
307+
In HTML output, the link's ``title`` attribute (that is e.g. shown as a
308+
tool-tip on mouse-hover) will always be the full target name.
297309

298310
The following roles refer to objects in modules and are possibly hyperlinked if
299311
a matching identifier is found:

Doc/tools/sphinxext/download.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h1>Download Python {{ release }} Documentation</h1>
3131
<td><a href="{{ dlbase }}/python-{{ release }}-docs-html.tar.bz2">Download</a> (ca. 4 MB)</td>
3232
</tr>
3333
<tr><td>Plain Text</td>
34-
<td><a href="{{ dlbase }}/python-docs-text.zip">Download</a> (ca. 2 MB)</td>
34+
<td><a href="{{ dlbase }}/python-{{ release }}-text.zip">Download</a> (ca. 2 MB)</td>
3535
<td><a href="{{ dlbase }}/python-{{ release }}-docs-text.tar.bz2">Download</a> (ca. 1.5 MB)</td>
3636
</tr>
3737
</table>

Lib/colorsys.py

Lines changed: 58 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,18 @@ def yiq_to_rgb(y, i, q):
4444
r = y + 0.948262*i + 0.624013*q
4545
g = y - 0.276066*i - 0.639810*q
4646
b = y - 1.105450*i + 1.729860*q
47-
if r < 0.0: r = 0.0
48-
if g < 0.0: g = 0.0
49-
if b < 0.0: b = 0.0
50-
if r > 1.0: r = 1.0
51-
if g > 1.0: g = 1.0
52-
if b > 1.0: b = 1.0
47+
if r < 0.0:
48+
r = 0.0
49+
if g < 0.0:
50+
g = 0.0
51+
if b < 0.0:
52+
b = 0.0
53+
if r > 1.0:
54+
r = 1.0
55+
if g > 1.0:
56+
g = 1.0
57+
if b > 1.0:
58+
b = 1.0
5359
return (r, g, b)
5460

5561

@@ -63,30 +69,42 @@ def rgb_to_hls(r, g, b):
6369
minc = min(r, g, b)
6470
# XXX Can optimize (maxc+minc) and (maxc-minc)
6571
l = (minc+maxc)/2.0
66-
if minc == maxc: return 0.0, l, 0.0
67-
if l <= 0.5: s = (maxc-minc) / (maxc+minc)
68-
else: s = (maxc-minc) / (2.0-maxc-minc)
72+
if minc == maxc:
73+
return 0.0, l, 0.0
74+
if l <= 0.5:
75+
s = (maxc-minc) / (maxc+minc)
76+
else:
77+
s = (maxc-minc) / (2.0-maxc-minc)
6978
rc = (maxc-r) / (maxc-minc)
7079
gc = (maxc-g) / (maxc-minc)
7180
bc = (maxc-b) / (maxc-minc)
72-
if r == maxc: h = bc-gc
73-
elif g == maxc: h = 2.0+rc-bc
74-
else: h = 4.0+gc-rc
81+
if r == maxc:
82+
h = bc-gc
83+
elif g == maxc:
84+
h = 2.0+rc-bc
85+
else:
86+
h = 4.0+gc-rc
7587
h = (h/6.0) % 1.0
7688
return h, l, s
7789

7890
def hls_to_rgb(h, l, s):
79-
if s == 0.0: return l, l, l
80-
if l <= 0.5: m2 = l * (1.0+s)
81-
else: m2 = l+s-(l*s)
91+
if s == 0.0:
92+
return l, l, l
93+
if l <= 0.5:
94+
m2 = l * (1.0+s)
95+
else:
96+
m2 = l+s-(l*s)
8297
m1 = 2.0*l - m2
8398
return (_v(m1, m2, h+ONE_THIRD), _v(m1, m2, h), _v(m1, m2, h-ONE_THIRD))
8499

85100
def _v(m1, m2, hue):
86101
hue = hue % 1.0
87-
if hue < ONE_SIXTH: return m1 + (m2-m1)*hue*6.0
88-
if hue < 0.5: return m2
89-
if hue < TWO_THIRD: return m1 + (m2-m1)*(TWO_THIRD-hue)*6.0
102+
if hue < ONE_SIXTH:
103+
return m1 + (m2-m1)*hue*6.0
104+
if hue < 0.5:
105+
return m2
106+
if hue < TWO_THIRD:
107+
return m1 + (m2-m1)*(TWO_THIRD-hue)*6.0
90108
return m1
91109

92110

@@ -99,29 +117,40 @@ def rgb_to_hsv(r, g, b):
99117
maxc = max(r, g, b)
100118
minc = min(r, g, b)
101119
v = maxc
102-
if minc == maxc: return 0.0, 0.0, v
120+
if minc == maxc:
121+
return 0.0, 0.0, v
103122
s = (maxc-minc) / maxc
104123
rc = (maxc-r) / (maxc-minc)
105124
gc = (maxc-g) / (maxc-minc)
106125
bc = (maxc-b) / (maxc-minc)
107-
if r == maxc: h = bc-gc
108-
elif g == maxc: h = 2.0+rc-bc
109-
else: h = 4.0+gc-rc
126+
if r == maxc:
127+
h = bc-gc
128+
elif g == maxc:
129+
h = 2.0+rc-bc
130+
else:
131+
h = 4.0+gc-rc
110132
h = (h/6.0) % 1.0
111133
return h, s, v
112134

113135
def hsv_to_rgb(h, s, v):
114-
if s == 0.0: return v, v, v
136+
if s == 0.0:
137+
return v, v, v
115138
i = int(h*6.0) # XXX assume int() truncates!
116139
f = (h*6.0) - i
117140
p = v*(1.0 - s)
118141
q = v*(1.0 - s*f)
119142
t = v*(1.0 - s*(1.0-f))
120143
i = i%6
121-
if i == 0: return v, t, p
122-
if i == 1: return q, v, p
123-
if i == 2: return p, v, t
124-
if i == 3: return p, q, v
125-
if i == 4: return t, p, v
126-
if i == 5: return v, p, q
144+
if i == 0:
145+
return v, t, p
146+
if i == 1:
147+
return q, v, p
148+
if i == 2:
149+
return p, v, t
150+
if i == 3:
151+
return p, q, v
152+
if i == 4:
153+
return t, p, v
154+
if i == 5:
155+
return v, p, q
127156
# Cannot get here

Lib/posixpath.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,12 @@ def _resolve_link(path):
403403
until we either arrive at something that isn't a symlink, or
404404
encounter a path we've seen before (meaning that there's a loop).
405405
"""
406-
paths_seen = []
406+
paths_seen = set()
407407
while islink(path):
408408
if path in paths_seen:
409409
# Already seen this path, so we must have a symlink loop
410410
return None
411-
paths_seen.append(path)
411+
paths_seen.add(path)
412412
# Resolve where the link points to
413413
resolved = os.readlink(path)
414414
if not isabs(resolved):

Lib/test/test_tcl.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22

33
import unittest
44
import os
5+
import _tkinter
56
from test import support
67
from tkinter import Tcl
78
from _tkinter import TclError
89

10+
11+
class TkinterTest(unittest.TestCase):
12+
13+
def testFlattenLen(self):
14+
# flatten(<object with no length>)
15+
self.assertRaises(TypeError, _tkinter._flatten, True)
16+
17+
918
class TclTest(unittest.TestCase):
1019

1120
def setUp(self):
@@ -151,7 +160,7 @@ def testLoadTkFailure(self):
151160
os.environ['DISPLAY'] = old_display
152161

153162
def test_main():
154-
support.run_unittest(TclTest)
163+
support.run_unittest(TclTest, TkinterTest)
155164

156165
if __name__ == "__main__":
157166
test_main()

Modules/_tkinter.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2750,7 +2750,9 @@ Tkinter_Flatten(PyObject* self, PyObject* args)
27502750
return NULL;
27512751

27522752
context.maxsize = PySequence_Size(item);
2753-
if (context.maxsize <= 0)
2753+
if (context.maxsize < 0)
2754+
return NULL;
2755+
if (context.maxsize == 0)
27542756
return PyTuple_New(0);
27552757

27562758
context.tuple = PyTuple_New(context.maxsize);

0 commit comments

Comments
 (0)