File Doc/library/pathlib.rst changed (mode: 100644) (index 34ab3b8edf..1445226447) |
... |
... |
property: |
271 |
271 |
Methods and properties |
Methods and properties |
272 |
272 |
^^^^^^^^^^^^^^^^^^^^^^ |
^^^^^^^^^^^^^^^^^^^^^^ |
273 |
273 |
|
|
|
274 |
|
.. testsetup:: |
|
275 |
|
|
|
276 |
|
from pathlib import PurePosixPath, PureWindowsPath |
|
277 |
|
|
274 |
278 |
Pure paths provide the following methods and properties: |
Pure paths provide the following methods and properties: |
275 |
279 |
|
|
276 |
280 |
.. data:: PurePath.drive |
.. data:: PurePath.drive |
|
... |
... |
call fails (for example because the path doesn't exist): |
657 |
661 |
Return information about this path (similarly to :func:`os.stat`). |
Return information about this path (similarly to :func:`os.stat`). |
658 |
662 |
The result is looked up at each call to this method. |
The result is looked up at each call to this method. |
659 |
663 |
|
|
|
664 |
|
:: |
|
665 |
|
|
660 |
666 |
>>> p = Path('setup.py') |
>>> p = Path('setup.py') |
661 |
667 |
>>> p.stat().st_size |
>>> p.stat().st_size |
662 |
668 |
956 |
956 |
|
... |
... |
call fails (for example because the path doesn't exist): |
948 |
954 |
.. method:: Path.rglob(pattern) |
.. method:: Path.rglob(pattern) |
949 |
955 |
|
|
950 |
956 |
This is like calling :meth:`Path.glob` with "``**``" added in front of the |
This is like calling :meth:`Path.glob` with "``**``" added in front of the |
951 |
|
given *pattern*: |
|
|
957 |
|
given *pattern*:: |
952 |
958 |
|
|
953 |
959 |
>>> sorted(Path().rglob("*.py")) |
>>> sorted(Path().rglob("*.py")) |
954 |
960 |
[PosixPath('build/lib/pathlib.py'), |
[PosixPath('build/lib/pathlib.py'), |
|
... |
... |
call fails (for example because the path doesn't exist): |
972 |
978 |
An :exc:`OSError` can be raised if either file cannot be accessed for some |
An :exc:`OSError` can be raised if either file cannot be accessed for some |
973 |
979 |
reason. |
reason. |
974 |
980 |
|
|
|
981 |
|
:: |
|
982 |
|
|
975 |
983 |
>>> p = Path('spam') |
>>> p = Path('spam') |
976 |
984 |
>>> q = Path('eggs') |
>>> q = Path('eggs') |
977 |
985 |
>>> p.samefile(q) |
>>> p.samefile(q) |
|
... |
... |
call fails (for example because the path doesn't exist): |
988 |
996 |
*target_is_directory* must be true (default ``False``) if the link's target |
*target_is_directory* must be true (default ``False``) if the link's target |
989 |
997 |
is a directory. Under POSIX, *target_is_directory*'s value is ignored. |
is a directory. Under POSIX, *target_is_directory*'s value is ignored. |
990 |
998 |
|
|
|
999 |
|
:: |
|
1000 |
|
|
991 |
1001 |
>>> p = Path('mylink') |
>>> p = Path('mylink') |
992 |
1002 |
>>> p.symlink_to('setup.py') |
>>> p.symlink_to('setup.py') |
993 |
1003 |
>>> p.resolve() |
>>> p.resolve() |
File Doc/library/ssl.rst changed (mode: 100644) (index bbb13745b2..e3945191f5) |
... |
... |
Random generation |
369 |
369 |
Certificate handling |
Certificate handling |
370 |
370 |
^^^^^^^^^^^^^^^^^^^^ |
^^^^^^^^^^^^^^^^^^^^ |
371 |
371 |
|
|
|
372 |
|
.. testsetup:: |
|
373 |
|
|
|
374 |
|
import ssl |
|
375 |
|
|
372 |
376 |
.. function:: match_hostname(cert, hostname) |
.. function:: match_hostname(cert, hostname) |
373 |
377 |
|
|
374 |
378 |
Verify that *cert* (in decoded format as returned by |
Verify that *cert* (in decoded format as returned by |
|
... |
... |
Certificate handling |
415 |
419 |
|
|
416 |
420 |
>>> import ssl |
>>> import ssl |
417 |
421 |
>>> timestamp = ssl.cert_time_to_seconds("Jan 5 09:34:43 2018 GMT") |
>>> timestamp = ssl.cert_time_to_seconds("Jan 5 09:34:43 2018 GMT") |
418 |
|
>>> timestamp |
|
|
422 |
|
>>> timestamp # doctest: +SKIP |
419 |
423 |
1515144883 |
1515144883 |
420 |
424 |
>>> from datetime import datetime |
>>> from datetime import datetime |
421 |
|
>>> print(datetime.utcfromtimestamp(timestamp)) |
|
|
425 |
|
>>> print(datetime.utcfromtimestamp(timestamp)) # doctest: +SKIP |
422 |
426 |
2018-01-05 09:34:43 |
2018-01-05 09:34:43 |
423 |
427 |
|
|
424 |
428 |
"notBefore" or "notAfter" dates must use GMT (:rfc:`5280`). |
"notBefore" or "notAfter" dates must use GMT (:rfc:`5280`). |
|
... |
... |
to speed up repeated connections from the same clients. |
1378 |
1382 |
'strength_bits': 128}] |
'strength_bits': 128}] |
1379 |
1383 |
|
|
1380 |
1384 |
On OpenSSL 1.1 and newer the cipher dict contains additional fields:: |
On OpenSSL 1.1 and newer the cipher dict contains additional fields:: |
|
1385 |
|
|
1381 |
1386 |
>>> ctx.get_ciphers() # OpenSSL 1.1+ |
>>> ctx.get_ciphers() # OpenSSL 1.1+ |
1382 |
1387 |
[{'aead': True, |
[{'aead': True, |
1383 |
1388 |
'alg_bits': 256, |
'alg_bits': 256, |
|
... |
... |
to speed up repeated connections from the same clients. |
1638 |
1643 |
.. versionchanged:: 3.6 |
.. versionchanged:: 3.6 |
1639 |
1644 |
:attr:`SSLContext.options` returns :class:`Options` flags: |
:attr:`SSLContext.options` returns :class:`Options` flags: |
1640 |
1645 |
|
|
1641 |
|
>>> ssl.create_default_context().options |
|
|
1646 |
|
>>> ssl.create_default_context().options # doctest: +SKIP |
1642 |
1647 |
<Options.OP_ALL|OP_NO_SSLv3|OP_NO_SSLv2|OP_NO_COMPRESSION: 2197947391> |
<Options.OP_ALL|OP_NO_SSLv3|OP_NO_SSLv2|OP_NO_COMPRESSION: 2197947391> |
1643 |
1648 |
|
|
1644 |
1649 |
.. attribute:: SSLContext.protocol |
.. attribute:: SSLContext.protocol |
|
... |
... |
to speed up repeated connections from the same clients. |
1658 |
1663 |
.. versionchanged:: 3.6 |
.. versionchanged:: 3.6 |
1659 |
1664 |
:attr:`SSLContext.verify_flags` returns :class:`VerifyFlags` flags: |
:attr:`SSLContext.verify_flags` returns :class:`VerifyFlags` flags: |
1660 |
1665 |
|
|
1661 |
|
>>> ssl.create_default_context().verify_flags |
|
|
1666 |
|
>>> ssl.create_default_context().verify_flags # doctest: +SKIP |
1662 |
1667 |
<VerifyFlags.VERIFY_X509_TRUSTED_FIRST: 32768> |
<VerifyFlags.VERIFY_X509_TRUSTED_FIRST: 32768> |
1663 |
1668 |
|
|
1664 |
1669 |
.. attribute:: SSLContext.verify_mode |
.. attribute:: SSLContext.verify_mode |
|
... |
... |
recommended to use :const:`PROTOCOL_TLS_CLIENT` or |
2259 |
2264 |
:const:`PROTOCOL_TLS_SERVER` as the protocol version. SSLv2 and SSLv3 are |
:const:`PROTOCOL_TLS_SERVER` as the protocol version. SSLv2 and SSLv3 are |
2260 |
2265 |
disabled by default. |
disabled by default. |
2261 |
2266 |
|
|
|
2267 |
|
:: |
|
2268 |
|
|
2262 |
2269 |
>>> client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) |
>>> client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) |
2263 |
2270 |
>>> client_context.options |= ssl.OP_NO_TLSv1 |
>>> client_context.options |= ssl.OP_NO_TLSv1 |
2264 |
2271 |
>>> client_context.options |= ssl.OP_NO_TLSv1_1 |
>>> client_context.options |= ssl.OP_NO_TLSv1_1 |
File Doc/library/weakref.rst changed (mode: 100644) (index b02a006d73..40bb06adfd) |
... |
... |
the constructor when it was created. |
478 |
478 |
>>> obj = Object() |
>>> obj = Object() |
479 |
479 |
>>> f = weakref.finalize(obj, callback, 1, 2, z=3) |
>>> f = weakref.finalize(obj, callback, 1, 2, z=3) |
480 |
480 |
>>> f.detach() #doctest:+ELLIPSIS |
>>> f.detach() #doctest:+ELLIPSIS |
481 |
|
(<__main__.Object object ...>, <function callback ...>, (1, 2), {'z': 3}) |
|
|
481 |
|
(<...Object object ...>, <function callback ...>, (1, 2), {'z': 3}) |
482 |
482 |
>>> newobj, func, args, kwargs = _ |
>>> newobj, func, args, kwargs = _ |
483 |
483 |
>>> assert not f.alive |
>>> assert not f.alive |
484 |
484 |
>>> assert newobj is obj |
>>> assert newobj is obj |