mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Merged revisions 68884,68973,68978,69003,69083,69112-69113 via svnmerge from
svn+ssh://pythondev@svn.python.org/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 ........
This commit is contained in:
parent
90eaaf623a
commit
c4bbc8d7dc
6 changed files with 89 additions and 37 deletions
|
@ -290,10 +290,22 @@ they should be marked simply with ``*var*``.
|
||||||
|
|
||||||
For all other roles, you have to write ``:rolename:`content```.
|
For all other roles, you have to write ``:rolename:`content```.
|
||||||
|
|
||||||
.. note::
|
There are some additional facilities that make cross-referencing roles more
|
||||||
|
versatile:
|
||||||
|
|
||||||
For all cross-referencing roles, if you prefix the content with ``!``, no
|
* You may supply an explicit title and reference target, like in reST direct
|
||||||
reference/hyperlink will be created.
|
hyperlinks: ``:role:`title <target>``` will refer to *target*, but the link
|
||||||
|
text will be *title*.
|
||||||
|
|
||||||
|
* If you prefix the content with ``!``, no reference/hyperlink will be created.
|
||||||
|
|
||||||
|
* For the Python object roles, if you prefix the content with ``~``, the link
|
||||||
|
text will only be the last component of the target. For example,
|
||||||
|
``:meth:`~Queue.Queue.get``` will refer to ``Queue.Queue.get`` but only
|
||||||
|
display ``get`` as the link text.
|
||||||
|
|
||||||
|
In HTML output, the link's ``title`` attribute (that is e.g. shown as a
|
||||||
|
tool-tip on mouse-hover) will always be the full target name.
|
||||||
|
|
||||||
The following roles refer to objects in modules and are possibly hyperlinked if
|
The following roles refer to objects in modules and are possibly hyperlinked if
|
||||||
a matching identifier is found:
|
a matching identifier is found:
|
||||||
|
|
|
@ -31,7 +31,7 @@ in the table are the size of the download files in megabytes.</p>
|
||||||
<td><a href="{{ dlbase }}/python-{{ release }}-docs-html.tar.bz2">Download</a> (ca. 4 MB)</td>
|
<td><a href="{{ dlbase }}/python-{{ release }}-docs-html.tar.bz2">Download</a> (ca. 4 MB)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td>Plain Text</td>
|
<tr><td>Plain Text</td>
|
||||||
<td><a href="{{ dlbase }}/python-docs-text.zip">Download</a> (ca. 2 MB)</td>
|
<td><a href="{{ dlbase }}/python-{{ release }}-text.zip">Download</a> (ca. 2 MB)</td>
|
||||||
<td><a href="{{ dlbase }}/python-{{ release }}-docs-text.tar.bz2">Download</a> (ca. 1.5 MB)</td>
|
<td><a href="{{ dlbase }}/python-{{ release }}-docs-text.tar.bz2">Download</a> (ca. 1.5 MB)</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -44,12 +44,18 @@ def yiq_to_rgb(y, i, q):
|
||||||
r = y + 0.948262*i + 0.624013*q
|
r = y + 0.948262*i + 0.624013*q
|
||||||
g = y - 0.276066*i - 0.639810*q
|
g = y - 0.276066*i - 0.639810*q
|
||||||
b = y - 1.105450*i + 1.729860*q
|
b = y - 1.105450*i + 1.729860*q
|
||||||
if r < 0.0: r = 0.0
|
if r < 0.0:
|
||||||
if g < 0.0: g = 0.0
|
r = 0.0
|
||||||
if b < 0.0: b = 0.0
|
if g < 0.0:
|
||||||
if r > 1.0: r = 1.0
|
g = 0.0
|
||||||
if g > 1.0: g = 1.0
|
if b < 0.0:
|
||||||
if b > 1.0: b = 1.0
|
b = 0.0
|
||||||
|
if r > 1.0:
|
||||||
|
r = 1.0
|
||||||
|
if g > 1.0:
|
||||||
|
g = 1.0
|
||||||
|
if b > 1.0:
|
||||||
|
b = 1.0
|
||||||
return (r, g, b)
|
return (r, g, b)
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,30 +69,42 @@ def rgb_to_hls(r, g, b):
|
||||||
minc = min(r, g, b)
|
minc = min(r, g, b)
|
||||||
# XXX Can optimize (maxc+minc) and (maxc-minc)
|
# XXX Can optimize (maxc+minc) and (maxc-minc)
|
||||||
l = (minc+maxc)/2.0
|
l = (minc+maxc)/2.0
|
||||||
if minc == maxc: return 0.0, l, 0.0
|
if minc == maxc:
|
||||||
if l <= 0.5: s = (maxc-minc) / (maxc+minc)
|
return 0.0, l, 0.0
|
||||||
else: s = (maxc-minc) / (2.0-maxc-minc)
|
if l <= 0.5:
|
||||||
|
s = (maxc-minc) / (maxc+minc)
|
||||||
|
else:
|
||||||
|
s = (maxc-minc) / (2.0-maxc-minc)
|
||||||
rc = (maxc-r) / (maxc-minc)
|
rc = (maxc-r) / (maxc-minc)
|
||||||
gc = (maxc-g) / (maxc-minc)
|
gc = (maxc-g) / (maxc-minc)
|
||||||
bc = (maxc-b) / (maxc-minc)
|
bc = (maxc-b) / (maxc-minc)
|
||||||
if r == maxc: h = bc-gc
|
if r == maxc:
|
||||||
elif g == maxc: h = 2.0+rc-bc
|
h = bc-gc
|
||||||
else: h = 4.0+gc-rc
|
elif g == maxc:
|
||||||
|
h = 2.0+rc-bc
|
||||||
|
else:
|
||||||
|
h = 4.0+gc-rc
|
||||||
h = (h/6.0) % 1.0
|
h = (h/6.0) % 1.0
|
||||||
return h, l, s
|
return h, l, s
|
||||||
|
|
||||||
def hls_to_rgb(h, l, s):
|
def hls_to_rgb(h, l, s):
|
||||||
if s == 0.0: return l, l, l
|
if s == 0.0:
|
||||||
if l <= 0.5: m2 = l * (1.0+s)
|
return l, l, l
|
||||||
else: m2 = l+s-(l*s)
|
if l <= 0.5:
|
||||||
|
m2 = l * (1.0+s)
|
||||||
|
else:
|
||||||
|
m2 = l+s-(l*s)
|
||||||
m1 = 2.0*l - m2
|
m1 = 2.0*l - m2
|
||||||
return (_v(m1, m2, h+ONE_THIRD), _v(m1, m2, h), _v(m1, m2, h-ONE_THIRD))
|
return (_v(m1, m2, h+ONE_THIRD), _v(m1, m2, h), _v(m1, m2, h-ONE_THIRD))
|
||||||
|
|
||||||
def _v(m1, m2, hue):
|
def _v(m1, m2, hue):
|
||||||
hue = hue % 1.0
|
hue = hue % 1.0
|
||||||
if hue < ONE_SIXTH: return m1 + (m2-m1)*hue*6.0
|
if hue < ONE_SIXTH:
|
||||||
if hue < 0.5: return m2
|
return m1 + (m2-m1)*hue*6.0
|
||||||
if hue < TWO_THIRD: return m1 + (m2-m1)*(TWO_THIRD-hue)*6.0
|
if hue < 0.5:
|
||||||
|
return m2
|
||||||
|
if hue < TWO_THIRD:
|
||||||
|
return m1 + (m2-m1)*(TWO_THIRD-hue)*6.0
|
||||||
return m1
|
return m1
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,29 +117,40 @@ def rgb_to_hsv(r, g, b):
|
||||||
maxc = max(r, g, b)
|
maxc = max(r, g, b)
|
||||||
minc = min(r, g, b)
|
minc = min(r, g, b)
|
||||||
v = maxc
|
v = maxc
|
||||||
if minc == maxc: return 0.0, 0.0, v
|
if minc == maxc:
|
||||||
|
return 0.0, 0.0, v
|
||||||
s = (maxc-minc) / maxc
|
s = (maxc-minc) / maxc
|
||||||
rc = (maxc-r) / (maxc-minc)
|
rc = (maxc-r) / (maxc-minc)
|
||||||
gc = (maxc-g) / (maxc-minc)
|
gc = (maxc-g) / (maxc-minc)
|
||||||
bc = (maxc-b) / (maxc-minc)
|
bc = (maxc-b) / (maxc-minc)
|
||||||
if r == maxc: h = bc-gc
|
if r == maxc:
|
||||||
elif g == maxc: h = 2.0+rc-bc
|
h = bc-gc
|
||||||
else: h = 4.0+gc-rc
|
elif g == maxc:
|
||||||
|
h = 2.0+rc-bc
|
||||||
|
else:
|
||||||
|
h = 4.0+gc-rc
|
||||||
h = (h/6.0) % 1.0
|
h = (h/6.0) % 1.0
|
||||||
return h, s, v
|
return h, s, v
|
||||||
|
|
||||||
def hsv_to_rgb(h, s, v):
|
def hsv_to_rgb(h, s, v):
|
||||||
if s == 0.0: return v, v, v
|
if s == 0.0:
|
||||||
|
return v, v, v
|
||||||
i = int(h*6.0) # XXX assume int() truncates!
|
i = int(h*6.0) # XXX assume int() truncates!
|
||||||
f = (h*6.0) - i
|
f = (h*6.0) - i
|
||||||
p = v*(1.0 - s)
|
p = v*(1.0 - s)
|
||||||
q = v*(1.0 - s*f)
|
q = v*(1.0 - s*f)
|
||||||
t = v*(1.0 - s*(1.0-f))
|
t = v*(1.0 - s*(1.0-f))
|
||||||
i = i%6
|
i = i%6
|
||||||
if i == 0: return v, t, p
|
if i == 0:
|
||||||
if i == 1: return q, v, p
|
return v, t, p
|
||||||
if i == 2: return p, v, t
|
if i == 1:
|
||||||
if i == 3: return p, q, v
|
return q, v, p
|
||||||
if i == 4: return t, p, v
|
if i == 2:
|
||||||
if i == 5: return v, p, q
|
return p, v, t
|
||||||
|
if i == 3:
|
||||||
|
return p, q, v
|
||||||
|
if i == 4:
|
||||||
|
return t, p, v
|
||||||
|
if i == 5:
|
||||||
|
return v, p, q
|
||||||
# Cannot get here
|
# Cannot get here
|
||||||
|
|
|
@ -403,12 +403,12 @@ def _resolve_link(path):
|
||||||
until we either arrive at something that isn't a symlink, or
|
until we either arrive at something that isn't a symlink, or
|
||||||
encounter a path we've seen before (meaning that there's a loop).
|
encounter a path we've seen before (meaning that there's a loop).
|
||||||
"""
|
"""
|
||||||
paths_seen = []
|
paths_seen = set()
|
||||||
while islink(path):
|
while islink(path):
|
||||||
if path in paths_seen:
|
if path in paths_seen:
|
||||||
# Already seen this path, so we must have a symlink loop
|
# Already seen this path, so we must have a symlink loop
|
||||||
return None
|
return None
|
||||||
paths_seen.append(path)
|
paths_seen.add(path)
|
||||||
# Resolve where the link points to
|
# Resolve where the link points to
|
||||||
resolved = os.readlink(path)
|
resolved = os.readlink(path)
|
||||||
if not isabs(resolved):
|
if not isabs(resolved):
|
||||||
|
|
|
@ -2,10 +2,19 @@
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import os
|
import os
|
||||||
|
import _tkinter
|
||||||
from test import support
|
from test import support
|
||||||
from tkinter import Tcl
|
from tkinter import Tcl
|
||||||
from _tkinter import TclError
|
from _tkinter import TclError
|
||||||
|
|
||||||
|
|
||||||
|
class TkinterTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def testFlattenLen(self):
|
||||||
|
# flatten(<object with no length>)
|
||||||
|
self.assertRaises(TypeError, _tkinter._flatten, True)
|
||||||
|
|
||||||
|
|
||||||
class TclTest(unittest.TestCase):
|
class TclTest(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -151,7 +160,7 @@ class TclTest(unittest.TestCase):
|
||||||
os.environ['DISPLAY'] = old_display
|
os.environ['DISPLAY'] = old_display
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
support.run_unittest(TclTest)
|
support.run_unittest(TclTest, TkinterTest)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
test_main()
|
||||||
|
|
|
@ -2750,7 +2750,9 @@ Tkinter_Flatten(PyObject* self, PyObject* args)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
context.maxsize = PySequence_Size(item);
|
context.maxsize = PySequence_Size(item);
|
||||||
if (context.maxsize <= 0)
|
if (context.maxsize < 0)
|
||||||
|
return NULL;
|
||||||
|
if (context.maxsize == 0)
|
||||||
return PyTuple_New(0);
|
return PyTuple_New(0);
|
||||||
|
|
||||||
context.tuple = PyTuple_New(context.maxsize);
|
context.tuple = PyTuple_New(context.maxsize);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue