From 566da35ce4f937e4e9c35d70a42c37a174d70f38 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 17 Feb 2025 21:17:56 +0100 Subject: [PATCH 01/11] Regenerate all po files to bring up-to-date with cpython 3.12 --- Makefile | 2 +- about.po | 34 +- bugs.po | 64 +- c-api/abstract.po | 9 +- c-api/allocation.po | 37 +- c-api/apiabiversion.po | 3 +- c-api/arg.po | 489 +- c-api/bool.po | 3 +- c-api/buffer.po | 311 +- c-api/bytearray.po | 33 +- c-api/bytes.po | 7 +- c-api/call.po | 90 +- c-api/capsule.po | 19 +- c-api/cell.po | 22 +- c-api/code.po | 34 +- c-api/codec.po | 21 +- c-api/complex.po | 107 +- c-api/concrete.po | 3 +- c-api/contextvars.po | 23 +- c-api/conversion.po | 23 +- c-api/coro.po | 3 +- c-api/datetime.po | 31 +- c-api/descriptor.po | 3 +- c-api/dict.po | 134 +- c-api/exceptions.po | 902 ++-- c-api/file.po | 59 +- c-api/float.po | 64 +- c-api/frame.po | 11 +- c-api/function.po | 90 +- c-api/gcsupport.po | 98 +- c-api/gen.po | 7 +- c-api/hash.po | 3 +- c-api/import.po | 115 +- c-api/index.po | 9 +- c-api/init.po | 1308 ++--- c-api/init_config.po | 567 +- c-api/intro.po | 483 +- c-api/iter.po | 34 +- c-api/iterator.po | 11 +- c-api/list.po | 16 +- c-api/long.po | 98 +- c-api/mapping.po | 35 +- c-api/marshal.po | 9 +- c-api/memory.po | 186 +- c-api/memoryview.po | 10 +- c-api/method.po | 9 +- c-api/module.po | 434 +- c-api/none.po | 3 +- c-api/number.po | 31 +- c-api/objbuffer.po | 18 +- c-api/object.po | 269 +- c-api/objimpl.po | 3 +- c-api/perfmaps.po | 23 +- c-api/refcounting.po | 49 +- c-api/reflection.po | 7 +- c-api/sequence.po | 34 +- c-api/set.po | 67 +- c-api/slice.po | 82 +- c-api/stable.po | 96 +- c-api/structures.po | 184 +- c-api/sys.po | 127 +- c-api/tuple.po | 157 +- c-api/type.po | 342 +- c-api/typehints.po | 31 +- c-api/typeobj.po | 1988 ++++--- c-api/unicode.po | 816 +-- c-api/utilities.po | 3 +- c-api/veryhigh.po | 79 +- c-api/weakref.po | 7 +- contents.po | 2 +- copyright.po | 2 +- cpython | 2 +- deprecations/c-api-pending-removal-in-3.14.po | 178 + deprecations/c-api-pending-removal-in-3.15.po | 79 + .../c-api-pending-removal-in-future.po | 139 + deprecations/index.po | 1225 +++++ deprecations/pending-removal-in-3.13.po | 188 + deprecations/pending-removal-in-3.14.po | 216 + deprecations/pending-removal-in-3.15.po | 128 + deprecations/pending-removal-in-3.16.po | 49 + deprecations/pending-removal-in-future.po | 371 ++ dictionaries/main.txt | 3 + distributing/index.po | 2 +- extending/building.po | 21 +- extending/embedding.po | 272 +- extending/extending.po | 856 ++- extending/index.po | 20 +- extending/newtypes.po | 540 +- extending/newtypes_tutorial.po | 1347 ++++- extending/windows.po | 40 +- faq/design.po | 317 +- faq/extending.po | 254 +- faq/general.po | 171 +- faq/gui.po | 8 +- faq/index.po | 3 +- faq/installed.po | 3 +- faq/library.po | 437 +- faq/programming.po | 1560 +++++- faq/windows.po | 154 +- glossary.po | 1546 +++--- howto/annotations.po | 108 +- howto/argparse-optparse.po | 119 + howto/argparse.po | 696 ++- howto/clinic.po | 3 +- howto/cporting.po | 3 +- howto/curses.po | 465 +- howto/descriptor.po | 1124 +++- howto/enum.po | 1719 ++++-- howto/functional.po | 946 +++- howto/gdb_helpers.po | 405 +- howto/index.po | 103 +- howto/instrumentation.po | 271 +- howto/ipaddress.po | 200 +- howto/isolating-extensions.po | 260 +- howto/logging-cookbook.po | 3791 ++++++++++++-- howto/logging.po | 943 ++-- howto/mro.po | 904 ++++ howto/perf_profiling.po | 181 +- howto/pyporting.po | 10 +- howto/regex.po | 609 ++- howto/sockets.po | 89 +- howto/sorting.po | 204 +- howto/unicode.po | 323 +- howto/urllib2.po | 321 +- installing/index.po | 55 +- library/2to3.po | 146 +- library/__future__.po | 43 +- library/__main__.po | 216 +- library/_thread.po | 86 +- library/abc.po | 200 +- library/aifc.po | 38 +- library/allos.po | 3 +- library/archiving.po | 7 +- library/argparse.po | 2474 ++++++--- library/array.po | 71 +- library/ast.po | 2108 +++++++- library/asynchat.po | 38 + library/asyncio-api-index.po | 3 +- library/asyncio-dev.po | 179 +- library/asyncio-eventloop.po | 1221 +++-- library/asyncio-exceptions.po | 3 +- library/asyncio-extending.po | 20 +- library/asyncio-future.po | 104 +- library/asyncio-llapi-index.po | 49 +- library/asyncio-platforms.po | 41 +- library/asyncio-policy.po | 89 +- library/asyncio-protocol.po | 451 +- library/asyncio-queue.po | 113 +- library/asyncio-runner.po | 58 +- library/asyncio-stream.po | 228 +- library/asyncio-subprocess.po | 125 +- library/asyncio-sync.po | 275 +- library/asyncio-task.po | 1040 +++- library/asyncio.po | 67 +- library/asyncore.po | 38 + library/atexit.po | 68 +- library/audioop.po | 44 +- library/audit_events.po | 9 +- library/base64.po | 47 +- library/bdb.po | 233 +- library/binary.po | 3 +- library/binascii.po | 26 +- library/bisect.po | 117 +- library/builtins.po | 56 +- library/bz2.po | 38 +- library/calendar.po | 429 +- library/cgi.po | 265 +- library/cgitb.po | 21 +- library/chunk.po | 33 +- library/cmath.po | 158 +- library/cmd.po | 236 +- library/cmdline.po | 3 +- library/code.po | 41 +- library/codecs.po | 238 +- library/codeop.po | 15 +- library/collections.abc.po | 480 +- library/collections.po | 705 ++- library/colorsys.po | 20 +- library/compileall.po | 67 +- library/concurrency.po | 3 +- library/concurrent.futures.po | 254 +- library/concurrent.po | 3 +- library/configparser.po | 1009 +++- library/constants.po | 44 +- library/contextlib.po | 918 +++- library/contextvars.po | 126 +- library/copy.po | 19 +- library/copyreg.po | 10 +- library/crypt.po | 57 +- library/crypto.po | 3 +- library/csv.po | 386 +- library/ctypes.po | 2249 +++++--- library/curses.ascii.po | 13 +- library/curses.panel.po | 5 +- library/curses.po | 170 +- library/custominterp.po | 3 +- library/dataclasses.po | 1032 ++-- library/datatypes.po | 12 +- library/datetime.po | 2508 +++++---- library/dbm.po | 123 +- library/debug.po | 3 +- library/decimal.po | 1293 +++-- library/development.po | 3 +- library/devmode.po | 133 +- library/dialog.po | 3 +- library/difflib.po | 298 +- library/dis.po | 702 ++- library/distribution.po | 3 +- library/distutils.po | 36 + library/doctest.po | 793 ++- library/email.charset.po | 41 +- library/email.compat32-message.po | 566 +- library/email.contentmanager.po | 113 +- library/email.encoders.po | 47 +- library/email.errors.po | 158 +- library/email.examples.po | 400 +- library/email.generator.po | 158 +- library/email.header.po | 69 +- library/email.headerregistry.po | 134 +- library/email.iterators.po | 38 +- library/email.message.po | 281 +- library/email.mime.po | 174 +- library/email.parser.po | 169 +- library/email.po | 107 +- library/email.policy.po | 334 +- library/email.utils.po | 160 +- library/ensurepip.po | 23 +- library/enum.po | 600 ++- library/errno.po | 189 +- library/exceptions.po | 629 ++- library/faulthandler.po | 154 +- library/fcntl.po | 91 +- library/filecmp.po | 29 +- library/fileformats.po | 3 +- library/fileinput.po | 79 +- library/filesys.po | 7 +- library/fnmatch.po | 67 +- library/fractions.po | 117 +- library/frameworks.po | 3 +- library/ftplib.po | 118 +- library/functional.po | 3 +- library/functions.po | 2307 +++++---- library/functools.po | 546 +- library/gc.po | 70 +- library/getopt.po | 109 +- library/getpass.po | 25 +- library/gettext.po | 234 +- library/glob.po | 91 +- library/graphlib.po | 131 +- library/grp.po | 17 +- library/gzip.po | 142 +- library/hashlib.po | 215 +- library/heapq.po | 207 +- library/hmac.po | 29 +- library/html.entities.po | 14 +- library/html.parser.po | 181 +- library/html.po | 15 +- library/http.client.po | 183 +- library/http.cookiejar.po | 226 +- library/http.cookies.po | 109 +- library/http.po | 63 +- library/http.server.po | 131 +- library/i18n.po | 3 +- library/idle.po | 683 +-- library/imaplib.po | 123 +- library/imghdr.po | 17 +- library/imp.po | 40 + library/importlib.metadata.po | 556 +- library/importlib.po | 1092 ++-- library/importlib.resources.abc.po | 105 +- library/importlib.resources.po | 54 +- library/index.po | 3 +- library/inspect.po | 1145 ++-- library/internet.po | 8 +- library/intro.po | 12 +- library/io.po | 401 +- library/ipaddress.po | 488 +- library/ipc.po | 9 +- library/itertools.po | 1112 +++- library/json.po | 744 ++- library/keyword.po | 14 +- library/language.po | 3 +- library/linecache.po | 30 +- library/locale.po | 233 +- library/logging.config.po | 559 +- library/logging.handlers.po | 273 +- library/logging.po | 1098 ++-- library/lzma.po | 172 +- library/mailbox.po | 363 +- library/mailcap.po | 29 +- library/markup.po | 3 +- library/marshal.po | 42 +- library/math.po | 346 +- library/mimetypes.po | 66 +- library/mm.po | 3 +- library/mmap.po | 120 +- library/modulefinder.po | 58 +- library/modules.po | 3 +- library/msilib.po | 95 +- library/msvcrt.po | 16 +- library/multiprocessing.po | 2793 +++++++--- library/multiprocessing.shared_memory.po | 169 +- library/netdata.po | 3 +- library/netrc.po | 57 +- library/nis.po | 15 +- library/nntplib.po | 207 +- library/numbers.po | 173 +- library/numeric.po | 7 +- library/operator.po | 77 +- library/optparse.po | 1117 +++- library/os.path.po | 283 +- library/os.po | 2407 ++++----- library/ossaudiodev.po | 102 +- library/pathlib.po | 1839 +++++-- library/pdb.po | 342 +- library/persistence.po | 3 +- library/pickle.po | 719 ++- library/pickletools.po | 26 +- library/pipes.po | 19 +- library/pkgutil.po | 184 +- library/platform.po | 36 +- library/plistlib.po | 57 +- library/poplib.po | 65 +- library/posix.po | 58 +- library/pprint.po | 355 +- library/profile.po | 228 +- library/pty.po | 41 +- library/pwd.po | 9 +- library/py_compile.po | 25 +- library/pyclbr.po | 7 +- library/pydoc.po | 78 +- library/pyexpat.po | 242 +- library/python.po | 3 +- library/queue.po | 85 +- library/quopri.po | 19 +- library/random.po | 277 +- library/re.po | 1199 +++-- library/readline.po | 223 +- library/removed.po | 27 + library/reprlib.po | 117 +- library/resource.po | 87 +- library/rlcompleter.po | 32 +- library/runpy.po | 57 +- library/sched.po | 36 +- library/secrets.po | 71 +- library/security_warnings.po | 13 +- library/select.po | 126 +- library/selectors.po | 101 +- library/shelve.po | 100 +- library/shlex.po | 144 +- library/shutil.po | 419 +- library/signal.po | 286 +- library/site.po | 294 +- library/smtpd.po | 40 + library/smtplib.po | 229 +- library/sndhdr.po | 49 +- library/socket.po | 1310 +++-- library/socketserver.po | 453 +- library/spwd.po | 13 +- library/sqlite3.po | 1909 ++++--- library/ssl.po | 1548 ++++-- library/stat.po | 67 +- library/statistics.po | 813 ++- library/stdtypes.po | 4599 +++++++++++------ library/string.po | 752 ++- library/stringprep.po | 15 +- library/struct.po | 152 +- library/subprocess.po | 1150 +++-- library/sunau.po | 33 +- library/superseded.po | 3 +- library/symtable.po | 87 +- library/sys.monitoring.po | 96 +- library/sys.po | 1014 ++-- library/sys_path_init.po | 53 +- library/sysconfig.po | 129 +- library/syslog.po | 72 +- library/tabnanny.po | 9 +- library/tarfile.po | 379 +- library/telnetlib.po | 58 +- library/tempfile.po | 116 +- library/termios.po | 46 +- library/test.po | 463 +- library/text.po | 3 +- library/textwrap.po | 132 +- library/threading.po | 641 ++- library/time.po | 671 +-- library/timeit.po | 171 +- library/tk.po | 13 +- library/tkinter.colorchooser.po | 9 +- library/tkinter.dnd.po | 10 +- library/tkinter.font.po | 11 +- library/tkinter.messagebox.po | 39 +- library/tkinter.po | 451 +- library/tkinter.scrolledtext.po | 11 +- library/tkinter.tix.po | 135 +- library/tkinter.ttk.po | 247 +- library/token.po | 26 +- library/tokenize.po | 234 +- library/tomllib.po | 59 +- library/trace.po | 51 +- library/traceback.po | 592 ++- library/tracemalloc.po | 342 +- library/tty.po | 22 +- library/turtle.po | 1090 +++- library/types.po | 263 +- library/typing.po | 3549 +++++++++---- library/unicodedata.po | 21 +- library/unittest.mock-examples.po | 420 +- library/unittest.mock.po | 1921 ++++--- library/unittest.po | 1250 +++-- library/unix.po | 3 +- library/urllib.error.po | 26 +- library/urllib.parse.po | 507 +- library/urllib.po | 5 +- library/urllib.request.po | 1090 ++-- library/urllib.robotparser.po | 29 +- library/uu.po | 5 +- library/uuid.po | 105 +- library/venv.po | 657 ++- library/warnings.po | 333 +- library/wave.po | 45 +- library/weakref.po | 269 +- library/webbrowser.po | 177 +- library/windows.po | 3 +- library/winreg.po | 117 +- library/winsound.po | 34 +- library/wsgiref.po | 370 +- library/xdrlib.po | 57 +- library/xml.dom.minidom.po | 165 +- library/xml.dom.po | 157 +- library/xml.dom.pulldom.po | 68 +- library/xml.etree.elementtree.po | 817 ++- library/xml.po | 48 +- library/xml.sax.handler.po | 37 +- library/xml.sax.po | 72 +- library/xml.sax.reader.po | 75 +- library/xml.sax.utils.po | 30 +- library/xmlrpc.client.po | 271 +- library/xmlrpc.po | 11 +- library/xmlrpc.server.po | 246 +- library/zipapp.po | 79 +- library/zipfile.po | 192 +- library/zipimport.po | 73 +- library/zlib.po | 61 +- library/zoneinfo.po | 173 +- license.po | 1220 ++++- reference/compound_stmts.po | 1527 ++++-- reference/datamodel.po | 3251 +++++++----- reference/executionmodel.po | 390 +- reference/expressions.po | 1614 +++--- reference/grammar.po | 1737 ++++++- reference/import.po | 950 ++-- reference/index.po | 3 +- reference/introduction.po | 29 +- reference/lexical_analysis.po | 824 +-- reference/simple_stmts.po | 692 ++- reference/toplevel_components.po | 11 +- requirements.txt | 10 +- sphinx.po | 399 +- tutorial/appendix.po | 88 +- tutorial/appetite.po | 3 +- tutorial/classes.po | 779 ++- tutorial/controlflow.po | 1136 +++- tutorial/datastructures.po | 504 +- tutorial/errors.po | 587 ++- tutorial/floatingpoint.po | 258 +- tutorial/index.po | 22 +- tutorial/inputoutput.po | 616 ++- tutorial/interactive.po | 34 +- tutorial/interpreter.po | 97 +- tutorial/introduction.po | 574 +- tutorial/modules.po | 461 +- tutorial/stdlib.po | 277 +- tutorial/stdlib2.po | 366 +- tutorial/venv.po | 145 +- tutorial/whatnow.po | 6 +- using/cmdline.po | 586 ++- using/configure.po | 560 +- using/editors.po | 30 +- using/index.po | 3 +- using/mac.po | 122 +- using/unix.po | 180 +- using/windows.po | 319 +- whatsnew/2.0.po | 439 +- whatsnew/2.1.po | 370 +- whatsnew/2.2.po | 894 ++-- whatsnew/2.3.po | 1158 ++++- whatsnew/2.4.po | 883 +++- whatsnew/2.5.po | 1264 +++-- whatsnew/2.6.po | 1824 +++++-- whatsnew/2.7.po | 1847 ++++--- whatsnew/3.0.po | 419 +- whatsnew/3.1.po | 260 +- whatsnew/3.10.po | 1330 +++-- whatsnew/3.11.po | 2400 +++++---- whatsnew/3.12.po | 3161 +++++++---- whatsnew/3.2.po | 1585 ++++-- whatsnew/3.3.po | 2130 ++++---- whatsnew/3.4.po | 2065 ++++---- whatsnew/3.5.po | 1409 +++-- whatsnew/3.6.po | 1113 ++-- whatsnew/3.7.po | 1174 +++-- whatsnew/3.8.po | 1363 +++-- whatsnew/3.9.po | 1469 +++--- whatsnew/changelog.po | 5 +- whatsnew/index.po | 10 +- 506 files changed, 124890 insertions(+), 53790 deletions(-) create mode 100644 deprecations/c-api-pending-removal-in-3.14.po create mode 100644 deprecations/c-api-pending-removal-in-3.15.po create mode 100644 deprecations/c-api-pending-removal-in-future.po create mode 100644 deprecations/index.po create mode 100644 deprecations/pending-removal-in-3.13.po create mode 100644 deprecations/pending-removal-in-3.14.po create mode 100644 deprecations/pending-removal-in-3.15.po create mode 100644 deprecations/pending-removal-in-3.16.po create mode 100644 deprecations/pending-removal-in-future.po create mode 100644 howto/argparse-optparse.po create mode 100644 howto/mro.po create mode 100644 library/asynchat.po create mode 100644 library/asyncore.po create mode 100644 library/distutils.po create mode 100644 library/imp.po create mode 100644 library/removed.po create mode 100644 library/smtpd.po diff --git a/Makefile b/Makefile index b06e5906..7f63354c 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ # from which we generated our po files. We use it here so when we # test build, we're building with the .rst files that generated our # .po files. -CPYTHON_CURRENT_COMMIT := 9cbde7c6ce6f7b93301a37f03dfa0c0d45e00a39 +CPYTHON_CURRENT_COMMIT := 0274115585db8e26d9d1c0218fe65e5041c70f2c CPYTHON_PATH := ./cpython diff --git a/about.po b/about.po index 1d3d5584..9353a65f 100644 --- a/about.po +++ b/about.po @@ -8,28 +8,32 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-03-31 19:50+0000\n" "Last-Translator: Theofanis Petkos \n" "Language-Team: PyGreece \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: about.rst:3 -msgid "About these documents" +#, fuzzy +msgid "About this documentation" msgstr "Σχετικά με τα έγγραφα" #: about.rst:6 +#, fuzzy msgid "" -"These documents are generated from `reStructuredText`_ sources by `Sphinx`_, " -"a document processor specifically written for the Python documentation." +"Python's documentation is generated from `reStructuredText`_ sources using " +"`Sphinx`_, a documentation generator originally created for Python and now " +"maintained as an independent project." msgstr "" "Αυτά τα έγραφα έχουν δημιουργηθεί από τα `reStructuredText`_ sources του " "`Sphinx`_, έναν επεξεργαστή εγγράφων που έχει δημιουργηθεί ειδικά για τα " "έγγραφα της Python." -#: about.rst:15 +#: about.rst:16 msgid "" "Development of the documentation and its toolchain is an entirely volunteer " "effort, just like Python itself. If you want to contribute, please take a " @@ -41,19 +45,20 @@ msgstr "" "ρίξτε μια ματιά στη σελίδα :ref:`reporting-bugs` για πληροφορίες σχετικές με " "το πως να το κάνετε. Καινούριοι εθελοντές είναι πάντα ευπρόσδεκτοι!" -#: about.rst:20 +#: about.rst:21 msgid "Many thanks go to:" msgstr "Πολλές ευχαριστίες πηγαίνουν στους:" -#: about.rst:22 +#: about.rst:23 +#, fuzzy msgid "" "Fred L. Drake, Jr., the creator of the original Python documentation toolset " -"and writer of much of the content;" +"and author of much of the content;" msgstr "" "Fred L. Drake, Jr., τον δημιουργό των αρχικών εργαλείων των εγγράφων της " "Python και συντάκτη αρκετού περιεχομένου'" -#: about.rst:24 +#: about.rst:25 msgid "" "the `Docutils `_ project for creating " "reStructuredText and the Docutils suite;" @@ -61,7 +66,7 @@ msgstr "" "το `Docutils `_ πρότζεκτ για την " "δημιουργία των εφαρμογών reStructuredText και Docutils'" -#: about.rst:26 +#: about.rst:27 msgid "" "Fredrik Lundh for his Alternative Python Reference project from which Sphinx " "got many good ideas." @@ -69,11 +74,12 @@ msgstr "" "Fredrik Lundh για το δικό του Alternative Python Reference πρότζεκτ από το " "οποίο το Sphinx πήρε πολύ καλές ιδέες." -#: about.rst:31 -msgid "Contributors to the Python Documentation" +#: about.rst:32 +#, fuzzy +msgid "Contributors to the Python documentation" msgstr "Συντελεστές στα έγγραφα της Python" -#: about.rst:33 +#: about.rst:34 msgid "" "Many people have contributed to the Python language, the Python standard " "library, and the Python documentation. See :source:`Misc/ACKS` in the " @@ -83,7 +89,7 @@ msgstr "" "Python, και τα έγγραφα της Python. Δείτε :source:`Misc/ACKS` στις πηγές " "διανομής της Python για μια λίστα των συντελεστών." -#: about.rst:37 +#: about.rst:38 msgid "" "It is only with the input and contributions of the Python community that " "Python has such wonderful documentation -- Thank You!" diff --git a/bugs.po b/bugs.po index 11b442fb..5d15b58e 100644 --- a/bugs.po +++ b/bugs.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-05-06 12:51+0000\n" "Last-Translator: Theofanis Petkos \n" "Language-Team: PyGreece \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -33,8 +34,8 @@ msgstr "" #: bugs.rst:11 msgid "" "It can be sometimes faster to fix bugs yourself and contribute patches to " -"Python as it streamlines the process and involves less people. Learn how to :" -"ref:`contribute `." +"Python as it streamlines the process and involves less people. Learn how " +"to :ref:`contribute `." msgstr "" "Μερικές φορές μπορεί να είναι πιο γρήγορο να διορθώσετε μόνοι σας σφάλματα " "και να συνεισφέρετε ενημερώσεις στον κώδικα της Python μιας και " @@ -66,6 +67,13 @@ msgstr "" #: bugs.rst:25 msgid "" +"If you find a bug in the theme (HTML / CSS / JavaScript) of the " +"documentation, please submit a bug report on the `python-doc-theme bug " +"tracker `_." +msgstr "" + +#: bugs.rst:29 +msgid "" "If you're short on time, you can also email documentation bug reports to " "docs@python.org (behavioral bugs can be sent to python-list@python.org). " "'docs@' is a mailing list run by volunteers; your request will be noticed, " @@ -77,11 +85,11 @@ msgstr "" "ένα mailing list που διευθύνεται από εθελοντές. Το αίτημά σας θα γίνει " "αντιληπτό, αν και μπορεί να χρειαστεί λίγος χρόνος για την επεξεργασία του." -#: bugs.rst:33 +#: bugs.rst:36 msgid "`Documentation bugs`_" msgstr "`Σφάλματα τεκμηρίωσης`_" -#: bugs.rst:33 +#: bugs.rst:37 msgid "" "A list of documentation bugs that have been submitted to the Python issue " "tracker." @@ -89,18 +97,18 @@ msgstr "" "Μια λίστα σφαλμάτων τεκμηρίωσης που έχουν υποβληθεί στον Python issue " "tracker." -#: bugs.rst:36 +#: bugs.rst:39 msgid "`Issue Tracking `_" msgstr "`Παρακολούθηση Issue `_" -#: bugs.rst:36 +#: bugs.rst:40 msgid "" "Overview of the process involved in reporting an improvement on the tracker." msgstr "" "Επισκόπηση της διαδικασίας που περιλαμβάνει η αναφορά μιας βελτίωσης στον " "tracker." -#: bugs.rst:39 +#: bugs.rst:42 msgid "" "`Helping with Documentation `_" @@ -108,7 +116,7 @@ msgstr "" "`Βοηθώντας με την Τεκμηρίωση `_" -#: bugs.rst:39 +#: bugs.rst:43 msgid "" "Comprehensive guide for individuals that are interested in contributing to " "Python documentation." @@ -116,7 +124,7 @@ msgstr "" "Ολοκληρωμένος οδηγός για άτομα που ενδιαφέρονται να συνεισφέρουν στην " "Τεκμηρίωση της Python." -#: bugs.rst:41 +#: bugs.rst:45 msgid "" "`Documentation Translations `_" @@ -124,7 +132,7 @@ msgstr "" "`Μεταφράσεις Τεκμηρίωσης `_" -#: bugs.rst:42 +#: bugs.rst:46 msgid "" "A list of GitHub pages for documentation translation and their primary " "contacts." @@ -132,11 +140,11 @@ msgstr "" "Μια λίστα από Github pages για την μετάφραση της τεκμηρίωσης και τις " "κυριότερες επαφές." -#: bugs.rst:48 +#: bugs.rst:52 msgid "Using the Python issue tracker" msgstr "Χρησιμοποιώντας τον Python issue tracker" -#: bugs.rst:50 +#: bugs.rst:54 msgid "" "Issue reports for Python itself should be submitted via the GitHub issues " "tracker (https://github.com/python/cpython/issues). The GitHub issues " @@ -148,7 +156,7 @@ msgstr "" "GitHub issues tracker προσφέρει μια web φόρμα που επιτρέπει την εισαγωγή και " "υποβολή σχετικών πληροφοριών στους προγραμματιστές." -#: bugs.rst:55 +#: bugs.rst:59 msgid "" "The first step in filing a report is to determine whether the problem has " "already been reported. The advantage in doing so, aside from saving the " @@ -167,7 +175,7 @@ msgstr "" "αναζητήστε στον tracker χρησιμοποιώντας το πλαίσιο αναζήτησης στο επάνω " "μέρος της σελίδας." -#: bugs.rst:62 +#: bugs.rst:66 msgid "" "If the problem you're reporting is not already in the list, log in to " "GitHub. If you don't already have a GitHub account, create a new account " @@ -179,7 +187,7 @@ msgstr "" "λογαριασμό χρησιμοποιώντας τον σύνδεσμο \"Sign up\". Δεν είναι δυνατή η " "υποβολή αναφοράς σφαλμάτων ανώνυμα." -#: bugs.rst:67 +#: bugs.rst:71 msgid "" "Being now logged in, you can submit an issue. Click on the \"New issue\" " "button in the top bar to report a new issue." @@ -187,11 +195,11 @@ msgstr "" "Όταν πλέον είστε συνδεδεμένοι, μπορείτε να υποβάλετε ένα issue. Κάντε κλικ " "στο κουμπί \"New issue\" στην επάνω γραμμή για να αναφέρετε ένα νέο issue." -#: bugs.rst:70 +#: bugs.rst:74 msgid "The submission form has two fields, \"Title\" and \"Comment\"." msgstr "Η φόρμα υποβολής έχει δύο πεδία, \"Title\" και \"Comment\"." -#: bugs.rst:72 +#: bugs.rst:76 msgid "" "For the \"Title\" field, enter a *very* short description of the problem; " "fewer than ten words is good." @@ -199,7 +207,7 @@ msgstr "" "Για το πεδίο \"Title\", εισαγάγετε μια *πολύ* σύντομη περιγραφή του " "προβλήματος' λιγότερες από δέκα λέξεις είναι καλές." -#: bugs.rst:75 +#: bugs.rst:79 msgid "" "In the \"Comment\" field, describe the problem in detail, including what you " "expected to happen and what did happen. Be sure to include whether any " @@ -212,7 +220,7 @@ msgstr "" "ποια πλατφόρμα υλικού και λογισμικού (συμπεριλαμβανομένων των πληροφοριών " "έκδοσης ανάλογα με την περίπτωση)." -#: bugs.rst:80 +#: bugs.rst:84 msgid "" "Each issue report will be reviewed by a developer who will determine what " "needs to be done to correct the problem. You will receive an update each " @@ -222,15 +230,15 @@ msgstr "" "καθορίσει τι πρέπει να γίνει για να διορθωθεί το πρόβλημα. Θα λαμβάνετε μια " "ενημέρωση κάθε φορά που γίνεται κάποια ενέργεια για το πρόβλημα." -#: bugs.rst:89 +#: bugs.rst:91 msgid "" "`How to Report Bugs Effectively `_" msgstr "" -"`Πως να Αναφέρεται Σφάλματα Αποτελεσματικά `_" +"`Πως να Αναφέρεται Σφάλματα Αποτελεσματικά `_" -#: bugs.rst:88 +#: bugs.rst:92 msgid "" "Article which goes into some detail about how to create a useful bug report. " "This describes what kind of information is useful and why it is useful." @@ -239,7 +247,7 @@ msgstr "" "μιας χρήσιμης αναφοράς σφάλματος. Περιγράφει τι είδους πληροφορίες είναι " "χρήσιμες και γιατί είναι χρήσιμες." -#: bugs.rst:92 +#: bugs.rst:95 msgid "" "`Bug Writing Guidelines `_" @@ -247,7 +255,7 @@ msgstr "" "Οδηγίες Συγγραφής Αναφορών Σφαλμάτων `_" -#: bugs.rst:92 +#: bugs.rst:96 msgid "" "Information about writing a good bug report. Some of this is specific to " "the Mozilla project, but describes general good practices." @@ -256,11 +264,11 @@ msgstr "" "αυτά αφορούν ειδικά το πρότζεκτ Mozilla, αλλά περιγράφουν και γενικές καλές " "πρακτικές." -#: bugs.rst:98 +#: bugs.rst:102 msgid "Getting started contributing to Python yourself" msgstr "Ξεκινήστε να συνεισφέρετε και εσείς στην Python" -#: bugs.rst:100 +#: bugs.rst:104 msgid "" "Beyond just reporting bugs that you find, you are also welcome to submit " "patches to fix them. You can find more information on how to get started " diff --git a/c-api/abstract.po b/c-api/abstract.po index 159c29f9..498b361b 100644 --- a/c-api/abstract.po +++ b/c-api/abstract.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -31,7 +32,7 @@ msgstr "" #: c-api/abstract.rst:14 msgid "" "It is not possible to use these functions on objects that are not properly " -"initialized, such as a list object that has been created by :c:func:" -"`PyList_New`, but whose items have not been set to some non-\\ ``NULL`` " -"value yet." +"initialized, such as a list object that has been created " +"by :c:func:`PyList_New`, but whose items have not been set to some non-\\ " +"``NULL`` value yet." msgstr "" diff --git a/c-api/allocation.po b/c-api/allocation.po index 155abbed..832b9fb3 100644 --- a/c-api/allocation.po +++ b/c-api/allocation.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -23,29 +24,27 @@ msgstr "" #: c-api/allocation.rst:17 msgid "" "Initialize a newly allocated object *op* with its type and initial " -"reference. Returns the initialized object. If *type* indicates that the " -"object participates in the cyclic garbage detector, it is added to the " -"detector's set of observed objects. Other fields of the object are not " -"affected." +"reference. Returns the initialized object. Other fields of the object are " +"not affected." msgstr "" -#: c-api/allocation.rst:26 +#: c-api/allocation.rst:24 msgid "" "This does everything :c:func:`PyObject_Init` does, and also initializes the " "length information for a variable-size object." msgstr "" -#: c-api/allocation.rst:32 +#: c-api/allocation.rst:30 msgid "" "Allocate a new Python object using the C structure type *TYPE* and the " "Python type object *typeobj* (``PyTypeObject*``). Fields not defined by the " "Python object header are not initialized. The caller will own the only " "reference to the object (i.e. its reference count will be one). The size of " -"the memory allocation is determined from the :c:member:`~PyTypeObject." -"tp_basicsize` field of the type object." +"the memory allocation is determined from " +"the :c:member:`~PyTypeObject.tp_basicsize` field of the type object." msgstr "" -#: c-api/allocation.rst:43 +#: c-api/allocation.rst:41 msgid "" "Allocate a new Python object using the C structure type *TYPE* and the " "Python type object *typeobj* (``PyTypeObject*``). Fields not defined by the " @@ -58,26 +57,26 @@ msgid "" "management efficiency." msgstr "" -#: c-api/allocation.rst:57 +#: c-api/allocation.rst:55 msgid "" -"Releases memory allocated to an object using :c:macro:`PyObject_New` or :c:" -"macro:`PyObject_NewVar`. This is normally called from the :c:member:" -"`~PyTypeObject.tp_dealloc` handler specified in the object's type. The " -"fields of the object should not be accessed after this call as the memory is " -"no longer a valid Python object." +"Releases memory allocated to an object using :c:macro:`PyObject_New` " +"or :c:macro:`PyObject_NewVar`. This is normally called from " +"the :c:member:`~PyTypeObject.tp_dealloc` handler specified in the object's " +"type. The fields of the object should not be accessed after this call as " +"the memory is no longer a valid Python object." msgstr "" -#: c-api/allocation.rst:66 +#: c-api/allocation.rst:64 msgid "" "Object which is visible in Python as ``None``. This should only be accessed " "using the :c:macro:`Py_None` macro, which evaluates to a pointer to this " "object." msgstr "" -#: c-api/allocation.rst:73 +#: c-api/allocation.rst:71 msgid ":c:func:`PyModule_Create`" msgstr "" -#: c-api/allocation.rst:74 +#: c-api/allocation.rst:72 msgid "To allocate and create extension modules." msgstr "" diff --git a/c-api/apiabiversion.po b/c-api/apiabiversion.po index 10beeabc..19e096b6 100644 --- a/c-api/apiabiversion.po +++ b/c-api/apiabiversion.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/c-api/arg.po b/c-api/arg.po index e3abe7c1..37235a51 100644 --- a/c-api/arg.po +++ b/c-api/arg.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -23,17 +24,17 @@ msgstr "" #: c-api/arg.rst:8 msgid "" "These functions are useful when creating your own extensions functions and " -"methods. Additional information and examples are available in :ref:" -"`extending-index`." +"methods. Additional information and examples are available " +"in :ref:`extending-index`." msgstr "" #: c-api/arg.rst:12 msgid "" -"The first three of these functions described, :c:func:`PyArg_ParseTuple`, :c:" -"func:`PyArg_ParseTupleAndKeywords`, and :c:func:`PyArg_Parse`, all use " -"*format strings* which are used to tell the function about the expected " -"arguments. The format strings use the same syntax for each of these " -"functions." +"The first three of these functions " +"described, :c:func:`PyArg_ParseTuple`, :c:func:`PyArg_ParseTupleAndKeywords`, " +"and :c:func:`PyArg_Parse`, all use *format strings* which are used to tell " +"the function about the expected arguments. The format strings use the same " +"syntax for each of these functions." msgstr "" #: c-api/arg.rst:19 @@ -98,10 +99,10 @@ msgstr "" #: c-api/arg.rst:61 msgid "" -"To ensure that the underlying buffer may be safely borrowed, the object's :c:" -"member:`PyBufferProcs.bf_releasebuffer` field must be ``NULL``. This " -"disallows common mutable objects such as :class:`bytearray`, but also some " -"read-only objects such as :class:`memoryview` of :class:`bytes`." +"To ensure that the underlying buffer may be safely borrowed, the " +"object's :c:member:`PyBufferProcs.bf_releasebuffer` field must be ``NULL``. " +"This disallows common mutable objects such as :class:`bytearray`, but also " +"some read-only objects such as :class:`memoryview` of :class:`bytes`." msgstr "" #: c-api/arg.rst:67 @@ -113,14 +114,14 @@ msgstr "" #: c-api/arg.rst:73 msgid "" -"For all ``#`` variants of formats (``s#``, ``y#``, etc.), the macro :c:macro:" -"`PY_SSIZE_T_CLEAN` must be defined before including :file:`Python.h`. On " -"Python 3.9 and older, the type of the length argument is :c:type:" -"`Py_ssize_t` if the :c:macro:`PY_SSIZE_T_CLEAN` macro is defined, or int " -"otherwise." +"For all ``#`` variants of formats (``s#``, ``y#``, etc.), the " +"macro :c:macro:`PY_SSIZE_T_CLEAN` must be defined before " +"including :file:`Python.h`. On Python 3.9 and older, the type of the length " +"argument is :c:type:`Py_ssize_t` if the :c:macro:`PY_SSIZE_T_CLEAN` macro is " +"defined, or int otherwise." msgstr "" -#: c-api/arg.rst:98 +#: c-api/arg.rst:80 msgid "``s`` (:class:`str`) [const char \\*]" msgstr "" @@ -138,8 +139,8 @@ msgstr "" msgid "" "This format does not accept :term:`bytes-like objects `. " "If you want to accept filesystem paths and convert them to C character " -"strings, it is preferable to use the ``O&`` format with :c:func:" -"`PyUnicode_FSConverter` as *converter*." +"strings, it is preferable to use the ``O&`` format " +"with :c:func:`PyUnicode_FSConverter` as *converter*." msgstr "" #: c-api/arg.rst:96 @@ -148,7 +149,7 @@ msgid "" "encountered in the Python string." msgstr "" -#: c-api/arg.rst:104 +#: c-api/arg.rst:100 msgid "``s*`` (:class:`str` or :term:`bytes-like object`) [Py_buffer]" msgstr "" @@ -160,10 +161,10 @@ msgid "" "converted to C strings using ``'utf-8'`` encoding." msgstr "" -#: c-api/arg.rst:111 +#: c-api/arg.rst:106 msgid "" -"``s#`` (:class:`str`, read-only :term:`bytes-like object`) [const char \\*, :" -"c:type:`Py_ssize_t`]" +"``s#`` (:class:`str`, read-only :term:`bytes-like object`) [const char " +"\\*, :c:type:`Py_ssize_t`]" msgstr "" #: c-api/arg.rst:107 @@ -175,7 +176,7 @@ msgid "" "encoding." msgstr "" -#: c-api/arg.rst:547 +#: c-api/arg.rst:558 msgid "``z`` (:class:`str` or ``None``) [const char \\*]" msgstr "" @@ -185,7 +186,7 @@ msgid "" "pointer is set to ``NULL``." msgstr "" -#: c-api/arg.rst:119 +#: c-api/arg.rst:117 msgid "" "``z*`` (:class:`str`, :term:`bytes-like object` or ``None``) [Py_buffer]" msgstr "" @@ -196,7 +197,7 @@ msgid "" "``buf`` member of the :c:type:`Py_buffer` structure is set to ``NULL``." msgstr "" -#: c-api/arg.rst:123 +#: c-api/arg.rst:121 msgid "" "``z#`` (:class:`str`, read-only :term:`bytes-like object` or ``None``) " "[const char \\*, :c:type:`Py_ssize_t`]" @@ -208,7 +209,7 @@ msgid "" "pointer is set to ``NULL``." msgstr "" -#: c-api/arg.rst:134 +#: c-api/arg.rst:125 msgid "``y`` (read-only :term:`bytes-like object`) [const char \\*]" msgstr "" @@ -226,7 +227,7 @@ msgid "" "encountered in the bytes buffer." msgstr "" -#: c-api/arg.rst:139 +#: c-api/arg.rst:136 msgid "``y*`` (:term:`bytes-like object`) [Py_buffer]" msgstr "" @@ -236,10 +237,10 @@ msgid "" "objects. **This is the recommended way to accept binary data.**" msgstr "" -#: c-api/arg.rst:143 +#: c-api/arg.rst:141 msgid "" -"``y#`` (read-only :term:`bytes-like object`) [const char \\*, :c:type:" -"`Py_ssize_t`]" +"``y#`` (read-only :term:`bytes-like object`) [const char " +"\\*, :c:type:`Py_ssize_t`]" msgstr "" #: c-api/arg.rst:142 @@ -248,7 +249,7 @@ msgid "" "objects." msgstr "" -#: c-api/arg.rst:148 +#: c-api/arg.rst:145 msgid "``S`` (:class:`bytes`) [PyBytesObject \\*]" msgstr "" @@ -259,19 +260,19 @@ msgid "" "bytes object. The C variable may also be declared as :c:expr:`PyObject*`." msgstr "" -#: c-api/arg.rst:153 +#: c-api/arg.rst:150 msgid "``Y`` (:class:`bytearray`) [PyByteArrayObject \\*]" msgstr "" #: c-api/arg.rst:151 msgid "" "Requires that the Python object is a :class:`bytearray` object, without " -"attempting any conversion. Raises :exc:`TypeError` if the object is not a :" -"class:`bytearray` object. The C variable may also be declared as :c:expr:" -"`PyObject*`." +"attempting any conversion. Raises :exc:`TypeError` if the object is not " +"a :class:`bytearray` object. The C variable may also be declared " +"as :c:expr:`PyObject*`." msgstr "" -#: c-api/arg.rst:158 +#: c-api/arg.rst:155 msgid "``U`` (:class:`str`) [PyObject \\*]" msgstr "" @@ -282,7 +283,7 @@ msgid "" "The C variable may also be declared as :c:expr:`PyObject*`." msgstr "" -#: c-api/arg.rst:164 +#: c-api/arg.rst:160 msgid "``w*`` (read-write :term:`bytes-like object`) [Py_buffer]" msgstr "" @@ -290,11 +291,11 @@ msgstr "" msgid "" "This format accepts any object which implements the read-write buffer " "interface. It fills a :c:type:`Py_buffer` structure provided by the caller. " -"The buffer may contain embedded null bytes. The caller have to call :c:func:" -"`PyBuffer_Release` when it is done with the buffer." +"The buffer may contain embedded null bytes. The caller have to " +"call :c:func:`PyBuffer_Release` when it is done with the buffer." msgstr "" -#: c-api/arg.rst:181 +#: c-api/arg.rst:166 msgid "``es`` (:class:`str`) [const char \\*encoding, char \\*\\*buffer]" msgstr "" @@ -319,11 +320,11 @@ msgstr "" msgid "" ":c:func:`PyArg_ParseTuple` will allocate a buffer of the needed size, copy " "the encoded data into this buffer and adjust *\\*buffer* to reference the " -"newly allocated storage. The caller is responsible for calling :c:func:" -"`PyMem_Free` to free the allocated buffer after use." +"newly allocated storage. The caller is responsible for " +"calling :c:func:`PyMem_Free` to free the allocated buffer after use." msgstr "" -#: c-api/arg.rst:186 +#: c-api/arg.rst:183 msgid "" "``et`` (:class:`str`, :class:`bytes` or :class:`bytearray`) [const char " "\\*encoding, char \\*\\*buffer]" @@ -336,10 +337,10 @@ msgid "" "object uses the encoding passed in as parameter." msgstr "" -#: c-api/arg.rst:217 +#: c-api/arg.rst:188 msgid "" -"``es#`` (:class:`str`) [const char \\*encoding, char \\*\\*buffer, :c:type:" -"`Py_ssize_t` \\*buffer_length]" +"``es#`` (:class:`str`) [const char \\*encoding, char " +"\\*\\*buffer, :c:type:`Py_ssize_t` \\*buffer_length]" msgstr "" #: c-api/arg.rst:189 @@ -390,7 +391,7 @@ msgid "" "without the trailing NUL byte." msgstr "" -#: c-api/arg.rst:222 +#: c-api/arg.rst:219 msgid "" "``et#`` (:class:`str`, :class:`bytes` or :class:`bytearray`) [const char " "\\*encoding, char \\*\\*buffer, :c:type:`Py_ssize_t` \\*buffer_length]" @@ -413,175 +414,193 @@ msgstr "" msgid "Numbers" msgstr "" -#: c-api/arg.rst:234 +#: c-api/arg.rst:232 +msgid "" +"These formats allow representing Python numbers or single characters as C " +"numbers. Formats that require :class:`int`, :class:`float` " +"or :class:`complex` can also use the corresponding special " +"methods :meth:`~object.__index__`, :meth:`~object.__float__` " +"or :meth:`~object.__complex__` to convert the Python object to the required " +"type." +msgstr "" + +#: c-api/arg.rst:238 +msgid "" +"For signed integer formats, :exc:`OverflowError` is raised if the value is " +"out of range for the C type. For unsigned integer formats, no range checking " +"is done --- the most significant bits are silently truncated when the " +"receiving field is too small to receive the value." +msgstr "" + +#: c-api/arg.rst:244 msgid "``b`` (:class:`int`) [unsigned char]" msgstr "" -#: c-api/arg.rst:233 +#: c-api/arg.rst:245 msgid "" -"Convert a nonnegative Python integer to an unsigned tiny int, stored in a C :" -"c:expr:`unsigned char`." +"Convert a nonnegative Python integer to an unsigned tiny integer, stored in " +"a C :c:expr:`unsigned char`." msgstr "" -#: c-api/arg.rst:581 +#: c-api/arg.rst:592 msgid "``B`` (:class:`int`) [unsigned char]" msgstr "" -#: c-api/arg.rst:237 +#: c-api/arg.rst:249 msgid "" -"Convert a Python integer to a tiny int without overflow checking, stored in " -"a C :c:expr:`unsigned char`." +"Convert a Python integer to a tiny integer without overflow checking, stored " +"in a C :c:expr:`unsigned char`." msgstr "" -#: c-api/arg.rst:575 +#: c-api/arg.rst:586 msgid "``h`` (:class:`int`) [short int]" msgstr "" -#: c-api/arg.rst:241 +#: c-api/arg.rst:253 msgid "Convert a Python integer to a C :c:expr:`short int`." msgstr "" -#: c-api/arg.rst:584 +#: c-api/arg.rst:595 msgid "``H`` (:class:`int`) [unsigned short int]" msgstr "" -#: c-api/arg.rst:244 +#: c-api/arg.rst:256 msgid "" "Convert a Python integer to a C :c:expr:`unsigned short int`, without " "overflow checking." msgstr "" -#: c-api/arg.rst:569 +#: c-api/arg.rst:580 msgid "``i`` (:class:`int`) [int]" msgstr "" -#: c-api/arg.rst:248 +#: c-api/arg.rst:260 msgid "Convert a Python integer to a plain C :c:expr:`int`." msgstr "" -#: c-api/arg.rst:587 +#: c-api/arg.rst:598 msgid "``I`` (:class:`int`) [unsigned int]" msgstr "" -#: c-api/arg.rst:251 +#: c-api/arg.rst:263 msgid "" "Convert a Python integer to a C :c:expr:`unsigned int`, without overflow " "checking." msgstr "" -#: c-api/arg.rst:578 +#: c-api/arg.rst:589 msgid "``l`` (:class:`int`) [long int]" msgstr "" -#: c-api/arg.rst:255 +#: c-api/arg.rst:267 msgid "Convert a Python integer to a C :c:expr:`long int`." msgstr "" -#: c-api/arg.rst:590 +#: c-api/arg.rst:601 msgid "``k`` (:class:`int`) [unsigned long]" msgstr "" -#: c-api/arg.rst:258 +#: c-api/arg.rst:270 msgid "" "Convert a Python integer to a C :c:expr:`unsigned long` without overflow " "checking." msgstr "" -#: c-api/arg.rst:593 +#: c-api/arg.rst:604 msgid "``L`` (:class:`int`) [long long]" msgstr "" -#: c-api/arg.rst:262 +#: c-api/arg.rst:274 msgid "Convert a Python integer to a C :c:expr:`long long`." msgstr "" -#: c-api/arg.rst:596 +#: c-api/arg.rst:607 msgid "``K`` (:class:`int`) [unsigned long long]" msgstr "" -#: c-api/arg.rst:265 +#: c-api/arg.rst:277 msgid "" "Convert a Python integer to a C :c:expr:`unsigned long long` without " "overflow checking." msgstr "" -#: c-api/arg.rst:599 +#: c-api/arg.rst:610 msgid "``n`` (:class:`int`) [:c:type:`Py_ssize_t`]" msgstr "" -#: c-api/arg.rst:269 +#: c-api/arg.rst:281 msgid "Convert a Python integer to a C :c:type:`Py_ssize_t`." msgstr "" -#: c-api/arg.rst:276 +#: c-api/arg.rst:283 msgid "``c`` (:class:`bytes` or :class:`bytearray` of length 1) [char]" msgstr "" -#: c-api/arg.rst:272 +#: c-api/arg.rst:284 msgid "" "Convert a Python byte, represented as a :class:`bytes` or :class:`bytearray` " "object of length 1, to a C :c:expr:`char`." msgstr "" -#: c-api/arg.rst:275 +#: c-api/arg.rst:287 msgid "Allow :class:`bytearray` objects." msgstr "" -#: c-api/arg.rst:607 +#: c-api/arg.rst:617 msgid "``C`` (:class:`str` of length 1) [int]" msgstr "" -#: c-api/arg.rst:279 +#: c-api/arg.rst:291 msgid "" "Convert a Python character, represented as a :class:`str` object of length " "1, to a C :c:expr:`int`." msgstr "" -#: c-api/arg.rst:613 +#: c-api/arg.rst:624 msgid "``f`` (:class:`float`) [float]" msgstr "" -#: c-api/arg.rst:283 -msgid "Convert a Python floating point number to a C :c:expr:`float`." +#: c-api/arg.rst:295 +msgid "Convert a Python floating-point number to a C :c:expr:`float`." msgstr "" -#: c-api/arg.rst:610 +#: c-api/arg.rst:621 msgid "``d`` (:class:`float`) [double]" msgstr "" -#: c-api/arg.rst:286 -msgid "Convert a Python floating point number to a C :c:expr:`double`." +#: c-api/arg.rst:298 +msgid "Convert a Python floating-point number to a C :c:expr:`double`." msgstr "" -#: c-api/arg.rst:289 +#: c-api/arg.rst:300 msgid "``D`` (:class:`complex`) [Py_complex]" msgstr "" -#: c-api/arg.rst:289 +#: c-api/arg.rst:301 msgid "Convert a Python complex number to a C :c:type:`Py_complex` structure." msgstr "" -#: c-api/arg.rst:292 +#: c-api/arg.rst:304 msgid "Other objects" msgstr "" -#: c-api/arg.rst:626 +#: c-api/arg.rst:630 msgid "``O`` (object) [PyObject \\*]" msgstr "" -#: c-api/arg.rst:295 +#: c-api/arg.rst:307 msgid "" "Store a Python object (without any conversion) in a C object pointer. The C " -"program thus receives the actual object that was passed. A new :term:" -"`strong reference` to the object is not created (i.e. its reference count is " -"not increased). The pointer stored is not ``NULL``." +"program thus receives the actual object that was passed. A " +"new :term:`strong reference` to the object is not created (i.e. its " +"reference count is not increased). The pointer stored is not ``NULL``." msgstr "" -#: c-api/arg.rst:306 +#: c-api/arg.rst:313 msgid "``O!`` (object) [*typeobject*, PyObject \\*]" msgstr "" -#: c-api/arg.rst:302 +#: c-api/arg.rst:314 msgid "" "Store a Python object in a C object pointer. This is similar to ``O``, but " "takes two C arguments: the first is the address of a Python type object, the " @@ -590,11 +609,11 @@ msgid "" "required type, :exc:`TypeError` is raised." msgstr "" -#: c-api/arg.rst:640 -msgid "``O&`` (object) [*converter*, *anything*]" +#: c-api/arg.rst:322 +msgid "``O&`` (object) [*converter*, *address*]" msgstr "" -#: c-api/arg.rst:311 +#: c-api/arg.rst:323 msgid "" "Convert a Python object to a C variable through a *converter* function. " "This takes two arguments: the first is a function, the second is the address " @@ -602,34 +621,44 @@ msgid "" "*converter* function in turn is called as follows::" msgstr "" -#: c-api/arg.rst:318 +#: c-api/arg.rst:328 +msgid "status = converter(object, address);" +msgstr "" + +#: c-api/arg.rst:330 msgid "" -"where *object* is the Python object to be converted and *address* is the :c:" -"expr:`void*` argument that was passed to the ``PyArg_Parse*`` function. The " -"returned *status* should be ``1`` for a successful conversion and ``0`` if " -"the conversion has failed. When the conversion fails, the *converter* " -"function should raise an exception and leave the content of *address* " -"unmodified." +"where *object* is the Python object to be converted and *address* is " +"the :c:expr:`void*` argument that was passed to the ``PyArg_Parse*`` " +"function. The returned *status* should be ``1`` for a successful conversion " +"and ``0`` if the conversion has failed. When the conversion fails, the " +"*converter* function should raise an exception and leave the content of " +"*address* unmodified." msgstr "" -#: c-api/arg.rst:324 +#: c-api/arg.rst:339 msgid "" -"If the *converter* returns ``Py_CLEANUP_SUPPORTED``, it may get called a " -"second time if the argument parsing eventually fails, giving the converter a " -"chance to release any memory that it had already allocated. In this second " -"call, the *object* parameter will be ``NULL``; *address* will have the same " -"value as in the original call." +"If the *converter* returns :c:macro:`!Py_CLEANUP_SUPPORTED`, it may get " +"called a second time if the argument parsing eventually fails, giving the " +"converter a chance to release any memory that it had already allocated. In " +"this second call, the *object* parameter will be ``NULL``; *address* will " +"have the same value as in the original call." msgstr "" -#: c-api/arg.rst:330 -msgid "``Py_CLEANUP_SUPPORTED`` was added." +#: c-api/arg.rst:345 +msgid "" +"Examples of converters: :c:func:`PyUnicode_FSConverter` " +"and :c:func:`PyUnicode_FSDecoder`." +msgstr "" + +#: c-api/arg.rst:348 +msgid ":c:macro:`!Py_CLEANUP_SUPPORTED` was added." msgstr "" -#: c-api/arg.rst:340 +#: c-api/arg.rst:351 msgid "``p`` (:class:`bool`) [int]" msgstr "" -#: c-api/arg.rst:334 +#: c-api/arg.rst:352 msgid "" "Tests the value passed in for truth (a boolean **p**\\ redicate) and " "converts the result to its equivalent C true/false integer value. Sets the " @@ -638,37 +667,28 @@ msgid "" "how Python tests values for truth." msgstr "" -#: c-api/arg.rst:643 +#: c-api/arg.rst:654 msgid "``(items)`` (:class:`tuple`) [*matching-items*]" msgstr "" -#: c-api/arg.rst:343 +#: c-api/arg.rst:361 msgid "" "The object must be a Python sequence whose length is the number of format " "units in *items*. The C arguments must correspond to the individual format " "units in *items*. Format units for sequences may be nested." msgstr "" -#: c-api/arg.rst:347 -msgid "" -"It is possible to pass \"long\" integers (integers whose value exceeds the " -"platform's :c:macro:`LONG_MAX`) however no proper range checking is done --- " -"the most significant bits are silently truncated when the receiving field is " -"too small to receive the value (actually, the semantics are inherited from " -"downcasts in C --- your mileage may vary)." -msgstr "" - -#: c-api/arg.rst:353 +#: c-api/arg.rst:365 msgid "" "A few other characters have a meaning in a format string. These may not " "occur inside nested parentheses. They are:" msgstr "" -#: c-api/arg.rst:361 +#: c-api/arg.rst:368 msgid "``|``" msgstr "" -#: c-api/arg.rst:357 +#: c-api/arg.rst:369 msgid "" "Indicates that the remaining arguments in the Python argument list are " "optional. The C variables corresponding to optional arguments should be " @@ -677,11 +697,11 @@ msgid "" "corresponding C variable(s)." msgstr "" -#: c-api/arg.rst:370 +#: c-api/arg.rst:375 msgid "``$``" msgstr "" -#: c-api/arg.rst:364 +#: c-api/arg.rst:376 msgid "" ":c:func:`PyArg_ParseTupleAndKeywords` only: Indicates that the remaining " "arguments in the Python argument list are keyword-only. Currently, all " @@ -689,36 +709,36 @@ msgid "" "be specified before ``$`` in the format string." msgstr "" -#: c-api/arg.rst:375 +#: c-api/arg.rst:384 msgid "``:``" msgstr "" -#: c-api/arg.rst:373 +#: c-api/arg.rst:385 msgid "" "The list of format units ends here; the string after the colon is used as " "the function name in error messages (the \"associated value\" of the " "exception that :c:func:`PyArg_ParseTuple` raises)." msgstr "" -#: c-api/arg.rst:380 +#: c-api/arg.rst:389 msgid "``;``" msgstr "" -#: c-api/arg.rst:378 +#: c-api/arg.rst:390 msgid "" "The list of format units ends here; the string after the semicolon is used " -"as the error message *instead* of the default error message. ``:`` and ``;" -"`` mutually exclude each other." +"as the error message *instead* of the default error message. ``:`` and " +"``;`` mutually exclude each other." msgstr "" -#: c-api/arg.rst:382 +#: c-api/arg.rst:394 msgid "" "Note that any Python object references which are provided to the caller are " "*borrowed* references; do not release them (i.e. do not decrement their " "reference count)!" msgstr "" -#: c-api/arg.rst:386 +#: c-api/arg.rst:398 msgid "" "Additional arguments passed to these functions must be addresses of " "variables whose type is determined by the format string; these are used to " @@ -728,7 +748,7 @@ msgid "" "unit in that case." msgstr "" -#: c-api/arg.rst:392 +#: c-api/arg.rst:404 msgid "" "For the conversion to succeed, the *arg* object must match the format and " "the format must be exhausted. On success, the ``PyArg_Parse*`` functions " @@ -738,52 +758,53 @@ msgid "" "the following format units are left untouched." msgstr "" -#: c-api/arg.rst:401 +#: c-api/arg.rst:413 msgid "API Functions" msgstr "" -#: c-api/arg.rst:405 +#: c-api/arg.rst:417 msgid "" "Parse the parameters of a function that takes only positional parameters " "into local variables. Returns true on success; on failure, it returns false " "and raises the appropriate exception." msgstr "" -#: c-api/arg.rst:412 +#: c-api/arg.rst:424 msgid "" "Identical to :c:func:`PyArg_ParseTuple`, except that it accepts a va_list " "rather than a variable number of arguments." msgstr "" -#: c-api/arg.rst:418 +#: c-api/arg.rst:430 msgid "" "Parse the parameters of a function that takes both positional and keyword " "parameters into local variables. The *keywords* argument is a ``NULL``-" -"terminated array of keyword parameter names. Empty names denote :ref:" -"`positional-only parameters `. Returns true on " -"success; on failure, it returns false and raises the appropriate exception." +"terminated array of keyword parameter names. Empty names " +"denote :ref:`positional-only parameters `. " +"Returns true on success; on failure, it returns false and raises the " +"appropriate exception." msgstr "" -#: c-api/arg.rst:425 +#: c-api/arg.rst:437 msgid "" "Added support for :ref:`positional-only parameters `." msgstr "" -#: c-api/arg.rst:432 +#: c-api/arg.rst:444 msgid "" "Identical to :c:func:`PyArg_ParseTupleAndKeywords`, except that it accepts a " "va_list rather than a variable number of arguments." msgstr "" -#: c-api/arg.rst:438 +#: c-api/arg.rst:450 msgid "" "Ensure that the keys in the keywords argument dictionary are strings. This " "is only needed if :c:func:`PyArg_ParseTupleAndKeywords` is not used, since " "the latter already does this check." msgstr "" -#: c-api/arg.rst:448 +#: c-api/arg.rst:460 msgid "" "Function used to deconstruct the argument lists of \"old-style\" functions " "--- these are functions which use the :const:`METH_OLDARGS` parameter " @@ -794,7 +815,7 @@ msgid "" "continue to be used for that purpose." msgstr "" -#: c-api/arg.rst:459 +#: c-api/arg.rst:471 msgid "" "A simpler form of parameter retrieval which does not use a format string to " "specify the types of the arguments. Functions which use this method to " @@ -812,23 +833,43 @@ msgid "" "if there was a failure." msgstr "" -#: c-api/arg.rst:474 +#: c-api/arg.rst:486 msgid "" "This is an example of the use of this function, taken from the sources for " "the :mod:`!_weakref` helper module for weak references::" msgstr "" -#: c-api/arg.rst:490 +#: c-api/arg.rst:489 +msgid "" +"static PyObject *\n" +"weakref_ref(PyObject *self, PyObject *args)\n" +"{\n" +" PyObject *object;\n" +" PyObject *callback = NULL;\n" +" PyObject *result = NULL;\n" +"\n" +" if (PyArg_UnpackTuple(args, \"ref\", 1, 2, &object, &callback)) {\n" +" result = PyWeakref_NewRef(object, callback);\n" +" }\n" +" return result;\n" +"}" +msgstr "" + +#: c-api/arg.rst:502 msgid "" "The call to :c:func:`PyArg_UnpackTuple` in this example is entirely " "equivalent to this call to :c:func:`PyArg_ParseTuple`::" msgstr "" -#: c-api/arg.rst:498 +#: c-api/arg.rst:505 +msgid "PyArg_ParseTuple(args, \"O|O:ref\", &object, &callback)" +msgstr "" + +#: c-api/arg.rst:510 msgid "Building values" msgstr "" -#: c-api/arg.rst:502 +#: c-api/arg.rst:514 msgid "" "Create a new value based on a format string similar to those accepted by the " "``PyArg_Parse*`` family of functions and a sequence of values. Returns the " @@ -836,7 +877,7 @@ msgid "" "``NULL`` is returned." msgstr "" -#: c-api/arg.rst:507 +#: c-api/arg.rst:519 msgid "" ":c:func:`Py_BuildValue` does not always build a tuple. It builds a tuple " "only if its format string contains two or more format units. If the format " @@ -845,18 +886,18 @@ msgid "" "it to return a tuple of size 0 or one, parenthesize the format string." msgstr "" -#: c-api/arg.rst:513 +#: c-api/arg.rst:525 msgid "" "When memory buffers are passed as parameters to supply data to build " "objects, as for the ``s`` and ``s#`` formats, the required data is copied. " "Buffers provided by the caller are never referenced by the objects created " -"by :c:func:`Py_BuildValue`. In other words, if your code invokes :c:func:" -"`malloc` and passes the allocated memory to :c:func:`Py_BuildValue`, your " -"code is responsible for calling :c:func:`free` for that memory once :c:func:" -"`Py_BuildValue` returns." +"by :c:func:`Py_BuildValue`. In other words, if your code " +"invokes :c:func:`malloc` and passes the allocated memory " +"to :c:func:`Py_BuildValue`, your code is responsible for " +"calling :c:func:`free` for that memory once :c:func:`Py_BuildValue` returns." msgstr "" -#: c-api/arg.rst:521 +#: c-api/arg.rst:533 msgid "" "In the following description, the quoted form is the format unit; the entry " "in (round) parentheses is the Python object type that the format unit will " @@ -864,250 +905,254 @@ msgid "" "be passed." msgstr "" -#: c-api/arg.rst:525 +#: c-api/arg.rst:537 msgid "" "The characters space, tab, colon and comma are ignored in format strings " "(but not within format units such as ``s#``). This can be used to make long " "format strings a tad more readable." msgstr "" -#: c-api/arg.rst:531 +#: c-api/arg.rst:541 msgid "``s`` (:class:`str` or ``None``) [const char \\*]" msgstr "" -#: c-api/arg.rst:530 +#: c-api/arg.rst:542 msgid "" "Convert a null-terminated C string to a Python :class:`str` object using " "``'utf-8'`` encoding. If the C string pointer is ``NULL``, ``None`` is used." msgstr "" -#: c-api/arg.rst:536 +#: c-api/arg.rst:545 msgid "" "``s#`` (:class:`str` or ``None``) [const char \\*, :c:type:`Py_ssize_t`]" msgstr "" -#: c-api/arg.rst:534 +#: c-api/arg.rst:546 msgid "" "Convert a C string and its length to a Python :class:`str` object using " "``'utf-8'`` encoding. If the C string pointer is ``NULL``, the length is " "ignored and ``None`` is returned." msgstr "" -#: c-api/arg.rst:540 +#: c-api/arg.rst:550 msgid "``y`` (:class:`bytes`) [const char \\*]" msgstr "" -#: c-api/arg.rst:539 +#: c-api/arg.rst:551 msgid "" "This converts a C string to a Python :class:`bytes` object. If the C string " "pointer is ``NULL``, ``None`` is returned." msgstr "" -#: c-api/arg.rst:544 +#: c-api/arg.rst:554 msgid "``y#`` (:class:`bytes`) [const char \\*, :c:type:`Py_ssize_t`]" msgstr "" -#: c-api/arg.rst:543 +#: c-api/arg.rst:555 msgid "" "This converts a C string and its lengths to a Python object. If the C " "string pointer is ``NULL``, ``None`` is returned." msgstr "" -#: c-api/arg.rst:563 +#: c-api/arg.rst:575 msgid "Same as ``s``." msgstr "" -#: c-api/arg.rst:550 +#: c-api/arg.rst:561 msgid "" "``z#`` (:class:`str` or ``None``) [const char \\*, :c:type:`Py_ssize_t`]" msgstr "" -#: c-api/arg.rst:566 +#: c-api/arg.rst:578 msgid "Same as ``s#``." msgstr "" -#: c-api/arg.rst:555 +#: c-api/arg.rst:564 msgid "``u`` (:class:`str`) [const wchar_t \\*]" msgstr "" -#: c-api/arg.rst:553 +#: c-api/arg.rst:565 msgid "" "Convert a null-terminated :c:type:`wchar_t` buffer of Unicode (UTF-16 or " "UCS-4) data to a Python Unicode object. If the Unicode buffer pointer is " "``NULL``, ``None`` is returned." msgstr "" -#: c-api/arg.rst:560 +#: c-api/arg.rst:569 msgid "``u#`` (:class:`str`) [const wchar_t \\*, :c:type:`Py_ssize_t`]" msgstr "" -#: c-api/arg.rst:558 +#: c-api/arg.rst:570 msgid "" "Convert a Unicode (UTF-16 or UCS-4) data buffer and its length to a Python " "Unicode object. If the Unicode buffer pointer is ``NULL``, the length is " "ignored and ``None`` is returned." msgstr "" -#: c-api/arg.rst:563 +#: c-api/arg.rst:574 msgid "``U`` (:class:`str` or ``None``) [const char \\*]" msgstr "" -#: c-api/arg.rst:566 +#: c-api/arg.rst:577 msgid "" "``U#`` (:class:`str` or ``None``) [const char \\*, :c:type:`Py_ssize_t`]" msgstr "" -#: c-api/arg.rst:569 +#: c-api/arg.rst:581 msgid "Convert a plain C :c:expr:`int` to a Python integer object." msgstr "" -#: c-api/arg.rst:572 +#: c-api/arg.rst:583 msgid "``b`` (:class:`int`) [char]" msgstr "" -#: c-api/arg.rst:572 +#: c-api/arg.rst:584 msgid "Convert a plain C :c:expr:`char` to a Python integer object." msgstr "" -#: c-api/arg.rst:575 +#: c-api/arg.rst:587 msgid "Convert a plain C :c:expr:`short int` to a Python integer object." msgstr "" -#: c-api/arg.rst:578 +#: c-api/arg.rst:590 msgid "Convert a C :c:expr:`long int` to a Python integer object." msgstr "" -#: c-api/arg.rst:581 +#: c-api/arg.rst:593 msgid "Convert a C :c:expr:`unsigned char` to a Python integer object." msgstr "" -#: c-api/arg.rst:584 +#: c-api/arg.rst:596 msgid "Convert a C :c:expr:`unsigned short int` to a Python integer object." msgstr "" -#: c-api/arg.rst:587 +#: c-api/arg.rst:599 msgid "Convert a C :c:expr:`unsigned int` to a Python integer object." msgstr "" -#: c-api/arg.rst:590 +#: c-api/arg.rst:602 msgid "Convert a C :c:expr:`unsigned long` to a Python integer object." msgstr "" -#: c-api/arg.rst:593 +#: c-api/arg.rst:605 msgid "Convert a C :c:expr:`long long` to a Python integer object." msgstr "" -#: c-api/arg.rst:596 +#: c-api/arg.rst:608 msgid "Convert a C :c:expr:`unsigned long long` to a Python integer object." msgstr "" -#: c-api/arg.rst:599 +#: c-api/arg.rst:611 msgid "Convert a C :c:type:`Py_ssize_t` to a Python integer." msgstr "" -#: c-api/arg.rst:603 +#: c-api/arg.rst:613 msgid "``c`` (:class:`bytes` of length 1) [char]" msgstr "" -#: c-api/arg.rst:602 +#: c-api/arg.rst:614 msgid "" "Convert a C :c:expr:`int` representing a byte to a Python :class:`bytes` " "object of length 1." msgstr "" -#: c-api/arg.rst:606 +#: c-api/arg.rst:618 msgid "" "Convert a C :c:expr:`int` representing a character to Python :class:`str` " "object of length 1." msgstr "" -#: c-api/arg.rst:610 -msgid "Convert a C :c:expr:`double` to a Python floating point number." +#: c-api/arg.rst:622 +msgid "Convert a C :c:expr:`double` to a Python floating-point number." msgstr "" -#: c-api/arg.rst:613 -msgid "Convert a C :c:expr:`float` to a Python floating point number." +#: c-api/arg.rst:625 +msgid "Convert a C :c:expr:`float` to a Python floating-point number." msgstr "" -#: c-api/arg.rst:616 +#: c-api/arg.rst:627 msgid "``D`` (:class:`complex`) [Py_complex \\*]" msgstr "" -#: c-api/arg.rst:616 +#: c-api/arg.rst:628 msgid "Convert a C :c:type:`Py_complex` structure to a Python complex number." msgstr "" -#: c-api/arg.rst:619 +#: c-api/arg.rst:631 msgid "" "Pass a Python object untouched but create a new :term:`strong reference` to " "it (i.e. its reference count is incremented by one). If the object passed in " "is a ``NULL`` pointer, it is assumed that this was caused because the call " -"producing the argument found an error and set an exception. Therefore, :c:" -"func:`Py_BuildValue` will return ``NULL`` but won't raise an exception. If " -"no exception has been raised yet, :exc:`SystemError` is set." +"producing the argument found an error and set an exception. " +"Therefore, :c:func:`Py_BuildValue` will return ``NULL`` but won't raise an " +"exception. If no exception has been raised yet, :exc:`SystemError` is set." msgstr "" -#: c-api/arg.rst:629 +#: c-api/arg.rst:640 msgid "``S`` (object) [PyObject \\*]" msgstr "" -#: c-api/arg.rst:629 +#: c-api/arg.rst:641 msgid "Same as ``O``." msgstr "" -#: c-api/arg.rst:634 +#: c-api/arg.rst:643 msgid "``N`` (object) [PyObject \\*]" msgstr "" -#: c-api/arg.rst:632 +#: c-api/arg.rst:644 msgid "" "Same as ``O``, except it doesn't create a new :term:`strong reference`. " "Useful when the object is created by a call to an object constructor in the " "argument list." msgstr "" -#: c-api/arg.rst:637 +#: c-api/arg.rst:648 +msgid "``O&`` (object) [*converter*, *anything*]" +msgstr "" + +#: c-api/arg.rst:649 msgid "" "Convert *anything* to a Python object through a *converter* function. The " -"function is called with *anything* (which should be compatible with :c:expr:" -"`void*`) as its argument and should return a \"new\" Python object, or " -"``NULL`` if an error occurred." +"function is called with *anything* (which should be compatible " +"with :c:expr:`void*`) as its argument and should return a \"new\" Python " +"object, or ``NULL`` if an error occurred." msgstr "" -#: c-api/arg.rst:643 +#: c-api/arg.rst:655 msgid "" "Convert a sequence of C values to a Python tuple with the same number of " "items." msgstr "" -#: c-api/arg.rst:646 +#: c-api/arg.rst:657 msgid "``[items]`` (:class:`list`) [*matching-items*]" msgstr "" -#: c-api/arg.rst:646 +#: c-api/arg.rst:658 msgid "" "Convert a sequence of C values to a Python list with the same number of " "items." msgstr "" -#: c-api/arg.rst:651 +#: c-api/arg.rst:660 msgid "``{items}`` (:class:`dict`) [*matching-items*]" msgstr "" -#: c-api/arg.rst:649 +#: c-api/arg.rst:661 msgid "" "Convert a sequence of C values to a Python dictionary. Each pair of " "consecutive C values adds one item to the dictionary, serving as key and " "value, respectively." msgstr "" -#: c-api/arg.rst:653 +#: c-api/arg.rst:665 msgid "" "If there is an error in the format string, the :exc:`SystemError` exception " "is set and ``NULL`` returned." msgstr "" -#: c-api/arg.rst:658 +#: c-api/arg.rst:670 msgid "" "Identical to :c:func:`Py_BuildValue`, except that it accepts a va_list " "rather than a variable number of arguments." diff --git a/c-api/bool.po b/c-api/bool.po index 9d32a9b6..8a681fbd 100644 --- a/c-api/bool.po +++ b/c-api/bool.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/c-api/buffer.po b/c-api/buffer.po index 3f0fdc38..793ef16d 100644 --- a/c-api/buffer.po +++ b/c-api/buffer.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -23,10 +24,10 @@ msgstr "" #: c-api/buffer.rst:18 msgid "" "Certain objects available in Python wrap access to an underlying memory " -"array or *buffer*. Such objects include the built-in :class:`bytes` and :" -"class:`bytearray`, and some extension types like :class:`array.array`. Third-" -"party libraries may define their own types for special purposes, such as " -"image processing or numeric analysis." +"array or *buffer*. Such objects include the built-in :class:`bytes` " +"and :class:`bytearray`, and some extension types like :class:`array.array`. " +"Third-party libraries may define their own types for special purposes, such " +"as image processing or numeric analysis." msgstr "" #: c-api/buffer.rst:24 @@ -39,8 +40,8 @@ msgstr "" #: c-api/buffer.rst:29 msgid "" -"Python provides such a facility at the C level in the form of the :ref:" -"`buffer protocol `. This protocol has two sides:" +"Python provides such a facility at the C level in the form of " +"the :ref:`buffer protocol `. This protocol has two sides:" msgstr "" #: c-api/buffer.rst:34 @@ -66,14 +67,14 @@ msgstr "" #: c-api/buffer.rst:45 msgid "" -"An example consumer of the buffer interface is the :meth:`~io.BufferedIOBase." -"write` method of file objects: any object that can export a series of bytes " -"through the buffer interface can be written to a file. While :meth:`!write` " -"only needs read-only access to the internal contents of the object passed to " -"it, other methods such as :meth:`~io.BufferedIOBase.readinto` need write " -"access to the contents of their argument. The buffer interface allows " -"objects to selectively allow or reject exporting of read-write and read-only " -"buffers." +"An example consumer of the buffer interface is " +"the :meth:`~io.BufferedIOBase.write` method of file objects: any object that " +"can export a series of bytes through the buffer interface can be written to " +"a file. While :meth:`!write` only needs read-only access to the internal " +"contents of the object passed to it, other methods such " +"as :meth:`~io.BufferedIOBase.readinto` need write access to the contents of " +"their argument. The buffer interface allows objects to selectively allow or " +"reject exporting of read-write and read-only buffers." msgstr "" #: c-api/buffer.rst:53 @@ -127,8 +128,8 @@ msgstr "" #: c-api/buffer.rst:86 msgid "" "For short instructions how to write an exporting object, see :ref:`Buffer " -"Object Structures `. For obtaining a buffer, see :c:func:" -"`PyObject_GetBuffer`." +"Object Structures `. For obtaining a buffer, " +"see :c:func:`PyObject_GetBuffer`." msgstr "" #: c-api/buffer.rst:94 @@ -155,9 +156,9 @@ msgstr "" #: c-api/buffer.rst:111 msgid "" -"As a special case, for *temporary* buffers that are wrapped by :c:func:" -"`PyMemoryView_FromBuffer` or :c:func:`PyBuffer_FillInfo` this field is " -"``NULL``. In general, exporting objects MUST NOT use this scheme." +"As a special case, for *temporary* buffers that are wrapped " +"by :c:func:`PyMemoryView_FromBuffer` or :c:func:`PyBuffer_FillInfo` this " +"field is ``NULL``. In general, exporting objects MUST NOT use this scheme." msgstr "" #: c-api/buffer.rst:118 @@ -172,8 +173,8 @@ msgstr "" msgid "" "Accessing ``((char *)buf)[0] up to ((char *)buf)[len-1]`` is only valid if " "the buffer has been obtained by a request that guarantees contiguity. In " -"most cases such a request will be :c:macro:`PyBUF_SIMPLE` or :c:macro:" -"`PyBUF_WRITABLE`." +"most cases such a request will be :c:macro:`PyBUF_SIMPLE` " +"or :c:macro:`PyBUF_WRITABLE`." msgstr "" #: c-api/buffer.rst:129 @@ -184,35 +185,37 @@ msgstr "" #: c-api/buffer.rst:134 msgid "" -"Item size in bytes of a single element. Same as the value of :func:`struct." -"calcsize` called on non-``NULL`` :c:member:`~Py_buffer.format` values." +"Item size in bytes of a single element. Same as the value " +"of :func:`struct.calcsize` called on non-" +"``NULL`` :c:member:`~Py_buffer.format` values." msgstr "" #: c-api/buffer.rst:137 msgid "" -"Important exception: If a consumer requests a buffer without the :c:macro:" -"`PyBUF_FORMAT` flag, :c:member:`~Py_buffer.format` will be set to " -"``NULL``, but :c:member:`~Py_buffer.itemsize` still has the value for the " -"original format." +"Important exception: If a consumer requests a buffer without " +"the :c:macro:`PyBUF_FORMAT` flag, :c:member:`~Py_buffer.format` will be set " +"to ``NULL``, but :c:member:`~Py_buffer.itemsize` still has the value for " +"the original format." msgstr "" #: c-api/buffer.rst:142 msgid "" "If :c:member:`~Py_buffer.shape` is present, the equality ``product(shape) * " -"itemsize == len`` still holds and the consumer can use :c:member:`~Py_buffer." -"itemsize` to navigate the buffer." +"itemsize == len`` still holds and the consumer can " +"use :c:member:`~Py_buffer.itemsize` to navigate the buffer." msgstr "" #: c-api/buffer.rst:146 msgid "" -"If :c:member:`~Py_buffer.shape` is ``NULL`` as a result of a :c:macro:" -"`PyBUF_SIMPLE` or a :c:macro:`PyBUF_WRITABLE` request, the consumer must " -"disregard :c:member:`~Py_buffer.itemsize` and assume ``itemsize == 1``." +"If :c:member:`~Py_buffer.shape` is ``NULL`` as a result of " +"a :c:macro:`PyBUF_SIMPLE` or a :c:macro:`PyBUF_WRITABLE` request, the " +"consumer must disregard :c:member:`~Py_buffer.itemsize` and assume " +"``itemsize == 1``." msgstr "" #: c-api/buffer.rst:152 msgid "" -"A *NUL* terminated string in :mod:`struct` module style syntax describing " +"A *NULL* terminated string in :mod:`struct` module style syntax describing " "the contents of a single item. If this is ``NULL``, ``\"B\"`` (unsigned " "bytes) is assumed." msgstr "" @@ -225,17 +228,18 @@ msgstr "" msgid "" "The number of dimensions the memory represents as an n-dimensional array. If " "it is ``0``, :c:member:`~Py_buffer.buf` points to a single item representing " -"a scalar. In this case, :c:member:`~Py_buffer.shape`, :c:member:`~Py_buffer." -"strides` and :c:member:`~Py_buffer.suboffsets` MUST be ``NULL``. The maximum " -"number of dimensions is given by :c:macro:`PyBUF_MAX_NDIM`." +"a scalar. In this " +"case, :c:member:`~Py_buffer.shape`, :c:member:`~Py_buffer.strides` " +"and :c:member:`~Py_buffer.suboffsets` MUST be ``NULL``. The maximum number " +"of dimensions is given by :c:macro:`PyBUF_MAX_NDIM`." msgstr "" #: c-api/buffer.rst:168 msgid "" "An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim` " "indicating the shape of the memory as an n-dimensional array. Note that " -"``shape[0] * ... * shape[ndim-1] * itemsize`` MUST be equal to :c:member:" -"`~Py_buffer.len`." +"``shape[0] * ... * shape[ndim-1] * itemsize`` MUST be equal " +"to :c:member:`~Py_buffer.len`." msgstr "" #: c-api/buffer.rst:173 @@ -334,21 +338,21 @@ msgstr "" #: c-api/buffer.rst:243 msgid "" "The following fields are not influenced by *flags* and must always be filled " -"in with the correct values: :c:member:`~Py_buffer.obj`, :c:member:" -"`~Py_buffer.buf`, :c:member:`~Py_buffer.len`, :c:member:`~Py_buffer." -"itemsize`, :c:member:`~Py_buffer.ndim`." +"in with the correct " +"values: :c:member:`~Py_buffer.obj`, :c:member:`~Py_buffer.buf`, :c:member:`~Py_buffer.len`, :c:member:`~Py_buffer.itemsize`, :c:member:`~Py_buffer.ndim`." msgstr "" -#: c-api/buffer.rst:249 +#: c-api/buffer.rst:248 msgid "readonly, format" msgstr "" -#: c-api/buffer.rst:253 +#: c-api/buffer.rst:252 msgid "" "Controls the :c:member:`~Py_buffer.readonly` field. If set, the exporter " "MUST provide a writable buffer or else report failure. Otherwise, the " "exporter MAY provide either a read-only or writable buffer, but the choice " -"MUST be consistent for all consumers." +"MUST be consistent for all consumers. For example, :c:expr:`PyBUF_SIMPLE | " +"PyBUF_WRITABLE` can be used to request a simple writable buffer." msgstr "" #: c-api/buffer.rst:260 @@ -360,170 +364,208 @@ msgstr "" #: c-api/buffer.rst:264 msgid "" ":c:macro:`PyBUF_WRITABLE` can be \\|'d to any of the flags in the next " -"section. Since :c:macro:`PyBUF_SIMPLE` is defined as 0, :c:macro:" -"`PyBUF_WRITABLE` can be used as a stand-alone flag to request a simple " -"writable buffer." +"section. Since :c:macro:`PyBUF_SIMPLE` is defined as " +"0, :c:macro:`PyBUF_WRITABLE` can be used as a stand-alone flag to request a " +"simple writable buffer." msgstr "" #: c-api/buffer.rst:268 msgid "" -":c:macro:`PyBUF_FORMAT` can be \\|'d to any of the flags except :c:macro:" -"`PyBUF_SIMPLE`. The latter already implies format ``B`` (unsigned bytes)." +":c:macro:`PyBUF_FORMAT` must be \\|'d to any of the flags " +"except :c:macro:`PyBUF_SIMPLE`, because the latter already implies format " +"``B`` (unsigned bytes). :c:macro:`!PyBUF_FORMAT` cannot be used on its own." msgstr "" -#: c-api/buffer.rst:273 +#: c-api/buffer.rst:274 msgid "shape, strides, suboffsets" msgstr "" -#: c-api/buffer.rst:275 +#: c-api/buffer.rst:276 msgid "" "The flags that control the logical structure of the memory are listed in " "decreasing order of complexity. Note that each flag contains all bits of the " "flags below it." msgstr "" -#: c-api/buffer.rst:306 c-api/buffer.rst:331 +#: c-api/buffer.rst:307 c-api/buffer.rst:332 msgid "Request" msgstr "" -#: c-api/buffer.rst:306 c-api/buffer.rst:331 +#: c-api/buffer.rst:307 c-api/buffer.rst:332 msgid "shape" msgstr "" -#: c-api/buffer.rst:306 c-api/buffer.rst:331 +#: c-api/buffer.rst:307 c-api/buffer.rst:332 msgid "strides" msgstr "" -#: c-api/buffer.rst:306 c-api/buffer.rst:331 +#: c-api/buffer.rst:307 c-api/buffer.rst:332 msgid "suboffsets" msgstr "" -#: c-api/buffer.rst:286 c-api/buffer.rst:308 c-api/buffer.rst:312 -#: c-api/buffer.rst:333 c-api/buffer.rst:337 c-api/buffer.rst:341 -#: c-api/buffer.rst:345 c-api/buffer.rst:347 +#: c-api/buffer.rst:287 c-api/buffer.rst:309 c-api/buffer.rst:313 +#: c-api/buffer.rst:334 c-api/buffer.rst:338 c-api/buffer.rst:342 +#: c-api/buffer.rst:346 c-api/buffer.rst:348 msgid "yes" msgstr "" -#: c-api/buffer.rst:333 c-api/buffer.rst:335 +#: c-api/buffer.rst:334 c-api/buffer.rst:336 msgid "if needed" msgstr "" -#: c-api/buffer.rst:288 c-api/buffer.rst:308 c-api/buffer.rst:312 -#: c-api/buffer.rst:337 c-api/buffer.rst:341 c-api/buffer.rst:345 -#: c-api/buffer.rst:347 +#: c-api/buffer.rst:289 c-api/buffer.rst:309 c-api/buffer.rst:313 +#: c-api/buffer.rst:338 c-api/buffer.rst:342 c-api/buffer.rst:346 +#: c-api/buffer.rst:348 msgid "NULL" msgstr "" -#: c-api/buffer.rst:297 +#: c-api/buffer.rst:298 msgid "contiguity requests" msgstr "" -#: c-api/buffer.rst:299 +#: c-api/buffer.rst:300 msgid "" "C or Fortran :term:`contiguity ` can be explicitly requested, " "with and without stride information. Without stride information, the buffer " "must be C-contiguous." msgstr "" -#: c-api/buffer.rst:331 +#: c-api/buffer.rst:332 msgid "contig" msgstr "" -#: c-api/buffer.rst:314 c-api/buffer.rst:347 +#: c-api/buffer.rst:315 c-api/buffer.rst:348 msgid "C" msgstr "" -#: c-api/buffer.rst:310 +#: c-api/buffer.rst:311 msgid "F" msgstr "" -#: c-api/buffer.rst:312 +#: c-api/buffer.rst:313 msgid "C or F" msgstr "" -#: c-api/buffer.rst:314 +#: c-api/buffer.rst:315 msgid ":c:macro:`PyBUF_ND`" msgstr "" -#: c-api/buffer.rst:319 +#: c-api/buffer.rst:320 msgid "compound requests" msgstr "" -#: c-api/buffer.rst:321 +#: c-api/buffer.rst:322 msgid "" "All possible requests are fully defined by some combination of the flags in " "the previous section. For convenience, the buffer protocol provides " "frequently used combinations as single flags." msgstr "" -#: c-api/buffer.rst:325 +#: c-api/buffer.rst:326 msgid "" "In the following table *U* stands for undefined contiguity. The consumer " "would have to call :c:func:`PyBuffer_IsContiguous` to determine contiguity." msgstr "" -#: c-api/buffer.rst:331 +#: c-api/buffer.rst:332 msgid "readonly" msgstr "" -#: c-api/buffer.rst:331 +#: c-api/buffer.rst:332 msgid "format" msgstr "" -#: c-api/buffer.rst:335 c-api/buffer.rst:339 c-api/buffer.rst:343 +#: c-api/buffer.rst:336 c-api/buffer.rst:340 c-api/buffer.rst:344 msgid "U" msgstr "" -#: c-api/buffer.rst:337 c-api/buffer.rst:345 +#: c-api/buffer.rst:338 c-api/buffer.rst:346 msgid "0" msgstr "" -#: c-api/buffer.rst:339 c-api/buffer.rst:347 +#: c-api/buffer.rst:340 c-api/buffer.rst:348 msgid "1 or 0" msgstr "" -#: c-api/buffer.rst:352 +#: c-api/buffer.rst:353 msgid "Complex arrays" msgstr "" -#: c-api/buffer.rst:355 +#: c-api/buffer.rst:356 msgid "NumPy-style: shape and strides" msgstr "" -#: c-api/buffer.rst:357 +#: c-api/buffer.rst:358 msgid "" -"The logical structure of NumPy-style arrays is defined by :c:member:" -"`~Py_buffer.itemsize`, :c:member:`~Py_buffer.ndim`, :c:member:`~Py_buffer." -"shape` and :c:member:`~Py_buffer.strides`." +"The logical structure of NumPy-style arrays is defined " +"by :c:member:`~Py_buffer.itemsize`, :c:member:`~Py_buffer.ndim`, :c:member:`~Py_buffer.shape` " +"and :c:member:`~Py_buffer.strides`." msgstr "" -#: c-api/buffer.rst:360 +#: c-api/buffer.rst:361 msgid "" -"If ``ndim == 0``, the memory location pointed to by :c:member:`~Py_buffer." -"buf` is interpreted as a scalar of size :c:member:`~Py_buffer.itemsize`. In " -"that case, both :c:member:`~Py_buffer.shape` and :c:member:`~Py_buffer." -"strides` are ``NULL``." +"If ``ndim == 0``, the memory location pointed to " +"by :c:member:`~Py_buffer.buf` is interpreted as a scalar of " +"size :c:member:`~Py_buffer.itemsize`. In that case, " +"both :c:member:`~Py_buffer.shape` and :c:member:`~Py_buffer.strides` are " +"``NULL``." msgstr "" -#: c-api/buffer.rst:364 +#: c-api/buffer.rst:365 msgid "" "If :c:member:`~Py_buffer.strides` is ``NULL``, the array is interpreted as a " "standard n-dimensional C-array. Otherwise, the consumer must access an n-" "dimensional array as follows:" msgstr "" -#: c-api/buffer.rst:374 +#: c-api/buffer.rst:369 +msgid "" +"ptr = (char *)buf + indices[0] * strides[0] + ... + indices[n-1] * " +"strides[n-1];\n" +"item = *((typeof(item) *)ptr);" +msgstr "" + +#: c-api/buffer.rst:375 msgid "" "As noted above, :c:member:`~Py_buffer.buf` can point to any location within " "the actual memory block. An exporter can check the validity of a buffer with " "this function:" msgstr "" -#: c-api/buffer.rst:408 +#: c-api/buffer.rst:379 +msgid "" +"def verify_structure(memlen, itemsize, ndim, shape, strides, offset):\n" +" \"\"\"Verify that the parameters represent a valid array within\n" +" the bounds of the allocated memory:\n" +" char *mem: start of the physical memory block\n" +" memlen: length of the physical memory block\n" +" offset: (char *)buf - mem\n" +" \"\"\"\n" +" if offset % itemsize:\n" +" return False\n" +" if offset < 0 or offset+itemsize > memlen:\n" +" return False\n" +" if any(v % itemsize for v in strides):\n" +" return False\n" +"\n" +" if ndim <= 0:\n" +" return ndim == 0 and not shape and not strides\n" +" if 0 in shape:\n" +" return True\n" +"\n" +" imin = sum(strides[j]*(shape[j]-1) for j in range(ndim)\n" +" if strides[j] <= 0)\n" +" imax = sum(strides[j]*(shape[j]-1) for j in range(ndim)\n" +" if strides[j] > 0)\n" +"\n" +" return 0 <= offset+imin and offset+imax+itemsize <= memlen" +msgstr "" + +#: c-api/buffer.rst:409 msgid "PIL-style: shape, strides and suboffsets" msgstr "" -#: c-api/buffer.rst:410 +#: c-api/buffer.rst:411 msgid "" "In addition to the regular items, PIL-style arrays can contain pointers that " "must be followed in order to get to the next element in a dimension. For " @@ -534,32 +576,48 @@ msgid "" "x[2][3]`` arrays that can be located anywhere in memory." msgstr "" -#: c-api/buffer.rst:419 +#: c-api/buffer.rst:420 msgid "" "Here is a function that returns a pointer to the element in an N-D array " "pointed to by an N-dimensional index when there are both non-``NULL`` " "strides and suboffsets::" msgstr "" -#: c-api/buffer.rst:438 +#: c-api/buffer.rst:424 +msgid "" +"void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,\n" +" Py_ssize_t *suboffsets, Py_ssize_t *indices) {\n" +" char *pointer = (char*)buf;\n" +" int i;\n" +" for (i = 0; i < ndim; i++) {\n" +" pointer += strides[i] * indices[i];\n" +" if (suboffsets[i] >=0 ) {\n" +" pointer = *((char**)pointer) + suboffsets[i];\n" +" }\n" +" }\n" +" return (void*)pointer;\n" +"}" +msgstr "" + +#: c-api/buffer.rst:439 msgid "Buffer-related functions" msgstr "" -#: c-api/buffer.rst:442 +#: c-api/buffer.rst:443 msgid "" "Return ``1`` if *obj* supports the buffer interface otherwise ``0``. When " "``1`` is returned, it doesn't guarantee that :c:func:`PyObject_GetBuffer` " "will succeed. This function always succeeds." msgstr "" -#: c-api/buffer.rst:449 +#: c-api/buffer.rst:450 msgid "" "Send a request to *exporter* to fill in *view* as specified by *flags*. If " -"the exporter cannot provide a buffer of the exact type, it MUST raise :exc:" -"`BufferError`, set ``view->obj`` to ``NULL`` and return ``-1``." +"the exporter cannot provide a buffer of the exact type, it MUST " +"raise :exc:`BufferError`, set ``view->obj`` to ``NULL`` and return ``-1``." msgstr "" -#: c-api/buffer.rst:454 +#: c-api/buffer.rst:455 msgid "" "On success, fill in *view*, set ``view->obj`` to a new reference to " "*exporter* and return 0. In the case of chained buffer providers that " @@ -567,15 +625,15 @@ msgid "" "instead of *exporter* (See :ref:`Buffer Object Structures `)." msgstr "" -#: c-api/buffer.rst:459 +#: c-api/buffer.rst:460 msgid "" "Successful calls to :c:func:`PyObject_GetBuffer` must be paired with calls " -"to :c:func:`PyBuffer_Release`, similar to :c:func:`malloc` and :c:func:" -"`free`. Thus, after the consumer is done with the buffer, :c:func:" -"`PyBuffer_Release` must be called exactly once." +"to :c:func:`PyBuffer_Release`, similar to :c:func:`malloc` " +"and :c:func:`free`. Thus, after the consumer is done with the " +"buffer, :c:func:`PyBuffer_Release` must be called exactly once." msgstr "" -#: c-api/buffer.rst:467 +#: c-api/buffer.rst:468 msgid "" "Release the buffer *view* and release the :term:`strong reference` (i.e. " "decrement the reference count) to the view's supporting object, ``view-" @@ -583,19 +641,20 @@ msgid "" "used, otherwise reference leaks may occur." msgstr "" -#: c-api/buffer.rst:472 +#: c-api/buffer.rst:473 msgid "" -"It is an error to call this function on a buffer that was not obtained via :" -"c:func:`PyObject_GetBuffer`." +"It is an error to call this function on a buffer that was not obtained " +"via :c:func:`PyObject_GetBuffer`." msgstr "" -#: c-api/buffer.rst:478 +#: c-api/buffer.rst:479 msgid "" -"Return the implied :c:member:`~Py_buffer.itemsize` from :c:member:" -"`~Py_buffer.format`. On error, raise an exception and return -1." +"Return the implied :c:member:`~Py_buffer.itemsize` " +"from :c:member:`~Py_buffer.format`. On error, raise an exception and return " +"-1." msgstr "" -#: c-api/buffer.rst:486 +#: c-api/buffer.rst:487 msgid "" "Return ``1`` if the memory defined by the *view* is C-style (*order* is " "``'C'``) or Fortran-style (*order* is ``'F'``) :term:`contiguous` or either " @@ -603,69 +662,69 @@ msgid "" "succeeds." msgstr "" -#: c-api/buffer.rst:493 +#: c-api/buffer.rst:494 msgid "" "Get the memory area pointed to by the *indices* inside the given *view*. " "*indices* must point to an array of ``view->ndim`` indices." msgstr "" -#: c-api/buffer.rst:499 +#: c-api/buffer.rst:500 msgid "" "Copy contiguous *len* bytes from *buf* to *view*. *fort* can be ``'C'`` or " "``'F'`` (for C-style or Fortran-style ordering). ``0`` is returned on " "success, ``-1`` on error." msgstr "" -#: c-api/buffer.rst:506 +#: c-api/buffer.rst:507 msgid "" "Copy *len* bytes from *src* to its contiguous representation in *buf*. " "*order* can be ``'C'`` or ``'F'`` or ``'A'`` (for C-style or Fortran-style " "ordering or either one). ``0`` is returned on success, ``-1`` on error." msgstr "" -#: c-api/buffer.rst:510 +#: c-api/buffer.rst:511 msgid "This function fails if *len* != *src->len*." msgstr "" -#: c-api/buffer.rst:515 +#: c-api/buffer.rst:516 msgid "" "Copy data from *src* to *dest* buffer. Can convert between C-style and or " "Fortran-style buffers." msgstr "" -#: c-api/buffer.rst:518 +#: c-api/buffer.rst:519 msgid "``0`` is returned on success, ``-1`` on error." msgstr "" -#: c-api/buffer.rst:522 +#: c-api/buffer.rst:523 msgid "" "Fill the *strides* array with byte-strides of a :term:`contiguous` (C-style " "if *order* is ``'C'`` or Fortran-style if *order* is ``'F'``) array of the " "given shape with the given number of bytes per element." msgstr "" -#: c-api/buffer.rst:529 +#: c-api/buffer.rst:530 msgid "" "Handle buffer requests for an exporter that wants to expose *buf* of size " "*len* with writability set according to *readonly*. *buf* is interpreted as " "a sequence of unsigned bytes." msgstr "" -#: c-api/buffer.rst:533 +#: c-api/buffer.rst:534 msgid "" "The *flags* argument indicates the request type. This function always fills " "in *view* as specified by flags, unless *buf* has been designated as read-" "only and :c:macro:`PyBUF_WRITABLE` is set in *flags*." msgstr "" -#: c-api/buffer.rst:537 +#: c-api/buffer.rst:538 msgid "" "On success, set ``view->obj`` to a new reference to *exporter* and return 0. " "Otherwise, raise :exc:`BufferError`, set ``view->obj`` to ``NULL`` and " "return ``-1``;" msgstr "" -#: c-api/buffer.rst:541 +#: c-api/buffer.rst:542 msgid "" "If this function is used as part of a :ref:`getbufferproc `, " "*exporter* MUST be set to the exporting object and *flags* must be passed " @@ -692,14 +751,14 @@ msgstr "" msgid "PyBufferProcs (C type)" msgstr "" -#: c-api/buffer.rst:294 +#: c-api/buffer.rst:295 msgid "contiguous" msgstr "" -#: c-api/buffer.rst:294 +#: c-api/buffer.rst:295 msgid "C-contiguous" msgstr "" -#: c-api/buffer.rst:294 +#: c-api/buffer.rst:295 msgid "Fortran contiguous" msgstr "" diff --git a/c-api/bytearray.po b/c-api/bytearray.po index fc57d389..ff3f83e3 100644 --- a/c-api/bytearray.po +++ b/c-api/bytearray.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -53,48 +54,50 @@ msgstr "" #: c-api/bytearray.rst:42 msgid "" -"Return a new bytearray object from any object, *o*, that implements the :ref:" -"`buffer protocol `." +"Return a new bytearray object from any object, *o*, that implements " +"the :ref:`buffer protocol `." msgstr "" -#: c-api/bytearray.rst:48 -msgid "" -"Create a new bytearray object from *string* and its length, *len*. On " -"failure, ``NULL`` is returned." +#: c-api/bytearray.rst:52 c-api/bytearray.rst:59 +msgid "On failure, return ``NULL`` with an exception set." +msgstr "" + +#: c-api/bytearray.rst:50 +msgid "Create a new bytearray object from *string* and its length, *len*." msgstr "" -#: c-api/bytearray.rst:54 +#: c-api/bytearray.rst:57 msgid "" "Concat bytearrays *a* and *b* and return a new bytearray with the result." msgstr "" -#: c-api/bytearray.rst:59 +#: c-api/bytearray.rst:64 msgid "Return the size of *bytearray* after checking for a ``NULL`` pointer." msgstr "" -#: c-api/bytearray.rst:64 +#: c-api/bytearray.rst:69 msgid "" "Return the contents of *bytearray* as a char array after checking for a " "``NULL`` pointer. The returned array always has an extra null byte appended." msgstr "" -#: c-api/bytearray.rst:71 +#: c-api/bytearray.rst:76 msgid "Resize the internal buffer of *bytearray* to *len*." msgstr "" -#: c-api/bytearray.rst:74 +#: c-api/bytearray.rst:79 msgid "Macros" msgstr "" -#: c-api/bytearray.rst:76 +#: c-api/bytearray.rst:81 msgid "These macros trade safety for speed and they don't check pointers." msgstr "" -#: c-api/bytearray.rst:80 +#: c-api/bytearray.rst:85 msgid "Similar to :c:func:`PyByteArray_AsString`, but without error checking." msgstr "" -#: c-api/bytearray.rst:85 +#: c-api/bytearray.rst:90 msgid "Similar to :c:func:`PyByteArray_Size`, but without error checking." msgstr "" diff --git a/c-api/bytes.po b/c-api/bytes.po index 80a3d0a2..d39420f8 100644 --- a/c-api/bytes.po +++ b/c-api/bytes.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -258,8 +259,8 @@ msgid "" "buffer is always null, regardless of whether there are any other null " "bytes. The data must not be modified in any way, unless the object was just " "created using ``PyBytes_FromStringAndSize(NULL, size)``. It must not be " -"deallocated. If *o* is not a bytes object at all, :c:func:" -"`PyBytes_AsString` returns ``NULL`` and raises :exc:`TypeError`." +"deallocated. If *o* is not a bytes object at " +"all, :c:func:`PyBytes_AsString` returns ``NULL`` and raises :exc:`TypeError`." msgstr "" #: c-api/bytes.rst:151 diff --git a/c-api/call.po b/c-api/call.po index 7574569d..08e3e4d1 100644 --- a/c-api/call.po +++ b/c-api/call.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -35,6 +36,11 @@ msgid "" "callable. The signature of the slot is::" msgstr "" +#: c-api/call.rst:17 +msgid "" +"PyObject *tp_call(PyObject *callable, PyObject *args, PyObject *kwargs);" +msgstr "" + #: c-api/call.rst:19 msgid "" "A call is made using a tuple for the positional arguments and a dict for the " @@ -45,8 +51,9 @@ msgstr "" #: c-api/call.rst:25 msgid "" -"This convention is not only used by *tp_call*: :c:member:`~PyTypeObject." -"tp_new` and :c:member:`~PyTypeObject.tp_init` also pass arguments this way." +"This convention is not only used by " +"*tp_call*: :c:member:`~PyTypeObject.tp_new` " +"and :c:member:`~PyTypeObject.tp_init` also pass arguments this way." msgstr "" #: c-api/call.rst:29 @@ -69,18 +76,19 @@ msgstr "" msgid "" "As rule of thumb, CPython will prefer the vectorcall for internal calls if " "the callable supports it. However, this is not a hard rule. Additionally, " -"some third-party extensions use *tp_call* directly (rather than using :c:" -"func:`PyObject_Call`). Therefore, a class supporting vectorcall must also " -"implement :c:member:`~PyTypeObject.tp_call`. Moreover, the callable must " -"behave the same regardless of which protocol is used. The recommended way to " -"achieve this is by setting :c:member:`~PyTypeObject.tp_call` to :c:func:" -"`PyVectorcall_Call`. This bears repeating:" +"some third-party extensions use *tp_call* directly (rather than " +"using :c:func:`PyObject_Call`). Therefore, a class supporting vectorcall " +"must also implement :c:member:`~PyTypeObject.tp_call`. Moreover, the " +"callable must behave the same regardless of which protocol is used. The " +"recommended way to achieve this is by " +"setting :c:member:`~PyTypeObject.tp_call` to :c:func:`PyVectorcall_Call`. " +"This bears repeating:" msgstr "" #: c-api/call.rst:57 msgid "" -"A class supporting vectorcall **must** also implement :c:member:" -"`~PyTypeObject.tp_call` with the same semantics." +"A class supporting vectorcall **must** also " +"implement :c:member:`~PyTypeObject.tp_call` with the same semantics." msgstr "" #: c-api/call.rst:62 @@ -103,18 +111,18 @@ msgstr "" #: c-api/call.rst:74 msgid "" -"Classes can implement the vectorcall protocol by enabling the :c:macro:" -"`Py_TPFLAGS_HAVE_VECTORCALL` flag and setting :c:member:`~PyTypeObject." -"tp_vectorcall_offset` to the offset inside the object structure where a " -"*vectorcallfunc* appears. This is a pointer to a function with the following " -"signature:" +"Classes can implement the vectorcall protocol by enabling " +"the :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` flag and " +"setting :c:member:`~PyTypeObject.tp_vectorcall_offset` to the offset inside " +"the object structure where a *vectorcallfunc* appears. This is a pointer to " +"a function with the following signature:" msgstr "" #: c-api/call.rst:82 msgid "*callable* is the object being called." msgstr "" -#: c-api/call.rst:84 +#: c-api/call.rst:83 msgid "" "*args* is a C array consisting of the positional arguments followed by the" msgstr "" @@ -125,7 +133,7 @@ msgid "" "arguments." msgstr "" -#: c-api/call.rst:88 +#: c-api/call.rst:86 msgid "*nargsf* is the number of positional arguments plus possibly the" msgstr "" @@ -135,7 +143,7 @@ msgid "" "positional arguments from *nargsf*, use :c:func:`PyVectorcall_NARGS`." msgstr "" -#: c-api/call.rst:94 +#: c-api/call.rst:90 msgid "*kwnames* is a tuple containing the names of the keyword arguments;" msgstr "" @@ -194,8 +202,8 @@ msgstr "" #: c-api/call.rst:134 msgid "" "When using *tp_call*, callees do not need to worry about :ref:`recursion " -"`: CPython uses :c:func:`Py_EnterRecursiveCall` and :c:func:" -"`Py_LeaveRecursiveCall` for calls made using *tp_call*." +"`: CPython uses :c:func:`Py_EnterRecursiveCall` " +"and :c:func:`Py_LeaveRecursiveCall` for calls made using *tp_call*." msgstr "" #: c-api/call.rst:139 @@ -215,6 +223,10 @@ msgid "" "Currently equivalent to::" msgstr "" +#: c-api/call.rst:153 +msgid "(Py_ssize_t)(nargsf & ~PY_VECTORCALL_ARGUMENTS_OFFSET)" +msgstr "" + #: c-api/call.rst:155 msgid "" "However, the function ``PyVectorcall_NARGS`` should be used to allow for " @@ -243,10 +255,10 @@ msgstr "" #: c-api/call.rst:177 msgid "" -"This is a specialized function, intended to be put in the :c:member:" -"`~PyTypeObject.tp_call` slot or be used in an implementation of ``tp_call``. " -"It does not check the :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` flag and it does " -"not fall back to ``tp_call``." +"This is a specialized function, intended to be put in " +"the :c:member:`~PyTypeObject.tp_call` slot or be used in an implementation " +"of ``tp_call``. It does not check the :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` " +"flag and it does not fall back to ``tp_call``." msgstr "" #: c-api/call.rst:188 @@ -441,8 +453,8 @@ msgstr "" #: c-api/call.rst:289 msgid "" -"Note that if you only pass :c:expr:`PyObject *` args, :c:func:" -"`PyObject_CallFunctionObjArgs` is a faster alternative." +"Note that if you only pass :c:expr:`PyObject *` " +"args, :c:func:`PyObject_CallFunctionObjArgs` is a faster alternative." msgstr "" #: c-api/call.rst:292 @@ -468,8 +480,8 @@ msgstr "" #: c-api/call.rst:310 msgid "" -"Note that if you only pass :c:expr:`PyObject *` args, :c:func:" -"`PyObject_CallMethodObjArgs` is a faster alternative." +"Note that if you only pass :c:expr:`PyObject *` " +"args, :c:func:`PyObject_CallMethodObjArgs` is a faster alternative." msgstr "" #: c-api/call.rst:313 @@ -478,9 +490,9 @@ msgstr "" #: c-api/call.rst:319 msgid "" -"Call a callable Python object *callable*, with a variable number of :c:expr:" -"`PyObject *` arguments. The arguments are provided as a variable number of " -"parameters followed by *NULL*." +"Call a callable Python object *callable*, with a variable number " +"of :c:expr:`PyObject *` arguments. The arguments are provided as a variable " +"number of parameters followed by *NULL*." msgstr "" #: c-api/call.rst:326 @@ -512,9 +524,9 @@ msgstr "" #: c-api/call.rst:366 msgid "" -"Call a callable Python object *callable*. The arguments are the same as for :" -"c:type:`vectorcallfunc`. If *callable* supports vectorcall_, this directly " -"calls the vectorcall function stored in *callable*." +"Call a callable Python object *callable*. The arguments are the same as " +"for :c:type:`vectorcallfunc`. If *callable* supports vectorcall_, this " +"directly calls the vectorcall function stored in *callable*." msgstr "" #: c-api/call.rst:378 @@ -538,10 +550,10 @@ msgid "" "method is given as a Python string *name*. The object whose method is called " "is *args[0]*, and the *args* array starting at *args[1]* represents the " "arguments of the call. There must be at least one positional argument. " -"*nargsf* is the number of positional arguments including *args[0]*, plus :c:" -"macro:`PY_VECTORCALL_ARGUMENTS_OFFSET` if the value of ``args[0]`` may " -"temporarily be changed. Keyword arguments can be passed just like in :c:func:" -"`PyObject_Vectorcall`." +"*nargsf* is the number of positional arguments including *args[0]*, " +"plus :c:macro:`PY_VECTORCALL_ARGUMENTS_OFFSET` if the value of ``args[0]`` " +"may temporarily be changed. Keyword arguments can be passed just like " +"in :c:func:`PyObject_Vectorcall`." msgstr "" #: c-api/call.rst:401 diff --git a/c-api/capsule.po b/c-api/capsule.po index 3e2f66df..8f6c4a67 100644 --- a/c-api/capsule.po +++ b/c-api/capsule.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -39,6 +40,10 @@ msgstr "" msgid "The type of a destructor callback for a capsule. Defined as::" msgstr "" +#: c-api/capsule.rst:29 +msgid "typedef void (*PyCapsule_Destructor)(PyObject *);" +msgstr "" + #: c-api/capsule.rst:31 msgid "" "See :c:func:`PyCapsule_New` for the semantics of PyCapsule_Destructor " @@ -104,8 +109,8 @@ msgstr "" #: c-api/capsule.rst:76 msgid "" "It is legal for a capsule to have a ``NULL`` destructor. This makes a " -"``NULL`` return code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` or :" -"c:func:`PyErr_Occurred` to disambiguate." +"``NULL`` return code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` " +"or :c:func:`PyErr_Occurred` to disambiguate." msgstr "" #: c-api/capsule.rst:83 @@ -117,8 +122,8 @@ msgstr "" #: c-api/capsule.rst:86 msgid "" "It is legal for a capsule to have a ``NULL`` context. This makes a ``NULL`` " -"return code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` or :c:func:" -"`PyErr_Occurred` to disambiguate." +"return code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` " +"or :c:func:`PyErr_Occurred` to disambiguate." msgstr "" #: c-api/capsule.rst:93 @@ -130,8 +135,8 @@ msgstr "" #: c-api/capsule.rst:96 msgid "" "It is legal for a capsule to have a ``NULL`` name. This makes a ``NULL`` " -"return code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` or :c:func:" -"`PyErr_Occurred` to disambiguate." +"return code somewhat ambiguous; use :c:func:`PyCapsule_IsValid` " +"or :c:func:`PyErr_Occurred` to disambiguate." msgstr "" #: c-api/capsule.rst:103 diff --git a/c-api/cell.po b/c-api/cell.po index b32d87fc..608f4130 100644 --- a/c-api/cell.po +++ b/c-api/cell.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -53,24 +54,31 @@ msgid "" msgstr "" #: c-api/cell.rst:42 -msgid "Return the contents of the cell *cell*." +msgid "" +"Return the contents of the cell *cell*, which can be ``NULL``. If *cell* is " +"not a cell object, returns ``NULL`` with an exception set." msgstr "" -#: c-api/cell.rst:47 +#: c-api/cell.rst:48 msgid "" "Return the contents of the cell *cell*, but without checking that *cell* is " "non-``NULL`` and a cell object." msgstr "" -#: c-api/cell.rst:53 +#: c-api/cell.rst:54 msgid "" "Set the contents of the cell object *cell* to *value*. This releases the " "reference to any current content of the cell. *value* may be ``NULL``. " -"*cell* must be non-``NULL``; if it is not a cell object, ``-1`` will be " -"returned. On success, ``0`` will be returned." +"*cell* must be non-``NULL``." +msgstr "" + +#: c-api/cell.rst:58 +msgid "" +"On success, return ``0``. If *cell* is not a cell object, set an exception " +"and return ``-1``." msgstr "" -#: c-api/cell.rst:61 +#: c-api/cell.rst:64 msgid "" "Sets the value of the cell object *cell* to *value*. No reference counts " "are adjusted, and no checks are made for safety; *cell* must be non-``NULL`` " diff --git a/c-api/code.po b/c-api/code.po index c06cf0fe..fe5abb73 100644 --- a/c-api/code.po +++ b/c-api/code.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -35,8 +36,8 @@ msgstr "" #: c-api/code.rst:24 msgid "" -"This is an instance of :c:type:`PyTypeObject` representing the Python :ref:" -"`code object `." +"This is an instance of :c:type:`PyTypeObject` representing the " +"Python :ref:`code object `." msgstr "" #: c-api/code.rst:30 @@ -61,8 +62,9 @@ msgstr "" #: c-api/code.rst:46 msgid "" -"Since the definition of the bytecode changes often, calling :c:func:" -"`PyUnstable_Code_New` directly can bind you to a precise Python version." +"Since the definition of the bytecode changes often, " +"calling :c:func:`PyUnstable_Code_New` directly can bind you to a precise " +"Python version." msgstr "" #: c-api/code.rst:49 @@ -119,9 +121,9 @@ msgstr "" #: c-api/code.rst:93 msgid "" -"For efficiently iterating over the line numbers in a code object, use `the " -"API described in PEP 626 `_." +"For efficiently iterating over the line numbers in a code object, " +"use :pep:`the API described in PEP 626 <0626#out-of-process-debuggers-and-" +"profilers>`." msgstr "" #: c-api/code.rst:98 @@ -181,10 +183,10 @@ msgstr "" #: c-api/code.rst:156 msgid "" -"Clear watcher identified by *watcher_id* previously returned from :c:func:" -"`PyCode_AddWatcher` for the current interpreter. Return ``0`` on success, or " -"``-1`` and set an exception on error (e.g. if the given *watcher_id* was " -"never registered.)" +"Clear watcher identified by *watcher_id* previously returned " +"from :c:func:`PyCode_AddWatcher` for the current interpreter. Return ``0`` " +"on success, or ``-1`` and set an exception on error (e.g. if the given " +"*watcher_id* was never registered.)" msgstr "" #: c-api/code.rst:165 @@ -226,8 +228,8 @@ msgstr "" #: c-api/code.rst:192 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " -"will be printed as an unraisable exception using :c:func:" -"`PyErr_WriteUnraisable`. Otherwise it should return ``0``." +"will be printed as an unraisable exception " +"using :c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" #: c-api/code.rst:196 @@ -271,8 +273,8 @@ msgstr "" #: c-api/code.rst:224 msgid "" "If *free* is not ``NULL``: when a code object is deallocated, *free* will be " -"called on non-``NULL`` data stored under the new index. Use :c:func:" -"`Py_DecRef` when storing :c:type:`PyObject`." +"called on non-``NULL`` data stored under the new index. " +"Use :c:func:`Py_DecRef` when storing :c:type:`PyObject`." msgstr "" #: c-api/code.rst:230 diff --git a/c-api/codec.po b/c-api/codec.po index c914c599..56d70bc0 100644 --- a/c-api/codec.po +++ b/c-api/codec.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -51,8 +52,8 @@ msgstr "" msgid "" "*object* is passed through the encoder function found for the given " "*encoding* using the error handling method defined by *errors*. *errors* " -"may be ``NULL`` to use the default method defined for the codec. Raises a :" -"exc:`LookupError` if no encoder can be found." +"may be ``NULL`` to use the default method defined for the codec. Raises " +"a :exc:`LookupError` if no encoder can be found." msgstr "" #: c-api/codec.rst:37 @@ -63,8 +64,8 @@ msgstr "" msgid "" "*object* is passed through the decoder function found for the given " "*encoding* using the error handling method defined by *errors*. *errors* " -"may be ``NULL`` to use the default method defined for the codec. Raises a :" -"exc:`LookupError` if no encoder can be found." +"may be ``NULL`` to use the default method defined for the codec. Raises " +"a :exc:`LookupError` if no encoder can be found." msgstr "" #: c-api/codec.rst:46 @@ -75,8 +76,8 @@ msgstr "" msgid "" "In the following functions, the *encoding* string is looked up converted to " "all lower-case characters, which makes encodings looked up through this " -"mechanism effectively case-insensitive. If no codec is found, a :exc:" -"`KeyError` is set and ``NULL`` returned." +"mechanism effectively case-insensitive. If no codec is found, " +"a :exc:`KeyError` is set and ``NULL`` returned." msgstr "" #: c-api/codec.rst:55 @@ -123,9 +124,9 @@ msgstr "" #: c-api/codec.rst:88 msgid "" -"The callback gets a single argument, an instance of :exc:" -"`UnicodeEncodeError`, :exc:`UnicodeDecodeError` or :exc:" -"`UnicodeTranslateError` that holds information about the problematic " +"The callback gets a single argument, an instance " +"of :exc:`UnicodeEncodeError`, :exc:`UnicodeDecodeError` " +"or :exc:`UnicodeTranslateError` that holds information about the problematic " "sequence of characters or bytes and their offset in the original string " "(see :ref:`unicodeexceptions` for functions to extract this information). " "The callback must either raise the given exception, or return a two-item " diff --git a/c-api/complex.po b/c-api/complex.po index 4497cf24..8a574309 100644 --- a/c-api/complex.po +++ b/c-api/complex.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -44,117 +45,143 @@ msgid "" "The C structure which corresponds to the value portion of a Python complex " "number object. Most of the functions for dealing with complex number " "objects use structures of this type as input or output values, as " -"appropriate. It is defined as::" +"appropriate." msgstr "" -#: c-api/complex.rst:39 +#: c-api/complex.rst:33 +msgid "The structure is defined as::" +msgstr "" + +#: c-api/complex.rst:35 +msgid "" +"typedef struct {\n" +" double real;\n" +" double imag;\n" +"} Py_complex;" +msgstr "" + +#: c-api/complex.rst:43 msgid "" "Return the sum of two complex numbers, using the C :c:type:`Py_complex` " "representation." msgstr "" -#: c-api/complex.rst:45 +#: c-api/complex.rst:49 msgid "" -"Return the difference between two complex numbers, using the C :c:type:" -"`Py_complex` representation." +"Return the difference between two complex numbers, using the " +"C :c:type:`Py_complex` representation." msgstr "" -#: c-api/complex.rst:51 +#: c-api/complex.rst:55 msgid "" -"Return the negation of the complex number *num*, using the C :c:type:" -"`Py_complex` representation." +"Return the negation of the complex number *num*, using the " +"C :c:type:`Py_complex` representation." msgstr "" -#: c-api/complex.rst:57 +#: c-api/complex.rst:61 msgid "" "Return the product of two complex numbers, using the C :c:type:`Py_complex` " "representation." msgstr "" -#: c-api/complex.rst:63 +#: c-api/complex.rst:67 msgid "" "Return the quotient of two complex numbers, using the C :c:type:`Py_complex` " "representation." msgstr "" -#: c-api/complex.rst:66 +#: c-api/complex.rst:70 msgid "" -"If *divisor* is null, this method returns zero and sets :c:data:`errno` to :" -"c:macro:`!EDOM`." +"If *divisor* is null, this method returns zero and sets :c:data:`errno` " +"to :c:macro:`!EDOM`." msgstr "" -#: c-api/complex.rst:72 +#: c-api/complex.rst:76 msgid "" -"Return the exponentiation of *num* by *exp*, using the C :c:type:" -"`Py_complex` representation." +"Return the exponentiation of *num* by *exp*, using the " +"C :c:type:`Py_complex` representation." msgstr "" -#: c-api/complex.rst:75 +#: c-api/complex.rst:79 msgid "" "If *num* is null and *exp* is not a positive real number, this method " "returns zero and sets :c:data:`errno` to :c:macro:`!EDOM`." msgstr "" -#: c-api/complex.rst:80 +#: c-api/complex.rst:84 msgid "Complex Numbers as Python Objects" msgstr "" -#: c-api/complex.rst:85 +#: c-api/complex.rst:89 msgid "" "This subtype of :c:type:`PyObject` represents a Python complex number object." msgstr "" -#: c-api/complex.rst:90 +#: c-api/complex.rst:94 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python complex number " "type. It is the same object as :class:`complex` in the Python layer." msgstr "" -#: c-api/complex.rst:96 +#: c-api/complex.rst:100 msgid "" -"Return true if its argument is a :c:type:`PyComplexObject` or a subtype of :" -"c:type:`PyComplexObject`. This function always succeeds." +"Return true if its argument is a :c:type:`PyComplexObject` or a subtype " +"of :c:type:`PyComplexObject`. This function always succeeds." msgstr "" -#: c-api/complex.rst:102 +#: c-api/complex.rst:106 msgid "" "Return true if its argument is a :c:type:`PyComplexObject`, but not a " "subtype of :c:type:`PyComplexObject`. This function always succeeds." msgstr "" -#: c-api/complex.rst:108 +#: c-api/complex.rst:112 msgid "" "Create a new Python complex number object from a C :c:type:`Py_complex` " -"value." +"value. Return ``NULL`` with an exception set on error." msgstr "" -#: c-api/complex.rst:113 -msgid "Return a new :c:type:`PyComplexObject` object from *real* and *imag*." +#: c-api/complex.rst:118 +msgid "" +"Return a new :c:type:`PyComplexObject` object from *real* and *imag*. Return " +"``NULL`` with an exception set on error." msgstr "" -#: c-api/complex.rst:118 +#: c-api/complex.rst:124 msgid "Return the real part of *op* as a C :c:expr:`double`." msgstr "" -#: c-api/complex.rst:123 +#: c-api/complex.rst:126 +msgid "" +"Upon failure, this method returns ``-1.0`` with an exception set, so one " +"should call :c:func:`PyErr_Occurred` to check for errors." +msgstr "" + +#: c-api/complex.rst:132 msgid "Return the imaginary part of *op* as a C :c:expr:`double`." msgstr "" -#: c-api/complex.rst:128 +#: c-api/complex.rst:137 msgid "Return the :c:type:`Py_complex` value of the complex number *op*." msgstr "" -#: c-api/complex.rst:130 +#: c-api/complex.rst:139 msgid "" -"If *op* is not a Python complex number object but has a :meth:`~object." -"__complex__` method, this method will first be called to convert *op* to a " -"Python complex number object. If :meth:`!__complex__` is not defined then " -"it falls back to :meth:`~object.__float__`. If :meth:`!__float__` is not " -"defined then it falls back to :meth:`~object.__index__`. Upon failure, this " -"method returns ``-1.0`` as a real value." +"If *op* is not a Python complex number object but has " +"a :meth:`~object.__complex__` method, this method will first be called to " +"convert *op* to a Python complex number object. If :meth:`!__complex__` is " +"not defined then it falls back to :meth:`~object.__float__`. If :meth:`!" +"__float__` is not defined then it falls back to :meth:`~object.__index__`." msgstr "" -#: c-api/complex.rst:137 +#: c-api/complex.rst:145 +msgid "" +"Upon failure, this method returns :c:type:`Py_complex` " +"with :c:member:`~Py_complex.real` set to ``-1.0`` and with an exception set, " +"so one should call :c:func:`PyErr_Occurred` to check for errors." +msgstr "" + +#: c-api/complex.rst:149 msgid "Use :meth:`~object.__index__` if available." msgstr "" diff --git a/c-api/concrete.po b/c-api/concrete.po index 982c836e..66612f84 100644 --- a/c-api/concrete.po +++ b/c-api/concrete.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/c-api/contextvars.po b/c-api/contextvars.po index b03b40c0..262c650b 100644 --- a/c-api/contextvars.po +++ b/c-api/contextvars.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -23,8 +24,18 @@ msgstr "" #: c-api/contextvars.rst:15 msgid "" "In Python 3.7.1 the signatures of all context variables C APIs were " -"**changed** to use :c:type:`PyObject` pointers instead of :c:type:" -"`PyContext`, :c:type:`PyContextVar`, and :c:type:`PyContextToken`, e.g.::" +"**changed** to use :c:type:`PyObject` pointers instead " +"of :c:type:`PyContext`, :c:type:`PyContextVar`, " +"and :c:type:`PyContextToken`, e.g.::" +msgstr "" + +#: c-api/contextvars.rst:20 +msgid "" +"// in 3.7.0:\n" +"PyContext *PyContext_New(void);\n" +"\n" +"// in 3.7.1+:\n" +"PyObject *PyContext_New(void);" msgstr "" #: c-api/contextvars.rst:26 @@ -168,7 +179,7 @@ msgstr "" #: c-api/contextvars.rst:136 msgid "" -"Reset the state of the *var* context variable to that it was in before :c:" -"func:`PyContextVar_Set` that returned the *token* was called. This function " -"returns ``0`` on success and ``-1`` on error." +"Reset the state of the *var* context variable to that it was in " +"before :c:func:`PyContextVar_Set` that returned the *token* was called. This " +"function returns ``0`` on success and ``-1`` on error." msgstr "" diff --git a/c-api/conversion.po b/c-api/conversion.po index 4adfc374..ae7a6296 100644 --- a/c-api/conversion.po +++ b/c-api/conversion.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -27,15 +28,15 @@ msgstr "" #: c-api/conversion.rst:13 msgid "" "Output not more than *size* bytes to *str* according to the format string " -"*format* and the extra arguments. See the Unix man page :manpage:" -"`snprintf(3)`." +"*format* and the extra arguments. See the Unix man " +"page :manpage:`snprintf(3)`." msgstr "" #: c-api/conversion.rst:19 msgid "" "Output not more than *size* bytes to *str* according to the format string " -"*format* and the variable argument list *va*. Unix man page :manpage:" -"`vsnprintf(3)`." +"*format* and the variable argument list *va*. Unix man " +"page :manpage:`vsnprintf(3)`." msgstr "" #: c-api/conversion.rst:23 @@ -107,9 +108,9 @@ msgstr "" #: c-api/conversion.rst:63 msgid "" "If the converted value falls out of range of corresponding return type, " -"range error occurs (:c:data:`errno` is set to :c:macro:`!ERANGE`) and :c:" -"macro:`!ULONG_MAX` is returned. If no conversion can be performed, ``0`` is " -"returned." +"range error occurs (:c:data:`errno` is set to :c:macro:`!ERANGE`) " +"and :c:macro:`!ULONG_MAX` is returned. If no conversion can be performed, " +"``0`` is returned." msgstr "" #: c-api/conversion.rst:68 @@ -144,9 +145,9 @@ msgstr "" #: c-api/conversion.rst:95 msgid "" -"If ``endptr`` is ``NULL``, convert the whole string. Raise :exc:" -"`ValueError` and return ``-1.0`` if the string is not a valid representation " -"of a floating-point number." +"If ``endptr`` is ``NULL``, convert the whole string. " +"Raise :exc:`ValueError` and return ``-1.0`` if the string is not a valid " +"representation of a floating-point number." msgstr "" #: c-api/conversion.rst:99 diff --git a/c-api/coro.po b/c-api/coro.po index 02ca0e92..d9cbd489 100644 --- a/c-api/coro.po +++ b/c-api/coro.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/c-api/datetime.po b/c-api/datetime.po index beab3acc..e07b8e77 100644 --- a/c-api/datetime.po +++ b/c-api/datetime.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,11 +25,11 @@ msgstr "" msgid "" "Various date and time objects are supplied by the :mod:`datetime` module. " "Before using any of these functions, the header file :file:`datetime.h` must " -"be included in your source (note that this is not included by :file:`Python." -"h`), and the macro :c:macro:`!PyDateTime_IMPORT` must be invoked, usually as " -"part of the module initialisation function. The macro puts a pointer to a C " -"structure into a static variable, :c:data:`!PyDateTimeAPI`, that is used by " -"the following macros." +"be included in your source (note that this is not included " +"by :file:`Python.h`), and the macro :c:macro:`!PyDateTime_IMPORT` must be " +"invoked, usually as part of the module initialisation function. The macro " +"puts a pointer to a C structure into a static variable, :c:data:`!" +"PyDateTimeAPI`, that is used by the following macros." msgstr "" #: c-api/datetime.rst:18 @@ -70,8 +71,8 @@ msgstr "" #: c-api/datetime.rst:49 msgid "" "This instance of :c:type:`PyTypeObject` represents Python type for the " -"difference between two datetime values; it is the same object as :class:" -"`datetime.timedelta` in the Python layer." +"difference between two datetime values; it is the same object " +"as :class:`datetime.timedelta` in the Python layer." msgstr "" #: c-api/datetime.rst:55 @@ -86,8 +87,8 @@ msgstr "" #: c-api/datetime.rst:63 msgid "" -"Returns the time zone singleton representing UTC, the same object as :attr:" -"`datetime.timezone.utc`." +"Returns the time zone singleton representing UTC, the same object " +"as :attr:`datetime.timezone.utc`." msgstr "" #: c-api/datetime.rst:69 @@ -216,9 +217,9 @@ msgstr "" #: c-api/datetime.rst:195 msgid "" "Macros to extract fields from date objects. The argument must be an " -"instance of :c:type:`PyDateTime_Date`, including subclasses (such as :c:type:" -"`PyDateTime_DateTime`). The argument must not be ``NULL``, and the type is " -"not checked:" +"instance of :c:type:`PyDateTime_Date`, including subclasses (such " +"as :c:type:`PyDateTime_DateTime`). The argument must not be ``NULL``, and " +"the type is not checked:" msgstr "" #: c-api/datetime.rst:202 @@ -297,11 +298,11 @@ msgstr "" #: c-api/datetime.rst:320 msgid "" "Create and return a new :class:`datetime.datetime` object given an argument " -"tuple suitable for passing to :meth:`datetime.datetime.fromtimestamp()`." +"tuple suitable for passing to :meth:`datetime.datetime.fromtimestamp`." msgstr "" #: c-api/datetime.rst:326 msgid "" "Create and return a new :class:`datetime.date` object given an argument " -"tuple suitable for passing to :meth:`datetime.date.fromtimestamp()`." +"tuple suitable for passing to :meth:`datetime.date.fromtimestamp`." msgstr "" diff --git a/c-api/descriptor.po b/c-api/descriptor.po index 6fd6003f..57b0b014 100644 --- a/c-api/descriptor.po +++ b/c-api/descriptor.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/c-api/dict.po b/c-api/dict.po index d8f15d56..2da803a8 100644 --- a/c-api/dict.po +++ b/c-api/dict.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -71,32 +72,32 @@ msgstr "" #: c-api/dict.rst:65 msgid "" -"Insert *val* into the dictionary *p* with a key of *key*. *key* must be :" -"term:`hashable`; if it isn't, :exc:`TypeError` will be raised. Return ``0`` " -"on success or ``-1`` on failure. This function *does not* steal a reference " -"to *val*." +"Insert *val* into the dictionary *p* with a key of *key*. *key* must " +"be :term:`hashable`; if it isn't, :exc:`TypeError` will be raised. Return " +"``0`` on success or ``-1`` on failure. This function *does not* steal a " +"reference to *val*." msgstr "" #: c-api/dict.rst:73 msgid "" -"This is the same as :c:func:`PyDict_SetItem`, but *key* is specified as a :c:" -"expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"This is the same as :c:func:`PyDict_SetItem`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" #: c-api/dict.rst:80 msgid "" -"Remove the entry in dictionary *p* with key *key*. *key* must be :term:" -"`hashable`; if it isn't, :exc:`TypeError` is raised. If *key* is not in the " -"dictionary, :exc:`KeyError` is raised. Return ``0`` on success or ``-1`` on " -"failure." +"Remove the entry in dictionary *p* with key *key*. *key* must " +"be :term:`hashable`; if it isn't, :exc:`TypeError` is raised. If *key* is " +"not in the dictionary, :exc:`KeyError` is raised. Return ``0`` on success or " +"``-1`` on failure." msgstr "" #: c-api/dict.rst:88 msgid "" -"This is the same as :c:func:`PyDict_DelItem`, but *key* is specified as a :c:" -"expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"This is the same as :c:func:`PyDict_DelItem`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" #: c-api/dict.rst:95 @@ -107,9 +108,9 @@ msgstr "" #: c-api/dict.rst:100 msgid "" -"Exceptions that occur while this calls :meth:`~object.__hash__` and :meth:" -"`~object.__eq__` methods are silently ignored. Prefer the :c:func:" -"`PyDict_GetItemWithError` function instead." +"Exceptions that occur while this calls :meth:`~object.__hash__` " +"and :meth:`~object.__eq__` methods are silently ignored. Prefer " +"the :c:func:`PyDict_GetItemWithError` function instead." msgstr "" #: c-api/dict.rst:104 @@ -127,17 +128,18 @@ msgstr "" #: c-api/dict.rst:119 msgid "" -"This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as a :c:" -"expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" #: c-api/dict.rst:125 msgid "" -"Exceptions that occur while this calls :meth:`~object.__hash__` and :meth:" -"`~object.__eq__` methods or while creating the temporary :class:`str` object " -"are silently ignored. Prefer using the :c:func:`PyDict_GetItemWithError` " -"function with your own :c:func:`PyUnicode_FromString` *key* instead." +"Exceptions that occur while this calls :meth:`~object.__hash__` " +"and :meth:`~object.__eq__` methods or while creating the " +"temporary :class:`str` object are silently ignored. Prefer using " +"the :c:func:`PyDict_GetItemWithError` function with your " +"own :c:func:`PyUnicode_FromString` *key* instead." msgstr "" #: c-api/dict.rst:134 @@ -174,22 +176,33 @@ msgstr "" #: c-api/dict.rst:168 msgid "" -"Iterate over all key-value pairs in the dictionary *p*. The :c:type:" -"`Py_ssize_t` referred to by *ppos* must be initialized to ``0`` prior to the " -"first call to this function to start the iteration; the function returns " -"true for each pair in the dictionary, and false once all pairs have been " -"reported. The parameters *pkey* and *pvalue* should either point to :c:expr:" -"`PyObject*` variables that will be filled in with each key and value, " -"respectively, or may be ``NULL``. Any references returned through them are " -"borrowed. *ppos* should not be altered during iteration. Its value " -"represents offsets within the internal dictionary structure, and since the " -"structure is sparse, the offsets are not consecutive." +"Iterate over all key-value pairs in the dictionary *p*. " +"The :c:type:`Py_ssize_t` referred to by *ppos* must be initialized to ``0`` " +"prior to the first call to this function to start the iteration; the " +"function returns true for each pair in the dictionary, and false once all " +"pairs have been reported. The parameters *pkey* and *pvalue* should either " +"point to :c:expr:`PyObject*` variables that will be filled in with each key " +"and value, respectively, or may be ``NULL``. Any references returned " +"through them are borrowed. *ppos* should not be altered during iteration. " +"Its value represents offsets within the internal dictionary structure, and " +"since the structure is sparse, the offsets are not consecutive." msgstr "" #: c-api/dict.rst:179 msgid "For example::" msgstr "" +#: c-api/dict.rst:181 +msgid "" +"PyObject *key, *value;\n" +"Py_ssize_t pos = 0;\n" +"\n" +"while (PyDict_Next(self->dict, &pos, &key, &value)) {\n" +" /* do something interesting with the values... */\n" +" ...\n" +"}" +msgstr "" + #: c-api/dict.rst:189 msgid "" "The dictionary *p* should not be mutated during iteration. It is safe to " @@ -197,6 +210,27 @@ msgid "" "so long as the set of keys does not change. For example::" msgstr "" +#: c-api/dict.rst:193 +msgid "" +"PyObject *key, *value;\n" +"Py_ssize_t pos = 0;\n" +"\n" +"while (PyDict_Next(self->dict, &pos, &key, &value)) {\n" +" long i = PyLong_AsLong(value);\n" +" if (i == -1 && PyErr_Occurred()) {\n" +" return -1;\n" +" }\n" +" PyObject *o = PyLong_FromLong(i + 1);\n" +" if (o == NULL)\n" +" return -1;\n" +" if (PyDict_SetItem(self->dict, key, o) < 0) {\n" +" Py_DECREF(o);\n" +" return -1;\n" +" }\n" +" Py_DECREF(o);\n" +"}" +msgstr "" + #: c-api/dict.rst:214 msgid "" "Iterate over mapping object *b* adding key-value pairs to dictionary *a*. " @@ -209,10 +243,10 @@ msgstr "" #: c-api/dict.rst:224 msgid "" -"This is the same as ``PyDict_Merge(a, b, 1)`` in C, and is similar to ``a." -"update(b)`` in Python except that :c:func:`PyDict_Update` doesn't fall back " -"to the iterating over a sequence of key value pairs if the second argument " -"has no \"keys\" attribute. Return ``0`` on success or ``-1`` if an " +"This is the same as ``PyDict_Merge(a, b, 1)`` in C, and is similar to " +"``a.update(b)`` in Python except that :c:func:`PyDict_Update` doesn't fall " +"back to the iterating over a sequence of key value pairs if the second " +"argument has no \"keys\" attribute. Return ``0`` on success or ``-1`` if an " "exception was raised." msgstr "" @@ -225,6 +259,14 @@ msgid "" "if an exception was raised. Equivalent Python (except for the return value)::" msgstr "" +#: c-api/dict.rst:240 +msgid "" +"def PyDict_MergeFromSeq2(a, seq2, override):\n" +" for key, value in seq2:\n" +" if override or key not in a:\n" +" a[key] = value" +msgstr "" + #: c-api/dict.rst:247 msgid "" "Register *callback* as a dictionary watcher. Return a non-negative integer " @@ -235,15 +277,15 @@ msgstr "" #: c-api/dict.rst:256 msgid "" -"Clear watcher identified by *watcher_id* previously returned from :c:func:" -"`PyDict_AddWatcher`. Return ``0`` on success, ``-1`` on error (e.g. if the " -"given *watcher_id* was never registered.)" +"Clear watcher identified by *watcher_id* previously returned " +"from :c:func:`PyDict_AddWatcher`. Return ``0`` on success, ``-1`` on error " +"(e.g. if the given *watcher_id* was never registered.)" msgstr "" #: c-api/dict.rst:264 msgid "" -"Mark dictionary *dict* as watched. The callback granted *watcher_id* by :c:" -"func:`PyDict_AddWatcher` will be called when *dict* is modified or " +"Mark dictionary *dict* as watched. The callback granted *watcher_id* " +"by :c:func:`PyDict_AddWatcher` will be called when *dict* is modified or " "deallocated. Return ``0`` on success or ``-1`` on error." msgstr "" @@ -309,8 +351,8 @@ msgstr "" #: c-api/dict.rst:316 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " -"will be printed as an unraisable exception using :c:func:" -"`PyErr_WriteUnraisable`. Otherwise it should return ``0``." +"will be printed as an unraisable exception " +"using :c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" #: c-api/dict.rst:320 diff --git a/c-api/exceptions.po b/c-api/exceptions.po index e4804e04..464eea0a 100644 --- a/c-api/exceptions.po +++ b/c-api/exceptions.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -57,7 +58,7 @@ msgstr "" #: c-api/exceptions.rst:37 msgid "" -"The error indicator is **not** the result of :func:`sys.exc_info()`. The " +"The error indicator is **not** the result of :func:`sys.exc_info`. The " "former corresponds to an exception that is not yet caught (and is therefore " "still propagating), while the latter returns an exception after it is caught " "(and has therefore stopped propagating)." @@ -91,9 +92,9 @@ msgstr "" msgid "" "If *set_sys_last_vars* is nonzero, the variable :data:`sys.last_exc` is set " "to the printed exception. For backwards compatibility, the deprecated " -"variables :data:`sys.last_type`, :data:`sys.last_value` and :data:`sys." -"last_traceback` are also set to the type, value and traceback of this " -"exception, respectively." +"variables :data:`sys.last_type`, :data:`sys.last_value` " +"and :data:`sys.last_traceback` are also set to the type, value and traceback " +"of this exception, respectively." msgstr "" #: c-api/exceptions.rst:69 @@ -174,8 +175,8 @@ msgstr "" msgid "" "This function sets the error indicator and returns ``NULL``. *exception* " "should be a Python exception class. The *format* and subsequent parameters " -"help format the error message; they have the same meaning and values as in :" -"c:func:`PyUnicode_FromFormat`. *format* is an ASCII-encoded string." +"help format the error message; they have the same meaning and values as " +"in :c:func:`PyUnicode_FromFormat`. *format* is an ASCII-encoded string." msgstr "" #: c-api/exceptions.rst:143 @@ -207,13 +208,14 @@ msgid "" "This is a convenience function to raise an exception when a C library " "function has returned an error and set the C variable :c:data:`errno`. It " "constructs a tuple object whose first item is the integer :c:data:`errno` " -"value and whose second item is the corresponding error message (gotten from :" -"c:func:`!strerror`), and then calls ``PyErr_SetObject(type, object)``. On " -"Unix, when the :c:data:`errno` value is :c:macro:`!EINTR`, indicating an " -"interrupted system call, this calls :c:func:`PyErr_CheckSignals`, and if " -"that set the error indicator, leaves it set to that. The function always " -"returns ``NULL``, so a wrapper function around a system call can write " -"``return PyErr_SetFromErrno(type);`` when the system call returns an error." +"value and whose second item is the corresponding error message (gotten " +"from :c:func:`!strerror`), and then calls ``PyErr_SetObject(type, " +"object)``. On Unix, when the :c:data:`errno` value is :c:macro:`!EINTR`, " +"indicating an interrupted system call, this " +"calls :c:func:`PyErr_CheckSignals`, and if that set the error indicator, " +"leaves it set to that. The function always returns ``NULL``, so a wrapper " +"function around a system call can write ``return PyErr_SetFromErrno(type);`` " +"when the system call returns an error." msgstr "" #: c-api/exceptions.rst:186 @@ -240,37 +242,38 @@ msgstr "" #: c-api/exceptions.rst:211 msgid "" -"This is a convenience function to raise :exc:`WindowsError`. If called with " +"This is a convenience function to raise :exc:`OSError`. If called with " "*ierr* of ``0``, the error code returned by a call to :c:func:`!" "GetLastError` is used instead. It calls the Win32 function :c:func:`!" "FormatMessage` to retrieve the Windows description of error code given by " -"*ierr* or :c:func:`!GetLastError`, then it constructs a tuple object whose " -"first item is the *ierr* value and whose second item is the corresponding " -"error message (gotten from :c:func:`!FormatMessage`), and then calls " -"``PyErr_SetObject(PyExc_WindowsError, object)``. This function always " -"returns ``NULL``." +"*ierr* or :c:func:`!GetLastError`, then it constructs a :exc:`OSError` " +"object with the :attr:`~OSError.winerror` attribute set to the error code, " +"the :attr:`~OSError.strerror` attribute set to the corresponding error " +"message (gotten from :c:func:`!FormatMessage`), and then calls " +"``PyErr_SetObject(PyExc_OSError, object)``. This function always returns " +"``NULL``." msgstr "" -#: c-api/exceptions.rst:228 c-api/exceptions.rst:249 c-api/exceptions.rst:267 -msgid ":ref:`Availability `: Windows." +#: c-api/exceptions.rst:229 c-api/exceptions.rst:250 c-api/exceptions.rst:268 +msgid "Availability" msgstr "" -#: c-api/exceptions.rst:225 +#: c-api/exceptions.rst:226 msgid "" "Similar to :c:func:`PyErr_SetFromWindowsErr`, with an additional parameter " "specifying the exception type to be raised." msgstr "" -#: c-api/exceptions.rst:233 +#: c-api/exceptions.rst:234 msgid "" "Similar to :c:func:`PyErr_SetFromWindowsErr`, with the additional behavior " "that if *filename* is not ``NULL``, it is decoded from the filesystem " -"encoding (:func:`os.fsdecode`) and passed to the constructor of :exc:" -"`OSError` as a third parameter to be used to define the :attr:`!filename` " -"attribute of the exception instance." +"encoding (:func:`os.fsdecode`) and passed to the constructor " +"of :exc:`OSError` as a third parameter to be used to define the :attr:`!" +"filename` attribute of the exception instance." msgstr "" -#: c-api/exceptions.rst:244 +#: c-api/exceptions.rst:245 msgid "" "Similar to :c:func:`PyErr_SetExcFromWindowsErr`, with the additional " "behavior that if *filename* is not ``NULL``, it is passed to the constructor " @@ -278,19 +281,19 @@ msgid "" "filename` attribute of the exception instance." msgstr "" -#: c-api/exceptions.rst:254 +#: c-api/exceptions.rst:255 msgid "" "Similar to :c:func:`PyErr_SetExcFromWindowsErrWithFilenameObject`, but " "accepts a second filename object." msgstr "" -#: c-api/exceptions.rst:264 +#: c-api/exceptions.rst:265 msgid "" "Similar to :c:func:`PyErr_SetFromWindowsErrWithFilename`, with an additional " "parameter specifying the exception type to be raised." msgstr "" -#: c-api/exceptions.rst:272 +#: c-api/exceptions.rst:273 msgid "" "This is a convenience function to raise :exc:`ImportError`. *msg* will be " "set as the exception's message string. *name* and *path*, both of which can " @@ -298,13 +301,13 @@ msgid "" "``path`` attributes." msgstr "" -#: c-api/exceptions.rst:282 +#: c-api/exceptions.rst:283 msgid "" "Much like :c:func:`PyErr_SetImportError` but this function allows for " "specifying a subclass of :exc:`ImportError` to raise." msgstr "" -#: c-api/exceptions.rst:290 +#: c-api/exceptions.rst:291 msgid "" "Set file, line, and offset information for the current exception. If the " "current exception is not a :exc:`SyntaxError`, then it sets additional " @@ -312,19 +315,19 @@ msgid "" "is a :exc:`SyntaxError`." msgstr "" -#: c-api/exceptions.rst:300 +#: c-api/exceptions.rst:301 msgid "" "Like :c:func:`PyErr_SyntaxLocationObject`, but *filename* is a byte string " "decoded from the :term:`filesystem encoding and error handler`." msgstr "" -#: c-api/exceptions.rst:308 +#: c-api/exceptions.rst:309 msgid "" "Like :c:func:`PyErr_SyntaxLocationEx`, but the *col_offset* parameter is " "omitted." msgstr "" -#: c-api/exceptions.rst:314 +#: c-api/exceptions.rst:315 msgid "" "This is a shorthand for ``PyErr_SetString(PyExc_SystemError, message)``, " "where *message* indicates that an internal operation (e.g. a Python/C API " @@ -332,11 +335,11 @@ msgid "" "use." msgstr "" -#: c-api/exceptions.rst:321 +#: c-api/exceptions.rst:322 msgid "Issuing warnings" msgstr "" -#: c-api/exceptions.rst:323 +#: c-api/exceptions.rst:324 msgid "" "Use these functions to issue warnings from C code. They mirror similar " "functions exported by the Python :mod:`warnings` module. They normally " @@ -352,94 +355,97 @@ msgid "" "return an error value)." msgstr "" -#: c-api/exceptions.rst:338 +#: c-api/exceptions.rst:339 msgid "" "Issue a warning message. The *category* argument is a warning category (see " "below) or ``NULL``; the *message* argument is a UTF-8 encoded string. " "*stack_level* is a positive number giving a number of stack frames; the " "warning will be issued from the currently executing line of code in that " -"stack frame. A *stack_level* of 1 is the function calling :c:func:" -"`PyErr_WarnEx`, 2 is the function above that, and so forth." +"stack frame. A *stack_level* of 1 is the function " +"calling :c:func:`PyErr_WarnEx`, 2 is the function above that, and so forth." msgstr "" -#: c-api/exceptions.rst:345 +#: c-api/exceptions.rst:346 msgid "" -"Warning categories must be subclasses of :c:data:`PyExc_Warning`; :c:data:" -"`PyExc_Warning` is a subclass of :c:data:`PyExc_Exception`; the default " -"warning category is :c:data:`PyExc_RuntimeWarning`. The standard Python " -"warning categories are available as global variables whose names are " -"enumerated at :ref:`standardwarningcategories`." +"Warning categories must be subclasses " +"of :c:data:`PyExc_Warning`; :c:data:`PyExc_Warning` is a subclass " +"of :c:data:`PyExc_Exception`; the default warning category " +"is :c:data:`PyExc_RuntimeWarning`. The standard Python warning categories " +"are available as global variables whose names are enumerated " +"at :ref:`standardwarningcategories`." msgstr "" -#: c-api/exceptions.rst:351 +#: c-api/exceptions.rst:352 msgid "" -"For information about warning control, see the documentation for the :mod:" -"`warnings` module and the :option:`-W` option in the command line " +"For information about warning control, see the documentation for " +"the :mod:`warnings` module and the :option:`-W` option in the command line " "documentation. There is no C API for warning control." msgstr "" -#: c-api/exceptions.rst:358 +#: c-api/exceptions.rst:359 msgid "" "Issue a warning message with explicit control over all warning attributes. " -"This is a straightforward wrapper around the Python function :func:`warnings." -"warn_explicit`; see there for more information. The *module* and *registry* " -"arguments may be set to ``NULL`` to get the default effect described there." +"This is a straightforward wrapper around the Python " +"function :func:`warnings.warn_explicit`; see there for more information. " +"The *module* and *registry* arguments may be set to ``NULL`` to get the " +"default effect described there." msgstr "" -#: c-api/exceptions.rst:369 +#: c-api/exceptions.rst:370 msgid "" "Similar to :c:func:`PyErr_WarnExplicitObject` except that *message* and " -"*module* are UTF-8 encoded strings, and *filename* is decoded from the :term:" -"`filesystem encoding and error handler`." +"*module* are UTF-8 encoded strings, and *filename* is decoded from " +"the :term:`filesystem encoding and error handler`." msgstr "" -#: c-api/exceptions.rst:376 +#: c-api/exceptions.rst:377 msgid "" -"Function similar to :c:func:`PyErr_WarnEx`, but use :c:func:" -"`PyUnicode_FromFormat` to format the warning message. *format* is an ASCII-" -"encoded string." +"Function similar to :c:func:`PyErr_WarnEx`, but " +"use :c:func:`PyUnicode_FromFormat` to format the warning message. *format* " +"is an ASCII-encoded string." msgstr "" -#: c-api/exceptions.rst:385 +#: c-api/exceptions.rst:386 msgid "" -"Function similar to :c:func:`PyErr_WarnFormat`, but *category* is :exc:" -"`ResourceWarning` and it passes *source* to :class:`!warnings." -"WarningMessage`." +"Function similar to :c:func:`PyErr_WarnFormat`, but *category* " +"is :exc:`ResourceWarning` and it passes *source* to :class:`!" +"warnings.WarningMessage`." msgstr "" -#: c-api/exceptions.rst:392 +#: c-api/exceptions.rst:393 msgid "Querying the error indicator" msgstr "" -#: c-api/exceptions.rst:396 +#: c-api/exceptions.rst:397 msgid "" "Test whether the error indicator is set. If set, return the exception " "*type* (the first argument to the last call to one of the ``PyErr_Set*`` " "functions or to :c:func:`PyErr_Restore`). If not set, return ``NULL``. You " -"do not own a reference to the return value, so you do not need to :c:func:" -"`Py_DECREF` it." +"do not own a reference to the return value, so you do not need " +"to :c:func:`Py_DECREF` it." msgstr "" -#: c-api/exceptions.rst:402 +#: c-api/exceptions.rst:403 msgid "The caller must hold the GIL." msgstr "" -#: c-api/exceptions.rst:406 +#: c-api/exceptions.rst:407 msgid "" -"Do not compare the return value to a specific exception; use :c:func:" -"`PyErr_ExceptionMatches` instead, shown below. (The comparison could easily " -"fail since the exception may be an instance instead of a class, in the case " -"of a class exception, or it may be a subclass of the expected exception.)" +"Do not compare the return value to a specific exception; " +"use :c:func:`PyErr_ExceptionMatches` instead, shown below. (The comparison " +"could easily fail since the exception may be an instance instead of a class, " +"in the case of a class exception, or it may be a subclass of the expected " +"exception.)" msgstr "" -#: c-api/exceptions.rst:414 +#: c-api/exceptions.rst:415 msgid "" "Equivalent to ``PyErr_GivenExceptionMatches(PyErr_Occurred(), exc)``. This " "should only be called when an exception is actually set; a memory access " "violation will occur if no exception has been raised." msgstr "" -#: c-api/exceptions.rst:421 +#: c-api/exceptions.rst:422 msgid "" "Return true if the *given* exception matches the exception type in *exc*. " "If *exc* is a class object, this also returns true when *given* is an " @@ -447,43 +453,54 @@ msgid "" "tuple (and recursively in subtuples) are searched for a match." msgstr "" -#: c-api/exceptions.rst:429 +#: c-api/exceptions.rst:430 msgid "" "Return the exception currently being raised, clearing the error indicator at " "the same time. Return ``NULL`` if the error indicator is not set." msgstr "" -#: c-api/exceptions.rst:432 +#: c-api/exceptions.rst:433 msgid "" "This function is used by code that needs to catch exceptions, or code that " "needs to save and restore the error indicator temporarily." msgstr "" -#: c-api/exceptions.rst:479 +#: c-api/exceptions.rst:480 msgid "For example::" msgstr "" -#: c-api/exceptions.rst:445 +#: c-api/exceptions.rst:438 +msgid "" +"{\n" +" PyObject *exc = PyErr_GetRaisedException();\n" +"\n" +" /* ... code that might produce other errors ... */\n" +"\n" +" PyErr_SetRaisedException(exc);\n" +"}" +msgstr "" + +#: c-api/exceptions.rst:446 msgid "" ":c:func:`PyErr_GetHandledException`, to save the exception currently being " "handled." msgstr "" -#: c-api/exceptions.rst:453 +#: c-api/exceptions.rst:454 msgid "" "Set *exc* as the exception currently being raised, clearing the existing " "exception if one is set." msgstr "" -#: c-api/exceptions.rst:458 +#: c-api/exceptions.rst:459 msgid "This call steals a reference to *exc*, which must be a valid exception." msgstr "" -#: c-api/exceptions.rst:467 +#: c-api/exceptions.rst:468 msgid "Use :c:func:`PyErr_GetRaisedException` instead." msgstr "" -#: c-api/exceptions.rst:469 +#: c-api/exceptions.rst:470 msgid "" "Retrieve the error indicator into three variables whose addresses are " "passed. If the error indicator is not set, set all three variables to " @@ -492,17 +509,29 @@ msgid "" "the type object is not." msgstr "" -#: c-api/exceptions.rst:476 +#: c-api/exceptions.rst:477 msgid "" "This function is normally only used by legacy code that needs to catch " "exceptions or save and restore the error indicator temporarily." msgstr "" -#: c-api/exceptions.rst:495 +#: c-api/exceptions.rst:482 +msgid "" +"{\n" +" PyObject *type, *value, *traceback;\n" +" PyErr_Fetch(&type, &value, &traceback);\n" +"\n" +" /* ... code that might produce other errors ... */\n" +"\n" +" PyErr_Restore(type, value, traceback);\n" +"}" +msgstr "" + +#: c-api/exceptions.rst:496 msgid "Use :c:func:`PyErr_SetRaisedException` instead." msgstr "" -#: c-api/exceptions.rst:497 +#: c-api/exceptions.rst:498 msgid "" "Set the error indicator from the three objects, *type*, *value*, and " "*traceback*, clearing the existing exception if one is set. If the objects " @@ -515,20 +544,20 @@ msgid "" "don't use this function. I warned you.)" msgstr "" -#: c-api/exceptions.rst:511 +#: c-api/exceptions.rst:512 msgid "" "This function is normally only used by legacy code that needs to save and " "restore the error indicator temporarily. Use :c:func:`PyErr_Fetch` to save " "the current error indicator." msgstr "" -#: c-api/exceptions.rst:520 +#: c-api/exceptions.rst:521 msgid "" "Use :c:func:`PyErr_GetRaisedException` instead, to avoid any possible de-" "normalization." msgstr "" -#: c-api/exceptions.rst:523 +#: c-api/exceptions.rst:524 msgid "" "Under certain circumstances, the values returned by :c:func:`PyErr_Fetch` " "below can be \"unnormalized\", meaning that ``*exc`` is a class object but " @@ -538,22 +567,31 @@ msgid "" "improve performance." msgstr "" -#: c-api/exceptions.rst:531 +#: c-api/exceptions.rst:532 +msgid "" +"This function *does not* implicitly set " +"the :attr:`~BaseException.__traceback__` attribute on the exception value. " +"If setting the traceback appropriately is desired, the following additional " +"snippet is needed::" +msgstr "" + +#: c-api/exceptions.rst:537 msgid "" -"This function *does not* implicitly set the :attr:`~BaseException." -"__traceback__` attribute on the exception value. If setting the traceback " -"appropriately is desired, the following additional snippet is needed::" +"if (tb != NULL) {\n" +" PyException_SetTraceback(val, tb);\n" +"}" msgstr "" -#: c-api/exceptions.rst:543 +#: c-api/exceptions.rst:544 msgid "" -"Retrieve the active exception instance, as would be returned by :func:`sys." -"exception`. This refers to an exception that was *already caught*, not to an " -"exception that was freshly raised. Returns a new reference to the exception " -"or ``NULL``. Does not modify the interpreter's exception state." +"Retrieve the active exception instance, as would be returned " +"by :func:`sys.exception`. This refers to an exception that was *already " +"caught*, not to an exception that was freshly raised. Returns a new " +"reference to the exception or ``NULL``. Does not modify the interpreter's " +"exception state." msgstr "" -#: c-api/exceptions.rst:550 +#: c-api/exceptions.rst:551 msgid "" "This function is not normally used by code that wants to handle exceptions. " "Rather, it can be used when code needs to save and restore the exception " @@ -561,14 +599,14 @@ msgid "" "clear the exception state." msgstr "" -#: c-api/exceptions.rst:559 +#: c-api/exceptions.rst:560 msgid "" "Set the active exception, as known from ``sys.exception()``. This refers to " "an exception that was *already caught*, not to an exception that was freshly " "raised. To clear the exception state, pass ``NULL``." msgstr "" -#: c-api/exceptions.rst:566 +#: c-api/exceptions.rst:567 msgid "" "This function is not normally used by code that wants to handle exceptions. " "Rather, it can be used when code needs to save and restore the exception " @@ -576,17 +614,17 @@ msgid "" "exception state." msgstr "" -#: c-api/exceptions.rst:575 +#: c-api/exceptions.rst:576 msgid "" -"Retrieve the old-style representation of the exception info, as known from :" -"func:`sys.exc_info`. This refers to an exception that was *already caught*, " -"not to an exception that was freshly raised. Returns new references for the " -"three objects, any of which may be ``NULL``. Does not modify the exception " -"info state. This function is kept for backwards compatibility. Prefer " -"using :c:func:`PyErr_GetHandledException`." +"Retrieve the old-style representation of the exception info, as known " +"from :func:`sys.exc_info`. This refers to an exception that was *already " +"caught*, not to an exception that was freshly raised. Returns new " +"references for the three objects, any of which may be ``NULL``. Does not " +"modify the exception info state. This function is kept for backwards " +"compatibility. Prefer using :c:func:`PyErr_GetHandledException`." msgstr "" -#: c-api/exceptions.rst:584 +#: c-api/exceptions.rst:585 msgid "" "This function is not normally used by code that wants to handle exceptions. " "Rather, it can be used when code needs to save and restore the exception " @@ -594,17 +632,17 @@ msgid "" "exception state." msgstr "" -#: c-api/exceptions.rst:594 +#: c-api/exceptions.rst:595 msgid "" "Set the exception info, as known from ``sys.exc_info()``. This refers to an " "exception that was *already caught*, not to an exception that was freshly " "raised. This function steals the references of the arguments. To clear the " "exception state, pass ``NULL`` for all three arguments. This function is " -"kept for backwards compatibility. Prefer using :c:func:" -"`PyErr_SetHandledException`." +"kept for backwards compatibility. Prefer " +"using :c:func:`PyErr_SetHandledException`." msgstr "" -#: c-api/exceptions.rst:603 +#: c-api/exceptions.rst:604 msgid "" "This function is not normally used by code that wants to handle exceptions. " "Rather, it can be used when code needs to save and restore the exception " @@ -612,22 +650,22 @@ msgid "" "state." msgstr "" -#: c-api/exceptions.rst:610 +#: c-api/exceptions.rst:611 msgid "" "The ``type`` and ``traceback`` arguments are no longer used and can be NULL. " "The interpreter now derives them from the exception instance (the ``value`` " "argument). The function still steals references of all three arguments." msgstr "" -#: c-api/exceptions.rst:618 +#: c-api/exceptions.rst:619 msgid "Signal Handling" msgstr "" -#: c-api/exceptions.rst:628 +#: c-api/exceptions.rst:629 msgid "This function interacts with Python's signal handling." msgstr "" -#: c-api/exceptions.rst:630 +#: c-api/exceptions.rst:631 msgid "" "If the function is called from the main thread and under the main Python " "interpreter, it checks whether a signal has been sent to the processes and " @@ -635,53 +673,53 @@ msgid "" "module is supported, this can invoke a signal handler written in Python." msgstr "" -#: c-api/exceptions.rst:635 +#: c-api/exceptions.rst:636 msgid "" "The function attempts to handle all pending signals, and then returns ``0``. " "However, if a Python signal handler raises an exception, the error indicator " "is set and the function returns ``-1`` immediately (such that other pending " -"signals may not have been handled yet: they will be on the next :c:func:" -"`PyErr_CheckSignals()` invocation)." +"signals may not have been handled yet: they will be on the " +"next :c:func:`PyErr_CheckSignals()` invocation)." msgstr "" -#: c-api/exceptions.rst:641 +#: c-api/exceptions.rst:642 msgid "" "If the function is called from a non-main thread, or under a non-main Python " "interpreter, it does nothing and returns ``0``." msgstr "" -#: c-api/exceptions.rst:644 +#: c-api/exceptions.rst:645 msgid "" "This function can be called by long-running C code that wants to be " "interruptible by user requests (such as by pressing Ctrl-C)." msgstr "" -#: c-api/exceptions.rst:648 +#: c-api/exceptions.rst:649 msgid "" -"The default Python signal handler for :c:macro:`!SIGINT` raises the :exc:" -"`KeyboardInterrupt` exception." +"The default Python signal handler for :c:macro:`!SIGINT` raises " +"the :exc:`KeyboardInterrupt` exception." msgstr "" -#: c-api/exceptions.rst:659 +#: c-api/exceptions.rst:660 msgid "" "Simulate the effect of a :c:macro:`!SIGINT` signal arriving. This is " "equivalent to ``PyErr_SetInterruptEx(SIGINT)``." msgstr "" -#: c-api/exceptions.rst:690 +#: c-api/exceptions.rst:691 msgid "" -"This function is async-signal-safe. It can be called without the :term:" -"`GIL` and from a C signal handler." +"This function is async-signal-safe. It can be called without " +"the :term:`GIL` and from a C signal handler." msgstr "" -#: c-api/exceptions.rst:673 +#: c-api/exceptions.rst:674 msgid "" -"Simulate the effect of a signal arriving. The next time :c:func:" -"`PyErr_CheckSignals` is called, the Python signal handler for the given " -"signal number will be called." +"Simulate the effect of a signal arriving. The next " +"time :c:func:`PyErr_CheckSignals` is called, the Python signal handler for " +"the given signal number will be called." msgstr "" -#: c-api/exceptions.rst:677 +#: c-api/exceptions.rst:678 msgid "" "This function can be called by C code that sets up its own signal handling " "and wants Python signal handlers to be invoked as expected when an " @@ -689,27 +727,28 @@ msgid "" "interrupt an operation)." msgstr "" -#: c-api/exceptions.rst:682 +#: c-api/exceptions.rst:683 msgid "" -"If the given signal isn't handled by Python (it was set to :py:const:`signal." -"SIG_DFL` or :py:const:`signal.SIG_IGN`), it will be ignored." +"If the given signal isn't handled by Python (it was set " +"to :py:const:`signal.SIG_DFL` or :py:const:`signal.SIG_IGN`), it will be " +"ignored." msgstr "" -#: c-api/exceptions.rst:685 +#: c-api/exceptions.rst:686 msgid "" "If *signum* is outside of the allowed range of signal numbers, ``-1`` is " "returned. Otherwise, ``0`` is returned. The error indicator is never " "changed by this function." msgstr "" -#: c-api/exceptions.rst:698 +#: c-api/exceptions.rst:699 msgid "" "This utility function specifies a file descriptor to which the signal number " "is written as a single byte whenever a signal is received. *fd* must be non-" "blocking. It returns the previous such file descriptor." msgstr "" -#: c-api/exceptions.rst:702 +#: c-api/exceptions.rst:703 msgid "" "The value ``-1`` disables the feature; this is the initial state. This is " "equivalent to :func:`signal.set_wakeup_fd` in Python, but without any error " @@ -717,15 +756,15 @@ msgid "" "be called from the main thread." msgstr "" -#: c-api/exceptions.rst:707 +#: c-api/exceptions.rst:708 msgid "On Windows, the function now also supports socket handles." msgstr "" -#: c-api/exceptions.rst:712 +#: c-api/exceptions.rst:713 msgid "Exception Classes" msgstr "" -#: c-api/exceptions.rst:716 +#: c-api/exceptions.rst:717 msgid "" "This utility function creates and returns a new exception class. The *name* " "argument must be the name of the new exception, a C string of the form " @@ -734,41 +773,41 @@ msgid "" "(accessible in C as :c:data:`PyExc_Exception`)." msgstr "" -#: c-api/exceptions.rst:722 +#: c-api/exceptions.rst:723 msgid "" -"The :attr:`!__module__` attribute of the new class is set to the first part " -"(up to the last dot) of the *name* argument, and the class name is set to " -"the last part (after the last dot). The *base* argument can be used to " +"The :attr:`~type.__module__` attribute of the new class is set to the first " +"part (up to the last dot) of the *name* argument, and the class name is set " +"to the last part (after the last dot). The *base* argument can be used to " "specify alternate base classes; it can either be only one class or a tuple " "of classes. The *dict* argument can be used to specify a dictionary of class " "variables and methods." msgstr "" -#: c-api/exceptions.rst:731 +#: c-api/exceptions.rst:732 msgid "" "Same as :c:func:`PyErr_NewException`, except that the new exception class " "can easily be given a docstring: If *doc* is non-``NULL``, it will be used " "as the docstring for the exception class." msgstr "" -#: c-api/exceptions.rst:739 +#: c-api/exceptions.rst:740 msgid "Exception Objects" msgstr "" -#: c-api/exceptions.rst:743 +#: c-api/exceptions.rst:744 msgid "" "Return the traceback associated with the exception as a new reference, as " "accessible from Python through the :attr:`~BaseException.__traceback__` " "attribute. If there is no traceback associated, this returns ``NULL``." msgstr "" -#: c-api/exceptions.rst:751 +#: c-api/exceptions.rst:752 msgid "" "Set the traceback associated with the exception to *tb*. Use ``Py_None`` to " "clear it." msgstr "" -#: c-api/exceptions.rst:757 +#: c-api/exceptions.rst:758 msgid "" "Return the context (another exception instance during whose handling *ex* " "was raised) associated with the exception as a new reference, as accessible " @@ -776,14 +815,14 @@ msgid "" "there is no context associated, this returns ``NULL``." msgstr "" -#: c-api/exceptions.rst:765 +#: c-api/exceptions.rst:766 msgid "" "Set the context associated with the exception to *ctx*. Use ``NULL`` to " "clear it. There is no type check to make sure that *ctx* is an exception " "instance. This steals a reference to *ctx*." msgstr "" -#: c-api/exceptions.rst:772 +#: c-api/exceptions.rst:773 msgid "" "Return the cause (either an exception instance, or ``None``, set by " "``raise ... from ...``) associated with the exception as a new reference, as " @@ -791,105 +830,105 @@ msgid "" "attribute." msgstr "" -#: c-api/exceptions.rst:780 +#: c-api/exceptions.rst:781 msgid "" "Set the cause associated with the exception to *cause*. Use ``NULL`` to " "clear it. There is no type check to make sure that *cause* is either an " "exception instance or ``None``. This steals a reference to *cause*." msgstr "" -#: c-api/exceptions.rst:784 +#: c-api/exceptions.rst:785 msgid "" "The :attr:`~BaseException.__suppress_context__` attribute is implicitly set " "to ``True`` by this function." msgstr "" -#: c-api/exceptions.rst:790 +#: c-api/exceptions.rst:791 msgid "Return :attr:`~BaseException.args` of exception *ex*." msgstr "" -#: c-api/exceptions.rst:795 +#: c-api/exceptions.rst:796 msgid "Set :attr:`~BaseException.args` of exception *ex* to *args*." msgstr "" -#: c-api/exceptions.rst:799 +#: c-api/exceptions.rst:800 msgid "" "Implement part of the interpreter's implementation of :keyword:`!except*`. " "*orig* is the original exception that was caught, and *excs* is the list of " "the exceptions that need to be raised. This list contains the unhandled part " -"of *orig*, if any, as well as the exceptions that were raised from the :" -"keyword:`!except*` clauses (so they have a different traceback from *orig*) " -"and those that were reraised (and have the same traceback as *orig*). Return " -"the :exc:`ExceptionGroup` that needs to be reraised in the end, or ``None`` " -"if there is nothing to reraise." +"of *orig*, if any, as well as the exceptions that were raised from " +"the :keyword:`!except*` clauses (so they have a different traceback from " +"*orig*) and those that were reraised (and have the same traceback as " +"*orig*). Return the :exc:`ExceptionGroup` that needs to be reraised in the " +"end, or ``None`` if there is nothing to reraise." msgstr "" -#: c-api/exceptions.rst:813 +#: c-api/exceptions.rst:814 msgid "Unicode Exception Objects" msgstr "" -#: c-api/exceptions.rst:815 +#: c-api/exceptions.rst:816 msgid "" "The following functions are used to create and modify Unicode exceptions " "from C." msgstr "" -#: c-api/exceptions.rst:819 +#: c-api/exceptions.rst:820 msgid "" "Create a :class:`UnicodeDecodeError` object with the attributes *encoding*, " "*object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are " "UTF-8 encoded strings." msgstr "" -#: c-api/exceptions.rst:826 +#: c-api/exceptions.rst:827 msgid "Return the *encoding* attribute of the given exception object." msgstr "" -#: c-api/exceptions.rst:832 +#: c-api/exceptions.rst:833 msgid "Return the *object* attribute of the given exception object." msgstr "" -#: c-api/exceptions.rst:838 +#: c-api/exceptions.rst:839 msgid "" "Get the *start* attribute of the given exception object and place it into " "*\\*start*. *start* must not be ``NULL``. Return ``0`` on success, ``-1`` " "on failure." msgstr "" -#: c-api/exceptions.rst:846 +#: c-api/exceptions.rst:847 msgid "" "Set the *start* attribute of the given exception object to *start*. Return " "``0`` on success, ``-1`` on failure." msgstr "" -#: c-api/exceptions.rst:853 +#: c-api/exceptions.rst:854 msgid "" "Get the *end* attribute of the given exception object and place it into " "*\\*end*. *end* must not be ``NULL``. Return ``0`` on success, ``-1`` on " "failure." msgstr "" -#: c-api/exceptions.rst:861 +#: c-api/exceptions.rst:862 msgid "" "Set the *end* attribute of the given exception object to *end*. Return " "``0`` on success, ``-1`` on failure." msgstr "" -#: c-api/exceptions.rst:868 +#: c-api/exceptions.rst:869 msgid "Return the *reason* attribute of the given exception object." msgstr "" -#: c-api/exceptions.rst:874 +#: c-api/exceptions.rst:875 msgid "" "Set the *reason* attribute of the given exception object to *reason*. " "Return ``0`` on success, ``-1`` on failure." msgstr "" -#: c-api/exceptions.rst:881 +#: c-api/exceptions.rst:882 msgid "Recursion Control" msgstr "" -#: c-api/exceptions.rst:883 +#: c-api/exceptions.rst:884 msgid "" "These two functions provide a way to perform safe recursive calls at the C " "level, both in the core and in extension modules. They are needed if the " @@ -899,601 +938,596 @@ msgid "" "recursion handling." msgstr "" -#: c-api/exceptions.rst:892 +#: c-api/exceptions.rst:893 msgid "Marks a point where a recursive C-level call is about to be performed." msgstr "" -#: c-api/exceptions.rst:894 +#: c-api/exceptions.rst:895 msgid "" "If :c:macro:`!USE_STACKCHECK` is defined, this function checks if the OS " "stack overflowed using :c:func:`PyOS_CheckStack`. If this is the case, it " "sets a :exc:`MemoryError` and returns a nonzero value." msgstr "" -#: c-api/exceptions.rst:898 +#: c-api/exceptions.rst:899 msgid "" "The function then checks if the recursion limit is reached. If this is the " "case, a :exc:`RecursionError` is set and a nonzero value is returned. " "Otherwise, zero is returned." msgstr "" -#: c-api/exceptions.rst:902 +#: c-api/exceptions.rst:903 msgid "" "*where* should be a UTF-8 encoded string such as ``\" in instance check\"`` " "to be concatenated to the :exc:`RecursionError` message caused by the " "recursion depth limit." msgstr "" -#: c-api/exceptions.rst:914 +#: c-api/exceptions.rst:915 msgid "" "This function is now also available in the :ref:`limited API `." msgstr "" -#: c-api/exceptions.rst:911 +#: c-api/exceptions.rst:912 msgid "" "Ends a :c:func:`Py_EnterRecursiveCall`. Must be called once for each " "*successful* invocation of :c:func:`Py_EnterRecursiveCall`." msgstr "" -#: c-api/exceptions.rst:917 +#: c-api/exceptions.rst:918 msgid "" "Properly implementing :c:member:`~PyTypeObject.tp_repr` for container types " -"requires special recursion handling. In addition to protecting the stack, :" -"c:member:`~PyTypeObject.tp_repr` also needs to track objects to prevent " -"cycles. The following two functions facilitate this functionality. " +"requires special recursion handling. In addition to protecting the " +"stack, :c:member:`~PyTypeObject.tp_repr` also needs to track objects to " +"prevent cycles. The following two functions facilitate this functionality. " "Effectively, these are the C equivalent to :func:`reprlib.recursive_repr`." msgstr "" -#: c-api/exceptions.rst:925 +#: c-api/exceptions.rst:926 msgid "" "Called at the beginning of the :c:member:`~PyTypeObject.tp_repr` " "implementation to detect cycles." msgstr "" -#: c-api/exceptions.rst:928 +#: c-api/exceptions.rst:929 msgid "" "If the object has already been processed, the function returns a positive " "integer. In that case the :c:member:`~PyTypeObject.tp_repr` implementation " -"should return a string object indicating a cycle. As examples, :class:" -"`dict` objects return ``{...}`` and :class:`list` objects return ``[...]``." +"should return a string object indicating a cycle. As " +"examples, :class:`dict` objects return ``{...}`` and :class:`list` objects " +"return ``[...]``." msgstr "" -#: c-api/exceptions.rst:934 +#: c-api/exceptions.rst:935 msgid "" "The function will return a negative integer if the recursion limit is " "reached. In that case the :c:member:`~PyTypeObject.tp_repr` implementation " "should typically return ``NULL``." msgstr "" -#: c-api/exceptions.rst:938 +#: c-api/exceptions.rst:939 msgid "" -"Otherwise, the function returns zero and the :c:member:`~PyTypeObject." -"tp_repr` implementation can continue normally." +"Otherwise, the function returns zero and " +"the :c:member:`~PyTypeObject.tp_repr` implementation can continue normally." msgstr "" -#: c-api/exceptions.rst:943 +#: c-api/exceptions.rst:944 msgid "" -"Ends a :c:func:`Py_ReprEnter`. Must be called once for each invocation of :" -"c:func:`Py_ReprEnter` that returns zero." +"Ends a :c:func:`Py_ReprEnter`. Must be called once for each invocation " +"of :c:func:`Py_ReprEnter` that returns zero." msgstr "" -#: c-api/exceptions.rst:950 +#: c-api/exceptions.rst:951 msgid "Standard Exceptions" msgstr "" -#: c-api/exceptions.rst:952 +#: c-api/exceptions.rst:953 msgid "" "All standard Python exceptions are available as global variables whose names " -"are ``PyExc_`` followed by the Python exception name. These have the type :" -"c:expr:`PyObject*`; they are all class objects. For completeness, here are " -"all the variables:" +"are ``PyExc_`` followed by the Python exception name. These have the " +"type :c:expr:`PyObject*`; they are all class objects. For completeness, " +"here are all the variables:" msgstr "" -#: c-api/exceptions.rst:1146 c-api/exceptions.rst:1191 +#: c-api/exceptions.rst:1147 c-api/exceptions.rst:1192 msgid "C Name" msgstr "" -#: c-api/exceptions.rst:1191 +#: c-api/exceptions.rst:1192 msgid "Python Name" msgstr "" -#: c-api/exceptions.rst:1146 c-api/exceptions.rst:1191 +#: c-api/exceptions.rst:1147 c-api/exceptions.rst:1192 msgid "Notes" msgstr "" -#: c-api/exceptions.rst:1015 +#: c-api/exceptions.rst:1016 msgid ":c:data:`PyExc_BaseException`" msgstr "" -#: c-api/exceptions.rst:1015 +#: c-api/exceptions.rst:1016 msgid ":exc:`BaseException`" msgstr "" -#: c-api/exceptions.rst:1017 c-api/exceptions.rst:1065 -#: c-api/exceptions.rst:1077 +#: c-api/exceptions.rst:1018 c-api/exceptions.rst:1066 +#: c-api/exceptions.rst:1078 msgid "[1]_" msgstr "" -#: c-api/exceptions.rst:1017 +#: c-api/exceptions.rst:1018 msgid ":c:data:`PyExc_Exception`" msgstr "" -#: c-api/exceptions.rst:1017 +#: c-api/exceptions.rst:1018 msgid ":exc:`Exception`" msgstr "" -#: c-api/exceptions.rst:1019 +#: c-api/exceptions.rst:1020 msgid ":c:data:`PyExc_ArithmeticError`" msgstr "" -#: c-api/exceptions.rst:1019 +#: c-api/exceptions.rst:1020 msgid ":exc:`ArithmeticError`" msgstr "" -#: c-api/exceptions.rst:1021 +#: c-api/exceptions.rst:1022 msgid ":c:data:`PyExc_AssertionError`" msgstr "" -#: c-api/exceptions.rst:1021 +#: c-api/exceptions.rst:1022 msgid ":exc:`AssertionError`" msgstr "" -#: c-api/exceptions.rst:1023 +#: c-api/exceptions.rst:1024 msgid ":c:data:`PyExc_AttributeError`" msgstr "" -#: c-api/exceptions.rst:1023 +#: c-api/exceptions.rst:1024 msgid ":exc:`AttributeError`" msgstr "" -#: c-api/exceptions.rst:1025 +#: c-api/exceptions.rst:1026 msgid ":c:data:`PyExc_BlockingIOError`" msgstr "" -#: c-api/exceptions.rst:1025 +#: c-api/exceptions.rst:1026 msgid ":exc:`BlockingIOError`" msgstr "" -#: c-api/exceptions.rst:1027 +#: c-api/exceptions.rst:1028 msgid ":c:data:`PyExc_BrokenPipeError`" msgstr "" -#: c-api/exceptions.rst:1027 +#: c-api/exceptions.rst:1028 msgid ":exc:`BrokenPipeError`" msgstr "" -#: c-api/exceptions.rst:1029 +#: c-api/exceptions.rst:1030 msgid ":c:data:`PyExc_BufferError`" msgstr "" -#: c-api/exceptions.rst:1029 +#: c-api/exceptions.rst:1030 msgid ":exc:`BufferError`" msgstr "" -#: c-api/exceptions.rst:1031 +#: c-api/exceptions.rst:1032 msgid ":c:data:`PyExc_ChildProcessError`" msgstr "" -#: c-api/exceptions.rst:1031 +#: c-api/exceptions.rst:1032 msgid ":exc:`ChildProcessError`" msgstr "" -#: c-api/exceptions.rst:1033 +#: c-api/exceptions.rst:1034 msgid ":c:data:`PyExc_ConnectionAbortedError`" msgstr "" -#: c-api/exceptions.rst:1033 +#: c-api/exceptions.rst:1034 msgid ":exc:`ConnectionAbortedError`" msgstr "" -#: c-api/exceptions.rst:1035 +#: c-api/exceptions.rst:1036 msgid ":c:data:`PyExc_ConnectionError`" msgstr "" -#: c-api/exceptions.rst:1035 +#: c-api/exceptions.rst:1036 msgid ":exc:`ConnectionError`" msgstr "" -#: c-api/exceptions.rst:1037 +#: c-api/exceptions.rst:1038 msgid ":c:data:`PyExc_ConnectionRefusedError`" msgstr "" -#: c-api/exceptions.rst:1037 +#: c-api/exceptions.rst:1038 msgid ":exc:`ConnectionRefusedError`" msgstr "" -#: c-api/exceptions.rst:1039 +#: c-api/exceptions.rst:1040 msgid ":c:data:`PyExc_ConnectionResetError`" msgstr "" -#: c-api/exceptions.rst:1039 +#: c-api/exceptions.rst:1040 msgid ":exc:`ConnectionResetError`" msgstr "" -#: c-api/exceptions.rst:1041 +#: c-api/exceptions.rst:1042 msgid ":c:data:`PyExc_EOFError`" msgstr "" -#: c-api/exceptions.rst:1041 +#: c-api/exceptions.rst:1042 msgid ":exc:`EOFError`" msgstr "" -#: c-api/exceptions.rst:1043 +#: c-api/exceptions.rst:1044 msgid ":c:data:`PyExc_FileExistsError`" msgstr "" -#: c-api/exceptions.rst:1043 +#: c-api/exceptions.rst:1044 msgid ":exc:`FileExistsError`" msgstr "" -#: c-api/exceptions.rst:1045 +#: c-api/exceptions.rst:1046 msgid ":c:data:`PyExc_FileNotFoundError`" msgstr "" -#: c-api/exceptions.rst:1045 +#: c-api/exceptions.rst:1046 msgid ":exc:`FileNotFoundError`" msgstr "" -#: c-api/exceptions.rst:1047 +#: c-api/exceptions.rst:1048 msgid ":c:data:`PyExc_FloatingPointError`" msgstr "" -#: c-api/exceptions.rst:1047 +#: c-api/exceptions.rst:1048 msgid ":exc:`FloatingPointError`" msgstr "" -#: c-api/exceptions.rst:1049 +#: c-api/exceptions.rst:1050 msgid ":c:data:`PyExc_GeneratorExit`" msgstr "" -#: c-api/exceptions.rst:1049 +#: c-api/exceptions.rst:1050 msgid ":exc:`GeneratorExit`" msgstr "" -#: c-api/exceptions.rst:1051 +#: c-api/exceptions.rst:1052 msgid ":c:data:`PyExc_ImportError`" msgstr "" -#: c-api/exceptions.rst:1051 +#: c-api/exceptions.rst:1052 msgid ":exc:`ImportError`" msgstr "" -#: c-api/exceptions.rst:1053 +#: c-api/exceptions.rst:1054 msgid ":c:data:`PyExc_IndentationError`" msgstr "" -#: c-api/exceptions.rst:1053 +#: c-api/exceptions.rst:1054 msgid ":exc:`IndentationError`" msgstr "" -#: c-api/exceptions.rst:1055 +#: c-api/exceptions.rst:1056 msgid ":c:data:`PyExc_IndexError`" msgstr "" -#: c-api/exceptions.rst:1055 +#: c-api/exceptions.rst:1056 msgid ":exc:`IndexError`" msgstr "" -#: c-api/exceptions.rst:1057 +#: c-api/exceptions.rst:1058 msgid ":c:data:`PyExc_InterruptedError`" msgstr "" -#: c-api/exceptions.rst:1057 +#: c-api/exceptions.rst:1058 msgid ":exc:`InterruptedError`" msgstr "" -#: c-api/exceptions.rst:1059 +#: c-api/exceptions.rst:1060 msgid ":c:data:`PyExc_IsADirectoryError`" msgstr "" -#: c-api/exceptions.rst:1059 +#: c-api/exceptions.rst:1060 msgid ":exc:`IsADirectoryError`" msgstr "" -#: c-api/exceptions.rst:1061 +#: c-api/exceptions.rst:1062 msgid ":c:data:`PyExc_KeyError`" msgstr "" -#: c-api/exceptions.rst:1061 +#: c-api/exceptions.rst:1062 msgid ":exc:`KeyError`" msgstr "" -#: c-api/exceptions.rst:1063 +#: c-api/exceptions.rst:1064 msgid ":c:data:`PyExc_KeyboardInterrupt`" msgstr "" -#: c-api/exceptions.rst:1063 +#: c-api/exceptions.rst:1064 msgid ":exc:`KeyboardInterrupt`" msgstr "" -#: c-api/exceptions.rst:1065 +#: c-api/exceptions.rst:1066 msgid ":c:data:`PyExc_LookupError`" msgstr "" -#: c-api/exceptions.rst:1065 +#: c-api/exceptions.rst:1066 msgid ":exc:`LookupError`" msgstr "" -#: c-api/exceptions.rst:1067 +#: c-api/exceptions.rst:1068 msgid ":c:data:`PyExc_MemoryError`" msgstr "" -#: c-api/exceptions.rst:1067 +#: c-api/exceptions.rst:1068 msgid ":exc:`MemoryError`" msgstr "" -#: c-api/exceptions.rst:1069 +#: c-api/exceptions.rst:1070 msgid ":c:data:`PyExc_ModuleNotFoundError`" msgstr "" -#: c-api/exceptions.rst:1069 +#: c-api/exceptions.rst:1070 msgid ":exc:`ModuleNotFoundError`" msgstr "" -#: c-api/exceptions.rst:1071 +#: c-api/exceptions.rst:1072 msgid ":c:data:`PyExc_NameError`" msgstr "" -#: c-api/exceptions.rst:1071 +#: c-api/exceptions.rst:1072 msgid ":exc:`NameError`" msgstr "" -#: c-api/exceptions.rst:1073 +#: c-api/exceptions.rst:1074 msgid ":c:data:`PyExc_NotADirectoryError`" msgstr "" -#: c-api/exceptions.rst:1073 +#: c-api/exceptions.rst:1074 msgid ":exc:`NotADirectoryError`" msgstr "" -#: c-api/exceptions.rst:1075 +#: c-api/exceptions.rst:1076 msgid ":c:data:`PyExc_NotImplementedError`" msgstr "" -#: c-api/exceptions.rst:1075 +#: c-api/exceptions.rst:1076 msgid ":exc:`NotImplementedError`" msgstr "" -#: c-api/exceptions.rst:1077 +#: c-api/exceptions.rst:1078 msgid ":c:data:`PyExc_OSError`" msgstr "" -#: c-api/exceptions.rst:1077 +#: c-api/exceptions.rst:1078 msgid ":exc:`OSError`" msgstr "" -#: c-api/exceptions.rst:1079 +#: c-api/exceptions.rst:1080 msgid ":c:data:`PyExc_OverflowError`" msgstr "" -#: c-api/exceptions.rst:1079 +#: c-api/exceptions.rst:1080 msgid ":exc:`OverflowError`" msgstr "" -#: c-api/exceptions.rst:1081 +#: c-api/exceptions.rst:1082 msgid ":c:data:`PyExc_PermissionError`" msgstr "" -#: c-api/exceptions.rst:1081 +#: c-api/exceptions.rst:1082 msgid ":exc:`PermissionError`" msgstr "" -#: c-api/exceptions.rst:1083 +#: c-api/exceptions.rst:1084 msgid ":c:data:`PyExc_ProcessLookupError`" msgstr "" -#: c-api/exceptions.rst:1083 +#: c-api/exceptions.rst:1084 msgid ":exc:`ProcessLookupError`" msgstr "" -#: c-api/exceptions.rst:1085 +#: c-api/exceptions.rst:1086 msgid ":c:data:`PyExc_RecursionError`" msgstr "" -#: c-api/exceptions.rst:1085 +#: c-api/exceptions.rst:1086 msgid ":exc:`RecursionError`" msgstr "" -#: c-api/exceptions.rst:1087 +#: c-api/exceptions.rst:1088 msgid ":c:data:`PyExc_ReferenceError`" msgstr "" -#: c-api/exceptions.rst:1087 +#: c-api/exceptions.rst:1088 msgid ":exc:`ReferenceError`" msgstr "" -#: c-api/exceptions.rst:1089 +#: c-api/exceptions.rst:1090 msgid ":c:data:`PyExc_RuntimeError`" msgstr "" -#: c-api/exceptions.rst:1089 +#: c-api/exceptions.rst:1090 msgid ":exc:`RuntimeError`" msgstr "" -#: c-api/exceptions.rst:1091 +#: c-api/exceptions.rst:1092 msgid ":c:data:`PyExc_StopAsyncIteration`" msgstr "" -#: c-api/exceptions.rst:1091 +#: c-api/exceptions.rst:1092 msgid ":exc:`StopAsyncIteration`" msgstr "" -#: c-api/exceptions.rst:1093 +#: c-api/exceptions.rst:1094 msgid ":c:data:`PyExc_StopIteration`" msgstr "" -#: c-api/exceptions.rst:1093 +#: c-api/exceptions.rst:1094 msgid ":exc:`StopIteration`" msgstr "" -#: c-api/exceptions.rst:1095 +#: c-api/exceptions.rst:1096 msgid ":c:data:`PyExc_SyntaxError`" msgstr "" -#: c-api/exceptions.rst:1095 +#: c-api/exceptions.rst:1096 msgid ":exc:`SyntaxError`" msgstr "" -#: c-api/exceptions.rst:1097 +#: c-api/exceptions.rst:1098 msgid ":c:data:`PyExc_SystemError`" msgstr "" -#: c-api/exceptions.rst:1097 +#: c-api/exceptions.rst:1098 msgid ":exc:`SystemError`" msgstr "" -#: c-api/exceptions.rst:1099 +#: c-api/exceptions.rst:1100 msgid ":c:data:`PyExc_SystemExit`" msgstr "" -#: c-api/exceptions.rst:1099 +#: c-api/exceptions.rst:1100 msgid ":exc:`SystemExit`" msgstr "" -#: c-api/exceptions.rst:1101 +#: c-api/exceptions.rst:1102 msgid ":c:data:`PyExc_TabError`" msgstr "" -#: c-api/exceptions.rst:1101 +#: c-api/exceptions.rst:1102 msgid ":exc:`TabError`" msgstr "" -#: c-api/exceptions.rst:1103 +#: c-api/exceptions.rst:1104 msgid ":c:data:`PyExc_TimeoutError`" msgstr "" -#: c-api/exceptions.rst:1103 +#: c-api/exceptions.rst:1104 msgid ":exc:`TimeoutError`" msgstr "" -#: c-api/exceptions.rst:1105 +#: c-api/exceptions.rst:1106 msgid ":c:data:`PyExc_TypeError`" msgstr "" -#: c-api/exceptions.rst:1105 +#: c-api/exceptions.rst:1106 msgid ":exc:`TypeError`" msgstr "" -#: c-api/exceptions.rst:1107 +#: c-api/exceptions.rst:1108 msgid ":c:data:`PyExc_UnboundLocalError`" msgstr "" -#: c-api/exceptions.rst:1107 +#: c-api/exceptions.rst:1108 msgid ":exc:`UnboundLocalError`" msgstr "" -#: c-api/exceptions.rst:1109 +#: c-api/exceptions.rst:1110 msgid ":c:data:`PyExc_UnicodeDecodeError`" msgstr "" -#: c-api/exceptions.rst:1109 +#: c-api/exceptions.rst:1110 msgid ":exc:`UnicodeDecodeError`" msgstr "" -#: c-api/exceptions.rst:1111 +#: c-api/exceptions.rst:1112 msgid ":c:data:`PyExc_UnicodeEncodeError`" msgstr "" -#: c-api/exceptions.rst:1111 +#: c-api/exceptions.rst:1112 msgid ":exc:`UnicodeEncodeError`" msgstr "" -#: c-api/exceptions.rst:1113 +#: c-api/exceptions.rst:1114 msgid ":c:data:`PyExc_UnicodeError`" msgstr "" -#: c-api/exceptions.rst:1113 +#: c-api/exceptions.rst:1114 msgid ":exc:`UnicodeError`" msgstr "" -#: c-api/exceptions.rst:1115 +#: c-api/exceptions.rst:1116 msgid ":c:data:`PyExc_UnicodeTranslateError`" msgstr "" -#: c-api/exceptions.rst:1115 +#: c-api/exceptions.rst:1116 msgid ":exc:`UnicodeTranslateError`" msgstr "" -#: c-api/exceptions.rst:1117 +#: c-api/exceptions.rst:1118 msgid ":c:data:`PyExc_ValueError`" msgstr "" -#: c-api/exceptions.rst:1117 +#: c-api/exceptions.rst:1118 msgid ":exc:`ValueError`" msgstr "" -#: c-api/exceptions.rst:1119 +#: c-api/exceptions.rst:1120 msgid ":c:data:`PyExc_ZeroDivisionError`" msgstr "" -#: c-api/exceptions.rst:1119 +#: c-api/exceptions.rst:1120 msgid ":exc:`ZeroDivisionError`" msgstr "" -#: c-api/exceptions.rst:1122 +#: c-api/exceptions.rst:1123 msgid "" -":c:data:`PyExc_BlockingIOError`, :c:data:`PyExc_BrokenPipeError`, :c:data:" -"`PyExc_ChildProcessError`, :c:data:`PyExc_ConnectionError`, :c:data:" -"`PyExc_ConnectionAbortedError`, :c:data:`PyExc_ConnectionRefusedError`, :c:" -"data:`PyExc_ConnectionResetError`, :c:data:`PyExc_FileExistsError`, :c:data:" -"`PyExc_FileNotFoundError`, :c:data:`PyExc_InterruptedError`, :c:data:" -"`PyExc_IsADirectoryError`, :c:data:`PyExc_NotADirectoryError`, :c:data:" -"`PyExc_PermissionError`, :c:data:`PyExc_ProcessLookupError` and :c:data:" -"`PyExc_TimeoutError` were introduced following :pep:`3151`." +":c:data:`PyExc_BlockingIOError`, :c:data:`PyExc_BrokenPipeError`, :c:data:`PyExc_ChildProcessError`, :c:data:`PyExc_ConnectionError`, :c:data:`PyExc_ConnectionAbortedError`, :c:data:`PyExc_ConnectionRefusedError`, :c:data:`PyExc_ConnectionResetError`, :c:data:`PyExc_FileExistsError`, :c:data:`PyExc_FileNotFoundError`, :c:data:`PyExc_InterruptedError`, :c:data:`PyExc_IsADirectoryError`, :c:data:`PyExc_NotADirectoryError`, :c:data:`PyExc_PermissionError`, :c:data:`PyExc_ProcessLookupError` " +"and :c:data:`PyExc_TimeoutError` were introduced following :pep:`3151`." msgstr "" -#: c-api/exceptions.rst:1132 +#: c-api/exceptions.rst:1133 msgid ":c:data:`PyExc_StopAsyncIteration` and :c:data:`PyExc_RecursionError`." msgstr "" -#: c-api/exceptions.rst:1135 +#: c-api/exceptions.rst:1136 msgid ":c:data:`PyExc_ModuleNotFoundError`." msgstr "" -#: c-api/exceptions.rst:1138 +#: c-api/exceptions.rst:1139 msgid "These are compatibility aliases to :c:data:`PyExc_OSError`:" msgstr "" -#: c-api/exceptions.rst:1148 +#: c-api/exceptions.rst:1149 msgid ":c:data:`!PyExc_EnvironmentError`" msgstr "" -#: c-api/exceptions.rst:1150 +#: c-api/exceptions.rst:1151 msgid ":c:data:`!PyExc_IOError`" msgstr "" -#: c-api/exceptions.rst:1152 +#: c-api/exceptions.rst:1153 msgid ":c:data:`!PyExc_WindowsError`" msgstr "" -#: c-api/exceptions.rst:1152 +#: c-api/exceptions.rst:1153 msgid "[2]_" msgstr "" -#: c-api/exceptions.rst:1155 +#: c-api/exceptions.rst:1156 msgid "These aliases used to be separate exception types." msgstr "" -#: c-api/exceptions.rst:1219 +#: c-api/exceptions.rst:1220 msgid "Notes:" msgstr "" -#: c-api/exceptions.rst:1161 +#: c-api/exceptions.rst:1162 msgid "This is a base class for other standard exceptions." msgstr "" -#: c-api/exceptions.rst:1164 +#: c-api/exceptions.rst:1165 msgid "" "Only defined on Windows; protect code that uses this by testing that the " "preprocessor macro ``MS_WINDOWS`` is defined." msgstr "" -#: c-api/exceptions.rst:1170 +#: c-api/exceptions.rst:1171 msgid "Standard Warning Categories" msgstr "" -#: c-api/exceptions.rst:1172 +#: c-api/exceptions.rst:1173 msgid "" "All standard Python warning categories are available as global variables " "whose names are ``PyExc_`` followed by the Python exception name. These have " @@ -1501,103 +1535,103 @@ msgid "" "here are all the variables:" msgstr "" -#: c-api/exceptions.rst:1193 +#: c-api/exceptions.rst:1194 msgid ":c:data:`PyExc_Warning`" msgstr "" -#: c-api/exceptions.rst:1193 +#: c-api/exceptions.rst:1194 msgid ":exc:`Warning`" msgstr "" -#: c-api/exceptions.rst:1193 +#: c-api/exceptions.rst:1194 msgid "[3]_" msgstr "" -#: c-api/exceptions.rst:1195 +#: c-api/exceptions.rst:1196 msgid ":c:data:`PyExc_BytesWarning`" msgstr "" -#: c-api/exceptions.rst:1195 +#: c-api/exceptions.rst:1196 msgid ":exc:`BytesWarning`" msgstr "" -#: c-api/exceptions.rst:1197 +#: c-api/exceptions.rst:1198 msgid ":c:data:`PyExc_DeprecationWarning`" msgstr "" -#: c-api/exceptions.rst:1197 +#: c-api/exceptions.rst:1198 msgid ":exc:`DeprecationWarning`" msgstr "" -#: c-api/exceptions.rst:1199 +#: c-api/exceptions.rst:1200 msgid ":c:data:`PyExc_FutureWarning`" msgstr "" -#: c-api/exceptions.rst:1199 +#: c-api/exceptions.rst:1200 msgid ":exc:`FutureWarning`" msgstr "" -#: c-api/exceptions.rst:1201 +#: c-api/exceptions.rst:1202 msgid ":c:data:`PyExc_ImportWarning`" msgstr "" -#: c-api/exceptions.rst:1201 +#: c-api/exceptions.rst:1202 msgid ":exc:`ImportWarning`" msgstr "" -#: c-api/exceptions.rst:1203 +#: c-api/exceptions.rst:1204 msgid ":c:data:`PyExc_PendingDeprecationWarning`" msgstr "" -#: c-api/exceptions.rst:1203 +#: c-api/exceptions.rst:1204 msgid ":exc:`PendingDeprecationWarning`" msgstr "" -#: c-api/exceptions.rst:1205 +#: c-api/exceptions.rst:1206 msgid ":c:data:`PyExc_ResourceWarning`" msgstr "" -#: c-api/exceptions.rst:1205 +#: c-api/exceptions.rst:1206 msgid ":exc:`ResourceWarning`" msgstr "" -#: c-api/exceptions.rst:1207 +#: c-api/exceptions.rst:1208 msgid ":c:data:`PyExc_RuntimeWarning`" msgstr "" -#: c-api/exceptions.rst:1207 +#: c-api/exceptions.rst:1208 msgid ":exc:`RuntimeWarning`" msgstr "" -#: c-api/exceptions.rst:1209 +#: c-api/exceptions.rst:1210 msgid ":c:data:`PyExc_SyntaxWarning`" msgstr "" -#: c-api/exceptions.rst:1209 +#: c-api/exceptions.rst:1210 msgid ":exc:`SyntaxWarning`" msgstr "" -#: c-api/exceptions.rst:1211 +#: c-api/exceptions.rst:1212 msgid ":c:data:`PyExc_UnicodeWarning`" msgstr "" -#: c-api/exceptions.rst:1211 +#: c-api/exceptions.rst:1212 msgid ":exc:`UnicodeWarning`" msgstr "" -#: c-api/exceptions.rst:1213 +#: c-api/exceptions.rst:1214 msgid ":c:data:`PyExc_UserWarning`" msgstr "" -#: c-api/exceptions.rst:1213 +#: c-api/exceptions.rst:1214 msgid ":exc:`UserWarning`" msgstr "" -#: c-api/exceptions.rst:1216 +#: c-api/exceptions.rst:1217 msgid ":c:data:`PyExc_ResourceWarning`." msgstr "" -#: c-api/exceptions.rst:1222 +#: c-api/exceptions.rst:1223 msgid "This is a base class for other standard warning categories." msgstr "" @@ -1605,286 +1639,286 @@ msgstr "" msgid "strerror (C function)" msgstr "" -#: c-api/exceptions.rst:654 c-api/exceptions.rst:669 +#: c-api/exceptions.rst:655 c-api/exceptions.rst:670 msgid "module" msgstr "" -#: c-api/exceptions.rst:654 c-api/exceptions.rst:669 +#: c-api/exceptions.rst:655 c-api/exceptions.rst:670 msgid "signal" msgstr "" -#: c-api/exceptions.rst:654 +#: c-api/exceptions.rst:655 msgid "SIGINT (C macro)" msgstr "" -#: c-api/exceptions.rst:654 c-api/exceptions.rst:669 +#: c-api/exceptions.rst:655 c-api/exceptions.rst:670 msgid "KeyboardInterrupt (built-in exception)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_BaseException (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_Exception (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_ArithmeticError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_AssertionError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_AttributeError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_BlockingIOError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_BrokenPipeError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_BufferError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_ChildProcessError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_ConnectionAbortedError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_ConnectionError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_ConnectionRefusedError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_ConnectionResetError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_EOFError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_FileExistsError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_FileNotFoundError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_FloatingPointError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_GeneratorExit (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_ImportError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_IndentationError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_IndexError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_InterruptedError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_IsADirectoryError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_KeyError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_KeyboardInterrupt (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_LookupError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_MemoryError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_ModuleNotFoundError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_NameError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_NotADirectoryError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_NotImplementedError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_OSError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_OverflowError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_PermissionError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_ProcessLookupError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_RecursionError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_ReferenceError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_RuntimeError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_StopAsyncIteration (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_StopIteration (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_SyntaxError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_SystemError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_SystemExit (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_TabError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_TimeoutError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_TypeError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_UnboundLocalError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_UnicodeDecodeError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_UnicodeEncodeError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_UnicodeError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_UnicodeTranslateError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_ValueError (C var)" msgstr "" -#: c-api/exceptions.rst:957 +#: c-api/exceptions.rst:958 msgid "PyExc_ZeroDivisionError (C var)" msgstr "" -#: c-api/exceptions.rst:1140 +#: c-api/exceptions.rst:1141 msgid "PyExc_EnvironmentError (C var)" msgstr "" -#: c-api/exceptions.rst:1140 +#: c-api/exceptions.rst:1141 msgid "PyExc_IOError (C var)" msgstr "" -#: c-api/exceptions.rst:1140 +#: c-api/exceptions.rst:1141 msgid "PyExc_WindowsError (C var)" msgstr "" -#: c-api/exceptions.rst:1177 +#: c-api/exceptions.rst:1178 msgid "PyExc_Warning (C var)" msgstr "" -#: c-api/exceptions.rst:1177 +#: c-api/exceptions.rst:1178 msgid "PyExc_BytesWarning (C var)" msgstr "" -#: c-api/exceptions.rst:1177 +#: c-api/exceptions.rst:1178 msgid "PyExc_DeprecationWarning (C var)" msgstr "" -#: c-api/exceptions.rst:1177 +#: c-api/exceptions.rst:1178 msgid "PyExc_FutureWarning (C var)" msgstr "" -#: c-api/exceptions.rst:1177 +#: c-api/exceptions.rst:1178 msgid "PyExc_ImportWarning (C var)" msgstr "" -#: c-api/exceptions.rst:1177 +#: c-api/exceptions.rst:1178 msgid "PyExc_PendingDeprecationWarning (C var)" msgstr "" -#: c-api/exceptions.rst:1177 +#: c-api/exceptions.rst:1178 msgid "PyExc_ResourceWarning (C var)" msgstr "" -#: c-api/exceptions.rst:1177 +#: c-api/exceptions.rst:1178 msgid "PyExc_RuntimeWarning (C var)" msgstr "" -#: c-api/exceptions.rst:1177 +#: c-api/exceptions.rst:1178 msgid "PyExc_SyntaxWarning (C var)" msgstr "" -#: c-api/exceptions.rst:1177 +#: c-api/exceptions.rst:1178 msgid "PyExc_UnicodeWarning (C var)" msgstr "" -#: c-api/exceptions.rst:1177 +#: c-api/exceptions.rst:1178 msgid "PyExc_UserWarning (C var)" msgstr "" diff --git a/c-api/file.po b/c-api/file.po index 03602e15..afe4e486 100644 --- a/c-api/file.po +++ b/c-api/file.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,12 +25,12 @@ msgstr "" msgid "" "These APIs are a minimal emulation of the Python 2 C API for built-in file " "objects, which used to rely on the buffered I/O (:c:expr:`FILE*`) support " -"from the C standard library. In Python 3, files and streams use the new :" -"mod:`io` module, which defines several layers over the low-level unbuffered " -"I/O of the operating system. The functions described below are convenience " -"C wrappers over these new APIs, and meant mostly for internal error " -"reporting in the interpreter; third-party code is advised to access the :mod:" -"`io` APIs instead." +"from the C standard library. In Python 3, files and streams use the " +"new :mod:`io` module, which defines several layers over the low-level " +"unbuffered I/O of the operating system. The functions described below are " +"convenience C wrappers over these new APIs, and meant mostly for internal " +"error reporting in the interpreter; third-party code is advised to access " +"the :mod:`io` APIs instead." msgstr "" #: c-api/file.rst:22 @@ -56,23 +57,23 @@ msgstr "" #: c-api/file.rst:41 msgid "" "Return the file descriptor associated with *p* as an :c:expr:`int`. If the " -"object is an integer, its value is returned. If not, the object's :meth:" -"`~io.IOBase.fileno` method is called if it exists; the method must return an " -"integer, which is returned as the file descriptor value. Sets an exception " -"and returns ``-1`` on failure." +"object is an integer, its value is returned. If not, the " +"object's :meth:`~io.IOBase.fileno` method is called if it exists; the method " +"must return an integer, which is returned as the file descriptor value. " +"Sets an exception and returns ``-1`` on failure." msgstr "" #: c-api/file.rst:52 msgid "" "Equivalent to ``p.readline([n])``, this function reads one line from the " -"object *p*. *p* may be a file object or any object with a :meth:`~io.IOBase." -"readline` method. If *n* is ``0``, exactly one line is read, regardless of " -"the length of the line. If *n* is greater than ``0``, no more than *n* " -"bytes will be read from the file; a partial line can be returned. In both " -"cases, an empty string is returned if the end of the file is reached " -"immediately. If *n* is less than ``0``, however, one line is read " -"regardless of length, but :exc:`EOFError` is raised if the end of the file " -"is reached immediately." +"object *p*. *p* may be a file object or any object with " +"a :meth:`~io.IOBase.readline` method. If *n* is ``0``, exactly one line is " +"read, regardless of the length of the line. If *n* is greater than ``0``, " +"no more than *n* bytes will be read from the file; a partial line can be " +"returned. In both cases, an empty string is returned if the end of the file " +"is reached immediately. If *n* is less than ``0``, however, one line is " +"read regardless of length, but :exc:`EOFError` is raised if the end of the " +"file is reached immediately." msgstr "" #: c-api/file.rst:65 @@ -82,47 +83,47 @@ msgid "" msgstr "" #: c-api/file.rst:68 -msgid "The handler is a function of type:" +msgid "The *handler* is a function of type:" msgstr "" -#: c-api/file.rst:72 +#: c-api/file.rst:73 msgid "" "Equivalent of :c:expr:`PyObject *(\\*)(PyObject *path, void *userData)`, " "where *path* is guaranteed to be :c:type:`PyUnicodeObject`." msgstr "" -#: c-api/file.rst:76 +#: c-api/file.rst:77 msgid "" "The *userData* pointer is passed into the hook function. Since hook " "functions may be called from different runtimes, this pointer should not " "refer directly to Python state." msgstr "" -#: c-api/file.rst:80 +#: c-api/file.rst:81 msgid "" "As this hook is intentionally used during import, avoid importing new " "modules during its execution unless they are known to be frozen or available " "in ``sys.modules``." msgstr "" -#: c-api/file.rst:84 +#: c-api/file.rst:85 msgid "" "Once a hook has been set, it cannot be removed or replaced, and later calls " "to :c:func:`PyFile_SetOpenCodeHook` will fail. On failure, the function " "returns -1 and sets an exception if the interpreter has been initialized." msgstr "" -#: c-api/file.rst:88 +#: c-api/file.rst:89 msgid "This function is safe to call before :c:func:`Py_Initialize`." msgstr "" -#: c-api/file.rst:90 +#: c-api/file.rst:91 msgid "" "Raises an :ref:`auditing event ` ``setopencodehook`` with no " "arguments." msgstr "" -#: c-api/file.rst:100 +#: c-api/file.rst:101 msgid "" "Write object *obj* to file object *p*. The only supported flag for *flags* " "is :c:macro:`Py_PRINT_RAW`; if given, the :func:`str` of the object is " @@ -130,7 +131,7 @@ msgid "" "failure; the appropriate exception will be set." msgstr "" -#: c-api/file.rst:108 +#: c-api/file.rst:109 msgid "" "Write string *s* to file object *p*. Return ``0`` on success or ``-1`` on " "failure; the appropriate exception will be set." @@ -148,6 +149,6 @@ msgstr "" msgid "EOFError (built-in exception)" msgstr "" -#: c-api/file.rst:98 +#: c-api/file.rst:99 msgid "Py_PRINT_RAW (C macro)" msgstr "" diff --git a/c-api/float.po b/c-api/float.po index bb9367de..dbc37d94 100644 --- a/c-api/float.po +++ b/c-api/float.po @@ -8,33 +8,34 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: c-api/float.rst:6 -msgid "Floating Point Objects" +msgid "Floating-Point Objects" msgstr "" #: c-api/float.rst:13 msgid "" -"This subtype of :c:type:`PyObject` represents a Python floating point object." +"This subtype of :c:type:`PyObject` represents a Python floating-point object." msgstr "" #: c-api/float.rst:18 msgid "" -"This instance of :c:type:`PyTypeObject` represents the Python floating point " +"This instance of :c:type:`PyTypeObject` represents the Python floating-point " "type. This is the same object as :class:`float` in the Python layer." msgstr "" #: c-api/float.rst:24 msgid "" -"Return true if its argument is a :c:type:`PyFloatObject` or a subtype of :c:" -"type:`PyFloatObject`. This function always succeeds." +"Return true if its argument is a :c:type:`PyFloatObject` or a subtype " +"of :c:type:`PyFloatObject`. This function always succeeds." msgstr "" #: c-api/float.rst:30 @@ -57,11 +58,11 @@ msgstr "" #: c-api/float.rst:47 msgid "" "Return a C :c:expr:`double` representation of the contents of *pyfloat*. If " -"*pyfloat* is not a Python floating point object but has a :meth:`~object." -"__float__` method, this method will first be called to convert *pyfloat* " -"into a float. If :meth:`!__float__` is not defined then it falls back to :" -"meth:`~object.__index__`. This method returns ``-1.0`` upon failure, so one " -"should call :c:func:`PyErr_Occurred` to check for errors." +"*pyfloat* is not a Python floating-point object but has " +"a :meth:`~object.__float__` method, this method will first be called to " +"convert *pyfloat* into a float. If :meth:`!__float__` is not defined then it " +"falls back to :meth:`~object.__index__`. This method returns ``-1.0`` upon " +"failure, so one should call :c:func:`PyErr_Occurred` to check for errors." msgstr "" #: c-api/float.rst:54 @@ -83,8 +84,8 @@ msgstr "" #: c-api/float.rst:73 msgid "" -"Return the maximum representable finite float *DBL_MAX* as C :c:expr:" -"`double`." +"Return the maximum representable finite float *DBL_MAX* as " +"C :c:expr:`double`." msgstr "" #: c-api/float.rst:78 @@ -100,9 +101,9 @@ msgstr "" msgid "" "The pack and unpack functions provide an efficient platform-independent way " "to store floating-point values as byte strings. The Pack routines produce a " -"bytes string from a C :c:expr:`double`, and the Unpack routines produce a C :" -"c:expr:`double` from such a bytes string. The suffix (2, 4 or 8) specifies " -"the number of bytes in the bytes string." +"bytes string from a C :c:expr:`double`, and the Unpack routines produce a " +"C :c:expr:`double` from such a bytes string. The suffix (2, 4 or 8) " +"specifies the number of bytes in the bytes string." msgstr "" #: c-api/float.rst:90 @@ -131,12 +132,13 @@ msgstr "" #: c-api/float.rst:109 msgid "" -"The pack routines write 2, 4 or 8 bytes, starting at *p*. *le* is an :c:expr:" -"`int` argument, non-zero if you want the bytes string in little-endian " -"format (exponent last, at ``p+1``, ``p+3``, or ``p+6`` ``p+7``), zero if you " -"want big-endian format (exponent first, at *p*). The :c:macro:" -"`PY_BIG_ENDIAN` constant can be used to use the native endian: it is equal " -"to ``1`` on big endian processor, or ``0`` on little endian processor." +"The pack routines write 2, 4 or 8 bytes, starting at *p*. *le* is " +"an :c:expr:`int` argument, non-zero if you want the bytes string in little-" +"endian format (exponent last, at ``p+1``, ``p+3``, or ``p+6`` ``p+7``), zero " +"if you want big-endian format (exponent first, at *p*). " +"The :c:macro:`PY_BIG_ENDIAN` constant can be used to use the native endian: " +"it is equal to ``1`` on big endian processor, or ``0`` on little endian " +"processor." msgstr "" #: c-api/float.rst:116 @@ -175,19 +177,19 @@ msgstr "" #: c-api/float.rst:140 msgid "" -"The unpack routines read 2, 4 or 8 bytes, starting at *p*. *le* is an :c:" -"expr:`int` argument, non-zero if the bytes string is in little-endian format " -"(exponent last, at ``p+1``, ``p+3`` or ``p+6`` and ``p+7``), zero if big-" -"endian (exponent first, at *p*). The :c:macro:`PY_BIG_ENDIAN` constant can " -"be used to use the native endian: it is equal to ``1`` on big endian " +"The unpack routines read 2, 4 or 8 bytes, starting at *p*. *le* is " +"an :c:expr:`int` argument, non-zero if the bytes string is in little-endian " +"format (exponent last, at ``p+1``, ``p+3`` or ``p+6`` and ``p+7``), zero if " +"big-endian (exponent first, at *p*). The :c:macro:`PY_BIG_ENDIAN` constant " +"can be used to use the native endian: it is equal to ``1`` on big endian " "processor, or ``0`` on little endian processor." msgstr "" #: c-api/float.rst:147 msgid "" -"Return value: The unpacked double. On error, this is ``-1.0`` and :c:func:" -"`PyErr_Occurred` is true (and an exception is set, most likely :exc:" -"`OverflowError`)." +"Return value: The unpacked double. On error, this is ``-1.0`` " +"and :c:func:`PyErr_Occurred` is true (and an exception is set, most " +"likely :exc:`OverflowError`)." msgstr "" #: c-api/float.rst:151 @@ -213,5 +215,5 @@ msgid "object" msgstr "" #: c-api/float.rst:8 -msgid "floating point" +msgid "floating-point" msgstr "" diff --git a/c-api/frame.po b/c-api/frame.po index 229a339b..f71c5a62 100644 --- a/c-api/frame.po +++ b/c-api/frame.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -46,8 +47,8 @@ msgstr "" #: c-api/frame.rst:24 msgid "" -"The type of frame objects. It is the same object as :py:class:`types." -"FrameType` in the Python layer." +"The type of frame objects. It is the same object " +"as :py:class:`types.FrameType` in the Python layer." msgstr "" #: c-api/frame.rst:29 @@ -61,8 +62,8 @@ msgstr "" #: c-api/frame.rst:38 msgid "" -"Previously, this function was only available after including ````." +"Previously, this function was only available after including " +"````." msgstr "" #: c-api/frame.rst:43 diff --git a/c-api/function.po b/c-api/function.po index b05a610f..7f4e4070 100644 --- a/c-api/function.po +++ b/c-api/function.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -31,15 +32,15 @@ msgstr "" #: c-api/function.rst:22 msgid "" "This is an instance of :c:type:`PyTypeObject` and represents the Python " -"function type. It is exposed to Python programmers as ``types." -"FunctionType``." +"function type. It is exposed to Python programmers as " +"``types.FunctionType``." msgstr "" #: c-api/function.rst:28 msgid "" -"Return true if *o* is a function object (has type :c:data:" -"`PyFunction_Type`). The parameter must not be ``NULL``. This function " -"always succeeds." +"Return true if *o* is a function object (has " +"type :c:data:`PyFunction_Type`). The parameter must not be ``NULL``. This " +"function always succeeds." msgstr "" #: c-api/function.rst:34 @@ -51,19 +52,20 @@ msgstr "" #: c-api/function.rst:37 msgid "" -"The function's docstring and name are retrieved from the code object. :attr:" -"`~function.__module__` is retrieved from *globals*. The argument defaults, " -"annotations and closure are set to ``NULL``. :attr:`~function.__qualname__` " -"is set to the same value as the code object's :attr:`~codeobject." -"co_qualname` field." +"The function's docstring and name are retrieved from the code " +"object. :attr:`~function.__module__` is retrieved from *globals*. The " +"argument defaults, annotations and closure are set to " +"``NULL``. :attr:`~function.__qualname__` is set to the same value as the " +"code object's :attr:`~codeobject.co_qualname` field." msgstr "" #: c-api/function.rst:46 msgid "" -"As :c:func:`PyFunction_New`, but also allows setting the function object's :" -"attr:`~function.__qualname__` attribute. *qualname* should be a unicode " -"object or ``NULL``; if ``NULL``, the :attr:`!__qualname__` attribute is set " -"to the same value as the code object's :attr:`~codeobject.co_qualname` field." +"As :c:func:`PyFunction_New`, but also allows setting the function " +"object's :attr:`~function.__qualname__` attribute. *qualname* should be a " +"unicode object or ``NULL``; if ``NULL``, the :attr:`!__qualname__` attribute " +"is set to the same value as the code " +"object's :attr:`~codeobject.co_qualname` field." msgstr "" #: c-api/function.rst:57 @@ -147,39 +149,55 @@ msgstr "" #: c-api/function.rst:138 msgid "" -"Clear watcher identified by *watcher_id* previously returned from :c:func:" -"`PyFunction_AddWatcher` for the current interpreter. Return ``0`` on " -"success, or ``-1`` and set an exception on error (e.g. if the given " -"*watcher_id* was never registered.)" +"Clear watcher identified by *watcher_id* previously returned " +"from :c:func:`PyFunction_AddWatcher` for the current interpreter. Return " +"``0`` on success, or ``-1`` and set an exception on error (e.g. if the " +"given *watcher_id* was never registered.)" msgstr "" #: c-api/function.rst:148 -msgid "" -"Enumeration of possible function watcher events: - " -"``PyFunction_EVENT_CREATE`` - ``PyFunction_EVENT_DESTROY`` - " -"``PyFunction_EVENT_MODIFY_CODE`` - ``PyFunction_EVENT_MODIFY_DEFAULTS`` - " -"``PyFunction_EVENT_MODIFY_KWDEFAULTS``" +msgid "Enumeration of possible function watcher events:" +msgstr "" + +#: c-api/function.rst:150 +msgid "``PyFunction_EVENT_CREATE``" +msgstr "" + +#: c-api/function.rst:151 +msgid "``PyFunction_EVENT_DESTROY``" +msgstr "" + +#: c-api/function.rst:152 +msgid "``PyFunction_EVENT_MODIFY_CODE``" +msgstr "" + +#: c-api/function.rst:153 +msgid "``PyFunction_EVENT_MODIFY_DEFAULTS``" +msgstr "" + +#: c-api/function.rst:154 +msgid "``PyFunction_EVENT_MODIFY_KWDEFAULTS``" msgstr "" -#: c-api/function.rst:160 +#: c-api/function.rst:161 msgid "Type of a function watcher callback function." msgstr "" -#: c-api/function.rst:162 +#: c-api/function.rst:163 msgid "" "If *event* is ``PyFunction_EVENT_CREATE`` or ``PyFunction_EVENT_DESTROY`` " -"then *new_value* will be ``NULL``. Otherwise, *new_value* will hold a :term:" -"`borrowed reference` to the new value that is about to be stored in *func* " -"for the attribute that is being modified." +"then *new_value* will be ``NULL``. Otherwise, *new_value* will hold " +"a :term:`borrowed reference` to the new value that is about to be stored in " +"*func* for the attribute that is being modified." msgstr "" -#: c-api/function.rst:167 +#: c-api/function.rst:168 msgid "" "The callback may inspect but must not modify *func*; doing so could have " "unpredictable effects, including infinite recursion." msgstr "" -#: c-api/function.rst:170 +#: c-api/function.rst:171 msgid "" "If *event* is ``PyFunction_EVENT_CREATE``, then the callback is invoked " "after `func` has been fully initialized. Otherwise, the callback is invoked " @@ -191,7 +209,7 @@ msgid "" "semantics of the Python code being executed." msgstr "" -#: c-api/function.rst:179 +#: c-api/function.rst:180 msgid "" "If *event* is ``PyFunction_EVENT_DESTROY``, Taking a reference in the " "callback to the about-to-be-destroyed function will resurrect it, preventing " @@ -199,14 +217,14 @@ msgid "" "later, any watcher callbacks active at that time will be called again." msgstr "" -#: c-api/function.rst:184 +#: c-api/function.rst:185 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " -"will be printed as an unraisable exception using :c:func:" -"`PyErr_WriteUnraisable`. Otherwise it should return ``0``." +"will be printed as an unraisable exception " +"using :c:func:`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" -#: c-api/function.rst:188 +#: c-api/function.rst:189 msgid "" "There may already be a pending exception set on entry to the callback. In " "this case, the callback should return ``0`` with the same exception still " diff --git a/c-api/gcsupport.po b/c-api/gcsupport.po index 07d472e4..ac03e7de 100644 --- a/c-api/gcsupport.po +++ b/c-api/gcsupport.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -39,7 +40,7 @@ msgid "" "implementation must also be provided." msgstr "" -#: c-api/gcsupport.rst:24 +#: c-api/gcsupport.rst:21 msgid ":c:macro:`Py_TPFLAGS_HAVE_GC`" msgstr "" @@ -74,8 +75,8 @@ msgstr "" #: c-api/gcsupport.rst:37 msgid "" -"Before fields which refer to other containers are invalidated, :c:func:" -"`PyObject_GC_UnTrack` must be called." +"Before fields which refer to other containers are " +"invalidated, :c:func:`PyObject_GC_UnTrack` must be called." msgstr "" #: c-api/gcsupport.rst:40 @@ -85,32 +86,32 @@ msgstr "" #: c-api/gcsupport.rst:43 msgid "" -"If a type adds the Py_TPFLAGS_HAVE_GC, then it *must* implement at least a :" -"c:member:`~PyTypeObject.tp_traverse` handler or explicitly use one from its " -"subclass or subclasses." +"If a type adds the Py_TPFLAGS_HAVE_GC, then it *must* implement at least " +"a :c:member:`~PyTypeObject.tp_traverse` handler or explicitly use one from " +"its subclass or subclasses." msgstr "" #: c-api/gcsupport.rst:47 msgid "" "When calling :c:func:`PyType_Ready` or some of the APIs that indirectly call " "it like :c:func:`PyType_FromSpecWithBases` or :c:func:`PyType_FromSpec` the " -"interpreter will automatically populate the :c:member:`~PyTypeObject." -"tp_flags`, :c:member:`~PyTypeObject.tp_traverse` and :c:member:" -"`~PyTypeObject.tp_clear` fields if the type inherits from a class that " -"implements the garbage collector protocol and the child class does *not* " -"include the :c:macro:`Py_TPFLAGS_HAVE_GC` flag." +"interpreter will automatically populate " +"the :c:member:`~PyTypeObject.tp_flags`, :c:member:`~PyTypeObject.tp_traverse` " +"and :c:member:`~PyTypeObject.tp_clear` fields if the type inherits from a " +"class that implements the garbage collector protocol and the child class " +"does *not* include the :c:macro:`Py_TPFLAGS_HAVE_GC` flag." msgstr "" #: c-api/gcsupport.rst:57 msgid "" -"Analogous to :c:macro:`PyObject_New` but for container objects with the :c:" -"macro:`Py_TPFLAGS_HAVE_GC` flag set." +"Analogous to :c:macro:`PyObject_New` but for container objects with " +"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag set." msgstr "" #: c-api/gcsupport.rst:62 msgid "" -"Analogous to :c:macro:`PyObject_NewVar` but for container objects with the :" -"c:macro:`Py_TPFLAGS_HAVE_GC` flag set." +"Analogous to :c:macro:`PyObject_NewVar` but for container objects with " +"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag set." msgstr "" #: c-api/gcsupport.rst:67 @@ -131,8 +132,8 @@ msgstr "" msgid "" "The function is marked as unstable because the final mechanism for reserving " "extra data after an instance is not yet decided. For allocating a variable " -"number of fields, prefer using :c:type:`PyVarObject` and :c:member:" -"`~PyTypeObject.tp_itemsize` instead." +"number of fields, prefer using :c:type:`PyVarObject` " +"and :c:member:`~PyTypeObject.tp_itemsize` instead." msgstr "" #: c-api/gcsupport.rst:88 @@ -191,18 +192,18 @@ msgstr "" #: c-api/gcsupport.rst:136 msgid "" -"Releases memory allocated to an object using :c:macro:`PyObject_GC_New` or :" -"c:macro:`PyObject_GC_NewVar`." +"Releases memory allocated to an object using :c:macro:`PyObject_GC_New` " +"or :c:macro:`PyObject_GC_NewVar`." msgstr "" #: c-api/gcsupport.rst:142 msgid "" "Remove the object *op* from the set of container objects tracked by the " "collector. Note that :c:func:`PyObject_GC_Track` can be called again on " -"this object to add it back to the set of tracked objects. The deallocator (:" -"c:member:`~PyTypeObject.tp_dealloc` handler) should call this for the object " -"before any of the fields used by the :c:member:`~PyTypeObject.tp_traverse` " -"handler become invalid." +"this object to add it back to the set of tracked objects. The deallocator " +"(:c:member:`~PyTypeObject.tp_dealloc` handler) should call this for the " +"object before any of the fields used by " +"the :c:member:`~PyTypeObject.tp_traverse` handler become invalid." msgstr "" #: c-api/gcsupport.rst:151 @@ -219,12 +220,12 @@ msgstr "" #: c-api/gcsupport.rst:159 msgid "" -"Type of the visitor function passed to the :c:member:`~PyTypeObject." -"tp_traverse` handler. The function should be called with an object to " -"traverse as *object* and the third parameter to the :c:member:`~PyTypeObject." -"tp_traverse` handler as *arg*. The Python core uses several visitor " -"functions to implement cyclic garbage detection; it's not expected that " -"users will need to write their own visitor functions." +"Type of the visitor function passed to " +"the :c:member:`~PyTypeObject.tp_traverse` handler. The function should be " +"called with an object to traverse as *object* and the third parameter to " +"the :c:member:`~PyTypeObject.tp_traverse` handler as *arg*. The Python core " +"uses several visitor functions to implement cyclic garbage detection; it's " +"not expected that users will need to write their own visitor functions." msgstr "" #: c-api/gcsupport.rst:166 @@ -245,10 +246,10 @@ msgstr "" #: c-api/gcsupport.rst:178 msgid "" -"To simplify writing :c:member:`~PyTypeObject.tp_traverse` handlers, a :c:" -"func:`Py_VISIT` macro is provided. In order to use this macro, the :c:" -"member:`~PyTypeObject.tp_traverse` implementation must name its arguments " -"exactly *visit* and *arg*:" +"To simplify writing :c:member:`~PyTypeObject.tp_traverse` handlers, " +"a :c:func:`Py_VISIT` macro is provided. In order to use this macro, " +"the :c:member:`~PyTypeObject.tp_traverse` implementation must name its " +"arguments exactly *visit* and *arg*:" msgstr "" #: c-api/gcsupport.rst:185 @@ -258,10 +259,21 @@ msgid "" "macro, :c:member:`~PyTypeObject.tp_traverse` handlers look like::" msgstr "" +#: c-api/gcsupport.rst:190 +msgid "" +"static int\n" +"my_traverse(Noddy *self, visitproc visit, void *arg)\n" +"{\n" +" Py_VISIT(self->foo);\n" +" Py_VISIT(self->bar);\n" +" return 0;\n" +"}" +msgstr "" + #: c-api/gcsupport.rst:198 msgid "" -"The :c:member:`~PyTypeObject.tp_clear` handler must be of the :c:type:" -"`inquiry` type, or ``NULL`` if the object is immutable." +"The :c:member:`~PyTypeObject.tp_clear` handler must be of " +"the :c:type:`inquiry` type, or ``NULL`` if the object is immutable." msgstr "" #: c-api/gcsupport.rst:204 @@ -294,8 +306,8 @@ msgstr "" msgid "" "Returns the number of collected + unreachable objects which cannot be " "collected. If the garbage collector is disabled or already collecting, " -"returns ``0`` immediately. Errors during garbage collection are passed to :" -"data:`sys.unraisablehook`. This function does not raise exceptions." +"returns ``0`` immediately. Errors during garbage collection are passed " +"to :data:`sys.unraisablehook`. This function does not raise exceptions." msgstr "" #: c-api/gcsupport.rst:233 @@ -347,9 +359,9 @@ msgstr "" #: c-api/gcsupport.rst:278 msgid "" -"Type of the visitor function to be passed to :c:func:" -"`PyUnstable_GC_VisitObjects`. *arg* is the same as the *arg* passed to " -"``PyUnstable_GC_VisitObjects``. Return ``0`` to continue iteration, return " -"``1`` to stop iteration. Other return values are reserved for now so " -"behavior on returning anything else is undefined." +"Type of the visitor function to be passed " +"to :c:func:`PyUnstable_GC_VisitObjects`. *arg* is the same as the *arg* " +"passed to ``PyUnstable_GC_VisitObjects``. Return ``0`` to continue " +"iteration, return ``1`` to stop iteration. Other return values are reserved " +"for now so behavior on returning anything else is undefined." msgstr "" diff --git a/c-api/gen.po b/c-api/gen.po index e59b546d..dc60618a 100644 --- a/c-api/gen.po +++ b/c-api/gen.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,8 +25,8 @@ msgstr "" msgid "" "Generator objects are what Python uses to implement generator iterators. " "They are normally created by iterating over a function that yields values, " -"rather than explicitly calling :c:func:`PyGen_New` or :c:func:" -"`PyGen_NewWithQualName`." +"rather than explicitly calling :c:func:`PyGen_New` " +"or :c:func:`PyGen_NewWithQualName`." msgstr "" #: c-api/gen.rst:15 diff --git a/c-api/hash.po b/c-api/hash.po index e6afcfad..adfbf644 100644 --- a/c-api/hash.po +++ b/c-api/hash.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/c-api/import.po b/c-api/import.po index d77ab7f3..5364b5ec 100644 --- a/c-api/import.po +++ b/c-api/import.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -22,8 +23,8 @@ msgstr "" #: c-api/import.rst:16 msgid "" -"This is a wrapper around :c:func:`PyImport_Import()` which takes a :c:expr:" -"`const char *` as an argument instead of a :c:expr:`PyObject *`." +"This is a wrapper around :c:func:`PyImport_Import()` which takes " +"a :c:expr:`const char *` as an argument instead of a :c:expr:`PyObject *`." msgstr "" #: c-api/import.rst:21 @@ -47,15 +48,16 @@ msgstr "" #: c-api/import.rst:53 msgid "" "The return value is a new reference to the imported module or top-level " -"package, or ``NULL`` with an exception set on failure. Like for :func:" -"`__import__`, the return value when a submodule of a package was requested " -"is normally the top-level package, unless a non-empty *fromlist* was given." +"package, or ``NULL`` with an exception set on failure. Like " +"for :func:`__import__`, the return value when a submodule of a package was " +"requested is normally the top-level package, unless a non-empty *fromlist* " +"was given." msgstr "" #: c-api/import.rst:43 msgid "" -"Failing imports remove incomplete module objects, like with :c:func:" -"`PyImport_ImportModule`." +"Failing imports remove incomplete module objects, like " +"with :c:func:`PyImport_ImportModule`." msgstr "" #: c-api/import.rst:49 @@ -105,10 +107,10 @@ msgstr "" #: c-api/import.rst:95 msgid "" "This function does not load or import the module; if the module wasn't " -"already loaded, you will get an empty module object. Use :c:func:" -"`PyImport_ImportModule` or one of its variants to import a module. Package " -"structures implied by a dotted name for *name* are not created if not " -"already present." +"already loaded, you will get an empty module object. " +"Use :c:func:`PyImport_ImportModule` or one of its variants to import a " +"module. Package structures implied by a dotted name for *name* are not " +"created if not already present." msgstr "" #: c-api/import.rst:105 @@ -124,32 +126,32 @@ msgid "" "function :func:`compile`, load the module. Return a new reference to the " "module object, or ``NULL`` with an exception set if an error occurred. " "*name* is removed from :data:`sys.modules` in error cases, even if *name* " -"was already in :data:`sys.modules` on entry to :c:func:" -"`PyImport_ExecCodeModule`. Leaving incompletely initialized modules in :" -"data:`sys.modules` is dangerous, as imports of such modules have no way to " -"know that the module object is an unknown (and probably damaged with respect " -"to the module author's intents) state." +"was already in :data:`sys.modules` on entry " +"to :c:func:`PyImport_ExecCodeModule`. Leaving incompletely initialized " +"modules in :data:`sys.modules` is dangerous, as imports of such modules have " +"no way to know that the module object is an unknown (and probably damaged " +"with respect to the module author's intents) state." msgstr "" #: c-api/import.rst:123 msgid "" -"The module's :attr:`__spec__` and :attr:`__loader__` will be set, if not set " -"already, with the appropriate values. The spec's loader will be set to the " -"module's ``__loader__`` (if set) and to an instance of :class:`~importlib." -"machinery.SourceFileLoader` otherwise." +"The module's :attr:`~module.__spec__` and :attr:`~module.__loader__` will be " +"set, if not set already, with the appropriate values. The spec's loader " +"will be set to the module's :attr:`!__loader__` (if set) and to an instance " +"of :class:`~importlib.machinery.SourceFileLoader` otherwise." msgstr "" #: c-api/import.rst:128 msgid "" -"The module's :attr:`__file__` attribute will be set to the code object's :" -"attr:`~codeobject.co_filename`. If applicable, :attr:`__cached__` will also " -"be set." +"The module's :attr:`~module.__file__` attribute will be set to the code " +"object's :attr:`~codeobject.co_filename`. If " +"applicable, :attr:`~module.__cached__` will also be set." msgstr "" #: c-api/import.rst:132 msgid "" -"This function will reload the module if it was already imported. See :c:" -"func:`PyImport_ReloadModule` for the intended way to reload a module." +"This function will reload the module if it was already imported. " +"See :c:func:`PyImport_ReloadModule` for the intended way to reload a module." msgstr "" #: c-api/import.rst:135 @@ -160,20 +162,20 @@ msgstr "" #: c-api/import.rst:138 msgid "" -"See also :c:func:`PyImport_ExecCodeModuleEx` and :c:func:" -"`PyImport_ExecCodeModuleWithPathnames`." +"See also :c:func:`PyImport_ExecCodeModuleEx` " +"and :c:func:`PyImport_ExecCodeModuleWithPathnames`." msgstr "" #: c-api/import.rst:141 msgid "" -"The setting of :attr:`__cached__` and :attr:`__loader__` is deprecated. See :" -"class:`~importlib.machinery.ModuleSpec` for alternatives." +"The setting of :attr:`~module.__cached__` and :attr:`~module.__loader__` is " +"deprecated. See :class:`~importlib.machinery.ModuleSpec` for alternatives." msgstr "" #: c-api/import.rst:149 msgid "" -"Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`__file__` attribute " -"of the module object is set to *pathname* if it is non-``NULL``." +"Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`~module.__file__` " +"attribute of the module object is set to *pathname* if it is non-``NULL``." msgstr "" #: c-api/import.rst:152 @@ -182,15 +184,15 @@ msgstr "" #: c-api/import.rst:157 msgid "" -"Like :c:func:`PyImport_ExecCodeModuleEx`, but the :attr:`__cached__` " +"Like :c:func:`PyImport_ExecCodeModuleEx`, but the :attr:`~module.__cached__` " "attribute of the module object is set to *cpathname* if it is non-``NULL``. " "Of the three functions, this is the preferred one to use." msgstr "" #: c-api/import.rst:163 msgid "" -"Setting :attr:`__cached__` is deprecated. See :class:`~importlib.machinery." -"ModuleSpec` for alternatives." +"Setting :attr:`~module.__cached__` is deprecated. " +"See :class:`~importlib.machinery.ModuleSpec` for alternatives." msgstr "" #: c-api/import.rst:170 @@ -203,7 +205,7 @@ msgstr "" #: c-api/import.rst:176 msgid "" -"Uses :func:`!imp.source_from_cache()` in calculating the source path if only " +"Uses :func:`!imp.source_from_cache` in calculating the source path if only " "the bytecode path is provided." msgstr "" @@ -231,8 +233,8 @@ msgstr "" #: c-api/import.rst:203 msgid "" -"Return the dictionary used for the module administration (a.k.a. ``sys." -"modules``). Note that this is a per-interpreter variable." +"Return the dictionary used for the module administration (a.k.a. " +"``sys.modules``). Note that this is a per-interpreter variable." msgstr "" #: c-api/import.rst:208 @@ -249,17 +251,18 @@ msgid "" "dict. If it wasn't yet cached, traverse :data:`sys.path_hooks` until a hook " "is found that can handle the path item. Return ``None`` if no hook could; " "this tells our caller that the :term:`path based finder` could not find a " -"finder for this path item. Cache the result in :data:`sys." -"path_importer_cache`. Return a new reference to the finder object." +"finder for this path item. Cache the result " +"in :data:`sys.path_importer_cache`. Return a new reference to the finder " +"object." msgstr "" #: c-api/import.rst:227 msgid "" "Load a frozen module named *name*. Return ``1`` for success, ``0`` if the " "module is not found, and ``-1`` with an exception set if the initialization " -"failed. To access the imported module on a successful load, use :c:func:" -"`PyImport_ImportModule`. (Note the misnomer --- this function would reload " -"the module if it was already imported.)" +"failed. To access the imported module on a successful load, " +"use :c:func:`PyImport_ImportModule`. (Note the misnomer --- this function " +"would reload the module if it was already imported.)" msgstr "" #: c-api/import.rst:235 @@ -276,8 +279,18 @@ msgstr "" msgid "" "This is the structure type definition for frozen module descriptors, as " "generated by the :program:`freeze` utility (see :file:`Tools/freeze/` in the " -"Python source distribution). Its definition, found in :file:`Include/import." -"h`, is::" +"Python source distribution). Its definition, found in :file:`Include/" +"import.h`, is::" +msgstr "" + +#: c-api/import.rst:254 +msgid "" +"struct _frozen {\n" +" const char *name;\n" +" const unsigned char *code;\n" +" int size;\n" +" bool is_package;\n" +"};" msgstr "" #: c-api/import.rst:261 @@ -324,12 +337,12 @@ msgstr "" #: c-api/import.rst:302 msgid "" "Add a collection of modules to the table of built-in modules. The *newtab* " -"array must end with a sentinel entry which contains ``NULL`` for the :c:" -"member:`~_inittab.name` field; failure to provide the sentinel value can " -"result in a memory fault. Returns ``0`` on success or ``-1`` if insufficient " -"memory could be allocated to extend the internal table. In the event of " -"failure, no modules are added to the internal table. This must be called " -"before :c:func:`Py_Initialize`." +"array must end with a sentinel entry which contains ``NULL`` for " +"the :c:member:`~_inittab.name` field; failure to provide the sentinel value " +"can result in a memory fault. Returns ``0`` on success or ``-1`` if " +"insufficient memory could be allocated to extend the internal table. In the " +"event of failure, no modules are added to the internal table. This must be " +"called before :c:func:`Py_Initialize`." msgstr "" #: c-api/import.rst:309 diff --git a/c-api/index.po b/c-api/index.po index c7c6be32..a6493e9b 100644 --- a/c-api/index.po +++ b/c-api/index.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -23,7 +24,7 @@ msgstr "" #: c-api/index.rst:7 msgid "" "This manual documents the API used by C and C++ programmers who want to " -"write extension modules or embed Python. It is a companion to :ref:" -"`extending-index`, which describes the general principles of extension " -"writing but does not document the API functions in detail." +"write extension modules or embed Python. It is a companion " +"to :ref:`extending-index`, which describes the general principles of " +"extension writing but does not document the API functions in detail." msgstr "" diff --git a/c-api/init.po b/c-api/init.po index 9fcd351f..0c33ceaa 100644 --- a/c-api/init.po +++ b/c-api/init.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -163,11 +164,9 @@ msgstr "" #: c-api/init.rst:64 msgid "" -"The following functions **should not be called** before :c:func:" -"`Py_Initialize`: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`, :c:func:" -"`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, :c:func:" -"`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome`, :c:func:" -"`Py_GetProgramName` and :c:func:`PyEval_InitThreads`." +"The following functions **should not be called** " +"before :c:func:`Py_Initialize`: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, :c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome`, :c:func:`Py_GetProgramName` " +"and :c:func:`PyEval_InitThreads`." msgstr "" #: c-api/init.rst:74 @@ -177,30 +176,30 @@ msgstr "" #: c-api/init.rst:76 msgid "" "Python has variables for the global configuration to control different " -"features and options. By default, these flags are controlled by :ref:" -"`command line options `." +"features and options. By default, these flags are controlled " +"by :ref:`command line options `." msgstr "" #: c-api/init.rst:80 msgid "" "When a flag is set by an option, the value of the flag is the number of " -"times that the option was set. For example, ``-b`` sets :c:data:" -"`Py_BytesWarningFlag` to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to " -"2." +"times that the option was set. For example, ``-b`` " +"sets :c:data:`Py_BytesWarningFlag` to 1 and ``-bb`` " +"sets :c:data:`Py_BytesWarningFlag` to 2." msgstr "" #: c-api/init.rst:86 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"bytes_warning` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.bytes_warning` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:90 msgid "" -"Issue a warning when comparing :class:`bytes` or :class:`bytearray` with :" -"class:`str` or :class:`bytes` with :class:`int`. Issue an error if greater " -"or equal to ``2``." +"Issue a warning when comparing :class:`bytes` or :class:`bytearray` " +"with :class:`str` or :class:`bytes` with :class:`int`. Issue an error if " +"greater or equal to ``2``." msgstr "" #: c-api/init.rst:94 @@ -209,9 +208,9 @@ msgstr "" #: c-api/init.rst:100 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"parser_debug` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.parser_debug` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:104 @@ -228,9 +227,9 @@ msgstr "" #: c-api/init.rst:114 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"write_bytecode` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.write_bytecode` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:118 @@ -247,15 +246,15 @@ msgstr "" #: c-api/init.rst:128 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"pathconfig_warnings` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.pathconfig_warnings` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:132 msgid "" -"Suppress error messages when calculating the module search path in :c:func:" -"`Py_GetPath`." +"Suppress error messages when calculating the module search path " +"in :c:func:`Py_GetPath`." msgstr "" #: c-api/init.rst:135 @@ -264,8 +263,9 @@ msgstr "" #: c-api/init.rst:141 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"hash_seed` and :c:member:`PyConfig.use_hash_seed` should be used instead, " +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.hash_seed` " +"and :c:member:`PyConfig.use_hash_seed` should be used instead, " "see :ref:`Python Initialization Configuration `." msgstr "" @@ -283,15 +283,15 @@ msgstr "" #: c-api/init.rst:156 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"use_environment` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.use_environment` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:160 msgid "" -"Ignore all :envvar:`!PYTHON*` environment variables, e.g. :envvar:" -"`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set." +"Ignore all :envvar:`!PYTHON*` environment variables, " +"e.g. :envvar:`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set." msgstr "" #: c-api/init.rst:163 @@ -300,9 +300,9 @@ msgstr "" #: c-api/init.rst:169 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"inspect` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.inspect` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:173 @@ -320,9 +320,9 @@ msgstr "" #: c-api/init.rst:184 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"interactive` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.interactive` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:188 @@ -331,9 +331,9 @@ msgstr "" #: c-api/init.rst:194 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"isolated` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.isolated` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:198 @@ -348,9 +348,9 @@ msgstr "" #: c-api/init.rst:209 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyPreConfig." -"legacy_windows_fs_encoding` should be used instead, see :ref:`Python " -"Initialization Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyPreConfig.legacy_windows_fs_encoding` should be used " +"instead, see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:213 @@ -371,20 +371,20 @@ msgid "See :pep:`529` for more details." msgstr "" #: c-api/init.rst:240 -msgid ":ref:`Availability `: Windows." +msgid "Availability" msgstr "" #: c-api/init.rst:228 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"legacy_windows_stdio` should be used instead, see :ref:`Python " -"Initialization Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.legacy_windows_stdio` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:232 msgid "" -"If the flag is non-zero, use :class:`io.FileIO` instead of :class:`!io." -"_WindowsConsoleIO` for :mod:`sys` standard streams." +"If the flag is non-zero, use :class:`io.FileIO` instead of :class:`!" +"io._WindowsConsoleIO` for :mod:`sys` standard streams." msgstr "" #: c-api/init.rst:235 @@ -399,17 +399,17 @@ msgstr "" #: c-api/init.rst:246 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"site_import` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.site_import` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:250 msgid "" "Disable the import of the module :mod:`site` and the site-dependent " "manipulations of :data:`sys.path` that it entails. Also disable these " -"manipulations if :mod:`site` is explicitly imported later (call :func:`site." -"main` if you want them to be triggered)." +"manipulations if :mod:`site` is explicitly imported later " +"(call :func:`site.main` if you want them to be triggered)." msgstr "" #: c-api/init.rst:255 @@ -418,28 +418,28 @@ msgstr "" #: c-api/init.rst:261 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"user_site_directory` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.user_site_directory` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:265 msgid "" -"Don't add the :data:`user site-packages directory ` to :data:" -"`sys.path`." +"Don't add the :data:`user site-packages directory ` " +"to :data:`sys.path`." msgstr "" #: c-api/init.rst:268 msgid "" -"Set by the :option:`-s` and :option:`-I` options, and the :envvar:" -"`PYTHONNOUSERSITE` environment variable." +"Set by the :option:`-s` and :option:`-I` options, and " +"the :envvar:`PYTHONNOUSERSITE` environment variable." msgstr "" #: c-api/init.rst:275 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"optimization_level` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.optimization_level` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:279 @@ -450,9 +450,9 @@ msgstr "" #: c-api/init.rst:286 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"quiet` should be used instead, see :ref:`Python Initialization Configuration " -"`." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.quiet` should be used instead, see :ref:`Python " +"Initialization Configuration `." msgstr "" #: c-api/init.rst:290 @@ -466,9 +466,9 @@ msgstr "" #: c-api/init.rst:300 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"buffered_stdio` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.buffered_stdio` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:304 @@ -483,9 +483,9 @@ msgstr "" #: c-api/init.rst:313 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"verbose` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.verbose` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:317 @@ -509,8 +509,9 @@ msgstr "" #: c-api/init.rst:347 msgid "" "Initialize the Python interpreter. In an application embedding Python, " -"this should be called before using any other Python/C API functions; see :" -"ref:`Before Python Initialization ` for the few exceptions." +"this should be called before using any other Python/C API functions; " +"see :ref:`Before Python Initialization ` for the few " +"exceptions." msgstr "" #: c-api/init.rst:351 @@ -525,8 +526,8 @@ msgstr "" #: c-api/init.rst:373 msgid "" -"Use the :c:func:`Py_InitializeFromConfig` function to customize the :ref:" -"`Python Initialization Configuration `." +"Use the :c:func:`Py_InitializeFromConfig` function to customize " +"the :ref:`Python Initialization Configuration `." msgstr "" #: c-api/init.rst:363 @@ -552,16 +553,29 @@ msgstr "" #: c-api/init.rst:386 msgid "" "Undo all initializations made by :c:func:`Py_Initialize` and subsequent use " -"of Python/C API functions, and destroy all sub-interpreters (see :c:func:" -"`Py_NewInterpreter` below) that were created and not yet destroyed since the " -"last call to :c:func:`Py_Initialize`. Ideally, this frees all memory " -"allocated by the Python interpreter. This is a no-op when called for a " -"second time (without calling :c:func:`Py_Initialize` again first). Normally " -"the return value is ``0``. If there were errors during finalization " +"of Python/C API functions, and destroy all sub-interpreters " +"(see :c:func:`Py_NewInterpreter` below) that were created and not yet " +"destroyed since the last call to :c:func:`Py_Initialize`. Ideally, this " +"frees all memory allocated by the Python interpreter. This is a no-op when " +"called for a second time (without calling :c:func:`Py_Initialize` again " +"first)." +msgstr "" + +#: c-api/init.rst:393 +msgid "" +"Since this is the reverse of :c:func:`Py_Initialize`, it should be called in " +"the same thread with the same interpreter active. That means the main " +"thread and the main interpreter. This should never be called " +"while :c:func:`Py_RunMain` is running." +msgstr "" + +#: c-api/init.rst:398 +msgid "" +"Normally the return value is ``0``. If there were errors during finalization " "(flushing buffered data), ``-1`` is returned." msgstr "" -#: c-api/init.rst:395 +#: c-api/init.rst:402 msgid "" "This function is provided for a number of reasons. An embedding application " "might want to restart Python without having to restart the application " @@ -572,7 +586,7 @@ msgid "" "Python before exiting from the application." msgstr "" -#: c-api/init.rst:403 +#: c-api/init.rst:410 msgid "" "**Bugs and caveats:** The destruction of modules and objects in modules is " "done in random order; this may cause destructors (:meth:`~object.__del__` " @@ -587,74 +601,75 @@ msgid "" "more than once." msgstr "" -#: c-api/init.rst:414 +#: c-api/init.rst:421 msgid "" -"Raises an :ref:`auditing event ` ``cpython." -"_PySys_ClearAuditHooks`` with no arguments." +"Raises an :ref:`auditing event ` " +"``cpython._PySys_ClearAuditHooks`` with no arguments." msgstr "" -#: c-api/init.rst:420 +#: c-api/init.rst:427 msgid "" "This is a backwards-compatible version of :c:func:`Py_FinalizeEx` that " "disregards the return value." msgstr "" -#: c-api/init.rst:425 +#: c-api/init.rst:432 msgid "Process-wide parameters" msgstr "" -#: c-api/init.rst:435 +#: c-api/init.rst:442 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"stdio_encoding` and :c:member:`PyConfig.stdio_errors` should be used " -"instead, see :ref:`Python Initialization Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.stdio_encoding` " +"and :c:member:`PyConfig.stdio_errors` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" -#: c-api/init.rst:440 +#: c-api/init.rst:447 msgid "" "This function should be called before :c:func:`Py_Initialize`, if it is " "called at all. It specifies which encoding and error handling to use with " "standard IO, with the same meanings as in :func:`str.encode`." msgstr "" -#: c-api/init.rst:444 +#: c-api/init.rst:451 msgid "" "It overrides :envvar:`PYTHONIOENCODING` values, and allows embedding code to " "control IO encoding when the environment variable does not work." msgstr "" -#: c-api/init.rst:447 +#: c-api/init.rst:454 msgid "" "*encoding* and/or *errors* may be ``NULL`` to use :envvar:`PYTHONIOENCODING` " "and/or default values (depending on other settings)." msgstr "" -#: c-api/init.rst:451 +#: c-api/init.rst:458 msgid "" "Note that :data:`sys.stderr` always uses the \"backslashreplace\" error " "handler, regardless of this (or any other) setting." msgstr "" -#: c-api/init.rst:454 +#: c-api/init.rst:461 msgid "" "If :c:func:`Py_FinalizeEx` is called, this function will need to be called " "again in order to affect subsequent calls to :c:func:`Py_Initialize`." msgstr "" -#: c-api/init.rst:457 +#: c-api/init.rst:464 msgid "" "Returns ``0`` if successful, a nonzero value on error (e.g. calling after " "the interpreter has already been initialized)." msgstr "" -#: c-api/init.rst:472 +#: c-api/init.rst:479 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"program_name` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.program_name` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" -#: c-api/init.rst:476 +#: c-api/init.rst:483 msgid "" "This function should be called before :c:func:`Py_Initialize` is called for " "the first time, if it is called at all. It tells the interpreter the value " @@ -668,30 +683,30 @@ msgid "" "this storage." msgstr "" -#: c-api/init.rst:487 +#: c-api/init.rst:760 c-api/init.rst:822 msgid "" -"Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a :c:expr:" -"`wchar_t *` string." +"Use :c:func:`Py_DecodeLocale` to decode a bytes string to get " +"a :c:expr:`wchar_t*` string." msgstr "" -#: c-api/init.rst:497 +#: c-api/init.rst:504 msgid "" "Return the program name set with :c:func:`Py_SetProgramName`, or the " "default. The returned string points into static storage; the caller should " "not modify its value." msgstr "" -#: c-api/init.rst:520 c-api/init.rst:580 c-api/init.rst:827 +#: c-api/init.rst:527 c-api/init.rst:587 c-api/init.rst:834 msgid "" "This function should not be called before :c:func:`Py_Initialize`, otherwise " "it returns ``NULL``." msgstr "" -#: c-api/init.rst:523 c-api/init.rst:583 c-api/init.rst:830 +#: c-api/init.rst:530 c-api/init.rst:590 c-api/init.rst:837 msgid "It now returns ``NULL`` if called before :c:func:`Py_Initialize`." msgstr "" -#: c-api/init.rst:510 +#: c-api/init.rst:517 msgid "" "Return the *prefix* for installed platform-independent files. This is " "derived through a number of complicated rules from the program name set " @@ -705,21 +720,21 @@ msgid "" "also the next function." msgstr "" -#: c-api/init.rst:529 +#: c-api/init.rst:536 msgid "" "Return the *exec-prefix* for installed platform-*dependent* files. This is " "derived through a number of complicated rules from the program name set " "with :c:func:`Py_SetProgramName` and some environment variables; for " "example, if the program name is ``'/usr/local/bin/python'``, the exec-prefix " "is ``'/usr/local'``. The returned string points into static storage; the " -"caller should not modify its value. This corresponds to the :makevar:" -"`exec_prefix` variable in the top-level :file:`Makefile` and the ``--exec-" -"prefix`` argument to the :program:`configure` script at build time. The " -"value is available to Python code as ``sys.exec_prefix``. It is only useful " -"on Unix." +"caller should not modify its value. This corresponds to " +"the :makevar:`exec_prefix` variable in the top-level :file:`Makefile` and " +"the ``--exec-prefix`` argument to the :program:`configure` script at build " +"time. The value is available to Python code as ``sys.exec_prefix``. It is " +"only useful on Unix." msgstr "" -#: c-api/init.rst:539 +#: c-api/init.rst:546 msgid "" "Background: The exec-prefix differs from the prefix when platform dependent " "files (such as executables and shared libraries) are installed in a " @@ -728,7 +743,7 @@ msgid "" "independent may be installed in :file:`/usr/local`." msgstr "" -#: c-api/init.rst:545 +#: c-api/init.rst:552 msgid "" "Generally speaking, a platform is a combination of hardware and software " "families, e.g. Sparc machines running the Solaris 2.x operating system are " @@ -742,15 +757,15 @@ msgid "" "independent from the Python version by which they were compiled!)." msgstr "" -#: c-api/init.rst:556 +#: c-api/init.rst:563 msgid "" -"System administrators will know how to configure the :program:`mount` or :" -"program:`automount` programs to share :file:`/usr/local` between platforms " -"while having :file:`/usr/local/plat` be a different filesystem for each " -"platform." +"System administrators will know how to configure the :program:`mount` " +"or :program:`automount` programs to share :file:`/usr/local` between " +"platforms while having :file:`/usr/local/plat` be a different filesystem for " +"each platform." msgstr "" -#: c-api/init.rst:574 +#: c-api/init.rst:581 msgid "" "Return the full program name of the Python executable; this is computed as " "a side-effect of deriving the default module search path from the program " @@ -759,7 +774,7 @@ msgid "" "available to Python code as ``sys.executable``." msgstr "" -#: c-api/init.rst:594 +#: c-api/init.rst:601 msgid "" "Return the default module search path; this is computed from the program " "name (set by :c:func:`Py_SetProgramName` above) and some environment " @@ -772,71 +787,75 @@ msgid "" "for loading modules." msgstr "" -#: c-api/init.rst:620 +#: c-api/init.rst:627 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"module_search_paths` and :c:member:`PyConfig.module_search_paths_set` should " -"be used instead, see :ref:`Python Initialization Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.module_search_paths` " +"and :c:member:`PyConfig.module_search_paths_set` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" -#: c-api/init.rst:625 +#: c-api/init.rst:632 msgid "" -"Set the default module search path. If this function is called before :c:" -"func:`Py_Initialize`, then :c:func:`Py_GetPath` won't attempt to compute a " -"default search path but uses the one provided instead. This is useful if " -"Python is embedded by an application that has full knowledge of the location " -"of all modules. The path components should be separated by the platform " -"dependent delimiter character, which is ``':'`` on Unix and macOS, ``';'`` " -"on Windows." +"Set the default module search path. If this function is called " +"before :c:func:`Py_Initialize`, then :c:func:`Py_GetPath` won't attempt to " +"compute a default search path but uses the one provided instead. This is " +"useful if Python is embedded by an application that has full knowledge of " +"the location of all modules. The path components should be separated by the " +"platform dependent delimiter character, which is ``':'`` on Unix and macOS, " +"``';'`` on Windows." msgstr "" -#: c-api/init.rst:633 +#: c-api/init.rst:640 msgid "" "This also causes :data:`sys.executable` to be set to the program full path " -"(see :c:func:`Py_GetProgramFullPath`) and for :data:`sys.prefix` and :data:" -"`sys.exec_prefix` to be empty. It is up to the caller to modify these if " -"required after calling :c:func:`Py_Initialize`." +"(see :c:func:`Py_GetProgramFullPath`) and for :data:`sys.prefix` " +"and :data:`sys.exec_prefix` to be empty. It is up to the caller to modify " +"these if required after calling :c:func:`Py_Initialize`." msgstr "" -#: c-api/init.rst:753 c-api/init.rst:815 +#: c-api/init.rst:645 msgid "" -"Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a :c:expr:" -"`wchar_*` string." +"Use :c:func:`Py_DecodeLocale` to decode a bytes string to get " +"a :c:expr:`wchar_*` string." msgstr "" -#: c-api/init.rst:641 +#: c-api/init.rst:648 msgid "" "The path argument is copied internally, so the caller may free it after the " "call completes." msgstr "" -#: c-api/init.rst:644 +#: c-api/init.rst:651 msgid "" "The program full path is now used for :data:`sys.executable`, instead of the " "program name." msgstr "" -#: c-api/init.rst:653 +#: c-api/init.rst:660 msgid "" "Return the version of this Python interpreter. This is a string that looks " "something like ::" msgstr "" -#: c-api/init.rst:660 +#: c-api/init.rst:663 +msgid "\"3.0a5+ (py3k:63103M, May 12 2008, 00:53:55) \\n[GCC 4.2.3]\"" +msgstr "" + +#: c-api/init.rst:667 msgid "" "The first word (up to the first space character) is the current Python " "version; the first characters are the major and minor version separated by a " "period. The returned string points into static storage; the caller should " -"not modify its value. The value is available to Python code as :data:`sys." -"version`." +"not modify its value. The value is available to Python code " +"as :data:`sys.version`." msgstr "" -#: c-api/init.rst:665 +#: c-api/init.rst:672 msgid "See also the :c:var:`Py_Version` constant." msgstr "" -#: c-api/init.rst:672 +#: c-api/init.rst:679 msgid "" "Return the platform identifier for the current platform. On Unix, this is " "formed from the \"official\" name of the operating system, converted to " @@ -847,50 +866,58 @@ msgid "" "available to Python code as ``sys.platform``." msgstr "" -#: c-api/init.rst:683 +#: c-api/init.rst:690 msgid "" "Return the official copyright string for the current Python version, for " "example" msgstr "" -#: c-api/init.rst:685 +#: c-api/init.rst:692 msgid "``'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'``" msgstr "" -#: c-api/init.rst:689 +#: c-api/init.rst:696 msgid "" "The returned string points into static storage; the caller should not modify " "its value. The value is available to Python code as ``sys.copyright``." msgstr "" -#: c-api/init.rst:695 +#: c-api/init.rst:702 msgid "" "Return an indication of the compiler used to build the current Python " "version, in square brackets, for example::" msgstr "" -#: c-api/init.rst:716 +#: c-api/init.rst:705 +msgid "\"[GCC 2.7.2.2]\"" +msgstr "" + +#: c-api/init.rst:723 msgid "" "The returned string points into static storage; the caller should not modify " "its value. The value is available to Python code as part of the variable " "``sys.version``." msgstr "" -#: c-api/init.rst:709 +#: c-api/init.rst:716 msgid "" "Return information about the sequence number and build date and time of the " "current Python interpreter instance, for example ::" msgstr "" -#: c-api/init.rst:728 +#: c-api/init.rst:719 +msgid "\"#67, Aug 1 1997, 22:34:28\"" +msgstr "" + +#: c-api/init.rst:735 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"argv`, :c:member:`PyConfig.parse_argv` and :c:member:`PyConfig.safe_path` " -"should be used instead, see :ref:`Python Initialization Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.argv`, :c:member:`PyConfig.parse_argv` " +"and :c:member:`PyConfig.safe_path` should be used instead, see :ref:`Python " +"Initialization Configuration `." msgstr "" -#: c-api/init.rst:733 +#: c-api/init.rst:740 msgid "" "Set :data:`sys.argv` based on *argc* and *argv*. These parameters are " "similar to those passed to the program's :c:func:`main` function with the " @@ -901,81 +928,85 @@ msgid "" "fatal condition is signalled using :c:func:`Py_FatalError`." msgstr "" -#: c-api/init.rst:741 +#: c-api/init.rst:748 msgid "" "If *updatepath* is zero, this is all the function does. If *updatepath* is " "non-zero, the function also modifies :data:`sys.path` according to the " "following algorithm:" msgstr "" -#: c-api/init.rst:745 +#: c-api/init.rst:752 msgid "" "If the name of an existing script is passed in ``argv[0]``, the absolute " -"path of the directory where the script is located is prepended to :data:`sys." -"path`." +"path of the directory where the script is located is prepended " +"to :data:`sys.path`." msgstr "" -#: c-api/init.rst:748 +#: c-api/init.rst:755 msgid "" "Otherwise (that is, if *argc* is ``0`` or ``argv[0]`` doesn't point to an " "existing file name), an empty string is prepended to :data:`sys.path`, which " "is the same as prepending the current working directory (``\".\"``)." msgstr "" -#: c-api/init.rst:792 +#: c-api/init.rst:799 msgid "" "See also :c:member:`PyConfig.orig_argv` and :c:member:`PyConfig.argv` " "members of the :ref:`Python Initialization Configuration `." msgstr "" -#: c-api/init.rst:760 +#: c-api/init.rst:767 msgid "" "It is recommended that applications embedding the Python interpreter for " "purposes other than executing a single script pass ``0`` as *updatepath*, " -"and update :data:`sys.path` themselves if desired. See `CVE-2008-5983 " -"`_." +"and update :data:`sys.path` themselves if desired. See :cve:`2008-5983`." msgstr "" -#: c-api/init.rst:765 +#: c-api/init.rst:772 msgid "" "On versions before 3.1.3, you can achieve the same effect by manually " -"popping the first :data:`sys.path` element after having called :c:func:" -"`PySys_SetArgv`, for example using::" +"popping the first :data:`sys.path` element after having " +"called :c:func:`PySys_SetArgv`, for example using::" msgstr "" -#: c-api/init.rst:781 +#: c-api/init.rst:776 +msgid "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" +msgstr "" + +#: c-api/init.rst:788 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"argv` and :c:member:`PyConfig.parse_argv` should be used instead, see :ref:" -"`Python Initialization Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.argv` and :c:member:`PyConfig.parse_argv` should " +"be used instead, see :ref:`Python Initialization Configuration `." msgstr "" -#: c-api/init.rst:785 +#: c-api/init.rst:792 msgid "" "This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set to " -"``1`` unless the :program:`python` interpreter was started with the :option:" -"`-I`." +"``1`` unless the :program:`python` interpreter was started with " +"the :option:`-I`." msgstr "" -#: c-api/init.rst:795 +#: c-api/init.rst:802 msgid "The *updatepath* value depends on :option:`-I`." msgstr "" -#: c-api/init.rst:802 +#: c-api/init.rst:809 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"home` should be used instead, see :ref:`Python Initialization Configuration " -"`." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.home` should be used instead, see :ref:`Python " +"Initialization Configuration `." msgstr "" -#: c-api/init.rst:806 +#: c-api/init.rst:813 msgid "" "Set the default \"home\" directory, that is, the location of the standard " "Python libraries. See :envvar:`PYTHONHOME` for the meaning of the argument " "string." msgstr "" -#: c-api/init.rst:810 +#: c-api/init.rst:817 msgid "" "The argument should point to a zero-terminated character string in static " "storage whose contents will not change for the duration of the program's " @@ -983,18 +1014,18 @@ msgid "" "this storage." msgstr "" -#: c-api/init.rst:823 +#: c-api/init.rst:830 msgid "" -"Return the default \"home\", that is, the value set by a previous call to :c:" -"func:`Py_SetPythonHome`, or the value of the :envvar:`PYTHONHOME` " +"Return the default \"home\", that is, the value set by a previous call " +"to :c:func:`Py_SetPythonHome`, or the value of the :envvar:`PYTHONHOME` " "environment variable if it is set." msgstr "" -#: c-api/init.rst:837 +#: c-api/init.rst:844 msgid "Thread State and the Global Interpreter Lock" msgstr "" -#: c-api/init.rst:844 +#: c-api/init.rst:851 msgid "" "The Python interpreter is not fully thread-safe. In order to support multi-" "threaded Python programs, there's a global lock, called the :term:`global " @@ -1006,17 +1037,18 @@ msgid "" "once instead of twice." msgstr "" -#: c-api/init.rst:854 +#: c-api/init.rst:861 msgid "" -"Therefore, the rule exists that only the thread that has acquired the :term:" -"`GIL` may operate on Python objects or call Python/C API functions. In order " -"to emulate concurrency of execution, the interpreter regularly tries to " -"switch threads (see :func:`sys.setswitchinterval`). The lock is also " -"released around potentially blocking I/O operations like reading or writing " -"a file, so that other Python threads can run in the meantime." +"Therefore, the rule exists that only the thread that has acquired " +"the :term:`GIL` may operate on Python objects or call Python/C API " +"functions. In order to emulate concurrency of execution, the interpreter " +"regularly tries to switch threads (see :func:`sys.setswitchinterval`). The " +"lock is also released around potentially blocking I/O operations like " +"reading or writing a file, so that other Python threads can run in the " +"meantime." msgstr "" -#: c-api/init.rst:864 +#: c-api/init.rst:871 msgid "" "The Python interpreter keeps some thread-specific bookkeeping information " "inside a data structure called :c:type:`PyThreadState`. There's also one " @@ -1024,32 +1056,57 @@ msgid "" "retrieved using :c:func:`PyThreadState_Get`." msgstr "" -#: c-api/init.rst:870 +#: c-api/init.rst:877 msgid "Releasing the GIL from extension code" msgstr "" -#: c-api/init.rst:872 +#: c-api/init.rst:879 msgid "" "Most extension code manipulating the :term:`GIL` has the following simple " "structure::" msgstr "" -#: c-api/init.rst:881 +#: c-api/init.rst:882 +msgid "" +"Save the thread state in a local variable.\n" +"Release the global interpreter lock.\n" +"... Do some blocking I/O operation ...\n" +"Reacquire the global interpreter lock.\n" +"Restore the thread state from the local variable." +msgstr "" + +#: c-api/init.rst:888 msgid "This is so common that a pair of macros exists to simplify it::" msgstr "" -#: c-api/init.rst:891 +#: c-api/init.rst:890 +msgid "" +"Py_BEGIN_ALLOW_THREADS\n" +"... Do some blocking I/O operation ...\n" +"Py_END_ALLOW_THREADS" +msgstr "" + +#: c-api/init.rst:898 msgid "" "The :c:macro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a " "hidden local variable; the :c:macro:`Py_END_ALLOW_THREADS` macro closes the " "block." msgstr "" -#: c-api/init.rst:895 +#: c-api/init.rst:902 msgid "The block above expands to the following code::" msgstr "" -#: c-api/init.rst:907 +#: c-api/init.rst:904 +msgid "" +"PyThreadState *_save;\n" +"\n" +"_save = PyEval_SaveThread();\n" +"... Do some blocking I/O operation ...\n" +"PyEval_RestoreThread(_save);" +msgstr "" + +#: c-api/init.rst:914 msgid "" "Here is how these functions work: the global interpreter lock is used to " "protect the pointer to the current thread state. When releasing the lock " @@ -1060,7 +1117,7 @@ msgid "" "state, the lock must be acquired before storing the thread state pointer." msgstr "" -#: c-api/init.rst:916 +#: c-api/init.rst:923 msgid "" "Calling system I/O functions is the most common use case for releasing the " "GIL, but it can also be useful before calling long-running computations " @@ -1070,21 +1127,21 @@ msgid "" "compressing or hashing data." msgstr "" -#: c-api/init.rst:927 +#: c-api/init.rst:934 msgid "Non-Python created threads" msgstr "" -#: c-api/init.rst:929 +#: c-api/init.rst:936 msgid "" -"When threads are created using the dedicated Python APIs (such as the :mod:" -"`threading` module), a thread state is automatically associated to them and " -"the code showed above is therefore correct. However, when threads are " -"created from C (for example by a third-party library with its own thread " +"When threads are created using the dedicated Python APIs (such as " +"the :mod:`threading` module), a thread state is automatically associated to " +"them and the code showed above is therefore correct. However, when threads " +"are created from C (for example by a third-party library with its own thread " "management), they don't hold the GIL, nor is there a thread state structure " "for them." msgstr "" -#: c-api/init.rst:936 +#: c-api/init.rst:943 msgid "" "If you need to call Python code from these threads (often this will be part " "of a callback API provided by the aforementioned third-party library), you " @@ -1095,27 +1152,40 @@ msgid "" "finally free the thread state data structure." msgstr "" -#: c-api/init.rst:944 +#: c-api/init.rst:951 msgid "" "The :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release` functions " "do all of the above automatically. The typical idiom for calling into " "Python from a C thread is::" msgstr "" -#: c-api/init.rst:958 +#: c-api/init.rst:955 +msgid "" +"PyGILState_STATE gstate;\n" +"gstate = PyGILState_Ensure();\n" +"\n" +"/* Perform Python actions here. */\n" +"result = CallSomeFunction();\n" +"/* evaluate result or handle exception */\n" +"\n" +"/* Release the thread. No Python API allowed beyond this point. */\n" +"PyGILState_Release(gstate);" +msgstr "" + +#: c-api/init.rst:965 msgid "" "Note that the ``PyGILState_*`` functions assume there is only one global " "interpreter (created automatically by :c:func:`Py_Initialize`). Python " -"supports the creation of additional interpreters (using :c:func:" -"`Py_NewInterpreter`), but mixing multiple interpreters and the " -"``PyGILState_*`` API is unsupported." +"supports the creation of additional interpreters " +"(using :c:func:`Py_NewInterpreter`), but mixing multiple interpreters and " +"the ``PyGILState_*`` API is unsupported." msgstr "" -#: c-api/init.rst:968 +#: c-api/init.rst:975 msgid "Cautions about fork()" msgstr "" -#: c-api/init.rst:970 +#: c-api/init.rst:977 msgid "" "Another important thing to note about threads is their behaviour in the face " "of the C :c:func:`fork` call. On most systems with :c:func:`fork`, after a " @@ -1124,7 +1194,7 @@ msgid "" "CPython's runtime." msgstr "" -#: c-api/init.rst:976 +#: c-api/init.rst:983 msgid "" "The fact that only the \"current\" thread remains means any locks held by " "other threads will never be released. Python solves this for :func:`os.fork` " @@ -1134,14 +1204,14 @@ msgid "" "of additional (non-Python) locks that need to be acquired before or reset " "after a fork. OS facilities such as :c:func:`!pthread_atfork` would need to " "be used to accomplish the same thing. Additionally, when extending or " -"embedding Python, calling :c:func:`fork` directly rather than through :func:" -"`os.fork` (and returning to or calling into Python) may result in a deadlock " -"by one of Python's internal locks being held by a thread that is defunct " -"after the fork. :c:func:`PyOS_AfterFork_Child` tries to reset the necessary " -"locks, but is not always able to." +"embedding Python, calling :c:func:`fork` directly rather than " +"through :func:`os.fork` (and returning to or calling into Python) may result " +"in a deadlock by one of Python's internal locks being held by a thread that " +"is defunct after the fork. :c:func:`PyOS_AfterFork_Child` tries to reset the " +"necessary locks, but is not always able to." msgstr "" -#: c-api/init.rst:991 +#: c-api/init.rst:998 msgid "" "The fact that all other threads go away also means that CPython's runtime " "state there must be cleaned up properly, which :func:`os.fork` does. This " @@ -1154,17 +1224,17 @@ msgid "" "called immediately after." msgstr "" -#: c-api/init.rst:1004 +#: c-api/init.rst:1011 msgid "High-level API" msgstr "" -#: c-api/init.rst:1006 +#: c-api/init.rst:1013 msgid "" "These are the most commonly used types and functions when writing C " "extension code, or when embedding the Python interpreter:" msgstr "" -#: c-api/init.rst:1011 +#: c-api/init.rst:1018 msgid "" "This data structure represents the state shared by a number of cooperating " "threads. Threads belonging to the same interpreter share their module " @@ -1172,7 +1242,7 @@ msgid "" "in this structure." msgstr "" -#: c-api/init.rst:1016 +#: c-api/init.rst:1023 msgid "" "Threads belonging to different interpreters initially share nothing, except " "process state like available memory, open file descriptors and such. The " @@ -1180,52 +1250,52 @@ msgid "" "which interpreter they belong." msgstr "" -#: c-api/init.rst:1024 +#: c-api/init.rst:1031 msgid "" "This data structure represents the state of a single thread. The only " "public data member is:" msgstr "" -#: c-api/init.rst:1029 +#: c-api/init.rst:1036 msgid "This thread's interpreter state." msgstr "" -#: c-api/init.rst:1040 +#: c-api/init.rst:1047 msgid "Deprecated function which does nothing." msgstr "" -#: c-api/init.rst:1042 +#: c-api/init.rst:1049 msgid "" "In Python 3.6 and older, this function created the GIL if it didn't exist." msgstr "" -#: c-api/init.rst:1044 +#: c-api/init.rst:1051 msgid "The function now does nothing." msgstr "" -#: c-api/init.rst:1047 +#: c-api/init.rst:1054 msgid "" "This function is now called by :c:func:`Py_Initialize()`, so you don't have " "to call it yourself anymore." msgstr "" -#: c-api/init.rst:1051 +#: c-api/init.rst:1058 msgid "" "This function cannot be called before :c:func:`Py_Initialize()` anymore." msgstr "" -#: c-api/init.rst:1061 +#: c-api/init.rst:1068 msgid "" "Returns a non-zero value if :c:func:`PyEval_InitThreads` has been called. " "This function can be called without holding the GIL, and therefore can be " "used to avoid calls to the locking API when running single-threaded." msgstr "" -#: c-api/init.rst:1065 +#: c-api/init.rst:1072 msgid "The :term:`GIL` is now initialized by :c:func:`Py_Initialize()`." msgstr "" -#: c-api/init.rst:1073 +#: c-api/init.rst:1080 msgid "" "Release the global interpreter lock (if it has been created) and reset the " "thread state to ``NULL``, returning the previous thread state (which is not " @@ -1233,7 +1303,7 @@ msgid "" "acquired it." msgstr "" -#: c-api/init.rst:1081 +#: c-api/init.rst:1088 msgid "" "Acquire the global interpreter lock (if it has been created) and set the " "thread state to *tstate*, which must not be ``NULL``. If the lock has been " @@ -1241,7 +1311,7 @@ msgid "" "ensues." msgstr "" -#: c-api/init.rst:1133 c-api/init.rst:1415 +#: c-api/init.rst:1140 c-api/init.rst:1422 msgid "" "Calling this function from a thread when the runtime is finalizing will " "terminate the thread, even if the thread was not created by Python. You can " @@ -1250,70 +1320,70 @@ msgid "" "avoid unwanted termination." msgstr "" -#: c-api/init.rst:1095 +#: c-api/init.rst:1102 msgid "" "Return the current thread state. The global interpreter lock must be held. " "When the current thread state is ``NULL``, this issues a fatal error (so " "that the caller needn't check for ``NULL``)." msgstr "" -#: c-api/init.rst:1102 +#: c-api/init.rst:1109 msgid "" "Swap the current thread state with the thread state given by the argument " "*tstate*, which may be ``NULL``. The global interpreter lock must be held " "and is not released." msgstr "" -#: c-api/init.rst:1107 +#: c-api/init.rst:1114 msgid "" "The following functions use thread-local storage, and are not compatible " "with sub-interpreters:" msgstr "" -#: c-api/init.rst:1112 +#: c-api/init.rst:1119 msgid "" "Ensure that the current thread is ready to call the Python C API regardless " "of the current state of Python, or of the global interpreter lock. This may " "be called as many times as desired by a thread as long as each call is " "matched with a call to :c:func:`PyGILState_Release`. In general, other " -"thread-related APIs may be used between :c:func:`PyGILState_Ensure` and :c:" -"func:`PyGILState_Release` calls as long as the thread state is restored to " -"its previous state before the Release(). For example, normal usage of the :" -"c:macro:`Py_BEGIN_ALLOW_THREADS` and :c:macro:`Py_END_ALLOW_THREADS` macros " -"is acceptable." +"thread-related APIs may be used between :c:func:`PyGILState_Ensure` " +"and :c:func:`PyGILState_Release` calls as long as the thread state is " +"restored to its previous state before the Release(). For example, normal " +"usage of the :c:macro:`Py_BEGIN_ALLOW_THREADS` " +"and :c:macro:`Py_END_ALLOW_THREADS` macros is acceptable." msgstr "" -#: c-api/init.rst:1122 +#: c-api/init.rst:1129 msgid "" -"The return value is an opaque \"handle\" to the thread state when :c:func:" -"`PyGILState_Ensure` was called, and must be passed to :c:func:" -"`PyGILState_Release` to ensure Python is left in the same state. Even though " -"recursive calls are allowed, these handles *cannot* be shared - each unique " -"call to :c:func:`PyGILState_Ensure` must save the handle for its call to :c:" -"func:`PyGILState_Release`." +"The return value is an opaque \"handle\" to the thread state " +"when :c:func:`PyGILState_Ensure` was called, and must be passed " +"to :c:func:`PyGILState_Release` to ensure Python is left in the same state. " +"Even though recursive calls are allowed, these handles *cannot* be shared - " +"each unique call to :c:func:`PyGILState_Ensure` must save the handle for its " +"call to :c:func:`PyGILState_Release`." msgstr "" -#: c-api/init.rst:1129 +#: c-api/init.rst:1136 msgid "" "When the function returns, the current thread will hold the GIL and be able " "to call arbitrary Python code. Failure is a fatal error." msgstr "" -#: c-api/init.rst:1141 +#: c-api/init.rst:1148 msgid "" "Release any resources previously acquired. After this call, Python's state " -"will be the same as it was prior to the corresponding :c:func:" -"`PyGILState_Ensure` call (but generally this state will be unknown to the " -"caller, hence the use of the GILState API)." +"will be the same as it was prior to the " +"corresponding :c:func:`PyGILState_Ensure` call (but generally this state " +"will be unknown to the caller, hence the use of the GILState API)." msgstr "" -#: c-api/init.rst:1146 +#: c-api/init.rst:1153 msgid "" -"Every call to :c:func:`PyGILState_Ensure` must be matched by a call to :c:" -"func:`PyGILState_Release` on the same thread." +"Every call to :c:func:`PyGILState_Ensure` must be matched by a call " +"to :c:func:`PyGILState_Release` on the same thread." msgstr "" -#: c-api/init.rst:1152 +#: c-api/init.rst:1159 msgid "" "Get the current thread state for this thread. May return ``NULL`` if no " "GILState API has been used on the current thread. Note that the main thread " @@ -1321,7 +1391,7 @@ msgid "" "made on the main thread. This is mainly a helper/diagnostic function." msgstr "" -#: c-api/init.rst:1160 +#: c-api/init.rst:1167 msgid "" "Return ``1`` if the current thread is holding the GIL and ``0`` otherwise. " "This function can be called from any thread at any time. Only if it has had " @@ -1332,232 +1402,232 @@ msgid "" "otherwise behave differently." msgstr "" -#: c-api/init.rst:1172 +#: c-api/init.rst:1179 msgid "" "The following macros are normally used without a trailing semicolon; look " "for example usage in the Python source distribution." msgstr "" -#: c-api/init.rst:1178 +#: c-api/init.rst:1185 msgid "" -"This macro expands to ``{ PyThreadState *_save; _save = PyEval_SaveThread();" -"``. Note that it contains an opening brace; it must be matched with a " -"following :c:macro:`Py_END_ALLOW_THREADS` macro. See above for further " -"discussion of this macro." +"This macro expands to ``{ PyThreadState *_save; _save = " +"PyEval_SaveThread();``. Note that it contains an opening brace; it must be " +"matched with a following :c:macro:`Py_END_ALLOW_THREADS` macro. See above " +"for further discussion of this macro." msgstr "" -#: c-api/init.rst:1186 +#: c-api/init.rst:1193 msgid "" "This macro expands to ``PyEval_RestoreThread(_save); }``. Note that it " -"contains a closing brace; it must be matched with an earlier :c:macro:" -"`Py_BEGIN_ALLOW_THREADS` macro. See above for further discussion of this " -"macro." +"contains a closing brace; it must be matched with an " +"earlier :c:macro:`Py_BEGIN_ALLOW_THREADS` macro. See above for further " +"discussion of this macro." msgstr "" -#: c-api/init.rst:1194 +#: c-api/init.rst:1201 msgid "" -"This macro expands to ``PyEval_RestoreThread(_save);``: it is equivalent to :" -"c:macro:`Py_END_ALLOW_THREADS` without the closing brace." +"This macro expands to ``PyEval_RestoreThread(_save);``: it is equivalent " +"to :c:macro:`Py_END_ALLOW_THREADS` without the closing brace." msgstr "" -#: c-api/init.rst:1200 +#: c-api/init.rst:1207 msgid "" -"This macro expands to ``_save = PyEval_SaveThread();``: it is equivalent to :" -"c:macro:`Py_BEGIN_ALLOW_THREADS` without the opening brace and variable " +"This macro expands to ``_save = PyEval_SaveThread();``: it is equivalent " +"to :c:macro:`Py_BEGIN_ALLOW_THREADS` without the opening brace and variable " "declaration." msgstr "" -#: c-api/init.rst:1206 +#: c-api/init.rst:1213 msgid "Low-level API" msgstr "" -#: c-api/init.rst:1208 +#: c-api/init.rst:1215 msgid "" "All of the following functions must be called after :c:func:`Py_Initialize`." msgstr "" -#: c-api/init.rst:1210 +#: c-api/init.rst:1217 msgid ":c:func:`Py_Initialize()` now initializes the :term:`GIL`." msgstr "" -#: c-api/init.rst:1216 +#: c-api/init.rst:1223 msgid "" "Create a new interpreter state object. The global interpreter lock need not " "be held, but may be held if it is necessary to serialize calls to this " "function." msgstr "" -#: c-api/init.rst:1220 +#: c-api/init.rst:1227 msgid "" -"Raises an :ref:`auditing event ` ``cpython." -"PyInterpreterState_New`` with no arguments." +"Raises an :ref:`auditing event ` " +"``cpython.PyInterpreterState_New`` with no arguments." msgstr "" -#: c-api/init.rst:1225 +#: c-api/init.rst:1232 msgid "" "Reset all information in an interpreter state object. The global " "interpreter lock must be held." msgstr "" -#: c-api/init.rst:1228 +#: c-api/init.rst:1235 msgid "" -"Raises an :ref:`auditing event ` ``cpython." -"PyInterpreterState_Clear`` with no arguments." +"Raises an :ref:`auditing event ` " +"``cpython.PyInterpreterState_Clear`` with no arguments." msgstr "" -#: c-api/init.rst:1233 +#: c-api/init.rst:1240 msgid "" "Destroy an interpreter state object. The global interpreter lock need not " "be held. The interpreter state must have been reset with a previous call " "to :c:func:`PyInterpreterState_Clear`." msgstr "" -#: c-api/init.rst:1240 +#: c-api/init.rst:1247 msgid "" "Create a new thread state object belonging to the given interpreter object. " "The global interpreter lock need not be held, but may be held if it is " "necessary to serialize calls to this function." msgstr "" -#: c-api/init.rst:1247 +#: c-api/init.rst:1254 msgid "" "Reset all information in a thread state object. The global interpreter lock " "must be held." msgstr "" -#: c-api/init.rst:1250 +#: c-api/init.rst:1257 msgid "" "This function now calls the :c:member:`PyThreadState.on_delete` callback. " "Previously, that happened in :c:func:`PyThreadState_Delete`." msgstr "" -#: c-api/init.rst:1257 +#: c-api/init.rst:1264 msgid "" "Destroy a thread state object. The global interpreter lock need not be " -"held. The thread state must have been reset with a previous call to :c:func:" -"`PyThreadState_Clear`." +"held. The thread state must have been reset with a previous call " +"to :c:func:`PyThreadState_Clear`." msgstr "" -#: c-api/init.rst:1264 +#: c-api/init.rst:1271 msgid "" "Destroy the current thread state and release the global interpreter lock. " -"Like :c:func:`PyThreadState_Delete`, the global interpreter lock need not be " -"held. The thread state must have been reset with a previous call to :c:func:" -"`PyThreadState_Clear`." +"Like :c:func:`PyThreadState_Delete`, the global interpreter lock must be " +"held. The thread state must have been reset with a previous call " +"to :c:func:`PyThreadState_Clear`." msgstr "" -#: c-api/init.rst:1272 +#: c-api/init.rst:1279 msgid "Get the current frame of the Python thread state *tstate*." msgstr "" -#: c-api/init.rst:1274 +#: c-api/init.rst:1281 msgid "" "Return a :term:`strong reference`. Return ``NULL`` if no frame is currently " "executing." msgstr "" -#: c-api/init.rst:1277 +#: c-api/init.rst:1284 msgid "See also :c:func:`PyEval_GetFrame`." msgstr "" -#: c-api/init.rst:1288 c-api/init.rst:1297 +#: c-api/init.rst:1295 c-api/init.rst:1304 msgid "*tstate* must not be ``NULL``." msgstr "" -#: c-api/init.rst:1286 +#: c-api/init.rst:1293 msgid "" "Get the unique thread state identifier of the Python thread state *tstate*." msgstr "" -#: c-api/init.rst:1295 +#: c-api/init.rst:1302 msgid "Get the interpreter of the Python thread state *tstate*." msgstr "" -#: c-api/init.rst:1304 +#: c-api/init.rst:1311 msgid "Suspend tracing and profiling in the Python thread state *tstate*." msgstr "" -#: c-api/init.rst:1306 +#: c-api/init.rst:1313 msgid "Resume them using the :c:func:`PyThreadState_LeaveTracing` function." msgstr "" -#: c-api/init.rst:1313 +#: c-api/init.rst:1320 msgid "" "Resume tracing and profiling in the Python thread state *tstate* suspended " "by the :c:func:`PyThreadState_EnterTracing` function." msgstr "" -#: c-api/init.rst:1316 +#: c-api/init.rst:1323 msgid "" "See also :c:func:`PyEval_SetTrace` and :c:func:`PyEval_SetProfile` functions." msgstr "" -#: c-api/init.rst:1324 +#: c-api/init.rst:1331 msgid "Get the current interpreter." msgstr "" -#: c-api/init.rst:1326 +#: c-api/init.rst:1333 msgid "" "Issue a fatal error if there no current Python thread state or no current " "interpreter. It cannot return NULL." msgstr "" -#: c-api/init.rst:1339 +#: c-api/init.rst:1346 msgid "The caller must hold the GIL." msgstr "" -#: c-api/init.rst:1336 +#: c-api/init.rst:1343 msgid "" "Return the interpreter's unique ID. If there was any error in doing so then " "``-1`` is returned and an error is set." msgstr "" -#: c-api/init.rst:1346 +#: c-api/init.rst:1353 msgid "" "Return a dictionary in which interpreter-specific data may be stored. If " "this function returns ``NULL`` then no exception has been raised and the " "caller should assume no interpreter-specific dict is available." msgstr "" -#: c-api/init.rst:1350 +#: c-api/init.rst:1357 msgid "" "This is not a replacement for :c:func:`PyModule_GetState()`, which " "extensions should use to store interpreter-specific state information." msgstr "" -#: c-api/init.rst:1357 +#: c-api/init.rst:1364 msgid "Type of a frame evaluation function." msgstr "" -#: c-api/init.rst:1359 +#: c-api/init.rst:1366 msgid "" "The *throwflag* parameter is used by the ``throw()`` method of generators: " "if non-zero, handle the current exception." msgstr "" -#: c-api/init.rst:1362 +#: c-api/init.rst:1369 msgid "The function now takes a *tstate* parameter." msgstr "" -#: c-api/init.rst:1365 +#: c-api/init.rst:1372 msgid "" "The *frame* parameter changed from ``PyFrameObject*`` to " "``_PyInterpreterFrame*``." msgstr "" -#: c-api/init.rst:1370 +#: c-api/init.rst:1377 msgid "Get the frame evaluation function." msgstr "" -#: c-api/init.rst:1380 +#: c-api/init.rst:1387 msgid "See the :pep:`523` \"Adding a frame evaluation API to CPython\"." msgstr "" -#: c-api/init.rst:1378 +#: c-api/init.rst:1385 msgid "Set the frame evaluation function." msgstr "" -#: c-api/init.rst:1387 +#: c-api/init.rst:1394 msgid "" "Return a dictionary in which extensions can store thread-specific state " "information. Each extension should use a unique key to use to store state " @@ -1566,7 +1636,7 @@ msgid "" "raised and the caller should assume no current thread state is available." msgstr "" -#: c-api/init.rst:1396 +#: c-api/init.rst:1403 msgid "" "Asynchronously raise an exception in a thread. The *id* argument is the " "thread id of the target thread; *exc* is the exception object to be raised. " @@ -1578,33 +1648,34 @@ msgid "" "raises no exceptions." msgstr "" -#: c-api/init.rst:1404 +#: c-api/init.rst:1411 msgid "" -"The type of the *id* parameter changed from :c:expr:`long` to :c:expr:" -"`unsigned long`." +"The type of the *id* parameter changed from :c:expr:`long` " +"to :c:expr:`unsigned long`." msgstr "" -#: c-api/init.rst:1410 +#: c-api/init.rst:1417 msgid "" "Acquire the global interpreter lock and set the current thread state to " "*tstate*, which must not be ``NULL``. The lock must have been created " "earlier. If this thread already has the lock, deadlock ensues." msgstr "" -#: c-api/init.rst:1459 +#: c-api/init.rst:1466 msgid "" -"Updated to be consistent with :c:func:`PyEval_RestoreThread`, :c:func:" -"`Py_END_ALLOW_THREADS`, and :c:func:`PyGILState_Ensure`, and terminate the " -"current thread if called while the interpreter is finalizing." +"Updated to be consistent " +"with :c:func:`PyEval_RestoreThread`, :c:func:`Py_END_ALLOW_THREADS`, " +"and :c:func:`PyGILState_Ensure`, and terminate the current thread if called " +"while the interpreter is finalizing." msgstr "" -#: c-api/init.rst:1426 +#: c-api/init.rst:1433 msgid "" ":c:func:`PyEval_RestoreThread` is a higher-level function which is always " "available (even when threads have not been initialized)." msgstr "" -#: c-api/init.rst:1432 +#: c-api/init.rst:1439 msgid "" "Reset the current thread state to ``NULL`` and release the global " "interpreter lock. The lock must have been created earlier and must be held " @@ -1613,25 +1684,25 @@ msgid "" "isn't, a fatal error is reported." msgstr "" -#: c-api/init.rst:1438 +#: c-api/init.rst:1445 msgid "" ":c:func:`PyEval_SaveThread` is a higher-level function which is always " "available (even when threads have not been initialized)." msgstr "" -#: c-api/init.rst:1444 +#: c-api/init.rst:1451 msgid "" "Acquire the global interpreter lock. The lock must have been created " "earlier. If this thread already has the lock, a deadlock ensues." msgstr "" -#: c-api/init.rst:1447 +#: c-api/init.rst:1454 msgid "" -"This function does not update the current thread state. Please use :c:func:" -"`PyEval_RestoreThread` or :c:func:`PyEval_AcquireThread` instead." +"This function does not update the current thread state. Please " +"use :c:func:`PyEval_RestoreThread` or :c:func:`PyEval_AcquireThread` instead." msgstr "" -#: c-api/init.rst:1453 +#: c-api/init.rst:1460 msgid "" "Calling this function from a thread when the runtime is finalizing will " "terminate the thread, even if the thread was not created by Python. You can " @@ -1640,23 +1711,23 @@ msgid "" "avoid unwanted termination." msgstr "" -#: c-api/init.rst:1467 +#: c-api/init.rst:1474 msgid "" "Release the global interpreter lock. The lock must have been created " "earlier." msgstr "" -#: c-api/init.rst:1469 +#: c-api/init.rst:1476 msgid "" -"This function does not update the current thread state. Please use :c:func:" -"`PyEval_SaveThread` or :c:func:`PyEval_ReleaseThread` instead." +"This function does not update the current thread state. Please " +"use :c:func:`PyEval_SaveThread` or :c:func:`PyEval_ReleaseThread` instead." msgstr "" -#: c-api/init.rst:1478 +#: c-api/init.rst:1485 msgid "Sub-interpreter support" msgstr "" -#: c-api/init.rst:1480 +#: c-api/init.rst:1487 msgid "" "While in most uses, you will only embed a single Python interpreter, there " "are cases where you need to create several independent interpreters in the " @@ -1664,7 +1735,7 @@ msgid "" "to do that." msgstr "" -#: c-api/init.rst:1485 +#: c-api/init.rst:1492 msgid "" "The \"main\" interpreter is the first one created when the runtime " "initializes. It is usually the only Python interpreter in a process. Unlike " @@ -1675,134 +1746,134 @@ msgid "" "returns a pointer to its state." msgstr "" -#: c-api/init.rst:1492 +#: c-api/init.rst:1499 msgid "" -"You can switch between sub-interpreters using the :c:func:" -"`PyThreadState_Swap` function. You can create and destroy them using the " -"following functions:" +"You can switch between sub-interpreters using " +"the :c:func:`PyThreadState_Swap` function. You can create and destroy them " +"using the following functions:" msgstr "" -#: c-api/init.rst:1498 +#: c-api/init.rst:1505 msgid "" "Structure containing most parameters to configure a sub-interpreter. Its " "values are used only in :c:func:`Py_NewInterpreterFromConfig` and never " "modified by the runtime." msgstr "" -#: c-api/init.rst:1504 +#: c-api/init.rst:1511 msgid "Structure fields:" msgstr "" -#: c-api/init.rst:1508 +#: c-api/init.rst:1515 msgid "" "If this is ``0`` then the sub-interpreter will use its own \"object\" " "allocator state. Otherwise it will use (share) the main interpreter's." msgstr "" -#: c-api/init.rst:1512 +#: c-api/init.rst:1519 msgid "" -"If this is ``0`` then :c:member:`~PyInterpreterConfig." -"check_multi_interp_extensions` must be ``1`` (non-zero). If this is ``1`` " -"then :c:member:`~PyInterpreterConfig.gil` must not be :c:macro:" -"`PyInterpreterConfig_OWN_GIL`." +"If this is ``0`` " +"then :c:member:`~PyInterpreterConfig.check_multi_interp_extensions` must be " +"``1`` (non-zero). If this is ``1`` then :c:member:`~PyInterpreterConfig.gil` " +"must not be :c:macro:`PyInterpreterConfig_OWN_GIL`." msgstr "" -#: c-api/init.rst:1520 +#: c-api/init.rst:1527 msgid "" "If this is ``0`` then the runtime will not support forking the process in " "any thread where the sub-interpreter is currently active. Otherwise fork is " "unrestricted." msgstr "" -#: c-api/init.rst:1524 +#: c-api/init.rst:1531 msgid "" "Note that the :mod:`subprocess` module still works when fork is disallowed." msgstr "" -#: c-api/init.rst:1529 +#: c-api/init.rst:1536 msgid "" "If this is ``0`` then the runtime will not support replacing the current " "process via exec (e.g. :func:`os.execv`) in any thread where the sub-" "interpreter is currently active. Otherwise exec is unrestricted." msgstr "" -#: c-api/init.rst:1534 +#: c-api/init.rst:1541 msgid "" "Note that the :mod:`subprocess` module still works when exec is disallowed." msgstr "" -#: c-api/init.rst:1539 +#: c-api/init.rst:1546 msgid "" "If this is ``0`` then the sub-interpreter's :mod:`threading` module won't " "create threads. Otherwise threads are allowed." msgstr "" -#: c-api/init.rst:1545 +#: c-api/init.rst:1552 msgid "" "If this is ``0`` then the sub-interpreter's :mod:`threading` module won't " -"create daemon threads. Otherwise daemon threads are allowed (as long as :c:" -"member:`~PyInterpreterConfig.allow_threads` is non-zero)." +"create daemon threads. Otherwise daemon threads are allowed (as long " +"as :c:member:`~PyInterpreterConfig.allow_threads` is non-zero)." msgstr "" -#: c-api/init.rst:1552 +#: c-api/init.rst:1559 msgid "" "If this is ``0`` then all extension modules may be imported, including " "legacy (single-phase init) modules, in any thread where the sub-interpreter " -"is currently active. Otherwise only multi-phase init extension modules (see :" -"pep:`489`) may be imported. (Also see :c:macro:" -"`Py_mod_multiple_interpreters`.)" +"is currently active. Otherwise only multi-phase init extension modules " +"(see :pep:`489`) may be imported. (Also " +"see :c:macro:`Py_mod_multiple_interpreters`.)" msgstr "" -#: c-api/init.rst:1559 +#: c-api/init.rst:1566 msgid "" -"This must be ``1`` (non-zero) if :c:member:`~PyInterpreterConfig." -"use_main_obmalloc` is ``0``." +"This must be ``1`` (non-zero) " +"if :c:member:`~PyInterpreterConfig.use_main_obmalloc` is ``0``." msgstr "" -#: c-api/init.rst:1564 +#: c-api/init.rst:1571 msgid "" "This determines the operation of the GIL for the sub-interpreter. It may be " "one of the following:" msgstr "" -#: c-api/init.rst:1571 +#: c-api/init.rst:1578 msgid "Use the default selection (:c:macro:`PyInterpreterConfig_SHARED_GIL`)." msgstr "" -#: c-api/init.rst:1575 +#: c-api/init.rst:1582 msgid "Use (share) the main interpreter's GIL." msgstr "" -#: c-api/init.rst:1579 +#: c-api/init.rst:1586 msgid "Use the sub-interpreter's own GIL." msgstr "" -#: c-api/init.rst:1581 +#: c-api/init.rst:1588 msgid "" -"If this is :c:macro:`PyInterpreterConfig_OWN_GIL` then :c:member:" -"`PyInterpreterConfig.use_main_obmalloc` must be ``0``." +"If this is :c:macro:`PyInterpreterConfig_OWN_GIL` " +"then :c:member:`PyInterpreterConfig.use_main_obmalloc` must be ``0``." msgstr "" -#: c-api/init.rst:1595 +#: c-api/init.rst:1602 msgid "" "Create a new sub-interpreter. This is an (almost) totally separate " "environment for the execution of Python code. In particular, the new " "interpreter has separate, independent versions of all imported modules, " -"including the fundamental modules :mod:`builtins`, :mod:`__main__` and :mod:" -"`sys`. The table of loaded modules (``sys.modules``) and the module search " -"path (``sys.path``) are also separate. The new environment has no ``sys." -"argv`` variable. It has new standard I/O stream file objects ``sys.stdin``, " -"``sys.stdout`` and ``sys.stderr`` (however these refer to the same " -"underlying file descriptors)." +"including the fundamental modules :mod:`builtins`, :mod:`__main__` " +"and :mod:`sys`. The table of loaded modules (``sys.modules``) and the " +"module search path (``sys.path``) are also separate. The new environment " +"has no ``sys.argv`` variable. It has new standard I/O stream file objects " +"``sys.stdin``, ``sys.stdout`` and ``sys.stderr`` (however these refer to the " +"same underlying file descriptors)." msgstr "" -#: c-api/init.rst:1605 +#: c-api/init.rst:1612 msgid "" "The given *config* controls the options with which the interpreter is " "initialized." msgstr "" -#: c-api/init.rst:1608 +#: c-api/init.rst:1615 msgid "" "Upon success, *tstate_p* will be set to the first thread state created in " "the new sub-interpreter. This thread state is made in the current thread " @@ -1813,7 +1884,7 @@ msgid "" "state." msgstr "" -#: c-api/init.rst:1617 +#: c-api/init.rst:1624 msgid "" "Like all other Python/C API functions, the global interpreter lock must be " "held before calling this function and is still held when it returns. " @@ -1825,64 +1896,83 @@ msgid "" "released here." msgstr "" -#: c-api/init.rst:1628 +#: c-api/init.rst:1635 msgid "" "Sub-interpreters are most effective when isolated from each other, with " "certain functionality restricted::" msgstr "" -#: c-api/init.rst:1642 +#: c-api/init.rst:1638 +msgid "" +"PyInterpreterConfig config = {\n" +" .use_main_obmalloc = 0,\n" +" .allow_fork = 0,\n" +" .allow_exec = 0,\n" +" .allow_threads = 1,\n" +" .allow_daemon_threads = 0,\n" +" .check_multi_interp_extensions = 1,\n" +" .gil = PyInterpreterConfig_OWN_GIL,\n" +"};\n" +"PyThreadState *tstate = NULL;\n" +"PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);\n" +"if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +"}" +msgstr "" + +#: c-api/init.rst:1653 msgid "" "Note that the config is used only briefly and does not get modified. During " -"initialization the config's values are converted into various :c:type:" -"`PyInterpreterState` values. A read-only copy of the config may be stored " -"internally on the :c:type:`PyInterpreterState`." +"initialization the config's values are converted into " +"various :c:type:`PyInterpreterState` values. A read-only copy of the config " +"may be stored internally on the :c:type:`PyInterpreterState`." msgstr "" -#: c-api/init.rst:1651 +#: c-api/init.rst:1662 msgid "Extension modules are shared between (sub-)interpreters as follows:" msgstr "" -#: c-api/init.rst:1653 +#: c-api/init.rst:1664 msgid "" -"For modules using multi-phase initialization, e.g. :c:func:" -"`PyModule_FromDefAndSpec`, a separate module object is created and " -"initialized for each interpreter. Only C-level static and global variables " -"are shared between these module objects." +"For modules using multi-phase initialization, " +"e.g. :c:func:`PyModule_FromDefAndSpec`, a separate module object is created " +"and initialized for each interpreter. Only C-level static and global " +"variables are shared between these module objects." msgstr "" -#: c-api/init.rst:1659 +#: c-api/init.rst:1670 msgid "" -"For modules using single-phase initialization, e.g. :c:func:" -"`PyModule_Create`, the first time a particular extension is imported, it is " -"initialized normally, and a (shallow) copy of its module's dictionary is " -"squirreled away. When the same extension is imported by another " -"(sub-)interpreter, a new module is initialized and filled with the contents " -"of this copy; the extension's ``init`` function is not called. Objects in " -"the module's dictionary thus end up shared across (sub-)interpreters, which " -"might cause unwanted behavior (see `Bugs and caveats`_ below)." +"For modules using single-phase initialization, " +"e.g. :c:func:`PyModule_Create`, the first time a particular extension is " +"imported, it is initialized normally, and a (shallow) copy of its module's " +"dictionary is squirreled away. When the same extension is imported by " +"another (sub-)interpreter, a new module is initialized and filled with the " +"contents of this copy; the extension's ``init`` function is not called. " +"Objects in the module's dictionary thus end up shared across " +"(sub-)interpreters, which might cause unwanted behavior (see `Bugs and " +"caveats`_ below)." msgstr "" -#: c-api/init.rst:1670 +#: c-api/init.rst:1681 msgid "" "Note that this is different from what happens when an extension is imported " -"after the interpreter has been completely re-initialized by calling :c:func:" -"`Py_FinalizeEx` and :c:func:`Py_Initialize`; in that case, the extension's " -"``initmodule`` function *is* called again. As with multi-phase " -"initialization, this means that only C-level static and global variables are " -"shared between these modules." +"after the interpreter has been completely re-initialized by " +"calling :c:func:`Py_FinalizeEx` and :c:func:`Py_Initialize`; in that case, " +"the extension's ``initmodule`` function *is* called again. As with multi-" +"phase initialization, this means that only C-level static and global " +"variables are shared between these modules." msgstr "" -#: c-api/init.rst:1690 +#: c-api/init.rst:1701 msgid "" -"Create a new sub-interpreter. This is essentially just a wrapper around :c:" -"func:`Py_NewInterpreterFromConfig` with a config that preserves the existing " -"behavior. The result is an unisolated sub-interpreter that shares the main " -"interpreter's GIL, allows fork/exec, allows daemon threads, and allows " -"single-phase init modules." +"Create a new sub-interpreter. This is essentially just a wrapper " +"around :c:func:`Py_NewInterpreterFromConfig` with a config that preserves " +"the existing behavior. The result is an unisolated sub-interpreter that " +"shares the main interpreter's GIL, allows fork/exec, allows daemon threads, " +"and allows single-phase init modules." msgstr "" -#: c-api/init.rst:1702 +#: c-api/init.rst:1713 msgid "" "Destroy the (sub-)interpreter represented by the given thread state. The " "given thread state must be the current thread state. See the discussion of " @@ -1892,17 +1982,17 @@ msgid "" "be held before calling this function. No GIL is held when it returns." msgstr "" -#: c-api/init.rst:1710 +#: c-api/init.rst:1721 msgid "" ":c:func:`Py_FinalizeEx` will destroy all sub-interpreters that haven't been " "explicitly destroyed at that point." msgstr "" -#: c-api/init.rst:1715 +#: c-api/init.rst:1726 msgid "A Per-Interpreter GIL" msgstr "" -#: c-api/init.rst:1717 +#: c-api/init.rst:1728 msgid "" "Using :c:func:`Py_NewInterpreterFromConfig` you can create a sub-interpreter " "that is completely isolated from other interpreters, including having its " @@ -1914,7 +2004,7 @@ msgid "" "just using threads. (See :pep:`554`.)" msgstr "" -#: c-api/init.rst:1727 +#: c-api/init.rst:1738 msgid "" "Using an isolated interpreter requires vigilance in preserving that " "isolation. That especially means not sharing any objects or mutable state " @@ -1928,7 +2018,7 @@ msgid "" "builtin objects." msgstr "" -#: c-api/init.rst:1738 +#: c-api/init.rst:1749 msgid "" "If you preserve isolation then you will have access to proper multi-core " "computing without the complications that come with free-threading. Failure " @@ -1936,7 +2026,7 @@ msgid "" "threading, including races and hard-to-debug crashes." msgstr "" -#: c-api/init.rst:1743 +#: c-api/init.rst:1754 msgid "" "Aside from that, one of the main challenges of using multiple isolated " "interpreters is how to communicate between them safely (not break isolation) " @@ -1946,11 +2036,11 @@ msgid "" "sharing) data between interpreters." msgstr "" -#: c-api/init.rst:1754 +#: c-api/init.rst:1765 msgid "Bugs and caveats" msgstr "" -#: c-api/init.rst:1756 +#: c-api/init.rst:1767 msgid "" "Because sub-interpreters (and the main interpreter) are part of the same " "process, the insulation between them isn't perfect --- for example, using " @@ -1963,7 +2053,7 @@ msgid "" "should be avoided if possible." msgstr "" -#: c-api/init.rst:1766 +#: c-api/init.rst:1777 msgid "" "Special care should be taken to avoid sharing user-defined functions, " "methods, instances or classes between sub-interpreters, since import " @@ -1972,37 +2062,37 @@ msgid "" "objects from which the above are reachable." msgstr "" -#: c-api/init.rst:1772 +#: c-api/init.rst:1783 msgid "" "Also note that combining this functionality with ``PyGILState_*`` APIs is " "delicate, because these APIs assume a bijection between Python thread states " "and OS-level threads, an assumption broken by the presence of sub-" "interpreters. It is highly recommended that you don't switch sub-" -"interpreters between a pair of matching :c:func:`PyGILState_Ensure` and :c:" -"func:`PyGILState_Release` calls. Furthermore, extensions (such as :mod:" -"`ctypes`) using these APIs to allow calling of Python code from non-Python " -"created threads will probably be broken when using sub-interpreters." +"interpreters between a pair of matching :c:func:`PyGILState_Ensure` " +"and :c:func:`PyGILState_Release` calls. Furthermore, extensions (such " +"as :mod:`ctypes`) using these APIs to allow calling of Python code from non-" +"Python created threads will probably be broken when using sub-interpreters." msgstr "" -#: c-api/init.rst:1783 +#: c-api/init.rst:1794 msgid "Asynchronous Notifications" msgstr "" -#: c-api/init.rst:1785 +#: c-api/init.rst:1796 msgid "" "A mechanism is provided to make asynchronous notifications to the main " "interpreter thread. These notifications take the form of a function pointer " "and a void pointer argument." msgstr "" -#: c-api/init.rst:1792 +#: c-api/init.rst:1803 msgid "" "Schedule a function to be called from the main interpreter thread. On " "success, ``0`` is returned and *func* is queued for being called in the main " "thread. On failure, ``-1`` is returned without setting any exception." msgstr "" -#: c-api/init.rst:1796 +#: c-api/init.rst:1807 msgid "" "When successfully queued, *func* will be *eventually* called from the main " "interpreter thread with the argument *arg*. It will be called " @@ -2010,17 +2100,17 @@ msgid "" "these conditions met:" msgstr "" -#: c-api/init.rst:1801 +#: c-api/init.rst:1812 msgid "on a :term:`bytecode` boundary;" msgstr "" -#: c-api/init.rst:1802 +#: c-api/init.rst:1813 msgid "" "with the main thread holding the :term:`global interpreter lock` (*func* can " "therefore use the full C API)." msgstr "" -#: c-api/init.rst:1805 +#: c-api/init.rst:1816 msgid "" "*func* must return ``0`` on success, or ``-1`` on failure with an exception " "set. *func* won't be interrupted to perform another asynchronous " @@ -2028,30 +2118,30 @@ msgid "" "if the global interpreter lock is released." msgstr "" -#: c-api/init.rst:1810 +#: c-api/init.rst:1821 msgid "" "This function doesn't need a current thread state to run, and it doesn't " "need the global interpreter lock." msgstr "" -#: c-api/init.rst:1813 +#: c-api/init.rst:1824 msgid "" "To call this function in a subinterpreter, the caller must hold the GIL. " "Otherwise, the function *func* can be scheduled to be called from the wrong " "interpreter." msgstr "" -#: c-api/init.rst:1818 +#: c-api/init.rst:1829 msgid "" "This is a low-level function, only useful for very special cases. There is " "no guarantee that *func* will be called as quick as possible. If the main " "thread is busy executing a system call, *func* won't be called before the " "system call returns. This function is generally **not** suitable for " -"calling Python code from arbitrary C threads. Instead, use the :ref:" -"`PyGILState API`." +"calling Python code from arbitrary C threads. Instead, use " +"the :ref:`PyGILState API`." msgstr "" -#: c-api/init.rst:1827 +#: c-api/init.rst:1838 msgid "" "If this function is called in a subinterpreter, the function *func* is now " "scheduled to be called from the subinterpreter, rather than being called " @@ -2059,18 +2149,18 @@ msgid "" "scheduled calls." msgstr "" -#: c-api/init.rst:1836 +#: c-api/init.rst:1847 msgid "Profiling and Tracing" msgstr "" -#: c-api/init.rst:1841 +#: c-api/init.rst:1852 msgid "" "The Python interpreter provides some low-level support for attaching " "profiling and execution tracing facilities. These are used for profiling, " "debugging, and coverage analysis tools." msgstr "" -#: c-api/init.rst:1845 +#: c-api/init.rst:1856 msgid "" "This C interface allows the profiling or tracing code to avoid the overhead " "of calling through Python-level callable objects, making a direct C function " @@ -2080,76 +2170,74 @@ msgid "" "reported to the Python-level trace functions in previous versions." msgstr "" -#: c-api/init.rst:1855 +#: c-api/init.rst:1866 msgid "" "The type of the trace function registered using :c:func:`PyEval_SetProfile` " "and :c:func:`PyEval_SetTrace`. The first parameter is the object passed to " "the registration function as *obj*, *frame* is the frame object to which the " -"event pertains, *what* is one of the constants :c:data:`PyTrace_CALL`, :c:" -"data:`PyTrace_EXCEPTION`, :c:data:`PyTrace_LINE`, :c:data:`PyTrace_RETURN`, :" -"c:data:`PyTrace_C_CALL`, :c:data:`PyTrace_C_EXCEPTION`, :c:data:" -"`PyTrace_C_RETURN`, or :c:data:`PyTrace_OPCODE`, and *arg* depends on the " -"value of *what*:" +"event pertains, *what* is one of the " +"constants :c:data:`PyTrace_CALL`, :c:data:`PyTrace_EXCEPTION`, :c:data:`PyTrace_LINE`, :c:data:`PyTrace_RETURN`, :c:data:`PyTrace_C_CALL`, :c:data:`PyTrace_C_EXCEPTION`, :c:data:`PyTrace_C_RETURN`, " +"or :c:data:`PyTrace_OPCODE`, and *arg* depends on the value of *what*:" msgstr "" -#: c-api/init.rst:1864 +#: c-api/init.rst:1875 msgid "Value of *what*" msgstr "" -#: c-api/init.rst:1864 +#: c-api/init.rst:1875 msgid "Meaning of *arg*" msgstr "" -#: c-api/init.rst:1866 +#: c-api/init.rst:1877 msgid ":c:data:`PyTrace_CALL`" msgstr "" -#: c-api/init.rst:1871 c-api/init.rst:1882 +#: c-api/init.rst:1882 c-api/init.rst:1893 msgid "Always :c:data:`Py_None`." msgstr "" -#: c-api/init.rst:1868 +#: c-api/init.rst:1879 msgid ":c:data:`PyTrace_EXCEPTION`" msgstr "" -#: c-api/init.rst:1868 +#: c-api/init.rst:1879 msgid "Exception information as returned by :func:`sys.exc_info`." msgstr "" -#: c-api/init.rst:1871 +#: c-api/init.rst:1882 msgid ":c:data:`PyTrace_LINE`" msgstr "" -#: c-api/init.rst:1873 +#: c-api/init.rst:1884 msgid ":c:data:`PyTrace_RETURN`" msgstr "" -#: c-api/init.rst:1873 +#: c-api/init.rst:1884 msgid "" "Value being returned to the caller, or ``NULL`` if caused by an exception." msgstr "" -#: c-api/init.rst:1876 +#: c-api/init.rst:1887 msgid ":c:data:`PyTrace_C_CALL`" msgstr "" -#: c-api/init.rst:1878 c-api/init.rst:1880 +#: c-api/init.rst:1889 c-api/init.rst:1891 msgid "Function object being called." msgstr "" -#: c-api/init.rst:1878 +#: c-api/init.rst:1889 msgid ":c:data:`PyTrace_C_EXCEPTION`" msgstr "" -#: c-api/init.rst:1880 +#: c-api/init.rst:1891 msgid ":c:data:`PyTrace_C_RETURN`" msgstr "" -#: c-api/init.rst:1882 +#: c-api/init.rst:1893 msgid ":c:data:`PyTrace_OPCODE`" msgstr "" -#: c-api/init.rst:1887 +#: c-api/init.rst:1898 msgid "" "The value of the *what* parameter to a :c:type:`Py_tracefunc` function when " "a new call to a function or method is being reported, or a new entry into a " @@ -2158,7 +2246,7 @@ msgid "" "the corresponding frame." msgstr "" -#: c-api/init.rst:1896 +#: c-api/init.rst:1907 msgid "" "The value of the *what* parameter to a :c:type:`Py_tracefunc` function when " "an exception has been raised. The callback function is called with this " @@ -2170,147 +2258,148 @@ msgid "" "profiler." msgstr "" -#: c-api/init.rst:1907 +#: c-api/init.rst:1918 msgid "" "The value passed as the *what* parameter to a :c:type:`Py_tracefunc` " "function (but not a profiling function) when a line-number event is being " -"reported. It may be disabled for a frame by setting :attr:`~frame." -"f_trace_lines` to *0* on that frame." +"reported. It may be disabled for a frame by " +"setting :attr:`~frame.f_trace_lines` to *0* on that frame." msgstr "" -#: c-api/init.rst:1915 +#: c-api/init.rst:1926 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a call is about to return." msgstr "" -#: c-api/init.rst:1921 +#: c-api/init.rst:1932 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function is about to be called." msgstr "" -#: c-api/init.rst:1927 +#: c-api/init.rst:1938 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function has raised an exception." msgstr "" -#: c-api/init.rst:1933 +#: c-api/init.rst:1944 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions when " "a C function has returned." msgstr "" -#: c-api/init.rst:1939 +#: c-api/init.rst:1950 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions (but " "not profiling functions) when a new opcode is about to be executed. This " -"event is not emitted by default: it must be explicitly requested by setting :" -"attr:`~frame.f_trace_opcodes` to *1* on the frame." +"event is not emitted by default: it must be explicitly requested by " +"setting :attr:`~frame.f_trace_opcodes` to *1* on the frame." msgstr "" -#: c-api/init.rst:1947 +#: c-api/init.rst:1958 msgid "" "Set the profiler function to *func*. The *obj* parameter is passed to the " "function as its first parameter, and may be any Python object, or ``NULL``. " "If the profile function needs to maintain state, using a different value for " "*obj* for each thread provides a convenient and thread-safe place to store " -"it. The profile function is called for all monitored events except :c:data:" -"`PyTrace_LINE` :c:data:`PyTrace_OPCODE` and :c:data:`PyTrace_EXCEPTION`." +"it. The profile function is called for all monitored events " +"except :c:data:`PyTrace_LINE` :c:data:`PyTrace_OPCODE` " +"and :c:data:`PyTrace_EXCEPTION`." msgstr "" -#: c-api/init.rst:1954 +#: c-api/init.rst:1965 msgid "See also the :func:`sys.setprofile` function." msgstr "" -#: c-api/init.rst:1963 c-api/init.rst:1989 +#: c-api/init.rst:1974 c-api/init.rst:2000 msgid "The caller must hold the :term:`GIL`." msgstr "" -#: c-api/init.rst:1960 +#: c-api/init.rst:1971 msgid "" "Like :c:func:`PyEval_SetProfile` but sets the profile function in all " "running threads belonging to the current interpreter instead of the setting " "it only on the current thread." msgstr "" -#: c-api/init.rst:1965 +#: c-api/init.rst:1976 msgid "" "As :c:func:`PyEval_SetProfile`, this function ignores any exceptions raised " "while setting the profile functions in all threads." msgstr "" -#: c-api/init.rst:1973 +#: c-api/init.rst:1984 msgid "" -"Set the tracing function to *func*. This is similar to :c:func:" -"`PyEval_SetProfile`, except the tracing function does receive line-number " -"events and per-opcode events, but does not receive any event related to C " -"function objects being called. Any trace function registered using :c:func:" -"`PyEval_SetTrace` will not receive :c:data:`PyTrace_C_CALL`, :c:data:" -"`PyTrace_C_EXCEPTION` or :c:data:`PyTrace_C_RETURN` as a value for the " -"*what* parameter." +"Set the tracing function to *func*. This is similar " +"to :c:func:`PyEval_SetProfile`, except the tracing function does receive " +"line-number events and per-opcode events, but does not receive any event " +"related to C function objects being called. Any trace function registered " +"using :c:func:`PyEval_SetTrace` will not " +"receive :c:data:`PyTrace_C_CALL`, :c:data:`PyTrace_C_EXCEPTION` " +"or :c:data:`PyTrace_C_RETURN` as a value for the *what* parameter." msgstr "" -#: c-api/init.rst:1980 +#: c-api/init.rst:1991 msgid "See also the :func:`sys.settrace` function." msgstr "" -#: c-api/init.rst:1986 +#: c-api/init.rst:1997 msgid "" "Like :c:func:`PyEval_SetTrace` but sets the tracing function in all running " "threads belonging to the current interpreter instead of the setting it only " "on the current thread." msgstr "" -#: c-api/init.rst:1991 +#: c-api/init.rst:2002 msgid "" "As :c:func:`PyEval_SetTrace`, this function ignores any exceptions raised " "while setting the trace functions in all threads." msgstr "" -#: c-api/init.rst:2000 +#: c-api/init.rst:2011 msgid "Advanced Debugger Support" msgstr "" -#: c-api/init.rst:2005 +#: c-api/init.rst:2016 msgid "" "These functions are only intended to be used by advanced debugging tools." msgstr "" -#: c-api/init.rst:2010 +#: c-api/init.rst:2021 msgid "" "Return the interpreter state object at the head of the list of all such " "objects." msgstr "" -#: c-api/init.rst:2015 +#: c-api/init.rst:2026 msgid "Return the main interpreter state object." msgstr "" -#: c-api/init.rst:2020 +#: c-api/init.rst:2031 msgid "" "Return the next interpreter state object after *interp* from the list of all " "such objects." msgstr "" -#: c-api/init.rst:2026 +#: c-api/init.rst:2037 msgid "" "Return the pointer to the first :c:type:`PyThreadState` object in the list " "of threads associated with the interpreter *interp*." msgstr "" -#: c-api/init.rst:2032 +#: c-api/init.rst:2043 msgid "" "Return the next thread state object after *tstate* from the list of all such " "objects belonging to the same :c:type:`PyInterpreterState` object." msgstr "" -#: c-api/init.rst:2039 +#: c-api/init.rst:2050 msgid "Thread Local Storage Support" msgstr "" -#: c-api/init.rst:2043 +#: c-api/init.rst:2054 msgid "" "The Python interpreter provides low-level support for thread-local storage " "(TLS) which wraps the underlying native TLS implementation to support the " @@ -2320,42 +2409,42 @@ msgid "" "thread." msgstr "" -#: c-api/init.rst:2050 +#: c-api/init.rst:2061 msgid "" "The GIL does *not* need to be held when calling these functions; they supply " "their own locking." msgstr "" -#: c-api/init.rst:2053 +#: c-api/init.rst:2064 msgid "" "Note that :file:`Python.h` does not include the declaration of the TLS APIs, " "you need to include :file:`pythread.h` to use thread-local storage." msgstr "" -#: c-api/init.rst:2057 +#: c-api/init.rst:2068 msgid "" -"None of these API functions handle memory management on behalf of the :c:" -"expr:`void*` values. You need to allocate and deallocate them yourself. If " -"the :c:expr:`void*` values happen to be :c:expr:`PyObject*`, these functions " -"don't do refcount operations on them either." +"None of these API functions handle memory management on behalf of " +"the :c:expr:`void*` values. You need to allocate and deallocate them " +"yourself. If the :c:expr:`void*` values happen to be :c:expr:`PyObject*`, " +"these functions don't do refcount operations on them either." msgstr "" -#: c-api/init.rst:2065 +#: c-api/init.rst:2076 msgid "Thread Specific Storage (TSS) API" msgstr "" -#: c-api/init.rst:2067 +#: c-api/init.rst:2078 msgid "" "TSS API is introduced to supersede the use of the existing TLS API within " "the CPython interpreter. This API uses a new type :c:type:`Py_tss_t` " "instead of :c:expr:`int` to represent thread keys." msgstr "" -#: c-api/init.rst:2073 +#: c-api/init.rst:2084 msgid "\"A New C-API for Thread-Local Storage in CPython\" (:pep:`539`)" msgstr "" -#: c-api/init.rst:2078 +#: c-api/init.rst:2089 msgid "" "This data structure represents the state of a thread key, the definition of " "which may depend on the underlying TLS implementation, and it has an " @@ -2363,66 +2452,67 @@ msgid "" "public members in this structure." msgstr "" -#: c-api/init.rst:2083 +#: c-api/init.rst:2094 msgid "" "When :ref:`Py_LIMITED_API ` is not defined, static allocation of " "this type by :c:macro:`Py_tss_NEEDS_INIT` is allowed." msgstr "" -#: c-api/init.rst:2089 +#: c-api/init.rst:2100 msgid "" "This macro expands to the initializer for :c:type:`Py_tss_t` variables. Note " "that this macro won't be defined with :ref:`Py_LIMITED_API `." msgstr "" -#: c-api/init.rst:2094 +#: c-api/init.rst:2105 msgid "Dynamic Allocation" msgstr "" -#: c-api/init.rst:2096 +#: c-api/init.rst:2107 msgid "" "Dynamic allocation of the :c:type:`Py_tss_t`, required in extension modules " "built with :ref:`Py_LIMITED_API `, where static allocation of this " "type is not possible due to its implementation being opaque at build time." msgstr "" -#: c-api/init.rst:2103 +#: c-api/init.rst:2114 msgid "" -"Return a value which is the same state as a value initialized with :c:macro:" -"`Py_tss_NEEDS_INIT`, or ``NULL`` in the case of dynamic allocation failure." +"Return a value which is the same state as a value initialized " +"with :c:macro:`Py_tss_NEEDS_INIT`, or ``NULL`` in the case of dynamic " +"allocation failure." msgstr "" -#: c-api/init.rst:2110 +#: c-api/init.rst:2121 msgid "" "Free the given *key* allocated by :c:func:`PyThread_tss_alloc`, after first " "calling :c:func:`PyThread_tss_delete` to ensure any associated thread locals " "have been unassigned. This is a no-op if the *key* argument is ``NULL``." msgstr "" -#: c-api/init.rst:2116 +#: c-api/init.rst:2127 msgid "" "A freed key becomes a dangling pointer. You should reset the key to ``NULL``." msgstr "" -#: c-api/init.rst:2121 +#: c-api/init.rst:2132 msgid "Methods" msgstr "" -#: c-api/init.rst:2123 +#: c-api/init.rst:2134 msgid "" "The parameter *key* of these functions must not be ``NULL``. Moreover, the " "behaviors of :c:func:`PyThread_tss_set` and :c:func:`PyThread_tss_get` are " -"undefined if the given :c:type:`Py_tss_t` has not been initialized by :c:" -"func:`PyThread_tss_create`." +"undefined if the given :c:type:`Py_tss_t` has not been initialized " +"by :c:func:`PyThread_tss_create`." msgstr "" -#: c-api/init.rst:2131 +#: c-api/init.rst:2142 msgid "" "Return a non-zero value if the given :c:type:`Py_tss_t` has been initialized " "by :c:func:`PyThread_tss_create`." msgstr "" -#: c-api/init.rst:2137 +#: c-api/init.rst:2148 msgid "" "Return a zero value on successful initialization of a TSS key. The behavior " "is undefined if the value pointed to by the *key* argument is not " @@ -2431,40 +2521,40 @@ msgid "" "no-op and immediately returns success." msgstr "" -#: c-api/init.rst:2146 +#: c-api/init.rst:2157 msgid "" "Destroy a TSS key to forget the values associated with the key across all " "threads, and change the key's initialization state to uninitialized. A " -"destroyed key is able to be initialized again by :c:func:" -"`PyThread_tss_create`. This function can be called repeatedly on the same " -"key -- calling it on an already destroyed key is a no-op." +"destroyed key is able to be initialized again " +"by :c:func:`PyThread_tss_create`. This function can be called repeatedly on " +"the same key -- calling it on an already destroyed key is a no-op." msgstr "" -#: c-api/init.rst:2155 +#: c-api/init.rst:2166 msgid "" "Return a zero value to indicate successfully associating a :c:expr:`void*` " "value with a TSS key in the current thread. Each thread has a distinct " "mapping of the key to a :c:expr:`void*` value." msgstr "" -#: c-api/init.rst:2162 +#: c-api/init.rst:2173 msgid "" "Return the :c:expr:`void*` value associated with a TSS key in the current " "thread. This returns ``NULL`` if no value is associated with the key in the " "current thread." msgstr "" -#: c-api/init.rst:2170 +#: c-api/init.rst:2181 msgid "Thread Local Storage (TLS) API" msgstr "" -#: c-api/init.rst:2172 +#: c-api/init.rst:2183 msgid "" "This API is superseded by :ref:`Thread Specific Storage (TSS) API `." msgstr "" -#: c-api/init.rst:2177 +#: c-api/init.rst:2188 msgid "" "This version of the API does not support platforms where the native TLS key " "is defined in a way that cannot be safely cast to ``int``. On such " @@ -2473,13 +2563,13 @@ msgid "" "platforms." msgstr "" -#: c-api/init.rst:2182 +#: c-api/init.rst:2193 msgid "" "Due to the compatibility problem noted above, this version of the API should " "not be used in new code." msgstr "" -#: c-api/init.rst:495 c-api/init.rst:570 +#: c-api/init.rst:502 c-api/init.rst:577 msgid "Py_SetProgramName()" msgstr "" @@ -2491,31 +2581,31 @@ msgstr "" msgid "modules (in module sys)" msgstr "" -#: c-api/init.rst:589 c-api/init.rst:615 +#: c-api/init.rst:596 c-api/init.rst:622 msgid "path (in module sys)" msgstr "" -#: c-api/init.rst:589 c-api/init.rst:1056 c-api/init.rst:1682 +#: c-api/init.rst:596 c-api/init.rst:1063 c-api/init.rst:1693 msgid "module" msgstr "" -#: c-api/init.rst:1587 c-api/init.rst:1682 +#: c-api/init.rst:1594 c-api/init.rst:1693 msgid "builtins" msgstr "" -#: c-api/init.rst:1587 c-api/init.rst:1682 +#: c-api/init.rst:1594 c-api/init.rst:1693 msgid "__main__" msgstr "" -#: c-api/init.rst:1587 c-api/init.rst:1682 +#: c-api/init.rst:1594 c-api/init.rst:1693 msgid "sys" msgstr "" -#: c-api/init.rst:589 c-api/init.rst:615 +#: c-api/init.rst:596 c-api/init.rst:622 msgid "search" msgstr "" -#: c-api/init.rst:589 c-api/init.rst:615 +#: c-api/init.rst:596 c-api/init.rst:622 msgid "path" msgstr "" @@ -2527,134 +2617,134 @@ msgstr "" msgid "PySys_SetArgvEx (C function)" msgstr "" -#: c-api/init.rst:1647 c-api/init.rst:1700 +#: c-api/init.rst:1658 c-api/init.rst:1711 msgid "Py_FinalizeEx (C function)" msgstr "" -#: c-api/init.rst:467 +#: c-api/init.rst:474 msgid "Py_Initialize()" msgstr "" -#: c-api/init.rst:467 c-api/init.rst:723 +#: c-api/init.rst:474 c-api/init.rst:730 msgid "main()" msgstr "" -#: c-api/init.rst:430 +#: c-api/init.rst:437 msgid "stdin" msgstr "" -#: c-api/init.rst:430 +#: c-api/init.rst:437 msgid "stdout" msgstr "" -#: c-api/init.rst:430 +#: c-api/init.rst:437 msgid "sdterr" msgstr "" -#: c-api/init.rst:615 +#: c-api/init.rst:622 msgid "Py_GetPath()" msgstr "" -#: c-api/init.rst:570 +#: c-api/init.rst:577 msgid "executable (in module sys)" msgstr "" -#: c-api/init.rst:589 +#: c-api/init.rst:596 msgid "Py_SetPath()" msgstr "" -#: c-api/init.rst:700 c-api/init.rst:714 +#: c-api/init.rst:707 c-api/init.rst:721 msgid "version (in module sys)" msgstr "" -#: c-api/init.rst:670 +#: c-api/init.rst:677 msgid "platform (in module sys)" msgstr "" -#: c-api/init.rst:687 +#: c-api/init.rst:694 msgid "copyright (in module sys)" msgstr "" -#: c-api/init.rst:723 +#: c-api/init.rst:730 msgid "Py_FatalError()" msgstr "" -#: c-api/init.rst:723 +#: c-api/init.rst:730 msgid "argv (in module sys)" msgstr "" -#: c-api/init.rst:839 +#: c-api/init.rst:846 msgid "global interpreter lock" msgstr "" -#: c-api/init.rst:839 +#: c-api/init.rst:846 msgid "interpreter lock" msgstr "" -#: c-api/init.rst:839 +#: c-api/init.rst:846 msgid "lock, interpreter" msgstr "" -#: c-api/init.rst:852 +#: c-api/init.rst:859 msgid "setswitchinterval (in module sys)" msgstr "" -#: c-api/init.rst:861 +#: c-api/init.rst:868 msgid "PyThreadState (C type)" msgstr "" -#: c-api/init.rst:887 +#: c-api/init.rst:894 msgid "Py_BEGIN_ALLOW_THREADS (C macro)" msgstr "" -#: c-api/init.rst:887 +#: c-api/init.rst:894 msgid "Py_END_ALLOW_THREADS (C macro)" msgstr "" -#: c-api/init.rst:903 +#: c-api/init.rst:910 msgid "PyEval_RestoreThread (C function)" msgstr "" -#: c-api/init.rst:903 +#: c-api/init.rst:910 msgid "PyEval_SaveThread (C function)" msgstr "" -#: c-api/init.rst:1034 +#: c-api/init.rst:1041 msgid "PyEval_AcquireThread()" msgstr "" -#: c-api/init.rst:1034 +#: c-api/init.rst:1041 msgid "PyEval_ReleaseThread()" msgstr "" -#: c-api/init.rst:1034 +#: c-api/init.rst:1041 msgid "PyEval_SaveThread()" msgstr "" -#: c-api/init.rst:1034 +#: c-api/init.rst:1041 msgid "PyEval_RestoreThread()" msgstr "" -#: c-api/init.rst:1056 +#: c-api/init.rst:1063 msgid "_thread" msgstr "" -#: c-api/init.rst:1682 +#: c-api/init.rst:1693 msgid "stdout (in module sys)" msgstr "" -#: c-api/init.rst:1682 +#: c-api/init.rst:1693 msgid "stderr (in module sys)" msgstr "" -#: c-api/init.rst:1682 +#: c-api/init.rst:1693 msgid "stdin (in module sys)" msgstr "" -#: c-api/init.rst:1647 +#: c-api/init.rst:1658 msgid "Py_Initialize (C function)" msgstr "" -#: c-api/init.rst:1677 +#: c-api/init.rst:1688 msgid "close (in module os)" msgstr "" diff --git a/c-api/init_config.po b/c-api/init_config.po index 5fc09f62..8abffdca 100644 --- a/c-api/init_config.po +++ b/c-api/init_config.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -22,9 +23,9 @@ msgstr "" #: c-api/init_config.rst:11 msgid "" -"Python can be initialized with :c:func:`Py_InitializeFromConfig` and the :c:" -"type:`PyConfig` structure. It can be preinitialized with :c:func:" -"`Py_PreInitialize` and the :c:type:`PyPreConfig` structure." +"Python can be initialized with :c:func:`Py_InitializeFromConfig` and " +"the :c:type:`PyConfig` structure. It can be preinitialized " +"with :c:func:`Py_PreInitialize` and the :c:type:`PyPreConfig` structure." msgstr "" #: c-api/init_config.rst:15 @@ -70,6 +71,42 @@ msgstr "" msgid "Example of customized Python always running in isolated mode::" msgstr "" +#: c-api/init_config.rst:41 +msgid "" +"int main(int argc, char **argv)\n" +"{\n" +" PyStatus status;\n" +"\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +" config.isolated = 1;\n" +"\n" +" /* Decode command line arguments.\n" +" Implicitly preinitialize Python (in isolated mode). */\n" +" status = PyConfig_SetBytesArgv(&config, argc, argv);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +" PyConfig_Clear(&config);\n" +"\n" +" return Py_RunMain();\n" +"\n" +"exception:\n" +" PyConfig_Clear(&config);\n" +" if (PyStatus_IsExit(status)) {\n" +" return status.exitcode;\n" +" }\n" +" /* Display the error message and exit the process with\n" +" non-zero exit code */\n" +" Py_ExitStatusException(status);\n" +"}" +msgstr "" + #: c-api/init_config.rst:76 msgid "PyWideStringList" msgstr "" @@ -206,6 +243,29 @@ msgstr "" msgid "Example::" msgstr "" +#: c-api/init_config.rst:191 +msgid "" +"PyStatus alloc(void **ptr, size_t size)\n" +"{\n" +" *ptr = PyMem_RawMalloc(size);\n" +" if (*ptr == NULL) {\n" +" return PyStatus_NoMemory();\n" +" }\n" +" return PyStatus_Ok();\n" +"}\n" +"\n" +"int main(int argc, char **argv)\n" +"{\n" +" void *ptr;\n" +" PyStatus status = alloc(&ptr, 16);\n" +" if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +" }\n" +" PyMem_Free(ptr);\n" +" return 0;\n" +"}" +msgstr "" + #: c-api/init_config.rst:213 msgid "PyPreConfig" msgstr "" @@ -258,8 +318,8 @@ msgstr "" #: c-api/init_config.rst:249 msgid "" -"``PYMEM_ALLOCATOR_MALLOC_DEBUG`` (``4``): force usage of ``malloc()`` with :" -"ref:`debug hooks `." +"``PYMEM_ALLOCATOR_MALLOC_DEBUG`` (``4``): force usage of ``malloc()`` " +"with :ref:`debug hooks `." msgstr "" #: c-api/init_config.rst:251 @@ -295,8 +355,8 @@ msgstr "" #: c-api/init_config.rst:269 msgid "" -"If equals to ``0``, set :c:member:`~PyPreConfig.coerce_c_locale` and :c:" -"member:`~PyPreConfig.coerce_c_locale_warn` members to ``0``." +"If equals to ``0``, set :c:member:`~PyPreConfig.coerce_c_locale` " +"and :c:member:`~PyPreConfig.coerce_c_locale_warn` members to ``0``." msgstr "" #: c-api/init_config.rst:283 @@ -360,7 +420,7 @@ msgstr "" #: c-api/init_config.rst:314 msgid "" -"Initialized the from :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment " +"Initialized from the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment " "variable value." msgstr "" @@ -379,16 +439,16 @@ msgstr "" #: c-api/init_config.rst:324 msgid "" -"If non-zero, :c:func:`Py_PreInitializeFromArgs` and :c:func:" -"`Py_PreInitializeFromBytesArgs` parse their ``argv`` argument the same way " -"the regular Python parses command line arguments: see :ref:`Command Line " -"Arguments `." +"If non-zero, :c:func:`Py_PreInitializeFromArgs` " +"and :c:func:`Py_PreInitializeFromBytesArgs` parse their ``argv`` argument " +"the same way the regular Python parses command line arguments: " +"see :ref:`Command Line Arguments `." msgstr "" #: c-api/init_config.rst:333 msgid "" -"Use :ref:`environment variables `? See :c:member:`PyConfig." -"use_environment`." +"Use :ref:`environment variables `? " +"See :c:member:`PyConfig.use_environment`." msgstr "" #: c-api/init_config.rst:1213 @@ -431,8 +491,8 @@ msgstr "" #: c-api/init_config.rst:359 msgid "" -"Set the :ref:`Python UTF-8 Mode ` (:c:member:`PyPreConfig." -"utf8_mode`)" +"Set the :ref:`Python UTF-8 Mode ` " +"(:c:member:`PyPreConfig.utf8_mode`)" msgstr "" #: c-api/init_config.rst:362 @@ -455,38 +515,38 @@ msgstr "" #: c-api/init_config.rst:377 msgid "" -"Parse *argv* command line arguments (bytes strings) if :c:member:" -"`~PyPreConfig.parse_argv` of *preconfig* is non-zero." +"Parse *argv* command line arguments (bytes strings) " +"if :c:member:`~PyPreConfig.parse_argv` of *preconfig* is non-zero." msgstr "" #: c-api/init_config.rst:386 msgid "" -"Parse *argv* command line arguments (wide strings) if :c:member:" -"`~PyPreConfig.parse_argv` of *preconfig* is non-zero." +"Parse *argv* command line arguments (wide strings) " +"if :c:member:`~PyPreConfig.parse_argv` of *preconfig* is non-zero." msgstr "" #: c-api/init_config.rst:1301 msgid "" -"The caller is responsible to handle exceptions (error or exit) using :c:func:" -"`PyStatus_Exception` and :c:func:`Py_ExitStatusException`." +"The caller is responsible to handle exceptions (error or exit) " +"using :c:func:`PyStatus_Exception` and :c:func:`Py_ExitStatusException`." msgstr "" #: c-api/init_config.rst:394 msgid "" -"For :ref:`Python Configuration ` (:c:func:" -"`PyPreConfig_InitPythonConfig`), if Python is initialized with command line " -"arguments, the command line arguments must also be passed to preinitialize " -"Python, since they have an effect on the pre-configuration like encodings. " -"For example, the :option:`-X utf8 <-X>` command line option enables the :ref:" -"`Python UTF-8 Mode `." +"For :ref:`Python Configuration ` " +"(:c:func:`PyPreConfig_InitPythonConfig`), if Python is initialized with " +"command line arguments, the command line arguments must also be passed to " +"preinitialize Python, since they have an effect on the pre-configuration " +"like encodings. For example, the :option:`-X utf8 <-X>` command line option " +"enables the :ref:`Python UTF-8 Mode `." msgstr "" #: c-api/init_config.rst:401 msgid "" "``PyMem_SetAllocator()`` can be called after :c:func:`Py_PreInitialize` and " "before :c:func:`Py_InitializeFromConfig` to install a custom memory " -"allocator. It can be called before :c:func:`Py_PreInitialize` if :c:member:" -"`PyPreConfig.allocator` is set to ``PYMEM_ALLOCATOR_NOT_SET``." +"allocator. It can be called before :c:func:`Py_PreInitialize` " +"if :c:member:`PyPreConfig.allocator` is set to ``PYMEM_ALLOCATOR_NOT_SET``." msgstr "" #: c-api/init_config.rst:406 @@ -503,6 +563,26 @@ msgid "" "`::" msgstr "" +#: c-api/init_config.rst:414 +msgid "" +"PyStatus status;\n" +"PyPreConfig preconfig;\n" +"PyPreConfig_InitPythonConfig(&preconfig);\n" +"\n" +"preconfig.utf8_mode = 1;\n" +"\n" +"status = Py_PreInitialize(&preconfig);\n" +"if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +"}\n" +"\n" +"/* at this point, Python speaks UTF-8 */\n" +"\n" +"Py_Initialize();\n" +"/* ... use Python API here ... */\n" +"Py_Finalize();" +msgstr "" + #: c-api/init_config.rst:433 msgid "PyConfig" msgstr "" @@ -557,8 +637,8 @@ msgstr "" #: c-api/init_config.rst:478 msgid "" "Set command line arguments (:c:member:`~PyConfig.argv` member of *config*) " -"from the *argv* list of bytes strings. Decode bytes using :c:func:" -"`Py_DecodeLocale`." +"from the *argv* list of bytes strings. Decode bytes " +"using :c:func:`Py_DecodeLocale`." msgstr "" #: c-api/init_config.rst:486 @@ -583,16 +663,17 @@ msgstr "" msgid "" "The :c:func:`PyConfig_Read` function only parses :c:member:`PyConfig.argv` " "arguments once: :c:member:`PyConfig.parse_argv` is set to ``2`` after " -"arguments are parsed. Since Python arguments are strippped from :c:member:" -"`PyConfig.argv`, parsing arguments twice would parse the application options " -"as Python options." +"arguments are parsed. Since Python arguments are stripped " +"from :c:member:`PyConfig.argv`, parsing arguments twice would parse the " +"application options as Python options." msgstr "" #: c-api/init_config.rst:507 msgid "" -"The :c:member:`PyConfig.argv` arguments are now only parsed once, :c:member:" -"`PyConfig.parse_argv` is set to ``2`` after arguments are parsed, and " -"arguments are only parsed if :c:member:`PyConfig.parse_argv` equals ``1``." +"The :c:member:`PyConfig.argv` arguments are now only parsed " +"once, :c:member:`PyConfig.parse_argv` is set to ``2`` after arguments are " +"parsed, and arguments are only parsed if :c:member:`PyConfig.parse_argv` " +"equals ``1``." msgstr "" #: c-api/init_config.rst:513 @@ -609,10 +690,10 @@ msgstr "" #: c-api/init_config.rst:523 msgid "" "Most ``PyConfig`` methods :ref:`preinitialize Python ` if needed. " -"In that case, the Python preinitialization configuration (:c:type:" -"`PyPreConfig`) in based on the :c:type:`PyConfig`. If configuration fields " -"which are in common with :c:type:`PyPreConfig` are tuned, they must be set " -"before calling a :c:type:`PyConfig` method:" +"In that case, the Python preinitialization configuration " +"(:c:type:`PyPreConfig`) in based on the :c:type:`PyConfig`. If configuration " +"fields which are in common with :c:type:`PyPreConfig` are tuned, they must " +"be set before calling a :c:type:`PyConfig` method:" msgstr "" #: c-api/init_config.rst:529 @@ -635,8 +716,8 @@ msgstr "" msgid "" "Moreover, if :c:func:`PyConfig_SetArgv` or :c:func:`PyConfig_SetBytesArgv` " "is used, this method must be called before other methods, since the " -"preinitialization configuration depends on command line arguments (if :c:" -"member:`~PyConfig.parse_argv` is non-zero)." +"preinitialization configuration depends on command line arguments " +"(if :c:member:`~PyConfig.parse_argv` is non-zero)." msgstr "" #: c-api/init_config.rst:539 @@ -651,9 +732,10 @@ msgstr "" #: c-api/init_config.rst:550 msgid "" -"Set :c:member:`~PyConfig.parse_argv` to ``1`` to parse :c:member:`~PyConfig." -"argv` the same way the regular Python parses Python command line arguments " -"and then to strip Python arguments from :c:member:`~PyConfig.argv`." +"Set :c:member:`~PyConfig.parse_argv` to ``1`` to " +"parse :c:member:`~PyConfig.argv` the same way the regular Python parses " +"Python command line arguments and then to strip Python arguments " +"from :c:member:`~PyConfig.argv`." msgstr "" #: c-api/init_config.rst:555 @@ -675,8 +757,8 @@ msgstr "" #: c-api/init_config.rst:564 msgid "" -"If equals to zero, ``Py_RunMain()`` prepends a potentially unsafe path to :" -"data:`sys.path` at startup:" +"If equals to zero, ``Py_RunMain()`` prepends a potentially unsafe path " +"to :data:`sys.path` at startup:" msgstr "" #: c-api/init_config.rst:567 @@ -699,8 +781,8 @@ msgstr "" #: c-api/init_config.rst:574 msgid "" -"Set to ``1`` by the :option:`-P` command line option and the :envvar:" -"`PYTHONSAFEPATH` environment variable." +"Set to ``1`` by the :option:`-P` command line option and " +"the :envvar:`PYTHONSAFEPATH` environment variable." msgstr "" #: c-api/init_config.rst:577 @@ -740,8 +822,8 @@ msgstr "" #: c-api/init_config.rst:614 msgid "" -"Set to ``0`` by the :option:`-u` command line option and the :envvar:" -"`PYTHONUNBUFFERED` environment variable." +"Set to ``0`` by the :option:`-u` command line option and " +"the :envvar:`PYTHONUNBUFFERED` environment variable." msgstr "" #: c-api/init_config.rst:617 @@ -754,8 +836,9 @@ msgstr "" #: c-api/init_config.rst:623 msgid "" -"If equals to ``1``, issue a warning when comparing :class:`bytes` or :class:" -"`bytearray` with :class:`str`, or comparing :class:`bytes` with :class:`int`." +"If equals to ``1``, issue a warning when comparing :class:`bytes` " +"or :class:`bytearray` with :class:`str`, or comparing :class:`bytes` " +"with :class:`int`." msgstr "" #: c-api/init_config.rst:627 @@ -770,9 +853,9 @@ msgstr "" #: c-api/init_config.rst:636 msgid "" -"If non-zero, emit a :exc:`EncodingWarning` warning when :class:`io." -"TextIOWrapper` uses its default encoding. See :ref:`io-encoding-warning` for " -"details." +"If non-zero, emit a :exc:`EncodingWarning` warning " +"when :class:`io.TextIOWrapper` uses its default encoding. See :ref:`io-" +"encoding-warning` for details." msgstr "" #: c-api/init_config.rst:645 @@ -790,8 +873,8 @@ msgstr "" #: c-api/init_config.rst:658 msgid "" -"Control the validation behavior of hash-based ``.pyc`` files: value of the :" -"option:`--check-hash-based-pycs` command line option." +"Control the validation behavior of hash-based ``.pyc`` files: value of " +"the :option:`--check-hash-based-pycs` command line option." msgstr "" #: c-api/init_config.rst:661 @@ -849,8 +932,8 @@ msgstr "" #: c-api/init_config.rst:690 msgid "" -"Set to ``1`` by the :option:`-X dev <-X>` option and the :envvar:" -"`PYTHONDEVMODE` environment variable." +"Set to ``1`` by the :option:`-X dev <-X>` option and " +"the :envvar:`PYTHONDEVMODE` environment variable." msgstr "" #: c-api/init_config.rst:697 @@ -879,8 +962,8 @@ msgstr "" #: c-api/init_config.rst:719 msgid "" -"The absolute path of the executable binary for the Python interpreter: :data:" -"`sys.executable`." +"The absolute path of the executable binary for the Python " +"interpreter: :data:`sys.executable`." msgstr "" #: c-api/init_config.rst:728 @@ -893,14 +976,14 @@ msgstr "" #: c-api/init_config.rst:732 msgid "" -"Set to ``1`` by :option:`-X faulthandler <-X>` and the :envvar:" -"`PYTHONFAULTHANDLER` environment variable." +"Set to ``1`` by :option:`-X faulthandler <-X>` and " +"the :envvar:`PYTHONFAULTHANDLER` environment variable." msgstr "" #: c-api/init_config.rst:739 msgid "" -":term:`Filesystem encoding `: :func:" -"`sys.getfilesystemencoding`." +":term:`Filesystem encoding `: :func:`sys.getfilesystemencoding`." msgstr "" #: c-api/init_config.rst:742 @@ -909,9 +992,9 @@ msgstr "" #: c-api/init_config.rst:744 msgid "" -"On Windows: use ``\"utf-8\"`` by default, or ``\"mbcs\"`` if :c:member:" -"`~PyPreConfig.legacy_windows_fs_encoding` of :c:type:`PyPreConfig` is non-" -"zero." +"On Windows: use ``\"utf-8\"`` by default, or ``\"mbcs\"`` " +"if :c:member:`~PyPreConfig.legacy_windows_fs_encoding` " +"of :c:type:`PyPreConfig` is non-zero." msgstr "" #: c-api/init_config.rst:748 @@ -950,15 +1033,15 @@ msgstr "" #: c-api/init_config.rst:765 msgid "" -":term:`Filesystem error handler `: :" -"func:`sys.getfilesystemencodeerrors`." +":term:`Filesystem error handler `: :func:`sys.getfilesystemencodeerrors`." msgstr "" #: c-api/init_config.rst:768 msgid "" -"On Windows: use ``\"surrogatepass\"`` by default, or ``\"replace\"`` if :c:" -"member:`~PyPreConfig.legacy_windows_fs_encoding` of :c:type:`PyPreConfig` is " -"non-zero." +"On Windows: use ``\"surrogatepass\"`` by default, or ``\"replace\"`` " +"if :c:member:`~PyPreConfig.legacy_windows_fs_encoding` " +"of :c:type:`PyPreConfig` is non-zero." msgstr "" #: c-api/init_config.rst:772 @@ -1029,8 +1112,8 @@ msgstr "" #: c-api/init_config.rst:812 msgid "" -"Set the ``1`` by the :option:`-X importtime <-X>` option and the :envvar:" -"`PYTHONPROFILEIMPORTTIME` environment variable." +"Set the ``1`` by the :option:`-X importtime <-X>` option and " +"the :envvar:`PYTHONPROFILEIMPORTTIME` environment variable." msgstr "" #: c-api/init_config.rst:819 @@ -1047,8 +1130,8 @@ msgstr "" #: c-api/init_config.rst:826 msgid "" -"Incremented by the :option:`-i` command line option. Set to ``1`` if the :" -"envvar:`PYTHONINSPECT` environment variable is non-empty." +"Incremented by the :option:`-i` command line option. Set to ``1`` if " +"the :envvar:`PYTHONINSPECT` environment variable is non-empty." msgstr "" #: c-api/init_config.rst:833 @@ -1071,10 +1154,11 @@ msgstr "" msgid "" "Configures the :ref:`integer string conversion length limitation " "`. An initial value of ``-1`` means the value will be " -"taken from the command line or environment or otherwise default to 4300 (:" -"data:`sys.int_info.default_max_str_digits`). A value of ``0`` disables the " -"limitation. Values greater than zero but less than 640 (:data:`sys.int_info." -"str_digits_check_threshold`) are unsupported and will produce an error." +"taken from the command line or environment or otherwise default to 4300 " +"(:data:`sys.int_info.default_max_str_digits`). A value of ``0`` disables " +"the limitation. Values greater than zero but less than 640 " +"(:data:`sys.int_info.str_digits_check_threshold`) are unsupported and will " +"produce an error." msgstr "" #: c-api/init_config.rst:855 @@ -1085,8 +1169,8 @@ msgstr "" #: c-api/init_config.rst:858 msgid "" -"Default: ``-1`` in Python mode. 4300 (:data:`sys.int_info." -"default_max_str_digits`) in isolated mode." +"Default: ``-1`` in Python mode. 4300 " +"(:data:`sys.int_info.default_max_str_digits`) in isolated mode." msgstr "" #: c-api/init_config.rst:865 @@ -1124,15 +1208,15 @@ msgstr "" #: c-api/init_config.rst:882 msgid "" -"See also the :ref:`Isolated Configuration ` and :c:" -"member:`PyPreConfig.isolated`." +"See also the :ref:`Isolated Configuration ` " +"and :c:member:`PyPreConfig.isolated`." msgstr "" #: c-api/init_config.rst:887 msgid "" -"If non-zero, use :class:`io.FileIO` instead of :class:`!io." -"_WindowsConsoleIO` for :data:`sys.stdin`, :data:`sys.stdout` and :data:`sys." -"stderr`." +"If non-zero, use :class:`io.FileIO` instead of :class:`!" +"io._WindowsConsoleIO` for :data:`sys.stdin`, :data:`sys.stdout` " +"and :data:`sys.stderr`." msgstr "" #: c-api/init_config.rst:891 @@ -1171,9 +1255,9 @@ msgstr "" #: c-api/init_config.rst:919 msgid "" -"Default: value of the ``PLATLIBDIR`` macro which is set by the :option:" -"`configure --with-platlibdir option <--with-platlibdir>` (default: " -"``\"lib\"``, or ``\"DLLs\"`` on Windows)." +"Default: value of the ``PLATLIBDIR`` macro which is set by " +"the :option:`configure --with-platlibdir option <--with-platlibdir>` " +"(default: ``\"lib\"``, or ``\"DLLs\"`` on Windows)." msgstr "" #: c-api/init_config.rst:927 @@ -1186,8 +1270,8 @@ msgstr "" #: c-api/init_config.rst:936 msgid "" -"Module search paths (:data:`sys.path`) as a string separated by ``DELIM`` (:" -"data:`os.pathsep`)." +"Module search paths (:data:`sys.path`) as a string separated by ``DELIM`` " +"(:data:`os.pathsep`)." msgstr "" #: c-api/init_config.rst:939 @@ -1200,10 +1284,10 @@ msgstr "" #: c-api/init_config.rst:950 msgid "" -"If :c:member:`~PyConfig.module_search_paths_set` is equal to ``0``, :c:func:" -"`Py_InitializeFromConfig` will replace :c:member:`~PyConfig." -"module_search_paths` and sets :c:member:`~PyConfig.module_search_paths_set` " -"to ``1``." +"If :c:member:`~PyConfig.module_search_paths_set` is equal to " +"``0``, :c:func:`Py_InitializeFromConfig` will " +"replace :c:member:`~PyConfig.module_search_paths` and " +"sets :c:member:`~PyConfig.module_search_paths_set` to ``1``." msgstr "" #: c-api/init_config.rst:955 @@ -1230,8 +1314,8 @@ msgstr "" #: c-api/init_config.rst:968 msgid "" -"Incremented by the :option:`-O` command line option. Set to the :envvar:" -"`PYTHONOPTIMIZE` environment variable value." +"Incremented by the :option:`-O` command line option. Set to " +"the :envvar:`PYTHONOPTIMIZE` environment variable value." msgstr "" #: c-api/init_config.rst:975 @@ -1242,17 +1326,18 @@ msgstr "" #: c-api/init_config.rst:978 msgid "" -"If :c:member:`~PyConfig.orig_argv` list is empty and :c:member:`~PyConfig." -"argv` is not a list only containing an empty string, :c:func:`PyConfig_Read` " -"copies :c:member:`~PyConfig.argv` into :c:member:`~PyConfig.orig_argv` " -"before modifying :c:member:`~PyConfig.argv` (if :c:member:`~PyConfig." -"parse_argv` is non-zero)." +"If :c:member:`~PyConfig.orig_argv` list is empty " +"and :c:member:`~PyConfig.argv` is not a list only containing an empty " +"string, :c:func:`PyConfig_Read` copies :c:member:`~PyConfig.argv` " +"into :c:member:`~PyConfig.orig_argv` before " +"modifying :c:member:`~PyConfig.argv` (if :c:member:`~PyConfig.parse_argv` is " +"non-zero)." msgstr "" #: c-api/init_config.rst:985 msgid "" -"See also the :c:member:`~PyConfig.argv` member and the :c:func:" -"`Py_GetArgcArgv` function." +"See also the :c:member:`~PyConfig.argv` member and " +"the :c:func:`Py_GetArgcArgv` function." msgstr "" #: c-api/init_config.rst:1258 c-api/init_config.rst:1277 @@ -1272,8 +1357,8 @@ msgstr "" #: c-api/init_config.rst:1008 msgid "" -"The :c:member:`PyConfig.argv` arguments are now only parsed if :c:member:" -"`PyConfig.parse_argv` equals to ``1``." +"The :c:member:`PyConfig.argv` arguments are now only parsed " +"if :c:member:`PyConfig.parse_argv` equals to ``1``." msgstr "" #: c-api/init_config.rst:1014 @@ -1284,8 +1369,8 @@ msgstr "" #: c-api/init_config.rst:1017 msgid "" -"Incremented by the :option:`-d` command line option. Set to the :envvar:" -"`PYTHONDEBUG` environment variable value." +"Incremented by the :option:`-d` command line option. Set to " +"the :envvar:`PYTHONDEBUG` environment variable value." msgstr "" #: c-api/init_config.rst:1020 @@ -1326,8 +1411,8 @@ msgstr "" #: c-api/init_config.rst:1053 msgid "" -"If the ``WITH_NEXT_FRAMEWORK`` macro is defined, use :envvar:" -"`__PYVENV_LAUNCHER__` environment variable if set." +"If the ``WITH_NEXT_FRAMEWORK`` macro is defined, " +"use :envvar:`__PYVENV_LAUNCHER__` environment variable if set." msgstr "" #: c-api/init_config.rst:1055 @@ -1343,8 +1428,8 @@ msgstr "" #: c-api/init_config.rst:1066 msgid "" -"Directory where cached ``.pyc`` files are written: :data:`sys." -"pycache_prefix`." +"Directory where cached ``.pyc`` files are " +"written: :data:`sys.pycache_prefix`." msgstr "" #: c-api/init_config.rst:1069 @@ -1377,8 +1462,9 @@ msgstr "" #: c-api/init_config.rst:1095 msgid "" -"Filename passed on the command line: trailing command line argument without :" -"option:`-c` or :option:`-m`. It is used by the :c:func:`Py_RunMain` function." +"Filename passed on the command line: trailing command line argument " +"without :option:`-c` or :option:`-m`. It is used by the :c:func:`Py_RunMain` " +"function." msgstr "" #: c-api/init_config.rst:1099 @@ -1431,8 +1517,8 @@ msgstr "" #: c-api/init_config.rst:1137 msgid "" -":data:`sys.flags.no_site ` is set to the inverted value of :c:" -"member:`~PyConfig.site_import`." +":data:`sys.flags.no_site ` is set to the inverted value " +"of :c:member:`~PyConfig.site_import`." msgstr "" #: c-api/init_config.rst:1144 @@ -1453,8 +1539,8 @@ msgstr "" #: c-api/init_config.rst:1157 msgid "" -"Encoding and encoding errors of :data:`sys.stdin`, :data:`sys.stdout` and :" -"data:`sys.stderr` (but :data:`sys.stderr` always uses " +"Encoding and encoding errors of :data:`sys.stdin`, :data:`sys.stdout` " +"and :data:`sys.stderr` (but :data:`sys.stderr` always uses " "``\"backslashreplace\"`` error handler)." msgstr "" @@ -1509,8 +1595,8 @@ msgstr "" #: c-api/init_config.rst:1185 msgid "" -"Set by :option:`-X tracemalloc=N <-X>` command line option and by the :" -"envvar:`PYTHONTRACEMALLOC` environment variable." +"Set by :option:`-X tracemalloc=N <-X>` command line option and by " +"the :envvar:`PYTHONTRACEMALLOC` environment variable." msgstr "" #: c-api/init_config.rst:1192 @@ -1525,8 +1611,8 @@ msgstr "" #: c-api/init_config.rst:1197 msgid "" -"Set by :option:`-X perf <-X>` command line option and by the :envvar:" -"`PYTHONPERFSUPPORT` environment variable." +"Set by :option:`-X perf <-X>` command line option and by " +"the :envvar:`PYTHONPERFSUPPORT` environment variable." msgstr "" #: c-api/init_config.rst:1200 @@ -1596,15 +1682,15 @@ msgstr "" #: c-api/init_config.rst:1251 msgid "" -"The :option:`-W` command line options adds its value to :c:member:`~PyConfig." -"warnoptions`, it can be used multiple times." +"The :option:`-W` command line options adds its value " +"to :c:member:`~PyConfig.warnoptions`, it can be used multiple times." msgstr "" #: c-api/init_config.rst:1254 msgid "" "The :envvar:`PYTHONWARNINGS` environment variable can also be used to add " -"warning options. Multiple options can be specified, separated by commas (``," -"``)." +"warning options. Multiple options can be specified, separated by commas " +"(``,``)." msgstr "" #: c-api/init_config.rst:1262 @@ -1615,14 +1701,14 @@ msgstr "" #: c-api/init_config.rst:1265 msgid "" -"Set to ``0`` by the :option:`-B` command line option and the :envvar:" -"`PYTHONDONTWRITEBYTECODE` environment variable." +"Set to ``0`` by the :option:`-B` command line option and " +"the :envvar:`PYTHONDONTWRITEBYTECODE` environment variable." msgstr "" #: c-api/init_config.rst:1268 msgid "" -":data:`sys.dont_write_bytecode` is initialized to the inverted value of :c:" -"member:`~PyConfig.write_bytecode`." +":data:`sys.dont_write_bytecode` is initialized to the inverted value " +"of :c:member:`~PyConfig.write_bytecode`." msgstr "" #: c-api/init_config.rst:1275 @@ -1633,8 +1719,8 @@ msgstr "" msgid "" "If :c:member:`~PyConfig.parse_argv` is non-zero, :c:member:`~PyConfig.argv` " "arguments are parsed the same way the regular Python parses :ref:`command " -"line arguments `, and Python arguments are stripped from :" -"c:member:`~PyConfig.argv`." +"line arguments `, and Python arguments are stripped " +"from :c:member:`~PyConfig.argv`." msgstr "" #: c-api/init_config.rst:1284 @@ -1661,11 +1747,12 @@ msgstr "" #: c-api/init_config.rst:1304 msgid "" -"If :c:func:`PyImport_FrozenModules`, :c:func:`PyImport_AppendInittab` or :c:" -"func:`PyImport_ExtendInittab` are used, they must be set or called after " -"Python preinitialization and before the Python initialization. If Python is " -"initialized multiple times, :c:func:`PyImport_AppendInittab` or :c:func:" -"`PyImport_ExtendInittab` must be called before each Python initialization." +"If :c:func:`PyImport_FrozenModules`, :c:func:`PyImport_AppendInittab` " +"or :c:func:`PyImport_ExtendInittab` are used, they must be set or called " +"after Python preinitialization and before the Python initialization. If " +"Python is initialized multiple times, :c:func:`PyImport_AppendInittab` " +"or :c:func:`PyImport_ExtendInittab` must be called before each Python " +"initialization." msgstr "" #: c-api/init_config.rst:1311 @@ -1678,6 +1765,35 @@ msgstr "" msgid "Example setting the program name::" msgstr "" +#: c-api/init_config.rst:1316 +msgid "" +"void init_python(void)\n" +"{\n" +" PyStatus status;\n" +"\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +"\n" +" /* Set the program name. Implicitly preinitialize Python. */\n" +" status = PyConfig_SetString(&config, &config.program_name,\n" +" L\"/path/to/my_program\");\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +" PyConfig_Clear(&config);\n" +" return;\n" +"\n" +"exception:\n" +" PyConfig_Clear(&config);\n" +" Py_ExitStatusException(status);\n" +"}" +msgstr "" + #: c-api/init_config.rst:1342 msgid "" "More complete example modifying the default configuration, read the " @@ -1687,15 +1803,71 @@ msgid "" "called will be left unchanged by initialization::" msgstr "" +#: c-api/init_config.rst:1349 +msgid "" +"PyStatus init_python(const char *program_name)\n" +"{\n" +" PyStatus status;\n" +"\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +"\n" +" /* Set the program name before reading the configuration\n" +" (decode byte string from the locale encoding).\n" +"\n" +" Implicitly preinitialize Python. */\n" +" status = PyConfig_SetBytesString(&config, &config.program_name,\n" +" program_name);\n" +" if (PyStatus_Exception(status)) {\n" +" goto done;\n" +" }\n" +"\n" +" /* Read all configuration at once */\n" +" status = PyConfig_Read(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" goto done;\n" +" }\n" +"\n" +" /* Specify sys.path explicitly */\n" +" /* If you want to modify the default set of paths, finish\n" +" initialization first and then use PySys_GetObject(\"path\") */\n" +" config.module_search_paths_set = 1;\n" +" status = PyWideStringList_Append(&config.module_search_paths,\n" +" L\"/path/to/stdlib\");\n" +" if (PyStatus_Exception(status)) {\n" +" goto done;\n" +" }\n" +" status = PyWideStringList_Append(&config.module_search_paths,\n" +" L\"/path/to/more/modules\");\n" +" if (PyStatus_Exception(status)) {\n" +" goto done;\n" +" }\n" +"\n" +" /* Override executable computed by PyConfig_Read() */\n" +" status = PyConfig_SetString(&config, &config.executable,\n" +" L\"/path/to/my_executable\");\n" +" if (PyStatus_Exception(status)) {\n" +" goto done;\n" +" }\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +"\n" +"done:\n" +" PyConfig_Clear(&config);\n" +" return status;\n" +"}" +msgstr "" + #: c-api/init_config.rst:1405 msgid "Isolated Configuration" msgstr "" #: c-api/init_config.rst:1407 msgid "" -":c:func:`PyPreConfig_InitIsolatedConfig` and :c:func:" -"`PyConfig_InitIsolatedConfig` functions create a configuration to isolate " -"Python from the system. For example, to embed Python into an application." +":c:func:`PyPreConfig_InitIsolatedConfig` " +"and :c:func:`PyConfig_InitIsolatedConfig` functions create a configuration " +"to isolate Python from the system. For example, to embed Python into an " +"application." msgstr "" #: c-api/init_config.rst:1412 @@ -1719,9 +1891,9 @@ msgstr "" #: c-api/init_config.rst:1427 msgid "" -":c:func:`PyPreConfig_InitPythonConfig` and :c:func:" -"`PyConfig_InitPythonConfig` functions create a configuration to build a " -"customized Python which behaves as the regular Python." +":c:func:`PyPreConfig_InitPythonConfig` " +"and :c:func:`PyConfig_InitPythonConfig` functions create a configuration to " +"build a customized Python which behaves as the regular Python." msgstr "" #: c-api/init_config.rst:1431 @@ -1733,8 +1905,9 @@ msgstr "" #: c-api/init_config.rst:1434 msgid "" "This function enables C locale coercion (:pep:`538`) and :ref:`Python UTF-8 " -"Mode ` (:pep:`540`) depending on the LC_CTYPE locale, :envvar:" -"`PYTHONUTF8` and :envvar:`PYTHONCOERCECLOCALE` environment variables." +"Mode ` (:pep:`540`) depending on the LC_CTYPE " +"locale, :envvar:`PYTHONUTF8` and :envvar:`PYTHONCOERCECLOCALE` environment " +"variables." msgstr "" #: c-api/init_config.rst:1443 @@ -1775,8 +1948,8 @@ msgstr "" #: c-api/init_config.rst:1455 msgid "" -"``PATH`` environment variable to get the program full path (from :c:member:" -"`PyConfig.program_name`)" +"``PATH`` environment variable to get the program full path " +"(from :c:member:`PyConfig.program_name`)" msgstr "" #: c-api/init_config.rst:1457 @@ -1815,9 +1988,7 @@ msgid ":c:member:`PyConfig.executable`" msgstr "" #: c-api/init_config.rst:1469 -msgid "" -":c:member:`PyConfig.module_search_paths_set`, :c:member:`PyConfig." -"module_search_paths`" +msgid ":c:member:`PyConfig.module_search_paths_set`, :c:member:`PyConfig.module_search_paths`" msgstr "" #: c-api/init_config.rst:1471 @@ -1827,10 +1998,10 @@ msgstr "" #: c-api/init_config.rst:1473 msgid "" "If at least one \"output field\" is not set, Python calculates the path " -"configuration to fill unset fields. If :c:member:`~PyConfig." -"module_search_paths_set` is equal to ``0``, :c:member:`~PyConfig." -"module_search_paths` is overridden and :c:member:`~PyConfig." -"module_search_paths_set` is set to ``1``." +"configuration to fill unset fields. " +"If :c:member:`~PyConfig.module_search_paths_set` is equal to " +"``0``, :c:member:`~PyConfig.module_search_paths` is overridden " +"and :c:member:`~PyConfig.module_search_paths_set` is set to ``1``." msgstr "" #: c-api/init_config.rst:1479 @@ -1852,9 +2023,10 @@ msgstr "" #: c-api/init_config.rst:1489 msgid "" -"If :c:member:`~PyConfig.base_prefix` or :c:member:`~PyConfig." -"base_exec_prefix` fields are not set, they inherit their value from :c:" -"member:`~PyConfig.prefix` and :c:member:`~PyConfig.exec_prefix` respectively." +"If :c:member:`~PyConfig.base_prefix` " +"or :c:member:`~PyConfig.base_exec_prefix` fields are not set, they inherit " +"their value from :c:member:`~PyConfig.prefix` " +"and :c:member:`~PyConfig.exec_prefix` respectively." msgstr "" #: c-api/init_config.rst:1493 @@ -1864,8 +2036,8 @@ msgstr "" #: c-api/init_config.rst:1495 msgid "" "If :c:member:`~PyConfig.run_filename` is set and is a directory which " -"contains a ``__main__.py`` script, prepend :c:member:`~PyConfig." -"run_filename` to :data:`sys.path`." +"contains a ``__main__.py`` script, " +"prepend :c:member:`~PyConfig.run_filename` to :data:`sys.path`." msgstr "" #: c-api/init_config.rst:1498 @@ -1891,10 +2063,10 @@ msgstr "" #: c-api/init_config.rst:1506 msgid "" "If :c:member:`~PyConfig.site_import` is non-zero, :data:`sys.path` can be " -"modified by the :mod:`site` module. If :c:member:`~PyConfig." -"user_site_directory` is non-zero and the user's site-package directory " -"exists, the :mod:`site` module appends the user's site-package directory to :" -"data:`sys.path`." +"modified by the :mod:`site` module. " +"If :c:member:`~PyConfig.user_site_directory` is non-zero and the user's site-" +"package directory exists, the :mod:`site` module appends the user's site-" +"package directory to :data:`sys.path`." msgstr "" #: c-api/init_config.rst:1512 @@ -1935,8 +2107,8 @@ msgstr "" #: c-api/init_config.rst:1525 msgid "" -"The ``__PYVENV_LAUNCHER__`` environment variable is used to set :c:member:" -"`PyConfig.base_executable`" +"The ``__PYVENV_LAUNCHER__`` environment variable is used to " +"set :c:member:`PyConfig.base_executable`" msgstr "" #: c-api/init_config.rst:1530 @@ -1945,9 +2117,10 @@ msgstr "" #: c-api/init_config.rst:1534 msgid "" -"Execute the command (:c:member:`PyConfig.run_command`), the script (:c:" -"member:`PyConfig.run_filename`) or the module (:c:member:`PyConfig." -"run_module`) specified on the command line or in the configuration." +"Execute the command (:c:member:`PyConfig.run_command`), the script " +"(:c:member:`PyConfig.run_filename`) or the module " +"(:c:member:`PyConfig.run_module`) specified on the command line or in the " +"configuration." msgstr "" #: c-api/init_config.rst:1539 @@ -2028,8 +2201,8 @@ msgstr "" #: c-api/init_config.rst:1578 msgid "" -"Finish :mod:`sys` module initialization (ex: create :data:`sys.stdout` and :" -"data:`sys.path`);" +"Finish :mod:`sys` module initialization (ex: create :data:`sys.stdout` " +"and :data:`sys.path`);" msgstr "" #: c-api/init_config.rst:1580 @@ -2051,8 +2224,9 @@ msgstr "" #: c-api/init_config.rst:1586 msgid "" -":c:member:`PyConfig._init_main`: if set to ``0``, :c:func:" -"`Py_InitializeFromConfig` stops at the \"Core\" initialization phase." +":c:member:`PyConfig._init_main`: if set to " +"``0``, :c:func:`Py_InitializeFromConfig` stops at the \"Core\" " +"initialization phase." msgstr "" #: c-api/init_config.rst:1591 @@ -2089,3 +2263,40 @@ msgid "" "Example running Python code between \"Core\" and \"Main\" initialization " "phases::" msgstr "" + +#: c-api/init_config.rst:1611 +msgid "" +"void init_python(void)\n" +"{\n" +" PyStatus status;\n" +"\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +" config._init_main = 0;\n" +"\n" +" /* ... customize 'config' configuration ... */\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +" PyConfig_Clear(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +" }\n" +"\n" +" /* Use sys.stderr because sys.stdout is only created\n" +" by _Py_InitializeMain() */\n" +" int res = PyRun_SimpleString(\n" +" \"import sys; \"\n" +" \"print('Run Python code before _Py_InitializeMain', \"\n" +" \"file=sys.stderr)\");\n" +" if (res < 0) {\n" +" exit(1);\n" +" }\n" +"\n" +" /* ... put more configuration code here ... */\n" +"\n" +" status = _Py_InitializeMain();\n" +" if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +" }\n" +"}" +msgstr "" diff --git a/c-api/intro.po b/c-api/intro.po index 30b7485d..ca97aeee 100644 --- a/c-api/intro.po +++ b/c-api/intro.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -29,8 +30,8 @@ msgid "" "API. The first reason is to write *extension modules* for specific purposes; " "these are C modules that extend the Python interpreter. This is probably " "the most common use. The second reason is to use Python as a component in a " -"larger application; this technique is generally referred to as :dfn:" -"`embedding` Python in an application." +"larger application; this technique is generally referred to " +"as :dfn:`embedding` Python in an application." msgstr "" #: c-api/intro.rst:20 @@ -74,11 +75,17 @@ msgid "" "included in your code by the following line::" msgstr "" +#: c-api/intro.rst:51 +msgid "" +"#define PY_SSIZE_T_CLEAN\n" +"#include " +msgstr "" + #: c-api/intro.rst:54 msgid "" "This implies inclusion of the following standard headers: ````, " -"````, ````, ````, ```` and ```` (if available)." +"````, ````, ````, ```` and " +"```` (if available)." msgstr "" #: c-api/intro.rst:60 @@ -114,13 +121,13 @@ msgstr "" #: c-api/intro.rst:79 msgid "" "The header files are typically installed with Python. On Unix, these are " -"located in the directories :file:`{prefix}/include/pythonversion/` and :file:" -"`{exec_prefix}/include/pythonversion/`, where :option:`prefix <--prefix>` " -"and :option:`exec_prefix <--exec-prefix>` are defined by the corresponding " -"parameters to Python's :program:`configure` script and *version* is ``'%d." -"%d' % sys.version_info[:2]``. On Windows, the headers are installed in :" -"file:`{prefix}/include`, where ``prefix`` is the installation directory " -"specified to the installer." +"located in the directories :file:`{prefix}/include/pythonversion/` " +"and :file:`{exec_prefix}/include/pythonversion/`, where :option:`prefix <--" +"prefix>` and :option:`exec_prefix <--exec-prefix>` are defined by the " +"corresponding parameters to Python's :program:`configure` script and " +"*version* is ``'%d.%d' % sys.version_info[:2]``. On Windows, the headers " +"are installed in :file:`{prefix}/include`, where ``prefix`` is the " +"installation directory specified to the installer." msgstr "" #: c-api/intro.rst:88 @@ -128,9 +135,9 @@ msgid "" "To include the headers, place both directories (if different) on your " "compiler's search path for includes. Do *not* place the parent directories " "on the search path and then use ``#include ``; this will " -"break on multi-platform builds since the platform independent headers under :" -"option:`prefix <--prefix>` include the platform specific headers from :" -"option:`exec_prefix <--exec-prefix>`." +"break on multi-platform builds since the platform independent headers " +"under :option:`prefix <--prefix>` include the platform specific headers " +"from :option:`exec_prefix <--exec-prefix>`." msgstr "" #: c-api/intro.rst:95 @@ -167,6 +174,21 @@ msgid "" "item defined in the module file. Example::" msgstr "" +#: c-api/intro.rst:119 +msgid "" +"static struct PyModuleDef spam_module = {\n" +" PyModuleDef_HEAD_INIT,\n" +" .m_name = \"spam\",\n" +" ...\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_spam(void)\n" +"{\n" +" return PyModule_Create(&spam_module);\n" +"}" +msgstr "" + #: c-api/intro.rst:134 msgid "Return the absolute value of ``x``." msgstr "" @@ -193,15 +215,19 @@ msgstr "" #: c-api/intro.rst:151 msgid "" -"If Python is :ref:`built in debug mode ` (if the :c:macro:" -"`Py_DEBUG` macro is defined), the :c:macro:`Py_ALWAYS_INLINE` macro does " -"nothing." +"If Python is :ref:`built in debug mode ` (if " +"the :c:macro:`Py_DEBUG` macro is defined), the :c:macro:`Py_ALWAYS_INLINE` " +"macro does nothing." msgstr "" #: c-api/intro.rst:154 msgid "It must be specified before the function return type. Usage::" msgstr "" +#: c-api/intro.rst:156 +msgid "static inline Py_ALWAYS_INLINE int random(void) { return 4; }" +msgstr "" + #: c-api/intro.rst:162 msgid "" "Argument must be a character or an integer in the range [-128, 127] or [0, " @@ -218,6 +244,10 @@ msgstr "" msgid "Example::" msgstr "" +#: c-api/intro.rst:172 +msgid "Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);" +msgstr "" + #: c-api/intro.rst:174 msgid "MSVC support was added." msgstr "" @@ -243,14 +273,18 @@ msgstr "" #: c-api/intro.rst:202 msgid "" "Disable inlining on a function. For example, it reduces the C stack " -"consumption: useful on LTO+PGO builds which heavily inline code (see :issue:" -"`33720`)." +"consumption: useful on LTO+PGO builds which heavily inline code " +"(see :issue:`33720`)." msgstr "" #: c-api/intro.rst:206 msgid "Usage::" msgstr "" +#: c-api/intro.rst:208 +msgid "Py_NO_INLINE static int random(void) { return 4; }" +msgstr "" + #: c-api/intro.rst:214 msgid "" "Convert ``x`` to a C string. E.g. ``Py_STRINGIFY(123)`` returns ``\"123\"``." @@ -304,6 +338,17 @@ msgid "" "without docstrings, as specified in :pep:`7`." msgstr "" +#: c-api/intro.rst:258 +msgid "" +"PyDoc_STRVAR(pop_doc, \"Remove and return the rightmost element.\");\n" +"\n" +"static PyMethodDef deque_methods[] = {\n" +" // ...\n" +" {\"pop\", (PyCFunction)deque_pop, METH_NOARGS, pop_doc},\n" +" // ...\n" +"}" +msgstr "" + #: c-api/intro.rst:268 msgid "" "Creates a docstring for the given input string or an empty string if " @@ -316,6 +361,15 @@ msgid "" "without docstrings, as specified in :pep:`7`." msgstr "" +#: c-api/intro.rst:276 +msgid "" +"static PyMethodDef pysqlite_row_methods[] = {\n" +" {\"keys\", (PyCFunction)pysqlite_row_keys, METH_NOARGS,\n" +" PyDoc_STR(\"Returns the keys of the row.\")},\n" +" {NULL, NULL}\n" +"};" +msgstr "" + #: c-api/intro.rst:286 msgid "Objects, Types and Reference Counts" msgstr "" @@ -328,20 +382,20 @@ msgid "" "are treated the same way by the Python language in most situations (e.g., " "assignments, scope rules, and argument passing), it is only fitting that " "they should be represented by a single C type. Almost all Python objects " -"live on the heap: you never declare an automatic or static variable of type :" -"c:type:`PyObject`, only pointer variables of type :c:expr:`PyObject*` can " -"be declared. The sole exception are the type objects; since these must " +"live on the heap: you never declare an automatic or static variable of " +"type :c:type:`PyObject`, only pointer variables of type :c:expr:`PyObject*` " +"can be declared. The sole exception are the type objects; since these must " "never be deallocated, they are typically static :c:type:`PyTypeObject` " "objects." msgstr "" #: c-api/intro.rst:301 msgid "" -"All Python objects (even Python integers) have a :dfn:`type` and a :dfn:" -"`reference count`. An object's type determines what kind of object it is (e." -"g., an integer, a list, or a user-defined function; there are many more as " -"explained in :ref:`types`). For each of the well-known types there is a " -"macro to check whether an object is of that type; for instance, " +"All Python objects (even Python integers) have a :dfn:`type` and " +"a :dfn:`reference count`. An object's type determines what kind of object " +"it is (e.g., an integer, a list, or a user-defined function; there are many " +"more as explained in :ref:`types`). For each of the well-known types there " +"is a macro to check whether an object is of that type; for instance, " "``PyList_Check(a)`` is true if (and only if) the object pointed to by *a* is " "a Python list." msgstr "" @@ -370,18 +424,18 @@ msgid "" "Reference counts are always manipulated explicitly. The normal way is to " "use the macro :c:func:`Py_INCREF` to take a new reference to an object (i.e. " "increment its reference count by one), and :c:func:`Py_DECREF` to release " -"that reference (i.e. decrement the reference count by one). The :c:func:" -"`Py_DECREF` macro is considerably more complex than the incref one, since it " -"must check whether the reference count becomes zero and then cause the " -"object's deallocator to be called. The deallocator is a function pointer " -"contained in the object's type structure. The type-specific deallocator " -"takes care of releasing references for other objects contained in the object " -"if this is a compound object type, such as a list, as well as performing any " -"additional finalization that's needed. There's no chance that the reference " -"count can overflow; at least as many bits are used to hold the reference " -"count as there are distinct memory locations in virtual memory (assuming " -"``sizeof(Py_ssize_t) >= sizeof(void*)``). Thus, the reference count " -"increment is a simple operation." +"that reference (i.e. decrement the reference count by one). " +"The :c:func:`Py_DECREF` macro is considerably more complex than the incref " +"one, since it must check whether the reference count becomes zero and then " +"cause the object's deallocator to be called. The deallocator is a function " +"pointer contained in the object's type structure. The type-specific " +"deallocator takes care of releasing references for other objects contained " +"in the object if this is a compound object type, such as a list, as well as " +"performing any additional finalization that's needed. There's no chance " +"that the reference count can overflow; at least as many bits are used to " +"hold the reference count as there are distinct memory locations in virtual " +"memory (assuming ``sizeof(Py_ssize_t) >= sizeof(void*)``). Thus, the " +"reference count increment is a simple operation." msgstr "" #: c-api/intro.rst:347 @@ -409,8 +463,8 @@ msgid "" "conceivably remove the object from the list, releasing that reference, and " "possibly deallocating it. The real danger is that innocent-looking " "operations may invoke arbitrary Python code which could do this; there is a " -"code path which allows control to flow back to the user from a :c:func:" -"`Py_DECREF`, so almost any operation is potentially dangerous." +"code path which allows control to flow back to the user from " +"a :c:func:`Py_DECREF`, so almost any operation is potentially dangerous." msgstr "" #: c-api/intro.rst:371 @@ -435,13 +489,13 @@ msgid "" "shared). \"Owning a reference\" means being responsible for calling " "Py_DECREF on it when the reference is no longer needed. Ownership can also " "be transferred, meaning that the code that receives ownership of the " -"reference then becomes responsible for eventually releasing it by calling :c:" -"func:`Py_DECREF` or :c:func:`Py_XDECREF` when it's no longer needed---or " -"passing on this responsibility (usually to its caller). When a function " -"passes ownership of a reference on to its caller, the caller is said to " -"receive a *new* reference. When no ownership is transferred, the caller is " -"said to *borrow* the reference. Nothing needs to be done for a :term:" -"`borrowed reference`." +"reference then becomes responsible for eventually releasing it by " +"calling :c:func:`Py_DECREF` or :c:func:`Py_XDECREF` when it's no longer " +"needed---or passing on this responsibility (usually to its caller). When a " +"function passes ownership of a reference on to its caller, the caller is " +"said to receive a *new* reference. When no ownership is transferred, the " +"caller is said to *borrow* the reference. Nothing needs to be done for " +"a :term:`borrowed reference`." msgstr "" #: c-api/intro.rst:397 @@ -455,14 +509,24 @@ msgstr "" #: c-api/intro.rst:407 msgid "" -"Few functions steal references; the two notable exceptions are :c:func:" -"`PyList_SetItem` and :c:func:`PyTuple_SetItem`, which steal a reference to " -"the item (but not to the tuple or list into which the item is put!). These " -"functions were designed to steal a reference because of a common idiom for " -"populating a tuple or list with newly created objects; for example, the code " -"to create the tuple ``(1, 2, \"three\")`` could look like this (forgetting " -"about error handling for the moment; a better way to code this is shown " -"below)::" +"Few functions steal references; the two notable exceptions " +"are :c:func:`PyList_SetItem` and :c:func:`PyTuple_SetItem`, which steal a " +"reference to the item (but not to the tuple or list into which the item is " +"put!). These functions were designed to steal a reference because of a " +"common idiom for populating a tuple or list with newly created objects; for " +"example, the code to create the tuple ``(1, 2, \"three\")`` could look like " +"this (forgetting about error handling for the moment; a better way to code " +"this is shown below)::" +msgstr "" + +#: c-api/intro.rst:415 +msgid "" +"PyObject *t;\n" +"\n" +"t = PyTuple_New(3);\n" +"PyTuple_SetItem(t, 0, PyLong_FromLong(1L));\n" +"PyTuple_SetItem(t, 1, PyLong_FromLong(2L));\n" +"PyTuple_SetItem(t, 2, PyUnicode_FromString(\"three\"));" msgstr "" #: c-api/intro.rst:422 @@ -477,23 +541,32 @@ msgstr "" msgid "" "Incidentally, :c:func:`PyTuple_SetItem` is the *only* way to set tuple " "items; :c:func:`PySequence_SetItem` and :c:func:`PyObject_SetItem` refuse to " -"do this since tuples are an immutable data type. You should only use :c:" -"func:`PyTuple_SetItem` for tuples that you are creating yourself." +"do this since tuples are an immutable data type. You should only " +"use :c:func:`PyTuple_SetItem` for tuples that you are creating yourself." msgstr "" #: c-api/intro.rst:432 msgid "" -"Equivalent code for populating a list can be written using :c:func:" -"`PyList_New` and :c:func:`PyList_SetItem`." +"Equivalent code for populating a list can be written " +"using :c:func:`PyList_New` and :c:func:`PyList_SetItem`." msgstr "" #: c-api/intro.rst:435 msgid "" "However, in practice, you will rarely use these ways of creating and " -"populating a tuple or list. There's a generic function, :c:func:" -"`Py_BuildValue`, that can create most common objects from C values, directed " -"by a :dfn:`format string`. For example, the above two blocks of code could " -"be replaced by the following (which also takes care of the error checking)::" +"populating a tuple or list. There's a generic " +"function, :c:func:`Py_BuildValue`, that can create most common objects from " +"C values, directed by a :dfn:`format string`. For example, the above two " +"blocks of code could be replaced by the following (which also takes care of " +"the error checking)::" +msgstr "" + +#: c-api/intro.rst:441 +msgid "" +"PyObject *tuple, *list;\n" +"\n" +"tuple = Py_BuildValue(\"(iis)\", 1, 2, \"three\");\n" +"list = Py_BuildValue(\"[iis]\", 1, 2, \"three\");" msgstr "" #: c-api/intro.rst:446 @@ -507,6 +580,30 @@ msgid "" "sequence) to a given item::" msgstr "" +#: c-api/intro.rst:453 +msgid "" +"int\n" +"set_all(PyObject *target, PyObject *item)\n" +"{\n" +" Py_ssize_t i, n;\n" +"\n" +" n = PyObject_Length(target);\n" +" if (n < 0)\n" +" return -1;\n" +" for (i = 0; i < n; i++) {\n" +" PyObject *index = PyLong_FromSsize_t(i);\n" +" if (!index)\n" +" return -1;\n" +" if (PyObject_SetItem(target, index, item) < 0) {\n" +" Py_DECREF(index);\n" +" return -1;\n" +" }\n" +" Py_DECREF(index);\n" +" }\n" +" return 0;\n" +"}" +msgstr "" + #: c-api/intro.rst:476 msgid "" "The situation is slightly different for function return values. While " @@ -538,6 +635,62 @@ msgid "" "and once using :c:func:`PySequence_GetItem`. ::" msgstr "" +#: c-api/intro.rst:501 +msgid "" +"long\n" +"sum_list(PyObject *list)\n" +"{\n" +" Py_ssize_t i, n;\n" +" long total = 0, value;\n" +" PyObject *item;\n" +"\n" +" n = PyList_Size(list);\n" +" if (n < 0)\n" +" return -1; /* Not a list */\n" +" for (i = 0; i < n; i++) {\n" +" item = PyList_GetItem(list, i); /* Can't fail */\n" +" if (!PyLong_Check(item)) continue; /* Skip non-integers */\n" +" value = PyLong_AsLong(item);\n" +" if (value == -1 && PyErr_Occurred())\n" +" /* Integer too big to fit in a C long, bail out */\n" +" return -1;\n" +" total += value;\n" +" }\n" +" return total;\n" +"}" +msgstr "" + +#: c-api/intro.rst:527 +msgid "" +"long\n" +"sum_sequence(PyObject *sequence)\n" +"{\n" +" Py_ssize_t i, n;\n" +" long total = 0, value;\n" +" PyObject *item;\n" +" n = PySequence_Length(sequence);\n" +" if (n < 0)\n" +" return -1; /* Has no length */\n" +" for (i = 0; i < n; i++) {\n" +" item = PySequence_GetItem(sequence, i);\n" +" if (item == NULL)\n" +" return -1; /* Not a sequence, or other failure */\n" +" if (PyLong_Check(item)) {\n" +" value = PyLong_AsLong(item);\n" +" Py_DECREF(item);\n" +" if (value == -1 && PyErr_Occurred())\n" +" /* Integer too big to fit in a C long, bail out */\n" +" return -1;\n" +" total += value;\n" +" }\n" +" else {\n" +" Py_DECREF(item); /* Discard reference ownership */\n" +" }\n" +" }\n" +" return total;\n" +"}" +msgstr "" + #: c-api/intro.rst:561 msgid "Types" msgstr "" @@ -545,12 +698,12 @@ msgstr "" #: c-api/intro.rst:563 msgid "" "There are few other data types that play a significant role in the Python/C " -"API; most are simple C types such as :c:expr:`int`, :c:expr:`long`, :c:expr:" -"`double` and :c:expr:`char*`. A few structure types are used to describe " -"static tables used to list the functions exported by a module or the data " -"attributes of a new object type, and another is used to describe the value " -"of a complex number. These will be discussed together with the functions " -"that use them." +"API; most are simple C types such " +"as :c:expr:`int`, :c:expr:`long`, :c:expr:`double` and :c:expr:`char*`. A " +"few structure types are used to describe static tables used to list the " +"functions exported by a module or the data attributes of a new object type, " +"and another is used to describe the value of a complex number. These will " +"be discussed together with the functions that use them." msgstr "" #: c-api/intro.rst:573 @@ -593,40 +746,40 @@ msgstr "" msgid "" "Exception state is maintained in per-thread storage (this is equivalent to " "using global storage in an unthreaded application). A thread can be in one " -"of two states: an exception has occurred, or not. The function :c:func:" -"`PyErr_Occurred` can be used to check for this: it returns a borrowed " -"reference to the exception type object when an exception has occurred, and " -"``NULL`` otherwise. There are a number of functions to set the exception " -"state: :c:func:`PyErr_SetString` is the most common (though not the most " -"general) function to set the exception state, and :c:func:`PyErr_Clear` " -"clears the exception state." +"of two states: an exception has occurred, or not. The " +"function :c:func:`PyErr_Occurred` can be used to check for this: it returns " +"a borrowed reference to the exception type object when an exception has " +"occurred, and ``NULL`` otherwise. There are a number of functions to set " +"the exception state: :c:func:`PyErr_SetString` is the most common (though " +"not the most general) function to set the exception state, " +"and :c:func:`PyErr_Clear` clears the exception state." msgstr "" #: c-api/intro.rst:617 msgid "" "The full exception state consists of three objects (all of which can be " "``NULL``): the exception type, the corresponding exception value, and the " -"traceback. These have the same meanings as the Python result of ``sys." -"exc_info()``; however, they are not the same: the Python objects represent " -"the last exception being handled by a Python :keyword:`try` ... :keyword:" -"`except` statement, while the C level exception state only exists while an " -"exception is being passed on between C functions until it reaches the Python " -"bytecode interpreter's main loop, which takes care of transferring it to " -"``sys.exc_info()`` and friends." +"traceback. These have the same meanings as the Python result of " +"``sys.exc_info()``; however, they are not the same: the Python objects " +"represent the last exception being handled by a " +"Python :keyword:`try` ... :keyword:`except` statement, while the C level " +"exception state only exists while an exception is being passed on between C " +"functions until it reaches the Python bytecode interpreter's main loop, " +"which takes care of transferring it to ``sys.exc_info()`` and friends." msgstr "" #: c-api/intro.rst:629 msgid "" "Note that starting with Python 1.5, the preferred, thread-safe way to access " -"the exception state from Python code is to call the function :func:`sys." -"exc_info`, which returns the per-thread exception state for Python code. " -"Also, the semantics of both ways to access the exception state have changed " -"so that a function which catches an exception will save and restore its " -"thread's exception state so as to preserve the exception state of its " -"caller. This prevents common bugs in exception handling code caused by an " -"innocent-looking function overwriting the exception being handled; it also " -"reduces the often unwanted lifetime extension for objects that are " -"referenced by the stack frames in the traceback." +"the exception state from Python code is to call the " +"function :func:`sys.exc_info`, which returns the per-thread exception state " +"for Python code. Also, the semantics of both ways to access the exception " +"state have changed so that a function which catches an exception will save " +"and restore its thread's exception state so as to preserve the exception " +"state of its caller. This prevents common bugs in exception handling code " +"caused by an innocent-looking function overwriting the exception being " +"handled; it also reduces the often unwanted lifetime extension for objects " +"that are referenced by the stack frames in the traceback." msgstr "" #: c-api/intro.rst:640 @@ -649,21 +802,77 @@ msgid "" "why you like Python, we show the equivalent Python code::" msgstr "" +#: c-api/intro.rst:655 +msgid "" +"def incr_item(dict, key):\n" +" try:\n" +" item = dict[key]\n" +" except KeyError:\n" +" item = 0\n" +" dict[key] = item + 1" +msgstr "" + #: c-api/intro.rst:664 msgid "Here is the corresponding C code, in all its glory::" msgstr "" +#: c-api/intro.rst:666 +msgid "" +"int\n" +"incr_item(PyObject *dict, PyObject *key)\n" +"{\n" +" /* Objects all initialized to NULL for Py_XDECREF */\n" +" PyObject *item = NULL, *const_one = NULL, *incremented_item = NULL;\n" +" int rv = -1; /* Return value initialized to -1 (failure) */\n" +"\n" +" item = PyObject_GetItem(dict, key);\n" +" if (item == NULL) {\n" +" /* Handle KeyError only: */\n" +" if (!PyErr_ExceptionMatches(PyExc_KeyError))\n" +" goto error;\n" +"\n" +" /* Clear the error and use zero: */\n" +" PyErr_Clear();\n" +" item = PyLong_FromLong(0L);\n" +" if (item == NULL)\n" +" goto error;\n" +" }\n" +" const_one = PyLong_FromLong(1L);\n" +" if (const_one == NULL)\n" +" goto error;\n" +"\n" +" incremented_item = PyNumber_Add(item, const_one);\n" +" if (incremented_item == NULL)\n" +" goto error;\n" +"\n" +" if (PyObject_SetItem(dict, key, incremented_item) < 0)\n" +" goto error;\n" +" rv = 0; /* Success */\n" +" /* Continue with cleanup code */\n" +"\n" +" error:\n" +" /* Cleanup code, shared by success and failure path */\n" +"\n" +" /* Use Py_XDECREF() to ignore NULL references */\n" +" Py_XDECREF(item);\n" +" Py_XDECREF(const_one);\n" +" Py_XDECREF(incremented_item);\n" +"\n" +" return rv; /* -1 for error, 0 for success */\n" +"}" +msgstr "" + #: c-api/intro.rst:716 msgid "" "This example represents an endorsed use of the ``goto`` statement in C! It " -"illustrates the use of :c:func:`PyErr_ExceptionMatches` and :c:func:" -"`PyErr_Clear` to handle specific exceptions, and the use of :c:func:" -"`Py_XDECREF` to dispose of owned references that may be ``NULL`` (note the " -"``'X'`` in the name; :c:func:`Py_DECREF` would crash when confronted with a " -"``NULL`` reference). It is important that the variables used to hold owned " -"references are initialized to ``NULL`` for this to work; likewise, the " -"proposed return value is initialized to ``-1`` (failure) and only set to " -"success after the final call made is successful." +"illustrates the use of :c:func:`PyErr_ExceptionMatches` " +"and :c:func:`PyErr_Clear` to handle specific exceptions, and the use " +"of :c:func:`Py_XDECREF` to dispose of owned references that may be ``NULL`` " +"(note the ``'X'`` in the name; :c:func:`Py_DECREF` would crash when " +"confronted with a ``NULL`` reference). It is important that the variables " +"used to hold owned references are initialized to ``NULL`` for this to work; " +"likewise, the proposed return value is initialized to ``-1`` (failure) and " +"only set to success after the final call made is successful." msgstr "" #: c-api/intro.rst:730 @@ -688,10 +897,11 @@ msgstr "" #: c-api/intro.rst:750 msgid "" -":c:func:`Py_Initialize` does not set the \"script argument list\" (``sys." -"argv``). If this variable is needed by Python code that will be executed " -"later, setting :c:member:`PyConfig.argv` and :c:member:`PyConfig.parse_argv` " -"must be set: see :ref:`Python Initialization Configuration `." +":c:func:`Py_Initialize` does not set the \"script argument list\" " +"(``sys.argv``). If this variable is needed by Python code that will be " +"executed later, setting :c:member:`PyConfig.argv` " +"and :c:member:`PyConfig.parse_argv` must be set: see :ref:`Python " +"Initialization Configuration `." msgstr "" #: c-api/intro.rst:755 @@ -711,8 +921,8 @@ msgid "" "For instance, if the Python executable is found in :file:`/usr/local/bin/" "python`, it will assume that the libraries are in :file:`/usr/local/lib/" "python{X.Y}`. (In fact, this particular path is also the \"fallback\" " -"location, used when no executable file named :file:`python` is found along :" -"envvar:`PATH`.) The user can override this behavior by setting the " +"location, used when no executable file named :file:`python` is found " +"along :envvar:`PATH`.) The user can override this behavior by setting the " "environment variable :envvar:`PYTHONHOME`, or insert additional directories " "in front of the standard path by setting :envvar:`PYTHONPATH`." msgstr "" @@ -723,23 +933,24 @@ msgid "" "``Py_SetProgramName(file)`` *before* calling :c:func:`Py_Initialize`. Note " "that :envvar:`PYTHONHOME` still overrides this and :envvar:`PYTHONPATH` is " "still inserted in front of the standard path. An application that requires " -"total control has to provide its own implementation of :c:func:" -"`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, and :c:" -"func:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`)." +"total control has to provide its own implementation " +"of :c:func:`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, " +"and :c:func:`Py_GetProgramFullPath` (all defined in :file:`Modules/" +"getpath.c`)." msgstr "" #: c-api/intro.rst:789 msgid "" "Sometimes, it is desirable to \"uninitialize\" Python. For instance, the " -"application may want to start over (make another call to :c:func:" -"`Py_Initialize`) or the application is simply done with its use of Python " -"and wants to free memory allocated by Python. This can be accomplished by " -"calling :c:func:`Py_FinalizeEx`. The function :c:func:`Py_IsInitialized` " -"returns true if Python is currently in the initialized state. More " -"information about these functions is given in a later chapter. Notice that :" -"c:func:`Py_FinalizeEx` does *not* free all memory allocated by the Python " -"interpreter, e.g. memory allocated by extension modules currently cannot be " -"released." +"application may want to start over (make another call " +"to :c:func:`Py_Initialize`) or the application is simply done with its use " +"of Python and wants to free memory allocated by Python. This can be " +"accomplished by calling :c:func:`Py_FinalizeEx`. The " +"function :c:func:`Py_IsInitialized` returns true if Python is currently in " +"the initialized state. More information about these functions is given in a " +"later chapter. Notice that :c:func:`Py_FinalizeEx` does *not* free all " +"memory allocated by the Python interpreter, e.g. memory allocated by " +"extension modules currently cannot be released." msgstr "" #: c-api/intro.rst:803 @@ -755,11 +966,11 @@ msgstr "" #: c-api/intro.rst:809 msgid "" -"A full list of the various types of debugging builds is in the file :file:" -"`Misc/SpecialBuilds.txt` in the Python source distribution. Builds are " -"available that support tracing of reference counts, debugging the memory " -"allocator, or low-level profiling of the main interpreter loop. Only the " -"most frequently used builds will be described in the remainder of this " +"A full list of the various types of debugging builds is in the " +"file :file:`Misc/SpecialBuilds.txt` in the Python source distribution. " +"Builds are available that support tracing of reference counts, debugging the " +"memory allocator, or low-level profiling of the main interpreter loop. Only " +"the most frequently used builds will be described in the remainder of this " "section." msgstr "" @@ -767,11 +978,11 @@ msgstr "" msgid "" "Compiling the interpreter with the :c:macro:`!Py_DEBUG` macro defined " "produces what is generally meant by :ref:`a debug build of Python `. :c:macro:`!Py_DEBUG` is enabled in the Unix build by adding :option:" -"`--with-pydebug` to the :file:`./configure` command. It is also implied by " -"the presence of the not-Python-specific :c:macro:`!_DEBUG` macro. When :c:" -"macro:`!Py_DEBUG` is enabled in the Unix build, compiler optimization is " -"disabled." +"build>`. :c:macro:`!Py_DEBUG` is enabled in the Unix build by " +"adding :option:`--with-pydebug` to the :file:`./configure` command. It is " +"also implied by the presence of the not-Python-specific :c:macro:`!_DEBUG` " +"macro. When :c:macro:`!Py_DEBUG` is enabled in the Unix build, compiler " +"optimization is disabled." msgstr "" #: c-api/intro.rst:825 @@ -782,12 +993,12 @@ msgstr "" #: c-api/intro.rst:828 msgid "" -"Defining :c:macro:`Py_TRACE_REFS` enables reference tracing (see the :option:" -"`configure --with-trace-refs option <--with-trace-refs>`). When defined, a " -"circular doubly linked list of active objects is maintained by adding two " -"extra fields to every :c:type:`PyObject`. Total allocations are tracked as " -"well. Upon exit, all existing references are printed. (In interactive mode " -"this happens after every statement run by the interpreter.)" +"Defining :c:macro:`Py_TRACE_REFS` enables reference tracing (see " +"the :option:`configure --with-trace-refs option <--with-trace-refs>`). When " +"defined, a circular doubly linked list of active objects is maintained by " +"adding two extra fields to every :c:type:`PyObject`. Total allocations are " +"tracked as well. Upon exit, all existing references are printed. (In " +"interactive mode this happens after every statement run by the interpreter.)" msgstr "" #: c-api/intro.rst:835 diff --git a/c-api/iter.po b/c-api/iter.po index 479bf149..b9de5ccb 100644 --- a/c-api/iter.po +++ b/c-api/iter.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -26,8 +27,9 @@ msgstr "" #: c-api/iter.rst:12 msgid "" -"Return non-zero if the object *o* can be safely passed to :c:func:" -"`PyIter_Next`, and ``0`` otherwise. This function always succeeds." +"Return non-zero if the object *o* can be safely passed " +"to :c:func:`PyIter_Next`, and ``0`` otherwise. This function always " +"succeeds." msgstr "" #: c-api/iter.rst:17 @@ -51,6 +53,32 @@ msgid "" "something like this::" msgstr "" +#: c-api/iter.rst:33 +msgid "" +"PyObject *iterator = PyObject_GetIter(obj);\n" +"PyObject *item;\n" +"\n" +"if (iterator == NULL) {\n" +" /* propagate error */\n" +"}\n" +"\n" +"while ((item = PyIter_Next(iterator))) {\n" +" /* do something with item */\n" +" ...\n" +" /* release reference when done */\n" +" Py_DECREF(item);\n" +"}\n" +"\n" +"Py_DECREF(iterator);\n" +"\n" +"if (PyErr_Occurred()) {\n" +" /* propagate error */\n" +"}\n" +"else {\n" +" /* continue doing useful work */\n" +"}" +msgstr "" + #: c-api/iter.rst:59 msgid "" "The enum value used to represent different results of :c:func:`PyIter_Send`." diff --git a/c-api/iterator.po b/c-api/iterator.po index a91c2f15..811103c8 100644 --- a/c-api/iterator.po +++ b/c-api/iterator.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -23,10 +24,10 @@ msgstr "" #: c-api/iterator.rst:8 msgid "" "Python provides two general-purpose iterator objects. The first, a sequence " -"iterator, works with an arbitrary sequence supporting the :meth:`~object." -"__getitem__` method. The second works with a callable object and a sentinel " -"value, calling the callable for each item in the sequence, and ending the " -"iteration when the sentinel value is returned." +"iterator, works with an arbitrary sequence supporting " +"the :meth:`~object.__getitem__` method. The second works with a callable " +"object and a sentinel value, calling the callable for each item in the " +"sequence, and ending the iteration when the sentinel value is returned." msgstr "" #: c-api/iterator.rst:17 diff --git a/c-api/list.po b/c-api/list.po index 5df947f6..69f41c40 100644 --- a/c-api/list.po +++ b/c-api/list.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -49,9 +50,9 @@ msgstr "" #: c-api/list.rst:40 msgid "" "If *len* is greater than zero, the returned list object's items are set to " -"``NULL``. Thus you cannot use abstract API functions such as :c:func:" -"`PySequence_SetItem` or expose the object to Python code before setting all " -"items to a real object with :c:func:`PyList_SetItem`." +"``NULL``. Thus you cannot use abstract API functions such " +"as :c:func:`PySequence_SetItem` or expose the object to Python code before " +"setting all items to a real object with :c:func:`PyList_SetItem`." msgstr "" #: c-api/list.rst:50 @@ -97,9 +98,10 @@ msgstr "" #: c-api/list.rst:91 msgid "" -"This macro \"steals\" a reference to *item*, and, unlike :c:func:" -"`PyList_SetItem`, does *not* discard a reference to any item that is being " -"replaced; any reference in *list* at position *i* will be leaked." +"This macro \"steals\" a reference to *item*, and, " +"unlike :c:func:`PyList_SetItem`, does *not* discard a reference to any item " +"that is being replaced; any reference in *list* at position *i* will be " +"leaked." msgstr "" #: c-api/list.rst:99 diff --git a/c-api/long.po b/c-api/long.po index 371927e5..07e8b241 100644 --- a/c-api/long.po +++ b/c-api/long.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -44,8 +45,8 @@ msgstr "" #: c-api/long.rst:29 msgid "" -"Return true if its argument is a :c:type:`PyLongObject` or a subtype of :c:" -"type:`PyLongObject`. This function always succeeds." +"Return true if its argument is a :c:type:`PyLongObject` or a subtype " +"of :c:type:`PyLongObject`. This function always succeeds." msgstr "" #: c-api/long.rst:35 @@ -119,8 +120,8 @@ msgstr "" #: c-api/long.rst:97 msgid "" -"Python methods :meth:`int.to_bytes` and :meth:`int.from_bytes` to convert a :" -"c:type:`PyLongObject` to/from an array of bytes in base ``256``. You can " +"Python methods :meth:`int.to_bytes` and :meth:`int.from_bytes` to convert " +"a :c:type:`PyLongObject` to/from an array of bytes in base ``256``. You can " "call those from C using :c:func:`PyObject_CallMethod`." msgstr "" @@ -145,8 +146,8 @@ msgstr "" #: c-api/long.rst:127 msgid "" -"Raise :exc:`OverflowError` if the value of *obj* is out of range for a :c:" -"expr:`long`." +"Raise :exc:`OverflowError` if the value of *obj* is out of range for " +"a :c:expr:`long`." msgstr "" #: c-api/long.rst:150 c-api/long.rst:191 c-api/long.rst:214 @@ -163,10 +164,11 @@ msgstr "" #: c-api/long.rst:145 msgid "" -"If the value of *obj* is greater than :c:macro:`LONG_MAX` or less than :c:" -"macro:`LONG_MIN`, set *\\*overflow* to ``1`` or ``-1``, respectively, and " -"return ``-1``; otherwise, set *\\*overflow* to ``0``. If any other " -"exception occurs set *\\*overflow* to ``0`` and return ``-1`` as usual." +"If the value of *obj* is greater than :c:macro:`LONG_MAX` or less " +"than :c:macro:`LONG_MIN`, set *\\*overflow* to ``1`` or ``-1``, " +"respectively, and return ``-1``; otherwise, set *\\*overflow* to ``0``. If " +"any other exception occurs set *\\*overflow* to ``0`` and return ``-1`` as " +"usual." msgstr "" #: c-api/long.rst:182 @@ -178,16 +180,17 @@ msgstr "" #: c-api/long.rst:168 msgid "" -"Raise :exc:`OverflowError` if the value of *obj* is out of range for a :c:" -"expr:`long long`." +"Raise :exc:`OverflowError` if the value of *obj* is out of range for " +"a :c:expr:`long long`." msgstr "" #: c-api/long.rst:186 msgid "" -"If the value of *obj* is greater than :c:macro:`LLONG_MAX` or less than :c:" -"macro:`LLONG_MIN`, set *\\*overflow* to ``1`` or ``-1``, respectively, and " -"return ``-1``; otherwise, set *\\*overflow* to ``0``. If any other " -"exception occurs set *\\*overflow* to ``0`` and return ``-1`` as usual." +"If the value of *obj* is greater than :c:macro:`LLONG_MAX` or less " +"than :c:macro:`LLONG_MIN`, set *\\*overflow* to ``1`` or ``-1``, " +"respectively, and return ``-1``; otherwise, set *\\*overflow* to ``0``. If " +"any other exception occurs set *\\*overflow* to ``0`` and return ``-1`` as " +"usual." msgstr "" #: c-api/long.rst:208 @@ -198,8 +201,8 @@ msgstr "" #: c-api/long.rst:211 msgid "" -"Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" -"type:`Py_ssize_t`." +"Raise :exc:`OverflowError` if the value of *pylong* is out of range for " +"a :c:type:`Py_ssize_t`." msgstr "" #: c-api/long.rst:223 @@ -210,8 +213,8 @@ msgstr "" #: c-api/long.rst:226 msgid "" -"Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" -"expr:`unsigned long`." +"Raise :exc:`OverflowError` if the value of *pylong* is out of range for " +"a :c:expr:`unsigned long`." msgstr "" #: c-api/long.rst:229 @@ -228,8 +231,8 @@ msgstr "" #: c-api/long.rst:242 msgid "" -"Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" -"type:`size_t`." +"Raise :exc:`OverflowError` if the value of *pylong* is out of range for " +"a :c:type:`size_t`." msgstr "" #: c-api/long.rst:245 @@ -246,8 +249,8 @@ msgstr "" #: c-api/long.rst:257 msgid "" -"Raise :exc:`OverflowError` if the value of *pylong* is out of range for an :" -"c:expr:`unsigned long long`." +"Raise :exc:`OverflowError` if the value of *pylong* is out of range for " +"an :c:expr:`unsigned long long`." msgstr "" #: c-api/long.rst:260 @@ -264,8 +267,9 @@ msgstr "" #: c-api/long.rst:269 msgid "" "Return a C :c:expr:`unsigned long` representation of *obj*. If *obj* is not " -"an instance of :c:type:`PyLongObject`, first call its :meth:`~object." -"__index__` method (if present) to convert it to a :c:type:`PyLongObject`." +"an instance of :c:type:`PyLongObject`, first call " +"its :meth:`~object.__index__` method (if present) to convert it to " +"a :c:type:`PyLongObject`." msgstr "" #: c-api/long.rst:273 @@ -283,8 +287,9 @@ msgstr "" #: c-api/long.rst:288 msgid "" "Return a C :c:expr:`unsigned long long` representation of *obj*. If *obj* " -"is not an instance of :c:type:`PyLongObject`, first call its :meth:`~object." -"__index__` method (if present) to convert it to a :c:type:`PyLongObject`." +"is not an instance of :c:type:`PyLongObject`, first call " +"its :meth:`~object.__index__` method (if present) to convert it to " +"a :c:type:`PyLongObject`." msgstr "" #: c-api/long.rst:293 @@ -307,8 +312,8 @@ msgstr "" #: c-api/long.rst:311 msgid "" -"Raise :exc:`OverflowError` if the value of *pylong* is out of range for a :c:" -"expr:`double`." +"Raise :exc:`OverflowError` if the value of *pylong* is out of range for " +"a :c:expr:`double`." msgstr "" #: c-api/long.rst:314 @@ -320,8 +325,8 @@ msgstr "" msgid "" "Convert a Python integer *pylong* to a C :c:expr:`void` pointer. If *pylong* " "cannot be converted, an :exc:`OverflowError` will be raised. This is only " -"assured to produce a usable :c:expr:`void` pointer for values created with :" -"c:func:`PyLong_FromVoidPtr`." +"assured to produce a usable :c:expr:`void` pointer for values created " +"with :c:func:`PyLong_FromVoidPtr`." msgstr "" #: c-api/long.rst:324 @@ -330,35 +335,46 @@ msgid "" msgstr "" #: c-api/long.rst:329 +msgid "" +"On success, return a read only :term:`named tuple`, that holds information " +"about Python's internal representation of integers. See :data:`sys.int_info` " +"for description of individual fields." +msgstr "" + +#: c-api/long.rst:333 +msgid "On failure, return ``NULL`` with an exception set." +msgstr "" + +#: c-api/long.rst:340 msgid "Return 1 if *op* is compact, 0 otherwise." msgstr "" -#: c-api/long.rst:331 +#: c-api/long.rst:342 msgid "" "This function makes it possible for performance-critical code to implement a " -"“fast path” for small integers. For compact values use :c:func:" -"`PyUnstable_Long_CompactValue`; for others fall back to a :c:func:" -"`PyLong_As* ` function or :c:func:`calling " +"“fast path” for small integers. For compact values " +"use :c:func:`PyUnstable_Long_CompactValue`; for others fall back to " +"a :c:func:`PyLong_As* ` function or :c:func:`calling " "` :meth:`int.to_bytes`." msgstr "" -#: c-api/long.rst:337 +#: c-api/long.rst:348 msgid "The speedup is expected to be negligible for most users." msgstr "" -#: c-api/long.rst:339 +#: c-api/long.rst:350 msgid "" "Exactly what values are considered compact is an implementation detail and " "is subject to change." msgstr "" -#: c-api/long.rst:344 +#: c-api/long.rst:358 msgid "" "If *op* is compact, as determined by :c:func:`PyUnstable_Long_IsCompact`, " "return its value." msgstr "" -#: c-api/long.rst:347 +#: c-api/long.rst:361 msgid "Otherwise, the return value is undefined." msgstr "" diff --git a/c-api/mapping.po b/c-api/mapping.po index 2d9ecd31..cac7b06c 100644 --- a/c-api/mapping.po +++ b/c-api/mapping.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -22,8 +23,8 @@ msgstr "" #: c-api/mapping.rst:8 msgid "" -"See also :c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem` and :c:func:" -"`PyObject_DelItem`." +"See also :c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem` " +"and :c:func:`PyObject_DelItem`." msgstr "" #: c-api/mapping.rst:14 @@ -43,16 +44,16 @@ msgstr "" #: c-api/mapping.rst:31 msgid "" -"This is the same as :c:func:`PyObject_GetItem`, but *key* is specified as a :" -"c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"This is the same as :c:func:`PyObject_GetItem`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" #: c-api/mapping.rst:38 msgid "" -"This is the same as :c:func:`PyObject_SetItem`, but *key* is specified as a :" -"c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"This is the same as :c:func:`PyObject_SetItem`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" #: c-api/mapping.rst:45 @@ -61,9 +62,9 @@ msgstr "" #: c-api/mapping.rst:50 msgid "" -"This is the same as :c:func:`PyObject_DelItem`, but *key* is specified as a :" -"c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"This is the same as :c:func:`PyObject_DelItem`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" #: c-api/mapping.rst:57 @@ -76,15 +77,15 @@ msgstr "" #: c-api/mapping.rst:63 msgid "" "Exceptions which occur when this calls :meth:`~object.__getitem__` method " -"are silently ignored. For proper error handling, use :c:func:" -"`PyObject_GetItem()` instead." +"are silently ignored. For proper error handling, " +"use :c:func:`PyObject_GetItem()` instead." msgstr "" #: c-api/mapping.rst:70 msgid "" -"This is the same as :c:func:`PyMapping_HasKey`, but *key* is specified as a :" -"c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"This is the same as :c:func:`PyMapping_HasKey`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" #: c-api/mapping.rst:76 diff --git a/c-api/marshal.po b/c-api/marshal.po index 108d1bc0..96708f2e 100644 --- a/c-api/marshal.po +++ b/c-api/marshal.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -37,7 +38,7 @@ msgstr "" msgid "" "The module supports two versions of the data format: version 0 is the " "historical version, version 1 shares interned strings in the file, and upon " -"unmarshalling. Version 2 uses a binary format for floating point numbers. " +"unmarshalling. Version 2 uses a binary format for floating-point numbers. " "``Py_MARSHAL_VERSION`` indicates the current file format (currently 2)." msgstr "" @@ -50,8 +51,8 @@ msgstr "" #: c-api/marshal.rst:36 msgid "" -"This function can fail, in which case it sets the error indicator. Use :c:" -"func:`PyErr_Occurred` to check for that." +"This function can fail, in which case it sets the error indicator. " +"Use :c:func:`PyErr_Occurred` to check for that." msgstr "" #: c-api/marshal.rst:33 diff --git a/c-api/memory.po b/c-api/memory.po index 7b2acb72..f2b6b016 100644 --- a/c-api/memory.po +++ b/c-api/memory.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -60,13 +61,27 @@ msgstr "" #: c-api/memory.rst:49 msgid "" "To avoid memory corruption, extension writers should never try to operate on " -"Python objects with the functions exported by the C library: :c:func:" -"`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`. This will " -"result in mixed calls between the C allocator and the Python memory manager " -"with fatal consequences, because they implement different algorithms and " -"operate on different heaps. However, one may safely allocate and release " -"memory blocks with the C library allocator for individual purposes, as shown " -"in the following example::" +"Python objects with the functions exported by the C " +"library: :c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` " +"and :c:func:`free`. This will result in mixed calls between the C " +"allocator and the Python memory manager with fatal consequences, because " +"they implement different algorithms and operate on different heaps. " +"However, one may safely allocate and release memory blocks with the C " +"library allocator for individual purposes, as shown in the following " +"example::" +msgstr "" + +#: c-api/memory.rst:58 +msgid "" +"PyObject *res;\n" +"char *buf = (char *) malloc(BUFSIZ); /* for I/O */\n" +"\n" +"if (buf == NULL)\n" +" return PyErr_NoMemory();\n" +"...Do some I/O operation involving buf...\n" +"res = PyBytes_FromString(buf);\n" +"free(buf); /* malloc'ed */\n" +"return res;" msgstr "" #: c-api/memory.rst:68 @@ -123,8 +138,8 @@ msgid "" "allocation functions belonging to a given domain for only the purposes " "hinted by that domain (although this is the recommended practice). For " "example, one could use the memory returned by :c:func:`PyMem_RawMalloc` for " -"allocating Python objects or the memory returned by :c:func:" -"`PyObject_Malloc` for allocating memory for buffers." +"allocating Python objects or the memory returned " +"by :c:func:`PyObject_Malloc` for allocating memory for buffers." msgstr "" #: c-api/memory.rst:112 @@ -221,9 +236,9 @@ msgstr "" #: c-api/memory.rst:176 msgid "" -"Unless *p* is ``NULL``, it must have been returned by a previous call to :c:" -"func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc` or :c:func:" -"`PyMem_RawCalloc`." +"Unless *p* is ``NULL``, it must have been returned by a previous call " +"to :c:func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc` " +"or :c:func:`PyMem_RawCalloc`." msgstr "" #: c-api/memory.rst:180 @@ -235,9 +250,9 @@ msgstr "" #: c-api/memory.rst:186 msgid "" "Frees the memory block pointed to by *p*, which must have been returned by a " -"previous call to :c:func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc` or :c:" -"func:`PyMem_RawCalloc`. Otherwise, or if ``PyMem_RawFree(p)`` has been " -"called before, undefined behavior occurs." +"previous call to :c:func:`PyMem_RawMalloc`, :c:func:`PyMem_RawRealloc` " +"or :c:func:`PyMem_RawCalloc`. Otherwise, or if ``PyMem_RawFree(p)`` has " +"been called before, undefined behavior occurs." msgstr "" #: c-api/memory.rst:261 c-api/memory.rst:369 @@ -257,8 +272,8 @@ msgstr "" #: c-api/memory.rst:203 msgid "" -"The :ref:`default memory allocator ` uses the :" -"ref:`pymalloc memory allocator `." +"The :ref:`default memory allocator ` uses " +"the :ref:`pymalloc memory allocator `." msgstr "" #: c-api/memory.rst:320 @@ -295,8 +310,8 @@ msgstr "" #: c-api/memory.rst:247 msgid "" -"Unless *p* is ``NULL``, it must have been returned by a previous call to :c:" -"func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or :c:func:`PyMem_Calloc`." +"Unless *p* is ``NULL``, it must have been returned by a previous call " +"to :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or :c:func:`PyMem_Calloc`." msgstr "" #: c-api/memory.rst:250 @@ -308,9 +323,9 @@ msgstr "" #: c-api/memory.rst:256 msgid "" "Frees the memory block pointed to by *p*, which must have been returned by a " -"previous call to :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` or :c:func:" -"`PyMem_Calloc`. Otherwise, or if ``PyMem_Free(p)`` has been called before, " -"undefined behavior occurs." +"previous call to :c:func:`PyMem_Malloc`, :c:func:`PyMem_Realloc` " +"or :c:func:`PyMem_Calloc`. Otherwise, or if ``PyMem_Free(p)`` has been " +"called before, undefined behavior occurs." msgstr "" #: c-api/memory.rst:263 @@ -390,8 +405,8 @@ msgstr "" #: c-api/memory.rst:315 msgid "" -"The :ref:`default object allocator ` uses the :" -"ref:`pymalloc memory allocator `." +"The :ref:`default object allocator ` uses " +"the :ref:`pymalloc memory allocator `." msgstr "" #: c-api/memory.rst:328 @@ -417,9 +432,9 @@ msgstr "" #: c-api/memory.rst:355 msgid "" -"Unless *p* is ``NULL``, it must have been returned by a previous call to :c:" -"func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` or :c:func:" -"`PyObject_Calloc`." +"Unless *p* is ``NULL``, it must have been returned by a previous call " +"to :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` " +"or :c:func:`PyObject_Calloc`." msgstr "" #: c-api/memory.rst:358 @@ -431,9 +446,9 @@ msgstr "" #: c-api/memory.rst:364 msgid "" "Frees the memory block pointed to by *p*, which must have been returned by a " -"previous call to :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` or :c:" -"func:`PyObject_Calloc`. Otherwise, or if ``PyObject_Free(p)`` has been " -"called before, undefined behavior occurs." +"previous call to :c:func:`PyObject_Malloc`, :c:func:`PyObject_Realloc` " +"or :c:func:`PyObject_Calloc`. Otherwise, or if ``PyObject_Free(p)`` has " +"been called before, undefined behavior occurs." msgstr "" #: c-api/memory.rst:375 @@ -522,8 +537,9 @@ msgstr "" #: c-api/memory.rst:391 msgid "" -"``malloc``: system allocators from the standard C library, C functions: :c:" -"func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`." +"``malloc``: system allocators from the standard C library, C " +"functions: :c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` " +"and :c:func:`free`." msgstr "" #: c-api/memory.rst:393 @@ -600,8 +616,8 @@ msgstr "" #: c-api/memory.rst:425 msgid "" -"The :c:type:`!PyMemAllocator` structure was renamed to :c:type:" -"`PyMemAllocatorEx` and a new ``calloc`` field was added." +"The :c:type:`!PyMemAllocator` structure was renamed " +"to :c:type:`PyMemAllocatorEx` and a new ``calloc`` field was added." msgstr "" #: c-api/memory.rst:432 @@ -707,20 +723,20 @@ msgstr "" #: c-api/memory.rst:494 msgid "" -"It can be called after :c:func:`Py_PreInitialize` and before :c:func:" -"`Py_InitializeFromConfig` to install a custom memory allocator. There are no " -"restrictions over the installed allocator other than the ones imposed by the " -"domain (for instance, the Raw Domain allows the allocator to be called " -"without the GIL held). See :ref:`the section on allocator domains ` for more information." +"It can be called after :c:func:`Py_PreInitialize` and " +"before :c:func:`Py_InitializeFromConfig` to install a custom memory " +"allocator. There are no restrictions over the installed allocator other than " +"the ones imposed by the domain (for instance, the Raw Domain allows the " +"allocator to be called without the GIL held). See :ref:`the section on " +"allocator domains ` for more information." msgstr "" #: c-api/memory.rst:502 msgid "" -"If called after Python has finish initializing (after :c:func:" -"`Py_InitializeFromConfig` has been called) the allocator **must** wrap the " -"existing allocator. Substituting the current allocator for some other " -"arbitrary one is **not supported**." +"If called after Python has finish initializing " +"(after :c:func:`Py_InitializeFromConfig` has been called) the allocator " +"**must** wrap the existing allocator. Substituting the current allocator for " +"some other arbitrary one is **not supported**." msgstr "" #: c-api/memory.rst:507 @@ -739,8 +755,8 @@ msgstr "" #: c-api/memory.rst:522 msgid "" -"When :ref:`Python is built in debug mode `, the :c:func:" -"`PyMem_SetupDebugHooks` function is called at the :ref:`Python " +"When :ref:`Python is built in debug mode `, " +"the :c:func:`PyMem_SetupDebugHooks` function is called at the :ref:`Python " "preinitialization ` to setup debug hooks on Python memory " "allocators to detect memory errors." msgstr "" @@ -811,7 +827,7 @@ msgid "" "from a Python slice):" msgstr "" -#: c-api/memory.rst:563 +#: c-api/memory.rst:562 msgid "``p[-2*S:-S]``" msgstr "" @@ -821,7 +837,7 @@ msgid "" "to read in a memory dump)." msgstr "" -#: c-api/memory.rst:570 +#: c-api/memory.rst:565 msgid "``p[-S]``" msgstr "" @@ -841,7 +857,7 @@ msgstr "" msgid "``'o'`` for :c:macro:`PYMEM_DOMAIN_OBJ`." msgstr "" -#: c-api/memory.rst:573 +#: c-api/memory.rst:572 msgid "``p[-S+1:0]``" msgstr "" @@ -849,7 +865,7 @@ msgstr "" msgid "Copies of PYMEM_FORBIDDENBYTE. Used to catch under- writes and reads." msgstr "" -#: c-api/memory.rst:582 +#: c-api/memory.rst:575 msgid "``p[0:N]``" msgstr "" @@ -864,7 +880,7 @@ msgid "" "bytes are also filled with PYMEM_DEADBYTE." msgstr "" -#: c-api/memory.rst:585 +#: c-api/memory.rst:584 msgid "``p[N:N+S]``" msgstr "" @@ -872,7 +888,7 @@ msgstr "" msgid "Copies of PYMEM_FORBIDDENBYTE. Used to catch over- writes and reads." msgstr "" -#: c-api/memory.rst:596 +#: c-api/memory.rst:587 msgid "``p[N+S:N+2*S]``" msgstr "" @@ -908,10 +924,11 @@ msgstr "" #: c-api/memory.rst:607 msgid "" "The :c:func:`PyMem_SetupDebugHooks` function now also works on Python " -"compiled in release mode. On error, the debug hooks now use :mod:" -"`tracemalloc` to get the traceback where a memory block was allocated. The " -"debug hooks now also check if the GIL is held when functions of :c:macro:" -"`PYMEM_DOMAIN_OBJ` and :c:macro:`PYMEM_DOMAIN_MEM` domains are called." +"compiled in release mode. On error, the debug hooks now " +"use :mod:`tracemalloc` to get the traceback where a memory block was " +"allocated. The debug hooks now also check if the GIL is held when functions " +"of :c:macro:`PYMEM_DOMAIN_OBJ` and :c:macro:`PYMEM_DOMAIN_MEM` domains are " +"called." msgstr "" #: c-api/memory.rst:615 @@ -931,15 +948,15 @@ msgid "" "Python has a *pymalloc* allocator optimized for small objects (smaller or " "equal to 512 bytes) with a short lifetime. It uses memory mappings called " "\"arenas\" with a fixed size of either 256 KiB on 32-bit platforms or 1 MiB " -"on 64-bit platforms. It falls back to :c:func:`PyMem_RawMalloc` and :c:func:" -"`PyMem_RawRealloc` for allocations larger than 512 bytes." +"on 64-bit platforms. It falls back to :c:func:`PyMem_RawMalloc` " +"and :c:func:`PyMem_RawRealloc` for allocations larger than 512 bytes." msgstr "" #: c-api/memory.rst:633 msgid "" "*pymalloc* is the :ref:`default allocator ` of " -"the :c:macro:`PYMEM_DOMAIN_MEM` (ex: :c:func:`PyMem_Malloc`) and :c:macro:" -"`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) domains." +"the :c:macro:`PYMEM_DOMAIN_MEM` (ex: :c:func:`PyMem_Malloc`) " +"and :c:macro:`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) domains." msgstr "" #: c-api/memory.rst:637 @@ -961,8 +978,9 @@ msgstr "" #: c-api/memory.rst:643 msgid "" "This allocator is disabled if Python is configured with the :option:`--" -"without-pymalloc` option. It can also be disabled at runtime using the :" -"envvar:`PYTHONMALLOC` environment variable (ex: ``PYTHONMALLOC=malloc``)." +"without-pymalloc` option. It can also be disabled at runtime using " +"the :envvar:`PYTHONMALLOC` environment variable (ex: " +"``PYTHONMALLOC=malloc``)." msgstr "" #: c-api/memory.rst:648 @@ -1038,10 +1056,36 @@ msgid "" "set::" msgstr "" +#: c-api/memory.rst:706 +msgid "" +"PyObject *res;\n" +"char *buf = (char *) PyMem_Malloc(BUFSIZ); /* for I/O */\n" +"\n" +"if (buf == NULL)\n" +" return PyErr_NoMemory();\n" +"/* ...Do some I/O operation involving buf... */\n" +"res = PyBytes_FromString(buf);\n" +"PyMem_Free(buf); /* allocated with PyMem_Malloc */\n" +"return res;" +msgstr "" + #: c-api/memory.rst:716 msgid "The same code using the type-oriented function set::" msgstr "" +#: c-api/memory.rst:718 +msgid "" +"PyObject *res;\n" +"char *buf = PyMem_New(char, BUFSIZ); /* for I/O */\n" +"\n" +"if (buf == NULL)\n" +" return PyErr_NoMemory();\n" +"/* ...Do some I/O operation involving buf... */\n" +"res = PyBytes_FromString(buf);\n" +"PyMem_Del(buf); /* allocated with PyMem_New */\n" +"return res;" +msgstr "" + #: c-api/memory.rst:728 msgid "" "Note that in the two examples above, the buffer is always manipulated via " @@ -1052,11 +1096,23 @@ msgid "" "different allocators operating on different heaps. ::" msgstr "" +#: c-api/memory.rst:735 +msgid "" +"char *buf1 = PyMem_New(char, BUFSIZ);\n" +"char *buf2 = (char *) malloc(BUFSIZ);\n" +"char *buf3 = (char *) PyMem_Malloc(BUFSIZ);\n" +"...\n" +"PyMem_Del(buf3); /* Wrong -- should be PyMem_Free() */\n" +"free(buf2); /* Right -- allocated via malloc() */\n" +"free(buf1); /* Fatal -- should be PyMem_Del() */" +msgstr "" + #: c-api/memory.rst:743 msgid "" "In addition to the functions aimed at handling raw memory blocks from the " -"Python heap, objects in Python are allocated and released with :c:macro:" -"`PyObject_New`, :c:macro:`PyObject_NewVar` and :c:func:`PyObject_Del`." +"Python heap, objects in Python are allocated and released " +"with :c:macro:`PyObject_New`, :c:macro:`PyObject_NewVar` " +"and :c:func:`PyObject_Del`." msgstr "" #: c-api/memory.rst:747 diff --git a/c-api/memoryview.po b/c-api/memoryview.po index 843e71a4..24a6b420 100644 --- a/c-api/memoryview.po +++ b/c-api/memoryview.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -87,9 +88,10 @@ msgstr "" #: c-api/memoryview.rst:73 msgid "" "Return either a pointer to the exporting object that the memoryview is based " -"on or ``NULL`` if the memoryview has been created by one of the functions :c:" -"func:`PyMemoryView_FromMemory` or :c:func:`PyMemoryView_FromBuffer`. *mview* " -"**must** be a memoryview instance." +"on or ``NULL`` if the memoryview has been created by one of the " +"functions :c:func:`PyMemoryView_FromMemory` " +"or :c:func:`PyMemoryView_FromBuffer`. *mview* **must** be a memoryview " +"instance." msgstr "" #: c-api/memoryview.rst:5 diff --git a/c-api/method.po b/c-api/method.po index 49e45c02..bb48e977 100644 --- a/c-api/method.po +++ b/c-api/method.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -35,9 +36,9 @@ msgstr "" #: c-api/method.rst:23 msgid "" -"Return true if *o* is an instance method object (has type :c:data:" -"`PyInstanceMethod_Type`). The parameter must not be ``NULL``. This function " -"always succeeds." +"Return true if *o* is an instance method object (has " +"type :c:data:`PyInstanceMethod_Type`). The parameter must not be ``NULL``. " +"This function always succeeds." msgstr "" #: c-api/method.rst:30 diff --git a/c-api/module.po b/c-api/module.po index 1649e47e..97e15128 100644 --- a/c-api/module.po +++ b/c-api/module.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -34,30 +35,37 @@ msgstr "" #: c-api/module.rst:27 msgid "" -"Return true if *p* is a module object, but not a subtype of :c:data:" -"`PyModule_Type`. This function always succeeds." +"Return true if *p* is a module object, but not a subtype " +"of :c:data:`PyModule_Type`. This function always succeeds." msgstr "" #: c-api/module.rst:40 msgid "" -"Return a new module object with the :attr:`__name__` attribute set to " -"*name*. The module's :attr:`__name__`, :attr:`__doc__`, :attr:`__package__`, " -"and :attr:`__loader__` attributes are filled in (all but :attr:`__name__` " -"are set to ``None``); the caller is responsible for providing a :attr:" -"`__file__` attribute." +"Return a new module object with :attr:`module.__name__` set to *name*. The " +"module's :attr:`!" +"__name__`, :attr:`~module.__doc__`, :attr:`~module.__package__` " +"and :attr:`~module.__loader__` attributes are filled in (all but :attr:`!" +"__name__` are set to ``None``). The caller is responsible for setting " +"a :attr:`~module.__file__` attribute." msgstr "" -#: c-api/module.rst:48 -msgid ":attr:`__package__` and :attr:`__loader__` are set to ``None``." +#: c-api/module.rst:272 c-api/module.rst:447 +msgid "Return ``NULL`` with an exception set on error." msgstr "" -#: c-api/module.rst:54 +#: c-api/module.rst:50 +msgid "" +":attr:`~module.__package__` and :attr:`~module.__loader__` are now set to " +"``None``." +msgstr "" + +#: c-api/module.rst:57 msgid "" "Similar to :c:func:`PyModule_NewObject`, but the name is a UTF-8 encoded " "string instead of a Unicode object." msgstr "" -#: c-api/module.rst:62 +#: c-api/module.rst:65 msgid "" "Return the dictionary object that implements *module*'s namespace; this " "object is the same as the :attr:`~object.__dict__` attribute of the module " @@ -65,64 +73,64 @@ msgid "" "object), :exc:`SystemError` is raised and ``NULL`` is returned." msgstr "" -#: c-api/module.rst:67 +#: c-api/module.rst:70 msgid "" "It is recommended extensions use other ``PyModule_*`` and ``PyObject_*`` " -"functions rather than directly manipulate a module's :attr:`~object." -"__dict__`." +"functions rather than directly manipulate a " +"module's :attr:`~object.__dict__`." msgstr "" -#: c-api/module.rst:78 +#: c-api/module.rst:81 msgid "" -"Return *module*'s :attr:`__name__` value. If the module does not provide " -"one, or if it is not a string, :exc:`SystemError` is raised and ``NULL`` is " -"returned." +"Return *module*'s :attr:`~module.__name__` value. If the module does not " +"provide one, or if it is not a string, :exc:`SystemError` is raised and " +"``NULL`` is returned." msgstr "" -#: c-api/module.rst:86 +#: c-api/module.rst:90 msgid "" "Similar to :c:func:`PyModule_GetNameObject` but return the name encoded to " "``'utf-8'``." msgstr "" -#: c-api/module.rst:91 +#: c-api/module.rst:95 msgid "" "Return the \"state\" of the module, that is, a pointer to the block of " -"memory allocated at module creation time, or ``NULL``. See :c:member:" -"`PyModuleDef.m_size`." +"memory allocated at module creation time, or ``NULL``. " +"See :c:member:`PyModuleDef.m_size`." msgstr "" -#: c-api/module.rst:98 +#: c-api/module.rst:102 msgid "" "Return a pointer to the :c:type:`PyModuleDef` struct from which the module " "was created, or ``NULL`` if the module wasn't created from a definition." msgstr "" -#: c-api/module.rst:108 +#: c-api/module.rst:112 msgid "" -"Return the name of the file from which *module* was loaded using *module*'s :" -"attr:`__file__` attribute. If this is not defined, or if it is not a " -"unicode string, raise :exc:`SystemError` and return ``NULL``; otherwise " -"return a reference to a Unicode object." +"Return the name of the file from which *module* was loaded using " +"*module*'s :attr:`~module.__file__` attribute. If this is not defined, or " +"if it is not a string, raise :exc:`SystemError` and return ``NULL``; " +"otherwise return a reference to a Unicode object." msgstr "" -#: c-api/module.rst:118 +#: c-api/module.rst:122 msgid "" "Similar to :c:func:`PyModule_GetFilenameObject` but return the filename " "encoded to 'utf-8'." msgstr "" -#: c-api/module.rst:121 +#: c-api/module.rst:125 msgid "" ":c:func:`PyModule_GetFilename` raises :exc:`UnicodeEncodeError` on " "unencodable filenames, use :c:func:`PyModule_GetFilenameObject` instead." msgstr "" -#: c-api/module.rst:129 +#: c-api/module.rst:133 msgid "Initializing C modules" msgstr "" -#: c-api/module.rst:131 +#: c-api/module.rst:135 msgid "" "Modules objects are usually created from extension modules (shared libraries " "which export an initialization function), or compiled-in modules (where the " @@ -130,55 +138,56 @@ msgid "" "See :ref:`building` or :ref:`extending-with-embedding` for details." msgstr "" -#: c-api/module.rst:136 +#: c-api/module.rst:140 msgid "" -"The initialization function can either pass a module definition instance to :" -"c:func:`PyModule_Create`, and return the resulting module object, or request " -"\"multi-phase initialization\" by returning the definition struct itself." +"The initialization function can either pass a module definition instance " +"to :c:func:`PyModule_Create`, and return the resulting module object, or " +"request \"multi-phase initialization\" by returning the definition struct " +"itself." msgstr "" -#: c-api/module.rst:142 +#: c-api/module.rst:146 msgid "" "The module definition struct, which holds all information needed to create a " "module object. There is usually only one statically initialized variable of " "this type for each module." msgstr "" -#: c-api/module.rst:148 +#: c-api/module.rst:152 msgid "Always initialize this member to :c:macro:`PyModuleDef_HEAD_INIT`." msgstr "" -#: c-api/module.rst:152 +#: c-api/module.rst:156 msgid "Name for the new module." msgstr "" -#: c-api/module.rst:156 +#: c-api/module.rst:160 msgid "" -"Docstring for the module; usually a docstring variable created with :c:macro:" -"`PyDoc_STRVAR` is used." +"Docstring for the module; usually a docstring variable created " +"with :c:macro:`PyDoc_STRVAR` is used." msgstr "" -#: c-api/module.rst:161 +#: c-api/module.rst:165 msgid "" "Module state may be kept in a per-module memory area that can be retrieved " "with :c:func:`PyModule_GetState`, rather than in static globals. This makes " "modules safe for use in multiple sub-interpreters." msgstr "" -#: c-api/module.rst:165 +#: c-api/module.rst:169 msgid "" "This memory area is allocated based on *m_size* on module creation, and " -"freed when the module object is deallocated, after the :c:member:" -"`~PyModuleDef.m_free` function has been called, if present." +"freed when the module object is deallocated, after " +"the :c:member:`~PyModuleDef.m_free` function has been called, if present." msgstr "" -#: c-api/module.rst:169 +#: c-api/module.rst:173 msgid "" "Setting ``m_size`` to ``-1`` means that the module does not support sub-" "interpreters, because it has global state." msgstr "" -#: c-api/module.rst:172 +#: c-api/module.rst:176 msgid "" "Setting it to a non-negative value means that the module can be re-" "initialized and specifies the additional amount of memory it requires for " @@ -186,56 +195,57 @@ msgid "" "initialization." msgstr "" -#: c-api/module.rst:177 +#: c-api/module.rst:181 msgid "See :PEP:`3121` for more details." msgstr "" -#: c-api/module.rst:181 +#: c-api/module.rst:185 msgid "" -"A pointer to a table of module-level functions, described by :c:type:" -"`PyMethodDef` values. Can be ``NULL`` if no functions are present." +"A pointer to a table of module-level functions, described " +"by :c:type:`PyMethodDef` values. Can be ``NULL`` if no functions are " +"present." msgstr "" -#: c-api/module.rst:186 +#: c-api/module.rst:190 msgid "" "An array of slot definitions for multi-phase initialization, terminated by a " "``{0, NULL}`` entry. When using single-phase initialization, *m_slots* must " "be ``NULL``." msgstr "" -#: c-api/module.rst:192 +#: c-api/module.rst:196 msgid "" "Prior to version 3.5, this member was always set to ``NULL``, and was " "defined as:" msgstr "" -#: c-api/module.rst:199 +#: c-api/module.rst:203 msgid "" "A traversal function to call during GC traversal of the module object, or " "``NULL`` if not needed." msgstr "" -#: c-api/module.rst:217 c-api/module.rst:238 +#: c-api/module.rst:221 c-api/module.rst:242 msgid "" "This function is not called if the module state was requested but is not " "allocated yet. This is the case immediately after the module is created and " "before the module is executed (:c:data:`Py_mod_exec` function). More " "precisely, this function is not called if :c:member:`~PyModuleDef.m_size` is " -"greater than 0 and the module state (as returned by :c:func:" -"`PyModule_GetState`) is ``NULL``." +"greater than 0 and the module state (as returned " +"by :c:func:`PyModule_GetState`) is ``NULL``." msgstr "" -#: c-api/module.rst:230 c-api/module.rst:245 +#: c-api/module.rst:234 c-api/module.rst:249 msgid "No longer called before the module state is allocated." msgstr "" -#: c-api/module.rst:214 +#: c-api/module.rst:218 msgid "" "A clear function to call during GC clearing of the module object, or " "``NULL`` if not needed." msgstr "" -#: c-api/module.rst:224 +#: c-api/module.rst:228 msgid "" "Like :c:member:`PyTypeObject.tp_clear`, this function is not *always* called " "before a module is deallocated. For example, when reference counting is " @@ -244,55 +254,55 @@ msgid "" "directly." msgstr "" -#: c-api/module.rst:235 +#: c-api/module.rst:239 msgid "" "A function to call during deallocation of the module object, or ``NULL`` if " "not needed." msgstr "" -#: c-api/module.rst:249 +#: c-api/module.rst:253 msgid "Single-phase initialization" msgstr "" -#: c-api/module.rst:251 +#: c-api/module.rst:255 msgid "" "The module initialization function may create and return the module object " "directly. This is referred to as \"single-phase initialization\", and uses " "one of the following two module creation functions:" msgstr "" -#: c-api/module.rst:257 +#: c-api/module.rst:261 msgid "" "Create a new module object, given the definition in *def*. This behaves " -"like :c:func:`PyModule_Create2` with *module_api_version* set to :c:macro:" -"`PYTHON_API_VERSION`." +"like :c:func:`PyModule_Create2` with *module_api_version* set " +"to :c:macro:`PYTHON_API_VERSION`." msgstr "" -#: c-api/module.rst:264 +#: c-api/module.rst:268 msgid "" "Create a new module object, given the definition in *def*, assuming the API " "version *module_api_version*. If that version does not match the version of " "the running interpreter, a :exc:`RuntimeWarning` is emitted." msgstr "" -#: c-api/module.rst:270 +#: c-api/module.rst:276 msgid "" "Most uses of this function should be using :c:func:`PyModule_Create` " "instead; only use this if you are sure you need it." msgstr "" -#: c-api/module.rst:273 +#: c-api/module.rst:279 msgid "" "Before it is returned from in the initialization function, the resulting " -"module object is typically populated using functions like :c:func:" -"`PyModule_AddObjectRef`." +"module object is typically populated using functions " +"like :c:func:`PyModule_AddObjectRef`." msgstr "" -#: c-api/module.rst:279 +#: c-api/module.rst:285 msgid "Multi-phase initialization" msgstr "" -#: c-api/module.rst:281 +#: c-api/module.rst:287 msgid "" "An alternate way to specify extensions is to request \"multi-phase " "initialization\". Extension modules created this way behave more like Python " @@ -302,7 +312,7 @@ msgid "" "__init__` methods of classes." msgstr "" -#: c-api/module.rst:288 +#: c-api/module.rst:294 msgid "" "Unlike modules created using single-phase initialization, these modules are " "not singletons: if the *sys.modules* entry is removed and the module is re-" @@ -310,85 +320,86 @@ msgid "" "normal garbage collection -- as with Python modules. By default, multiple " "modules created from the same definition should be independent: changes to " "one should not affect the others. This means that all state should be " -"specific to the module object (using e.g. using :c:func:" -"`PyModule_GetState`), or its contents (such as the module's :attr:`~object." -"__dict__` or individual classes created with :c:func:`PyType_FromSpec`)." +"specific to the module object (using e.g. " +"using :c:func:`PyModule_GetState`), or its contents (such as the " +"module's :attr:`~object.__dict__` or individual classes created " +"with :c:func:`PyType_FromSpec`)." msgstr "" -#: c-api/module.rst:298 +#: c-api/module.rst:304 msgid "" "All modules created using multi-phase initialization are expected to " "support :ref:`sub-interpreters `. Making sure " "multiple modules are independent is typically enough to achieve this." msgstr "" -#: c-api/module.rst:302 +#: c-api/module.rst:308 msgid "" "To request multi-phase initialization, the initialization function " -"(PyInit_modulename) returns a :c:type:`PyModuleDef` instance with non-empty :" -"c:member:`~PyModuleDef.m_slots`. Before it is returned, the ``PyModuleDef`` " -"instance must be initialized with the following function:" +"(PyInit_modulename) returns a :c:type:`PyModuleDef` instance with non-" +"empty :c:member:`~PyModuleDef.m_slots`. Before it is returned, the " +"``PyModuleDef`` instance must be initialized with the following function:" msgstr "" -#: c-api/module.rst:309 +#: c-api/module.rst:315 msgid "" "Ensures a module definition is a properly initialized Python object that " "correctly reports its type and reference count." msgstr "" -#: c-api/module.rst:312 +#: c-api/module.rst:318 msgid "Returns *def* cast to ``PyObject*``, or ``NULL`` if an error occurred." msgstr "" -#: c-api/module.rst:316 +#: c-api/module.rst:322 msgid "" "The *m_slots* member of the module definition must point to an array of " "``PyModuleDef_Slot`` structures:" msgstr "" -#: c-api/module.rst:323 +#: c-api/module.rst:329 msgid "A slot ID, chosen from the available values explained below." msgstr "" -#: c-api/module.rst:327 +#: c-api/module.rst:333 msgid "Value of the slot, whose meaning depends on the slot ID." msgstr "" -#: c-api/module.rst:331 +#: c-api/module.rst:337 msgid "The *m_slots* array must be terminated by a slot with id 0." msgstr "" -#: c-api/module.rst:333 +#: c-api/module.rst:339 msgid "The available slot types are:" msgstr "" -#: c-api/module.rst:337 +#: c-api/module.rst:343 msgid "" "Specifies a function that is called to create the module object itself. The " "*value* pointer of this slot must point to a function of the signature:" msgstr "" -#: c-api/module.rst:343 +#: c-api/module.rst:350 msgid "" "The function receives a :py:class:`~importlib.machinery.ModuleSpec` " "instance, as defined in :PEP:`451`, and the module definition. It should " "return a new module object, or set an error and return ``NULL``." msgstr "" -#: c-api/module.rst:348 +#: c-api/module.rst:355 msgid "" "This function should be kept minimal. In particular, it should not call " "arbitrary Python code, as trying to import the same module again may result " "in an infinite loop." msgstr "" -#: c-api/module.rst:352 +#: c-api/module.rst:359 msgid "" "Multiple ``Py_mod_create`` slots may not be specified in one module " "definition." msgstr "" -#: c-api/module.rst:355 +#: c-api/module.rst:362 msgid "" "If ``Py_mod_create`` is not specified, the import machinery will create a " "normal module object using :c:func:`PyModule_New`. The name is taken from " @@ -397,17 +408,17 @@ msgid "" "through symlinks, all while sharing a single module definition." msgstr "" -#: c-api/module.rst:361 +#: c-api/module.rst:368 msgid "" -"There is no requirement for the returned object to be an instance of :c:type:" -"`PyModule_Type`. Any type can be used, as long as it supports setting and " -"getting import-related attributes. However, only ``PyModule_Type`` instances " -"may be returned if the ``PyModuleDef`` has non-``NULL`` ``m_traverse``, " -"``m_clear``, ``m_free``; non-zero ``m_size``; or slots other than " -"``Py_mod_create``." +"There is no requirement for the returned object to be an instance " +"of :c:type:`PyModule_Type`. Any type can be used, as long as it supports " +"setting and getting import-related attributes. However, only " +"``PyModule_Type`` instances may be returned if the ``PyModuleDef`` has non-" +"``NULL`` ``m_traverse``, ``m_clear``, ``m_free``; non-zero ``m_size``; or " +"slots other than ``Py_mod_create``." msgstr "" -#: c-api/module.rst:370 +#: c-api/module.rst:377 msgid "" "Specifies a function that is called to *execute* the module. This is " "equivalent to executing the code of a Python module: typically, this " @@ -415,59 +426,59 @@ msgid "" "function is:" msgstr "" -#: c-api/module.rst:378 +#: c-api/module.rst:386 msgid "" "If multiple ``Py_mod_exec`` slots are specified, they are processed in the " "order they appear in the *m_slots* array." msgstr "" -#: c-api/module.rst:383 +#: c-api/module.rst:391 msgid "Specifies one of the following values:" msgstr "" -#: c-api/module.rst:389 +#: c-api/module.rst:397 msgid "The module does not support being imported in subinterpreters." msgstr "" -#: c-api/module.rst:393 +#: c-api/module.rst:401 msgid "" "The module supports being imported in subinterpreters, but only when they " "share the main interpreter's GIL. (See :ref:`isolating-extensions-howto`.)" msgstr "" -#: c-api/module.rst:399 +#: c-api/module.rst:407 msgid "" "The module supports being imported in subinterpreters, even when they have " "their own GIL. (See :ref:`isolating-extensions-howto`.)" msgstr "" -#: c-api/module.rst:403 +#: c-api/module.rst:411 msgid "" "This slot determines whether or not importing this module in a " "subinterpreter will fail." msgstr "" -#: c-api/module.rst:406 +#: c-api/module.rst:414 msgid "" "Multiple ``Py_mod_multiple_interpreters`` slots may not be specified in one " "module definition." msgstr "" -#: c-api/module.rst:409 +#: c-api/module.rst:417 msgid "" "If ``Py_mod_multiple_interpreters`` is not specified, the import machinery " "defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED``." msgstr "" -#: c-api/module.rst:414 +#: c-api/module.rst:422 msgid "See :PEP:`489` for more details on multi-phase initialization." msgstr "" -#: c-api/module.rst:417 +#: c-api/module.rst:425 msgid "Low-level module creation functions" msgstr "" -#: c-api/module.rst:419 +#: c-api/module.rst:427 msgid "" "The following functions are called under the hood when using multi-phase " "initialization. They can be used directly, for example when creating module " @@ -475,14 +486,14 @@ msgid "" "``PyModule_ExecDef`` must be called to fully initialize a module." msgstr "" -#: c-api/module.rst:426 +#: c-api/module.rst:434 msgid "" "Create a new module object, given the definition in *def* and the ModuleSpec " "*spec*. This behaves like :c:func:`PyModule_FromDefAndSpec2` with " "*module_api_version* set to :c:macro:`PYTHON_API_VERSION`." msgstr "" -#: c-api/module.rst:434 +#: c-api/module.rst:442 msgid "" "Create a new module object, given the definition in *def* and the ModuleSpec " "*spec*, assuming the API version *module_api_version*. If that version does " @@ -490,24 +501,24 @@ msgid "" "emitted." msgstr "" -#: c-api/module.rst:441 +#: c-api/module.rst:451 msgid "" "Most uses of this function should be using :c:func:`PyModule_FromDefAndSpec` " "instead; only use this if you are sure you need it." msgstr "" -#: c-api/module.rst:448 +#: c-api/module.rst:458 msgid "Process any execution slots (:c:data:`Py_mod_exec`) given in *def*." msgstr "" -#: c-api/module.rst:454 +#: c-api/module.rst:464 msgid "" "Set the docstring for *module* to *docstring*. This function is called " "automatically when creating a module from ``PyModuleDef``, using either " "``PyModule_Create`` or ``PyModule_FromDefAndSpec``." msgstr "" -#: c-api/module.rst:463 +#: c-api/module.rst:473 msgid "" "Add the functions from the ``NULL`` terminated *functions* array to " "*module*. Refer to the :c:type:`PyMethodDef` documentation for details on " @@ -519,11 +530,11 @@ msgid "" "``PyModule_FromDefAndSpec``." msgstr "" -#: c-api/module.rst:475 +#: c-api/module.rst:485 msgid "Support functions" msgstr "" -#: c-api/module.rst:477 +#: c-api/module.rst:487 msgid "" "The module initialization function (if using single phase initialization) or " "a function called from a module execution slot (if using multi-phase " @@ -531,117 +542,204 @@ msgid "" "module state:" msgstr "" -#: c-api/module.rst:484 +#: c-api/module.rst:494 msgid "" "Add an object to *module* as *name*. This is a convenience function which " "can be used from the module's initialization function." msgstr "" -#: c-api/module.rst:487 +#: c-api/module.rst:497 msgid "" "On success, return ``0``. On error, raise an exception and return ``-1``." msgstr "" -#: c-api/module.rst:489 +#: c-api/module.rst:560 +msgid "Example usage::" +msgstr "" + +#: c-api/module.rst:501 msgid "" -"Return ``NULL`` if *value* is ``NULL``. It must be called with an exception " -"raised in this case." +"static int\n" +"add_spam(PyObject *module, int value)\n" +"{\n" +" PyObject *obj = PyLong_FromLong(value);\n" +" if (obj == NULL) {\n" +" return -1;\n" +" }\n" +" int res = PyModule_AddObjectRef(module, \"spam\", obj);\n" +" Py_DECREF(obj);\n" +" return res;\n" +" }" msgstr "" -#: c-api/module.rst:541 -msgid "Example usage::" +#: c-api/module.rst:513 +msgid "" +"To be convenient, the function accepts ``NULL`` *value* with an exception " +"set. In this case, return ``-1`` and just leave the raised exception " +"unchanged." msgstr "" -#: c-api/module.rst:559 +#: c-api/module.rst:578 msgid "" "The example can also be written without checking explicitly if *obj* is " "``NULL``::" msgstr "" -#: c-api/module.rst:575 +#: c-api/module.rst:520 +msgid "" +"static int\n" +"add_spam(PyObject *module, int value)\n" +"{\n" +" PyObject *obj = PyLong_FromLong(value);\n" +" int res = PyModule_AddObjectRef(module, \"spam\", obj);\n" +" Py_XDECREF(obj);\n" +" return res;\n" +" }" +msgstr "" + +#: c-api/module.rst:594 msgid "" "Note that ``Py_XDECREF()`` should be used instead of ``Py_DECREF()`` in this " "case, since *obj* can be ``NULL``." msgstr "" -#: c-api/module.rst:526 +#: c-api/module.rst:532 +msgid "" +"The number of different *name* strings passed to this function should be " +"kept small, usually by only using statically allocated strings as *name*. " +"For names that aren't known at compile time, prefer " +"calling :c:func:`PyUnicode_FromString` and :c:func:`PyObject_SetAttr` " +"directly. For more details, see :c:func:`PyUnicode_InternFromString`, which " +"may be used internally to create a key object." +msgstr "" + +#: c-api/module.rst:545 msgid "" "Similar to :c:func:`PyModule_AddObjectRef`, but steals a reference to " "*value* on success (if it returns ``0``)." msgstr "" -#: c-api/module.rst:529 +#: c-api/module.rst:548 msgid "" "The new :c:func:`PyModule_AddObjectRef` function is recommended, since it is " -"easy to introduce reference leaks by misusing the :c:func:" -"`PyModule_AddObject` function." +"easy to introduce reference leaks by misusing " +"the :c:func:`PyModule_AddObject` function." msgstr "" -#: c-api/module.rst:535 +#: c-api/module.rst:554 msgid "" "Unlike other functions that steal references, ``PyModule_AddObject()`` only " "releases the reference to *value* **on success**." msgstr "" -#: c-api/module.rst:538 +#: c-api/module.rst:557 msgid "" -"This means that its return value must be checked, and calling code must :c:" -"func:`Py_DECREF` *value* manually on error." +"This means that its return value must be checked, and calling code " +"must :c:func:`Py_DECREF` *value* manually on error." +msgstr "" + +#: c-api/module.rst:562 +msgid "" +"static int\n" +"add_spam(PyObject *module, int value)\n" +"{\n" +" PyObject *obj = PyLong_FromLong(value);\n" +" if (obj == NULL) {\n" +" return -1;\n" +" }\n" +" if (PyModule_AddObject(module, \"spam\", obj) < 0) {\n" +" Py_DECREF(obj);\n" +" return -1;\n" +" }\n" +" // PyModule_AddObject() stole a reference to obj:\n" +" // Py_DECREF(obj) is not needed here\n" +" return 0;\n" +"}" msgstr "" #: c-api/module.rst:581 msgid "" +"static int\n" +"add_spam(PyObject *module, int value)\n" +"{\n" +" PyObject *obj = PyLong_FromLong(value);\n" +" if (PyModule_AddObject(module, \"spam\", obj) < 0) {\n" +" Py_XDECREF(obj);\n" +" return -1;\n" +" }\n" +" // PyModule_AddObject() stole a reference to obj:\n" +" // Py_DECREF(obj) is not needed here\n" +" return 0;\n" +"}" +msgstr "" + +#: c-api/module.rst:600 +msgid "" "Add an integer constant to *module* as *name*. This convenience function " -"can be used from the module's initialization function. Return ``-1`` on " -"error, ``0`` on success." +"can be used from the module's initialization function. Return ``-1`` with an " +"exception set on error, ``0`` on success." +msgstr "" + +#: c-api/module.rst:604 +msgid "" +"This is a convenience function that calls :c:func:`PyLong_FromLong` " +"and :c:func:`PyModule_AddObjectRef`; see their documentation for details." msgstr "" -#: c-api/module.rst:588 +#: c-api/module.rst:610 msgid "" "Add a string constant to *module* as *name*. This convenience function can " "be used from the module's initialization function. The string *value* must " -"be ``NULL``-terminated. Return ``-1`` on error, ``0`` on success." +"be ``NULL``-terminated. Return ``-1`` with an exception set on error, ``0`` " +"on success." msgstr "" -#: c-api/module.rst:595 +#: c-api/module.rst:615 +msgid "" +"This is a convenience function that " +"calls :c:func:`PyUnicode_InternFromString` " +"and :c:func:`PyModule_AddObjectRef`; see their documentation for details." +msgstr "" + +#: c-api/module.rst:622 msgid "" "Add an int constant to *module*. The name and the value are taken from " "*macro*. For example ``PyModule_AddIntMacro(module, AF_INET)`` adds the int " -"constant *AF_INET* with the value of *AF_INET* to *module*. Return ``-1`` on " -"error, ``0`` on success." +"constant *AF_INET* with the value of *AF_INET* to *module*. Return ``-1`` " +"with an exception set on error, ``0`` on success." msgstr "" -#: c-api/module.rst:603 +#: c-api/module.rst:630 msgid "Add a string constant to *module*." msgstr "" -#: c-api/module.rst:607 +#: c-api/module.rst:634 msgid "" "Add a type object to *module*. The type object is finalized by calling " "internally :c:func:`PyType_Ready`. The name of the type object is taken from " "the last component of :c:member:`~PyTypeObject.tp_name` after dot. Return " -"``-1`` on error, ``0`` on success." +"``-1`` with an exception set on error, ``0`` on success." msgstr "" -#: c-api/module.rst:617 +#: c-api/module.rst:644 msgid "Module lookup" msgstr "" -#: c-api/module.rst:619 +#: c-api/module.rst:646 msgid "" "Single-phase initialization creates singleton modules that can be looked up " "in the context of the current interpreter. This allows the module object to " "be retrieved later with only a reference to the module definition." msgstr "" -#: c-api/module.rst:623 +#: c-api/module.rst:650 msgid "" "These functions will not work on modules created using multi-phase " "initialization, since multiple such modules can be created from a single " "definition." msgstr "" -#: c-api/module.rst:628 +#: c-api/module.rst:655 msgid "" "Returns the module object that was created from *def* for the current " "interpreter. This method requires that the module object has been attached " @@ -650,18 +748,18 @@ msgid "" "to the interpreter state yet, it returns ``NULL``." msgstr "" -#: c-api/module.rst:635 +#: c-api/module.rst:662 msgid "" "Attaches the module object passed to the function to the interpreter state. " -"This allows the module object to be accessible via :c:func:" -"`PyState_FindModule`." +"This allows the module object to be accessible " +"via :c:func:`PyState_FindModule`." msgstr "" -#: c-api/module.rst:638 +#: c-api/module.rst:665 msgid "Only effective on modules created using single-phase initialization." msgstr "" -#: c-api/module.rst:640 +#: c-api/module.rst:667 msgid "" "Python calls ``PyState_AddModule`` automatically after importing a module, " "so it is unnecessary (but harmless) to call it from module initialization " @@ -672,18 +770,18 @@ msgid "" "state updates)." msgstr "" -#: c-api/module.rst:659 +#: c-api/module.rst:686 msgid "The caller must hold the GIL." msgstr "" -#: c-api/module.rst:650 -msgid "Return 0 on success or -1 on failure." +#: c-api/module.rst:677 +msgid "Return ``-1`` with an exception set on error, ``0`` on success." msgstr "" -#: c-api/module.rst:656 +#: c-api/module.rst:683 msgid "" "Removes the module object created from *def* from the interpreter state. " -"Return 0 on success or -1 on failure." +"Return ``-1`` with an exception set on error, ``0`` on success." msgstr "" #: c-api/module.rst:8 @@ -698,7 +796,7 @@ msgstr "" msgid "ModuleType (in module types)" msgstr "" -#: c-api/module.rst:74 +#: c-api/module.rst:77 msgid "__name__ (module attribute)" msgstr "" @@ -706,7 +804,7 @@ msgstr "" msgid "__doc__ (module attribute)" msgstr "" -#: c-api/module.rst:104 +#: c-api/module.rst:108 msgid "__file__ (module attribute)" msgstr "" @@ -718,10 +816,10 @@ msgstr "" msgid "__loader__ (module attribute)" msgstr "" -#: c-api/module.rst:60 +#: c-api/module.rst:63 msgid "__dict__ (module attribute)" msgstr "" -#: c-api/module.rst:104 +#: c-api/module.rst:108 msgid "SystemError (built-in exception)" msgstr "" diff --git a/c-api/none.po b/c-api/none.po index bbd7ea16..69587253 100644 --- a/c-api/none.po +++ b/c-api/none.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/c-api/number.po b/c-api/number.po index d59b2015..25db00d0 100644 --- a/c-api/number.po +++ b/c-api/number.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -64,8 +65,8 @@ msgstr "" msgid "" "Return a reasonable approximation for the mathematical value of *o1* divided " "by *o2*, or ``NULL`` on failure. The return value is \"approximate\" " -"because binary floating point numbers are approximate; it is not possible to " -"represent all real numbers in base two. This function can return a floating " +"because binary floating-point numbers are approximate; it is not possible to " +"represent all real numbers in base two. This function can return a floating-" "point value when passed two integers. This is the equivalent of the Python " "expression ``o1 / o2``." msgstr "" @@ -183,8 +184,8 @@ msgstr "" msgid "" "Return a reasonable approximation for the mathematical value of *o1* divided " "by *o2*, or ``NULL`` on failure. The return value is \"approximate\" " -"because binary floating point numbers are approximate; it is not possible to " -"represent all real numbers in base two. This function can return a floating " +"because binary floating-point numbers are approximate; it is not possible to " +"represent all real numbers in base two. This function can return a floating-" "point value when passed two integers. The operation is done *in-place* when " "*o1* supports it. This is the equivalent of the Python statement ``o1 /= " "o2``." @@ -256,8 +257,8 @@ msgstr "" #: c-api/number.rst:257 msgid "" -"Returns the *o* converted to a Python int on success or ``NULL`` with a :exc:" -"`TypeError` exception raised on failure." +"Returns the *o* converted to a Python int on success or ``NULL`` with " +"a :exc:`TypeError` exception raised on failure." msgstr "" #: c-api/number.rst:260 @@ -271,8 +272,8 @@ msgid "" "Returns the integer *n* converted to base *base* as a string. The *base* " "argument must be one of 2, 8, 10, or 16. For base 2, 8, or 16, the returned " "string is prefixed with a base marker of ``'0b'``, ``'0o'``, or ``'0x'``, " -"respectively. If *n* is not a Python int, it is converted with :c:func:" -"`PyNumber_Index` first." +"respectively. If *n* is not a Python int, it is converted " +"with :c:func:`PyNumber_Index` first." msgstr "" #: c-api/number.rst:276 @@ -284,12 +285,12 @@ msgstr "" #: c-api/number.rst:279 msgid "" -"If *o* can be converted to a Python int but the attempt to convert to a :c:" -"type:`Py_ssize_t` value would raise an :exc:`OverflowError`, then the *exc* " -"argument is the type of exception that will be raised (usually :exc:" -"`IndexError` or :exc:`OverflowError`). If *exc* is ``NULL``, then the " -"exception is cleared and the value is clipped to ``PY_SSIZE_T_MIN`` for a " -"negative integer or ``PY_SSIZE_T_MAX`` for a positive integer." +"If *o* can be converted to a Python int but the attempt to convert to " +"a :c:type:`Py_ssize_t` value would raise an :exc:`OverflowError`, then the " +"*exc* argument is the type of exception that will be raised " +"(usually :exc:`IndexError` or :exc:`OverflowError`). If *exc* is ``NULL``, " +"then the exception is cleared and the value is clipped to ``PY_SSIZE_T_MIN`` " +"for a negative integer or ``PY_SSIZE_T_MAX`` for a positive integer." msgstr "" #: c-api/number.rst:289 diff --git a/c-api/objbuffer.po b/c-api/objbuffer.po index 38193523..76094dd0 100644 --- a/c-api/objbuffer.po +++ b/c-api/objbuffer.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -33,9 +34,10 @@ msgstr "" #: c-api/objbuffer.rst:15 msgid "" "Therefore, it is recommended that you call :c:func:`PyObject_GetBuffer` (or " -"the ``y*`` or ``w*`` :ref:`format codes ` with the :c:func:" -"`PyArg_ParseTuple` family of functions) to get a buffer view over an object, " -"and :c:func:`PyBuffer_Release` when the buffer view can be released." +"the ``y*`` or ``w*`` :ref:`format codes ` with " +"the :c:func:`PyArg_ParseTuple` family of functions) to get a buffer view " +"over an object, and :c:func:`PyBuffer_Release` when the buffer view can be " +"released." msgstr "" #: c-api/objbuffer.rst:23 @@ -43,8 +45,8 @@ msgid "" "Returns a pointer to a read-only memory location usable as character-based " "input. The *obj* argument must support the single-segment character buffer " "interface. On success, returns ``0``, sets *buffer* to the memory location " -"and *buffer_len* to the buffer length. Returns ``-1`` and sets a :exc:" -"`TypeError` on error." +"and *buffer_len* to the buffer length. Returns ``-1`` and sets " +"a :exc:`TypeError` on error." msgstr "" #: c-api/objbuffer.rst:32 @@ -52,8 +54,8 @@ msgid "" "Returns a pointer to a read-only memory location containing arbitrary data. " "The *obj* argument must support the single-segment readable buffer " "interface. On success, returns ``0``, sets *buffer* to the memory location " -"and *buffer_len* to the buffer length. Returns ``-1`` and sets a :exc:" -"`TypeError` on error." +"and *buffer_len* to the buffer length. Returns ``-1`` and sets " +"a :exc:`TypeError` on error." msgstr "" #: c-api/objbuffer.rst:41 diff --git a/c-api/object.po b/c-api/object.po index ee23c81c..05c20693 100644 --- a/c-api/object.po +++ b/c-api/object.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -29,15 +30,16 @@ msgstr "" #: c-api/object.rst:17 msgid "" "Properly handle returning :c:data:`Py_NotImplemented` from within a C " -"function (that is, create a new :term:`strong reference` to NotImplemented " -"and return it)." +"function (that is, create a new :term:`strong reference` " +"to :const:`NotImplemented` and return it)." msgstr "" #: c-api/object.rst:24 msgid "" -"Flag to be used with multiple functions that print the object (like :c:func:" -"`PyObject_Print` and :c:func:`PyFile_WriteObject`). If passed, these " -"function would use the :func:`str` of the object instead of the :func:`repr`." +"Flag to be used with multiple functions that print the object " +"(like :c:func:`PyObject_Print` and :c:func:`PyFile_WriteObject`). If passed, " +"these function would use the :func:`str` of the object instead of " +"the :func:`repr`." msgstr "" #: c-api/object.rst:32 @@ -57,24 +59,24 @@ msgstr "" #: c-api/object.rst:46 msgid "" -"Exceptions that occur when this calls :meth:`~object.__getattr__` and :meth:" -"`~object.__getattribute__` methods are silently ignored. For proper error " -"handling, use :c:func:`PyObject_GetAttr` instead." +"Exceptions that occur when this calls :meth:`~object.__getattr__` " +"and :meth:`~object.__getattribute__` methods are silently ignored. For " +"proper error handling, use :c:func:`PyObject_GetAttr` instead." msgstr "" #: c-api/object.rst:53 msgid "" "This is the same as :c:func:`PyObject_HasAttr`, but *attr_name* is specified " -"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" #: c-api/object.rst:59 msgid "" -"Exceptions that occur when this calls :meth:`~object.__getattr__` and :meth:" -"`~object.__getattribute__` methods or while creating the temporary :class:" -"`str` object are silently ignored. For proper error handling, use :c:func:" -"`PyObject_GetAttrString` instead." +"Exceptions that occur when this calls :meth:`~object.__getattr__` " +"and :meth:`~object.__getattribute__` methods or while creating the " +"temporary :class:`str` object are silently ignored. For proper error " +"handling, use :c:func:`PyObject_GetAttrString` instead." msgstr "" #: c-api/object.rst:67 @@ -87,18 +89,19 @@ msgstr "" #: c-api/object.rst:74 msgid "" "This is the same as :c:func:`PyObject_GetAttr`, but *attr_name* is specified " -"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" #: c-api/object.rst:81 msgid "" "Generic attribute getter function that is meant to be put into a type " "object's ``tp_getattro`` slot. It looks for a descriptor in the dictionary " -"of classes in the object's MRO as well as an attribute in the object's :attr:" -"`~object.__dict__` (if present). As outlined in :ref:`descriptors`, data " -"descriptors take preference over instance attributes, while non-data " -"descriptors don't. Otherwise, an :exc:`AttributeError` is raised." +"of classes in the object's MRO as well as an attribute in the " +"object's :attr:`~object.__dict__` (if present). As outlined " +"in :ref:`descriptors`, data descriptors take preference over instance " +"attributes, while non-data descriptors don't. Otherwise, " +"an :exc:`AttributeError` is raised." msgstr "" #: c-api/object.rst:91 @@ -118,8 +121,8 @@ msgstr "" #: c-api/object.rst:103 msgid "" "This is the same as :c:func:`PyObject_SetAttr`, but *attr_name* is specified " -"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" #: c-api/object.rst:107 @@ -128,7 +131,17 @@ msgid "" "in favour of using :c:func:`PyObject_DelAttrString`." msgstr "" -#: c-api/object.rst:113 +#: c-api/object.rst:110 +msgid "" +"The number of different attribute names passed to this function should be " +"kept small, usually by using a statically allocated string as *attr_name*. " +"For attribute names that aren't known at compile time, prefer " +"calling :c:func:`PyUnicode_FromString` and :c:func:`PyObject_SetAttr` " +"directly. For more details, see :c:func:`PyUnicode_InternFromString`, which " +"may be used internally to create a key object." +msgstr "" + +#: c-api/object.rst:120 msgid "" "Generic attribute setter and deleter function that is meant to be put into a " "type object's :c:member:`~PyTypeObject.tp_setattro` slot. It looks for a " @@ -140,26 +153,36 @@ msgid "" "returned." msgstr "" -#: c-api/object.rst:125 +#: c-api/object.rst:132 msgid "" "Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on " "failure. This is the equivalent of the Python statement ``del o.attr_name``." msgstr "" -#: c-api/object.rst:131 +#: c-api/object.rst:138 msgid "" "This is the same as :c:func:`PyObject_DelAttr`, but *attr_name* is specified " -"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" -"`PyObject*`." +"as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." msgstr "" -#: c-api/object.rst:138 +#: c-api/object.rst:142 +msgid "" +"The number of different attribute names passed to this function should be " +"kept small, usually by using a statically allocated string as *attr_name*. " +"For attribute names that aren't known at compile time, prefer " +"calling :c:func:`PyUnicode_FromString` and :c:func:`PyObject_DelAttr` " +"directly. For more details, see :c:func:`PyUnicode_InternFromString`, which " +"may be used internally to create a key object for lookup." +msgstr "" + +#: c-api/object.rst:153 msgid "" "A generic implementation for the getter of a ``__dict__`` descriptor. It " "creates the dictionary if necessary." msgstr "" -#: c-api/object.rst:141 +#: c-api/object.rst:156 msgid "" "This function may also be called to get the :py:attr:`~object.__dict__` of " "the object *o*. Pass ``NULL`` for *context* when calling it. Since this " @@ -168,67 +191,67 @@ msgid "" "the object." msgstr "" -#: c-api/object.rst:147 +#: c-api/object.rst:162 msgid "On failure, returns ``NULL`` with an exception set." msgstr "" -#: c-api/object.rst:154 +#: c-api/object.rst:169 msgid "" "A generic implementation for the setter of a ``__dict__`` descriptor. This " "implementation does not allow the dictionary to be deleted." msgstr "" -#: c-api/object.rst:162 +#: c-api/object.rst:177 msgid "" "Return a pointer to :py:attr:`~object.__dict__` of the object *obj*. If " "there is no ``__dict__``, return ``NULL`` without setting an exception." msgstr "" -#: c-api/object.rst:165 +#: c-api/object.rst:180 msgid "" "This function may need to allocate memory for the dictionary, so it may be " "more efficient to call :c:func:`PyObject_GetAttr` when accessing an " "attribute on the object." msgstr "" -#: c-api/object.rst:172 +#: c-api/object.rst:187 msgid "" "Compare the values of *o1* and *o2* using the operation specified by *opid*, " -"which must be one of :c:macro:`Py_LT`, :c:macro:`Py_LE`, :c:macro:`Py_EQ`, :" -"c:macro:`Py_NE`, :c:macro:`Py_GT`, or :c:macro:`Py_GE`, corresponding to " -"``<``, ``<=``, ``==``, ``!=``, ``>``, or ``>=`` respectively. This is the " -"equivalent of the Python expression ``o1 op o2``, where ``op`` is the " -"operator corresponding to *opid*. Returns the value of the comparison on " -"success, or ``NULL`` on failure." +"which must be one " +"of :c:macro:`Py_LT`, :c:macro:`Py_LE`, :c:macro:`Py_EQ`, :c:macro:`Py_NE`, :c:macro:`Py_GT`, " +"or :c:macro:`Py_GE`, corresponding to ``<``, ``<=``, ``==``, ``!=``, ``>``, " +"or ``>=`` respectively. This is the equivalent of the Python expression ``o1 " +"op o2``, where ``op`` is the operator corresponding to *opid*. Returns the " +"value of the comparison on success, or ``NULL`` on failure." msgstr "" -#: c-api/object.rst:182 +#: c-api/object.rst:197 msgid "" "Compare the values of *o1* and *o2* using the operation specified by *opid*, " "like :c:func:`PyObject_RichCompare`, but returns ``-1`` on error, ``0`` if " "the result is false, ``1`` otherwise." msgstr "" -#: c-api/object.rst:187 +#: c-api/object.rst:202 msgid "" "If *o1* and *o2* are the same object, :c:func:`PyObject_RichCompareBool` " "will always return ``1`` for :c:macro:`Py_EQ` and ``0`` for :c:macro:`Py_NE`." msgstr "" -#: c-api/object.rst:192 +#: c-api/object.rst:207 msgid "" "Format *obj* using *format_spec*. This is equivalent to the Python " "expression ``format(obj, format_spec)``." msgstr "" -#: c-api/object.rst:195 +#: c-api/object.rst:210 msgid "" "*format_spec* may be ``NULL``. In this case the call is equivalent to " "``format(obj)``. Returns the formatted string on success, ``NULL`` on " "failure." msgstr "" -#: c-api/object.rst:203 +#: c-api/object.rst:218 msgid "" "Compute a string representation of object *o*. Returns the string " "representation on success, ``NULL`` on failure. This is the equivalent of " @@ -236,22 +259,22 @@ msgid "" "function." msgstr "" -#: c-api/object.rst:231 +#: c-api/object.rst:246 msgid "" "This function now includes a debug assertion to help ensure that it does not " "silently discard an active exception." msgstr "" -#: c-api/object.rst:215 +#: c-api/object.rst:230 msgid "" "As :c:func:`PyObject_Repr`, compute a string representation of object *o*, " -"but escape the non-ASCII characters in the string returned by :c:func:" -"`PyObject_Repr` with ``\\x``, ``\\u`` or ``\\U`` escapes. This generates a " -"string similar to that returned by :c:func:`PyObject_Repr` in Python 2. " -"Called by the :func:`ascii` built-in function." +"but escape the non-ASCII characters in the string returned " +"by :c:func:`PyObject_Repr` with ``\\x``, ``\\u`` or ``\\U`` escapes. This " +"generates a string similar to that returned by :c:func:`PyObject_Repr` in " +"Python 2. Called by the :func:`ascii` built-in function." msgstr "" -#: c-api/object.rst:226 +#: c-api/object.rst:241 msgid "" "Compute a string representation of object *o*. Returns the string " "representation on success, ``NULL`` on failure. This is the equivalent of " @@ -259,7 +282,7 @@ msgid "" "function and, therefore, by the :func:`print` function." msgstr "" -#: c-api/object.rst:240 +#: c-api/object.rst:255 msgid "" "Compute a bytes representation of object *o*. ``NULL`` is returned on " "failure and a bytes object on success. This is equivalent to the Python " @@ -268,73 +291,73 @@ msgid "" "bytes object." msgstr "" -#: c-api/object.rst:249 +#: c-api/object.rst:264 msgid "" "Return ``1`` if the class *derived* is identical to or derived from the " "class *cls*, otherwise return ``0``. In case of an error, return ``-1``." msgstr "" -#: c-api/object.rst:271 +#: c-api/object.rst:286 msgid "" "If *cls* is a tuple, the check will be done against every entry in *cls*. " "The result will be ``1`` when at least one of the checks returns ``1``, " "otherwise it will be ``0``." msgstr "" -#: c-api/object.rst:256 +#: c-api/object.rst:271 msgid "" -"If *cls* has a :meth:`~class.__subclasscheck__` method, it will be called to " +"If *cls* has a :meth:`~type.__subclasscheck__` method, it will be called to " "determine the subclass status as described in :pep:`3119`. Otherwise, " -"*derived* is a subclass of *cls* if it is a direct or indirect subclass, i." -"e. contained in ``cls.__mro__``." +"*derived* is a subclass of *cls* if it is a direct or indirect subclass, " +"i.e. contained in :attr:`cls.__mro__ `." msgstr "" -#: c-api/object.rst:261 +#: c-api/object.rst:276 msgid "" "Normally only class objects, i.e. instances of :class:`type` or a derived " "class, are considered classes. However, objects can override this by having " -"a :attr:`~class.__bases__` attribute (which must be a tuple of base classes)." +"a :attr:`~type.__bases__` attribute (which must be a tuple of base classes)." msgstr "" -#: c-api/object.rst:268 +#: c-api/object.rst:283 msgid "" "Return ``1`` if *inst* is an instance of the class *cls* or a subclass of " "*cls*, or ``0`` if not. On error, returns ``-1`` and sets an exception." msgstr "" -#: c-api/object.rst:275 +#: c-api/object.rst:290 msgid "" -"If *cls* has a :meth:`~class.__instancecheck__` method, it will be called to " +"If *cls* has a :meth:`~type.__instancecheck__` method, it will be called to " "determine the subclass status as described in :pep:`3119`. Otherwise, " "*inst* is an instance of *cls* if its class is a subclass of *cls*." msgstr "" -#: c-api/object.rst:279 +#: c-api/object.rst:294 msgid "" -"An instance *inst* can override what is considered its class by having a :" -"attr:`~instance.__class__` attribute." +"An instance *inst* can override what is considered its class by having " +"a :attr:`~object.__class__` attribute." msgstr "" -#: c-api/object.rst:282 +#: c-api/object.rst:297 msgid "" "An object *cls* can override if it is considered a class, and what its base " -"classes are, by having a :attr:`~class.__bases__` attribute (which must be a " +"classes are, by having a :attr:`~type.__bases__` attribute (which must be a " "tuple of base classes)." msgstr "" -#: c-api/object.rst:291 +#: c-api/object.rst:306 msgid "" "Compute and return the hash value of an object *o*. On failure, return " "``-1``. This is the equivalent of the Python expression ``hash(o)``." msgstr "" -#: c-api/object.rst:294 +#: c-api/object.rst:309 msgid "" "The return type is now Py_hash_t. This is a signed integer the same size " "as :c:type:`Py_ssize_t`." msgstr "" -#: c-api/object.rst:301 +#: c-api/object.rst:316 msgid "" "Set a :exc:`TypeError` indicating that ``type(o)`` is not :term:`hashable` " "and return ``-1``. This function receives special treatment when stored in a " @@ -342,21 +365,21 @@ msgid "" "that it is not hashable." msgstr "" -#: c-api/object.rst:309 +#: c-api/object.rst:324 msgid "" "Returns ``1`` if the object *o* is considered to be true, and ``0`` " "otherwise. This is equivalent to the Python expression ``not not o``. On " "failure, return ``-1``." msgstr "" -#: c-api/object.rst:316 +#: c-api/object.rst:331 msgid "" "Returns ``0`` if the object *o* is considered to be true, and ``1`` " "otherwise. This is equivalent to the Python expression ``not o``. On " "failure, return ``-1``." msgstr "" -#: c-api/object.rst:325 +#: c-api/object.rst:340 msgid "" "When *o* is non-``NULL``, returns a type object corresponding to the object " "type of object *o*. On failure, raises :exc:`SystemError` and returns " @@ -367,13 +390,13 @@ msgid "" "when a new :term:`strong reference` is needed." msgstr "" -#: c-api/object.rst:337 +#: c-api/object.rst:352 msgid "" "Return non-zero if the object *o* is of type *type* or a subtype of *type*, " "and ``0`` otherwise. Both parameters must be non-``NULL``." msgstr "" -#: c-api/object.rst:346 +#: c-api/object.rst:361 msgid "" "Return the length of object *o*. If the object *o* provides either the " "sequence and mapping protocols, the sequence length is returned. On error, " @@ -381,7 +404,7 @@ msgid "" "``len(o)``." msgstr "" -#: c-api/object.rst:353 +#: c-api/object.rst:368 msgid "" "Return an estimated length for the object *o*. First try to return its " "actual length, then an estimate using :meth:`~object.__length_hint__`, and " @@ -390,36 +413,43 @@ msgid "" "defaultvalue)``." msgstr "" -#: c-api/object.rst:363 +#: c-api/object.rst:378 msgid "" "Return element of *o* corresponding to the object *key* or ``NULL`` on " "failure. This is the equivalent of the Python expression ``o[key]``." msgstr "" -#: c-api/object.rst:369 +#: c-api/object.rst:384 msgid "" "Map the object *key* to the value *v*. Raise an exception and return ``-1`` " "on failure; return ``0`` on success. This is the equivalent of the Python " "statement ``o[key] = v``. This function *does not* steal a reference to *v*." msgstr "" -#: c-api/object.rst:377 +#: c-api/object.rst:392 msgid "" "Remove the mapping for the object *key* from the object *o*. Return ``-1`` " "on failure. This is equivalent to the Python statement ``del o[key]``." msgstr "" -#: c-api/object.rst:383 +#: c-api/object.rst:398 +msgid "" +"This is the same as :c:func:`PyObject_DelItem`, but *key* is specified as " +"a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " +"a :c:expr:`PyObject*`." +msgstr "" + +#: c-api/object.rst:405 msgid "" "This is equivalent to the Python expression ``dir(o)``, returning a " "(possibly empty) list of strings appropriate for the object argument, or " "``NULL`` if there was an error. If the argument is ``NULL``, this is like " "the Python ``dir()``, returning the names of the current locals; in this " -"case, if no execution frame is active then ``NULL`` is returned but :c:func:" -"`PyErr_Occurred` will return false." +"case, if no execution frame is active then ``NULL`` is returned " +"but :c:func:`PyErr_Occurred` will return false." msgstr "" -#: c-api/object.rst:392 +#: c-api/object.rst:414 msgid "" "This is equivalent to the Python expression ``iter(o)``. It returns a new " "iterator for the object argument, or the object itself if the object is " @@ -427,97 +457,104 @@ msgid "" "object cannot be iterated." msgstr "" -#: c-api/object.rst:400 +#: c-api/object.rst:422 msgid "" -"This is the equivalent to the Python expression ``aiter(o)``. Takes an :" -"class:`AsyncIterable` object and returns an :class:`AsyncIterator` for it. " -"This is typically a new iterator but if the argument is an :class:" -"`AsyncIterator`, this returns itself. Raises :exc:`TypeError` and returns " -"``NULL`` if the object cannot be iterated." +"This is equivalent to the Python ``__iter__(self): return self`` method. It " +"is intended for :term:`iterator` types, to be used in " +"the :c:member:`PyTypeObject.tp_iter` slot." msgstr "" -#: c-api/object.rst:410 +#: c-api/object.rst:428 +msgid "" +"This is the equivalent to the Python expression ``aiter(o)``. Takes " +"an :class:`AsyncIterable` object and returns an :class:`AsyncIterator` for " +"it. This is typically a new iterator but if the argument is " +"an :class:`AsyncIterator`, this returns itself. Raises :exc:`TypeError` and " +"returns ``NULL`` if the object cannot be iterated." +msgstr "" + +#: c-api/object.rst:438 msgid "Get a pointer to subclass-specific data reserved for *cls*." msgstr "" -#: c-api/object.rst:412 +#: c-api/object.rst:440 msgid "" "The object *o* must be an instance of *cls*, and *cls* must have been " "created using negative :c:member:`PyType_Spec.basicsize`. Python does not " "check this." msgstr "" -#: c-api/object.rst:416 +#: c-api/object.rst:444 msgid "On error, set an exception and return ``NULL``." msgstr "" -#: c-api/object.rst:422 +#: c-api/object.rst:450 msgid "" "Return the size of the instance memory space reserved for *cls*, i.e. the " "size of the memory :c:func:`PyObject_GetTypeData` returns." msgstr "" -#: c-api/object.rst:425 +#: c-api/object.rst:453 msgid "" "This may be larger than requested using :c:member:`-PyType_Spec.basicsize " -"`; it is safe to use this larger size (e.g. with :c:" -"func:`!memset`)." +"`; it is safe to use this larger size (e.g. " +"with :c:func:`!memset`)." msgstr "" -#: c-api/object.rst:428 +#: c-api/object.rst:456 msgid "" -"The type *cls* **must** have been created using negative :c:member:" -"`PyType_Spec.basicsize`. Python does not check this." +"The type *cls* **must** have been created using " +"negative :c:member:`PyType_Spec.basicsize`. Python does not check this." msgstr "" -#: c-api/object.rst:432 +#: c-api/object.rst:460 msgid "On error, set an exception and return a negative value." msgstr "" -#: c-api/object.rst:438 +#: c-api/object.rst:466 msgid "" -"Get a pointer to per-item data for a class with :c:macro:" -"`Py_TPFLAGS_ITEMS_AT_END`." +"Get a pointer to per-item data for a class " +"with :c:macro:`Py_TPFLAGS_ITEMS_AT_END`." msgstr "" -#: c-api/object.rst:441 +#: c-api/object.rst:469 msgid "" "On error, set an exception and return ``NULL``. :py:exc:`TypeError` is " "raised if *o* does not have :c:macro:`Py_TPFLAGS_ITEMS_AT_END` set." msgstr "" -#: c-api/object.rst:213 c-api/object.rst:289 c-api/object.rst:344 +#: c-api/object.rst:228 c-api/object.rst:304 c-api/object.rst:359 msgid "built-in function" msgstr "" -#: c-api/object.rst:201 +#: c-api/object.rst:216 msgid "repr" msgstr "" -#: c-api/object.rst:213 +#: c-api/object.rst:228 msgid "ascii" msgstr "" -#: c-api/object.rst:221 +#: c-api/object.rst:236 msgid "string" msgstr "" -#: c-api/object.rst:221 +#: c-api/object.rst:236 msgid "PyObject_Str (C function)" msgstr "" -#: c-api/object.rst:238 +#: c-api/object.rst:253 msgid "bytes" msgstr "" -#: c-api/object.rst:289 +#: c-api/object.rst:304 msgid "hash" msgstr "" -#: c-api/object.rst:323 +#: c-api/object.rst:338 msgid "type" msgstr "" -#: c-api/object.rst:344 +#: c-api/object.rst:359 msgid "len" msgstr "" diff --git a/c-api/objimpl.po b/c-api/objimpl.po index fa8027a0..39f6fb94 100644 --- a/c-api/objimpl.po +++ b/c-api/objimpl.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/c-api/perfmaps.po b/c-api/perfmaps.po index 3df71920..7033f166 100644 --- a/c-api/perfmaps.po +++ b/c-api/perfmaps.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,12 +25,12 @@ msgstr "" msgid "" "On supported platforms (as of this writing, only Linux), the runtime can " "take advantage of *perf map files* to make Python functions visible to an " -"external profiling tool (such as `perf `_). A running process may create a file in the ``/tmp`` " +"external profiling tool (such as `perf `_). A running process may create a file in the ``/tmp`` " "directory, which contains entries that can map a section of executable code " "to a name. This interface is described in the `documentation of the Linux " -"Perf tool `_." +"Perf tool `_." msgstr "" #: c-api/perfmaps.rst:16 @@ -49,9 +50,9 @@ msgid "" "Open the ``/tmp/perf-$pid.map`` file, unless it's already opened, and create " "a lock to ensure thread-safe writes to the file (provided the writes are " "done through :c:func:`PyUnstable_WritePerfMapEntry`). Normally, there's no " -"need to call this explicitly; just use :c:func:" -"`PyUnstable_WritePerfMapEntry` and it will initialize the state on first " -"call." +"need to call this explicitly; just " +"use :c:func:`PyUnstable_WritePerfMapEntry` and it will initialize the state " +"on first call." msgstr "" #: c-api/perfmaps.rst:29 @@ -67,6 +68,12 @@ msgid "" "thread safe. Here is what an example entry looks like::" msgstr "" +#: c-api/perfmaps.rst:38 +msgid "" +"# address size name\n" +"7f3529fcf759 b py::bar:/run/t.py" +msgstr "" + #: c-api/perfmaps.rst:41 msgid "" "Will call :c:func:`PyUnstable_PerfMapState_Init` before writing the entry, " diff --git a/c-api/refcounting.po b/c-api/refcounting.po index eca8df93..672e97ed 100644 --- a/c-api/refcounting.po +++ b/c-api/refcounting.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -74,8 +75,8 @@ msgstr "" #: c-api/refcounting.rst:52 msgid "" -"This function is usually used to convert a :term:`borrowed reference` to a :" -"term:`strong reference` in-place. The :c:func:`Py_NewRef` function can be " +"This function is usually used to convert a :term:`borrowed reference` to " +"a :term:`strong reference` in-place. The :c:func:`Py_NewRef` function can be " "used to create a new :term:`strong reference`." msgstr "" @@ -89,11 +90,10 @@ msgid "" "use :c:func:`Py_XINCREF`." msgstr "" -#: c-api/refcounting.rst:127 +#: c-api/refcounting.rst:61 msgid "" -"Do not expect this function to actually modify *o* in any way. For at least " -"`some objects `_, this function has no " -"effect." +"Do not expect this function to actually modify *o* in any way. For at " +"least :pep:`some objects <0683>`, this function has no effect." msgstr "" #: c-api/refcounting.rst:71 @@ -128,10 +128,20 @@ msgstr "" msgid "For example::" msgstr "" +#: c-api/refcounting.rst:90 +msgid "" +"Py_INCREF(obj);\n" +"self->attr = obj;" +msgstr "" + #: c-api/refcounting.rst:93 msgid "can be written as::" msgstr "" +#: c-api/refcounting.rst:95 +msgid "self->attr = Py_NewRef(obj);" +msgstr "" + #: c-api/refcounting.rst:97 msgid "See also :c:func:`Py_INCREF`." msgstr "" @@ -169,10 +179,16 @@ msgid "" "use :c:func:`Py_XDECREF`." msgstr "" +#: c-api/refcounting.rst:127 +msgid "" +"Do not expect this function to actually modify *o* in any way. For at " +"least :pep:`some objects <683>`, this function has no effect." +msgstr "" + #: c-api/refcounting.rst:133 msgid "" -"The deallocation function can cause arbitrary Python code to be invoked (e." -"g. when a class instance with a :meth:`~object.__del__` method is " +"The deallocation function can cause arbitrary Python code to be invoked " +"(e.g. when a class instance with a :meth:`~object.__del__` method is " "deallocated). While exceptions in such code are not propagated, the " "executed code has free access to all Python global variables. This means " "that any object that is reachable from a global variable should be in a " @@ -220,8 +236,9 @@ msgstr "" #: c-api/refcounting.rst:180 msgid "" -"Release a :term:`strong reference` to object *o*. A function version of :c:" -"func:`Py_XDECREF`. It can be used for runtime dynamic embedding of Python." +"Release a :term:`strong reference` to object *o*. A function version " +"of :c:func:`Py_XDECREF`. It can be used for runtime dynamic embedding of " +"Python." msgstr "" #: c-api/refcounting.rst:187 @@ -234,10 +251,20 @@ msgstr "" msgid "As in case of :c:func:`Py_CLEAR`, \"the obvious\" code can be deadly::" msgstr "" +#: c-api/refcounting.rst:192 +msgid "" +"Py_DECREF(dst);\n" +"dst = src;" +msgstr "" + #: c-api/refcounting.rst:195 msgid "The safe way is::" msgstr "" +#: c-api/refcounting.rst:197 +msgid "Py_SETREF(dst, src);" +msgstr "" + #: c-api/refcounting.rst:199 msgid "" "That arranges to set *dst* to *src* _before_ releasing the reference to the " diff --git a/c-api/reflection.po b/c-api/reflection.po index 74b5de9f..5c92884d 100644 --- a/c-api/reflection.po +++ b/c-api/reflection.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -58,6 +59,6 @@ msgstr "" msgid "" "Return a description string, depending on the type of *func*. Return values " "include \"()\" for functions and methods, \" constructor\", \" instance\", " -"and \" object\". Concatenated with the result of :c:func:" -"`PyEval_GetFuncName`, the result will be a description of *func*." +"and \" object\". Concatenated with the result " +"of :c:func:`PyEval_GetFuncName`, the result will be a description of *func*." msgstr "" diff --git a/c-api/sequence.po b/c-api/sequence.po index 4edd2214..5dcfef3f 100644 --- a/c-api/sequence.po +++ b/c-api/sequence.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -23,10 +24,10 @@ msgstr "" #: c-api/sequence.rst:11 msgid "" "Return ``1`` if the object provides the sequence protocol, and ``0`` " -"otherwise. Note that it returns ``1`` for Python classes with a :meth:" -"`~object.__getitem__` method, unless they are :class:`dict` subclasses, " -"since in general it is impossible to determine what type of keys the class " -"supports. This function always succeeds." +"otherwise. Note that it returns ``1`` for Python classes with " +"a :meth:`~object.__getitem__` method, unless they are :class:`dict` " +"subclasses, since in general it is impossible to determine what type of keys " +"the class supports. This function always succeeds." msgstr "" #: c-api/sequence.rst:23 @@ -164,17 +165,18 @@ msgstr "" #: c-api/sequence.rst:148 msgid "" -"Returns the length of *o*, assuming that *o* was returned by :c:func:" -"`PySequence_Fast` and that *o* is not ``NULL``. The size can also be " -"retrieved by calling :c:func:`PySequence_Size` on *o*, but :c:func:" -"`PySequence_Fast_GET_SIZE` is faster because it can assume *o* is a list or " -"tuple." +"Returns the length of *o*, assuming that *o* was returned " +"by :c:func:`PySequence_Fast` and that *o* is not ``NULL``. The size can " +"also be retrieved by calling :c:func:`PySequence_Size` on *o*, " +"but :c:func:`PySequence_Fast_GET_SIZE` is faster because it can assume *o* " +"is a list or tuple." msgstr "" #: c-api/sequence.rst:157 msgid "" -"Return the *i*\\ th element of *o*, assuming that *o* was returned by :c:" -"func:`PySequence_Fast`, *o* is not ``NULL``, and that *i* is within bounds." +"Return the *i*\\ th element of *o*, assuming that *o* was returned " +"by :c:func:`PySequence_Fast`, *o* is not ``NULL``, and that *i* is within " +"bounds." msgstr "" #: c-api/sequence.rst:163 @@ -192,10 +194,10 @@ msgstr "" #: c-api/sequence.rst:173 msgid "" -"Return the *i*\\ th element of *o* or ``NULL`` on failure. Faster form of :c:" -"func:`PySequence_GetItem` but without checking that :c:func:" -"`PySequence_Check` on *o* is true and without adjustment for negative " -"indices." +"Return the *i*\\ th element of *o* or ``NULL`` on failure. Faster form " +"of :c:func:`PySequence_GetItem` but without checking " +"that :c:func:`PySequence_Check` on *o* is true and without adjustment for " +"negative indices." msgstr "" #: c-api/sequence.rst:123 diff --git a/c-api/set.po b/c-api/set.po index 6cecb74c..ee0b4e98 100644 --- a/c-api/set.po +++ b/c-api/set.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,38 +25,35 @@ msgstr "" msgid "" "This section details the public API for :class:`set` and :class:`frozenset` " "objects. Any functionality not listed below is best accessed using either " -"the abstract object protocol (including :c:func:`PyObject_CallMethod`, :c:" -"func:`PyObject_RichCompareBool`, :c:func:`PyObject_Hash`, :c:func:" -"`PyObject_Repr`, :c:func:`PyObject_IsTrue`, :c:func:`PyObject_Print`, and :c:" -"func:`PyObject_GetIter`) or the abstract number protocol (including :c:func:" -"`PyNumber_And`, :c:func:`PyNumber_Subtract`, :c:func:`PyNumber_Or`, :c:func:" -"`PyNumber_Xor`, :c:func:`PyNumber_InPlaceAnd`, :c:func:" -"`PyNumber_InPlaceSubtract`, :c:func:`PyNumber_InPlaceOr`, and :c:func:" -"`PyNumber_InPlaceXor`)." +"the abstract object protocol " +"(including :c:func:`PyObject_CallMethod`, :c:func:`PyObject_RichCompareBool`, :c:func:`PyObject_Hash`, :c:func:`PyObject_Repr`, :c:func:`PyObject_IsTrue`, :c:func:`PyObject_Print`, " +"and :c:func:`PyObject_GetIter`) or the abstract number protocol " +"(including :c:func:`PyNumber_And`, :c:func:`PyNumber_Subtract`, :c:func:`PyNumber_Or`, :c:func:`PyNumber_Xor`, :c:func:`PyNumber_InPlaceAnd`, :c:func:`PyNumber_InPlaceSubtract`, :c:func:`PyNumber_InPlaceOr`, " +"and :c:func:`PyNumber_InPlaceXor`)." msgstr "" #: c-api/set.rst:29 msgid "" "This subtype of :c:type:`PyObject` is used to hold the internal data for " -"both :class:`set` and :class:`frozenset` objects. It is like a :c:type:" -"`PyDictObject` in that it is a fixed size for small sets (much like tuple " -"storage) and will point to a separate, variable sized block of memory for " -"medium and large sized sets (much like list storage). None of the fields of " -"this structure should be considered public and all are subject to change. " -"All access should be done through the documented API rather than by " +"both :class:`set` and :class:`frozenset` objects. It is like " +"a :c:type:`PyDictObject` in that it is a fixed size for small sets (much " +"like tuple storage) and will point to a separate, variable sized block of " +"memory for medium and large sized sets (much like list storage). None of the " +"fields of this structure should be considered public and all are subject to " +"change. All access should be done through the documented API rather than by " "manipulating the values in the structure." msgstr "" #: c-api/set.rst:40 msgid "" -"This is an instance of :c:type:`PyTypeObject` representing the Python :class:" -"`set` type." +"This is an instance of :c:type:`PyTypeObject` representing the " +"Python :class:`set` type." msgstr "" #: c-api/set.rst:46 msgid "" -"This is an instance of :c:type:`PyTypeObject` representing the Python :class:" -"`frozenset` type." +"This is an instance of :c:type:`PyTypeObject` representing the " +"Python :class:`frozenset` type." msgstr "" #: c-api/set.rst:49 @@ -113,21 +111,21 @@ msgstr "" msgid "" "Return a new :class:`frozenset` containing objects returned by the " "*iterable*. The *iterable* may be ``NULL`` to create a new empty frozenset. " -"Return the new set on success or ``NULL`` on failure. Raise :exc:" -"`TypeError` if *iterable* is not actually iterable." +"Return the new set on success or ``NULL`` on failure. " +"Raise :exc:`TypeError` if *iterable* is not actually iterable." msgstr "" #: c-api/set.rst:104 msgid "" -"The following functions and macros are available for instances of :class:" -"`set` or :class:`frozenset` or instances of their subtypes." +"The following functions and macros are available for instances " +"of :class:`set` or :class:`frozenset` or instances of their subtypes." msgstr "" #: c-api/set.rst:112 msgid "" "Return the length of a :class:`set` or :class:`frozenset` object. Equivalent " -"to ``len(anyset)``. Raises a :exc:`SystemError` if *anyset* is not a :class:" -"`set`, :class:`frozenset`, or an instance of a subtype." +"to ``len(anyset)``. Raises a :exc:`SystemError` if *anyset* is not " +"a :class:`set`, :class:`frozenset`, or an instance of a subtype." msgstr "" #: c-api/set.rst:119 @@ -139,9 +137,9 @@ msgid "" "Return ``1`` if found, ``0`` if not found, and ``-1`` if an error is " "encountered. Unlike the Python :meth:`~object.__contains__` method, this " "function does not automatically convert unhashable sets into temporary " -"frozensets. Raise a :exc:`TypeError` if the *key* is unhashable. Raise :exc:" -"`SystemError` if *anyset* is not a :class:`set`, :class:`frozenset`, or an " -"instance of a subtype." +"frozensets. Raise a :exc:`TypeError` if the *key* is unhashable. " +"Raise :exc:`SystemError` if *anyset* is not " +"a :class:`set`, :class:`frozenset`, or an instance of a subtype." msgstr "" #: c-api/set.rst:133 @@ -151,8 +149,8 @@ msgid "" "values of brand new frozensets before they are exposed to other code). " "Return ``0`` on success or ``-1`` on failure. Raise a :exc:`TypeError` if " "the *key* is unhashable. Raise a :exc:`MemoryError` if there is no room to " -"grow. Raise a :exc:`SystemError` if *set* is not an instance of :class:" -"`set` or its subtype." +"grow. Raise a :exc:`SystemError` if *set* is not an instance " +"of :class:`set` or its subtype." msgstr "" #: c-api/set.rst:142 @@ -167,8 +165,9 @@ msgid "" "``-1`` if an error is encountered. Does not raise :exc:`KeyError` for " "missing keys. Raise a :exc:`TypeError` if the *key* is unhashable. Unlike " "the Python :meth:`~frozenset.discard` method, this function does not " -"automatically convert unhashable sets into temporary frozensets. Raise :exc:" -"`SystemError` if *set* is not an instance of :class:`set` or its subtype." +"automatically convert unhashable sets into temporary frozensets. " +"Raise :exc:`SystemError` if *set* is not an instance of :class:`set` or its " +"subtype." msgstr "" #: c-api/set.rst:158 @@ -182,8 +181,8 @@ msgstr "" #: c-api/set.rst:166 msgid "" "Empty an existing set of all elements. Return ``0`` on success. Return " -"``-1`` and raise :exc:`SystemError` if *set* is not an instance of :class:" -"`set` or its subtype." +"``-1`` and raise :exc:`SystemError` if *set* is not an instance " +"of :class:`set` or its subtype." msgstr "" #: c-api/set.rst:11 diff --git a/c-api/slice.po b/c-api/slice.po index 5f2374f9..9e4838b1 100644 --- a/c-api/slice.po +++ b/c-api/slice.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -37,34 +38,39 @@ msgid "" "Return a new slice object with the given values. The *start*, *stop*, and " "*step* parameters are used as the values of the slice object attributes of " "the same names. Any of the values may be ``NULL``, in which case the " -"``None`` will be used for the corresponding attribute. Return ``NULL`` if " -"the new object could not be allocated." +"``None`` will be used for the corresponding attribute." msgstr "" -#: c-api/slice.rst:32 +#: c-api/slice.rst:28 +msgid "" +"Return ``NULL`` with an exception set if the new object could not be " +"allocated." +msgstr "" + +#: c-api/slice.rst:34 msgid "" "Retrieve the start, stop and step indices from the slice object *slice*, " "assuming a sequence of length *length*. Treats indices greater than *length* " "as errors." msgstr "" -#: c-api/slice.rst:36 +#: c-api/slice.rst:38 msgid "" "Returns ``0`` on success and ``-1`` on error with no exception set (unless " "one of the indices was not ``None`` and failed to be converted to an " "integer, in which case ``-1`` is returned with an exception set)." msgstr "" -#: c-api/slice.rst:40 +#: c-api/slice.rst:42 msgid "You probably do not want to use this function." msgstr "" -#: c-api/slice.rst:73 +#: c-api/slice.rst:75 msgid "" "The parameter type for the *slice* parameter was ``PySliceObject*`` before." msgstr "" -#: c-api/slice.rst:49 +#: c-api/slice.rst:51 msgid "" "Usable replacement for :c:func:`PySlice_GetIndices`. Retrieve the start, " "stop, and step indices from the slice object *slice* assuming a sequence of " @@ -73,22 +79,38 @@ msgid "" "normal slices." msgstr "" -#: c-api/slice.rst:55 -msgid "Returns ``0`` on success and ``-1`` on error with exception set." +#: c-api/slice.rst:57 +msgid "Return ``0`` on success and ``-1`` on error with an exception set." msgstr "" -#: c-api/slice.rst:58 +#: c-api/slice.rst:60 msgid "" "This function is considered not safe for resizable sequences. Its invocation " -"should be replaced by a combination of :c:func:`PySlice_Unpack` and :c:func:" -"`PySlice_AdjustIndices` where ::" +"should be replaced by a combination of :c:func:`PySlice_Unpack` " +"and :c:func:`PySlice_AdjustIndices` where ::" +msgstr "" + +#: c-api/slice.rst:64 +msgid "" +"if (PySlice_GetIndicesEx(slice, length, &start, &stop, &step, &slicelength) " +"< 0) {\n" +" // return error\n" +"}" msgstr "" -#: c-api/slice.rst:66 +#: c-api/slice.rst:68 msgid "is replaced by ::" msgstr "" -#: c-api/slice.rst:77 +#: c-api/slice.rst:70 +msgid "" +"if (PySlice_Unpack(slice, &start, &stop, &step) < 0) {\n" +" // return error\n" +"}\n" +"slicelength = PySlice_AdjustIndices(length, &start, &stop, step);" +msgstr "" + +#: c-api/slice.rst:79 msgid "" "If ``Py_LIMITED_API`` is not set or set to the value between ``0x03050400`` " "and ``0x03060000`` (not including) or ``0x03060100`` or higher :c:func:`!" @@ -97,14 +119,14 @@ msgid "" "*stop* and *step* are evaluated more than once." msgstr "" -#: c-api/slice.rst:84 +#: c-api/slice.rst:86 msgid "" "If ``Py_LIMITED_API`` is set to the value less than ``0x03050400`` or " "between ``0x03060000`` and ``0x03060100`` (not including) :c:func:`!" "PySlice_GetIndicesEx` is a deprecated function." msgstr "" -#: c-api/slice.rst:92 +#: c-api/slice.rst:94 msgid "" "Extract the start, stop and step data members from a slice object as C " "integers. Silently reduce values larger than ``PY_SSIZE_T_MAX`` to " @@ -113,34 +135,40 @@ msgid "" "less than ``-PY_SSIZE_T_MAX`` to ``-PY_SSIZE_T_MAX``." msgstr "" -#: c-api/slice.rst:98 -msgid "Return ``-1`` on error, ``0`` on success." +#: c-api/slice.rst:100 +msgid "Return ``-1`` with an exception set on error, ``0`` on success." msgstr "" -#: c-api/slice.rst:105 +#: c-api/slice.rst:107 msgid "" "Adjust start/end slice indices assuming a sequence of the specified length. " "Out of bounds indices are clipped in a manner consistent with the handling " "of normal slices." msgstr "" -#: c-api/slice.rst:109 +#: c-api/slice.rst:111 msgid "" "Return the length of the slice. Always successful. Doesn't call Python " "code." msgstr "" -#: c-api/slice.rst:116 +#: c-api/slice.rst:118 msgid "Ellipsis Object" msgstr "" -#: c-api/slice.rst:121 +#: c-api/slice.rst:123 +msgid "" +"The type of Python :const:`Ellipsis` object. Same " +"as :class:`types.EllipsisType` in the Python layer." +msgstr "" + +#: c-api/slice.rst:129 msgid "" -"The Python ``Ellipsis`` object. This object has no methods. Like :c:data:" -"`Py_None`, it is an `immortal `_. " -"singleton object." +"The Python ``Ellipsis`` object. This object has no methods. " +"Like :c:data:`Py_None`, it is an `immortal `_. singleton object." msgstr "" -#: c-api/slice.rst:125 +#: c-api/slice.rst:133 msgid ":c:data:`Py_Ellipsis` is immortal." msgstr "" diff --git a/c-api/stable.po b/c-api/stable.po index 67c1af39..907c6899 100644 --- a/c-api/stable.po +++ b/c-api/stable.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -31,10 +32,10 @@ msgstr "" #: c-api/stable.rst:15 msgid "" "CPython's Application Binary Interface (ABI) is forward- and backwards-" -"compatible across a minor release (if these are compiled the same way; see :" -"ref:`stable-abi-platform` below). So, code compiled for Python 3.10.0 will " -"work on 3.10.8 and vice versa, but will need to be compiled separately for " -"3.9.x and 3.11.x." +"compatible across a minor release (if these are compiled the same way; " +"see :ref:`stable-abi-platform` below). So, code compiled for Python 3.10.0 " +"will work on 3.10.8 and vice versa, but will need to be compiled separately " +"for 3.9.x and 3.11.x." msgstr "" #: c-api/stable.rst:21 @@ -62,9 +63,9 @@ msgstr "" msgid "" "Names prefixed by an underscore, such as ``_Py_InternalState``, are private " "API that can change without notice even in patch releases. If you need to " -"use this API, consider reaching out to `CPython developers `_ to discuss adding public API for your use " -"case." +"use this API, consider reaching out to `CPython developers `_ to discuss adding public API for " +"your use case." msgstr "" #: c-api/stable.rst:40 @@ -108,8 +109,8 @@ msgstr "" #: c-api/stable.rst:67 msgid "" "Python 3.2 introduced the *Limited API*, a subset of Python's C API. " -"Extensions that only use the Limited API can be compiled once and work with " -"multiple versions of Python. Contents of the Limited API are :ref:`listed " +"Extensions that only use the Limited API can be compiled once and be loaded " +"on multiple versions of Python. Contents of the Limited API are :ref:`listed " "below `." msgstr "" @@ -123,9 +124,8 @@ msgstr "" msgid "" "Define ``Py_LIMITED_API`` to the value of :c:macro:`PY_VERSION_HEX` " "corresponding to the lowest Python version your extension supports. The " -"extension will work without recompilation with all Python 3 releases from " -"the specified one onward, and can use Limited API introduced up to that " -"version." +"extension will be ABI-compatible with all Python 3 releases from the " +"specified one onward, and can use Limited API introduced up to that version." msgstr "" #: c-api/stable.rst:83 @@ -148,24 +148,33 @@ msgstr "" #: c-api/stable.rst:96 msgid "" "To enable this, Python provides a *Stable ABI*: a set of symbols that will " -"remain compatible across Python 3.x versions." +"remain ABI-compatible across Python 3.x versions." msgstr "" -#: c-api/stable.rst:99 +#: c-api/stable.rst:101 +msgid "" +"The Stable ABI prevents ABI issues, like linker errors due to missing " +"symbols or data corruption due to changes in structure layouts or function " +"signatures. However, other changes in Python can change the *behavior* of " +"extensions. See Python's Backwards Compatibility Policy (:pep:`387`) for " +"details." +msgstr "" + +#: c-api/stable.rst:107 msgid "" "The Stable ABI contains symbols exposed in the :ref:`Limited API `, but also other ones – for example, functions necessary to support " "older versions of the Limited API." msgstr "" -#: c-api/stable.rst:103 +#: c-api/stable.rst:111 msgid "" "On Windows, extensions that use the Stable ABI should be linked against " -"``python3.dll`` rather than a version-specific library such as ``python39." -"dll``." +"``python3.dll`` rather than a version-specific library such as " +"``python39.dll``." msgstr "" -#: c-api/stable.rst:107 +#: c-api/stable.rst:115 msgid "" "On some platforms, Python will look for and load shared library files named " "with the ``abi3`` tag (e.g. ``mymodule.abi3.so``). It does not check if such " @@ -174,31 +183,31 @@ msgid "" "not installed for lower versions of Python." msgstr "" -#: c-api/stable.rst:114 +#: c-api/stable.rst:122 msgid "" "All functions in the Stable ABI are present as functions in Python's shared " "library, not solely as macros. This makes them usable from languages that " "don't use the C preprocessor." msgstr "" -#: c-api/stable.rst:120 +#: c-api/stable.rst:128 msgid "Limited API Scope and Performance" msgstr "" -#: c-api/stable.rst:122 +#: c-api/stable.rst:130 msgid "" "The goal for the Limited API is to allow everything that is possible with " "the full C API, but possibly with a performance penalty." msgstr "" -#: c-api/stable.rst:125 +#: c-api/stable.rst:133 msgid "" "For example, while :c:func:`PyList_GetItem` is available, its “unsafe” macro " "variant :c:func:`PyList_GET_ITEM` is not. The macro can be faster because it " "can rely on version-specific implementation details of the list object." msgstr "" -#: c-api/stable.rst:130 +#: c-api/stable.rst:138 msgid "" "Without ``Py_LIMITED_API`` defined, some C API functions are inlined or " "replaced by macros. Defining ``Py_LIMITED_API`` disables this inlining, " @@ -206,7 +215,7 @@ msgid "" "reducing performance." msgstr "" -#: c-api/stable.rst:135 +#: c-api/stable.rst:143 msgid "" "By leaving out the ``Py_LIMITED_API`` definition, it is possible to compile " "a Limited API extension with a version-specific ABI. This can improve " @@ -216,19 +225,20 @@ msgid "" "of an upcoming Python version." msgstr "" -#: c-api/stable.rst:144 +#: c-api/stable.rst:152 msgid "Limited API Caveats" msgstr "" -#: c-api/stable.rst:146 +#: c-api/stable.rst:154 msgid "" "Note that compiling with ``Py_LIMITED_API`` is *not* a complete guarantee " -"that code conforms to the :ref:`Limited API ` or the :ref:" -"`Stable ABI `. ``Py_LIMITED_API`` only covers definitions, but " -"an API also includes other issues, such as expected semantics." +"that code conforms to the :ref:`Limited API ` or " +"the :ref:`Stable ABI `. ``Py_LIMITED_API`` only covers " +"definitions, but an API also includes other issues, such as expected " +"semantics." msgstr "" -#: c-api/stable.rst:151 +#: c-api/stable.rst:159 msgid "" "One issue that ``Py_LIMITED_API`` does not guard against is calling a " "function with arguments that are invalid in a lower Python version. For " @@ -238,19 +248,19 @@ msgid "" "crash. A similar argument works for fields of structs." msgstr "" -#: c-api/stable.rst:158 +#: c-api/stable.rst:166 msgid "" "Another issue is that some struct fields are currently not hidden when " "``Py_LIMITED_API`` is defined, even though they're part of the Limited API." msgstr "" -#: c-api/stable.rst:161 +#: c-api/stable.rst:169 msgid "" "For these reasons, we recommend testing an extension with *all* minor Python " "versions it supports, and preferably to build with the *lowest* such version." msgstr "" -#: c-api/stable.rst:164 +#: c-api/stable.rst:172 msgid "" "We also recommend reviewing documentation of all used API to check if it is " "explicitly part of the Limited API. Even with ``Py_LIMITED_API`` defined, a " @@ -258,7 +268,7 @@ msgid "" "unintentionally, as bugs)." msgstr "" -#: c-api/stable.rst:169 +#: c-api/stable.rst:177 msgid "" "Also note that the Limited API is not necessarily stable: compiling with " "``Py_LIMITED_API`` with Python 3.8 means that the extension will run with " @@ -267,19 +277,19 @@ msgid "" "that the Stable ABI stays stable." msgstr "" -#: c-api/stable.rst:179 +#: c-api/stable.rst:187 msgid "Platform Considerations" msgstr "" -#: c-api/stable.rst:181 +#: c-api/stable.rst:189 msgid "" "ABI stability depends not only on Python, but also on the compiler used, " -"lower-level libraries and compiler options. For the purposes of the :ref:" -"`Stable ABI `, these details define a “platform”. They usually " -"depend on the OS type and processor architecture" +"lower-level libraries and compiler options. For the purposes of " +"the :ref:`Stable ABI `, these details define a “platform”. They " +"usually depend on the OS type and processor architecture" msgstr "" -#: c-api/stable.rst:186 +#: c-api/stable.rst:194 msgid "" "It is the responsibility of each particular distributor of Python to ensure " "that all Python versions on a particular platform are built in a way that " @@ -287,11 +297,11 @@ msgid "" "releases from ``python.org`` and many third-party distributors." msgstr "" -#: c-api/stable.rst:196 +#: c-api/stable.rst:204 msgid "Contents of Limited API" msgstr "" -#: c-api/stable.rst:199 +#: c-api/stable.rst:207 msgid "" "Currently, the :ref:`Limited API ` includes the following " "items:" diff --git a/c-api/structures.po b/c-api/structures.po index 12265cd6..50babaec 100644 --- a/c-api/structures.po +++ b/c-api/structures.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -55,11 +56,11 @@ msgstr "" #: c-api/structures.rst:38 msgid "" -"This is an extension of :c:type:`PyObject` that adds the :c:member:" -"`~PyVarObject.ob_size` field. This is only used for objects that have some " -"notion of *length*. This type does not often appear in the Python/C API. " -"Access to the members must be done by using the macros :c:macro:" -"`Py_REFCNT`, :c:macro:`Py_TYPE`, and :c:macro:`Py_SIZE`." +"This is an extension of :c:type:`PyObject` that adds " +"the :c:member:`~PyVarObject.ob_size` field. This is only used for objects " +"that have some notion of *length*. This type does not often appear in the " +"Python/C API. Access to the members must be done by using the " +"macros :c:macro:`Py_REFCNT`, :c:macro:`Py_TYPE`, and :c:macro:`Py_SIZE`." msgstr "" #: c-api/structures.rst:47 @@ -68,6 +69,10 @@ msgid "" "without a varying length. The PyObject_HEAD macro expands to::" msgstr "" +#: c-api/structures.rst:50 +msgid "PyObject ob_base;" +msgstr "" + #: c-api/structures.rst:52 msgid "See documentation of :c:type:`PyObject` above." msgstr "" @@ -79,6 +84,10 @@ msgid "" "expands to::" msgstr "" +#: c-api/structures.rst:61 +msgid "PyVarObject ob_base;" +msgstr "" + #: c-api/structures.rst:63 msgid "See documentation of :c:type:`PyVarObject` above." msgstr "" @@ -154,15 +163,27 @@ msgstr "" #: c-api/structures.rst:145 msgid "" -"This is a macro which expands to initialization values for a new :c:type:" -"`PyObject` type. This macro expands to::" +"This is a macro which expands to initialization values for a " +"new :c:type:`PyObject` type. This macro expands to::" +msgstr "" + +#: c-api/structures.rst:148 +msgid "" +"_PyObject_EXTRA_INIT\n" +"1, type," msgstr "" #: c-api/structures.rst:154 msgid "" -"This is a macro which expands to initialization values for a new :c:type:" -"`PyVarObject` type, including the :c:member:`~PyVarObject.ob_size` field. " -"This macro expands to::" +"This is a macro which expands to initialization values for a " +"new :c:type:`PyVarObject` type, including " +"the :c:member:`~PyVarObject.ob_size` field. This macro expands to::" +msgstr "" + +#: c-api/structures.rst:158 +msgid "" +"_PyObject_EXTRA_INIT\n" +"1, type, size," msgstr "" #: c-api/structures.rst:163 @@ -183,6 +204,12 @@ msgstr "" msgid "The function signature is::" msgstr "" +#: c-api/structures.rst:176 +msgid "" +"PyObject *PyCFunction(PyObject *self,\n" +" PyObject *args);" +msgstr "" + #: c-api/structures.rst:181 msgid "" "Type of the functions used to implement Python callables in C with " @@ -190,12 +217,26 @@ msgid "" "The function signature is::" msgstr "" +#: c-api/structures.rst:185 +msgid "" +"PyObject *PyCFunctionWithKeywords(PyObject *self,\n" +" PyObject *args,\n" +" PyObject *kwargs);" +msgstr "" + #: c-api/structures.rst:192 msgid "" "Type of the functions used to implement Python callables in C with " "signature :c:macro:`METH_FASTCALL`. The function signature is::" msgstr "" +#: c-api/structures.rst:196 +msgid "" +"PyObject *_PyCFunctionFast(PyObject *self,\n" +" PyObject *const *args,\n" +" Py_ssize_t nargs);" +msgstr "" + #: c-api/structures.rst:202 msgid "" "Type of the functions used to implement Python callables in C with " @@ -203,6 +244,14 @@ msgid "" "METH_KEYWORDS>`. The function signature is::" msgstr "" +#: c-api/structures.rst:206 +msgid "" +"PyObject *_PyCFunctionFastWithKeywords(PyObject *self,\n" +" PyObject *const *args,\n" +" Py_ssize_t nargs,\n" +" PyObject *kwnames);" +msgstr "" + #: c-api/structures.rst:213 msgid "" "Type of the functions used to implement Python callables in C with " @@ -210,6 +259,15 @@ msgid "" "METH_FASTCALL-METH_KEYWORDS>`. The function signature is::" msgstr "" +#: c-api/structures.rst:217 +msgid "" +"PyObject *PyCMethod(PyObject *self,\n" +" PyTypeObject *defining_class,\n" +" PyObject *const *args,\n" +" Py_ssize_t nargs,\n" +" PyObject *kwnames)" +msgstr "" + #: c-api/structures.rst:228 msgid "" "Structure used to describe a method of an extension type. This structure " @@ -255,24 +313,25 @@ msgstr "" #: c-api/structures.rst:264 msgid "" -"This is the typical calling convention, where the methods have the type :c:" -"type:`PyCFunction`. The function expects two :c:expr:`PyObject*` values. The " -"first one is the *self* object for methods; for module functions, it is the " -"module object. The second parameter (often called *args*) is a tuple object " -"representing all arguments. This parameter is typically processed using :c:" -"func:`PyArg_ParseTuple` or :c:func:`PyArg_UnpackTuple`." +"This is the typical calling convention, where the methods have the " +"type :c:type:`PyCFunction`. The function expects two :c:expr:`PyObject*` " +"values. The first one is the *self* object for methods; for module " +"functions, it is the module object. The second parameter (often called " +"*args*) is a tuple object representing all arguments. This parameter is " +"typically processed using :c:func:`PyArg_ParseTuple` " +"or :c:func:`PyArg_UnpackTuple`." msgstr "" #: c-api/structures.rst:274 msgid "" -"Can only be used in certain combinations with other flags: :ref:" -"`METH_VARARGS | METH_KEYWORDS `, :ref:" -"`METH_FASTCALL | METH_KEYWORDS ` and :ref:" -"`METH_METHOD | METH_FASTCALL | METH_KEYWORDS `." +"Can only be used in certain combinations with other " +"flags: :ref:`METH_VARARGS | METH_KEYWORDS `, :ref:`METH_FASTCALL | METH_KEYWORDS ` and :ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS " +"`." msgstr "" -#: c-api/structures.rst:288 +#: c-api/structures.rst:282 msgid ":c:expr:`METH_VARARGS | METH_KEYWORDS`" msgstr "" @@ -298,7 +357,7 @@ msgstr "" msgid "``METH_FASTCALL`` is now part of the :ref:`stable ABI `." msgstr "" -#: c-api/structures.rst:319 +#: c-api/structures.rst:307 msgid ":c:expr:`METH_FASTCALL | METH_KEYWORDS`" msgstr "" @@ -320,7 +379,7 @@ msgid "" "METH_FASTCALL | METH_KEYWORDS `." msgstr "" -#: c-api/structures.rst:340 +#: c-api/structures.rst:329 msgid ":c:expr:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS`" msgstr "" @@ -350,16 +409,16 @@ msgstr "" #: c-api/structures.rst:350 msgid "" -"The function must have 2 parameters. Since the second parameter is unused, :" -"c:macro:`Py_UNUSED` can be used to prevent a compiler warning." +"The function must have 2 parameters. Since the second parameter is " +"unused, :c:macro:`Py_UNUSED` can be used to prevent a compiler warning." msgstr "" #: c-api/structures.rst:356 msgid "" -"Methods with a single object argument can be listed with the :c:macro:" -"`METH_O` flag, instead of invoking :c:func:`PyArg_ParseTuple` with a " -"``\"O\"`` argument. They have the type :c:type:`PyCFunction`, with the " -"*self* parameter, and a :c:expr:`PyObject*` parameter representing the " +"Methods with a single object argument can be listed with " +"the :c:macro:`METH_O` flag, instead of invoking :c:func:`PyArg_ParseTuple` " +"with a ``\"O\"`` argument. They have the type :c:type:`PyCFunction`, with " +"the *self* parameter, and a :c:expr:`PyObject*` parameter representing the " "single argument." msgstr "" @@ -396,12 +455,12 @@ msgid "" "The method will be loaded in place of existing definitions. Without " "*METH_COEXIST*, the default is to skip repeated definitions. Since slot " "wrappers are loaded before the method table, the existence of a " -"*sq_contains* slot, for example, would generate a wrapped method named :meth:" -"`~object.__contains__` and preclude the loading of a corresponding " -"PyCFunction with the same name. With the flag defined, the PyCFunction will " -"be loaded in place of the wrapper object and will co-exist with the slot. " -"This is helpful because calls to PyCFunctions are optimized more than " -"wrapper object calls." +"*sq_contains* slot, for example, would generate a wrapped method " +"named :meth:`~object.__contains__` and preclude the loading of a " +"corresponding PyCFunction with the same name. With the flag defined, the " +"PyCFunction will be loaded in place of the wrapper object and will co-exist " +"with the slot. This is helpful because calls to PyCFunctions are optimized " +"more than wrapper object calls." msgstr "" #: c-api/structures.rst:404 @@ -493,18 +552,27 @@ msgstr "" msgid "" "By default (when :c:member:`~PyMemberDef.flags` is ``0``), members allow " "both read and write access. Use the :c:macro:`Py_READONLY` flag for read-" -"only access. Certain types, like :c:macro:`Py_T_STRING`, imply :c:macro:" -"`Py_READONLY`. Only :c:macro:`Py_T_OBJECT_EX` (and legacy :c:macro:" -"`T_OBJECT`) members can be deleted." +"only access. Certain types, like :c:macro:`Py_T_STRING`, " +"imply :c:macro:`Py_READONLY`. Only :c:macro:`Py_T_OBJECT_EX` (and " +"legacy :c:macro:`T_OBJECT`) members can be deleted." msgstr "" #: c-api/structures.rst:484 msgid "" "For heap-allocated types (created using :c:func:`PyType_FromSpec` or " "similar), ``PyMemberDef`` may contain a definition for the special member " -"``\"__vectorcalloffset__\"``, corresponding to :c:member:`~PyTypeObject." -"tp_vectorcall_offset` in type objects. These must be defined with " -"``Py_T_PYSSIZET`` and ``Py_READONLY``, for example::" +"``\"__vectorcalloffset__\"``, corresponding " +"to :c:member:`~PyTypeObject.tp_vectorcall_offset` in type objects. These " +"must be defined with ``Py_T_PYSSIZET`` and ``Py_READONLY``, for example::" +msgstr "" + +#: c-api/structures.rst:490 +msgid "" +"static PyMemberDef spam_type_members[] = {\n" +" {\"__vectorcalloffset__\", Py_T_PYSSIZET,\n" +" offsetof(Spam_object, vectorcall), Py_READONLY},\n" +" {NULL} /* Sentinel */\n" +"};" msgstr "" #: c-api/structures.rst:496 @@ -513,9 +581,9 @@ msgstr "" #: c-api/structures.rst:498 msgid "" -"The legacy offsets :c:member:`~PyTypeObject.tp_dictoffset` and :c:member:" -"`~PyTypeObject.tp_weaklistoffset` can be defined similarly using " -"``\"__dictoffset__\"`` and ``\"__weaklistoffset__\"`` members, but " +"The legacy offsets :c:member:`~PyTypeObject.tp_dictoffset` " +"and :c:member:`~PyTypeObject.tp_weaklistoffset` can be defined similarly " +"using ``\"__dictoffset__\"`` and ``\"__weaklistoffset__\"`` members, but " "extensions are strongly encouraged to use :c:macro:`Py_TPFLAGS_MANAGED_DICT` " "and :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead." msgstr "" @@ -578,16 +646,18 @@ msgstr "" #: c-api/structures.rst:553 msgid "" -"Can only be used as part of :c:member:`Py_tp_members ` :c:type:`slot ` when creating a class using " -"negative :c:member:`~PyType_Spec.basicsize`. It is mandatory in that case." +"Can only be used as part of :c:member:`Py_tp_members " +"` :c:type:`slot ` when creating a " +"class using negative :c:member:`~PyType_Spec.basicsize`. It is mandatory in " +"that case." msgstr "" #: c-api/structures.rst:558 msgid "" -"This flag is only used in :c:type:`PyType_Slot`. When setting :c:member:" -"`~PyTypeObject.tp_members` during class creation, Python clears it and sets :" -"c:member:`PyMemberDef.offset` to the offset from the ``PyObject`` struct." +"This flag is only used in :c:type:`PyType_Slot`. When " +"setting :c:member:`~PyTypeObject.tp_members` during class creation, Python " +"clears it and sets :c:member:`PyMemberDef.offset` to the offset from the " +"``PyObject`` struct." msgstr "" #: c-api/structures.rst:570 @@ -601,9 +671,9 @@ msgstr "" #: c-api/structures.rst:581 msgid "" -"The :c:macro:`!READONLY` macro was renamed to :c:macro:`Py_READONLY`. The :c:" -"macro:`!PY_AUDIT_READ` macro was renamed with the ``Py_`` prefix. The new " -"names are now always available. Previously, these required ``#include " +"The :c:macro:`!READONLY` macro was renamed to :c:macro:`Py_READONLY`. " +"The :c:macro:`!PY_AUDIT_READ` macro was renamed with the ``Py_`` prefix. The " +"new names are now always available. Previously, these required ``#include " "\"structmember.h\"``. The header is still available and it provides the old " "names." msgstr "" @@ -623,8 +693,8 @@ msgstr "" #: c-api/structures.rst:600 msgid "" -"Unless marked (D), attributes defined this way cannot be deleted using e.g. :" -"keyword:`del` or :py:func:`delattr`." +"Unless marked (D), attributes defined this way cannot be deleted using " +"e.g. :keyword:`del` or :py:func:`delattr`." msgstr "" #: c-api/structures.rst:604 diff --git a/c-api/sys.po b/c-api/sys.po index 73624df9..df043745 100644 --- a/c-api/sys.po +++ b/c-api/sys.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -22,12 +23,12 @@ msgstr "" #: c-api/sys.rst:11 msgid "" -"Return the file system representation for *path*. If the object is a :class:" -"`str` or :class:`bytes` object, then a new :term:`strong reference` is " -"returned. If the object implements the :class:`os.PathLike` interface, then :" -"meth:`~os.PathLike.__fspath__` is returned as long as it is a :class:`str` " -"or :class:`bytes` object. Otherwise :exc:`TypeError` is raised and ``NULL`` " -"is returned." +"Return the file system representation for *path*. If the object is " +"a :class:`str` or :class:`bytes` object, then a new :term:`strong reference` " +"is returned. If the object implements the :class:`os.PathLike` interface, " +"then :meth:`~os.PathLike.__fspath__` is returned as long as it is " +"a :class:`str` or :class:`bytes` object. Otherwise :exc:`TypeError` is " +"raised and ``NULL`` is returned." msgstr "" #: c-api/sys.rst:24 @@ -94,8 +95,8 @@ msgstr "" #: c-api/sys.rst:83 msgid "" ":func:`os.register_at_fork` allows registering custom Python functions to be " -"called by :c:func:`PyOS_BeforeFork()`, :c:func:`PyOS_AfterFork_Parent` and :" -"c:func:`PyOS_AfterFork_Child`." +"called by :c:func:`PyOS_BeforeFork()`, :c:func:`PyOS_AfterFork_Parent` " +"and :c:func:`PyOS_AfterFork_Child`." msgstr "" #: c-api/sys.rst:90 @@ -129,22 +130,22 @@ msgstr "" #: c-api/sys.rst:122 msgid "" "Set the signal handler for signal *i* to be *h*; return the old signal " -"handler. This is a thin wrapper around either :c:func:`!sigaction` or :c:" -"func:`!signal`. Do not call those functions directly!" +"handler. This is a thin wrapper around either :c:func:`!sigaction` " +"or :c:func:`!signal`. Do not call those functions directly!" msgstr "" #: c-api/sys.rst:129 msgid "" "This function should not be called directly: use the :c:type:`PyConfig` API " -"with the :c:func:`PyConfig_SetBytesString` function which ensures that :ref:" -"`Python is preinitialized `." +"with the :c:func:`PyConfig_SetBytesString` function which ensures " +"that :ref:`Python is preinitialized `." msgstr "" #: c-api/sys.rst:200 msgid "" "This function must not be called before :ref:`Python is preinitialized ` and so that the LC_CTYPE locale is properly configured: see the :c:" -"func:`Py_PreInitialize` function." +"preinit>` and so that the LC_CTYPE locale is properly configured: see " +"the :c:func:`Py_PreInitialize` function." msgstr "" #: c-api/sys.rst:137 @@ -159,9 +160,10 @@ msgstr "" #: c-api/sys.rst:144 msgid "" -"Return a pointer to a newly allocated wide character string, use :c:func:" -"`PyMem_RawFree` to free the memory. If size is not ``NULL``, write the " -"number of wide characters excluding the null character into ``*size``" +"Return a pointer to a newly allocated wide character string, " +"use :c:func:`PyMem_RawFree` to free the memory. If size is not ``NULL``, " +"write the number of wide characters excluding the null character into " +"``*size``" msgstr "" #: c-api/sys.rst:148 @@ -173,9 +175,9 @@ msgstr "" #: c-api/sys.rst:192 msgid "" -"The :term:`filesystem encoding and error handler` are selected by :c:func:" -"`PyConfig_Read`: see :c:member:`~PyConfig.filesystem_encoding` and :c:member:" -"`~PyConfig.filesystem_errors` members of :c:type:`PyConfig`." +"The :term:`filesystem encoding and error handler` are selected " +"by :c:func:`PyConfig_Read`: see :c:member:`~PyConfig.filesystem_encoding` " +"and :c:member:`~PyConfig.filesystem_errors` members of :c:type:`PyConfig`." msgstr "" #: c-api/sys.rst:156 @@ -191,8 +193,8 @@ msgstr "" #: c-api/sys.rst:164 msgid "" -"The :c:func:`PyUnicode_DecodeFSDefaultAndSize` and :c:func:" -"`PyUnicode_DecodeLocaleAndSize` functions." +"The :c:func:`PyUnicode_DecodeFSDefaultAndSize` " +"and :c:func:`PyUnicode_DecodeLocaleAndSize` functions." msgstr "" #: c-api/sys.rst:211 @@ -203,8 +205,8 @@ msgstr "" #: c-api/sys.rst:173 msgid "" -"The function now uses the UTF-8 encoding on Windows if :c:member:" -"`PyPreConfig.legacy_windows_fs_encoding` is zero;" +"The function now uses the UTF-8 encoding on Windows " +"if :c:member:`PyPreConfig.legacy_windows_fs_encoding` is zero;" msgstr "" #: c-api/sys.rst:180 @@ -242,8 +244,8 @@ msgstr "" #: c-api/sys.rst:215 msgid "" -"The function now uses the UTF-8 encoding on Windows if :c:member:" -"`PyPreConfig.legacy_windows_fs_encoding` is zero." +"The function now uses the UTF-8 encoding on Windows " +"if :c:member:`PyPreConfig.legacy_windows_fs_encoding` is zero." msgstr "" #: c-api/sys.rst:223 @@ -279,9 +281,9 @@ msgstr "" #: c-api/sys.rst:258 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"warnoptions` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.warnoptions` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/sys.rst:251 @@ -297,25 +299,25 @@ msgstr "" #: c-api/sys.rst:264 msgid "" "Note: this function is not currently usable from outside the CPython " -"implementation, as it must be called prior to the implicit import of :mod:" -"`warnings` in :c:func:`Py_Initialize` to be effective, but can't be called " -"until enough of the runtime has been initialized to permit the creation of " -"Unicode objects." +"implementation, as it must be called prior to the implicit import " +"of :mod:`warnings` in :c:func:`Py_Initialize` to be effective, but can't be " +"called until enough of the runtime has been initialized to permit the " +"creation of Unicode objects." msgstr "" #: c-api/sys.rst:274 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"module_search_paths` and :c:member:`PyConfig.module_search_paths_set` should " -"be used instead, see :ref:`Python Initialization Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.module_search_paths` " +"and :c:member:`PyConfig.module_search_paths_set` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/sys.rst:279 msgid "" "Set :data:`sys.path` to a list object of paths found in *path* which should " -"be a list of paths separated with the platform's search path delimiter (``:" -"`` on Unix, ``;`` on Windows)." +"be a list of paths separated with the platform's search path delimiter " +"(``:`` on Unix, ``;`` on Windows)." msgstr "" #: c-api/sys.rst:287 @@ -349,9 +351,9 @@ msgstr "" #: c-api/sys.rst:308 msgid "" -"Function similar to PySys_WriteStdout() but format the message using :c:func:" -"`PyUnicode_FromFormatV` and don't truncate the message to an arbitrary " -"length." +"Function similar to PySys_WriteStdout() but format the message " +"using :c:func:`PyUnicode_FromFormatV` and don't truncate the message to an " +"arbitrary length." msgstr "" #: c-api/sys.rst:316 @@ -362,9 +364,9 @@ msgstr "" #: c-api/sys.rst:323 msgid "" -"This API is kept for backward compatibility: setting :c:member:`PyConfig." -"xoptions` should be used instead, see :ref:`Python Initialization " -"Configuration `." +"This API is kept for backward compatibility: " +"setting :c:member:`PyConfig.xoptions` should be used instead, " +"see :ref:`Python Initialization Configuration `." msgstr "" #: c-api/sys.rst:327 @@ -376,8 +378,9 @@ msgstr "" #: c-api/sys.rst:337 msgid "" -"Return the current dictionary of :option:`-X` options, similarly to :data:" -"`sys._xoptions`. On error, ``NULL`` is returned and an exception is set." +"Return the current dictionary of :option:`-X` options, similarly " +"to :data:`sys._xoptions`. On error, ``NULL`` is returned and an exception " +"is set." msgstr "" #: c-api/sys.rst:346 @@ -399,8 +402,9 @@ msgstr "" #: c-api/sys.rst:357 msgid "" -"Note that ``#`` format characters should always be treated as :c:type:" -"`Py_ssize_t`, regardless of whether ``PY_SSIZE_T_CLEAN`` was defined." +"Note that ``#`` format characters should always be treated " +"as :c:type:`Py_ssize_t`, regardless of whether ``PY_SSIZE_T_CLEAN`` was " +"defined." msgstr "" #: c-api/sys.rst:360 @@ -432,8 +436,8 @@ msgstr "" msgid "" "This function is safe to call before :c:func:`Py_Initialize`. When called " "after runtime initialization, existing audit hooks are notified and may " -"silently abort the operation by raising an error subclassed from :class:" -"`Exception` (other errors will not be silenced)." +"silently abort the operation by raising an error subclassed " +"from :class:`Exception` (other errors will not be silenced)." msgstr "" #: c-api/sys.rst:387 @@ -449,12 +453,6 @@ msgid "" "events table `. Details are in each function's documentation." msgstr "" -#: c-api/sys.rst:395 -msgid "" -"Raises an :ref:`auditing event ` ``sys.addaudithook`` with no " -"arguments." -msgstr "" - #: c-api/sys.rst:397 msgid "" "If the interpreter is initialized, this function raises an auditing event " @@ -467,8 +465,9 @@ msgstr "" #: c-api/sys.rst:406 msgid "" "The type of the hook function. *event* is the C string event argument passed " -"to :c:func:`PySys_Audit`. *args* is guaranteed to be a :c:type:" -"`PyTupleObject`. *userData* is the argument passed to PySys_AddAuditHook()." +"to :c:func:`PySys_Audit`. *args* is guaranteed to be " +"a :c:type:`PyTupleObject`. *userData* is the argument passed to " +"PySys_AddAuditHook()." msgstr "" #: c-api/sys.rst:417 @@ -481,8 +480,8 @@ msgid "" "This function should only be invoked when a condition is detected that would " "make it dangerous to continue using the Python interpreter; e.g., when the " "object administration appears to be corrupted. On Unix, the standard C " -"library function :c:func:`!abort` is called which will attempt to produce a :" -"file:`core` file." +"library function :c:func:`!abort` is called which will attempt to produce " +"a :file:`core` file." msgstr "" #: c-api/sys.rst:431 @@ -499,8 +498,8 @@ msgstr "" #: c-api/sys.rst:445 msgid "" "Exit the current process. This calls :c:func:`Py_FinalizeEx` and then calls " -"the standard C library function ``exit(status)``. If :c:func:" -"`Py_FinalizeEx` indicates an error, the exit status is set to 120." +"the standard C library function ``exit(status)``. " +"If :c:func:`Py_FinalizeEx` indicates an error, the exit status is set to 120." msgstr "" #: c-api/sys.rst:449 diff --git a/c-api/tuple.po b/c-api/tuple.po index 89b071fd..ba16f5f5 100644 --- a/c-api/tuple.po +++ b/c-api/tuple.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -43,72 +44,88 @@ msgid "" msgstr "" #: c-api/tuple.rst:36 -msgid "Return a new tuple object of size *len*, or ``NULL`` on failure." +msgid "" +"Return a new tuple object of size *len*, or ``NULL`` with an exception set " +"on failure." msgstr "" -#: c-api/tuple.rst:41 +#: c-api/tuple.rst:42 msgid "" -"Return a new tuple object of size *n*, or ``NULL`` on failure. The tuple " -"values are initialized to the subsequent *n* C arguments pointing to Python " -"objects. ``PyTuple_Pack(2, a, b)`` is equivalent to " +"Return a new tuple object of size *n*, or ``NULL`` with an exception set on " +"failure. The tuple values are initialized to the subsequent *n* C arguments " +"pointing to Python objects. ``PyTuple_Pack(2, a, b)`` is equivalent to " "``Py_BuildValue(\"(OO)\", a, b)``." msgstr "" -#: c-api/tuple.rst:48 -msgid "Take a pointer to a tuple object, and return the size of that tuple." +#: c-api/tuple.rst:50 +msgid "" +"Take a pointer to a tuple object, and return the size of that tuple. On " +"error, return ``-1`` and with an exception set." msgstr "" -#: c-api/tuple.rst:53 -msgid "" -"Return the size of the tuple *p*, which must be non-``NULL`` and point to a " -"tuple; no error checking is performed." +#: c-api/tuple.rst:56 +msgid "Like :c:func:`PyTuple_Size`, but without error checking." msgstr "" -#: c-api/tuple.rst:59 +#: c-api/tuple.rst:61 msgid "" "Return the object at position *pos* in the tuple pointed to by *p*. If " -"*pos* is negative or out of bounds, return ``NULL`` and set an :exc:" -"`IndexError` exception." +"*pos* is negative or out of bounds, return ``NULL`` and set " +"an :exc:`IndexError` exception." msgstr "" -#: c-api/tuple.rst:65 +#: c-api/tuple.rst:64 +msgid "" +"The returned reference is borrowed from the tuple *p* (that is: it is only " +"valid as long as you hold a reference to *p*). To get a :term:`strong " +"reference`, use :c:func:`Py_NewRef(PyTuple_GetItem(...)) ` " +"or :c:func:`PySequence_GetItem`." +msgstr "" + +#: c-api/tuple.rst:73 msgid "Like :c:func:`PyTuple_GetItem`, but does no checking of its arguments." msgstr "" -#: c-api/tuple.rst:70 +#: c-api/tuple.rst:78 msgid "" "Return the slice of the tuple pointed to by *p* between *low* and *high*, or " -"``NULL`` on failure. This is the equivalent of the Python expression " -"``p[low:high]``. Indexing from the end of the tuple is not supported." +"``NULL`` with an exception set on failure." msgstr "" -#: c-api/tuple.rst:77 +#: c-api/tuple.rst:81 +msgid "" +"This is the equivalent of the Python expression ``p[low:high]``. Indexing " +"from the end of the tuple is not supported." +msgstr "" + +#: c-api/tuple.rst:87 msgid "" "Insert a reference to object *o* at position *pos* of the tuple pointed to " "by *p*. Return ``0`` on success. If *pos* is out of bounds, return ``-1`` " "and set an :exc:`IndexError` exception." msgstr "" -#: c-api/tuple.rst:83 +#: c-api/tuple.rst:93 msgid "" "This function \"steals\" a reference to *o* and discards a reference to an " "item already in the tuple at the affected position." msgstr "" -#: c-api/tuple.rst:89 +#: c-api/tuple.rst:99 msgid "" "Like :c:func:`PyTuple_SetItem`, but does no error checking, and should " "*only* be used to fill in brand new tuples." msgstr "" -#: c-api/tuple.rst:94 +#: c-api/tuple.rst:104 msgid "" -"This function \"steals\" a reference to *o*, and, unlike :c:func:" -"`PyTuple_SetItem`, does *not* discard a reference to any item that is being " -"replaced; any reference in the tuple at position *pos* will be leaked." +"This function \"steals\" a reference to *o*, and, " +"unlike :c:func:`PyTuple_SetItem`, does *not* discard a reference to any item " +"that is being replaced; any reference in the tuple at position *pos* will be " +"leaked." msgstr "" -#: c-api/tuple.rst:102 +#: c-api/tuple.rst:112 msgid "" "Can be used to resize a tuple. *newsize* will be the new length of the " "tuple. Because tuples are *supposed* to be immutable, this should only be " @@ -119,114 +136,120 @@ msgid "" "Client code should never assume that the resulting value of ``*p`` will be " "the same as before calling this function. If the object referenced by ``*p`` " "is replaced, the original ``*p`` is destroyed. On failure, returns ``-1`` " -"and sets ``*p`` to ``NULL``, and raises :exc:`MemoryError` or :exc:" -"`SystemError`." +"and sets ``*p`` to ``NULL``, and raises :exc:`MemoryError` " +"or :exc:`SystemError`." msgstr "" -#: c-api/tuple.rst:117 +#: c-api/tuple.rst:127 msgid "Struct Sequence Objects" msgstr "" -#: c-api/tuple.rst:119 +#: c-api/tuple.rst:129 msgid "" -"Struct sequence objects are the C equivalent of :func:`~collections." -"namedtuple` objects, i.e. a sequence whose items can also be accessed " -"through attributes. To create a struct sequence, you first have to create a " -"specific struct sequence type." +"Struct sequence objects are the C equivalent " +"of :func:`~collections.namedtuple` objects, i.e. a sequence whose items can " +"also be accessed through attributes. To create a struct sequence, you first " +"have to create a specific struct sequence type." msgstr "" -#: c-api/tuple.rst:126 +#: c-api/tuple.rst:136 msgid "" "Create a new struct sequence type from the data in *desc*, described below. " -"Instances of the resulting type can be created with :c:func:" -"`PyStructSequence_New`." +"Instances of the resulting type can be created " +"with :c:func:`PyStructSequence_New`." +msgstr "" + +#: c-api/tuple.rst:208 +msgid "Return ``NULL`` with an exception set on failure." msgstr "" -#: c-api/tuple.rst:132 +#: c-api/tuple.rst:144 msgid "Initializes a struct sequence type *type* from *desc* in place." msgstr "" -#: c-api/tuple.rst:137 +#: c-api/tuple.rst:149 msgid "" -"The same as ``PyStructSequence_InitType``, but returns ``0`` on success and " -"``-1`` on failure." +"Like :c:func:`PyStructSequence_InitType`, but returns ``0`` on success and " +"``-1`` with an exception set on failure." msgstr "" -#: c-api/tuple.rst:145 +#: c-api/tuple.rst:157 msgid "Contains the meta information of a struct sequence type to create." msgstr "" -#: c-api/tuple.rst:149 -msgid "Name of the struct sequence type." +#: c-api/tuple.rst:161 +msgid "" +"Fully qualified name of the type; null-terminated UTF-8 encoded. The name " +"must contain the module name." msgstr "" -#: c-api/tuple.rst:153 +#: c-api/tuple.rst:166 msgid "Pointer to docstring for the type or ``NULL`` to omit." msgstr "" -#: c-api/tuple.rst:157 +#: c-api/tuple.rst:170 msgid "Pointer to ``NULL``-terminated array with field names of the new type." msgstr "" -#: c-api/tuple.rst:161 +#: c-api/tuple.rst:174 msgid "Number of fields visible to the Python side (if used as tuple)." msgstr "" -#: c-api/tuple.rst:166 +#: c-api/tuple.rst:179 msgid "" "Describes a field of a struct sequence. As a struct sequence is modeled as a " -"tuple, all fields are typed as :c:expr:`PyObject*`. The index in the :c:" -"member:`~PyStructSequence_Desc.fields` array of the :c:type:" -"`PyStructSequence_Desc` determines which field of the struct sequence is " -"described." +"tuple, all fields are typed as :c:expr:`PyObject*`. The index in " +"the :c:member:`~PyStructSequence_Desc.fields` array of " +"the :c:type:`PyStructSequence_Desc` determines which field of the struct " +"sequence is described." msgstr "" -#: c-api/tuple.rst:174 +#: c-api/tuple.rst:187 msgid "" -"Name for the field or ``NULL`` to end the list of named fields, set to :c:" -"data:`PyStructSequence_UnnamedField` to leave unnamed." +"Name for the field or ``NULL`` to end the list of named fields, set " +"to :c:data:`PyStructSequence_UnnamedField` to leave unnamed." msgstr "" -#: c-api/tuple.rst:179 +#: c-api/tuple.rst:192 msgid "Field docstring or ``NULL`` to omit." msgstr "" -#: c-api/tuple.rst:184 +#: c-api/tuple.rst:197 msgid "Special value for a field name to leave it unnamed." msgstr "" -#: c-api/tuple.rst:186 +#: c-api/tuple.rst:199 msgid "The type was changed from ``char *``." msgstr "" -#: c-api/tuple.rst:192 +#: c-api/tuple.rst:205 msgid "" -"Creates an instance of *type*, which must have been created with :c:func:" -"`PyStructSequence_NewType`." +"Creates an instance of *type*, which must have been created " +"with :c:func:`PyStructSequence_NewType`." msgstr "" -#: c-api/tuple.rst:198 +#: c-api/tuple.rst:213 msgid "" "Return the object at position *pos* in the struct sequence pointed to by " "*p*. No bounds checking is performed." msgstr "" -#: c-api/tuple.rst:204 +#: c-api/tuple.rst:219 msgid "Macro equivalent of :c:func:`PyStructSequence_GetItem`." msgstr "" -#: c-api/tuple.rst:209 +#: c-api/tuple.rst:224 msgid "" "Sets the field at index *pos* of the struct sequence *p* to value *o*. " "Like :c:func:`PyTuple_SET_ITEM`, this should only be used to fill in brand " "new instances." msgstr "" -#: c-api/tuple.rst:225 +#: c-api/tuple.rst:240 msgid "This function \"steals\" a reference to *o*." msgstr "" -#: c-api/tuple.rst:220 +#: c-api/tuple.rst:235 msgid "" "Similar to :c:func:`PyStructSequence_SetItem`, but implemented as a static " "inlined function." diff --git a/c-api/type.po b/c-api/type.po index e1d9569f..e528adad 100644 --- a/c-api/type.po +++ b/c-api/type.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -26,8 +27,8 @@ msgstr "" #: c-api/type.rst:18 msgid "" -"This is the type object for type objects; it is the same object as :class:" -"`type` in the Python layer." +"This is the type object for type objects; it is the same object " +"as :class:`type` in the Python layer." msgstr "" #: c-api/type.rst:24 @@ -52,9 +53,9 @@ msgstr "" msgid "" "Return the :c:member:`~PyTypeObject.tp_flags` member of *type*. This " "function is primarily meant for use with ``Py_LIMITED_API``; the individual " -"flag bits are guaranteed to be stable across Python releases, but access to :" -"c:member:`~PyTypeObject.tp_flags` itself is not part of the :ref:`limited " -"API `." +"flag bits are guaranteed to be stable across Python releases, but access " +"to :c:member:`~PyTypeObject.tp_flags` itself is not part of " +"the :ref:`limited API `." msgstr "" #: c-api/type.rst:49 @@ -64,32 +65,32 @@ msgstr "" #: c-api/type.rst:55 msgid "" "Return the type object's internal namespace, which is otherwise only exposed " -"via a read-only proxy (``cls.__dict__``). This is a replacement for " -"accessing :c:member:`~PyTypeObject.tp_dict` directly. The returned " -"dictionary must be treated as read-only." +"via a read-only proxy (:attr:`cls.__dict__ `). This is a " +"replacement for accessing :c:member:`~PyTypeObject.tp_dict` directly. The " +"returned dictionary must be treated as read-only." msgstr "" -#: c-api/type.rst:60 +#: c-api/type.rst:61 msgid "" "This function is meant for specific embedding and language-binding cases, " "where direct access to the dict is necessary and indirect access (e.g. via " "the proxy or :c:func:`PyObject_GetAttr`) isn't adequate." msgstr "" -#: c-api/type.rst:64 +#: c-api/type.rst:65 msgid "" "Extension modules should continue to use ``tp_dict``, directly or " "indirectly, when setting up their own types." msgstr "" -#: c-api/type.rst:72 +#: c-api/type.rst:73 msgid "" "Invalidate the internal lookup cache for the type and all of its subtypes. " "This function must be called after any manual modification of the attributes " "or base classes of the type." msgstr "" -#: c-api/type.rst:79 +#: c-api/type.rst:80 msgid "" "Register *callback* as a type watcher. Return a non-negative integer ID " "which must be passed to future calls to :c:func:`PyType_Watch`. In case of " @@ -97,85 +98,86 @@ msgid "" "exception." msgstr "" -#: c-api/type.rst:89 +#: c-api/type.rst:90 msgid "" -"Clear watcher identified by *watcher_id* (previously returned from :c:func:" -"`PyType_AddWatcher`). Return ``0`` on success, ``-1`` on error (e.g. if " -"*watcher_id* was never registered.)" +"Clear watcher identified by *watcher_id* (previously returned " +"from :c:func:`PyType_AddWatcher`). Return ``0`` on success, ``-1`` on error " +"(e.g. if *watcher_id* was never registered.)" msgstr "" -#: c-api/type.rst:93 +#: c-api/type.rst:94 msgid "" "An extension should never call ``PyType_ClearWatcher`` with a *watcher_id* " -"that was not returned to it by a previous call to :c:func:" -"`PyType_AddWatcher`." +"that was not returned to it by a previous call " +"to :c:func:`PyType_AddWatcher`." msgstr "" -#: c-api/type.rst:102 +#: c-api/type.rst:103 msgid "" -"Mark *type* as watched. The callback granted *watcher_id* by :c:func:" -"`PyType_AddWatcher` will be called whenever :c:func:`PyType_Modified` " -"reports a change to *type*. (The callback may be called only once for a " -"series of consecutive modifications to *type*, if :c:func:`!_PyType_Lookup` " -"is not called on *type* between the modifications; this is an implementation " -"detail and subject to change.)" +"Mark *type* as watched. The callback granted *watcher_id* " +"by :c:func:`PyType_AddWatcher` will be called " +"whenever :c:func:`PyType_Modified` reports a change to *type*. (The callback " +"may be called only once for a series of consecutive modifications to *type*, " +"if :c:func:`!_PyType_Lookup` is not called on *type* between the " +"modifications; this is an implementation detail and subject to change.)" msgstr "" -#: c-api/type.rst:109 +#: c-api/type.rst:110 msgid "" "An extension should never call ``PyType_Watch`` with a *watcher_id* that was " "not returned to it by a previous call to :c:func:`PyType_AddWatcher`." msgstr "" -#: c-api/type.rst:117 +#: c-api/type.rst:118 msgid "Type of a type-watcher callback function." msgstr "" -#: c-api/type.rst:119 +#: c-api/type.rst:120 msgid "" "The callback must not modify *type* or cause :c:func:`PyType_Modified` to be " "called on *type* or any type in its MRO; violating this rule could cause " "infinite recursion." msgstr "" -#: c-api/type.rst:128 +#: c-api/type.rst:129 msgid "" "Return non-zero if the type object *o* sets the feature *feature*. Type " "features are denoted by single bit flags." msgstr "" -#: c-api/type.rst:134 +#: c-api/type.rst:135 msgid "" "Return true if the type object includes support for the cycle detector; this " "tests the type flag :c:macro:`Py_TPFLAGS_HAVE_GC`." msgstr "" -#: c-api/type.rst:140 +#: c-api/type.rst:141 msgid "Return true if *a* is a subtype of *b*." msgstr "" -#: c-api/type.rst:142 +#: c-api/type.rst:143 msgid "" -"This function only checks for actual subtypes, which means that :meth:" -"`~class.__subclasscheck__` is not called on *b*. Call :c:func:" -"`PyObject_IsSubclass` to do the same check that :func:`issubclass` would do." +"This function only checks for actual subtypes, which means " +"that :meth:`~type.__subclasscheck__` is not called on *b*. " +"Call :c:func:`PyObject_IsSubclass` to do the same check " +"that :func:`issubclass` would do." msgstr "" -#: c-api/type.rst:150 +#: c-api/type.rst:151 msgid "" "Generic handler for the :c:member:`~PyTypeObject.tp_alloc` slot of a type " "object. Use Python's default memory allocation mechanism to allocate a new " "instance and initialize all its contents to ``NULL``." msgstr "" -#: c-api/type.rst:156 +#: c-api/type.rst:157 msgid "" "Generic handler for the :c:member:`~PyTypeObject.tp_new` slot of a type " -"object. Create a new instance using the type's :c:member:`~PyTypeObject." -"tp_alloc` slot." +"object. Create a new instance using the " +"type's :c:member:`~PyTypeObject.tp_alloc` slot." msgstr "" -#: c-api/type.rst:161 +#: c-api/type.rst:162 msgid "" "Finalize a type object. This should be called on all type objects to finish " "their initialization. This function is responsible for adding inherited " @@ -183,30 +185,30 @@ msgid "" "and sets an exception on error." msgstr "" -#: c-api/type.rst:167 +#: c-api/type.rst:168 msgid "" "If some of the base classes implements the GC protocol and the provided type " "does not include the :c:macro:`Py_TPFLAGS_HAVE_GC` in its flags, then the GC " "protocol will be automatically implemented from its parents. On the " -"contrary, if the type being created does include :c:macro:" -"`Py_TPFLAGS_HAVE_GC` in its flags then it **must** implement the GC protocol " -"itself by at least implementing the :c:member:`~PyTypeObject.tp_traverse` " -"handle." +"contrary, if the type being created does " +"include :c:macro:`Py_TPFLAGS_HAVE_GC` in its flags then it **must** " +"implement the GC protocol itself by at least implementing " +"the :c:member:`~PyTypeObject.tp_traverse` handle." msgstr "" -#: c-api/type.rst:177 +#: c-api/type.rst:178 msgid "" -"Return the type's name. Equivalent to getting the type's ``__name__`` " -"attribute." +"Return the type's name. Equivalent to getting the " +"type's :attr:`~type.__name__` attribute." msgstr "" -#: c-api/type.rst:183 +#: c-api/type.rst:185 msgid "" -"Return the type's qualified name. Equivalent to getting the type's " -"``__qualname__`` attribute." +"Return the type's qualified name. Equivalent to getting the " +"type's :attr:`~type.__qualname__` attribute." msgstr "" -#: c-api/type.rst:190 +#: c-api/type.rst:192 msgid "" "Return the function pointer stored in the given slot. If the result is " "``NULL``, this indicates that either the slot is ``NULL``, or that the " @@ -214,107 +216,108 @@ msgid "" "result pointer into the appropriate function type." msgstr "" -#: c-api/type.rst:196 +#: c-api/type.rst:198 msgid "" "See :c:member:`PyType_Slot.slot` for possible values of the *slot* argument." msgstr "" -#: c-api/type.rst:200 +#: c-api/type.rst:202 msgid "" ":c:func:`PyType_GetSlot` can now accept all types. Previously, it was " "limited to :ref:`heap types `." msgstr "" -#: c-api/type.rst:206 +#: c-api/type.rst:208 msgid "" "Return the module object associated with the given type when the type was " "created using :c:func:`PyType_FromModuleAndSpec`." msgstr "" -#: c-api/type.rst:229 +#: c-api/type.rst:231 msgid "" "If no module is associated with the given type, sets :py:class:`TypeError` " "and returns ``NULL``." msgstr "" -#: c-api/type.rst:212 +#: c-api/type.rst:214 msgid "" "This function is usually used to get the module in which a method is " "defined. Note that in such a method, ``PyType_GetModule(Py_TYPE(self))`` may " "not return the intended result. ``Py_TYPE(self)`` may be a *subclass* of the " "intended class, and subclasses are not necessarily defined in the same " "module as their superclass. See :c:type:`PyCMethod` to get the class that " -"defines the method. See :c:func:`PyType_GetModuleByDef` for cases when :c:" -"type:`!PyCMethod` cannot be used." +"defines the method. See :c:func:`PyType_GetModuleByDef` for cases " +"when :c:type:`!PyCMethod` cannot be used." msgstr "" -#: c-api/type.rst:225 +#: c-api/type.rst:227 msgid "" "Return the state of the module object associated with the given type. This " -"is a shortcut for calling :c:func:`PyModule_GetState()` on the result of :c:" -"func:`PyType_GetModule`." +"is a shortcut for calling :c:func:`PyModule_GetState()` on the result " +"of :c:func:`PyType_GetModule`." msgstr "" -#: c-api/type.rst:232 +#: c-api/type.rst:234 msgid "" "If the *type* has an associated module but its state is ``NULL``, returns " "``NULL`` without setting an exception." msgstr "" -#: c-api/type.rst:239 +#: c-api/type.rst:241 msgid "" -"Find the first superclass whose module was created from the given :c:type:" -"`PyModuleDef` *def*, and return that module." +"Find the first superclass whose module was created from the " +"given :c:type:`PyModuleDef` *def*, and return that module." msgstr "" -#: c-api/type.rst:242 +#: c-api/type.rst:244 msgid "" "If no module is found, raises a :py:class:`TypeError` and returns ``NULL``." msgstr "" -#: c-api/type.rst:244 +#: c-api/type.rst:246 msgid "" -"This function is intended to be used together with :c:func:" -"`PyModule_GetState()` to get module state from slot methods (such as :c:" -"member:`~PyTypeObject.tp_init` or :c:member:`~PyNumberMethods.nb_add`) and " -"other places where a method's defining class cannot be passed using the :c:" -"type:`PyCMethod` calling convention." +"This function is intended to be used together " +"with :c:func:`PyModule_GetState()` to get module state from slot methods " +"(such as :c:member:`~PyTypeObject.tp_init` " +"or :c:member:`~PyNumberMethods.nb_add`) and other places where a method's " +"defining class cannot be passed using the :c:type:`PyCMethod` calling " +"convention." msgstr "" -#: c-api/type.rst:254 +#: c-api/type.rst:256 msgid "Attempt to assign a version tag to the given type." msgstr "" -#: c-api/type.rst:256 +#: c-api/type.rst:258 msgid "" "Returns 1 if the type already had a valid version tag or a new one was " "assigned, or 0 if a new tag could not be assigned." msgstr "" -#: c-api/type.rst:263 +#: c-api/type.rst:265 msgid "Creating Heap-Allocated Types" msgstr "" -#: c-api/type.rst:265 +#: c-api/type.rst:267 msgid "" "The following functions and structs are used to create :ref:`heap types " "`." msgstr "" -#: c-api/type.rst:270 +#: c-api/type.rst:272 msgid "" -"Create and return a :ref:`heap type ` from the *spec* (see :c:" -"macro:`Py_TPFLAGS_HEAPTYPE`)." +"Create and return a :ref:`heap type ` from the *spec* " +"(see :c:macro:`Py_TPFLAGS_HEAPTYPE`)." msgstr "" -#: c-api/type.rst:273 +#: c-api/type.rst:275 msgid "" "The metaclass *metaclass* is used to construct the resulting type object. " "When *metaclass* is ``NULL``, the metaclass is derived from *bases* (or " "*Py_tp_base[s]* slots if *bases* is ``NULL``, see below)." msgstr "" -#: c-api/type.rst:277 +#: c-api/type.rst:279 msgid "" "Metaclasses that override :c:member:`~PyTypeObject.tp_new` are not " "supported, except if ``tp_new`` is ``NULL``. (For backwards compatibility, " @@ -323,7 +326,7 @@ msgid "" "deprecated and in Python 3.14+ such metaclasses will not be supported.)" msgstr "" -#: c-api/type.rst:284 +#: c-api/type.rst:286 msgid "" "The *bases* argument can be used to specify base classes; it can either be " "only one class or a tuple of classes. If *bases* is ``NULL``, the " @@ -332,63 +335,63 @@ msgid "" "derives from :class:`object`." msgstr "" -#: c-api/type.rst:290 +#: c-api/type.rst:292 msgid "" "The *module* argument can be used to record the module in which the new " "class is defined. It must be a module object or ``NULL``. If not ``NULL``, " -"the module is associated with the new type and can later be retrieved with :" -"c:func:`PyType_GetModule`. The associated module is not inherited by " +"the module is associated with the new type and can later be retrieved " +"with :c:func:`PyType_GetModule`. The associated module is not inherited by " "subclasses; it must be specified for each class individually." msgstr "" -#: c-api/type.rst:297 +#: c-api/type.rst:299 msgid "This function calls :c:func:`PyType_Ready` on the new type." msgstr "" -#: c-api/type.rst:299 +#: c-api/type.rst:301 msgid "" -"Note that this function does *not* fully match the behavior of calling :py:" -"class:`type() ` or using the :keyword:`class` statement. With user-" -"provided base types or metaclasses, prefer :ref:`calling ` :py:" -"class:`type` (or the metaclass) over ``PyType_From*`` functions. " +"Note that this function does *not* fully match the behavior of " +"calling :py:class:`type() ` or using the :keyword:`class` statement. " +"With user-provided base types or metaclasses, prefer :ref:`calling ` :py:class:`type` (or the metaclass) over ``PyType_From*`` functions. " "Specifically:" msgstr "" -#: c-api/type.rst:306 +#: c-api/type.rst:308 msgid "" ":py:meth:`~object.__new__` is not called on the new class (and it must be " "set to ``type.__new__``)." msgstr "" -#: c-api/type.rst:308 +#: c-api/type.rst:310 msgid ":py:meth:`~object.__init__` is not called on the new class." msgstr "" -#: c-api/type.rst:309 +#: c-api/type.rst:311 msgid ":py:meth:`~object.__init_subclass__` is not called on any bases." msgstr "" -#: c-api/type.rst:310 +#: c-api/type.rst:312 msgid ":py:meth:`~object.__set_name__` is not called on new descriptors." msgstr "" -#: c-api/type.rst:316 +#: c-api/type.rst:318 msgid "Equivalent to ``PyType_FromMetaclass(NULL, module, spec, bases)``." msgstr "" -#: c-api/type.rst:322 +#: c-api/type.rst:324 msgid "" "The function now accepts a single class as the *bases* argument and ``NULL`` " "as the ``tp_doc`` slot." msgstr "" -#: c-api/type.rst:344 +#: c-api/type.rst:346 msgid "" "The function now finds and uses a metaclass corresponding to the provided " "base classes. Previously, only :class:`type` instances were returned." msgstr "" -#: c-api/type.rst:347 c-api/type.rst:363 +#: c-api/type.rst:349 c-api/type.rst:365 msgid "" "The :c:member:`~PyTypeObject.tp_new` of the metaclass is *ignored*. which " "may result in incomplete initialization. Creating classes whose metaclass " @@ -396,60 +399,61 @@ msgid "" "it will be no longer allowed." msgstr "" -#: c-api/type.rst:338 +#: c-api/type.rst:340 msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, bases)``." msgstr "" -#: c-api/type.rst:355 +#: c-api/type.rst:357 msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``." msgstr "" -#: c-api/type.rst:359 +#: c-api/type.rst:361 msgid "" "The function now finds and uses a metaclass corresponding to the base " "classes provided in *Py_tp_base[s]* slots. Previously, only :class:`type` " "instances were returned." msgstr "" -#: c-api/type.rst:380 +#: c-api/type.rst:382 msgid "Structure defining a type's behavior." msgstr "" -#: c-api/type.rst:384 +#: c-api/type.rst:386 msgid "Name of the type, used to set :c:member:`PyTypeObject.tp_name`." msgstr "" -#: c-api/type.rst:388 +#: c-api/type.rst:390 msgid "" -"If positive, specifies the size of the instance in bytes. It is used to set :" -"c:member:`PyTypeObject.tp_basicsize`." +"If positive, specifies the size of the instance in bytes. It is used to " +"set :c:member:`PyTypeObject.tp_basicsize`." msgstr "" -#: c-api/type.rst:391 +#: c-api/type.rst:393 msgid "" "If zero, specifies that :c:member:`~PyTypeObject.tp_basicsize` should be " "inherited." msgstr "" -#: c-api/type.rst:394 +#: c-api/type.rst:396 msgid "" "If negative, the absolute value specifies how much space instances of the " -"class need *in addition* to the superclass. Use :c:func:" -"`PyObject_GetTypeData` to get a pointer to subclass-specific memory reserved " -"this way." +"class need *in addition* to the superclass. " +"Use :c:func:`PyObject_GetTypeData` to get a pointer to subclass-specific " +"memory reserved this way." msgstr "" -#: c-api/type.rst:401 +#: c-api/type.rst:403 msgid "Previously, this field could not be negative." msgstr "" -#: c-api/type.rst:405 +#: c-api/type.rst:407 msgid "" -"Size of one element of a variable-size type, in bytes. Used to set :c:member:" -"`PyTypeObject.tp_itemsize`. See ``tp_itemsize`` documentation for caveats." +"Size of one element of a variable-size type, in bytes. Used to " +"set :c:member:`PyTypeObject.tp_itemsize`. See ``tp_itemsize`` documentation " +"for caveats." msgstr "" -#: c-api/type.rst:409 +#: c-api/type.rst:411 msgid "" "If zero, :c:member:`~PyTypeObject.tp_itemsize` is inherited. Extending " "arbitrary variable-sized classes is dangerous, since some types use a fixed " @@ -458,150 +462,150 @@ msgid "" "only possible in the following situations:" msgstr "" -#: c-api/type.rst:416 +#: c-api/type.rst:418 msgid "" "The base is not variable-sized (its :c:member:`~PyTypeObject.tp_itemsize`)." msgstr "" -#: c-api/type.rst:418 +#: c-api/type.rst:420 msgid "" "The requested :c:member:`PyType_Spec.basicsize` is positive, suggesting that " "the memory layout of the base class is known." msgstr "" -#: c-api/type.rst:420 +#: c-api/type.rst:422 msgid "" "The requested :c:member:`PyType_Spec.basicsize` is zero, suggesting that the " "subclass does not access the instance's memory directly." msgstr "" -#: c-api/type.rst:423 +#: c-api/type.rst:425 msgid "With the :c:macro:`Py_TPFLAGS_ITEMS_AT_END` flag." msgstr "" -#: c-api/type.rst:427 +#: c-api/type.rst:429 msgid "Type flags, used to set :c:member:`PyTypeObject.tp_flags`." msgstr "" -#: c-api/type.rst:429 +#: c-api/type.rst:431 msgid "" -"If the ``Py_TPFLAGS_HEAPTYPE`` flag is not set, :c:func:" -"`PyType_FromSpecWithBases` sets it automatically." +"If the ``Py_TPFLAGS_HEAPTYPE`` flag is not " +"set, :c:func:`PyType_FromSpecWithBases` sets it automatically." msgstr "" -#: c-api/type.rst:434 +#: c-api/type.rst:436 msgid "" "Array of :c:type:`PyType_Slot` structures. Terminated by the special slot " "value ``{0, NULL}``." msgstr "" -#: c-api/type.rst:437 +#: c-api/type.rst:439 msgid "Each slot ID should be specified at most once." msgstr "" -#: c-api/type.rst:447 +#: c-api/type.rst:449 msgid "" "Structure defining optional functionality of a type, containing a slot ID " "and a value pointer." msgstr "" -#: c-api/type.rst:452 +#: c-api/type.rst:454 msgid "A slot ID." msgstr "" -#: c-api/type.rst:454 +#: c-api/type.rst:456 msgid "" -"Slot IDs are named like the field names of the structures :c:type:" -"`PyTypeObject`, :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, :c:" -"type:`PyMappingMethods` and :c:type:`PyAsyncMethods` with an added ``Py_`` " -"prefix. For example, use:" +"Slot IDs are named like the field names of the " +"structures :c:type:`PyTypeObject`, :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, :c:type:`PyMappingMethods` " +"and :c:type:`PyAsyncMethods` with an added ``Py_`` prefix. For example, use:" msgstr "" -#: c-api/type.rst:460 +#: c-api/type.rst:462 msgid "``Py_tp_dealloc`` to set :c:member:`PyTypeObject.tp_dealloc`" msgstr "" -#: c-api/type.rst:461 +#: c-api/type.rst:463 msgid "``Py_nb_add`` to set :c:member:`PyNumberMethods.nb_add`" msgstr "" -#: c-api/type.rst:462 +#: c-api/type.rst:464 msgid "``Py_sq_length`` to set :c:member:`PySequenceMethods.sq_length`" msgstr "" -#: c-api/type.rst:464 +#: c-api/type.rst:466 msgid "" "The following “offset” fields cannot be set using :c:type:`PyType_Slot`:" msgstr "" -#: c-api/type.rst:466 +#: c-api/type.rst:468 msgid "" -":c:member:`~PyTypeObject.tp_weaklistoffset` (use :c:macro:" -"`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)" +":c:member:`~PyTypeObject.tp_weaklistoffset` " +"(use :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)" msgstr "" -#: c-api/type.rst:468 +#: c-api/type.rst:470 msgid "" -":c:member:`~PyTypeObject.tp_dictoffset` (use :c:macro:" -"`Py_TPFLAGS_MANAGED_DICT` instead if possible)" +":c:member:`~PyTypeObject.tp_dictoffset` " +"(use :c:macro:`Py_TPFLAGS_MANAGED_DICT` instead if possible)" msgstr "" -#: c-api/type.rst:470 +#: c-api/type.rst:472 msgid "" ":c:member:`~PyTypeObject.tp_vectorcall_offset` (use " "``\"__vectorcalloffset__\"`` in :ref:`PyMemberDef `)" msgstr "" -#: c-api/type.rst:474 +#: c-api/type.rst:476 msgid "" "If it is not possible to switch to a ``MANAGED`` flag (for example, for " -"vectorcall or to support Python older than 3.12), specify the offset in :c:" -"member:`Py_tp_members `. See :ref:`PyMemberDef " -"documentation ` for details." +"vectorcall or to support Python older than 3.12), specify the offset " +"in :c:member:`Py_tp_members `. " +"See :ref:`PyMemberDef documentation ` for details." msgstr "" -#: c-api/type.rst:480 +#: c-api/type.rst:482 msgid "The following fields cannot be set at all when creating a heap type:" msgstr "" -#: c-api/type.rst:482 +#: c-api/type.rst:484 msgid "" -":c:member:`~PyTypeObject.tp_vectorcall` (use :c:member:`~PyTypeObject." -"tp_new` and/or :c:member:`~PyTypeObject.tp_init`)" +":c:member:`~PyTypeObject.tp_vectorcall` " +"(use :c:member:`~PyTypeObject.tp_new` and/" +"or :c:member:`~PyTypeObject.tp_init`)" msgstr "" -#: c-api/type.rst:486 +#: c-api/type.rst:488 msgid "" -"Internal fields: :c:member:`~PyTypeObject.tp_dict`, :c:member:`~PyTypeObject." -"tp_mro`, :c:member:`~PyTypeObject.tp_cache`, :c:member:`~PyTypeObject." -"tp_subclasses`, and :c:member:`~PyTypeObject.tp_weaklist`." +"Internal " +"fields: :c:member:`~PyTypeObject.tp_dict`, :c:member:`~PyTypeObject.tp_mro`, :c:member:`~PyTypeObject.tp_cache`, :c:member:`~PyTypeObject.tp_subclasses`, " +"and :c:member:`~PyTypeObject.tp_weaklist`." msgstr "" -#: c-api/type.rst:493 +#: c-api/type.rst:495 msgid "" "Setting :c:data:`Py_tp_bases` or :c:data:`Py_tp_base` may be problematic on " -"some platforms. To avoid issues, use the *bases* argument of :c:func:" -"`PyType_FromSpecWithBases` instead." +"some platforms. To avoid issues, use the *bases* argument " +"of :c:func:`PyType_FromSpecWithBases` instead." msgstr "" #: c-api/type.rst:500 msgid "Slots in :c:type:`PyBufferProcs` may be set in the unlimited API." msgstr "" -#: c-api/type.rst:502 +#: c-api/type.rst:503 msgid "" -":c:member:`~PyBufferProcs.bf_getbuffer` and :c:member:`~PyBufferProcs." -"bf_releasebuffer` are now available under the :ref:`limited API `." +":c:member:`~PyBufferProcs.bf_getbuffer` " +"and :c:member:`~PyBufferProcs.bf_releasebuffer` are now available under " +"the :ref:`limited API `." msgstr "" -#: c-api/type.rst:509 +#: c-api/type.rst:510 msgid "" "The desired value of the slot. In most cases, this is a pointer to a " "function." msgstr "" -#: c-api/type.rst:512 +#: c-api/type.rst:513 msgid "Slots other than ``Py_tp_doc`` may not be ``NULL``." msgstr "" diff --git a/c-api/typehints.po b/c-api/typehints.po index 70c91e6f..84d84429 100644 --- a/c-api/typehints.po +++ b/c-api/typehints.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -32,20 +33,32 @@ msgid "" "Create a :ref:`GenericAlias ` object. Equivalent to " "calling the Python class :class:`types.GenericAlias`. The *origin* and " "*args* arguments set the ``GenericAlias``\\ 's ``__origin__`` and " -"``__args__`` attributes respectively. *origin* should be a :c:expr:" -"`PyTypeObject*`, and *args* can be a :c:expr:`PyTupleObject*` or any " -"``PyObject*``. If *args* passed is not a tuple, a 1-tuple is automatically " -"constructed and ``__args__`` is set to ``(args,)``. Minimal checking is done " -"for the arguments, so the function will succeed even if *origin* is not a " -"type. The ``GenericAlias``\\ 's ``__parameters__`` attribute is constructed " -"lazily from ``__args__``. On failure, an exception is raised and ``NULL`` " -"is returned." +"``__args__`` attributes respectively. *origin* should be " +"a :c:expr:`PyTypeObject*`, and *args* can be a :c:expr:`PyTupleObject*` or " +"any ``PyObject*``. If *args* passed is not a tuple, a 1-tuple is " +"automatically constructed and ``__args__`` is set to ``(args,)``. Minimal " +"checking is done for the arguments, so the function will succeed even if " +"*origin* is not a type. The ``GenericAlias``\\ 's ``__parameters__`` " +"attribute is constructed lazily from ``__args__``. On failure, an exception " +"is raised and ``NULL`` is returned." msgstr "" #: c-api/typehints.rst:28 msgid "Here's an example of how to make an extension type generic::" msgstr "" +#: c-api/typehints.rst:30 +msgid "" +"...\n" +"static PyMethodDef my_obj_methods[] = {\n" +" // Other methods.\n" +" ...\n" +" {\"__class_getitem__\", Py_GenericAlias, METH_O|METH_CLASS, \"See PEP " +"585\"}\n" +" ...\n" +"}" +msgstr "" + #: c-api/typehints.rst:38 msgid "The data model method :meth:`~object.__class_getitem__`." msgstr "" diff --git a/c-api/typeobj.po b/c-api/typeobj.po index 6ede1e51..d4dc28c5 100644 --- a/c-api/typeobj.po +++ b/c-api/typeobj.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -44,8 +45,8 @@ msgstr "" #: c-api/typeobj.rst:23 msgid "" "In addition to the following quick reference, the :ref:`typedef-examples` " -"section provides at-a-glance insight into the meaning and use of :c:type:" -"`PyTypeObject`." +"section provides at-a-glance insight into the meaning and use " +"of :c:type:`PyTypeObject`." msgstr "" #: c-api/typeobj.rst:29 @@ -583,10 +584,29 @@ msgstr "" msgid "**\"D\"**: default (if slot is set to ``NULL``)" msgstr "" +#: c-api/typeobj.rst:172 +msgid "" +"X - PyType_Ready sets this value if it is NULL\n" +"~ - PyType_Ready always sets this value (it should be NULL)\n" +"? - PyType_Ready may set this value depending on other slots\n" +"\n" +"Also see the inheritance column (\"I\")." +msgstr "" + #: c-api/typeobj.rst:180 msgid "**\"I\"**: inheritance" msgstr "" +#: c-api/typeobj.rst:182 +msgid "" +"X - type slot is inherited via *PyType_Ready* if defined with a *NULL* " +"value\n" +"% - the slots of the sub-struct are inherited individually\n" +"G - inherited, but only in combination with other slots; see the slot's " +"description\n" +"? - it's complicated; see the slot's description" +msgstr "" + #: c-api/typeobj.rst:189 msgid "" "Note that some slots are effectively inherited through the normal attribute " @@ -1097,22 +1117,113 @@ msgstr "" #: c-api/typeobj.rst:475 msgid "" -"The structure definition for :c:type:`PyTypeObject` can be found in :file:" -"`Include/object.h`. For convenience of reference, this repeats the " +"The structure definition for :c:type:`PyTypeObject` can be found " +"in :file:`Include/object.h`. For convenience of reference, this repeats the " "definition found there:" msgstr "" +#: c-api/typeobj.rst:481 +msgid "" +"typedef struct _typeobject {\n" +" PyObject_VAR_HEAD\n" +" const char *tp_name; /* For printing, in format \".\" */\n" +" Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */\n" +"\n" +" /* Methods to implement standard operations */\n" +"\n" +" destructor tp_dealloc;\n" +" Py_ssize_t tp_vectorcall_offset;\n" +" getattrfunc tp_getattr;\n" +" setattrfunc tp_setattr;\n" +" PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)\n" +" or tp_reserved (Python 3) */\n" +" reprfunc tp_repr;\n" +"\n" +" /* Method suites for standard classes */\n" +"\n" +" PyNumberMethods *tp_as_number;\n" +" PySequenceMethods *tp_as_sequence;\n" +" PyMappingMethods *tp_as_mapping;\n" +"\n" +" /* More standard operations (here for binary compatibility) */\n" +"\n" +" hashfunc tp_hash;\n" +" ternaryfunc tp_call;\n" +" reprfunc tp_str;\n" +" getattrofunc tp_getattro;\n" +" setattrofunc tp_setattro;\n" +"\n" +" /* Functions to access object as input/output buffer */\n" +" PyBufferProcs *tp_as_buffer;\n" +"\n" +" /* Flags to define presence of optional/expanded features */\n" +" unsigned long tp_flags;\n" +"\n" +" const char *tp_doc; /* Documentation string */\n" +"\n" +" /* Assigned meaning in release 2.0 */\n" +" /* call function for all accessible objects */\n" +" traverseproc tp_traverse;\n" +"\n" +" /* delete references to contained objects */\n" +" inquiry tp_clear;\n" +"\n" +" /* Assigned meaning in release 2.1 */\n" +" /* rich comparisons */\n" +" richcmpfunc tp_richcompare;\n" +"\n" +" /* weak reference enabler */\n" +" Py_ssize_t tp_weaklistoffset;\n" +"\n" +" /* Iterators */\n" +" getiterfunc tp_iter;\n" +" iternextfunc tp_iternext;\n" +"\n" +" /* Attribute descriptor and subclassing stuff */\n" +" struct PyMethodDef *tp_methods;\n" +" struct PyMemberDef *tp_members;\n" +" struct PyGetSetDef *tp_getset;\n" +" // Strong reference on a heap type, borrowed reference on a static type\n" +" struct _typeobject *tp_base;\n" +" PyObject *tp_dict;\n" +" descrgetfunc tp_descr_get;\n" +" descrsetfunc tp_descr_set;\n" +" Py_ssize_t tp_dictoffset;\n" +" initproc tp_init;\n" +" allocfunc tp_alloc;\n" +" newfunc tp_new;\n" +" freefunc tp_free; /* Low-level free-memory routine */\n" +" inquiry tp_is_gc; /* For PyObject_IS_GC */\n" +" PyObject *tp_bases;\n" +" PyObject *tp_mro; /* method resolution order */\n" +" PyObject *tp_cache;\n" +" PyObject *tp_subclasses;\n" +" PyObject *tp_weaklist;\n" +" destructor tp_del;\n" +"\n" +" /* Type attribute cache version tag. Added in version 2.6 */\n" +" unsigned int tp_version_tag;\n" +"\n" +" destructor tp_finalize;\n" +" vectorcallfunc tp_vectorcall;\n" +"\n" +" /* bitset of which type-watchers care about this type */\n" +" unsigned char tp_watched;\n" +"} PyTypeObject;\n" +msgstr "" + #: c-api/typeobj.rst:485 msgid "PyObject Slots" msgstr "" #: c-api/typeobj.rst:487 msgid "" -"The type object structure extends the :c:type:`PyVarObject` structure. The :" -"c:member:`~PyVarObject.ob_size` field is used for dynamic types (created by :" -"c:func:`!type_new`, usually called from a class statement). Note that :c:" -"data:`PyType_Type` (the metatype) initializes :c:member:`~PyTypeObject." -"tp_itemsize`, which means that its instances (i.e. type objects) *must* have " +"The type object structure extends the :c:type:`PyVarObject` structure. " +"The :c:member:`~PyVarObject.ob_size` field is used for dynamic types " +"(created by :c:func:`!type_new`, usually called from a class statement). " +"Note that :c:data:`PyType_Type` (the metatype) " +"initializes :c:member:`~PyTypeObject.tp_itemsize`, which means that its " +"instances (i.e. type objects) *must* have " "the :c:member:`~PyVarObject.ob_size` field." msgstr "" @@ -1120,23 +1231,23 @@ msgstr "" msgid "" "This is the type object's reference count, initialized to ``1`` by the " "``PyObject_HEAD_INIT`` macro. Note that for :ref:`statically allocated type " -"objects `, the type's instances (objects whose :c:member:" -"`~PyObject.ob_type` points back to the type) do *not* count as references. " -"But for :ref:`dynamically allocated type objects `, the " -"instances *do* count as references." +"objects `, the type's instances (objects " +"whose :c:member:`~PyObject.ob_type` points back to the type) do *not* count " +"as references. But for :ref:`dynamically allocated type objects `, the instances *do* count as references." msgstr "" #: c-api/typeobj.rst:526 c-api/typeobj.rst:562 c-api/typeobj.rst:649 -#: c-api/typeobj.rst:749 c-api/typeobj.rst:783 c-api/typeobj.rst:825 -#: c-api/typeobj.rst:854 c-api/typeobj.rst:899 c-api/typeobj.rst:937 -#: c-api/typeobj.rst:984 c-api/typeobj.rst:1019 c-api/typeobj.rst:1068 -#: c-api/typeobj.rst:1088 c-api/typeobj.rst:1120 c-api/typeobj.rst:1158 -#: c-api/typeobj.rst:1193 c-api/typeobj.rst:1258 c-api/typeobj.rst:1307 -#: c-api/typeobj.rst:1355 c-api/typeobj.rst:1491 c-api/typeobj.rst:1588 -#: c-api/typeobj.rst:1636 c-api/typeobj.rst:1664 c-api/typeobj.rst:1708 -#: c-api/typeobj.rst:1766 c-api/typeobj.rst:1813 c-api/typeobj.rst:1874 -#: c-api/typeobj.rst:1937 c-api/typeobj.rst:1997 c-api/typeobj.rst:2020 -#: c-api/typeobj.rst:2054 c-api/typeobj.rst:2114 c-api/typeobj.rst:2137 +#: c-api/typeobj.rst:762 c-api/typeobj.rst:796 c-api/typeobj.rst:838 +#: c-api/typeobj.rst:867 c-api/typeobj.rst:912 c-api/typeobj.rst:950 +#: c-api/typeobj.rst:997 c-api/typeobj.rst:1032 c-api/typeobj.rst:1082 +#: c-api/typeobj.rst:1102 c-api/typeobj.rst:1134 c-api/typeobj.rst:1172 +#: c-api/typeobj.rst:1207 c-api/typeobj.rst:1272 c-api/typeobj.rst:1321 +#: c-api/typeobj.rst:1369 c-api/typeobj.rst:1505 c-api/typeobj.rst:1602 +#: c-api/typeobj.rst:1650 c-api/typeobj.rst:1678 c-api/typeobj.rst:1722 +#: c-api/typeobj.rst:1780 c-api/typeobj.rst:1827 c-api/typeobj.rst:1888 +#: c-api/typeobj.rst:1951 c-api/typeobj.rst:2011 c-api/typeobj.rst:2034 +#: c-api/typeobj.rst:2068 c-api/typeobj.rst:2117 c-api/typeobj.rst:2140 msgid "**Inheritance:**" msgstr "" @@ -1156,16 +1267,21 @@ msgid "" "doing anything else. This is typically done like this::" msgstr "" +#: c-api/typeobj.rst:519 +msgid "Foo_Type.ob_type = &PyType_Type;" +msgstr "" + #: c-api/typeobj.rst:521 msgid "" -"This should be done before any instances of the type are created. :c:func:" -"`PyType_Ready` checks if :c:member:`~PyObject.ob_type` is ``NULL``, and if " -"so, initializes it to the :c:member:`~PyObject.ob_type` field of the base " -"class. :c:func:`PyType_Ready` will not change this field if it is non-zero." +"This should be done before any instances of the type are " +"created. :c:func:`PyType_Ready` checks if :c:member:`~PyObject.ob_type` is " +"``NULL``, and if so, initializes it to the :c:member:`~PyObject.ob_type` " +"field of the base class. :c:func:`PyType_Ready` will not change this field " +"if it is non-zero." msgstr "" -#: c-api/typeobj.rst:710 c-api/typeobj.rst:919 c-api/typeobj.rst:1615 -#: c-api/typeobj.rst:1768 c-api/typeobj.rst:1859 c-api/typeobj.rst:2116 +#: c-api/typeobj.rst:723 c-api/typeobj.rst:932 c-api/typeobj.rst:1629 +#: c-api/typeobj.rst:1782 c-api/typeobj.rst:1873 c-api/typeobj.rst:2119 msgid "This field is inherited by subtypes." msgstr "" @@ -1188,8 +1304,8 @@ msgstr "" msgid "" "This could be used for various debugging purposes; currently the only uses " "are the :func:`sys.getobjects` function and to print the objects that are " -"still alive at the end of a run when the environment variable :envvar:" -"`PYTHONDUMPREFS` is set." +"still alive at the end of a run when the environment " +"variable :envvar:`PYTHONDUMPREFS` is set." msgstr "" #: c-api/typeobj.rst:550 @@ -1215,8 +1331,9 @@ msgstr "" msgid "" "Each slot has a section describing inheritance. If :c:func:`PyType_Ready` " "may set a value when the field is set to ``NULL`` then there will also be a " -"\"Default\" section. (Note that many fields set on :c:data:" -"`PyBaseObject_Type` and :c:data:`PyType_Type` effectively act as defaults.)" +"\"Default\" section. (Note that many fields set " +"on :c:data:`PyBaseObject_Type` and :c:data:`PyType_Type` effectively act as " +"defaults.)" msgstr "" #: c-api/typeobj.rst:577 @@ -1226,9 +1343,9 @@ msgid "" "module name, followed by a dot, followed by the type name; for built-in " "types, it should be just the type name. If the module is a submodule of a " "package, the full package name is part of the full module name. For " -"example, a type named :class:`!T` defined in module :mod:`!M` in subpackage :" -"mod:`!Q` in package :mod:`!P` should have the :c:member:`~PyTypeObject." -"tp_name` initializer ``\"P.Q.M.T\"``." +"example, a type named :class:`!T` defined in module :mod:`!M` in " +"subpackage :mod:`!Q` in package :mod:`!P` should have " +"the :c:member:`~PyTypeObject.tp_name` initializer ``\"P.Q.M.T\"``." msgstr "" #: c-api/typeobj.rst:585 @@ -1242,25 +1359,25 @@ msgstr "" msgid "" "For :ref:`statically allocated type objects `, the *tp_name* " "field should contain a dot. Everything before the last dot is made " -"accessible as the :attr:`__module__` attribute, and everything after the " -"last dot is made accessible as the :attr:`~definition.__name__` attribute." +"accessible as the :attr:`~type.__module__` attribute, and everything after " +"the last dot is made accessible as the :attr:`~type.__name__` attribute." msgstr "" #: c-api/typeobj.rst:596 msgid "" "If no dot is present, the entire :c:member:`~PyTypeObject.tp_name` field is " -"made accessible as the :attr:`~definition.__name__` attribute, and the :attr:" -"`__module__` attribute is undefined (unless explicitly set in the " -"dictionary, as explained above). This means your type will be impossible to " -"pickle. Additionally, it will not be listed in module documentations " -"created with pydoc." +"made accessible as the :attr:`~type.__name__` attribute, and " +"the :attr:`~type.__module__` attribute is undefined (unless explicitly set " +"in the dictionary, as explained above). This means your type will be " +"impossible to pickle. Additionally, it will not be listed in module " +"documentations created with pydoc." msgstr "" #: c-api/typeobj.rst:602 msgid "" -"This field must not be ``NULL``. It is the only required field in :c:func:" -"`PyTypeObject` (other than potentially :c:member:`~PyTypeObject." -"tp_itemsize`)." +"This field must not be ``NULL``. It is the only required field " +"in :c:func:`PyTypeObject` (other than " +"potentially :c:member:`~PyTypeObject.tp_itemsize`)." msgstr "" #: c-api/typeobj.rst:614 @@ -1270,8 +1387,8 @@ msgstr "" #: c-api/typeobj.rst:616 msgid "" -"There are two kinds of types: types with fixed-length instances have a zero :" -"c:member:`~PyTypeObject.tp_itemsize` field, types with variable-length " +"There are two kinds of types: types with fixed-length instances have a " +"zero :c:member:`~PyTypeObject.tp_itemsize` field, types with variable-length " "instances have a non-zero :c:member:`~PyTypeObject.tp_itemsize` field. For " "a type with fixed-length instances, all instances have the same size, given " "in :c:member:`~PyTypeObject.tp_basicsize`." @@ -1279,41 +1396,42 @@ msgstr "" #: c-api/typeobj.rst:621 msgid "" -"For a type with variable-length instances, the instances must have an :c:" -"member:`~PyVarObject.ob_size` field, and the instance size is :c:member:" -"`~PyTypeObject.tp_basicsize` plus N times :c:member:`~PyTypeObject." -"tp_itemsize`, where N is the \"length\" of the object. The value of N is " -"typically stored in the instance's :c:member:`~PyVarObject.ob_size` field. " -"There are exceptions: for example, ints use a negative :c:member:" -"`~PyVarObject.ob_size` to indicate a negative number, and N is " -"``abs(ob_size)`` there. Also, the presence of an :c:member:`~PyVarObject." -"ob_size` field in the instance layout doesn't mean that the instance " -"structure is variable-length (for example, the structure for the list type " -"has fixed-length instances, yet those instances have a meaningful :c:member:" -"`~PyVarObject.ob_size` field)." +"For a type with variable-length instances, the instances must have " +"an :c:member:`~PyVarObject.ob_size` field, and the instance size " +"is :c:member:`~PyTypeObject.tp_basicsize` plus N " +"times :c:member:`~PyTypeObject.tp_itemsize`, where N is the \"length\" of " +"the object. The value of N is typically stored in the " +"instance's :c:member:`~PyVarObject.ob_size` field. There are exceptions: " +"for example, ints use a negative :c:member:`~PyVarObject.ob_size` to " +"indicate a negative number, and N is ``abs(ob_size)`` there. Also, the " +"presence of an :c:member:`~PyVarObject.ob_size` field in the instance layout " +"doesn't mean that the instance structure is variable-length (for example, " +"the structure for the list type has fixed-length instances, yet those " +"instances have a meaningful :c:member:`~PyVarObject.ob_size` field)." msgstr "" #: c-api/typeobj.rst:632 msgid "" -"The basic size includes the fields in the instance declared by the macro :c:" -"macro:`PyObject_HEAD` or :c:macro:`PyObject_VAR_HEAD` (whichever is used to " -"declare the instance struct) and this in turn includes the :c:member:" -"`~PyObject._ob_prev` and :c:member:`~PyObject._ob_next` fields if they are " -"present. This means that the only correct way to get an initializer for " -"the :c:member:`~PyTypeObject.tp_basicsize` is to use the ``sizeof`` operator " -"on the struct used to declare the instance layout. The basic size does not " -"include the GC header size." +"The basic size includes the fields in the instance declared by the " +"macro :c:macro:`PyObject_HEAD` or :c:macro:`PyObject_VAR_HEAD` (whichever is " +"used to declare the instance struct) and this in turn includes " +"the :c:member:`~PyObject._ob_prev` and :c:member:`~PyObject._ob_next` " +"fields if they are present. This means that the only correct way to get an " +"initializer for the :c:member:`~PyTypeObject.tp_basicsize` is to use the " +"``sizeof`` operator on the struct used to declare the instance layout. The " +"basic size does not include the GC header size." msgstr "" #: c-api/typeobj.rst:640 msgid "" "A note about alignment: if the variable items require a particular " -"alignment, this should be taken care of by the value of :c:member:" -"`~PyTypeObject.tp_basicsize`. Example: suppose a type implements an array " -"of ``double``. :c:member:`~PyTypeObject.tp_itemsize` is ``sizeof(double)``. " -"It is the programmer's responsibility that :c:member:`~PyTypeObject." -"tp_basicsize` is a multiple of ``sizeof(double)`` (assuming this is the " -"alignment requirement for ``double``)." +"alignment, this should be taken care of by the value " +"of :c:member:`~PyTypeObject.tp_basicsize`. Example: suppose a type " +"implements an array of ``double``. :c:member:`~PyTypeObject.tp_itemsize` is " +"``sizeof(double)``. It is the programmer's responsibility " +"that :c:member:`~PyTypeObject.tp_basicsize` is a multiple of " +"``sizeof(double)`` (assuming this is the alignment requirement for " +"``double``)." msgstr "" #: c-api/typeobj.rst:647 @@ -1337,97 +1455,136 @@ msgid "" "The function signature is::" msgstr "" +#: c-api/typeobj.rst:663 +msgid "void tp_dealloc(PyObject *self);" +msgstr "" + #: c-api/typeobj.rst:665 msgid "" -"The destructor function is called by the :c:func:`Py_DECREF` and :c:func:" -"`Py_XDECREF` macros when the new reference count is zero. At this point, " -"the instance is still in existence, but there are no references to it. The " -"destructor function should free all references which the instance owns, free " -"all memory buffers owned by the instance (using the freeing function " -"corresponding to the allocation function used to allocate the buffer), and " -"call the type's :c:member:`~PyTypeObject.tp_free` function. If the type is " -"not subtypable (doesn't have the :c:macro:`Py_TPFLAGS_BASETYPE` flag bit " -"set), it is permissible to call the object deallocator directly instead of " +"The destructor function is called by the :c:func:`Py_DECREF` " +"and :c:func:`Py_XDECREF` macros when the new reference count is zero. At " +"this point, the instance is still in existence, but there are no references " +"to it. The destructor function should free all references which the " +"instance owns, free all memory buffers owned by the instance (using the " +"freeing function corresponding to the allocation function used to allocate " +"the buffer), and call the type's :c:member:`~PyTypeObject.tp_free` " +"function. If the type is not subtypable (doesn't have " +"the :c:macro:`Py_TPFLAGS_BASETYPE` flag bit set), it is permissible to call " +"the object deallocator directly instead of " "via :c:member:`~PyTypeObject.tp_free`. The object deallocator should be the " "one used to allocate the instance; this is normally :c:func:`PyObject_Del` " -"if the instance was allocated using :c:macro:`PyObject_New` or :c:macro:" -"`PyObject_NewVar`, or :c:func:`PyObject_GC_Del` if the instance was " -"allocated using :c:macro:`PyObject_GC_New` or :c:macro:`PyObject_GC_NewVar`." +"if the instance was allocated using :c:macro:`PyObject_New` " +"or :c:macro:`PyObject_NewVar`, or :c:func:`PyObject_GC_Del` if the instance " +"was allocated using :c:macro:`PyObject_GC_New` " +"or :c:macro:`PyObject_GC_NewVar`." msgstr "" #: c-api/typeobj.rst:680 msgid "" -"If the type supports garbage collection (has the :c:macro:" -"`Py_TPFLAGS_HAVE_GC` flag bit set), the destructor should call :c:func:" -"`PyObject_GC_UnTrack` before clearing any member fields." +"If the type supports garbage collection (has " +"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit set), the destructor should " +"call :c:func:`PyObject_GC_UnTrack` before clearing any member fields." +msgstr "" + +#: c-api/typeobj.rst:684 +msgid "" +"static void foo_dealloc(foo_object *self) {\n" +" PyObject_GC_UnTrack(self);\n" +" Py_CLEAR(self->ref);\n" +" Py_TYPE(self)->tp_free((PyObject *)self);\n" +"}" msgstr "" #: c-api/typeobj.rst:692 msgid "" "Finally, if the type is heap allocated (:c:macro:`Py_TPFLAGS_HEAPTYPE`), the " -"deallocator should release the owned reference to its type object (via :c:" -"func:`Py_DECREF`) after calling the type deallocator. In order to avoid " -"dangling pointers, the recommended way to achieve this is:" +"deallocator should release the owned reference to its type object " +"(via :c:func:`Py_DECREF`) after calling the type deallocator. In order to " +"avoid dangling pointers, the recommended way to achieve this is:" +msgstr "" + +#: c-api/typeobj.rst:698 +msgid "" +"static void foo_dealloc(foo_object *self) {\n" +" PyTypeObject *tp = Py_TYPE(self);\n" +" // free references and buffers here\n" +" tp->tp_free(self);\n" +" Py_DECREF(tp);\n" +"}" +msgstr "" + +#: c-api/typeobj.rst:709 +msgid "" +"In a garbage collected Python, :c:member:`!tp_dealloc` may be called from " +"any Python thread, not just the thread which created the object (if the " +"object becomes part of a refcount cycle, that cycle might be collected by a " +"garbage collection on any thread). This is not a problem for Python API " +"calls, since the thread on which :c:member:`!tp_dealloc` is called will own " +"the Global Interpreter Lock (GIL). However, if the object being destroyed " +"in turn destroys objects from some other C or C++ library, care should be " +"taken to ensure that destroying those objects on the thread which " +"called :c:member:`!tp_dealloc` will not violate any assumptions of the " +"library." msgstr "" -#: c-api/typeobj.rst:715 +#: c-api/typeobj.rst:728 msgid "" "An optional offset to a per-instance function that implements calling the " "object using the :ref:`vectorcall protocol `, a more efficient " "alternative of the simpler :c:member:`~PyTypeObject.tp_call`." msgstr "" -#: c-api/typeobj.rst:720 +#: c-api/typeobj.rst:733 msgid "" "This field is only used if the flag :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` is " "set. If so, this must be a positive integer containing the offset in the " "instance of a :c:type:`vectorcallfunc` pointer." msgstr "" -#: c-api/typeobj.rst:724 +#: c-api/typeobj.rst:737 msgid "" "The *vectorcallfunc* pointer may be ``NULL``, in which case the instance " "behaves as if :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` was not set: calling the " "instance falls back to :c:member:`~PyTypeObject.tp_call`." msgstr "" -#: c-api/typeobj.rst:728 +#: c-api/typeobj.rst:741 msgid "" -"Any class that sets ``Py_TPFLAGS_HAVE_VECTORCALL`` must also set :c:member:" -"`~PyTypeObject.tp_call` and make sure its behaviour is consistent with the " -"*vectorcallfunc* function. This can be done by setting *tp_call* to :c:func:" -"`PyVectorcall_Call`." +"Any class that sets ``Py_TPFLAGS_HAVE_VECTORCALL`` must also " +"set :c:member:`~PyTypeObject.tp_call` and make sure its behaviour is " +"consistent with the *vectorcallfunc* function. This can be done by setting " +"*tp_call* to :c:func:`PyVectorcall_Call`." msgstr "" -#: c-api/typeobj.rst:735 +#: c-api/typeobj.rst:748 msgid "" "Before version 3.8, this slot was named ``tp_print``. In Python 2.x, it was " "used for printing to a file. In Python 3.0 to 3.7, it was unused." msgstr "" -#: c-api/typeobj.rst:741 +#: c-api/typeobj.rst:754 msgid "" "Before version 3.12, it was not recommended for :ref:`mutable heap types " -"` to implement the vectorcall protocol. When a user sets :attr:" -"`~object.__call__` in Python code, only *tp_call* is updated, likely making " -"it inconsistent with the vectorcall function. Since 3.12, setting " -"``__call__`` will disable vectorcall optimization by clearing the :c:macro:" -"`Py_TPFLAGS_HAVE_VECTORCALL` flag." +"` to implement the vectorcall protocol. When a user " +"sets :attr:`~object.__call__` in Python code, only *tp_call* is updated, " +"likely making it inconsistent with the vectorcall function. Since 3.12, " +"setting ``__call__`` will disable vectorcall optimization by clearing " +"the :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` flag." msgstr "" -#: c-api/typeobj.rst:751 +#: c-api/typeobj.rst:764 msgid "" -"This field is always inherited. However, the :c:macro:" -"`Py_TPFLAGS_HAVE_VECTORCALL` flag is not always inherited. If it's not set, " -"then the subclass won't use :ref:`vectorcall `, except when :c:" -"func:`PyVectorcall_Call` is explicitly called." +"This field is always inherited. However, " +"the :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` flag is not always inherited. If " +"it's not set, then the subclass won't use :ref:`vectorcall `, " +"except when :c:func:`PyVectorcall_Call` is explicitly called." msgstr "" -#: c-api/typeobj.rst:760 +#: c-api/typeobj.rst:773 msgid "An optional pointer to the get-attribute-string function." msgstr "" -#: c-api/typeobj.rst:762 +#: c-api/typeobj.rst:775 msgid "" "This field is deprecated. When it is defined, it should point to a function " "that acts the same as the :c:member:`~PyTypeObject.tp_getattro` function, " @@ -1435,27 +1592,26 @@ msgid "" "attribute name." msgstr "" -#: c-api/typeobj.rst:960 -msgid "" -"Group: :c:member:`~PyTypeObject.tp_getattr`, :c:member:`~PyTypeObject." -"tp_getattro`" +#: c-api/typeobj.rst:973 +msgid "Group: :c:member:`~PyTypeObject.tp_getattr`, :c:member:`~PyTypeObject.tp_getattro`" msgstr "" -#: c-api/typeobj.rst:770 +#: c-api/typeobj.rst:783 msgid "" -"This field is inherited by subtypes together with :c:member:`~PyTypeObject." -"tp_getattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_getattr` " +"This field is inherited by subtypes together " +"with :c:member:`~PyTypeObject.tp_getattro`: a subtype inherits " +"both :c:member:`~PyTypeObject.tp_getattr` " "and :c:member:`~PyTypeObject.tp_getattro` from its base type when the " -"subtype's :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject." -"tp_getattro` are both ``NULL``." +"subtype's :c:member:`~PyTypeObject.tp_getattr` " +"and :c:member:`~PyTypeObject.tp_getattro` are both ``NULL``." msgstr "" -#: c-api/typeobj.rst:973 +#: c-api/typeobj.rst:986 msgid "" "An optional pointer to the function for setting and deleting attributes." msgstr "" -#: c-api/typeobj.rst:779 +#: c-api/typeobj.rst:792 msgid "" "This field is deprecated. When it is defined, it should point to a function " "that acts the same as the :c:member:`~PyTypeObject.tp_setattro` function, " @@ -1463,49 +1619,52 @@ msgid "" "attribute name." msgstr "" -#: c-api/typeobj.rst:986 -msgid "" -"Group: :c:member:`~PyTypeObject.tp_setattr`, :c:member:`~PyTypeObject." -"tp_setattro`" +#: c-api/typeobj.rst:999 +msgid "Group: :c:member:`~PyTypeObject.tp_setattr`, :c:member:`~PyTypeObject.tp_setattro`" msgstr "" -#: c-api/typeobj.rst:787 +#: c-api/typeobj.rst:800 msgid "" -"This field is inherited by subtypes together with :c:member:`~PyTypeObject." -"tp_setattro`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` " +"This field is inherited by subtypes together " +"with :c:member:`~PyTypeObject.tp_setattro`: a subtype inherits " +"both :c:member:`~PyTypeObject.tp_setattr` " "and :c:member:`~PyTypeObject.tp_setattro` from its base type when the " -"subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject." -"tp_setattro` are both ``NULL``." +"subtype's :c:member:`~PyTypeObject.tp_setattr` " +"and :c:member:`~PyTypeObject.tp_setattro` are both ``NULL``." msgstr "" -#: c-api/typeobj.rst:794 +#: c-api/typeobj.rst:807 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement :term:`awaitable` and :term:`asynchronous iterator` " "protocols at the C-level. See :ref:`async-structs` for details." msgstr "" -#: c-api/typeobj.rst:798 +#: c-api/typeobj.rst:811 msgid "Formerly known as ``tp_compare`` and ``tp_reserved``." msgstr "" -#: c-api/typeobj.rst:803 +#: c-api/typeobj.rst:816 msgid "" "The :c:member:`~PyTypeObject.tp_as_async` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: c-api/typeobj.rst:811 +#: c-api/typeobj.rst:824 msgid "" -"An optional pointer to a function that implements the built-in function :" -"func:`repr`." +"An optional pointer to a function that implements the built-in " +"function :func:`repr`." msgstr "" -#: c-api/typeobj.rst:814 +#: c-api/typeobj.rst:827 msgid "The signature is the same as for :c:func:`PyObject_Repr`::" msgstr "" -#: c-api/typeobj.rst:818 +#: c-api/typeobj.rst:829 +msgid "PyObject *tp_repr(PyObject *self);" +msgstr "" + +#: c-api/typeobj.rst:831 msgid "" "The function must return a string or a Unicode object. Ideally, this " "function should return a string that, when passed to :func:`eval`, given a " @@ -1514,130 +1673,141 @@ msgid "" "``'>'`` from which both the type and the value of the object can be deduced." msgstr "" -#: c-api/typeobj.rst:941 c-api/typeobj.rst:992 c-api/typeobj.rst:1561 -#: c-api/typeobj.rst:1712 c-api/typeobj.rst:1820 c-api/typeobj.rst:1879 -#: c-api/typeobj.rst:1942 c-api/typeobj.rst:1973 +#: c-api/typeobj.rst:954 c-api/typeobj.rst:1005 c-api/typeobj.rst:1575 +#: c-api/typeobj.rst:1726 c-api/typeobj.rst:1834 c-api/typeobj.rst:1893 +#: c-api/typeobj.rst:1956 c-api/typeobj.rst:1987 msgid "**Default:**" msgstr "" -#: c-api/typeobj.rst:831 +#: c-api/typeobj.rst:844 msgid "" "When this field is not set, a string of the form ``<%s object at %p>`` is " "returned, where ``%s`` is replaced by the type name, and ``%p`` by the " "object's memory address." msgstr "" -#: c-api/typeobj.rst:838 +#: c-api/typeobj.rst:851 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement the number protocol. These fields are documented " "in :ref:`number-structs`." msgstr "" -#: c-api/typeobj.rst:844 +#: c-api/typeobj.rst:857 msgid "" "The :c:member:`~PyTypeObject.tp_as_number` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: c-api/typeobj.rst:850 +#: c-api/typeobj.rst:863 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement the sequence protocol. These fields are documented " "in :ref:`sequence-structs`." msgstr "" -#: c-api/typeobj.rst:856 +#: c-api/typeobj.rst:869 msgid "" "The :c:member:`~PyTypeObject.tp_as_sequence` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: c-api/typeobj.rst:862 +#: c-api/typeobj.rst:875 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement the mapping protocol. These fields are documented " "in :ref:`mapping-structs`." msgstr "" -#: c-api/typeobj.rst:868 +#: c-api/typeobj.rst:881 msgid "" "The :c:member:`~PyTypeObject.tp_as_mapping` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: c-api/typeobj.rst:876 +#: c-api/typeobj.rst:889 msgid "" -"An optional pointer to a function that implements the built-in function :" -"func:`hash`." +"An optional pointer to a function that implements the built-in " +"function :func:`hash`." msgstr "" -#: c-api/typeobj.rst:879 +#: c-api/typeobj.rst:892 msgid "The signature is the same as for :c:func:`PyObject_Hash`::" msgstr "" -#: c-api/typeobj.rst:883 +#: c-api/typeobj.rst:894 +msgid "Py_hash_t tp_hash(PyObject *);" +msgstr "" + +#: c-api/typeobj.rst:896 msgid "" "The value ``-1`` should not be returned as a normal return value; when an " "error occurs during the computation of the hash value, the function should " "set an exception and return ``-1``." msgstr "" -#: c-api/typeobj.rst:887 +#: c-api/typeobj.rst:900 msgid "" "When this field is not set (*and* :c:member:`~PyTypeObject.tp_richcompare` " -"is not set), an attempt to take the hash of the object raises :exc:" -"`TypeError`. This is the same as setting it to :c:func:" -"`PyObject_HashNotImplemented`." +"is not set), an attempt to take the hash of the object " +"raises :exc:`TypeError`. This is the same as setting it " +"to :c:func:`PyObject_HashNotImplemented`." msgstr "" -#: c-api/typeobj.rst:891 +#: c-api/typeobj.rst:904 msgid "" "This field can be set explicitly to :c:func:`PyObject_HashNotImplemented` to " "block inheritance of the hash method from a parent type. This is interpreted " "as the equivalent of ``__hash__ = None`` at the Python level, causing " "``isinstance(o, collections.Hashable)`` to correctly return ``False``. Note " "that the converse is also true - setting ``__hash__ = None`` on a class at " -"the Python level will result in the ``tp_hash`` slot being set to :c:func:" -"`PyObject_HashNotImplemented`." +"the Python level will result in the ``tp_hash`` slot being set " +"to :c:func:`PyObject_HashNotImplemented`." msgstr "" -#: c-api/typeobj.rst:1554 -msgid "" -"Group: :c:member:`~PyTypeObject.tp_hash`, :c:member:`~PyTypeObject." -"tp_richcompare`" +#: c-api/typeobj.rst:1568 +msgid "Group: :c:member:`~PyTypeObject.tp_hash`, :c:member:`~PyTypeObject.tp_richcompare`" msgstr "" -#: c-api/typeobj.rst:903 +#: c-api/typeobj.rst:916 msgid "" -"This field is inherited by subtypes together with :c:member:`~PyTypeObject." -"tp_richcompare`: a subtype inherits both of :c:member:`~PyTypeObject." -"tp_richcompare` and :c:member:`~PyTypeObject.tp_hash`, when the subtype's :c:" -"member:`~PyTypeObject.tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` " -"are both ``NULL``." +"This field is inherited by subtypes together " +"with :c:member:`~PyTypeObject.tp_richcompare`: a subtype inherits both " +"of :c:member:`~PyTypeObject.tp_richcompare` " +"and :c:member:`~PyTypeObject.tp_hash`, when the " +"subtype's :c:member:`~PyTypeObject.tp_richcompare` " +"and :c:member:`~PyTypeObject.tp_hash` are both ``NULL``." msgstr "" -#: c-api/typeobj.rst:911 +#: c-api/typeobj.rst:924 msgid "" "An optional pointer to a function that implements calling the object. This " "should be ``NULL`` if the object is not callable. The signature is the same " "as for :c:func:`PyObject_Call`::" msgstr "" -#: c-api/typeobj.rst:924 +#: c-api/typeobj.rst:928 +msgid "PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);" +msgstr "" + +#: c-api/typeobj.rst:937 msgid "" -"An optional pointer to a function that implements the built-in operation :" -"func:`str`. (Note that :class:`str` is a type now, and :func:`str` calls " -"the constructor for that type. This constructor calls :c:func:" -"`PyObject_Str` to do the actual work, and :c:func:`PyObject_Str` will call " -"this handler.)" +"An optional pointer to a function that implements the built-in " +"operation :func:`str`. (Note that :class:`str` is a type now, " +"and :func:`str` calls the constructor for that type. This constructor " +"calls :c:func:`PyObject_Str` to do the actual work, " +"and :c:func:`PyObject_Str` will call this handler.)" msgstr "" -#: c-api/typeobj.rst:929 +#: c-api/typeobj.rst:942 msgid "The signature is the same as for :c:func:`PyObject_Str`::" msgstr "" -#: c-api/typeobj.rst:933 +#: c-api/typeobj.rst:944 +msgid "PyObject *tp_str(PyObject *self);" +msgstr "" + +#: c-api/typeobj.rst:946 msgid "" "The function must return a string or a Unicode object. It should be a " "\"friendly\" string representation of the object, as this is the " @@ -1645,91 +1815,101 @@ msgid "" "function." msgstr "" -#: c-api/typeobj.rst:943 +#: c-api/typeobj.rst:956 msgid "" "When this field is not set, :c:func:`PyObject_Repr` is called to return a " "string representation." msgstr "" -#: c-api/typeobj.rst:949 +#: c-api/typeobj.rst:962 msgid "An optional pointer to the get-attribute function." msgstr "" -#: c-api/typeobj.rst:951 +#: c-api/typeobj.rst:964 msgid "The signature is the same as for :c:func:`PyObject_GetAttr`::" msgstr "" -#: c-api/typeobj.rst:955 +#: c-api/typeobj.rst:966 +msgid "PyObject *tp_getattro(PyObject *self, PyObject *attr);" +msgstr "" + +#: c-api/typeobj.rst:968 msgid "" -"It is usually convenient to set this field to :c:func:" -"`PyObject_GenericGetAttr`, which implements the normal way of looking for " -"object attributes." +"It is usually convenient to set this field " +"to :c:func:`PyObject_GenericGetAttr`, which implements the normal way of " +"looking for object attributes." msgstr "" -#: c-api/typeobj.rst:962 +#: c-api/typeobj.rst:975 msgid "" -"This field is inherited by subtypes together with :c:member:`~PyTypeObject." -"tp_getattr`: a subtype inherits both :c:member:`~PyTypeObject.tp_getattr` " +"This field is inherited by subtypes together " +"with :c:member:`~PyTypeObject.tp_getattr`: a subtype inherits " +"both :c:member:`~PyTypeObject.tp_getattr` " "and :c:member:`~PyTypeObject.tp_getattro` from its base type when the " -"subtype's :c:member:`~PyTypeObject.tp_getattr` and :c:member:`~PyTypeObject." -"tp_getattro` are both ``NULL``." +"subtype's :c:member:`~PyTypeObject.tp_getattr` " +"and :c:member:`~PyTypeObject.tp_getattro` are both ``NULL``." msgstr "" -#: c-api/typeobj.rst:968 +#: c-api/typeobj.rst:981 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericGetAttr`." msgstr "" -#: c-api/typeobj.rst:975 +#: c-api/typeobj.rst:988 msgid "The signature is the same as for :c:func:`PyObject_SetAttr`::" msgstr "" -#: c-api/typeobj.rst:979 +#: c-api/typeobj.rst:990 +msgid "int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);" +msgstr "" + +#: c-api/typeobj.rst:992 msgid "" "In addition, setting *value* to ``NULL`` to delete an attribute must be " -"supported. It is usually convenient to set this field to :c:func:" -"`PyObject_GenericSetAttr`, which implements the normal way of setting object " -"attributes." +"supported. It is usually convenient to set this field " +"to :c:func:`PyObject_GenericSetAttr`, which implements the normal way of " +"setting object attributes." msgstr "" -#: c-api/typeobj.rst:988 +#: c-api/typeobj.rst:1001 msgid "" -"This field is inherited by subtypes together with :c:member:`~PyTypeObject." -"tp_setattr`: a subtype inherits both :c:member:`~PyTypeObject.tp_setattr` " +"This field is inherited by subtypes together " +"with :c:member:`~PyTypeObject.tp_setattr`: a subtype inherits " +"both :c:member:`~PyTypeObject.tp_setattr` " "and :c:member:`~PyTypeObject.tp_setattro` from its base type when the " -"subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject." -"tp_setattro` are both ``NULL``." +"subtype's :c:member:`~PyTypeObject.tp_setattr` " +"and :c:member:`~PyTypeObject.tp_setattro` are both ``NULL``." msgstr "" -#: c-api/typeobj.rst:994 +#: c-api/typeobj.rst:1007 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericSetAttr`." msgstr "" -#: c-api/typeobj.rst:999 +#: c-api/typeobj.rst:1012 msgid "" "Pointer to an additional structure that contains fields relevant only to " "objects which implement the buffer interface. These fields are documented " "in :ref:`buffer-structs`." msgstr "" -#: c-api/typeobj.rst:1005 +#: c-api/typeobj.rst:1018 msgid "" "The :c:member:`~PyTypeObject.tp_as_buffer` field is not inherited, but the " "contained fields are inherited individually." msgstr "" -#: c-api/typeobj.rst:1011 +#: c-api/typeobj.rst:1024 msgid "" "This field is a bit mask of various flags. Some flags indicate variant " "semantics for certain situations; others are used to indicate that certain " -"fields in the type object (or in the extension structures referenced via :c:" -"member:`~PyTypeObject.tp_as_number`, :c:member:`~PyTypeObject." -"tp_as_sequence`, :c:member:`~PyTypeObject.tp_as_mapping`, and :c:member:" -"`~PyTypeObject.tp_as_buffer`) that were historically not always present are " -"valid; if such a flag bit is clear, the type fields it guards must not be " -"accessed and must be considered to have a zero or ``NULL`` value instead." +"fields in the type object (or in the extension structures referenced " +"via :c:member:`~PyTypeObject.tp_as_number`, :c:member:`~PyTypeObject.tp_as_sequence`, :c:member:`~PyTypeObject.tp_as_mapping`, " +"and :c:member:`~PyTypeObject.tp_as_buffer`) that were historically not " +"always present are valid; if such a flag bit is clear, the type fields it " +"guards must not be accessed and must be considered to have a zero or " +"``NULL`` value instead." msgstr "" -#: c-api/typeobj.rst:1021 +#: c-api/typeobj.rst:1034 msgid "" "Inheritance of this field is complicated. Most flag bits are inherited " "individually, i.e. if the base type has a flag bit set, the subtype inherits " @@ -1738,33 +1918,33 @@ msgid "" "type's value of the flag bit is copied into the subtype together with a " "pointer to the extension structure. The :c:macro:`Py_TPFLAGS_HAVE_GC` flag " "bit is inherited together with the :c:member:`~PyTypeObject.tp_traverse` " -"and :c:member:`~PyTypeObject.tp_clear` fields, i.e. if the :c:macro:" -"`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and the :c:member:" -"`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields in " -"the subtype exist and have ``NULL`` values. .. XXX are most flag bits " -"*really* inherited individually?" +"and :c:member:`~PyTypeObject.tp_clear` fields, i.e. if " +"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and " +"the :c:member:`~PyTypeObject.tp_traverse` " +"and :c:member:`~PyTypeObject.tp_clear` fields in the subtype exist and have " +"``NULL`` values. .. XXX are most flag bits *really* inherited individually?" msgstr "" -#: c-api/typeobj.rst:1035 +#: c-api/typeobj.rst:1048 msgid "" ":c:data:`PyBaseObject_Type` uses ``Py_TPFLAGS_DEFAULT | " "Py_TPFLAGS_BASETYPE``." msgstr "" -#: c-api/typeobj.rst:1038 +#: c-api/typeobj.rst:1051 msgid "**Bit Masks:**" msgstr "" -#: c-api/typeobj.rst:1042 +#: c-api/typeobj.rst:1055 msgid "" "The following bit masks are currently defined; these can be ORed together " -"using the ``|`` operator to form the value of the :c:member:`~PyTypeObject." -"tp_flags` field. The macro :c:func:`PyType_HasFeature` takes a type and a " -"flags value, *tp* and *f*, and checks whether ``tp->tp_flags & f`` is non-" -"zero." +"using the ``|`` operator to form the value of " +"the :c:member:`~PyTypeObject.tp_flags` field. The " +"macro :c:func:`PyType_HasFeature` takes a type and a flags value, *tp* and " +"*f*, and checks whether ``tp->tp_flags & f`` is non-zero." msgstr "" -#: c-api/typeobj.rst:1049 +#: c-api/typeobj.rst:1062 msgid "" "This bit is set when the type object itself is allocated on the heap, for " "example, types created dynamically using :c:func:`PyType_FromSpec`. In this " @@ -1772,244 +1952,248 @@ msgid "" "a reference to the type, and the type object is INCREF'ed when a new " "instance is created, and DECREF'ed when an instance is destroyed (this does " "not apply to instances of subtypes; only the type referenced by the " -"instance's ob_type gets INCREF'ed or DECREF'ed)." +"instance's ob_type gets INCREF'ed or DECREF'ed). Heap types should " +"also :ref:`support garbage collection ` as they " +"can form a reference cycle with their own module object." msgstr "" -#: c-api/typeobj.rst:1070 c-api/typeobj.rst:1090 c-api/typeobj.rst:1122 +#: c-api/typeobj.rst:1084 c-api/typeobj.rst:1104 c-api/typeobj.rst:1136 msgid "???" msgstr "" -#: c-api/typeobj.rst:1064 +#: c-api/typeobj.rst:1078 msgid "" "This bit is set when the type can be used as the base type of another type. " "If this bit is clear, the type cannot be subtyped (similar to a \"final\" " "class in Java)." msgstr "" -#: c-api/typeobj.rst:1075 +#: c-api/typeobj.rst:1089 msgid "" -"This bit is set when the type object has been fully initialized by :c:func:" -"`PyType_Ready`." +"This bit is set when the type object has been fully initialized " +"by :c:func:`PyType_Ready`." msgstr "" -#: c-api/typeobj.rst:1085 +#: c-api/typeobj.rst:1099 msgid "" "This bit is set while :c:func:`PyType_Ready` is in the process of " "initializing the type object." msgstr "" -#: c-api/typeobj.rst:1095 +#: c-api/typeobj.rst:1109 msgid "" "This bit is set when the object supports garbage collection. If this bit is " "set, instances must be created using :c:macro:`PyObject_GC_New` and " -"destroyed using :c:func:`PyObject_GC_Del`. More information in section :ref:" -"`supporting-cycle-detection`. This bit also implies that the GC-related " -"fields :c:member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject." -"tp_clear` are present in the type object." +"destroyed using :c:func:`PyObject_GC_Del`. More information in " +"section :ref:`supporting-cycle-detection`. This bit also implies that the " +"GC-related fields :c:member:`~PyTypeObject.tp_traverse` " +"and :c:member:`~PyTypeObject.tp_clear` are present in the type object." msgstr "" -#: c-api/typeobj.rst:1425 c-api/typeobj.rst:1493 -msgid "" -"Group: :c:macro:`Py_TPFLAGS_HAVE_GC`, :c:member:`~PyTypeObject." -"tp_traverse`, :c:member:`~PyTypeObject.tp_clear`" +#: c-api/typeobj.rst:1439 c-api/typeobj.rst:1507 +msgid "Group: :c:macro:`Py_TPFLAGS_HAVE_GC`, :c:member:`~PyTypeObject.tp_traverse`, :c:member:`~PyTypeObject.tp_clear`" msgstr "" -#: c-api/typeobj.rst:1106 +#: c-api/typeobj.rst:1120 msgid "" -"The :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is inherited together with the :c:" -"member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` " -"fields, i.e. if the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is clear in the " -"subtype and the :c:member:`~PyTypeObject.tp_traverse` and :c:member:" -"`~PyTypeObject.tp_clear` fields in the subtype exist and have ``NULL`` " -"values." +"The :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is inherited together with " +"the :c:member:`~PyTypeObject.tp_traverse` " +"and :c:member:`~PyTypeObject.tp_clear` fields, i.e. if " +"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is clear in the subtype and " +"the :c:member:`~PyTypeObject.tp_traverse` " +"and :c:member:`~PyTypeObject.tp_clear` fields in the subtype exist and have " +"``NULL`` values." msgstr "" -#: c-api/typeobj.rst:1116 +#: c-api/typeobj.rst:1130 msgid "" "This is a bitmask of all the bits that pertain to the existence of certain " "fields in the type object and its extension structures. Currently, it " "includes the following bits: :c:macro:`Py_TPFLAGS_HAVE_STACKLESS_EXTENSION`." msgstr "" -#: c-api/typeobj.rst:1127 +#: c-api/typeobj.rst:1141 msgid "This bit indicates that objects behave like unbound methods." msgstr "" -#: c-api/typeobj.rst:1129 +#: c-api/typeobj.rst:1143 msgid "If this flag is set for ``type(meth)``, then:" msgstr "" -#: c-api/typeobj.rst:1131 +#: c-api/typeobj.rst:1145 msgid "" "``meth.__get__(obj, cls)(*args, **kwds)`` (with ``obj`` not None) must be " "equivalent to ``meth(obj, *args, **kwds)``." msgstr "" -#: c-api/typeobj.rst:1134 +#: c-api/typeobj.rst:1148 msgid "" "``meth.__get__(None, cls)(*args, **kwds)`` must be equivalent to " "``meth(*args, **kwds)``." msgstr "" -#: c-api/typeobj.rst:1137 +#: c-api/typeobj.rst:1151 msgid "" -"This flag enables an optimization for typical method calls like ``obj." -"meth()``: it avoids creating a temporary \"bound method\" object for ``obj." -"meth``." +"This flag enables an optimization for typical method calls like " +"``obj.meth()``: it avoids creating a temporary \"bound method\" object for " +"``obj.meth``." msgstr "" -#: c-api/typeobj.rst:1145 +#: c-api/typeobj.rst:1159 msgid "" -"This flag is never inherited by types without the :c:macro:" -"`Py_TPFLAGS_IMMUTABLETYPE` flag set. For extension types, it is inherited " -"whenever :c:member:`~PyTypeObject.tp_descr_get` is inherited." +"This flag is never inherited by types without " +"the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag set. For extension types, it " +"is inherited whenever :c:member:`~PyTypeObject.tp_descr_get` is inherited." msgstr "" -#: c-api/typeobj.rst:1151 +#: c-api/typeobj.rst:1165 msgid "" -"This bit indicates that instances of the class have a ``__dict__`` " +"This bit indicates that instances of the class have a `~object.__dict__` " "attribute, and that the space for the dictionary is managed by the VM." msgstr "" -#: c-api/typeobj.rst:1154 +#: c-api/typeobj.rst:1168 msgid "If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set." msgstr "" -#: c-api/typeobj.rst:1160 +#: c-api/typeobj.rst:1174 msgid "" "This flag is inherited unless the :c:member:`~PyTypeObject.tp_dictoffset` " "field is set in a superclass." msgstr "" -#: c-api/typeobj.rst:1166 +#: c-api/typeobj.rst:1180 msgid "" "This bit indicates that instances of the class should be weakly " "referenceable." msgstr "" -#: c-api/typeobj.rst:1173 +#: c-api/typeobj.rst:1187 msgid "" -"This flag is inherited unless the :c:member:`~PyTypeObject." -"tp_weaklistoffset` field is set in a superclass." +"This flag is inherited unless " +"the :c:member:`~PyTypeObject.tp_weaklistoffset` field is set in a superclass." msgstr "" -#: c-api/typeobj.rst:1179 +#: c-api/typeobj.rst:1193 msgid "" -"Only usable with variable-size types, i.e. ones with non-zero :c:member:" -"`~PyTypeObject.tp_itemsize`." +"Only usable with variable-size types, i.e. ones with non-" +"zero :c:member:`~PyTypeObject.tp_itemsize`." msgstr "" -#: c-api/typeobj.rst:1182 +#: c-api/typeobj.rst:1196 msgid "" "Indicates that the variable-sized portion of an instance of this type is at " "the end of the instance's memory area, at an offset of ``Py_TYPE(obj)-" ">tp_basicsize`` (which may be different in each subclass)." msgstr "" -#: c-api/typeobj.rst:1187 +#: c-api/typeobj.rst:1201 msgid "" "When setting this flag, be sure that all superclasses either use this memory " "layout, or are not variable-sized. Python does not check this." msgstr "" -#: c-api/typeobj.rst:1195 +#: c-api/typeobj.rst:1209 msgid "This flag is inherited." msgstr "" -#: c-api/typeobj.rst:1209 +#: c-api/typeobj.rst:1223 msgid "" "These flags are used by functions such as :c:func:`PyLong_Check` to quickly " "determine if a type is a subclass of a built-in type; such specific checks " "are faster than a generic check, like :c:func:`PyObject_IsInstance`. Custom " -"types that inherit from built-ins should have their :c:member:`~PyTypeObject." -"tp_flags` set appropriately, or the code that interacts with such types will " -"behave differently depending on what kind of check is used." +"types that inherit from built-ins should have " +"their :c:member:`~PyTypeObject.tp_flags` set appropriately, or the code that " +"interacts with such types will behave differently depending on what kind of " +"check is used." msgstr "" -#: c-api/typeobj.rst:1220 +#: c-api/typeobj.rst:1234 msgid "" "This bit is set when the :c:member:`~PyTypeObject.tp_finalize` slot is " "present in the type structure." msgstr "" -#: c-api/typeobj.rst:1225 +#: c-api/typeobj.rst:1239 msgid "" -"This flag isn't necessary anymore, as the interpreter assumes the :c:member:" -"`~PyTypeObject.tp_finalize` slot is always present in the type structure." +"This flag isn't necessary anymore, as the interpreter assumes " +"the :c:member:`~PyTypeObject.tp_finalize` slot is always present in the type " +"structure." msgstr "" -#: c-api/typeobj.rst:1233 +#: c-api/typeobj.rst:1247 msgid "" "This bit is set when the class implements the :ref:`vectorcall protocol " "`. See :c:member:`~PyTypeObject.tp_vectorcall_offset` for " "details." msgstr "" -#: c-api/typeobj.rst:1239 +#: c-api/typeobj.rst:1253 msgid "" "This bit is inherited if :c:member:`~PyTypeObject.tp_call` is also inherited." msgstr "" -#: c-api/typeobj.rst:1246 +#: c-api/typeobj.rst:1260 msgid "" -"This flag is now removed from a class when the class's :py:meth:`~object." -"__call__` method is reassigned." +"This flag is now removed from a class when the " +"class's :py:meth:`~object.__call__` method is reassigned." msgstr "" -#: c-api/typeobj.rst:1249 +#: c-api/typeobj.rst:1263 msgid "This flag can now be inherited by mutable classes." msgstr "" -#: c-api/typeobj.rst:1253 +#: c-api/typeobj.rst:1267 msgid "" "This bit is set for type objects that are immutable: type attributes cannot " "be set nor deleted." msgstr "" -#: c-api/typeobj.rst:1255 +#: c-api/typeobj.rst:1269 msgid "" ":c:func:`PyType_Ready` automatically applies this flag to :ref:`static types " "`." msgstr "" -#: c-api/typeobj.rst:1260 +#: c-api/typeobj.rst:1274 msgid "This flag is not inherited." msgstr "" -#: c-api/typeobj.rst:1266 +#: c-api/typeobj.rst:1280 msgid "" -"Disallow creating instances of the type: set :c:member:`~PyTypeObject." -"tp_new` to NULL and don't create the ``__new__`` key in the type dictionary." +"Disallow creating instances of the type: " +"set :c:member:`~PyTypeObject.tp_new` to NULL and don't create the " +"``__new__`` key in the type dictionary." msgstr "" -#: c-api/typeobj.rst:1270 +#: c-api/typeobj.rst:1284 msgid "" "The flag must be set before creating the type, not after. For example, it " "must be set before :c:func:`PyType_Ready` is called on the type." msgstr "" -#: c-api/typeobj.rst:1273 +#: c-api/typeobj.rst:1287 msgid "" -"The flag is set automatically on :ref:`static types ` if :c:" -"member:`~PyTypeObject.tp_base` is NULL or ``&PyBaseObject_Type`` and :c:" -"member:`~PyTypeObject.tp_new` is NULL." +"The flag is set automatically on :ref:`static types ` " +"if :c:member:`~PyTypeObject.tp_base` is NULL or ``&PyBaseObject_Type`` " +"and :c:member:`~PyTypeObject.tp_new` is NULL." msgstr "" -#: c-api/typeobj.rst:1279 +#: c-api/typeobj.rst:1293 msgid "" "This flag is not inherited. However, subclasses will not be instantiable " "unless they provide a non-NULL :c:member:`~PyTypeObject.tp_new` (which is " "only possible via the C API)." msgstr "" -#: c-api/typeobj.rst:1286 +#: c-api/typeobj.rst:1300 msgid "" "To disallow instantiating a class directly but allow instantiating its " "subclasses (e.g. for an :term:`abstract base class`), do not use this flag. " "Instead, make :c:member:`~PyTypeObject.tp_new` only succeed for subclasses." msgstr "" -#: c-api/typeobj.rst:1297 +#: c-api/typeobj.rst:1311 msgid "" "This bit indicates that instances of the class may match mapping patterns " "when used as the subject of a :keyword:`match` block. It is automatically " @@ -2017,23 +2201,23 @@ msgid "" "unset when registering :class:`collections.abc.Sequence`." msgstr "" -#: c-api/typeobj.rst:1326 +#: c-api/typeobj.rst:1340 msgid "" ":c:macro:`Py_TPFLAGS_MAPPING` and :c:macro:`Py_TPFLAGS_SEQUENCE` are " "mutually exclusive; it is an error to enable both flags simultaneously." msgstr "" -#: c-api/typeobj.rst:1309 +#: c-api/typeobj.rst:1323 msgid "" -"This flag is inherited by types that do not already set :c:macro:" -"`Py_TPFLAGS_SEQUENCE`." +"This flag is inherited by types that do not already " +"set :c:macro:`Py_TPFLAGS_SEQUENCE`." msgstr "" -#: c-api/typeobj.rst:1334 +#: c-api/typeobj.rst:1348 msgid ":pep:`634` -- Structural Pattern Matching: Specification" msgstr "" -#: c-api/typeobj.rst:1319 +#: c-api/typeobj.rst:1333 msgid "" "This bit indicates that instances of the class may match sequence patterns " "when used as the subject of a :keyword:`match` block. It is automatically " @@ -2041,59 +2225,75 @@ msgid "" "unset when registering :class:`collections.abc.Mapping`." msgstr "" -#: c-api/typeobj.rst:1331 +#: c-api/typeobj.rst:1345 msgid "" -"This flag is inherited by types that do not already set :c:macro:" -"`Py_TPFLAGS_MAPPING`." +"This flag is inherited by types that do not already " +"set :c:macro:`Py_TPFLAGS_MAPPING`." msgstr "" -#: c-api/typeobj.rst:1341 +#: c-api/typeobj.rst:1355 msgid "" "Internal. Do not set or unset this flag. To indicate that a class has " "changed call :c:func:`PyType_Modified`" msgstr "" -#: c-api/typeobj.rst:1345 +#: c-api/typeobj.rst:1359 msgid "" "This flag is present in header files, but is an internal feature and should " "not be used. It will be removed in a future version of CPython" msgstr "" -#: c-api/typeobj.rst:1351 +#: c-api/typeobj.rst:1365 msgid "" "An optional pointer to a NUL-terminated C string giving the docstring for " -"this type object. This is exposed as the :attr:`__doc__` attribute on the " -"type and instances of the type." +"this type object. This is exposed as the :attr:`~type.__doc__` attribute on " +"the type and instances of the type." msgstr "" -#: c-api/typeobj.rst:1357 +#: c-api/typeobj.rst:1371 msgid "This field is *not* inherited by subtypes." msgstr "" -#: c-api/typeobj.rst:1362 +#: c-api/typeobj.rst:1376 msgid "" "An optional pointer to a traversal function for the garbage collector. This " "is only used if the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is set. The " "signature is::" msgstr "" -#: c-api/typeobj.rst:1488 +#: c-api/typeobj.rst:1379 +msgid "int tp_traverse(PyObject *self, visitproc visit, void *arg);" +msgstr "" + +#: c-api/typeobj.rst:1502 msgid "" "More information about Python's garbage collection scheme can be found in " "section :ref:`supporting-cycle-detection`." msgstr "" -#: c-api/typeobj.rst:1370 +#: c-api/typeobj.rst:1384 msgid "" "The :c:member:`~PyTypeObject.tp_traverse` pointer is used by the garbage " -"collector to detect reference cycles. A typical implementation of a :c:" -"member:`~PyTypeObject.tp_traverse` function simply calls :c:func:`Py_VISIT` " -"on each of the instance's members that are Python objects that the instance " -"owns. For example, this is function :c:func:`!local_traverse` from the :mod:" -"`!_thread` extension module::" +"collector to detect reference cycles. A typical implementation of " +"a :c:member:`~PyTypeObject.tp_traverse` function simply " +"calls :c:func:`Py_VISIT` on each of the instance's members that are Python " +"objects that the instance owns. For example, this is function :c:func:`!" +"local_traverse` from the :mod:`!_thread` extension module::" +msgstr "" + +#: c-api/typeobj.rst:1390 +msgid "" +"static int\n" +"local_traverse(localobject *self, visitproc visit, void *arg)\n" +"{\n" +" Py_VISIT(self->args);\n" +" Py_VISIT(self->kw);\n" +" Py_VISIT(self->dict);\n" +" return 0;\n" +"}" msgstr "" -#: c-api/typeobj.rst:1385 +#: c-api/typeobj.rst:1399 msgid "" "Note that :c:func:`Py_VISIT` is called only on those members that can " "participate in reference cycles. Although there is also a ``self->key`` " @@ -2101,14 +2301,14 @@ msgid "" "part of a reference cycle." msgstr "" -#: c-api/typeobj.rst:1389 +#: c-api/typeobj.rst:1403 msgid "" "On the other hand, even if you know a member can never be part of a cycle, " "as a debugging aid you may want to visit it anyway just so the :mod:`gc` " "module's :func:`~gc.get_referents` function will include it." msgstr "" -#: c-api/typeobj.rst:1394 +#: c-api/typeobj.rst:1408 msgid "" "When implementing :c:member:`~PyTypeObject.tp_traverse`, only the members " "that the instance *owns* (by having :term:`strong references ` hold a reference to " -"their type. Their traversal function must therefore either visit :c:func:" -"`Py_TYPE(self) `, or delegate this responsibility by calling " -"``tp_traverse`` of another heap-allocated type (such as a heap-allocated " -"superclass). If they do not, the type object may not be garbage-collected." +"their type. Their traversal function must therefore either " +"visit :c:func:`Py_TYPE(self) `, or delegate this responsibility by " +"calling ``tp_traverse`` of another heap-allocated type (such as a heap-" +"allocated superclass). If they do not, the type object may not be garbage-" +"collected." msgstr "" -#: c-api/typeobj.rst:1418 +#: c-api/typeobj.rst:1432 msgid "" "Heap-allocated types are expected to visit ``Py_TYPE(self)`` in " "``tp_traverse``. In earlier versions of Python, due to `bug 40217 `_, doing this may lead to crashes in subclasses." msgstr "" -#: c-api/typeobj.rst:1427 +#: c-api/typeobj.rst:1441 msgid "" -"This field is inherited by subtypes together with :c:member:`~PyTypeObject." -"tp_clear` and the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :c:" -"member:`~PyTypeObject.tp_traverse`, and :c:member:`~PyTypeObject.tp_clear` " -"are all inherited from the base type if they are all zero in the subtype." +"This field is inherited by subtypes together " +"with :c:member:`~PyTypeObject.tp_clear` and " +"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit: the flag " +"bit, :c:member:`~PyTypeObject.tp_traverse`, " +"and :c:member:`~PyTypeObject.tp_clear` are all inherited from the base type " +"if they are all zero in the subtype." msgstr "" -#: c-api/typeobj.rst:1435 +#: c-api/typeobj.rst:1449 msgid "" "An optional pointer to a clear function for the garbage collector. This is " "only used if the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is set. The " "signature is::" msgstr "" -#: c-api/typeobj.rst:1440 +#: c-api/typeobj.rst:1452 +msgid "int tp_clear(PyObject *);" +msgstr "" + +#: c-api/typeobj.rst:1454 msgid "" "The :c:member:`~PyTypeObject.tp_clear` member function is used to break " "reference cycles in cyclic garbage detected by the garbage collector. Taken " @@ -2168,13 +2375,14 @@ msgid "" "doubt supply a :c:member:`~PyTypeObject.tp_clear` function. For example, " "the tuple type does not implement a :c:member:`~PyTypeObject.tp_clear` " "function, because it's possible to prove that no reference cycle can be " -"composed entirely of tuples. Therefore the :c:member:`~PyTypeObject." -"tp_clear` functions of other types must be sufficient to break any cycle " -"containing a tuple. This isn't immediately obvious, and there's rarely a " -"good reason to avoid implementing :c:member:`~PyTypeObject.tp_clear`." +"composed entirely of tuples. Therefore " +"the :c:member:`~PyTypeObject.tp_clear` functions of other types must be " +"sufficient to break any cycle containing a tuple. This isn't immediately " +"obvious, and there's rarely a good reason to avoid " +"implementing :c:member:`~PyTypeObject.tp_clear`." msgstr "" -#: c-api/typeobj.rst:1450 +#: c-api/typeobj.rst:1464 msgid "" "Implementations of :c:member:`~PyTypeObject.tp_clear` should drop the " "instance's references to those of its members that may be Python objects, " @@ -2182,12 +2390,25 @@ msgid "" "example::" msgstr "" -#: c-api/typeobj.rst:1464 +#: c-api/typeobj.rst:1468 +msgid "" +"static int\n" +"local_clear(localobject *self)\n" +"{\n" +" Py_CLEAR(self->key);\n" +" Py_CLEAR(self->args);\n" +" Py_CLEAR(self->kw);\n" +" Py_CLEAR(self->dict);\n" +" return 0;\n" +"}" +msgstr "" + +#: c-api/typeobj.rst:1478 msgid "" "The :c:func:`Py_CLEAR` macro should be used, because clearing references is " -"delicate: the reference to the contained object must not be released (via :" -"c:func:`Py_DECREF`) until after the pointer to the contained object is set " -"to ``NULL``. This is because releasing the reference may cause the " +"delicate: the reference to the contained object must not be released " +"(via :c:func:`Py_DECREF`) until after the pointer to the contained object is " +"set to ``NULL``. This is because releasing the reference may cause the " "contained object to become trash, triggering a chain of reclamation activity " "that may include invoking arbitrary Python code (due to finalizers, or " "weakref callbacks, associated with the contained object). If it's possible " @@ -2197,7 +2418,7 @@ msgid "" "performs the operations in a safe order." msgstr "" -#: c-api/typeobj.rst:1476 +#: c-api/typeobj.rst:1490 msgid "" "Note that :c:member:`~PyTypeObject.tp_clear` is not *always* called before " "an instance is deallocated. For example, when reference counting is enough " @@ -2205,7 +2426,7 @@ msgid "" "is not involved and :c:member:`~PyTypeObject.tp_dealloc` is called directly." msgstr "" -#: c-api/typeobj.rst:1482 +#: c-api/typeobj.rst:1496 msgid "" "Because the goal of :c:member:`~PyTypeObject.tp_clear` functions is to break " "reference cycles, it's not necessary to clear contained objects like Python " @@ -2215,26 +2436,32 @@ msgid "" "invoke :c:member:`~PyTypeObject.tp_clear`." msgstr "" -#: c-api/typeobj.rst:1495 +#: c-api/typeobj.rst:1509 msgid "" -"This field is inherited by subtypes together with :c:member:`~PyTypeObject." -"tp_traverse` and the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :" -"c:member:`~PyTypeObject.tp_traverse`, and :c:member:`~PyTypeObject.tp_clear` " -"are all inherited from the base type if they are all zero in the subtype." +"This field is inherited by subtypes together " +"with :c:member:`~PyTypeObject.tp_traverse` and " +"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit: the flag " +"bit, :c:member:`~PyTypeObject.tp_traverse`, " +"and :c:member:`~PyTypeObject.tp_clear` are all inherited from the base type " +"if they are all zero in the subtype." msgstr "" -#: c-api/typeobj.rst:1503 +#: c-api/typeobj.rst:1517 msgid "" "An optional pointer to the rich comparison function, whose signature is::" msgstr "" -#: c-api/typeobj.rst:1507 +#: c-api/typeobj.rst:1519 +msgid "PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);" +msgstr "" + +#: c-api/typeobj.rst:1521 msgid "" "The first parameter is guaranteed to be an instance of the type that is " "defined by :c:type:`PyTypeObject`." msgstr "" -#: c-api/typeobj.rst:1510 +#: c-api/typeobj.rst:1524 msgid "" "The function should return the result of the comparison (usually ``Py_True`` " "or ``Py_False``). If the comparison is undefined, it must return " @@ -2242,50 +2469,51 @@ msgid "" "set an exception condition." msgstr "" -#: c-api/typeobj.rst:1515 +#: c-api/typeobj.rst:1529 msgid "" -"The following constants are defined to be used as the third argument for :c:" -"member:`~PyTypeObject.tp_richcompare` and for :c:func:`PyObject_RichCompare`:" +"The following constants are defined to be used as the third argument " +"for :c:member:`~PyTypeObject.tp_richcompare` and " +"for :c:func:`PyObject_RichCompare`:" msgstr "" -#: c-api/typeobj.rst:1521 +#: c-api/typeobj.rst:1535 msgid "Constant" msgstr "" -#: c-api/typeobj.rst:1521 +#: c-api/typeobj.rst:1535 msgid "Comparison" msgstr "" -#: c-api/typeobj.rst:1523 +#: c-api/typeobj.rst:1537 msgid "``<``" msgstr "" -#: c-api/typeobj.rst:1525 +#: c-api/typeobj.rst:1539 msgid "``<=``" msgstr "" -#: c-api/typeobj.rst:1527 +#: c-api/typeobj.rst:1541 msgid "``==``" msgstr "" -#: c-api/typeobj.rst:1529 +#: c-api/typeobj.rst:1543 msgid "``!=``" msgstr "" -#: c-api/typeobj.rst:1531 +#: c-api/typeobj.rst:1545 msgid "``>``" msgstr "" -#: c-api/typeobj.rst:1533 +#: c-api/typeobj.rst:1547 msgid "``>=``" msgstr "" -#: c-api/typeobj.rst:1536 +#: c-api/typeobj.rst:1550 msgid "" "The following macro is defined to ease writing rich comparison functions:" msgstr "" -#: c-api/typeobj.rst:1540 +#: c-api/typeobj.rst:1554 msgid "" "Return ``Py_True`` or ``Py_False`` from the function, depending on the " "result of a comparison. VAL_A and VAL_B must be orderable by C comparison " @@ -2293,60 +2521,62 @@ msgid "" "specifies the requested operation, as for :c:func:`PyObject_RichCompare`." msgstr "" -#: c-api/typeobj.rst:1546 +#: c-api/typeobj.rst:1560 msgid "The returned value is a new :term:`strong reference`." msgstr "" -#: c-api/typeobj.rst:1548 +#: c-api/typeobj.rst:1562 msgid "On error, sets an exception and returns ``NULL`` from the function." msgstr "" -#: c-api/typeobj.rst:1556 +#: c-api/typeobj.rst:1570 msgid "" -"This field is inherited by subtypes together with :c:member:`~PyTypeObject." -"tp_hash`: a subtype inherits :c:member:`~PyTypeObject.tp_richcompare` and :c:" -"member:`~PyTypeObject.tp_hash` when the subtype's :c:member:`~PyTypeObject." -"tp_richcompare` and :c:member:`~PyTypeObject.tp_hash` are both ``NULL``." +"This field is inherited by subtypes together " +"with :c:member:`~PyTypeObject.tp_hash`: a subtype " +"inherits :c:member:`~PyTypeObject.tp_richcompare` " +"and :c:member:`~PyTypeObject.tp_hash` when the " +"subtype's :c:member:`~PyTypeObject.tp_richcompare` " +"and :c:member:`~PyTypeObject.tp_hash` are both ``NULL``." msgstr "" -#: c-api/typeobj.rst:1563 +#: c-api/typeobj.rst:1577 msgid "" -":c:data:`PyBaseObject_Type` provides a :c:member:`~PyTypeObject." -"tp_richcompare` implementation, which may be inherited. However, if only :c:" -"member:`~PyTypeObject.tp_hash` is defined, not even the inherited function " -"is used and instances of the type will not be able to participate in any " -"comparisons." +":c:data:`PyBaseObject_Type` provides " +"a :c:member:`~PyTypeObject.tp_richcompare` implementation, which may be " +"inherited. However, if only :c:member:`~PyTypeObject.tp_hash` is defined, " +"not even the inherited function is used and instances of the type will not " +"be able to participate in any comparisons." msgstr "" -#: c-api/typeobj.rst:1572 +#: c-api/typeobj.rst:1586 msgid "" "While this field is still supported, :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` " "should be used instead, if at all possible." msgstr "" -#: c-api/typeobj.rst:1575 +#: c-api/typeobj.rst:1589 msgid "" "If the instances of this type are weakly referenceable, this field is " "greater than zero and contains the offset in the instance structure of the " "weak reference list head (ignoring the GC header, if present); this offset " "is used by :c:func:`PyObject_ClearWeakRefs` and the ``PyWeakref_*`` " -"functions. The instance structure needs to include a field of type :c:expr:" -"`PyObject*` which is initialized to ``NULL``." +"functions. The instance structure needs to include a field of " +"type :c:expr:`PyObject*` which is initialized to ``NULL``." msgstr "" -#: c-api/typeobj.rst:1582 +#: c-api/typeobj.rst:1596 msgid "" "Do not confuse this field with :c:member:`~PyTypeObject.tp_weaklist`; that " "is the list head for weak references to the type object itself." msgstr "" -#: c-api/typeobj.rst:1585 +#: c-api/typeobj.rst:1599 msgid "" "It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit " -"and :c:member:`~PyTypeObject.tp_weaklist`." +"and :c:member:`~PyTypeObject.tp_weaklistoffset`." msgstr "" -#: c-api/typeobj.rst:1590 +#: c-api/typeobj.rst:1604 msgid "" "This field is inherited by subtypes, but see the rules listed below. A " "subtype may override this offset; this means that the subtype uses a " @@ -2355,107 +2585,116 @@ msgid "" "not be a problem." msgstr "" -#: c-api/typeobj.rst:1597 +#: c-api/typeobj.rst:1611 msgid "" -"If the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit is set in the :c:member:" -"`~PyTypeObject.tp_dict` field, then :c:member:`~PyTypeObject." -"tp_weaklistoffset` will be set to a negative value, to indicate that it is " -"unsafe to use this field." +"If the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit is set in " +"the :c:member:`~PyTypeObject.tp_flags` field, " +"then :c:member:`~PyTypeObject.tp_weaklistoffset` will be set to a negative " +"value, to indicate that it is unsafe to use this field." msgstr "" -#: c-api/typeobj.rst:1605 +#: c-api/typeobj.rst:1619 msgid "" "An optional pointer to a function that returns an :term:`iterator` for the " -"object. Its presence normally signals that the instances of this type are :" -"term:`iterable` (although sequences may be iterable without this function)." +"object. Its presence normally signals that the instances of this type " +"are :term:`iterable` (although sequences may be iterable without this " +"function)." msgstr "" -#: c-api/typeobj.rst:1609 +#: c-api/typeobj.rst:1623 msgid "This function has the same signature as :c:func:`PyObject_GetIter`::" msgstr "" -#: c-api/typeobj.rst:1620 +#: c-api/typeobj.rst:1625 +msgid "PyObject *tp_iter(PyObject *self);" +msgstr "" + +#: c-api/typeobj.rst:1634 msgid "" -"An optional pointer to a function that returns the next item in an :term:" -"`iterator`. The signature is::" +"An optional pointer to a function that returns the next item in " +"an :term:`iterator`. The signature is::" msgstr "" -#: c-api/typeobj.rst:1625 +#: c-api/typeobj.rst:1637 +msgid "PyObject *tp_iternext(PyObject *self);" +msgstr "" + +#: c-api/typeobj.rst:1639 msgid "" -"When the iterator is exhausted, it must return ``NULL``; a :exc:" -"`StopIteration` exception may or may not be set. When another error occurs, " -"it must return ``NULL`` too. Its presence signals that the instances of " -"this type are iterators." +"When the iterator is exhausted, it must return ``NULL``; " +"a :exc:`StopIteration` exception may or may not be set. When another error " +"occurs, it must return ``NULL`` too. Its presence signals that the " +"instances of this type are iterators." msgstr "" -#: c-api/typeobj.rst:1630 +#: c-api/typeobj.rst:1644 msgid "" "Iterator types should also define the :c:member:`~PyTypeObject.tp_iter` " "function, and that function should return the iterator instance itself (not " "a new iterator instance)." msgstr "" -#: c-api/typeobj.rst:1634 +#: c-api/typeobj.rst:1648 msgid "This function has the same signature as :c:func:`PyIter_Next`." msgstr "" -#: c-api/typeobj.rst:1643 +#: c-api/typeobj.rst:1657 msgid "" -"An optional pointer to a static ``NULL``-terminated array of :c:type:" -"`PyMethodDef` structures, declaring regular methods of this type." +"An optional pointer to a static ``NULL``-terminated array " +"of :c:type:`PyMethodDef` structures, declaring regular methods of this type." msgstr "" -#: c-api/typeobj.rst:1646 +#: c-api/typeobj.rst:1660 msgid "" "For each entry in the array, an entry is added to the type's dictionary " "(see :c:member:`~PyTypeObject.tp_dict` below) containing a method descriptor." msgstr "" -#: c-api/typeobj.rst:1651 +#: c-api/typeobj.rst:1665 msgid "" "This field is not inherited by subtypes (methods are inherited through a " "different mechanism)." msgstr "" -#: c-api/typeobj.rst:1657 +#: c-api/typeobj.rst:1671 msgid "" -"An optional pointer to a static ``NULL``-terminated array of :c:type:" -"`PyMemberDef` structures, declaring regular data members (fields or slots) " -"of instances of this type." +"An optional pointer to a static ``NULL``-terminated array " +"of :c:type:`PyMemberDef` structures, declaring regular data members (fields " +"or slots) of instances of this type." msgstr "" -#: c-api/typeobj.rst:1661 +#: c-api/typeobj.rst:1675 msgid "" "For each entry in the array, an entry is added to the type's dictionary " "(see :c:member:`~PyTypeObject.tp_dict` below) containing a member descriptor." msgstr "" -#: c-api/typeobj.rst:1666 +#: c-api/typeobj.rst:1680 msgid "" "This field is not inherited by subtypes (members are inherited through a " "different mechanism)." msgstr "" -#: c-api/typeobj.rst:1672 +#: c-api/typeobj.rst:1686 msgid "" -"An optional pointer to a static ``NULL``-terminated array of :c:type:" -"`PyGetSetDef` structures, declaring computed attributes of instances of this " -"type." +"An optional pointer to a static ``NULL``-terminated array " +"of :c:type:`PyGetSetDef` structures, declaring computed attributes of " +"instances of this type." msgstr "" -#: c-api/typeobj.rst:1675 +#: c-api/typeobj.rst:1689 msgid "" "For each entry in the array, an entry is added to the type's dictionary " "(see :c:member:`~PyTypeObject.tp_dict` below) containing a getset descriptor." msgstr "" -#: c-api/typeobj.rst:1680 +#: c-api/typeobj.rst:1694 msgid "" "This field is not inherited by subtypes (computed attributes are inherited " "through a different mechanism)." msgstr "" -#: c-api/typeobj.rst:1686 +#: c-api/typeobj.rst:1700 msgid "" "An optional pointer to a base type from which type properties are " "inherited. At this level, only single inheritance is supported; multiple " @@ -2463,7 +2702,7 @@ msgid "" "metatype." msgstr "" -#: c-api/typeobj.rst:1694 +#: c-api/typeobj.rst:1708 msgid "" "Slot initialization is subject to the rules of initializing globals. C99 " "requires the initializers to be \"address constants\". Function designators " @@ -2471,162 +2710,173 @@ msgid "" "valid C99 address constants." msgstr "" -#: c-api/typeobj.rst:1699 +#: c-api/typeobj.rst:1713 msgid "" -"However, the unary '&' operator applied to a non-static variable like :c:" -"data:`PyBaseObject_Type` is not required to produce an address constant. " -"Compilers may support this (gcc does), MSVC does not. Both compilers are " -"strictly standard conforming in this particular behavior." +"However, the unary '&' operator applied to a non-static variable " +"like :c:data:`PyBaseObject_Type` is not required to produce an address " +"constant. Compilers may support this (gcc does), MSVC does not. Both " +"compilers are strictly standard conforming in this particular behavior." msgstr "" -#: c-api/typeobj.rst:1705 +#: c-api/typeobj.rst:1719 msgid "" "Consequently, :c:member:`~PyTypeObject.tp_base` should be set in the " "extension module's init function." msgstr "" -#: c-api/typeobj.rst:1710 +#: c-api/typeobj.rst:1724 msgid "This field is not inherited by subtypes (obviously)." msgstr "" -#: c-api/typeobj.rst:1714 +#: c-api/typeobj.rst:1728 msgid "" "This field defaults to ``&PyBaseObject_Type`` (which to Python programmers " "is known as the type :class:`object`)." msgstr "" -#: c-api/typeobj.rst:1720 +#: c-api/typeobj.rst:1734 msgid "The type's dictionary is stored here by :c:func:`PyType_Ready`." msgstr "" -#: c-api/typeobj.rst:1722 +#: c-api/typeobj.rst:1736 msgid "" "This field should normally be initialized to ``NULL`` before PyType_Ready is " "called; it may also be initialized to a dictionary containing initial " "attributes for the type. Once :c:func:`PyType_Ready` has initialized the " "type, extra attributes for the type may be added to this dictionary only if " -"they don't correspond to overloaded operations (like :meth:`~object." -"__add__`). Once initialization for the type has finished, this field should " -"be treated as read-only." +"they don't correspond to overloaded operations " +"(like :meth:`~object.__add__`). Once initialization for the type has " +"finished, this field should be treated as read-only." msgstr "" -#: c-api/typeobj.rst:1730 +#: c-api/typeobj.rst:1744 msgid "" -"Some types may not store their dictionary in this slot. Use :c:func:" -"`PyType_GetDict` to retrieve the dictionary for an arbitrary type." +"Some types may not store their dictionary in this slot. " +"Use :c:func:`PyType_GetDict` to retrieve the dictionary for an arbitrary " +"type." msgstr "" -#: c-api/typeobj.rst:1736 +#: c-api/typeobj.rst:1750 msgid "" "Internals detail: For static builtin types, this is always ``NULL``. " -"Instead, the dict for such types is stored on ``PyInterpreterState``. Use :c:" -"func:`PyType_GetDict` to get the dict for an arbitrary type." +"Instead, the dict for such types is stored on ``PyInterpreterState``. " +"Use :c:func:`PyType_GetDict` to get the dict for an arbitrary type." msgstr "" -#: c-api/typeobj.rst:1742 +#: c-api/typeobj.rst:1756 msgid "" "This field is not inherited by subtypes (though the attributes defined in " "here are inherited through a different mechanism)." msgstr "" -#: c-api/typeobj.rst:1747 +#: c-api/typeobj.rst:1761 msgid "" "If this field is ``NULL``, :c:func:`PyType_Ready` will assign a new " "dictionary to it." msgstr "" -#: c-api/typeobj.rst:1752 +#: c-api/typeobj.rst:1766 msgid "" -"It is not safe to use :c:func:`PyDict_SetItem` on or otherwise modify :c:" -"member:`~PyTypeObject.tp_dict` with the dictionary C-API." +"It is not safe to use :c:func:`PyDict_SetItem` on or otherwise " +"modify :c:member:`~PyTypeObject.tp_dict` with the dictionary C-API." msgstr "" -#: c-api/typeobj.rst:1758 +#: c-api/typeobj.rst:1772 msgid "An optional pointer to a \"descriptor get\" function." msgstr "" -#: c-api/typeobj.rst:1776 c-api/typeobj.rst:1870 c-api/typeobj.rst:1894 +#: c-api/typeobj.rst:1790 c-api/typeobj.rst:1884 c-api/typeobj.rst:1908 msgid "The function signature is::" msgstr "" -#: c-api/typeobj.rst:1773 +#: c-api/typeobj.rst:1776 +msgid "PyObject * tp_descr_get(PyObject *self, PyObject *obj, PyObject *type);" +msgstr "" + +#: c-api/typeobj.rst:1787 msgid "" "An optional pointer to a function for setting and deleting a descriptor's " "value." msgstr "" -#: c-api/typeobj.rst:1780 +#: c-api/typeobj.rst:1792 +msgid "int tp_descr_set(PyObject *self, PyObject *obj, PyObject *value);" +msgstr "" + +#: c-api/typeobj.rst:1794 msgid "The *value* argument is set to ``NULL`` to delete the value." msgstr "" -#: c-api/typeobj.rst:1791 +#: c-api/typeobj.rst:1805 msgid "" "While this field is still supported, :c:macro:`Py_TPFLAGS_MANAGED_DICT` " "should be used instead, if at all possible." msgstr "" -#: c-api/typeobj.rst:1794 +#: c-api/typeobj.rst:1808 msgid "" "If the instances of this type have a dictionary containing instance " "variables, this field is non-zero and contains the offset in the instances " -"of the type of the instance variable dictionary; this offset is used by :c:" -"func:`PyObject_GenericGetAttr`." +"of the type of the instance variable dictionary; this offset is used " +"by :c:func:`PyObject_GenericGetAttr`." msgstr "" -#: c-api/typeobj.rst:1799 +#: c-api/typeobj.rst:1813 msgid "" "Do not confuse this field with :c:member:`~PyTypeObject.tp_dict`; that is " "the dictionary for attributes of the type object itself." msgstr "" -#: c-api/typeobj.rst:1802 +#: c-api/typeobj.rst:1816 msgid "" "The value specifies the offset of the dictionary from the start of the " "instance structure." msgstr "" -#: c-api/typeobj.rst:1804 +#: c-api/typeobj.rst:1818 msgid "" "The :c:member:`~PyTypeObject.tp_dictoffset` should be regarded as write-" -"only. To get the pointer to the dictionary call :c:func:" -"`PyObject_GenericGetDict`. Calling :c:func:`PyObject_GenericGetDict` may " -"need to allocate memory for the dictionary, so it is may be more efficient " -"to call :c:func:`PyObject_GetAttr` when accessing an attribute on the object." +"only. To get the pointer to the dictionary " +"call :c:func:`PyObject_GenericGetDict`. " +"Calling :c:func:`PyObject_GenericGetDict` may need to allocate memory for " +"the dictionary, so it is may be more efficient to " +"call :c:func:`PyObject_GetAttr` when accessing an attribute on the object." msgstr "" -#: c-api/typeobj.rst:1810 +#: c-api/typeobj.rst:1824 msgid "" -"It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit " +"It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit " "and :c:member:`~PyTypeObject.tp_dictoffset`." msgstr "" -#: c-api/typeobj.rst:1815 +#: c-api/typeobj.rst:1829 msgid "" "This field is inherited by subtypes. A subtype should not override this " "offset; doing so could be unsafe, if C code tries to access the dictionary " -"at the previous offset. To properly support inheritance, use :c:macro:" -"`Py_TPFLAGS_MANAGED_DICT`." +"at the previous offset. To properly support inheritance, " +"use :c:macro:`Py_TPFLAGS_MANAGED_DICT`." msgstr "" -#: c-api/typeobj.rst:1822 +#: c-api/typeobj.rst:1836 msgid "" "This slot has no default. For :ref:`static types `, if the " "field is ``NULL`` then no :attr:`~object.__dict__` gets created for " "instances." msgstr "" -#: c-api/typeobj.rst:1825 +#: c-api/typeobj.rst:1839 msgid "" -"If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the :c:member:" -"`~PyTypeObject.tp_dict` field, then :c:member:`~PyTypeObject.tp_dictoffset` " -"will be set to ``-1``, to indicate that it is unsafe to use this field." +"If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in " +"the :c:member:`~PyTypeObject.tp_dict` field, " +"then :c:member:`~PyTypeObject.tp_dictoffset` will be set to ``-1``, to " +"indicate that it is unsafe to use this field." msgstr "" -#: c-api/typeobj.rst:1833 +#: c-api/typeobj.rst:1847 msgid "An optional pointer to an instance initialization function." msgstr "" -#: c-api/typeobj.rst:1835 +#: c-api/typeobj.rst:1849 msgid "" "This function corresponds to the :meth:`~object.__init__` method of " "classes. Like :meth:`!__init__`, it is possible to create an instance " @@ -2634,96 +2884,111 @@ msgid "" "instance by calling its :meth:`!__init__` method again." msgstr "" -#: c-api/typeobj.rst:1844 +#: c-api/typeobj.rst:1856 +msgid "int tp_init(PyObject *self, PyObject *args, PyObject *kwds);" +msgstr "" + +#: c-api/typeobj.rst:1858 msgid "" "The self argument is the instance to be initialized; the *args* and *kwds* " -"arguments represent positional and keyword arguments of the call to :meth:" -"`~object.__init__`." +"arguments represent positional and keyword arguments of the call " +"to :meth:`~object.__init__`." msgstr "" -#: c-api/typeobj.rst:1848 +#: c-api/typeobj.rst:1862 msgid "" "The :c:member:`~PyTypeObject.tp_init` function, if not ``NULL``, is called " -"when an instance is created normally by calling its type, after the type's :" -"c:member:`~PyTypeObject.tp_new` function has returned an instance of the " -"type. If the :c:member:`~PyTypeObject.tp_new` function returns an instance " -"of some other type that is not a subtype of the original type, no :c:member:" -"`~PyTypeObject.tp_init` function is called; if :c:member:`~PyTypeObject." -"tp_new` returns an instance of a subtype of the original type, the " -"subtype's :c:member:`~PyTypeObject.tp_init` is called." +"when an instance is created normally by calling its type, after the " +"type's :c:member:`~PyTypeObject.tp_new` function has returned an instance of " +"the type. If the :c:member:`~PyTypeObject.tp_new` function returns an " +"instance of some other type that is not a subtype of the original type, " +"no :c:member:`~PyTypeObject.tp_init` function is called; " +"if :c:member:`~PyTypeObject.tp_new` returns an instance of a subtype of the " +"original type, the subtype's :c:member:`~PyTypeObject.tp_init` is called." msgstr "" -#: c-api/typeobj.rst:1855 +#: c-api/typeobj.rst:1869 msgid "Returns ``0`` on success, ``-1`` and sets an exception on error." msgstr "" -#: c-api/typeobj.rst:1863 +#: c-api/typeobj.rst:1877 msgid "" "For :ref:`static types ` this field does not have a default." msgstr "" -#: c-api/typeobj.rst:1868 +#: c-api/typeobj.rst:1882 msgid "An optional pointer to an instance allocation function." msgstr "" -#: c-api/typeobj.rst:1876 +#: c-api/typeobj.rst:1886 +msgid "PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);" +msgstr "" + +#: c-api/typeobj.rst:1890 msgid "" "This field is inherited by static subtypes, but not by dynamic subtypes " "(subtypes created by a class statement)." msgstr "" -#: c-api/typeobj.rst:1881 +#: c-api/typeobj.rst:1895 msgid "" -"For dynamic subtypes, this field is always set to :c:func:" -"`PyType_GenericAlloc`, to force a standard heap allocation strategy." +"For dynamic subtypes, this field is always set " +"to :c:func:`PyType_GenericAlloc`, to force a standard heap allocation " +"strategy." msgstr "" -#: c-api/typeobj.rst:1885 +#: c-api/typeobj.rst:1899 msgid "" -"For static subtypes, :c:data:`PyBaseObject_Type` uses :c:func:" -"`PyType_GenericAlloc`. That is the recommended value for all statically " -"defined types." +"For static subtypes, :c:data:`PyBaseObject_Type` " +"uses :c:func:`PyType_GenericAlloc`. That is the recommended value for all " +"statically defined types." msgstr "" -#: c-api/typeobj.rst:1892 +#: c-api/typeobj.rst:1906 msgid "An optional pointer to an instance creation function." msgstr "" -#: c-api/typeobj.rst:1898 +#: c-api/typeobj.rst:1910 +msgid "" +"PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);" +msgstr "" + +#: c-api/typeobj.rst:1912 msgid "" "The *subtype* argument is the type of the object being created; the *args* " "and *kwds* arguments represent positional and keyword arguments of the call " -"to the type. Note that *subtype* doesn't have to equal the type whose :c:" -"member:`~PyTypeObject.tp_new` function is called; it may be a subtype of " -"that type (but not an unrelated type)." +"to the type. Note that *subtype* doesn't have to equal the type " +"whose :c:member:`~PyTypeObject.tp_new` function is called; it may be a " +"subtype of that type (but not an unrelated type)." msgstr "" -#: c-api/typeobj.rst:1904 +#: c-api/typeobj.rst:1918 msgid "" "The :c:member:`~PyTypeObject.tp_new` function should call ``subtype-" ">tp_alloc(subtype, nitems)`` to allocate space for the object, and then do " "only as much further initialization as is absolutely necessary. " "Initialization that can safely be ignored or repeated should be placed in " "the :c:member:`~PyTypeObject.tp_init` handler. A good rule of thumb is that " -"for immutable types, all initialization should take place in :c:member:" -"`~PyTypeObject.tp_new`, while for mutable types, most initialization should " -"be deferred to :c:member:`~PyTypeObject.tp_init`." +"for immutable types, all initialization should take place " +"in :c:member:`~PyTypeObject.tp_new`, while for mutable types, most " +"initialization should be deferred to :c:member:`~PyTypeObject.tp_init`." msgstr "" -#: c-api/typeobj.rst:1912 +#: c-api/typeobj.rst:1926 msgid "" "Set the :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag to disallow " "creating instances of the type in Python." msgstr "" -#: c-api/typeobj.rst:1917 +#: c-api/typeobj.rst:1931 msgid "" -"This field is inherited by subtypes, except it is not inherited by :ref:" -"`static types ` whose :c:member:`~PyTypeObject.tp_base` is " -"``NULL`` or ``&PyBaseObject_Type``." +"This field is inherited by subtypes, except it is not inherited " +"by :ref:`static types ` " +"whose :c:member:`~PyTypeObject.tp_base` is ``NULL`` or " +"``&PyBaseObject_Type``." msgstr "" -#: c-api/typeobj.rst:1923 +#: c-api/typeobj.rst:1937 msgid "" "For :ref:`static types ` this field has no default. This means " "if the slot is defined as ``NULL``, the type cannot be called to create new " @@ -2731,132 +2996,140 @@ msgid "" "factory function." msgstr "" -#: c-api/typeobj.rst:1931 +#: c-api/typeobj.rst:1945 msgid "" "An optional pointer to an instance deallocation function. Its signature is::" msgstr "" -#: c-api/typeobj.rst:1935 +#: c-api/typeobj.rst:1947 +msgid "void tp_free(void *self);" +msgstr "" + +#: c-api/typeobj.rst:1949 msgid "" -"An initializer that is compatible with this signature is :c:func:" -"`PyObject_Free`." +"An initializer that is compatible with this signature " +"is :c:func:`PyObject_Free`." msgstr "" -#: c-api/typeobj.rst:1939 +#: c-api/typeobj.rst:1953 msgid "" "This field is inherited by static subtypes, but not by dynamic subtypes " "(subtypes created by a class statement)" msgstr "" -#: c-api/typeobj.rst:1944 +#: c-api/typeobj.rst:1958 msgid "" -"In dynamic subtypes, this field is set to a deallocator suitable to match :c:" -"func:`PyType_GenericAlloc` and the value of the :c:macro:" -"`Py_TPFLAGS_HAVE_GC` flag bit." +"In dynamic subtypes, this field is set to a deallocator suitable to " +"match :c:func:`PyType_GenericAlloc` and the value of " +"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit." msgstr "" -#: c-api/typeobj.rst:1948 +#: c-api/typeobj.rst:1962 msgid "" "For static subtypes, :c:data:`PyBaseObject_Type` uses :c:func:`PyObject_Del`." msgstr "" -#: c-api/typeobj.rst:1953 +#: c-api/typeobj.rst:1967 msgid "An optional pointer to a function called by the garbage collector." msgstr "" -#: c-api/typeobj.rst:1955 +#: c-api/typeobj.rst:1969 msgid "" "The garbage collector needs to know whether a particular object is " "collectible or not. Normally, it is sufficient to look at the object's " -"type's :c:member:`~PyTypeObject.tp_flags` field, and check the :c:macro:" -"`Py_TPFLAGS_HAVE_GC` flag bit. But some types have a mixture of statically " -"and dynamically allocated instances, and the statically allocated instances " -"are not collectible. Such types should define this function; it should " -"return ``1`` for a collectible instance, and ``0`` for a non-collectible " -"instance. The signature is::" +"type's :c:member:`~PyTypeObject.tp_flags` field, and check " +"the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit. But some types have a mixture " +"of statically and dynamically allocated instances, and the statically " +"allocated instances are not collectible. Such types should define this " +"function; it should return ``1`` for a collectible instance, and ``0`` for a " +"non-collectible instance. The signature is::" +msgstr "" + +#: c-api/typeobj.rst:1977 +msgid "int tp_is_gc(PyObject *self);" msgstr "" -#: c-api/typeobj.rst:1965 +#: c-api/typeobj.rst:1979 msgid "" -"(The only example of this are types themselves. The metatype, :c:data:" -"`PyType_Type`, defines this function to distinguish between statically and :" -"ref:`dynamically allocated types `.)" +"(The only example of this are types themselves. The " +"metatype, :c:data:`PyType_Type`, defines this function to distinguish " +"between statically and :ref:`dynamically allocated types `.)" msgstr "" -#: c-api/typeobj.rst:1975 +#: c-api/typeobj.rst:1989 msgid "" -"This slot has no default. If this field is ``NULL``, :c:macro:" -"`Py_TPFLAGS_HAVE_GC` is used as the functional equivalent." +"This slot has no default. If this field is " +"``NULL``, :c:macro:`Py_TPFLAGS_HAVE_GC` is used as the functional equivalent." msgstr "" -#: c-api/typeobj.rst:1981 +#: c-api/typeobj.rst:1995 msgid "Tuple of base types." msgstr "" -#: c-api/typeobj.rst:2007 +#: c-api/typeobj.rst:2021 msgid "" "This field should be set to ``NULL`` and treated as read-only. Python will " "fill it in when the type is :c:func:`initialized `." msgstr "" -#: c-api/typeobj.rst:1986 +#: c-api/typeobj.rst:2000 msgid "" "For dynamically created classes, the ``Py_tp_bases`` :c:type:`slot " -"` can be used instead of the *bases* argument of :c:func:" -"`PyType_FromSpecWithBases`. The argument form is preferred." +"` can be used instead of the *bases* argument " +"of :c:func:`PyType_FromSpecWithBases`. The argument form is preferred." msgstr "" -#: c-api/typeobj.rst:1993 +#: c-api/typeobj.rst:2007 msgid "" "Multiple inheritance does not work well for statically defined types. If you " "set ``tp_bases`` to a tuple, Python will not raise an error, but some slots " "will only be inherited from the first base." msgstr "" -#: c-api/typeobj.rst:2022 c-api/typeobj.rst:2056 c-api/typeobj.rst:2070 +#: c-api/typeobj.rst:2036 c-api/typeobj.rst:2070 c-api/typeobj.rst:2084 msgid "This field is not inherited." msgstr "" -#: c-api/typeobj.rst:2004 +#: c-api/typeobj.rst:2018 msgid "" "Tuple containing the expanded set of base types, starting with the type " "itself and ending with :class:`object`, in Method Resolution Order." msgstr "" -#: c-api/typeobj.rst:2012 +#: c-api/typeobj.rst:2026 msgid "" -"This field is not inherited; it is calculated fresh by :c:func:" -"`PyType_Ready`." +"This field is not inherited; it is calculated fresh " +"by :c:func:`PyType_Ready`." msgstr "" -#: c-api/typeobj.rst:2018 +#: c-api/typeobj.rst:2032 msgid "Unused. Internal use only." msgstr "" -#: c-api/typeobj.rst:2027 +#: c-api/typeobj.rst:2041 msgid "" "A collection of subclasses. Internal use only. May be an invalid pointer." msgstr "" -#: c-api/typeobj.rst:2029 +#: c-api/typeobj.rst:2043 msgid "" -"To get a list of subclasses, call the Python method :py:meth:`~class." -"__subclasses__`." +"To get a list of subclasses, call the Python " +"method :py:meth:`~type.__subclasses__`." msgstr "" -#: c-api/typeobj.rst:2034 +#: c-api/typeobj.rst:2048 msgid "" "For some types, this field does not hold a valid :c:expr:`PyObject*`. The " "type was changed to :c:expr:`void*` to indicate this." msgstr "" -#: c-api/typeobj.rst:2044 +#: c-api/typeobj.rst:2058 msgid "" "Weak reference list head, for weak references to this type object. Not " "inherited. Internal use only." msgstr "" -#: c-api/typeobj.rst:2049 +#: c-api/typeobj.rst:2063 msgid "" "Internals detail: For the static builtin types this is always ``NULL``, even " "if weakrefs are added. Instead, the weakrefs for each are stored on " @@ -2864,21 +3137,25 @@ msgid "" "``_PyObject_GET_WEAKREFS_LISTPTR()`` macro to avoid the distinction." msgstr "" -#: c-api/typeobj.rst:2061 +#: c-api/typeobj.rst:2075 msgid "" "This field is deprecated. Use :c:member:`~PyTypeObject.tp_finalize` instead." msgstr "" -#: c-api/typeobj.rst:2066 +#: c-api/typeobj.rst:2080 msgid "Used to index into the method cache. Internal use only." msgstr "" -#: c-api/typeobj.rst:2075 +#: c-api/typeobj.rst:2089 msgid "" "An optional pointer to an instance finalization function. Its signature is::" msgstr "" -#: c-api/typeobj.rst:2079 +#: c-api/typeobj.rst:2091 +msgid "void tp_finalize(PyObject *self);" +msgstr "" + +#: c-api/typeobj.rst:2093 msgid "" "If :c:member:`~PyTypeObject.tp_finalize` is set, the interpreter calls it " "once when finalizing an instance. It is called either from the garbage " @@ -2888,7 +3165,7 @@ msgid "" "object in a sane state." msgstr "" -#: c-api/typeobj.rst:2086 +#: c-api/typeobj.rst:2100 msgid "" ":c:member:`~PyTypeObject.tp_finalize` should not mutate the current " "exception status; therefore, a recommended way to write a non-trivial " @@ -2897,125 +3174,175 @@ msgstr "" #: c-api/typeobj.rst:2103 msgid "" -"Also, note that, in a garbage collected Python, :c:member:`~PyTypeObject." -"tp_dealloc` may be called from any Python thread, not just the thread which " -"created the object (if the object becomes part of a refcount cycle, that " -"cycle might be collected by a garbage collection on any thread). This is " -"not a problem for Python API calls, since the thread on which tp_dealloc is " -"called will own the Global Interpreter Lock (GIL). However, if the object " -"being destroyed in turn destroys objects from some other C or C++ library, " -"care should be taken to ensure that destroying those objects on the thread " -"which called tp_dealloc will not violate any assumptions of the library." +"static void\n" +"local_finalize(PyObject *self)\n" +"{\n" +" PyObject *error_type, *error_value, *error_traceback;\n" +"\n" +" /* Save the current exception, if any. */\n" +" PyErr_Fetch(&error_type, &error_value, &error_traceback);\n" +"\n" +" /* ... */\n" +"\n" +" /* Restore the saved exception. */\n" +" PyErr_Restore(error_type, error_value, error_traceback);\n" +"}" msgstr "" -#: c-api/typeobj.rst:2122 +#: c-api/typeobj.rst:2125 msgid "" -"Before version 3.8 it was necessary to set the :c:macro:" -"`Py_TPFLAGS_HAVE_FINALIZE` flags bit in order for this field to be used. " -"This is no longer required." +"Before version 3.8 it was necessary to set " +"the :c:macro:`Py_TPFLAGS_HAVE_FINALIZE` flags bit in order for this field to " +"be used. This is no longer required." msgstr "" -#: c-api/typeobj.rst:2126 +#: c-api/typeobj.rst:2129 msgid "\"Safe object finalization\" (:pep:`442`)" msgstr "" -#: c-api/typeobj.rst:2131 +#: c-api/typeobj.rst:2134 msgid "" "Vectorcall function to use for calls of this type object. In other words, it " "is used to implement :ref:`vectorcall ` for ``type.__call__``. " -"If ``tp_vectorcall`` is ``NULL``, the default call implementation using :" -"meth:`~object.__new__` and :meth:`~object.__init__` is used." +"If ``tp_vectorcall`` is ``NULL``, the default call implementation " +"using :meth:`~object.__new__` and :meth:`~object.__init__` is used." msgstr "" -#: c-api/typeobj.rst:2139 +#: c-api/typeobj.rst:2142 msgid "This field is never inherited." msgstr "" -#: c-api/typeobj.rst:2141 +#: c-api/typeobj.rst:2144 msgid "(the field exists since 3.8 but it's only used since 3.9)" msgstr "" -#: c-api/typeobj.rst:2146 +#: c-api/typeobj.rst:2149 msgid "Internal. Do not use." msgstr "" -#: c-api/typeobj.rst:2154 +#: c-api/typeobj.rst:2157 msgid "Static Types" msgstr "" -#: c-api/typeobj.rst:2156 +#: c-api/typeobj.rst:2159 msgid "" -"Traditionally, types defined in C code are *static*, that is, a static :c:" -"type:`PyTypeObject` structure is defined directly in code and initialized " -"using :c:func:`PyType_Ready`." +"Traditionally, types defined in C code are *static*, that is, a " +"static :c:type:`PyTypeObject` structure is defined directly in code and " +"initialized using :c:func:`PyType_Ready`." msgstr "" -#: c-api/typeobj.rst:2160 +#: c-api/typeobj.rst:2163 msgid "" "This results in types that are limited relative to types defined in Python:" msgstr "" -#: c-api/typeobj.rst:2162 +#: c-api/typeobj.rst:2165 msgid "" "Static types are limited to one base, i.e. they cannot use multiple " "inheritance." msgstr "" -#: c-api/typeobj.rst:2164 +#: c-api/typeobj.rst:2167 msgid "" "Static type objects (but not necessarily their instances) are immutable. It " "is not possible to add or modify the type object's attributes from Python." msgstr "" -#: c-api/typeobj.rst:2166 +#: c-api/typeobj.rst:2169 msgid "" "Static type objects are shared across :ref:`sub-interpreters `, so they should not include any subinterpreter-" "specific state." msgstr "" -#: c-api/typeobj.rst:2170 +#: c-api/typeobj.rst:2173 msgid "" "Also, since :c:type:`PyTypeObject` is only part of the :ref:`Limited API " "` as an opaque struct, any extension modules using static " "types must be compiled for a specific Python minor version." msgstr "" -#: c-api/typeobj.rst:2178 +#: c-api/typeobj.rst:2181 msgid "Heap Types" msgstr "" -#: c-api/typeobj.rst:2180 +#: c-api/typeobj.rst:2183 msgid "" "An alternative to :ref:`static types ` is *heap-allocated " "types*, or *heap types* for short, which correspond closely to classes " -"created by Python's ``class`` statement. Heap types have the :c:macro:" -"`Py_TPFLAGS_HEAPTYPE` flag set." +"created by Python's ``class`` statement. Heap types have " +"the :c:macro:`Py_TPFLAGS_HEAPTYPE` flag set." msgstr "" -#: c-api/typeobj.rst:2185 +#: c-api/typeobj.rst:2188 msgid "" -"This is done by filling a :c:type:`PyType_Spec` structure and calling :c:" -"func:`PyType_FromSpec`, :c:func:`PyType_FromSpecWithBases`, :c:func:" -"`PyType_FromModuleAndSpec`, or :c:func:`PyType_FromMetaclass`." +"This is done by filling a :c:type:`PyType_Spec` structure and " +"calling :c:func:`PyType_FromSpec`, :c:func:`PyType_FromSpecWithBases`, :c:func:`PyType_FromModuleAndSpec`, " +"or :c:func:`PyType_FromMetaclass`." msgstr "" -#: c-api/typeobj.rst:2193 +#: c-api/typeobj.rst:2196 msgid "Number Object Structures" msgstr "" -#: c-api/typeobj.rst:2200 +#: c-api/typeobj.rst:2203 msgid "" "This structure holds pointers to the functions which an object uses to " "implement the number protocol. Each function is used by the function of " "similar name documented in the :ref:`number` section." msgstr "" -#: c-api/typeobj.rst:2530 +#: c-api/typeobj.rst:2533 msgid "Here is the structure definition::" msgstr "" -#: c-api/typeobj.rst:2253 +#: c-api/typeobj.rst:2211 +msgid "" +"typedef struct {\n" +" binaryfunc nb_add;\n" +" binaryfunc nb_subtract;\n" +" binaryfunc nb_multiply;\n" +" binaryfunc nb_remainder;\n" +" binaryfunc nb_divmod;\n" +" ternaryfunc nb_power;\n" +" unaryfunc nb_negative;\n" +" unaryfunc nb_positive;\n" +" unaryfunc nb_absolute;\n" +" inquiry nb_bool;\n" +" unaryfunc nb_invert;\n" +" binaryfunc nb_lshift;\n" +" binaryfunc nb_rshift;\n" +" binaryfunc nb_and;\n" +" binaryfunc nb_xor;\n" +" binaryfunc nb_or;\n" +" unaryfunc nb_int;\n" +" void *nb_reserved;\n" +" unaryfunc nb_float;\n" +"\n" +" binaryfunc nb_inplace_add;\n" +" binaryfunc nb_inplace_subtract;\n" +" binaryfunc nb_inplace_multiply;\n" +" binaryfunc nb_inplace_remainder;\n" +" ternaryfunc nb_inplace_power;\n" +" binaryfunc nb_inplace_lshift;\n" +" binaryfunc nb_inplace_rshift;\n" +" binaryfunc nb_inplace_and;\n" +" binaryfunc nb_inplace_xor;\n" +" binaryfunc nb_inplace_or;\n" +"\n" +" binaryfunc nb_floor_divide;\n" +" binaryfunc nb_true_divide;\n" +" binaryfunc nb_inplace_floor_divide;\n" +" binaryfunc nb_inplace_true_divide;\n" +"\n" +" unaryfunc nb_index;\n" +"\n" +" binaryfunc nb_matrix_multiply;\n" +" binaryfunc nb_inplace_matrix_multiply;\n" +"} PyNumberMethods;" +msgstr "" + +#: c-api/typeobj.rst:2256 msgid "" "Binary and ternary functions must check the type of all their operands, and " "implement the necessary conversions (at least one of the operands is an " @@ -3025,81 +3352,82 @@ msgid "" "and set an exception." msgstr "" -#: c-api/typeobj.rst:2262 +#: c-api/typeobj.rst:2265 msgid "" "The :c:member:`~PyNumberMethods.nb_reserved` field should always be " "``NULL``. It was previously called :c:member:`!nb_long`, and was renamed in " "Python 3.0.1." msgstr "" -#: c-api/typeobj.rst:2307 +#: c-api/typeobj.rst:2310 msgid "Mapping Object Structures" msgstr "" -#: c-api/typeobj.rst:2314 +#: c-api/typeobj.rst:2317 msgid "" "This structure holds pointers to the functions which an object uses to " "implement the mapping protocol. It has three members:" msgstr "" -#: c-api/typeobj.rst:2319 +#: c-api/typeobj.rst:2322 msgid "" -"This function is used by :c:func:`PyMapping_Size` and :c:func:" -"`PyObject_Size`, and has the same signature. This slot may be set to " -"``NULL`` if the object has no defined length." +"This function is used by :c:func:`PyMapping_Size` " +"and :c:func:`PyObject_Size`, and has the same signature. This slot may be " +"set to ``NULL`` if the object has no defined length." msgstr "" -#: c-api/typeobj.rst:2325 +#: c-api/typeobj.rst:2328 msgid "" -"This function is used by :c:func:`PyObject_GetItem` and :c:func:" -"`PySequence_GetSlice`, and has the same signature as :c:func:`!" -"PyObject_GetItem`. This slot must be filled for the :c:func:" -"`PyMapping_Check` function to return ``1``, it can be ``NULL`` otherwise." +"This function is used by :c:func:`PyObject_GetItem` " +"and :c:func:`PySequence_GetSlice`, and has the same signature as :c:func:`!" +"PyObject_GetItem`. This slot must be filled for " +"the :c:func:`PyMapping_Check` function to return ``1``, it can be ``NULL`` " +"otherwise." msgstr "" -#: c-api/typeobj.rst:2333 +#: c-api/typeobj.rst:2336 msgid "" -"This function is used by :c:func:`PyObject_SetItem`, :c:func:" -"`PyObject_DelItem`, :c:func:`PySequence_SetSlice` and :c:func:" -"`PySequence_DelSlice`. It has the same signature as :c:func:`!" +"This function is used " +"by :c:func:`PyObject_SetItem`, :c:func:`PyObject_DelItem`, :c:func:`PySequence_SetSlice` " +"and :c:func:`PySequence_DelSlice`. It has the same signature as :c:func:`!" "PyObject_SetItem`, but *v* can also be set to ``NULL`` to delete an item. " "If this slot is ``NULL``, the object does not support item assignment and " "deletion." msgstr "" -#: c-api/typeobj.rst:2344 +#: c-api/typeobj.rst:2347 msgid "Sequence Object Structures" msgstr "" -#: c-api/typeobj.rst:2351 +#: c-api/typeobj.rst:2354 msgid "" "This structure holds pointers to the functions which an object uses to " "implement the sequence protocol." msgstr "" -#: c-api/typeobj.rst:2356 +#: c-api/typeobj.rst:2359 msgid "" -"This function is used by :c:func:`PySequence_Size` and :c:func:" -"`PyObject_Size`, and has the same signature. It is also used for handling " -"negative indices via the :c:member:`~PySequenceMethods.sq_item` and the :c:" -"member:`~PySequenceMethods.sq_ass_item` slots." +"This function is used by :c:func:`PySequence_Size` " +"and :c:func:`PyObject_Size`, and has the same signature. It is also used " +"for handling negative indices via the :c:member:`~PySequenceMethods.sq_item` " +"and the :c:member:`~PySequenceMethods.sq_ass_item` slots." msgstr "" -#: c-api/typeobj.rst:2363 +#: c-api/typeobj.rst:2366 msgid "" "This function is used by :c:func:`PySequence_Concat` and has the same " "signature. It is also used by the ``+`` operator, after trying the numeric " "addition via the :c:member:`~PyNumberMethods.nb_add` slot." msgstr "" -#: c-api/typeobj.rst:2369 +#: c-api/typeobj.rst:2372 msgid "" "This function is used by :c:func:`PySequence_Repeat` and has the same " "signature. It is also used by the ``*`` operator, after trying numeric " "multiplication via the :c:member:`~PyNumberMethods.nb_multiply` slot." msgstr "" -#: c-api/typeobj.rst:2375 +#: c-api/typeobj.rst:2378 msgid "" "This function is used by :c:func:`PySequence_GetItem` and has the same " "signature. It is also used by :c:func:`PyObject_GetItem`, after trying the " @@ -3108,42 +3436,43 @@ msgid "" "``1``, it can be ``NULL`` otherwise." msgstr "" -#: c-api/typeobj.rst:2381 +#: c-api/typeobj.rst:2384 msgid "" -"Negative indexes are handled as follows: if the :c:member:" -"`~PySequenceMethods.sq_length` slot is filled, it is called and the sequence " -"length is used to compute a positive index which is passed to :c:member:" -"`~PySequenceMethods.sq_item`. If :c:member:`!sq_length` is ``NULL``, the " -"index is passed as is to the function." +"Negative indexes are handled as follows: if " +"the :c:member:`~PySequenceMethods.sq_length` slot is filled, it is called " +"and the sequence length is used to compute a positive index which is passed " +"to :c:member:`~PySequenceMethods.sq_item`. If :c:member:`!sq_length` is " +"``NULL``, the index is passed as is to the function." msgstr "" -#: c-api/typeobj.rst:2388 +#: c-api/typeobj.rst:2391 msgid "" "This function is used by :c:func:`PySequence_SetItem` and has the same " -"signature. It is also used by :c:func:`PyObject_SetItem` and :c:func:" -"`PyObject_DelItem`, after trying the item assignment and deletion via the :c:" -"member:`~PyMappingMethods.mp_ass_subscript` slot. This slot may be left to " -"``NULL`` if the object does not support item assignment and deletion." +"signature. It is also used by :c:func:`PyObject_SetItem` " +"and :c:func:`PyObject_DelItem`, after trying the item assignment and " +"deletion via the :c:member:`~PyMappingMethods.mp_ass_subscript` slot. This " +"slot may be left to ``NULL`` if the object does not support item assignment " +"and deletion." msgstr "" -#: c-api/typeobj.rst:2397 +#: c-api/typeobj.rst:2400 msgid "" "This function may be used by :c:func:`PySequence_Contains` and has the same " "signature. This slot may be left to ``NULL``, in this case :c:func:`!" "PySequence_Contains` simply traverses the sequence until it finds a match." msgstr "" -#: c-api/typeobj.rst:2404 +#: c-api/typeobj.rst:2407 msgid "" "This function is used by :c:func:`PySequence_InPlaceConcat` and has the same " "signature. It should modify its first operand, and return it. This slot " "may be left to ``NULL``, in this case :c:func:`!PySequence_InPlaceConcat` " "will fall back to :c:func:`PySequence_Concat`. It is also used by the " -"augmented assignment ``+=``, after trying numeric in-place addition via the :" -"c:member:`~PyNumberMethods.nb_inplace_add` slot." +"augmented assignment ``+=``, after trying numeric in-place addition via " +"the :c:member:`~PyNumberMethods.nb_inplace_add` slot." msgstr "" -#: c-api/typeobj.rst:2413 +#: c-api/typeobj.rst:2416 msgid "" "This function is used by :c:func:`PySequence_InPlaceRepeat` and has the same " "signature. It should modify its first operand, and return it. This slot " @@ -3153,70 +3482,74 @@ msgid "" "via the :c:member:`~PyNumberMethods.nb_inplace_multiply` slot." msgstr "" -#: c-api/typeobj.rst:2424 +#: c-api/typeobj.rst:2427 msgid "Buffer Object Structures" msgstr "" -#: c-api/typeobj.rst:2432 +#: c-api/typeobj.rst:2435 msgid "" "This structure holds pointers to the functions required by the :ref:`Buffer " "protocol `. The protocol defines how an exporter object can " "expose its internal data to consumer objects." msgstr "" -#: c-api/typeobj.rst:2487 c-api/typeobj.rst:2552 c-api/typeobj.rst:2574 +#: c-api/typeobj.rst:2490 c-api/typeobj.rst:2555 c-api/typeobj.rst:2577 msgid "The signature of this function is::" msgstr "" -#: c-api/typeobj.rst:2442 +#: c-api/typeobj.rst:2443 +msgid "int (PyObject *exporter, Py_buffer *view, int flags);" +msgstr "" + +#: c-api/typeobj.rst:2445 msgid "" "Handle a request to *exporter* to fill in *view* as specified by *flags*. " "Except for point (3), an implementation of this function MUST take these " "steps:" msgstr "" -#: c-api/typeobj.rst:2446 +#: c-api/typeobj.rst:2449 msgid "" -"Check if the request can be met. If not, raise :exc:`BufferError`, set :c:" -"expr:`view->obj` to ``NULL`` and return ``-1``." +"Check if the request can be met. If not, raise :exc:`BufferError`, " +"set :c:expr:`view->obj` to ``NULL`` and return ``-1``." msgstr "" -#: c-api/typeobj.rst:2449 +#: c-api/typeobj.rst:2452 msgid "Fill in the requested fields." msgstr "" -#: c-api/typeobj.rst:2451 +#: c-api/typeobj.rst:2454 msgid "Increment an internal counter for the number of exports." msgstr "" -#: c-api/typeobj.rst:2453 +#: c-api/typeobj.rst:2456 msgid "" "Set :c:expr:`view->obj` to *exporter* and increment :c:expr:`view->obj`." msgstr "" -#: c-api/typeobj.rst:2455 +#: c-api/typeobj.rst:2458 msgid "Return ``0``." msgstr "" -#: c-api/typeobj.rst:2457 +#: c-api/typeobj.rst:2460 msgid "" "If *exporter* is part of a chain or tree of buffer providers, two main " "schemes can be used:" msgstr "" -#: c-api/typeobj.rst:2460 +#: c-api/typeobj.rst:2463 msgid "" -"Re-export: Each member of the tree acts as the exporting object and sets :c:" -"expr:`view->obj` to a new reference to itself." +"Re-export: Each member of the tree acts as the exporting object and " +"sets :c:expr:`view->obj` to a new reference to itself." msgstr "" -#: c-api/typeobj.rst:2463 +#: c-api/typeobj.rst:2466 msgid "" "Redirect: The buffer request is redirected to the root object of the tree. " "Here, :c:expr:`view->obj` will be a new reference to the root object." msgstr "" -#: c-api/typeobj.rst:2467 +#: c-api/typeobj.rst:2470 msgid "" "The individual fields of *view* are described in section :ref:`Buffer " "structure `, the rules how an exporter must react to " @@ -3224,28 +3557,31 @@ msgid "" "types>`." msgstr "" -#: c-api/typeobj.rst:2472 +#: c-api/typeobj.rst:2475 msgid "" "All memory pointed to in the :c:type:`Py_buffer` structure belongs to the " -"exporter and must remain valid until there are no consumers left. :c:member:" -"`~Py_buffer.format`, :c:member:`~Py_buffer.shape`, :c:member:`~Py_buffer." -"strides`, :c:member:`~Py_buffer.suboffsets` and :c:member:`~Py_buffer." -"internal` are read-only for the consumer." +"exporter and must remain valid until there are no consumers " +"left. :c:member:`~Py_buffer.format`, :c:member:`~Py_buffer.shape`, :c:member:`~Py_buffer.strides`, :c:member:`~Py_buffer.suboffsets` " +"and :c:member:`~Py_buffer.internal` are read-only for the consumer." msgstr "" -#: c-api/typeobj.rst:2479 +#: c-api/typeobj.rst:2482 msgid "" ":c:func:`PyBuffer_FillInfo` provides an easy way of exposing a simple bytes " "buffer while dealing correctly with all request types." msgstr "" -#: c-api/typeobj.rst:2482 +#: c-api/typeobj.rst:2485 msgid "" ":c:func:`PyObject_GetBuffer` is the interface for the consumer that wraps " "this function." msgstr "" -#: c-api/typeobj.rst:2491 +#: c-api/typeobj.rst:2492 +msgid "void (PyObject *exporter, Py_buffer *view);" +msgstr "" + +#: c-api/typeobj.rst:2494 msgid "" "Handle a request to release the resources of the buffer. If no resources " "need to be released, :c:member:`PyBufferProcs.bf_releasebuffer` may be " @@ -3253,15 +3589,15 @@ msgid "" "these optional steps:" msgstr "" -#: c-api/typeobj.rst:2496 +#: c-api/typeobj.rst:2499 msgid "Decrement an internal counter for the number of exports." msgstr "" -#: c-api/typeobj.rst:2498 +#: c-api/typeobj.rst:2501 msgid "If the counter is ``0``, free all memory associated with *view*." msgstr "" -#: c-api/typeobj.rst:2500 +#: c-api/typeobj.rst:2503 msgid "" "The exporter MUST use the :c:member:`~Py_buffer.internal` field to keep " "track of buffer-specific resources. This field is guaranteed to remain " @@ -3269,155 +3605,182 @@ msgid "" "*view* argument." msgstr "" -#: c-api/typeobj.rst:2506 +#: c-api/typeobj.rst:2509 msgid "" "This function MUST NOT decrement :c:expr:`view->obj`, since that is done " "automatically in :c:func:`PyBuffer_Release` (this scheme is useful for " "breaking reference cycles)." msgstr "" -#: c-api/typeobj.rst:2511 +#: c-api/typeobj.rst:2514 msgid "" ":c:func:`PyBuffer_Release` is the interface for the consumer that wraps this " "function." msgstr "" -#: c-api/typeobj.rst:2519 +#: c-api/typeobj.rst:2522 msgid "Async Object Structures" msgstr "" -#: c-api/typeobj.rst:2527 +#: c-api/typeobj.rst:2530 +msgid "" +"This structure holds pointers to the functions required to " +"implement :term:`awaitable` and :term:`asynchronous iterator` objects." +msgstr "" + +#: c-api/typeobj.rst:2535 msgid "" -"This structure holds pointers to the functions required to implement :term:" -"`awaitable` and :term:`asynchronous iterator` objects." +"typedef struct {\n" +" unaryfunc am_await;\n" +" unaryfunc am_aiter;\n" +" unaryfunc am_anext;\n" +" sendfunc am_send;\n" +"} PyAsyncMethods;" msgstr "" -#: c-api/typeobj.rst:2545 +#: c-api/typeobj.rst:2546 +msgid "PyObject *am_await(PyObject *self);" +msgstr "" + +#: c-api/typeobj.rst:2548 msgid "" "The returned object must be an :term:`iterator`, i.e. :c:func:`PyIter_Check` " "must return ``1`` for it." msgstr "" -#: c-api/typeobj.rst:2548 +#: c-api/typeobj.rst:2551 msgid "" "This slot may be set to ``NULL`` if an object is not an :term:`awaitable`." msgstr "" -#: c-api/typeobj.rst:2556 -msgid "" -"Must return an :term:`asynchronous iterator` object. See :meth:`~object." -"__anext__` for details." +#: c-api/typeobj.rst:2557 +msgid "PyObject *am_aiter(PyObject *self);" msgstr "" #: c-api/typeobj.rst:2559 msgid "" +"Must return an :term:`asynchronous iterator` object. " +"See :meth:`~object.__anext__` for details." +msgstr "" + +#: c-api/typeobj.rst:2562 +msgid "" "This slot may be set to ``NULL`` if an object does not implement " "asynchronous iteration protocol." msgstr "" -#: c-api/typeobj.rst:2568 +#: c-api/typeobj.rst:2569 +msgid "PyObject *am_anext(PyObject *self);" +msgstr "" + +#: c-api/typeobj.rst:2571 msgid "" "Must return an :term:`awaitable` object. See :meth:`~object.__anext__` for " "details. This slot may be set to ``NULL``." msgstr "" -#: c-api/typeobj.rst:2578 +#: c-api/typeobj.rst:2579 +msgid "PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);" +msgstr "" + +#: c-api/typeobj.rst:2581 msgid "" "See :c:func:`PyIter_Send` for details. This slot may be set to ``NULL``." msgstr "" -#: c-api/typeobj.rst:2587 +#: c-api/typeobj.rst:2590 msgid "Slot Type typedefs" msgstr "" -#: c-api/typeobj.rst:2591 +#: c-api/typeobj.rst:2594 msgid "" "The purpose of this function is to separate memory allocation from memory " "initialization. It should return a pointer to a block of memory of adequate " "length for the instance, suitably aligned, and initialized to zeros, but " -"with :c:member:`~PyObject.ob_refcnt` set to ``1`` and :c:member:`~PyObject." -"ob_type` set to the type argument. If the type's :c:member:`~PyTypeObject." -"tp_itemsize` is non-zero, the object's :c:member:`~PyVarObject.ob_size` " -"field should be initialized to *nitems* and the length of the allocated " -"memory block should be ``tp_basicsize + nitems*tp_itemsize``, rounded up to " -"a multiple of ``sizeof(void*)``; otherwise, *nitems* is not used and the " -"length of the block should be :c:member:`~PyTypeObject.tp_basicsize`." +"with :c:member:`~PyObject.ob_refcnt` set to ``1`` " +"and :c:member:`~PyObject.ob_type` set to the type argument. If the " +"type's :c:member:`~PyTypeObject.tp_itemsize` is non-zero, the " +"object's :c:member:`~PyVarObject.ob_size` field should be initialized to " +"*nitems* and the length of the allocated memory block should be " +"``tp_basicsize + nitems*tp_itemsize``, rounded up to a multiple of " +"``sizeof(void*)``; otherwise, *nitems* is not used and the length of the " +"block should be :c:member:`~PyTypeObject.tp_basicsize`." msgstr "" -#: c-api/typeobj.rst:2601 +#: c-api/typeobj.rst:2604 msgid "" "This function should not do any other instance initialization, not even to " -"allocate additional memory; that should be done by :c:member:`~PyTypeObject." -"tp_new`." +"allocate additional memory; that should be done " +"by :c:member:`~PyTypeObject.tp_new`." msgstr "" -#: c-api/typeobj.rst:2608 +#: c-api/typeobj.rst:2611 msgid "See :c:member:`~PyTypeObject.tp_free`." msgstr "" -#: c-api/typeobj.rst:2612 +#: c-api/typeobj.rst:2615 msgid "See :c:member:`~PyTypeObject.tp_new`." msgstr "" -#: c-api/typeobj.rst:2616 +#: c-api/typeobj.rst:2619 msgid "See :c:member:`~PyTypeObject.tp_init`." msgstr "" -#: c-api/typeobj.rst:2620 +#: c-api/typeobj.rst:2623 msgid "See :c:member:`~PyTypeObject.tp_repr`." msgstr "" -#: c-api/typeobj.rst:2633 +#: c-api/typeobj.rst:2636 msgid "Return the value of the named attribute for the object." msgstr "" -#: c-api/typeobj.rst:2639 +#: c-api/typeobj.rst:2642 msgid "" "Set the value of the named attribute for the object. The value argument is " "set to ``NULL`` to delete the attribute." msgstr "" -#: c-api/typeobj.rst:2635 +#: c-api/typeobj.rst:2638 msgid "See :c:member:`~PyTypeObject.tp_getattro`." msgstr "" -#: c-api/typeobj.rst:2642 +#: c-api/typeobj.rst:2645 msgid "See :c:member:`~PyTypeObject.tp_setattro`." msgstr "" -#: c-api/typeobj.rst:2646 +#: c-api/typeobj.rst:2649 msgid "See :c:member:`~PyTypeObject.tp_descr_get`." msgstr "" -#: c-api/typeobj.rst:2650 +#: c-api/typeobj.rst:2653 msgid "See :c:member:`~PyTypeObject.tp_descr_set`." msgstr "" -#: c-api/typeobj.rst:2654 +#: c-api/typeobj.rst:2657 msgid "See :c:member:`~PyTypeObject.tp_hash`." msgstr "" -#: c-api/typeobj.rst:2658 +#: c-api/typeobj.rst:2661 msgid "See :c:member:`~PyTypeObject.tp_richcompare`." msgstr "" -#: c-api/typeobj.rst:2662 +#: c-api/typeobj.rst:2665 msgid "See :c:member:`~PyTypeObject.tp_iter`." msgstr "" -#: c-api/typeobj.rst:2666 +#: c-api/typeobj.rst:2669 msgid "See :c:member:`~PyTypeObject.tp_iternext`." msgstr "" -#: c-api/typeobj.rst:2680 +#: c-api/typeobj.rst:2683 msgid "See :c:member:`~PyAsyncMethods.am_send`." msgstr "" -#: c-api/typeobj.rst:2696 +#: c-api/typeobj.rst:2699 msgid "Examples" msgstr "" -#: c-api/typeobj.rst:2698 +#: c-api/typeobj.rst:2701 msgid "" "The following are simple examples of Python type definitions. They include " "common usage you may encounter. Some demonstrate tricky corner cases. For " @@ -3425,46 +3788,179 @@ msgid "" "and :ref:`new-types-topics`." msgstr "" -#: c-api/typeobj.rst:2703 +#: c-api/typeobj.rst:2706 msgid "A basic :ref:`static type `::" msgstr "" -#: c-api/typeobj.rst:2720 +#: c-api/typeobj.rst:2708 +msgid "" +"typedef struct {\n" +" PyObject_HEAD\n" +" const char *data;\n" +"} MyObject;\n" +"\n" +"static PyTypeObject MyObject_Type = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"mymod.MyObject\",\n" +" .tp_basicsize = sizeof(MyObject),\n" +" .tp_doc = PyDoc_STR(\"My objects\"),\n" +" .tp_new = myobj_new,\n" +" .tp_dealloc = (destructor)myobj_dealloc,\n" +" .tp_repr = (reprfunc)myobj_repr,\n" +"};" +msgstr "" + +#: c-api/typeobj.rst:2723 msgid "" "You may also find older code (especially in the CPython code base) with a " "more verbose initializer::" msgstr "" -#: c-api/typeobj.rst:2764 +#: c-api/typeobj.rst:2726 +msgid "" +"static PyTypeObject MyObject_Type = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" \"mymod.MyObject\", /* tp_name */\n" +" sizeof(MyObject), /* tp_basicsize */\n" +" 0, /* tp_itemsize */\n" +" (destructor)myobj_dealloc, /* tp_dealloc */\n" +" 0, /* tp_vectorcall_offset */\n" +" 0, /* tp_getattr */\n" +" 0, /* tp_setattr */\n" +" 0, /* tp_as_async */\n" +" (reprfunc)myobj_repr, /* tp_repr */\n" +" 0, /* tp_as_number */\n" +" 0, /* tp_as_sequence */\n" +" 0, /* tp_as_mapping */\n" +" 0, /* tp_hash */\n" +" 0, /* tp_call */\n" +" 0, /* tp_str */\n" +" 0, /* tp_getattro */\n" +" 0, /* tp_setattro */\n" +" 0, /* tp_as_buffer */\n" +" 0, /* tp_flags */\n" +" PyDoc_STR(\"My objects\"), /* tp_doc */\n" +" 0, /* tp_traverse */\n" +" 0, /* tp_clear */\n" +" 0, /* tp_richcompare */\n" +" 0, /* tp_weaklistoffset */\n" +" 0, /* tp_iter */\n" +" 0, /* tp_iternext */\n" +" 0, /* tp_methods */\n" +" 0, /* tp_members */\n" +" 0, /* tp_getset */\n" +" 0, /* tp_base */\n" +" 0, /* tp_dict */\n" +" 0, /* tp_descr_get */\n" +" 0, /* tp_descr_set */\n" +" 0, /* tp_dictoffset */\n" +" 0, /* tp_init */\n" +" 0, /* tp_alloc */\n" +" myobj_new, /* tp_new */\n" +"};" +msgstr "" + +#: c-api/typeobj.rst:2767 msgid "A type that supports weakrefs, instance dicts, and hashing::" msgstr "" -#: c-api/typeobj.rst:2789 +#: c-api/typeobj.rst:2769 +msgid "" +"typedef struct {\n" +" PyObject_HEAD\n" +" const char *data;\n" +"} MyObject;\n" +"\n" +"static PyTypeObject MyObject_Type = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"mymod.MyObject\",\n" +" .tp_basicsize = sizeof(MyObject),\n" +" .tp_doc = PyDoc_STR(\"My objects\"),\n" +" .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |\n" +" Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_MANAGED_DICT |\n" +" Py_TPFLAGS_MANAGED_WEAKREF,\n" +" .tp_new = myobj_new,\n" +" .tp_traverse = (traverseproc)myobj_traverse,\n" +" .tp_clear = (inquiry)myobj_clear,\n" +" .tp_alloc = PyType_GenericNew,\n" +" .tp_dealloc = (destructor)myobj_dealloc,\n" +" .tp_repr = (reprfunc)myobj_repr,\n" +" .tp_hash = (hashfunc)myobj_hash,\n" +" .tp_richcompare = PyBaseObject_Type.tp_richcompare,\n" +"};" +msgstr "" + +#: c-api/typeobj.rst:2792 msgid "" "A str subclass that cannot be subclassed and cannot be called to create " -"instances (e.g. uses a separate factory func) using :c:macro:" -"`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag::" +"instances (e.g. uses a separate factory func) " +"using :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag::" +msgstr "" + +#: c-api/typeobj.rst:2796 +msgid "" +"typedef struct {\n" +" PyUnicodeObject raw;\n" +" char *extra;\n" +"} MyStr;\n" +"\n" +"static PyTypeObject MyStr_Type = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"mymod.MyStr\",\n" +" .tp_basicsize = sizeof(MyStr),\n" +" .tp_base = NULL, // set to &PyUnicode_Type in module init\n" +" .tp_doc = PyDoc_STR(\"my custom str\"),\n" +" .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION,\n" +" .tp_repr = (reprfunc)myobj_repr,\n" +"};" msgstr "" -#: c-api/typeobj.rst:2808 +#: c-api/typeobj.rst:2811 msgid "" "The simplest :ref:`static type ` with fixed-length instances::" msgstr "" -#: c-api/typeobj.rst:2819 +#: c-api/typeobj.rst:2813 +msgid "" +"typedef struct {\n" +" PyObject_HEAD\n" +"} MyObject;\n" +"\n" +"static PyTypeObject MyObject_Type = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"mymod.MyObject\",\n" +"};" +msgstr "" + +#: c-api/typeobj.rst:2822 msgid "" "The simplest :ref:`static type ` with variable-length " "instances::" msgstr "" -#: c-api/typeobj.rst:874 +#: c-api/typeobj.rst:2824 +msgid "" +"typedef struct {\n" +" PyObject_VAR_HEAD\n" +" const char *data[1];\n" +"} MyObject;\n" +"\n" +"static PyTypeObject MyObject_Type = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"mymod.MyObject\",\n" +" .tp_basicsize = sizeof(MyObject) - sizeof(char *),\n" +" .tp_itemsize = sizeof(char *),\n" +"};" +msgstr "" + +#: c-api/typeobj.rst:887 msgid "built-in function" msgstr "" -#: c-api/typeobj.rst:809 +#: c-api/typeobj.rst:822 msgid "repr" msgstr "" -#: c-api/typeobj.rst:874 +#: c-api/typeobj.rst:887 msgid "hash" msgstr "" diff --git a/c-api/unicode.po b/c-api/unicode.po index a8fedc46..7c0d2030 100644 --- a/c-api/unicode.po +++ b/c-api/unicode.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -124,8 +125,8 @@ msgstr "" msgid "" "Return a pointer to the canonical representation cast to UCS1, UCS2 or UCS4 " "integer types for direct character access. No checks are performed if the " -"canonical representation has the correct character size; use :c:func:" -"`PyUnicode_KIND` to select the right function." +"canonical representation has the correct character size; " +"use :c:func:`PyUnicode_KIND` to select the right function." msgstr "" #: c-api/unicode.rst:122 @@ -152,25 +153,25 @@ msgstr "" #: c-api/unicode.rst:150 msgid "" -"Write into a canonical representation *data* (as obtained with :c:func:" -"`PyUnicode_DATA`). This function performs no sanity checks, and is intended " -"for usage in loops. The caller should cache the *kind* value and *data* " -"pointer as obtained from other calls. *index* is the index in the string " -"(starts at 0) and *value* is the new code point value which should be " -"written to that location." +"Write into a canonical representation *data* (as obtained " +"with :c:func:`PyUnicode_DATA`). This function performs no sanity checks, " +"and is intended for usage in loops. The caller should cache the *kind* " +"value and *data* pointer as obtained from other calls. *index* is the index " +"in the string (starts at 0) and *value* is the new code point value which " +"should be written to that location." msgstr "" #: c-api/unicode.rst:163 msgid "" -"Read a code point from a canonical representation *data* (as obtained with :" -"c:func:`PyUnicode_DATA`). No checks or ready calls are performed." +"Read a code point from a canonical representation *data* (as obtained " +"with :c:func:`PyUnicode_DATA`). No checks or ready calls are performed." msgstr "" #: c-api/unicode.rst:171 msgid "" "Read a character from a Unicode object *unicode*, which must be in the " -"\"canonical\" representation. This is less efficient than :c:func:" -"`PyUnicode_READ` if you do multiple consecutive reads." +"\"canonical\" representation. This is less efficient " +"than :c:func:`PyUnicode_READ` if you do multiple consecutive reads." msgstr "" #: c-api/unicode.rst:180 @@ -252,70 +253,65 @@ msgstr "" #: c-api/unicode.rst:257 msgid "" -"Return ``1`` or ``0`` depending on whether *ch* is a printable character. " -"Nonprintable characters are those characters defined in the Unicode " -"character database as \"Other\" or \"Separator\", excepting the ASCII space " -"(0x20) which is considered printable. (Note that printable characters in " -"this context are those which should not be escaped when :func:`repr` is " -"invoked on a string. It has no bearing on the handling of strings written " -"to :data:`sys.stdout` or :data:`sys.stderr`.)" +"Return ``1`` or ``0`` depending on whether *ch* is a printable character, in " +"the sense of :meth:`str.isprintable`." msgstr "" -#: c-api/unicode.rst:266 +#: c-api/unicode.rst:261 msgid "These APIs can be used for fast direct character conversions:" msgstr "" -#: c-api/unicode.rst:271 +#: c-api/unicode.rst:266 msgid "Return the character *ch* converted to lower case." msgstr "" -#: c-api/unicode.rst:281 c-api/unicode.rst:289 +#: c-api/unicode.rst:276 c-api/unicode.rst:284 msgid "This function uses simple case mappings." msgstr "" -#: c-api/unicode.rst:279 +#: c-api/unicode.rst:274 msgid "Return the character *ch* converted to upper case." msgstr "" -#: c-api/unicode.rst:287 +#: c-api/unicode.rst:282 msgid "Return the character *ch* converted to title case." msgstr "" -#: c-api/unicode.rst:295 +#: c-api/unicode.rst:290 msgid "" "Return the character *ch* converted to a decimal positive integer. Return " "``-1`` if this is not possible. This function does not raise exceptions." msgstr "" -#: c-api/unicode.rst:301 +#: c-api/unicode.rst:296 msgid "" "Return the character *ch* converted to a single digit integer. Return ``-1`` " "if this is not possible. This function does not raise exceptions." msgstr "" -#: c-api/unicode.rst:307 +#: c-api/unicode.rst:302 msgid "" "Return the character *ch* converted to a double. Return ``-1.0`` if this is " "not possible. This function does not raise exceptions." msgstr "" -#: c-api/unicode.rst:311 +#: c-api/unicode.rst:306 msgid "These APIs can be used to work with surrogates:" msgstr "" -#: c-api/unicode.rst:315 +#: c-api/unicode.rst:310 msgid "Check if *ch* is a surrogate (``0xD800 <= ch <= 0xDFFF``)." msgstr "" -#: c-api/unicode.rst:319 +#: c-api/unicode.rst:314 msgid "Check if *ch* is a high surrogate (``0xD800 <= ch <= 0xDBFF``)." msgstr "" -#: c-api/unicode.rst:323 +#: c-api/unicode.rst:318 msgid "Check if *ch* is a low surrogate (``0xDC00 <= ch <= 0xDFFF``)." msgstr "" -#: c-api/unicode.rst:327 +#: c-api/unicode.rst:322 msgid "" "Join two surrogate characters and return a single :c:type:`Py_UCS4` value. " "*high* and *low* are respectively the leading and trailing surrogates in a " @@ -323,46 +319,51 @@ msgid "" "be in the range [0xDC00; 0xDFFF]." msgstr "" -#: c-api/unicode.rst:334 +#: c-api/unicode.rst:329 msgid "Creating and accessing Unicode strings" msgstr "" -#: c-api/unicode.rst:336 +#: c-api/unicode.rst:331 msgid "" "To create Unicode objects and access their basic sequence properties, use " "these APIs:" msgstr "" -#: c-api/unicode.rst:341 +#: c-api/unicode.rst:336 msgid "" "Create a new Unicode object. *maxchar* should be the true maximum code " "point to be placed in the string. As an approximation, it can be rounded up " "to the nearest value in the sequence 127, 255, 65535, 1114111." msgstr "" -#: c-api/unicode.rst:345 +#: c-api/unicode.rst:340 msgid "" "This is the recommended way to allocate a new Unicode object. Objects " "created using this function are not resizable." msgstr "" -#: c-api/unicode.rst:354 +#: c-api/unicode.rst:343 +msgid "On error, set an exception and return ``NULL``." +msgstr "" + +#: c-api/unicode.rst:351 msgid "" -"Create a new Unicode object with the given *kind* (possible values are :c:" -"macro:`PyUnicode_1BYTE_KIND` etc., as returned by :c:func:" -"`PyUnicode_KIND`). The *buffer* must point to an array of *size* units of " -"1, 2 or 4 bytes per character, as given by the kind." +"Create a new Unicode object with the given *kind* (possible values " +"are :c:macro:`PyUnicode_1BYTE_KIND` etc., as returned " +"by :c:func:`PyUnicode_KIND`). The *buffer* must point to an array of *size* " +"units of 1, 2 or 4 bytes per character, as given by the kind." msgstr "" -#: c-api/unicode.rst:359 +#: c-api/unicode.rst:356 msgid "" "If necessary, the input *buffer* is copied and transformed into the " -"canonical representation. For example, if the *buffer* is a UCS4 string (:c:" -"macro:`PyUnicode_4BYTE_KIND`) and it consists only of codepoints in the UCS1 " -"range, it will be transformed into UCS1 (:c:macro:`PyUnicode_1BYTE_KIND`)." +"canonical representation. For example, if the *buffer* is a UCS4 string " +"(:c:macro:`PyUnicode_4BYTE_KIND`) and it consists only of codepoints in the " +"UCS1 range, it will be transformed into UCS1 " +"(:c:macro:`PyUnicode_1BYTE_KIND`)." msgstr "" -#: c-api/unicode.rst:370 +#: c-api/unicode.rst:367 msgid "" "Create a Unicode object from the char buffer *str*. The bytes will be " "interpreted as being UTF-8 encoded. The buffer is copied into the new " @@ -370,29 +371,29 @@ msgid "" "data is not allowed." msgstr "" -#: c-api/unicode.rst:376 +#: c-api/unicode.rst:373 msgid "This function raises :exc:`SystemError` when:" msgstr "" -#: c-api/unicode.rst:378 +#: c-api/unicode.rst:375 msgid "*size* < 0," msgstr "" -#: c-api/unicode.rst:379 +#: c-api/unicode.rst:376 msgid "*str* is ``NULL`` and *size* > 0" msgstr "" -#: c-api/unicode.rst:381 +#: c-api/unicode.rst:378 msgid "*str* == ``NULL`` with *size* > 0 is not allowed anymore." msgstr "" -#: c-api/unicode.rst:387 +#: c-api/unicode.rst:384 msgid "" "Create a Unicode object from a UTF-8 encoded null-terminated char buffer " "*str*." msgstr "" -#: c-api/unicode.rst:393 +#: c-api/unicode.rst:390 msgid "" "Take a C :c:func:`printf`\\ -style *format* string and a variable number of " "arguments, calculate the size of the resulting Python Unicode string and " @@ -401,31 +402,31 @@ msgid "" "*format* ASCII-encoded string." msgstr "" -#: c-api/unicode.rst:399 +#: c-api/unicode.rst:396 msgid "" "A conversion specifier contains two or more characters and has the following " "components, which must occur in this order:" msgstr "" -#: c-api/unicode.rst:402 +#: c-api/unicode.rst:399 msgid "The ``'%'`` character, which marks the start of the specifier." msgstr "" -#: c-api/unicode.rst:404 +#: c-api/unicode.rst:401 msgid "" "Conversion flags (optional), which affect the result of some conversion " "types." msgstr "" -#: c-api/unicode.rst:407 +#: c-api/unicode.rst:404 msgid "" "Minimum field width (optional). If specified as an ``'*'`` (asterisk), the " -"actual width is given in the next argument, which must be of type :c:expr:" -"`int`, and the object to convert comes after the minimum field width and " -"optional precision." +"actual width is given in the next argument, which must be of " +"type :c:expr:`int`, and the object to convert comes after the minimum field " +"width and optional precision." msgstr "" -#: c-api/unicode.rst:412 +#: c-api/unicode.rst:409 msgid "" "Precision (optional), given as a ``'.'`` (dot) followed by the precision. If " "specified as ``'*'`` (an asterisk), the actual precision is given in the " @@ -433,268 +434,268 @@ msgid "" "comes after the precision." msgstr "" -#: c-api/unicode.rst:417 +#: c-api/unicode.rst:414 msgid "Length modifier (optional)." msgstr "" -#: c-api/unicode.rst:419 +#: c-api/unicode.rst:416 msgid "Conversion type." msgstr "" -#: c-api/unicode.rst:421 +#: c-api/unicode.rst:418 msgid "The conversion flag characters are:" msgstr "" -#: c-api/unicode.rst:426 +#: c-api/unicode.rst:423 msgid "Flag" msgstr "" -#: c-api/unicode.rst:426 +#: c-api/unicode.rst:423 msgid "Meaning" msgstr "" -#: c-api/unicode.rst:428 +#: c-api/unicode.rst:425 msgid "``0``" msgstr "" -#: c-api/unicode.rst:428 +#: c-api/unicode.rst:425 msgid "The conversion will be zero padded for numeric values." msgstr "" -#: c-api/unicode.rst:430 +#: c-api/unicode.rst:427 msgid "``-``" msgstr "" -#: c-api/unicode.rst:430 +#: c-api/unicode.rst:427 msgid "" "The converted value is left adjusted (overrides the ``0`` flag if both are " "given)." msgstr "" -#: c-api/unicode.rst:434 +#: c-api/unicode.rst:431 msgid "" "The length modifiers for following integer conversions (``d``, ``i``, ``o``, " "``u``, ``x``, or ``X``) specify the type of the argument (:c:expr:`int` by " "default):" msgstr "" -#: c-api/unicode.rst:441 +#: c-api/unicode.rst:438 msgid "Modifier" msgstr "" -#: c-api/unicode.rst:441 +#: c-api/unicode.rst:438 msgid "Types" msgstr "" -#: c-api/unicode.rst:443 +#: c-api/unicode.rst:440 msgid "``l``" msgstr "" -#: c-api/unicode.rst:443 +#: c-api/unicode.rst:440 msgid ":c:expr:`long` or :c:expr:`unsigned long`" msgstr "" -#: c-api/unicode.rst:445 +#: c-api/unicode.rst:442 msgid "``ll``" msgstr "" -#: c-api/unicode.rst:445 +#: c-api/unicode.rst:442 msgid ":c:expr:`long long` or :c:expr:`unsigned long long`" msgstr "" -#: c-api/unicode.rst:447 +#: c-api/unicode.rst:444 msgid "``j``" msgstr "" -#: c-api/unicode.rst:447 +#: c-api/unicode.rst:444 msgid ":c:type:`intmax_t` or :c:type:`uintmax_t`" msgstr "" -#: c-api/unicode.rst:449 +#: c-api/unicode.rst:446 msgid "``z``" msgstr "" -#: c-api/unicode.rst:449 +#: c-api/unicode.rst:446 msgid ":c:type:`size_t` or :c:type:`ssize_t`" msgstr "" -#: c-api/unicode.rst:451 +#: c-api/unicode.rst:448 msgid "``t``" msgstr "" -#: c-api/unicode.rst:451 +#: c-api/unicode.rst:448 msgid ":c:type:`ptrdiff_t`" msgstr "" -#: c-api/unicode.rst:454 +#: c-api/unicode.rst:451 msgid "" "The length modifier ``l`` for following conversions ``s`` or ``V`` specify " "that the type of the argument is :c:expr:`const wchar_t*`." msgstr "" -#: c-api/unicode.rst:457 +#: c-api/unicode.rst:454 msgid "The conversion specifiers are:" msgstr "" -#: c-api/unicode.rst:463 +#: c-api/unicode.rst:460 msgid "Conversion Specifier" msgstr "" -#: c-api/unicode.rst:464 +#: c-api/unicode.rst:461 msgid "Type" msgstr "" -#: c-api/unicode.rst:465 +#: c-api/unicode.rst:462 msgid "Comment" msgstr "" -#: c-api/unicode.rst:467 +#: c-api/unicode.rst:464 msgid "``%``" msgstr "" -#: c-api/unicode.rst:468 +#: c-api/unicode.rst:465 msgid "*n/a*" msgstr "" -#: c-api/unicode.rst:469 +#: c-api/unicode.rst:466 msgid "The literal ``%`` character." msgstr "" -#: c-api/unicode.rst:471 +#: c-api/unicode.rst:468 msgid "``d``, ``i``" msgstr "" -#: c-api/unicode.rst:476 c-api/unicode.rst:484 c-api/unicode.rst:488 +#: c-api/unicode.rst:473 c-api/unicode.rst:481 c-api/unicode.rst:485 msgid "Specified by the length modifier" msgstr "" -#: c-api/unicode.rst:473 +#: c-api/unicode.rst:470 msgid "The decimal representation of a signed C integer." msgstr "" -#: c-api/unicode.rst:475 +#: c-api/unicode.rst:472 msgid "``u``" msgstr "" -#: c-api/unicode.rst:477 +#: c-api/unicode.rst:474 msgid "The decimal representation of an unsigned C integer." msgstr "" -#: c-api/unicode.rst:479 +#: c-api/unicode.rst:476 msgid "``o``" msgstr "" -#: c-api/unicode.rst:481 +#: c-api/unicode.rst:478 msgid "The octal representation of an unsigned C integer." msgstr "" -#: c-api/unicode.rst:483 +#: c-api/unicode.rst:480 msgid "``x``" msgstr "" -#: c-api/unicode.rst:485 +#: c-api/unicode.rst:482 msgid "The hexadecimal representation of an unsigned C integer (lowercase)." msgstr "" -#: c-api/unicode.rst:487 +#: c-api/unicode.rst:484 msgid "``X``" msgstr "" -#: c-api/unicode.rst:489 +#: c-api/unicode.rst:486 msgid "The hexadecimal representation of an unsigned C integer (uppercase)." msgstr "" -#: c-api/unicode.rst:491 +#: c-api/unicode.rst:488 msgid "``c``" msgstr "" -#: c-api/unicode.rst:492 +#: c-api/unicode.rst:489 msgid ":c:expr:`int`" msgstr "" -#: c-api/unicode.rst:493 +#: c-api/unicode.rst:490 msgid "A single character." msgstr "" -#: c-api/unicode.rst:495 +#: c-api/unicode.rst:492 msgid "``s``" msgstr "" -#: c-api/unicode.rst:496 +#: c-api/unicode.rst:493 msgid ":c:expr:`const char*` or :c:expr:`const wchar_t*`" msgstr "" -#: c-api/unicode.rst:497 +#: c-api/unicode.rst:494 msgid "A null-terminated C character array." msgstr "" -#: c-api/unicode.rst:499 +#: c-api/unicode.rst:496 msgid "``p``" msgstr "" -#: c-api/unicode.rst:500 +#: c-api/unicode.rst:497 msgid ":c:expr:`const void*`" msgstr "" -#: c-api/unicode.rst:501 +#: c-api/unicode.rst:498 msgid "" "The hex representation of a C pointer. Mostly equivalent to " "``printf(\"%p\")`` except that it is guaranteed to start with the literal " "``0x`` regardless of what the platform's ``printf`` yields." msgstr "" -#: c-api/unicode.rst:506 +#: c-api/unicode.rst:503 msgid "``A``" msgstr "" -#: c-api/unicode.rst:511 c-api/unicode.rst:525 +#: c-api/unicode.rst:508 c-api/unicode.rst:522 msgid ":c:expr:`PyObject*`" msgstr "" -#: c-api/unicode.rst:508 +#: c-api/unicode.rst:505 msgid "The result of calling :func:`ascii`." msgstr "" -#: c-api/unicode.rst:510 +#: c-api/unicode.rst:507 msgid "``U``" msgstr "" -#: c-api/unicode.rst:512 +#: c-api/unicode.rst:509 msgid "A Unicode object." msgstr "" -#: c-api/unicode.rst:514 +#: c-api/unicode.rst:511 msgid "``V``" msgstr "" -#: c-api/unicode.rst:515 +#: c-api/unicode.rst:512 msgid ":c:expr:`PyObject*`, :c:expr:`const char*` or :c:expr:`const wchar_t*`" msgstr "" -#: c-api/unicode.rst:516 +#: c-api/unicode.rst:513 msgid "" "A Unicode object (which may be ``NULL``) and a null-terminated C character " "array as a second parameter (which will be used, if the first parameter is " "``NULL``)." msgstr "" -#: c-api/unicode.rst:520 +#: c-api/unicode.rst:517 msgid "``S``" msgstr "" -#: c-api/unicode.rst:522 +#: c-api/unicode.rst:519 msgid "The result of calling :c:func:`PyObject_Str`." msgstr "" -#: c-api/unicode.rst:524 +#: c-api/unicode.rst:521 msgid "``R``" msgstr "" -#: c-api/unicode.rst:526 +#: c-api/unicode.rst:523 msgid "The result of calling :c:func:`PyObject_Repr`." msgstr "" -#: c-api/unicode.rst:529 +#: c-api/unicode.rst:526 msgid "" "The width formatter unit is number of characters rather than bytes. The " "precision formatter unit is number of bytes or :c:type:`wchar_t` items (if " @@ -704,28 +705,28 @@ msgid "" "``PyObject*`` argument is not ``NULL``)." msgstr "" -#: c-api/unicode.rst:537 +#: c-api/unicode.rst:534 msgid "" "Unlike to C :c:func:`printf` the ``0`` flag has effect even when a precision " "is given for integer conversions (``d``, ``i``, ``u``, ``o``, ``x``, or " "``X``)." msgstr "" -#: c-api/unicode.rst:541 +#: c-api/unicode.rst:538 msgid "Support for ``\"%lld\"`` and ``\"%llu\"`` added." msgstr "" -#: c-api/unicode.rst:544 +#: c-api/unicode.rst:541 msgid "Support for ``\"%li\"``, ``\"%lli\"`` and ``\"%zi\"`` added." msgstr "" -#: c-api/unicode.rst:547 +#: c-api/unicode.rst:544 msgid "" "Support width and precision formatter for ``\"%s\"``, ``\"%A\"``, " "``\"%U\"``, ``\"%V\"``, ``\"%S\"``, ``\"%R\"`` added." msgstr "" -#: c-api/unicode.rst:551 +#: c-api/unicode.rst:548 msgid "" "Support for conversion specifiers ``o`` and ``X``. Support for length " "modifiers ``j`` and ``t``. Length modifiers are now applied to all integer " @@ -734,36 +735,36 @@ msgid "" "flag ``-``." msgstr "" -#: c-api/unicode.rst:559 +#: c-api/unicode.rst:556 msgid "" "An unrecognized format character now sets a :exc:`SystemError`. In previous " "versions it caused all the rest of the format string to be copied as-is to " "the result string, and any extra arguments discarded." msgstr "" -#: c-api/unicode.rst:566 +#: c-api/unicode.rst:563 msgid "" "Identical to :c:func:`PyUnicode_FromFormat` except that it takes exactly two " "arguments." msgstr "" -#: c-api/unicode.rst:572 +#: c-api/unicode.rst:569 msgid "" "Copy an instance of a Unicode subtype to a new true Unicode object if " "necessary. If *obj* is already a true Unicode object (not a subtype), return " "a new :term:`strong reference` to the object." msgstr "" -#: c-api/unicode.rst:576 +#: c-api/unicode.rst:573 msgid "" "Objects other than Unicode or its subtypes will cause a :exc:`TypeError`." msgstr "" -#: c-api/unicode.rst:582 +#: c-api/unicode.rst:579 msgid "Decode an encoded object *obj* to a Unicode object." msgstr "" -#: c-api/unicode.rst:584 +#: c-api/unicode.rst:581 msgid "" ":class:`bytes`, :class:`bytearray` and other :term:`bytes-like objects " "` are decoded according to the given *encoding* and using " @@ -771,23 +772,27 @@ msgid "" "interface use the default values (see :ref:`builtincodecs` for details)." msgstr "" -#: c-api/unicode.rst:590 +#: c-api/unicode.rst:587 msgid "" "All other objects, including Unicode objects, cause a :exc:`TypeError` to be " "set." msgstr "" -#: c-api/unicode.rst:593 +#: c-api/unicode.rst:590 msgid "" "The API returns ``NULL`` if there was an error. The caller is responsible " "for decref'ing the returned objects." msgstr "" -#: c-api/unicode.rst:599 +#: c-api/unicode.rst:596 msgid "Return the length of the Unicode object, in code points." msgstr "" -#: c-api/unicode.rst:610 +#: c-api/unicode.rst:598 +msgid "On error, set an exception and return ``-1``." +msgstr "" + +#: c-api/unicode.rst:609 msgid "" "Copy characters from one Unicode object into another. This function " "performs character conversion when necessary and falls back to :c:func:`!" @@ -795,52 +800,61 @@ msgid "" "otherwise returns the number of copied characters." msgstr "" -#: c-api/unicode.rst:621 +#: c-api/unicode.rst:620 msgid "" -"Fill a string with a character: write *fill_char* into ``unicode[start:" -"start+length]``." +"Fill a string with a character: write *fill_char* into " +"``unicode[start:start+length]``." msgstr "" -#: c-api/unicode.rst:624 +#: c-api/unicode.rst:623 msgid "" "Fail if *fill_char* is bigger than the string maximum character, or if the " "string has more than 1 reference." msgstr "" -#: c-api/unicode.rst:627 +#: c-api/unicode.rst:626 msgid "" "Return the number of written character, or return ``-1`` and raise an " "exception on error." msgstr "" -#: c-api/unicode.rst:636 +#: c-api/unicode.rst:635 msgid "" -"Write a character to a string. The string must have been created through :c:" -"func:`PyUnicode_New`. Since Unicode strings are supposed to be immutable, " -"the string must not be shared, or have been hashed yet." +"Write a character to a string. The string must have been created " +"through :c:func:`PyUnicode_New`. Since Unicode strings are supposed to be " +"immutable, the string must not be shared, or have been hashed yet." msgstr "" -#: c-api/unicode.rst:640 +#: c-api/unicode.rst:639 msgid "" "This function checks that *unicode* is a Unicode object, that the index is " "not out of bounds, and that the object can be modified safely (i.e. that it " "its reference count is one)." msgstr "" -#: c-api/unicode.rst:649 +#: c-api/unicode.rst:643 +msgid "Return ``0`` on success, ``-1`` on error with an exception set." +msgstr "" + +#: c-api/unicode.rst:650 msgid "" "Read a character from a string. This function checks that *unicode* is a " -"Unicode object and the index is not out of bounds, in contrast to :c:func:" -"`PyUnicode_READ_CHAR`, which performs no error checking." +"Unicode object and the index is not out of bounds, in contrast " +"to :c:func:`PyUnicode_READ_CHAR`, which performs no error checking." +msgstr "" + +#: c-api/unicode.rst:654 +msgid "Return character on success, ``-1`` on error with an exception set." msgstr "" -#: c-api/unicode.rst:659 +#: c-api/unicode.rst:662 msgid "" "Return a substring of *unicode*, from character index *start* (included) to " -"character index *end* (excluded). Negative indices are not supported." +"character index *end* (excluded). Negative indices are not supported. On " +"error, set an exception and return ``NULL``." msgstr "" -#: c-api/unicode.rst:668 +#: c-api/unicode.rst:672 msgid "" "Copy the string *unicode* into a UCS4 buffer, including a null character, if " "*copy_null* is set. Returns ``NULL`` and sets an exception on error (in " @@ -848,25 +862,25 @@ msgid "" "*unicode*). *buffer* is returned on success." msgstr "" -#: c-api/unicode.rst:678 +#: c-api/unicode.rst:682 msgid "" -"Copy the string *unicode* into a new UCS4 buffer that is allocated using :c:" -"func:`PyMem_Malloc`. If this fails, ``NULL`` is returned with a :exc:" -"`MemoryError` set. The returned buffer always has an extra null code point " -"appended." +"Copy the string *unicode* into a new UCS4 buffer that is allocated " +"using :c:func:`PyMem_Malloc`. If this fails, ``NULL`` is returned with " +"a :exc:`MemoryError` set. The returned buffer always has an extra null code " +"point appended." msgstr "" -#: c-api/unicode.rst:687 +#: c-api/unicode.rst:691 msgid "Locale Encoding" msgstr "" -#: c-api/unicode.rst:689 +#: c-api/unicode.rst:693 msgid "" "The current locale encoding can be used to decode text from the operating " "system." msgstr "" -#: c-api/unicode.rst:696 +#: c-api/unicode.rst:700 msgid "" "Decode a string from UTF-8 on Android and VxWorks, or from the current " "locale encoding on other platforms. The supported error handlers are " @@ -875,157 +889,179 @@ msgid "" "null character but cannot contain embedded null characters." msgstr "" -#: c-api/unicode.rst:703 +#: c-api/unicode.rst:707 msgid "" -"Use :c:func:`PyUnicode_DecodeFSDefaultAndSize` to decode a string from the :" -"term:`filesystem encoding and error handler`." +"Use :c:func:`PyUnicode_DecodeFSDefaultAndSize` to decode a string from " +"the :term:`filesystem encoding and error handler`." msgstr "" -#: c-api/unicode.rst:741 +#: c-api/unicode.rst:745 msgid "This function ignores the :ref:`Python UTF-8 Mode `." msgstr "" -#: c-api/unicode.rst:807 +#: c-api/unicode.rst:830 msgid "The :c:func:`Py_DecodeLocale` function." msgstr "" -#: c-api/unicode.rst:714 +#: c-api/unicode.rst:718 msgid "" "The function now also uses the current locale encoding for the " -"``surrogateescape`` error handler, except on Android. Previously, :c:func:" -"`Py_DecodeLocale` was used for the ``surrogateescape``, and the current " -"locale encoding was used for ``strict``." +"``surrogateescape`` error handler, except on Android. " +"Previously, :c:func:`Py_DecodeLocale` was used for the ``surrogateescape``, " +"and the current locale encoding was used for ``strict``." msgstr "" -#: c-api/unicode.rst:723 +#: c-api/unicode.rst:727 msgid "" "Similar to :c:func:`PyUnicode_DecodeLocaleAndSize`, but compute the string " "length using :c:func:`!strlen`." msgstr "" -#: c-api/unicode.rst:731 +#: c-api/unicode.rst:735 msgid "" "Encode a Unicode object to UTF-8 on Android and VxWorks, or to the current " "locale encoding on other platforms. The supported error handlers are " "``\"strict\"`` and ``\"surrogateescape\"`` (:pep:`383`). The encoder uses " -"``\"strict\"`` error handler if *errors* is ``NULL``. Return a :class:" -"`bytes` object. *unicode* cannot contain embedded null characters." +"``\"strict\"`` error handler if *errors* is ``NULL``. Return " +"a :class:`bytes` object. *unicode* cannot contain embedded null characters." msgstr "" -#: c-api/unicode.rst:738 +#: c-api/unicode.rst:742 msgid "" -"Use :c:func:`PyUnicode_EncodeFSDefault` to encode a string to the :term:" -"`filesystem encoding and error handler`." +"Use :c:func:`PyUnicode_EncodeFSDefault` to encode a string to " +"the :term:`filesystem encoding and error handler`." msgstr "" -#: c-api/unicode.rst:838 +#: c-api/unicode.rst:861 msgid "The :c:func:`Py_EncodeLocale` function." msgstr "" -#: c-api/unicode.rst:749 +#: c-api/unicode.rst:753 msgid "" "The function now also uses the current locale encoding for the " -"``surrogateescape`` error handler, except on Android. Previously, :c:func:" -"`Py_EncodeLocale` was used for the ``surrogateescape``, and the current " -"locale encoding was used for ``strict``." +"``surrogateescape`` error handler, except on Android. " +"Previously, :c:func:`Py_EncodeLocale` was used for the ``surrogateescape``, " +"and the current locale encoding was used for ``strict``." msgstr "" -#: c-api/unicode.rst:758 +#: c-api/unicode.rst:762 msgid "File System Encoding" msgstr "" -#: c-api/unicode.rst:760 +#: c-api/unicode.rst:764 msgid "" "Functions encoding to and decoding from the :term:`filesystem encoding and " "error handler` (:pep:`383` and :pep:`529`)." msgstr "" -#: c-api/unicode.rst:763 +#: c-api/unicode.rst:767 msgid "" "To encode file names to :class:`bytes` during argument parsing, the " -"``\"O&\"`` converter should be used, passing :c:func:`PyUnicode_FSConverter` " -"as the conversion function:" +"``\"O&\"`` converter should be used, passing :c:func:`!" +"PyUnicode_FSConverter` as the conversion function:" msgstr "" -#: c-api/unicode.rst:769 +#: c-api/unicode.rst:773 msgid "" -"ParseTuple converter: encode :class:`str` objects -- obtained directly or " -"through the :class:`os.PathLike` interface -- to :class:`bytes` using :c:" -"func:`PyUnicode_EncodeFSDefault`; :class:`bytes` objects are output as-is. " -"*result* must be a :c:expr:`PyBytesObject*` which must be released when it " -"is no longer used." +":ref:`PyArg_Parse\\* converter `: encode :class:`str` objects " +"-- obtained directly or through the :class:`os.PathLike` interface -- " +"to :class:`bytes` using :c:func:`PyUnicode_EncodeFSDefault`; :class:`bytes` " +"objects are output as-is. *result* must be an address of a C variable of " +"type :c:expr:`PyObject*` (or :c:expr:`PyBytesObject*`). On success, set the " +"variable to a new :term:`strong reference` to a :ref:`bytes object " +"` which must be released when it is no longer used and return " +"a non-zero value (:c:macro:`Py_CLEANUP_SUPPORTED`). Embedded null bytes are " +"not allowed in the result. On failure, return ``0`` with an exception set." msgstr "" -#: c-api/unicode.rst:794 +#: c-api/unicode.rst:785 +msgid "" +"If *obj* is ``NULL``, the function releases a strong reference stored in the " +"variable referred by *result* and returns ``1``." +msgstr "" + +#: c-api/unicode.rst:817 msgid "Accepts a :term:`path-like object`." msgstr "" -#: c-api/unicode.rst:780 +#: c-api/unicode.rst:793 msgid "" "To decode file names to :class:`str` during argument parsing, the ``\"O&\"`` " -"converter should be used, passing :c:func:`PyUnicode_FSDecoder` as the " +"converter should be used, passing :c:func:`!PyUnicode_FSDecoder` as the " "conversion function:" msgstr "" -#: c-api/unicode.rst:786 +#: c-api/unicode.rst:799 +msgid "" +":ref:`PyArg_Parse\\* converter `: decode :class:`bytes` objects " +"-- obtained either directly or indirectly through the :class:`os.PathLike` " +"interface -- to :class:`str` " +"using :c:func:`PyUnicode_DecodeFSDefaultAndSize`; :class:`str` objects are " +"output as-is. *result* must be an address of a C variable of " +"type :c:expr:`PyObject*` (or :c:expr:`PyUnicodeObject*`). On success, set " +"the variable to a new :term:`strong reference` to a :ref:`Unicode object " +"` which must be released when it is no longer used and " +"return a non-zero value (:c:macro:`Py_CLEANUP_SUPPORTED`). Embedded null " +"characters are not allowed in the result. On failure, return ``0`` with an " +"exception set." +msgstr "" + +#: c-api/unicode.rst:812 msgid "" -"ParseTuple converter: decode :class:`bytes` objects -- obtained either " -"directly or indirectly through the :class:`os.PathLike` interface -- to :" -"class:`str` using :c:func:`PyUnicode_DecodeFSDefaultAndSize`; :class:`str` " -"objects are output as-is. *result* must be a :c:expr:`PyUnicodeObject*` " -"which must be released when it is no longer used." +"If *obj* is ``NULL``, release the strong reference to the object referred to " +"by *result* and return ``1``." msgstr "" -#: c-api/unicode.rst:800 +#: c-api/unicode.rst:823 msgid "Decode a string from the :term:`filesystem encoding and error handler`." msgstr "" -#: c-api/unicode.rst:802 +#: c-api/unicode.rst:825 msgid "" -"If you need to decode a string from the current locale encoding, use :c:func:" -"`PyUnicode_DecodeLocaleAndSize`." +"If you need to decode a string from the current locale encoding, " +"use :c:func:`PyUnicode_DecodeLocaleAndSize`." msgstr "" -#: c-api/unicode.rst:822 c-api/unicode.rst:842 +#: c-api/unicode.rst:845 c-api/unicode.rst:865 msgid "" "The :term:`filesystem error handler ` " "is now used." msgstr "" -#: c-api/unicode.rst:816 +#: c-api/unicode.rst:839 msgid "" "Decode a null-terminated string from the :term:`filesystem encoding and " "error handler`." msgstr "" -#: c-api/unicode.rst:819 +#: c-api/unicode.rst:842 msgid "" -"If the string length is known, use :c:func:" -"`PyUnicode_DecodeFSDefaultAndSize`." +"If the string length is known, " +"use :c:func:`PyUnicode_DecodeFSDefaultAndSize`." msgstr "" -#: c-api/unicode.rst:829 +#: c-api/unicode.rst:852 msgid "" "Encode a Unicode object to the :term:`filesystem encoding and error " "handler`, and return :class:`bytes`. Note that the resulting :class:`bytes` " "object can contain null bytes." msgstr "" -#: c-api/unicode.rst:833 +#: c-api/unicode.rst:856 msgid "" -"If you need to encode a string to the current locale encoding, use :c:func:" -"`PyUnicode_EncodeLocale`." +"If you need to encode a string to the current locale encoding, " +"use :c:func:`PyUnicode_EncodeLocale`." msgstr "" -#: c-api/unicode.rst:847 +#: c-api/unicode.rst:870 msgid "wchar_t Support" msgstr "" -#: c-api/unicode.rst:849 +#: c-api/unicode.rst:872 msgid ":c:type:`wchar_t` support for platforms which support it:" msgstr "" -#: c-api/unicode.rst:853 +#: c-api/unicode.rst:876 msgid "" "Create a Unicode object from the :c:type:`wchar_t` buffer *wstr* of the " "given *size*. Passing ``-1`` as the *size* indicates that the function must " @@ -1033,72 +1069,73 @@ msgid "" "failure." msgstr "" -#: c-api/unicode.rst:861 +#: c-api/unicode.rst:884 msgid "" "Copy the Unicode object contents into the :c:type:`wchar_t` buffer *wstr*. " "At most *size* :c:type:`wchar_t` characters are copied (excluding a possibly " -"trailing null termination character). Return the number of :c:type:" -"`wchar_t` characters copied or ``-1`` in case of an error." +"trailing null termination character). Return the number " +"of :c:type:`wchar_t` characters copied or ``-1`` in case of an error." msgstr "" -#: c-api/unicode.rst:866 +#: c-api/unicode.rst:889 msgid "" "When *wstr* is ``NULL``, instead return the *size* that would be required to " "store all of *unicode* including a terminating null." msgstr "" -#: c-api/unicode.rst:869 +#: c-api/unicode.rst:892 msgid "" "Note that the resulting :c:expr:`wchar_t*` string may or may not be null-" -"terminated. It is the responsibility of the caller to make sure that the :c:" -"expr:`wchar_t*` string is null-terminated in case this is required by the " -"application. Also, note that the :c:expr:`wchar_t*` string might contain " +"terminated. It is the responsibility of the caller to make sure that " +"the :c:expr:`wchar_t*` string is null-terminated in case this is required by " +"the application. Also, note that the :c:expr:`wchar_t*` string might contain " "null characters, which would cause the string to be truncated when used with " "most C functions." msgstr "" -#: c-api/unicode.rst:879 +#: c-api/unicode.rst:902 msgid "" "Convert the Unicode object to a wide character string. The output string " "always ends with a null character. If *size* is not ``NULL``, write the " "number of wide characters (excluding the trailing null termination " "character) into *\\*size*. Note that the resulting :c:type:`wchar_t` string " "might contain null characters, which would cause the string to be truncated " -"when used with most C functions. If *size* is ``NULL`` and the :c:expr:" -"`wchar_t*` string contains null characters a :exc:`ValueError` is raised." +"when used with most C functions. If *size* is ``NULL`` and " +"the :c:expr:`wchar_t*` string contains null characters a :exc:`ValueError` " +"is raised." msgstr "" -#: c-api/unicode.rst:887 +#: c-api/unicode.rst:910 msgid "" "Returns a buffer allocated by :c:macro:`PyMem_New` (use :c:func:`PyMem_Free` " "to free it) on success. On error, returns ``NULL`` and *\\*size* is " "undefined. Raises a :exc:`MemoryError` if memory allocation is failed." msgstr "" -#: c-api/unicode.rst:894 +#: c-api/unicode.rst:917 msgid "" "Raises a :exc:`ValueError` if *size* is ``NULL`` and the :c:expr:`wchar_t*` " "string contains null characters." msgstr "" -#: c-api/unicode.rst:902 +#: c-api/unicode.rst:925 msgid "Built-in Codecs" msgstr "" -#: c-api/unicode.rst:904 +#: c-api/unicode.rst:927 msgid "" "Python provides a set of built-in codecs which are written in C for speed. " "All of these codecs are directly usable via the following functions." msgstr "" -#: c-api/unicode.rst:907 +#: c-api/unicode.rst:930 msgid "" "Many of the following APIs take two arguments encoding and errors, and they " "have the same semantics as the ones of the built-in :func:`str` string " "object constructor." msgstr "" -#: c-api/unicode.rst:911 +#: c-api/unicode.rst:934 msgid "" "Setting encoding to ``NULL`` causes the default encoding to be used which is " "UTF-8. The file system calls should use :c:func:`PyUnicode_FSConverter` for " @@ -1106,28 +1143,28 @@ msgid "" "handler` internally." msgstr "" -#: c-api/unicode.rst:916 +#: c-api/unicode.rst:939 msgid "" "Error handling is set by errors which may also be set to ``NULL`` meaning to " "use the default handling defined for the codec. Default error handling for " "all built-in codecs is \"strict\" (:exc:`ValueError` is raised)." msgstr "" -#: c-api/unicode.rst:920 +#: c-api/unicode.rst:943 msgid "" "The codecs all use a similar interface. Only deviations from the following " "generic ones are documented for simplicity." msgstr "" -#: c-api/unicode.rst:925 +#: c-api/unicode.rst:948 msgid "Generic Codecs" msgstr "" -#: c-api/unicode.rst:927 +#: c-api/unicode.rst:950 msgid "These are the generic codec APIs:" msgstr "" -#: c-api/unicode.rst:933 +#: c-api/unicode.rst:956 msgid "" "Create a Unicode object by decoding *size* bytes of the encoded string " "*str*. *encoding* and *errors* have the same meaning as the parameters of " @@ -1136,7 +1173,7 @@ msgid "" "was raised by the codec." msgstr "" -#: c-api/unicode.rst:943 +#: c-api/unicode.rst:966 msgid "" "Encode a Unicode object and return the result as Python bytes object. " "*encoding* and *errors* have the same meaning as the parameters of the same " @@ -1145,21 +1182,21 @@ msgid "" "was raised by the codec." msgstr "" -#: c-api/unicode.rst:951 +#: c-api/unicode.rst:974 msgid "UTF-8 Codecs" msgstr "" -#: c-api/unicode.rst:953 +#: c-api/unicode.rst:976 msgid "These are the UTF-8 codec APIs:" msgstr "" -#: c-api/unicode.rst:958 +#: c-api/unicode.rst:981 msgid "" "Create a Unicode object by decoding *size* bytes of the UTF-8 encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: c-api/unicode.rst:965 +#: c-api/unicode.rst:988 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF8`. If " "*consumed* is not ``NULL``, trailing incomplete UTF-8 byte sequences will " @@ -1167,14 +1204,14 @@ msgid "" "of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: c-api/unicode.rst:973 +#: c-api/unicode.rst:996 msgid "" "Encode a Unicode object using UTF-8 and return the result as Python bytes " "object. Error handling is \"strict\". Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: c-api/unicode.rst:980 +#: c-api/unicode.rst:1003 msgid "" "Return a pointer to the UTF-8 encoding of the Unicode object, and store the " "size of the encoded representation (in bytes) in *size*. The *size* " @@ -1183,13 +1220,13 @@ msgid "" "regardless of whether there are any other null code points." msgstr "" -#: c-api/unicode.rst:986 +#: c-api/unicode.rst:1009 msgid "" "In the case of an error, ``NULL`` is returned with an exception set and no " "*size* is stored." msgstr "" -#: c-api/unicode.rst:989 +#: c-api/unicode.rst:1012 msgid "" "This caches the UTF-8 representation of the string in the Unicode object, " "and subsequent calls will return a pointer to the same buffer. The caller " @@ -1198,40 +1235,57 @@ msgid "" "collected." msgstr "" -#: c-api/unicode.rst:1009 +#: c-api/unicode.rst:1041 msgid "The return type is now ``const char *`` rather of ``char *``." msgstr "" -#: c-api/unicode.rst:999 +#: c-api/unicode.rst:1022 msgid "This function is a part of the :ref:`limited API `." msgstr "" -#: c-api/unicode.rst:1005 +#: c-api/unicode.rst:1028 msgid "As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size." msgstr "" -#: c-api/unicode.rst:1014 +#: c-api/unicode.rst:1032 +msgid "" +"This function does not have any special behavior for `null characters " +"`_ embedded within *unicode*. " +"As a result, strings containing null characters will remain in the returned " +"string, which some C functions might interpret as the end of the string, " +"leading to truncation. If truncation is an issue, it is recommended to " +"use :c:func:`PyUnicode_AsUTF8AndSize` instead." +msgstr "" + +#: c-api/unicode.rst:1046 msgid "UTF-32 Codecs" msgstr "" -#: c-api/unicode.rst:1016 +#: c-api/unicode.rst:1048 msgid "These are the UTF-32 codec APIs:" msgstr "" -#: c-api/unicode.rst:1022 +#: c-api/unicode.rst:1054 msgid "" "Decode *size* bytes from a UTF-32 encoded buffer string and return the " "corresponding Unicode object. *errors* (if non-``NULL``) defines the error " "handling. It defaults to \"strict\"." msgstr "" -#: c-api/unicode.rst:1076 +#: c-api/unicode.rst:1108 msgid "" "If *byteorder* is non-``NULL``, the decoder starts decoding using the given " "byte order::" msgstr "" -#: c-api/unicode.rst:1033 +#: c-api/unicode.rst:1111 +msgid "" +"*byteorder == -1: little endian\n" +"*byteorder == 0: native order\n" +"*byteorder == 1: big endian" +msgstr "" + +#: c-api/unicode.rst:1065 msgid "" "If ``*byteorder`` is zero, and the first four bytes of the input data are a " "byte order mark (BOM), the decoder switches to this byte order and the BOM " @@ -1239,21 +1293,21 @@ msgid "" "``-1`` or ``1``, any byte order mark is copied to the output." msgstr "" -#: c-api/unicode.rst:1038 +#: c-api/unicode.rst:1070 msgid "" "After completion, *\\*byteorder* is set to the current byte order at the end " "of input data." msgstr "" -#: c-api/unicode.rst:1092 +#: c-api/unicode.rst:1124 msgid "If *byteorder* is ``NULL``, the codec starts in native order mode." msgstr "" -#: c-api/unicode.rst:1094 +#: c-api/unicode.rst:1126 msgid "Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: c-api/unicode.rst:1049 +#: c-api/unicode.rst:1081 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF32`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeUTF32Stateful` will not " @@ -1262,29 +1316,29 @@ msgid "" "number of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: c-api/unicode.rst:1058 +#: c-api/unicode.rst:1090 msgid "" "Return a Python byte string using the UTF-32 encoding in native byte order. " "The string always starts with a BOM mark. Error handling is \"strict\". " "Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: c-api/unicode.rst:1064 +#: c-api/unicode.rst:1096 msgid "UTF-16 Codecs" msgstr "" -#: c-api/unicode.rst:1066 +#: c-api/unicode.rst:1098 msgid "These are the UTF-16 codec APIs:" msgstr "" -#: c-api/unicode.rst:1072 +#: c-api/unicode.rst:1104 msgid "" "Decode *size* bytes from a UTF-16 encoded buffer string and return the " "corresponding Unicode object. *errors* (if non-``NULL``) defines the error " "handling. It defaults to \"strict\"." msgstr "" -#: c-api/unicode.rst:1083 +#: c-api/unicode.rst:1115 msgid "" "If ``*byteorder`` is zero, and the first two bytes of the input data are a " "byte order mark (BOM), the decoder switches to this byte order and the BOM " @@ -1293,13 +1347,13 @@ msgid "" "result in either a ``\\ufeff`` or a ``\\ufffe`` character)." msgstr "" -#: c-api/unicode.rst:1089 +#: c-api/unicode.rst:1121 msgid "" "After completion, ``*byteorder`` is set to the current byte order at the end " "of input data." msgstr "" -#: c-api/unicode.rst:1100 +#: c-api/unicode.rst:1132 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF16`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeUTF16Stateful` will not " @@ -1309,28 +1363,28 @@ msgid "" "*consumed*." msgstr "" -#: c-api/unicode.rst:1109 +#: c-api/unicode.rst:1141 msgid "" "Return a Python byte string using the UTF-16 encoding in native byte order. " "The string always starts with a BOM mark. Error handling is \"strict\". " "Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: c-api/unicode.rst:1115 +#: c-api/unicode.rst:1147 msgid "UTF-7 Codecs" msgstr "" -#: c-api/unicode.rst:1117 +#: c-api/unicode.rst:1149 msgid "These are the UTF-7 codec APIs:" msgstr "" -#: c-api/unicode.rst:1122 +#: c-api/unicode.rst:1154 msgid "" "Create a Unicode object by decoding *size* bytes of the UTF-7 encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: c-api/unicode.rst:1129 +#: c-api/unicode.rst:1161 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeUTF7`. If " "*consumed* is not ``NULL``, trailing incomplete UTF-7 base-64 sections will " @@ -1338,101 +1392,101 @@ msgid "" "of bytes that have been decoded will be stored in *consumed*." msgstr "" -#: c-api/unicode.rst:1136 +#: c-api/unicode.rst:1168 msgid "Unicode-Escape Codecs" msgstr "" -#: c-api/unicode.rst:1138 +#: c-api/unicode.rst:1170 msgid "These are the \"Unicode Escape\" codec APIs:" msgstr "" -#: c-api/unicode.rst:1144 +#: c-api/unicode.rst:1176 msgid "" "Create a Unicode object by decoding *size* bytes of the Unicode-Escape " "encoded string *str*. Return ``NULL`` if an exception was raised by the " "codec." msgstr "" -#: c-api/unicode.rst:1150 +#: c-api/unicode.rst:1182 msgid "" "Encode a Unicode object using Unicode-Escape and return the result as a " "bytes object. Error handling is \"strict\". Return ``NULL`` if an " "exception was raised by the codec." msgstr "" -#: c-api/unicode.rst:1156 +#: c-api/unicode.rst:1188 msgid "Raw-Unicode-Escape Codecs" msgstr "" -#: c-api/unicode.rst:1158 +#: c-api/unicode.rst:1190 msgid "These are the \"Raw Unicode Escape\" codec APIs:" msgstr "" -#: c-api/unicode.rst:1164 +#: c-api/unicode.rst:1196 msgid "" "Create a Unicode object by decoding *size* bytes of the Raw-Unicode-Escape " "encoded string *str*. Return ``NULL`` if an exception was raised by the " "codec." msgstr "" -#: c-api/unicode.rst:1170 +#: c-api/unicode.rst:1202 msgid "" "Encode a Unicode object using Raw-Unicode-Escape and return the result as a " "bytes object. Error handling is \"strict\". Return ``NULL`` if an " "exception was raised by the codec." msgstr "" -#: c-api/unicode.rst:1176 +#: c-api/unicode.rst:1208 msgid "Latin-1 Codecs" msgstr "" -#: c-api/unicode.rst:1178 +#: c-api/unicode.rst:1210 msgid "" "These are the Latin-1 codec APIs: Latin-1 corresponds to the first 256 " "Unicode ordinals and only these are accepted by the codecs during encoding." msgstr "" -#: c-api/unicode.rst:1184 +#: c-api/unicode.rst:1216 msgid "" "Create a Unicode object by decoding *size* bytes of the Latin-1 encoded " "string *str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: c-api/unicode.rst:1190 +#: c-api/unicode.rst:1222 msgid "" "Encode a Unicode object using Latin-1 and return the result as Python bytes " "object. Error handling is \"strict\". Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: c-api/unicode.rst:1196 +#: c-api/unicode.rst:1228 msgid "ASCII Codecs" msgstr "" -#: c-api/unicode.rst:1198 +#: c-api/unicode.rst:1230 msgid "" "These are the ASCII codec APIs. Only 7-bit ASCII data is accepted. All " "other codes generate errors." msgstr "" -#: c-api/unicode.rst:1204 +#: c-api/unicode.rst:1236 msgid "" "Create a Unicode object by decoding *size* bytes of the ASCII encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: c-api/unicode.rst:1210 +#: c-api/unicode.rst:1242 msgid "" "Encode a Unicode object using ASCII and return the result as Python bytes " "object. Error handling is \"strict\". Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: c-api/unicode.rst:1216 +#: c-api/unicode.rst:1248 msgid "Character Map Codecs" msgstr "" -#: c-api/unicode.rst:1218 +#: c-api/unicode.rst:1250 msgid "" "This codec is special in that it can be used to implement many different " "codecs (and this is in fact what was done to obtain most of the standard " @@ -1442,18 +1496,18 @@ msgid "" "sequences work well." msgstr "" -#: c-api/unicode.rst:1224 +#: c-api/unicode.rst:1256 msgid "These are the mapping codec APIs:" msgstr "" -#: c-api/unicode.rst:1229 +#: c-api/unicode.rst:1261 msgid "" "Create a Unicode object by decoding *size* bytes of the encoded string *str* " "using the given *mapping* object. Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: c-api/unicode.rst:1233 +#: c-api/unicode.rst:1265 msgid "" "If *mapping* is ``NULL``, Latin-1 decoding will be applied. Else *mapping* " "must map bytes ordinals (integers in the range from 0 to 255) to Unicode " @@ -1463,14 +1517,14 @@ msgid "" "treated as undefined mappings and cause an error." msgstr "" -#: c-api/unicode.rst:1244 +#: c-api/unicode.rst:1276 msgid "" "Encode a Unicode object using the given *mapping* object and return the " "result as a bytes object. Error handling is \"strict\". Return ``NULL`` if " "an exception was raised by the codec." msgstr "" -#: c-api/unicode.rst:1248 +#: c-api/unicode.rst:1280 msgid "" "The *mapping* object must map Unicode ordinal integers to bytes objects, " "integers in the range from 0 to 255 or ``None``. Unmapped character " @@ -1478,41 +1532,41 @@ msgid "" "``None`` are treated as \"undefined mapping\" and cause an error." msgstr "" -#: c-api/unicode.rst:1254 +#: c-api/unicode.rst:1286 msgid "The following codec API is special in that maps Unicode to Unicode." msgstr "" -#: c-api/unicode.rst:1258 +#: c-api/unicode.rst:1290 msgid "" "Translate a string by applying a character mapping table to it and return " "the resulting Unicode object. Return ``NULL`` if an exception was raised by " "the codec." msgstr "" -#: c-api/unicode.rst:1262 +#: c-api/unicode.rst:1294 msgid "" "The mapping table must map Unicode ordinal integers to Unicode ordinal " "integers or ``None`` (causing deletion of the character)." msgstr "" -#: c-api/unicode.rst:1265 +#: c-api/unicode.rst:1297 msgid "" "Mapping tables need only provide the :meth:`~object.__getitem__` interface; " "dictionaries and sequences work well. Unmapped character ordinals (ones " "which cause a :exc:`LookupError`) are left untouched and are copied as-is." msgstr "" -#: c-api/unicode.rst:1269 +#: c-api/unicode.rst:1301 msgid "" "*errors* has the usual meaning for codecs. It may be ``NULL`` which " "indicates to use the default error handling." msgstr "" -#: c-api/unicode.rst:1274 +#: c-api/unicode.rst:1306 msgid "MBCS codecs for Windows" msgstr "" -#: c-api/unicode.rst:1276 +#: c-api/unicode.rst:1308 msgid "" "These are the MBCS codec APIs. They are currently only available on Windows " "and use the Win32 MBCS converters to implement the conversions. Note that " @@ -1520,13 +1574,13 @@ msgid "" "is defined by the user settings on the machine running the codec." msgstr "" -#: c-api/unicode.rst:1283 +#: c-api/unicode.rst:1315 msgid "" "Create a Unicode object by decoding *size* bytes of the MBCS encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" -#: c-api/unicode.rst:1290 +#: c-api/unicode.rst:1322 msgid "" "If *consumed* is ``NULL``, behave like :c:func:`PyUnicode_DecodeMBCS`. If " "*consumed* is not ``NULL``, :c:func:`PyUnicode_DecodeMBCSStateful` will not " @@ -1534,44 +1588,50 @@ msgid "" "will be stored in *consumed*." msgstr "" -#: c-api/unicode.rst:1298 +#: c-api/unicode.rst:1331 +msgid "" +"Similar to :c:func:`PyUnicode_DecodeMBCSStateful`, except uses the code page " +"specified by *code_page*." +msgstr "" + +#: c-api/unicode.rst:1337 msgid "" "Encode a Unicode object using MBCS and return the result as Python bytes " "object. Error handling is \"strict\". Return ``NULL`` if an exception was " "raised by the codec." msgstr "" -#: c-api/unicode.rst:1305 +#: c-api/unicode.rst:1344 msgid "" "Encode the Unicode object using the specified code page and return a Python " -"bytes object. Return ``NULL`` if an exception was raised by the codec. Use :" -"c:macro:`!CP_ACP` code page to get the MBCS encoder." +"bytes object. Return ``NULL`` if an exception was raised by the codec. " +"Use :c:macro:`!CP_ACP` code page to get the MBCS encoder." msgstr "" -#: c-api/unicode.rst:1313 +#: c-api/unicode.rst:1352 msgid "Methods & Slots" msgstr "" -#: c-api/unicode.rst:1319 +#: c-api/unicode.rst:1358 msgid "Methods and Slot Functions" msgstr "" -#: c-api/unicode.rst:1321 +#: c-api/unicode.rst:1360 msgid "" "The following APIs are capable of handling Unicode objects and strings on " "input (we refer to them as strings in the descriptions) and return Unicode " "objects or integers as appropriate." msgstr "" -#: c-api/unicode.rst:1325 +#: c-api/unicode.rst:1364 msgid "They all return ``NULL`` or ``-1`` if an exception occurs." msgstr "" -#: c-api/unicode.rst:1330 +#: c-api/unicode.rst:1369 msgid "Concat two strings giving a new Unicode string." msgstr "" -#: c-api/unicode.rst:1335 +#: c-api/unicode.rst:1374 msgid "" "Split a string giving a list of Unicode strings. If *sep* is ``NULL``, " "splitting will be done at all whitespace substrings. Otherwise, splits " @@ -1580,27 +1640,27 @@ msgid "" "list." msgstr "" -#: c-api/unicode.rst:1343 +#: c-api/unicode.rst:1382 msgid "" "Split a Unicode string at line breaks, returning a list of Unicode strings. " "CRLF is considered to be one line break. If *keepends* is ``0``, the Line " "break characters are not included in the resulting strings." msgstr "" -#: c-api/unicode.rst:1350 +#: c-api/unicode.rst:1389 msgid "" "Join a sequence of strings using the given *separator* and return the " "resulting Unicode string." msgstr "" -#: c-api/unicode.rst:1357 +#: c-api/unicode.rst:1396 msgid "" "Return ``1`` if *substr* matches ``unicode[start:end]`` at the given tail " "end (*direction* == ``-1`` means to do a prefix match, *direction* == ``1`` " "a suffix match), ``0`` otherwise. Return ``-1`` if an error occurred." msgstr "" -#: c-api/unicode.rst:1365 +#: c-api/unicode.rst:1404 msgid "" "Return the first position of *substr* in ``unicode[start:end]`` using the " "given *direction* (*direction* == ``1`` means to do a forward search, " @@ -1609,7 +1669,7 @@ msgid "" "``-2`` indicates that an error occurred and an exception has been set." msgstr "" -#: c-api/unicode.rst:1375 +#: c-api/unicode.rst:1414 msgid "" "Return the first position of the character *ch* in ``unicode[start:end]`` " "using the given *direction* (*direction* == ``1`` means to do a forward " @@ -1619,37 +1679,37 @@ msgid "" "set." msgstr "" -#: c-api/unicode.rst:1383 +#: c-api/unicode.rst:1422 msgid "" "*start* and *end* are now adjusted to behave like ``unicode[start:end]``." msgstr "" -#: c-api/unicode.rst:1390 +#: c-api/unicode.rst:1429 msgid "" "Return the number of non-overlapping occurrences of *substr* in " "``unicode[start:end]``. Return ``-1`` if an error occurred." msgstr "" -#: c-api/unicode.rst:1397 +#: c-api/unicode.rst:1436 msgid "" "Replace at most *maxcount* occurrences of *substr* in *unicode* with " "*replstr* and return the resulting Unicode object. *maxcount* == ``-1`` " "means replace all occurrences." msgstr "" -#: c-api/unicode.rst:1404 +#: c-api/unicode.rst:1443 msgid "" "Compare two strings and return ``-1``, ``0``, ``1`` for less than, equal, " "and greater than, respectively." msgstr "" -#: c-api/unicode.rst:1407 +#: c-api/unicode.rst:1446 msgid "" -"This function returns ``-1`` upon failure, so one should call :c:func:" -"`PyErr_Occurred` to check for errors." +"This function returns ``-1`` upon failure, so one should " +"call :c:func:`PyErr_Occurred` to check for errors." msgstr "" -#: c-api/unicode.rst:1413 +#: c-api/unicode.rst:1452 msgid "" "Compare a Unicode object, *unicode*, with *string* and return ``-1``, ``0``, " "``1`` for less than, equal, and greater than, respectively. It is best to " @@ -1657,68 +1717,108 @@ msgid "" "string as ISO-8859-1 if it contains non-ASCII characters." msgstr "" -#: c-api/unicode.rst:1418 +#: c-api/unicode.rst:1457 msgid "This function does not raise exceptions." msgstr "" -#: c-api/unicode.rst:1423 +#: c-api/unicode.rst:1462 msgid "Rich compare two Unicode strings and return one of the following:" msgstr "" -#: c-api/unicode.rst:1425 +#: c-api/unicode.rst:1464 msgid "``NULL`` in case an exception was raised" msgstr "" -#: c-api/unicode.rst:1426 +#: c-api/unicode.rst:1465 msgid ":c:data:`Py_True` or :c:data:`Py_False` for successful comparisons" msgstr "" -#: c-api/unicode.rst:1427 +#: c-api/unicode.rst:1466 msgid ":c:data:`Py_NotImplemented` in case the type combination is unknown" msgstr "" -#: c-api/unicode.rst:1429 +#: c-api/unicode.rst:1468 msgid "" -"Possible values for *op* are :c:macro:`Py_GT`, :c:macro:`Py_GE`, :c:macro:" -"`Py_EQ`, :c:macro:`Py_NE`, :c:macro:`Py_LT`, and :c:macro:`Py_LE`." +"Possible values for *op* " +"are :c:macro:`Py_GT`, :c:macro:`Py_GE`, :c:macro:`Py_EQ`, :c:macro:`Py_NE`, :c:macro:`Py_LT`, " +"and :c:macro:`Py_LE`." msgstr "" -#: c-api/unicode.rst:1435 +#: c-api/unicode.rst:1474 msgid "" "Return a new string object from *format* and *args*; this is analogous to " "``format % args``." msgstr "" -#: c-api/unicode.rst:1441 +#: c-api/unicode.rst:1480 msgid "" "Check whether *substr* is contained in *unicode* and return true or false " "accordingly." msgstr "" -#: c-api/unicode.rst:1444 +#: c-api/unicode.rst:1483 msgid "" "*substr* has to coerce to a one element Unicode string. ``-1`` is returned " "if there was an error." msgstr "" -#: c-api/unicode.rst:1450 +#: c-api/unicode.rst:1489 msgid "" "Intern the argument :c:expr:`*p_unicode` in place. The argument must be the " "address of a pointer variable pointing to a Python Unicode string object. " -"If there is an existing interned string that is the same as :c:expr:" -"`*p_unicode`, it sets :c:expr:`*p_unicode` to it (releasing the reference to " -"the old string object and creating a new :term:`strong reference` to the " -"interned string object), otherwise it leaves :c:expr:`*p_unicode` alone and " -"interns it (creating a new :term:`strong reference`). (Clarification: even " -"though there is a lot of talk about references, think of this function as " -"reference-neutral; you own the object after the call if and only if you " -"owned it before the call.)" -msgstr "" - -#: c-api/unicode.rst:1463 -msgid "" -"A combination of :c:func:`PyUnicode_FromString` and :c:func:" -"`PyUnicode_InternInPlace`, returning either a new Unicode string object that " -"has been interned, or a new (\"owned\") reference to an earlier interned " -"string object with the same value." +"If there is an existing interned string that is the same " +"as :c:expr:`*p_unicode`, it sets :c:expr:`*p_unicode` to it (releasing the " +"reference to the old string object and creating a new :term:`strong " +"reference` to the interned string object), otherwise it " +"leaves :c:expr:`*p_unicode` alone and interns it." +msgstr "" + +#: c-api/unicode.rst:1496 +msgid "" +"(Clarification: even though there is a lot of talk about references, think " +"of this function as reference-neutral. You must own the object you pass in; " +"after the call you no longer own the passed-in reference, but you newly own " +"the result.)" +msgstr "" + +#: c-api/unicode.rst:1501 +msgid "" +"This function never raises an exception. On error, it leaves its argument " +"unchanged without interning it." +msgstr "" + +#: c-api/unicode.rst:1504 +msgid "" +"Instances of subclasses of :py:class:`str` may not be interned, that " +"is, :c:expr:`PyUnicode_CheckExact(*p_unicode)` must be true. If it is not, " +"then -- as with any other error -- the argument is left unchanged." +msgstr "" + +#: c-api/unicode.rst:1508 +msgid "" +"Note that interned strings are not “immortal”. You must keep a reference to " +"the result to benefit from interning." +msgstr "" + +#: c-api/unicode.rst:1514 +msgid "" +"A combination of :c:func:`PyUnicode_FromString` " +"and :c:func:`PyUnicode_InternInPlace`, meant for statically allocated " +"strings." +msgstr "" + +#: c-api/unicode.rst:1517 +msgid "" +"Return a new (\"owned\") reference to either a new Unicode string object " +"that has been interned, or an earlier interned string object with the same " +"value." +msgstr "" + +#: c-api/unicode.rst:1521 +msgid "" +"Python may keep a reference to the result, or prevent it from being garbage-" +"collected promptly. For interning an unbounded number of different strings, " +"such as ones coming from user input, prefer " +"calling :c:func:`PyUnicode_FromString` and :c:func:`PyUnicode_InternInPlace` " +"directly." msgstr "" diff --git a/c-api/utilities.po b/c-api/utilities.po index 55c390ee..3c2c8834 100644 --- a/c-api/utilities.po +++ b/c-api/utilities.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/c-api/veryhigh.po b/c-api/veryhigh.po index f14b5372..ff58e9e4 100644 --- a/c-api/veryhigh.po +++ b/c-api/veryhigh.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -30,16 +31,17 @@ msgstr "" #: c-api/veryhigh.rst:14 msgid "" "Several of these functions accept a start symbol from the grammar as a " -"parameter. The available start symbols are :c:data:`Py_eval_input`, :c:data:" -"`Py_file_input`, and :c:data:`Py_single_input`. These are described " -"following the functions which accept them as parameters." +"parameter. The available start symbols " +"are :c:data:`Py_eval_input`, :c:data:`Py_file_input`, " +"and :c:data:`Py_single_input`. These are described following the functions " +"which accept them as parameters." msgstr "" #: c-api/veryhigh.rst:19 msgid "" "Note also that several of these functions take :c:expr:`FILE*` parameters. " -"One particular issue which needs to be handled carefully is that the :c:type:" -"`FILE` structure for different C libraries can be different and " +"One particular issue which needs to be handled carefully is that " +"the :c:type:`FILE` structure for different C libraries can be different and " "incompatible. Under Windows (at least), it is possible for dynamically " "linked extensions to actually use different libraries, so care should be " "taken that :c:expr:`FILE*` parameters are only passed to these functions if " @@ -63,8 +65,8 @@ msgstr "" #: c-api/veryhigh.rst:40 msgid "" "Note that if an otherwise unhandled :exc:`SystemExit` is raised, this " -"function will not return ``1``, but exit the process, as long as :c:member:" -"`PyConfig.inspect` is zero." +"function will not return ``1``, but exit the process, as long " +"as :c:member:`PyConfig.inspect` is zero." msgstr "" #: c-api/veryhigh.rst:47 @@ -92,12 +94,12 @@ msgstr "" #: c-api/veryhigh.rst:72 msgid "" "If *fp* refers to a file associated with an interactive device (console or " -"terminal input or Unix pseudo-terminal), return the value of :c:func:" -"`PyRun_InteractiveLoop`, otherwise return the result of :c:func:" -"`PyRun_SimpleFile`. *filename* is decoded from the filesystem encoding (:" -"func:`sys.getfilesystemencoding`). If *filename* is ``NULL``, this function " -"uses ``\"???\"`` as the filename. If *closeit* is true, the file is closed " -"before ``PyRun_SimpleFileExFlags()`` returns." +"terminal input or Unix pseudo-terminal), return the value " +"of :c:func:`PyRun_InteractiveLoop`, otherwise return the result " +"of :c:func:`PyRun_SimpleFile`. *filename* is decoded from the filesystem " +"encoding (:func:`sys.getfilesystemencoding`). If *filename* is ``NULL``, " +"this function uses ``\"???\"`` as the filename. If *closeit* is true, the " +"file is closed before ``PyRun_SimpleFileExFlags()`` returns." msgstr "" #: c-api/veryhigh.rst:84 @@ -118,8 +120,8 @@ msgstr "" #: c-api/veryhigh.rst:96 msgid "" "Note that if an otherwise unhandled :exc:`SystemExit` is raised, this " -"function will not return ``-1``, but exit the process, as long as :c:member:" -"`PyConfig.inspect` is zero." +"function will not return ``-1``, but exit the process, as long " +"as :c:member:`PyConfig.inspect` is zero." msgstr "" #: c-api/veryhigh.rst:103 @@ -160,17 +162,17 @@ msgstr "" msgid "" "Read and execute a single statement from a file associated with an " "interactive device according to the *flags* argument. The user will be " -"prompted using ``sys.ps1`` and ``sys.ps2``. *filename* is decoded from the :" -"term:`filesystem encoding and error handler`." +"prompted using ``sys.ps1`` and ``sys.ps2``. *filename* is decoded from " +"the :term:`filesystem encoding and error handler`." msgstr "" #: c-api/veryhigh.rst:139 msgid "" "Returns ``0`` when the input was executed successfully, ``-1`` if there was " "an exception, or an error code from the :file:`errcode.h` include file " -"distributed as part of Python if there was a parse error. (Note that :file:" -"`errcode.h` is not included by :file:`Python.h`, so must be included " -"specifically if needed.)" +"distributed as part of Python if there was a parse error. (Note " +"that :file:`errcode.h` is not included by :file:`Python.h`, so must be " +"included specifically if needed.)" msgstr "" #: c-api/veryhigh.rst:148 @@ -216,15 +218,15 @@ msgstr "" #: c-api/veryhigh.rst:186 msgid "" -"The result must be a string allocated by :c:func:`PyMem_RawMalloc` or :c:" -"func:`PyMem_RawRealloc`, or ``NULL`` if an error occurred." +"The result must be a string allocated by :c:func:`PyMem_RawMalloc` " +"or :c:func:`PyMem_RawRealloc`, or ``NULL`` if an error occurred." msgstr "" #: c-api/veryhigh.rst:189 msgid "" -"The result must be allocated by :c:func:`PyMem_RawMalloc` or :c:func:" -"`PyMem_RawRealloc`, instead of being allocated by :c:func:`PyMem_Malloc` or :" -"c:func:`PyMem_Realloc`." +"The result must be allocated by :c:func:`PyMem_RawMalloc` " +"or :c:func:`PyMem_RawRealloc`, instead of being allocated " +"by :c:func:`PyMem_Malloc` or :c:func:`PyMem_Realloc`." msgstr "" #: c-api/veryhigh.rst:200 @@ -271,8 +273,8 @@ msgid "" "Similar to :c:func:`PyRun_StringFlags`, but the Python source code is read " "from *fp* instead of an in-memory string. *filename* should be the name of " "the file, it is decoded from the :term:`filesystem encoding and error " -"handler`. If *closeit* is true, the file is closed before :c:func:" -"`PyRun_FileExFlags` returns." +"handler`. If *closeit* is true, the file is closed " +"before :c:func:`PyRun_FileExFlags` returns." msgstr "" #: c-api/veryhigh.rst:245 @@ -291,11 +293,12 @@ msgstr "" msgid "" "Parse and compile the Python source code in *str*, returning the resulting " "code object. The start token is given by *start*; this can be used to " -"constrain the code which can be compiled and should be :c:data:" -"`Py_eval_input`, :c:data:`Py_file_input`, or :c:data:`Py_single_input`. The " -"filename specified by *filename* is used to construct the code object and " -"may appear in tracebacks or :exc:`SyntaxError` exception messages. This " -"returns ``NULL`` if the code cannot be parsed or compiled." +"constrain the code which can be compiled and should " +"be :c:data:`Py_eval_input`, :c:data:`Py_file_input`, " +"or :c:data:`Py_single_input`. The filename specified by *filename* is used " +"to construct the code object and may appear in tracebacks " +"or :exc:`SyntaxError` exception messages. This returns ``NULL`` if the code " +"cannot be parsed or compiled." msgstr "" #: c-api/veryhigh.rst:265 @@ -331,8 +334,8 @@ msgstr "" #: c-api/veryhigh.rst:299 msgid "" -"Evaluate an execution frame. This is a simplified interface to :c:func:" -"`PyEval_EvalFrameEx`, for backward compatibility." +"Evaluate an execution frame. This is a simplified interface " +"to :c:func:`PyEval_EvalFrameEx`, for backward compatibility." msgstr "" #: c-api/veryhigh.rst:305 @@ -387,9 +390,9 @@ msgstr "" #: c-api/veryhigh.rst:356 msgid "" -"Whenever ``PyCompilerFlags *flags`` is ``NULL``, :c:member:`~PyCompilerFlags." -"cf_flags` is treated as equal to ``0``, and any modification due to ``from " -"__future__ import`` is discarded." +"Whenever ``PyCompilerFlags *flags`` is " +"``NULL``, :c:member:`~PyCompilerFlags.cf_flags` is treated as equal to " +"``0``, and any modification due to ``from __future__ import`` is discarded." msgstr "" #: c-api/veryhigh.rst:362 diff --git a/c-api/weakref.po b/c-api/weakref.po index 8abdd378..7f8ed017 100644 --- a/c-api/weakref.po +++ b/c-api/weakref.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -51,7 +52,7 @@ msgid "" "a callable object that receives notification when *ob* is garbage collected; " "it should accept a single parameter, which will be the weak reference object " "itself. *callback* may also be ``None`` or ``NULL``. If *ob* is not a " -"weakly referencable object, or if *callback* is not callable, ``None``, or " +"weakly referenceable object, or if *callback* is not callable, ``None``, or " "``NULL``, this will return ``NULL`` and raise :exc:`TypeError`." msgstr "" @@ -63,7 +64,7 @@ msgid "" "can be a callable object that receives notification when *ob* is garbage " "collected; it should accept a single parameter, which will be the weak " "reference object itself. *callback* may also be ``None`` or ``NULL``. If " -"*ob* is not a weakly referencable object, or if *callback* is not callable, " +"*ob* is not a weakly referenceable object, or if *callback* is not callable, " "``None``, or ``NULL``, this will return ``NULL`` and raise :exc:`TypeError`." msgstr "" diff --git a/contents.po b/contents.po index 17db577e..96201696 100644 --- a/contents.po +++ b/contents.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-04-24 22:37+0300\n" "Last-Translator: Panagiotis Skias \n" "Language-Team: PyGreece \n" diff --git a/copyright.po b/copyright.po index 423285ff..fa7b8dec 100644 --- a/copyright.po +++ b/copyright.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-04-24 22:33+0300\n" "Last-Translator: Panagiotis Skias \n" "Language-Team: PyGreece \n" diff --git a/cpython b/cpython index 9cbde7c6..02741155 160000 --- a/cpython +++ b/cpython @@ -1 +1 @@ -Subproject commit 9cbde7c6ce6f7b93301a37f03dfa0c0d45e00a39 +Subproject commit 0274115585db8e26d9d1c0218fe65e5041c70f2c diff --git a/deprecations/c-api-pending-removal-in-3.14.po b/deprecations/c-api-pending-removal-in-3.14.po new file mode 100644 index 00000000..a2a5ee22 --- /dev/null +++ b/deprecations/c-api-pending-removal-in-3.14.po @@ -0,0 +1,178 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: deprecations/c-api-pending-removal-in-3.14.rst:2 +msgid "Pending Removal in Python 3.14" +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:4 +msgid "" +"The ``ma_version_tag`` field in :c:type:`PyDictObject` for extension modules " +"(:pep:`699`; :gh:`101193`)." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:7 +msgid "" +"Creating :c:data:`immutable types ` with mutable " +"bases (:gh:`95388`)." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:10 +msgid "" +"Functions to configure Python's initialization, deprecated in Python 3.11:" +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:12 +msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:14 +msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:16 +msgid "" +":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:18 +msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:21 +#: deprecations/c-api-pending-removal-in-3.14.rst:71 +msgid "" +"The :c:func:`Py_InitializeFromConfig` API should be used " +"with :c:type:`PyConfig` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:24 +msgid "Global configuration variables:" +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:26 +msgid ":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:28 +msgid ":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:30 +msgid ":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:32 +msgid "" +":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:34 +msgid ":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:36 +msgid "" +":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:38 +msgid ":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:40 +msgid "" +":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:42 +msgid "" +":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:44 +msgid "" +":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:46 +msgid "" +":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:48 +msgid "" +":c:var:`Py_NoUserSiteDirectory`: " +"Use :c:member:`PyConfig.user_site_directory` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:50 +msgid "" +":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:52 +msgid "" +":c:var:`Py_HashRandomizationFlag`: Use :c:member:`PyConfig.use_hash_seed` " +"and :c:member:`PyConfig.hash_seed` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:55 +msgid ":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:57 +msgid "" +":c:var:`Py_LegacyWindowsFSEncodingFlag`: " +"Use :c:member:`PyPreConfig.legacy_windows_fs_encoding` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:59 +msgid "" +":c:var:`Py_LegacyWindowsStdioFlag`: " +"Use :c:member:`PyConfig.legacy_windows_stdio` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:61 +msgid "" +":c:var:`!Py_FileSystemDefaultEncoding`: " +"Use :c:member:`PyConfig.filesystem_encoding` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:63 +msgid "" +":c:var:`!Py_HasFileSystemDefaultEncoding`: " +"Use :c:member:`PyConfig.filesystem_encoding` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:65 +msgid "" +":c:var:`!Py_FileSystemDefaultEncodeErrors`: " +"Use :c:member:`PyConfig.filesystem_errors` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:67 +msgid "" +":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` instead. " +"(see :c:func:`Py_PreInitialize`)" +msgstr "" diff --git a/deprecations/c-api-pending-removal-in-3.15.po b/deprecations/c-api-pending-removal-in-3.15.po new file mode 100644 index 00000000..1c771afa --- /dev/null +++ b/deprecations/c-api-pending-removal-in-3.15.po @@ -0,0 +1,79 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: deprecations/c-api-pending-removal-in-3.15.rst:2 +msgid "Pending Removal in Python 3.15" +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:4 +msgid "The bundled copy of ``libmpdecimal``." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:5 +msgid "" +"The :c:func:`PyImport_ImportModuleNoBlock`: " +"Use :c:func:`PyImport_ImportModule` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:7 +msgid "" +":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: " +"Use :c:func:`!PyWeakref_GetRef` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:9 +msgid "" +":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: " +"Use :c:type:`wchar_t` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:11 +msgid "Python initialization functions:" +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:13 +msgid "" +":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" +"warnings.filters` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:15 +msgid ":c:func:`Py_GetExecPrefix`: Get :data:`sys.exec_prefix` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:17 +msgid ":c:func:`Py_GetPath`: Get :data:`sys.path` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:19 +msgid ":c:func:`Py_GetPrefix`: Get :data:`sys.prefix` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:21 +msgid ":c:func:`Py_GetProgramFullPath`: Get :data:`sys.executable` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:23 +msgid ":c:func:`Py_GetProgramName`: Get :data:`sys.executable` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:25 +msgid "" +":c:func:`Py_GetPythonHome`: Get :c:member:`PyConfig.home` or " +"the :envvar:`PYTHONHOME` environment variable instead." +msgstr "" diff --git a/deprecations/c-api-pending-removal-in-future.po b/deprecations/c-api-pending-removal-in-future.po new file mode 100644 index 00000000..f4c18ac3 --- /dev/null +++ b/deprecations/c-api-pending-removal-in-future.po @@ -0,0 +1,139 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: deprecations/c-api-pending-removal-in-future.rst:2 +msgid "Pending Removal in Future Versions" +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:4 +msgid "" +"The following APIs are deprecated and will be removed, although there is " +"currently no date scheduled for their removal." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:7 +msgid ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: Unneeded since Python 3.8." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:9 +msgid ":c:func:`PyErr_Fetch`: Use :c:func:`PyErr_GetRaisedException` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:11 +msgid "" +":c:func:`PyErr_NormalizeException`: Use :c:func:`PyErr_GetRaisedException` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:13 +msgid "" +":c:func:`PyErr_Restore`: Use :c:func:`PyErr_SetRaisedException` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:15 +msgid "" +":c:func:`PyModule_GetFilename`: Use :c:func:`PyModule_GetFilenameObject` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:17 +msgid ":c:func:`PyOS_AfterFork`: Use :c:func:`PyOS_AfterFork_Child` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:19 +msgid "" +":c:func:`PySlice_GetIndicesEx`: Use :c:func:`PySlice_Unpack` " +"and :c:func:`PySlice_AdjustIndices` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:21 +msgid "" +":c:func:`!PyUnicode_AsDecodedObject`: Use :c:func:`PyCodec_Decode` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:23 +msgid "" +":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:25 +msgid "" +":c:func:`!PyUnicode_AsEncodedObject`: Use :c:func:`PyCodec_Encode` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:27 +msgid "" +":c:func:`!PyUnicode_AsEncodedUnicode`: Use :c:func:`PyCodec_Encode` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:29 +msgid ":c:func:`PyUnicode_READY`: Unneeded since Python 3.12" +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:31 +msgid ":c:func:`!PyErr_Display`: Use :c:func:`PyErr_DisplayException` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:33 +msgid "" +":c:func:`!_PyErr_ChainExceptions`: Use :c:func:`!_PyErr_ChainExceptions1` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:35 +msgid "" +":c:member:`!PyBytesObject.ob_shash` member: call :c:func:`PyObject_Hash` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:37 +msgid ":c:member:`!PyDictObject.ma_version_tag` member." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:38 +msgid "Thread Local Storage (TLS) API:" +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:40 +msgid "" +":c:func:`PyThread_create_key`: Use :c:func:`PyThread_tss_alloc` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:42 +msgid ":c:func:`PyThread_delete_key`: Use :c:func:`PyThread_tss_free` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:44 +msgid "" +":c:func:`PyThread_set_key_value`: Use :c:func:`PyThread_tss_set` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:46 +msgid "" +":c:func:`PyThread_get_key_value`: Use :c:func:`PyThread_tss_get` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:48 +msgid "" +":c:func:`PyThread_delete_key_value`: Use :c:func:`PyThread_tss_delete` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:50 +msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." +msgstr "" diff --git a/deprecations/index.po b/deprecations/index.po new file mode 100644 index 00000000..ab320b99 --- /dev/null +++ b/deprecations/index.po @@ -0,0 +1,1225 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: deprecations/index.rst:2 +msgid "Deprecations" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:2 +msgid "Pending Removal in Python 3.13" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:4 +msgid "Modules (see :pep:`594`):" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:6 +msgid ":mod:`aifc`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:7 +msgid ":mod:`audioop`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:8 +msgid ":mod:`cgi`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:9 +msgid ":mod:`cgitb`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:10 +msgid ":mod:`chunk`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:11 +msgid ":mod:`crypt`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:12 +msgid ":mod:`imghdr`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:13 +msgid ":mod:`mailcap`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:14 +msgid ":mod:`msilib`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:15 +msgid ":mod:`nis`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:16 +msgid ":mod:`nntplib`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:17 +msgid ":mod:`ossaudiodev`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:18 +msgid ":mod:`pipes`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:19 +msgid ":mod:`sndhdr`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:20 +msgid ":mod:`spwd`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:21 +msgid ":mod:`sunau`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:22 +msgid ":mod:`telnetlib`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:23 +msgid ":mod:`uu`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:24 +msgid ":mod:`xdrlib`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:26 +msgid "Other modules:" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:28 +msgid ":mod:`!lib2to3`, and the :program:`2to3` program (:gh:`84540`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:30 +msgid "APIs:" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:32 +msgid ":class:`!configparser.LegacyInterpolation` (:gh:`90765`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:33 +msgid "``locale.resetlocale()`` (:gh:`90817`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:34 +msgid ":meth:`!turtle.RawTurtle.settiltangle` (:gh:`50096`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:35 +msgid ":func:`!unittest.findTestCases` (:gh:`50096`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:36 +msgid ":func:`!unittest.getTestCaseNames` (:gh:`50096`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:37 +msgid ":func:`!unittest.makeSuite` (:gh:`50096`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:38 +msgid ":meth:`!unittest.TestProgram.usageExit` (:gh:`67048`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:39 +msgid ":class:`!webbrowser.MacOSX` (:gh:`86421`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:40 +msgid ":class:`classmethod` descriptor chaining (:gh:`89519`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:41 +msgid ":mod:`importlib.resources` deprecated methods:" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:43 +msgid "``contents()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:44 +msgid "``is_resource()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:45 +msgid "``open_binary()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:46 +msgid "``open_text()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:47 +msgid "``path()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:48 +msgid "``read_binary()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:49 +msgid "``read_text()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:51 +msgid "" +"Use :func:`importlib.resources.files` instead. Refer to `importlib-" +"resources: Migrating from Legacy `_ (:gh:`106531`)" +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:2 +#: deprecations/pending-removal-in-3.14.rst:2 +msgid "Pending Removal in Python 3.14" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:4 +msgid "" +":mod:`argparse`: The *type*, *choices*, and *metavar* parameters of :class:`!" +"argparse.BooleanOptionalAction` are deprecated and will be removed in 3.14. " +"(Contributed by Nikita Sobolev in :gh:`92248`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:9 +msgid "" +":mod:`ast`: The following features have been deprecated in documentation " +"since Python 3.8, now cause a :exc:`DeprecationWarning` to be emitted at " +"runtime when they are accessed or used, and will be removed in Python 3.14:" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:13 +msgid ":class:`!ast.Num`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:14 +msgid ":class:`!ast.Str`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:15 +msgid ":class:`!ast.Bytes`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:16 +msgid ":class:`!ast.NameConstant`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:17 +msgid ":class:`!ast.Ellipsis`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:19 +msgid "" +"Use :class:`ast.Constant` instead. (Contributed by Serhiy Storchaka " +"in :gh:`90953`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:22 +msgid ":mod:`asyncio`:" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:24 +msgid "" +"The child watcher " +"classes :class:`~asyncio.MultiLoopChildWatcher`, :class:`~asyncio.FastChildWatcher`, :class:`~asyncio.AbstractChildWatcher` " +"and :class:`~asyncio.SafeChildWatcher` are deprecated and will be removed in " +"Python 3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:30 +msgid "" +":func:`asyncio.set_child_watcher`, :func:`asyncio.get_child_watcher`, :meth:`asyncio.AbstractEventLoopPolicy.set_child_watcher` " +"and :meth:`asyncio.AbstractEventLoopPolicy.get_child_watcher` are deprecated " +"and will be removed in Python 3.14. (Contributed by Kumar Aditya " +"in :gh:`94597`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:36 +msgid "" +"The :meth:`~asyncio.get_event_loop` method of the default event loop policy " +"now emits a :exc:`DeprecationWarning` if there is no current event loop set " +"and it decides to create one. (Contributed by Serhiy Storchaka and Guido van " +"Rossum in :gh:`100160`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:41 +msgid "" +":mod:`collections.abc`: Deprecated :class:`~collections.abc.ByteString`. " +"Prefer :class:`!Sequence` or :class:`~collections.abc.Buffer`. For use in " +"typing, prefer a union, like ``bytes | bytearray``, " +"or :class:`collections.abc.Buffer`. (Contributed by Shantanu Jain " +"in :gh:`91896`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:47 +msgid "" +":mod:`email`: Deprecated the *isdst* parameter " +"in :func:`email.utils.localtime`. (Contributed by Alan Williams " +"in :gh:`72346`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:50 +msgid "" +":mod:`importlib`: ``__package__`` and ``__cached__`` will cease to be set or " +"taken into consideration by the import system (:gh:`97879`)." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:53 +msgid ":mod:`importlib.abc` deprecated classes:" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:55 +msgid ":class:`!importlib.abc.ResourceReader`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:56 +msgid ":class:`!importlib.abc.Traversable`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:57 +msgid ":class:`!importlib.abc.TraversableResources`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:59 +msgid "Use :mod:`importlib.resources.abc` classes instead:" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:61 +msgid ":class:`importlib.resources.abc.Traversable`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:62 +msgid ":class:`importlib.resources.abc.TraversableResources`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:64 +msgid "(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:66 +msgid "" +":mod:`itertools` had undocumented, inefficient, historically buggy, and " +"inconsistent support for copy, deepcopy, and pickle operations. This will be " +"removed in 3.14 for a significant reduction in code volume and maintenance " +"burden. (Contributed by Raymond Hettinger in :gh:`101588`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:72 +msgid "" +":mod:`multiprocessing`: The default start method will change to a safer one " +"on Linux, BSDs, and other non-macOS POSIX platforms where ``'fork'`` is " +"currently the default (:gh:`84559`). Adding a runtime warning about this was " +"deemed too disruptive as the majority of code is not expected to care. Use " +"the :func:`~multiprocessing.get_context` " +"or :func:`~multiprocessing.set_start_method` APIs to explicitly specify when " +"your code *requires* ``'fork'``. See :ref:`multiprocessing-start-methods`." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:80 +msgid "" +":mod:`pathlib`: :meth:`~pathlib.PurePath.is_relative_to` " +"and :meth:`~pathlib.PurePath.relative_to`: passing additional arguments is " +"deprecated." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:84 +msgid "" +":mod:`pkgutil`: :func:`~pkgutil.find_loader` and :func:`~pkgutil.get_loader` " +"now raise :exc:`DeprecationWarning`; use :func:`importlib.util.find_spec` " +"instead. (Contributed by Nikita Sobolev in :gh:`97850`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:89 +msgid ":mod:`pty`:" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:91 +msgid "``master_open()``: use :func:`pty.openpty`." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:92 +msgid "``slave_open()``: use :func:`pty.openpty`." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:94 +msgid ":mod:`sqlite3`:" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:96 +msgid ":data:`~sqlite3.version` and :data:`~sqlite3.version_info`." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:98 +msgid "" +":meth:`~sqlite3.Cursor.execute` and :meth:`~sqlite3.Cursor.executemany` " +"if :ref:`named placeholders ` are used and " +"*parameters* is a sequence instead of a :class:`dict`." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:102 +msgid "" +":mod:`typing`: :class:`~typing.ByteString`, deprecated since Python 3.9, now " +"causes a :exc:`DeprecationWarning` to be emitted when it is used." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:105 +msgid "" +":mod:`urllib`: :class:`!urllib.parse.Quoter` is deprecated: it was not " +"intended to be a public API. (Contributed by Gregory P. Smith " +"in :gh:`88168`.)" +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:2 +#: deprecations/pending-removal-in-3.15.rst:2 +msgid "Pending Removal in Python 3.15" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:4 +msgid "" +":class:`http.server.CGIHTTPRequestHandler` will be removed along with its " +"related ``--cgi`` flag to ``python -m http.server``. It was obsolete and " +"rarely used. No direct replacement exists. *Anything* is better than CGI " +"to interface a web server with a request handler." +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:9 +#: deprecations/pending-removal-in-future.rst:58 +msgid ":mod:`importlib`:" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:11 +msgid "``load_module()`` method: use ``exec_module()`` instead." +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:13 +msgid "" +":class:`locale`: :func:`locale.getdefaultlocale` was deprecated in Python " +"3.11 and originally planned for removal in Python 3.13 (:gh:`90817`), but " +"removal has been postponed to Python 3.15. " +"Use :func:`locale.setlocale`, :func:`locale.getencoding` " +"and :func:`locale.getlocale` instead. (Contributed by Hugo van Kemenade " +"in :gh:`111187`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:20 +msgid "" +":mod:`pathlib`: :meth:`pathlib.PurePath.is_reserved` is deprecated and " +"scheduled for removal in Python 3.15. From Python 3.13 onwards, use " +"``os.path.isreserved`` to detect reserved paths on Windows." +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:25 +msgid "" +":mod:`platform`: :func:`~platform.java_ver` is deprecated and will be " +"removed in 3.15. It was largely untested, had a confusing API, and was only " +"useful for Jython support. (Contributed by Nikita Sobolev in :gh:`116349`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:31 +msgid "" +":mod:`threading`: Passing any arguments to :func:`threading.RLock` is now " +"deprecated. C version allows any numbers of args and kwargs, but they are " +"just ignored. Python version does not allow any arguments. All arguments " +"will be removed from :func:`threading.RLock` in Python 3.15. (Contributed by " +"Nikita Sobolev in :gh:`102029`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:38 +msgid ":class:`typing.NamedTuple`:" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:40 +msgid "" +"The undocumented keyword argument syntax for creating :class:`!NamedTuple` " +"classes (``NT = NamedTuple(\"NT\", x=int)``) is deprecated, and will be " +"disallowed in 3.15. Use the class-based syntax or the functional syntax " +"instead." +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:44 +msgid ":mod:`types`:" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:46 +msgid "" +":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " +"deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " +"but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " +"in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:53 +msgid ":mod:`typing`:" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:55 +msgid "" +"When using the functional syntax to create a :class:`!NamedTuple` class, " +"failing to pass a value to the *fields* parameter (``NT = " +"NamedTuple(\"NT\")``) is deprecated. Passing ``None`` to the *fields* " +"parameter (``NT = NamedTuple(\"NT\", None)``) is also deprecated. Both will " +"be disallowed in Python 3.15. To create a :class:`!NamedTuple` class with 0 " +"fields, use ``class NT(NamedTuple): pass`` or ``NT = NamedTuple(\"NT\", " +"[])``." +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:62 +msgid "" +":class:`typing.TypedDict`: When using the functional syntax to create " +"a :class:`!TypedDict` class, failing to pass a value to the *fields* " +"parameter (``TD = TypedDict(\"TD\")``) is deprecated. Passing ``None`` to " +"the *fields* parameter (``TD = TypedDict(\"TD\", None)``) is also " +"deprecated. Both will be disallowed in Python 3.15. To create a :class:`!" +"TypedDict` class with 0 fields, use ``class TD(TypedDict): pass`` or ``TD = " +"TypedDict(\"TD\", {})``." +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:69 +msgid "" +":mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` " +"methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes. " +"They will be removed in Python 3.15. (Contributed by Victor Stinner " +"in :gh:`105096`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.16.rst:2 +msgid "Pending Removal in Python 3.16" +msgstr "" + +#: deprecations/pending-removal-in-3.16.rst:4 +msgid "The import system:" +msgstr "" + +#: deprecations/pending-removal-in-3.16.rst:6 +msgid "" +"Setting :attr:`~module.__loader__` on a module while failing to " +"set :attr:`__spec__.loader ` is " +"deprecated. In Python 3.16, :attr:`!__loader__` will cease to be set or " +"taken into consideration by the import system or the standard library." +msgstr "" + +#: deprecations/pending-removal-in-3.16.rst:11 +msgid "" +":mod:`array`: :class:`array.array` ``'u'`` type (:c:type:`wchar_t`): use the " +"``'w'`` type instead (``Py_UCS4``)." +msgstr "" + +#: deprecations/pending-removal-in-3.16.rst:15 +msgid ":mod:`builtins`: ``~bool``, bitwise inversion on bool." +msgstr "" + +#: deprecations/pending-removal-in-3.16.rst:18 +msgid "" +":mod:`symtable`: Deprecate :meth:`symtable.Class.get_methods` due to the " +"lack of interest. (Contributed by Bénédikt Tran in :gh:`119698`.)" +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:2 +#: deprecations/pending-removal-in-future.rst:2 +msgid "Pending Removal in Future Versions" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:4 +msgid "" +"The following APIs will be removed in the future, although there is " +"currently no date scheduled for their removal." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:7 +msgid "" +":mod:`argparse`: Nesting argument groups and nesting mutually exclusive " +"groups are deprecated." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:10 +msgid ":mod:`array`'s ``'u'`` format code (:gh:`57281`)" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:12 +msgid ":mod:`builtins`:" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:14 +msgid "``bool(NotImplemented)``." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:15 +msgid "" +"Generators: ``throw(type, exc, tb)`` and ``athrow(type, exc, tb)`` signature " +"is deprecated: use ``throw(exc)`` and ``athrow(exc)`` instead, the single " +"argument signature." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:18 +msgid "" +"Currently Python accepts numeric literals immediately followed by keywords, " +"for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing and " +"ambiguous expressions like ``[0x1for x in y]`` (which can be interpreted as " +"``[0x1 for x in y]`` or ``[0x1f or x in y]``). A syntax warning is raised " +"if the numeric literal is immediately followed by one of " +"keywords :keyword:`and`, :keyword:`else`, :keyword:`for`, :keyword:`if`, :keyword:`in`, :keyword:`is` " +"and :keyword:`or`. In a future release it will be changed to a syntax " +"error. (:gh:`87999`)" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:26 +msgid "" +"Support for ``__index__()`` and ``__int__()`` method returning non-int type: " +"these methods will be required to return an instance of a strict subclass " +"of :class:`int`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:29 +msgid "" +"Support for ``__float__()`` method returning a strict subclass " +"of :class:`float`: these methods will be required to return an instance " +"of :class:`float`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:32 +msgid "" +"Support for ``__complex__()`` method returning a strict subclass " +"of :class:`complex`: these methods will be required to return an instance " +"of :class:`complex`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:35 +msgid "Delegation of ``int()`` to ``__trunc__()`` method." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:36 +msgid "" +"Passing a complex number as the *real* or *imag* argument in " +"the :func:`complex` constructor is now deprecated; it should only be passed " +"as a single positional argument. (Contributed by Serhiy Storchaka " +"in :gh:`109218`.)" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:41 +msgid "" +":mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants " +"are deprecated and replaced by :data:`calendar.JANUARY` " +"and :data:`calendar.FEBRUARY`. (Contributed by Prince Roshan " +"in :gh:`103636`.)" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:46 +msgid "" +":attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " +"instead." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:49 +msgid ":mod:`datetime`:" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:51 +msgid "" +":meth:`~datetime.datetime.utcnow`: use " +"``datetime.datetime.now(tz=datetime.UTC)``." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:53 +msgid "" +":meth:`~datetime.datetime.utcfromtimestamp`: use " +"``datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)``." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:56 +msgid ":mod:`gettext`: Plural value must be an integer." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:60 +msgid "" +":func:`~importlib.util.cache_from_source` *debug_override* parameter is " +"deprecated: use the *optimization* parameter instead." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:63 +msgid ":mod:`importlib.metadata`:" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:65 +msgid "``EntryPoints`` tuple interface." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:66 +msgid "Implicit ``None`` on return values." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:68 +msgid "" +":mod:`mailbox`: Use of StringIO input and text mode is deprecated, use " +"BytesIO and binary mode instead." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:71 +msgid "" +":mod:`os`: Calling :func:`os.register_at_fork` in multi-threaded process." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:73 +msgid "" +":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " +"deprecated, use an exception instance." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:76 +msgid "" +":mod:`re`: More strict rules are now applied for numerical group references " +"and group names in regular expressions. Only sequence of ASCII digits is " +"now accepted as a numerical reference. The group name in bytes patterns and " +"replacement strings can now only contain ASCII letters and digits and " +"underscore. (Contributed by Serhiy Storchaka in :gh:`91760`.)" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:83 +msgid "" +":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:85 +msgid "" +":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " +"Python 3.12; use the *onexc* parameter instead." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:88 +msgid ":mod:`ssl` options and protocols:" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:90 +msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:91 +msgid "" +":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` " +"and :meth:`!selected_npn_protocol` are deprecated: use ALPN instead." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:94 +msgid "``ssl.OP_NO_SSL*`` options" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:95 +msgid "``ssl.OP_NO_TLS*`` options" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:96 +msgid "``ssl.PROTOCOL_SSLv3``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:97 +msgid "``ssl.PROTOCOL_TLS``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:98 +msgid "``ssl.PROTOCOL_TLSv1``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:99 +msgid "``ssl.PROTOCOL_TLSv1_1``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:100 +msgid "``ssl.PROTOCOL_TLSv1_2``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:101 +msgid "``ssl.TLSVersion.SSLv3``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:102 +msgid "``ssl.TLSVersion.TLSv1``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:103 +msgid "``ssl.TLSVersion.TLSv1_1``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:105 +msgid "" +":func:`sysconfig.is_python_build` *check_home* parameter is deprecated and " +"ignored." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:108 +msgid ":mod:`threading` methods:" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:110 +msgid "" +":meth:`!threading.Condition.notifyAll`: " +"use :meth:`~threading.Condition.notify_all`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:111 +msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:112 +msgid "" +":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: " +"use :attr:`threading.Thread.daemon` attribute." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:114 +msgid "" +":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: " +"use :attr:`threading.Thread.name` attribute." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:116 +msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:117 +msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:119 +msgid ":class:`typing.Text` (:gh:`92332`)." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:121 +msgid "" +":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " +"value that is not ``None`` from a test case." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:124 +msgid "" +":mod:`urllib.parse` deprecated functions: :func:`~urllib.parse.urlparse` " +"instead" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:126 +msgid "``splitattr()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:127 +msgid "``splithost()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:128 +msgid "``splitnport()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:129 +msgid "``splitpasswd()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:130 +msgid "``splitport()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:131 +msgid "``splitquery()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:132 +msgid "``splittag()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:133 +msgid "``splittype()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:134 +msgid "``splituser()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:135 +msgid "``splitvalue()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:136 +msgid "``to_bytes()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:138 +msgid "" +":mod:`urllib.request`: :class:`~urllib.request.URLopener` " +"and :class:`~urllib.request.FancyURLopener` style of invoking requests is " +"deprecated. Use newer :func:`~urllib.request.urlopen` functions and methods." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:142 +msgid "" +":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " +"writes." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:145 +msgid "" +":mod:`xml.etree.ElementTree`: Testing the truth value of " +"an :class:`~xml.etree.ElementTree.Element` is deprecated. In a future " +"release it will always return ``True``. Prefer explicit ``len(elem)`` or " +"``elem is not None`` tests instead." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:150 +msgid "" +":meth:`zipimport.zipimporter.load_module` is deprecated: " +"use :meth:`~zipimport.zipimporter.exec_module` instead." +msgstr "" + +#: deprecations/index.rst:15 +msgid "C API Deprecations" +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:4 +msgid "" +"The ``ma_version_tag`` field in :c:type:`PyDictObject` for extension modules " +"(:pep:`699`; :gh:`101193`)." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:7 +msgid "" +"Creating :c:data:`immutable types ` with mutable " +"bases (:gh:`95388`)." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:10 +msgid "" +"Functions to configure Python's initialization, deprecated in Python 3.11:" +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:12 +msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:14 +msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:16 +msgid "" +":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:18 +msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:21 +#: deprecations/c-api-pending-removal-in-3.14.rst:71 +msgid "" +"The :c:func:`Py_InitializeFromConfig` API should be used " +"with :c:type:`PyConfig` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:24 +msgid "Global configuration variables:" +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:26 +msgid ":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:28 +msgid ":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:30 +msgid ":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:32 +msgid "" +":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:34 +msgid ":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:36 +msgid "" +":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:38 +msgid ":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:40 +msgid "" +":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:42 +msgid "" +":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:44 +msgid "" +":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:46 +msgid "" +":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:48 +msgid "" +":c:var:`Py_NoUserSiteDirectory`: " +"Use :c:member:`PyConfig.user_site_directory` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:50 +msgid "" +":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:52 +msgid "" +":c:var:`Py_HashRandomizationFlag`: Use :c:member:`PyConfig.use_hash_seed` " +"and :c:member:`PyConfig.hash_seed` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:55 +msgid ":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:57 +msgid "" +":c:var:`Py_LegacyWindowsFSEncodingFlag`: " +"Use :c:member:`PyPreConfig.legacy_windows_fs_encoding` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:59 +msgid "" +":c:var:`Py_LegacyWindowsStdioFlag`: " +"Use :c:member:`PyConfig.legacy_windows_stdio` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:61 +msgid "" +":c:var:`!Py_FileSystemDefaultEncoding`: " +"Use :c:member:`PyConfig.filesystem_encoding` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:63 +msgid "" +":c:var:`!Py_HasFileSystemDefaultEncoding`: " +"Use :c:member:`PyConfig.filesystem_encoding` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:65 +msgid "" +":c:var:`!Py_FileSystemDefaultEncodeErrors`: " +"Use :c:member:`PyConfig.filesystem_errors` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.14.rst:67 +msgid "" +":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` instead. " +"(see :c:func:`Py_PreInitialize`)" +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:4 +msgid "The bundled copy of ``libmpdecimal``." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:5 +msgid "" +"The :c:func:`PyImport_ImportModuleNoBlock`: " +"Use :c:func:`PyImport_ImportModule` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:7 +msgid "" +":c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`: " +"Use :c:func:`!PyWeakref_GetRef` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:9 +msgid "" +":c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro: " +"Use :c:type:`wchar_t` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:11 +msgid "Python initialization functions:" +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:13 +msgid "" +":c:func:`PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" +"warnings.filters` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:15 +msgid ":c:func:`Py_GetExecPrefix`: Get :data:`sys.exec_prefix` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:17 +msgid ":c:func:`Py_GetPath`: Get :data:`sys.path` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:19 +msgid ":c:func:`Py_GetPrefix`: Get :data:`sys.prefix` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:21 +msgid ":c:func:`Py_GetProgramFullPath`: Get :data:`sys.executable` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:23 +msgid ":c:func:`Py_GetProgramName`: Get :data:`sys.executable` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-3.15.rst:25 +msgid "" +":c:func:`Py_GetPythonHome`: Get :c:member:`PyConfig.home` or " +"the :envvar:`PYTHONHOME` environment variable instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:4 +msgid "" +"The following APIs are deprecated and will be removed, although there is " +"currently no date scheduled for their removal." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:7 +msgid ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: Unneeded since Python 3.8." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:9 +msgid ":c:func:`PyErr_Fetch`: Use :c:func:`PyErr_GetRaisedException` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:11 +msgid "" +":c:func:`PyErr_NormalizeException`: Use :c:func:`PyErr_GetRaisedException` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:13 +msgid "" +":c:func:`PyErr_Restore`: Use :c:func:`PyErr_SetRaisedException` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:15 +msgid "" +":c:func:`PyModule_GetFilename`: Use :c:func:`PyModule_GetFilenameObject` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:17 +msgid ":c:func:`PyOS_AfterFork`: Use :c:func:`PyOS_AfterFork_Child` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:19 +msgid "" +":c:func:`PySlice_GetIndicesEx`: Use :c:func:`PySlice_Unpack` " +"and :c:func:`PySlice_AdjustIndices` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:21 +msgid "" +":c:func:`!PyUnicode_AsDecodedObject`: Use :c:func:`PyCodec_Decode` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:23 +msgid "" +":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:25 +msgid "" +":c:func:`!PyUnicode_AsEncodedObject`: Use :c:func:`PyCodec_Encode` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:27 +msgid "" +":c:func:`!PyUnicode_AsEncodedUnicode`: Use :c:func:`PyCodec_Encode` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:29 +msgid ":c:func:`PyUnicode_READY`: Unneeded since Python 3.12" +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:31 +msgid ":c:func:`!PyErr_Display`: Use :c:func:`PyErr_DisplayException` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:33 +msgid "" +":c:func:`!_PyErr_ChainExceptions`: Use :c:func:`!_PyErr_ChainExceptions1` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:35 +msgid "" +":c:member:`!PyBytesObject.ob_shash` member: call :c:func:`PyObject_Hash` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:37 +msgid ":c:member:`!PyDictObject.ma_version_tag` member." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:38 +msgid "Thread Local Storage (TLS) API:" +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:40 +msgid "" +":c:func:`PyThread_create_key`: Use :c:func:`PyThread_tss_alloc` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:42 +msgid ":c:func:`PyThread_delete_key`: Use :c:func:`PyThread_tss_free` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:44 +msgid "" +":c:func:`PyThread_set_key_value`: Use :c:func:`PyThread_tss_set` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:46 +msgid "" +":c:func:`PyThread_get_key_value`: Use :c:func:`PyThread_tss_get` instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:48 +msgid "" +":c:func:`PyThread_delete_key_value`: Use :c:func:`PyThread_tss_delete` " +"instead." +msgstr "" + +#: deprecations/c-api-pending-removal-in-future.rst:50 +msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." +msgstr "" diff --git a/deprecations/pending-removal-in-3.13.po b/deprecations/pending-removal-in-3.13.po new file mode 100644 index 00000000..59d61280 --- /dev/null +++ b/deprecations/pending-removal-in-3.13.po @@ -0,0 +1,188 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: deprecations/pending-removal-in-3.13.rst:2 +msgid "Pending Removal in Python 3.13" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:4 +msgid "Modules (see :pep:`594`):" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:6 +msgid ":mod:`aifc`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:7 +msgid ":mod:`audioop`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:8 +msgid ":mod:`cgi`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:9 +msgid ":mod:`cgitb`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:10 +msgid ":mod:`chunk`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:11 +msgid ":mod:`crypt`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:12 +msgid ":mod:`imghdr`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:13 +msgid ":mod:`mailcap`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:14 +msgid ":mod:`msilib`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:15 +msgid ":mod:`nis`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:16 +msgid ":mod:`nntplib`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:17 +msgid ":mod:`ossaudiodev`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:18 +msgid ":mod:`pipes`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:19 +msgid ":mod:`sndhdr`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:20 +msgid ":mod:`spwd`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:21 +msgid ":mod:`sunau`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:22 +msgid ":mod:`telnetlib`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:23 +msgid ":mod:`uu`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:24 +msgid ":mod:`xdrlib`" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:26 +msgid "Other modules:" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:28 +msgid ":mod:`!lib2to3`, and the :program:`2to3` program (:gh:`84540`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:30 +msgid "APIs:" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:32 +msgid ":class:`!configparser.LegacyInterpolation` (:gh:`90765`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:33 +msgid "``locale.resetlocale()`` (:gh:`90817`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:34 +msgid ":meth:`!turtle.RawTurtle.settiltangle` (:gh:`50096`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:35 +msgid ":func:`!unittest.findTestCases` (:gh:`50096`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:36 +msgid ":func:`!unittest.getTestCaseNames` (:gh:`50096`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:37 +msgid ":func:`!unittest.makeSuite` (:gh:`50096`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:38 +msgid ":meth:`!unittest.TestProgram.usageExit` (:gh:`67048`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:39 +msgid ":class:`!webbrowser.MacOSX` (:gh:`86421`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:40 +msgid ":class:`classmethod` descriptor chaining (:gh:`89519`)" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:41 +msgid ":mod:`importlib.resources` deprecated methods:" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:43 +msgid "``contents()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:44 +msgid "``is_resource()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:45 +msgid "``open_binary()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:46 +msgid "``open_text()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:47 +msgid "``path()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:48 +msgid "``read_binary()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:49 +msgid "``read_text()``" +msgstr "" + +#: deprecations/pending-removal-in-3.13.rst:51 +msgid "" +"Use :func:`importlib.resources.files` instead. Refer to `importlib-" +"resources: Migrating from Legacy `_ (:gh:`106531`)" +msgstr "" diff --git a/deprecations/pending-removal-in-3.14.po b/deprecations/pending-removal-in-3.14.po new file mode 100644 index 00000000..43ae35ce --- /dev/null +++ b/deprecations/pending-removal-in-3.14.po @@ -0,0 +1,216 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: deprecations/pending-removal-in-3.14.rst:2 +msgid "Pending Removal in Python 3.14" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:4 +msgid "" +":mod:`argparse`: The *type*, *choices*, and *metavar* parameters of :class:`!" +"argparse.BooleanOptionalAction` are deprecated and will be removed in 3.14. " +"(Contributed by Nikita Sobolev in :gh:`92248`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:9 +msgid "" +":mod:`ast`: The following features have been deprecated in documentation " +"since Python 3.8, now cause a :exc:`DeprecationWarning` to be emitted at " +"runtime when they are accessed or used, and will be removed in Python 3.14:" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:13 +msgid ":class:`!ast.Num`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:14 +msgid ":class:`!ast.Str`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:15 +msgid ":class:`!ast.Bytes`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:16 +msgid ":class:`!ast.NameConstant`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:17 +msgid ":class:`!ast.Ellipsis`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:19 +msgid "" +"Use :class:`ast.Constant` instead. (Contributed by Serhiy Storchaka " +"in :gh:`90953`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:22 +msgid ":mod:`asyncio`:" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:24 +msgid "" +"The child watcher " +"classes :class:`~asyncio.MultiLoopChildWatcher`, :class:`~asyncio.FastChildWatcher`, :class:`~asyncio.AbstractChildWatcher` " +"and :class:`~asyncio.SafeChildWatcher` are deprecated and will be removed in " +"Python 3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:30 +msgid "" +":func:`asyncio.set_child_watcher`, :func:`asyncio.get_child_watcher`, :meth:`asyncio.AbstractEventLoopPolicy.set_child_watcher` " +"and :meth:`asyncio.AbstractEventLoopPolicy.get_child_watcher` are deprecated " +"and will be removed in Python 3.14. (Contributed by Kumar Aditya " +"in :gh:`94597`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:36 +msgid "" +"The :meth:`~asyncio.get_event_loop` method of the default event loop policy " +"now emits a :exc:`DeprecationWarning` if there is no current event loop set " +"and it decides to create one. (Contributed by Serhiy Storchaka and Guido van " +"Rossum in :gh:`100160`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:41 +msgid "" +":mod:`collections.abc`: Deprecated :class:`~collections.abc.ByteString`. " +"Prefer :class:`!Sequence` or :class:`~collections.abc.Buffer`. For use in " +"typing, prefer a union, like ``bytes | bytearray``, " +"or :class:`collections.abc.Buffer`. (Contributed by Shantanu Jain " +"in :gh:`91896`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:47 +msgid "" +":mod:`email`: Deprecated the *isdst* parameter " +"in :func:`email.utils.localtime`. (Contributed by Alan Williams " +"in :gh:`72346`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:50 +msgid "" +":mod:`importlib`: ``__package__`` and ``__cached__`` will cease to be set or " +"taken into consideration by the import system (:gh:`97879`)." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:53 +msgid ":mod:`importlib.abc` deprecated classes:" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:55 +msgid ":class:`!importlib.abc.ResourceReader`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:56 +msgid ":class:`!importlib.abc.Traversable`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:57 +msgid ":class:`!importlib.abc.TraversableResources`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:59 +msgid "Use :mod:`importlib.resources.abc` classes instead:" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:61 +msgid ":class:`importlib.resources.abc.Traversable`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:62 +msgid ":class:`importlib.resources.abc.TraversableResources`" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:64 +msgid "(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:66 +msgid "" +":mod:`itertools` had undocumented, inefficient, historically buggy, and " +"inconsistent support for copy, deepcopy, and pickle operations. This will be " +"removed in 3.14 for a significant reduction in code volume and maintenance " +"burden. (Contributed by Raymond Hettinger in :gh:`101588`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:72 +msgid "" +":mod:`multiprocessing`: The default start method will change to a safer one " +"on Linux, BSDs, and other non-macOS POSIX platforms where ``'fork'`` is " +"currently the default (:gh:`84559`). Adding a runtime warning about this was " +"deemed too disruptive as the majority of code is not expected to care. Use " +"the :func:`~multiprocessing.get_context` " +"or :func:`~multiprocessing.set_start_method` APIs to explicitly specify when " +"your code *requires* ``'fork'``. See :ref:`multiprocessing-start-methods`." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:80 +msgid "" +":mod:`pathlib`: :meth:`~pathlib.PurePath.is_relative_to` " +"and :meth:`~pathlib.PurePath.relative_to`: passing additional arguments is " +"deprecated." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:84 +msgid "" +":mod:`pkgutil`: :func:`~pkgutil.find_loader` and :func:`~pkgutil.get_loader` " +"now raise :exc:`DeprecationWarning`; use :func:`importlib.util.find_spec` " +"instead. (Contributed by Nikita Sobolev in :gh:`97850`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:89 +msgid ":mod:`pty`:" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:91 +msgid "``master_open()``: use :func:`pty.openpty`." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:92 +msgid "``slave_open()``: use :func:`pty.openpty`." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:94 +msgid ":mod:`sqlite3`:" +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:96 +msgid ":data:`~sqlite3.version` and :data:`~sqlite3.version_info`." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:98 +msgid "" +":meth:`~sqlite3.Cursor.execute` and :meth:`~sqlite3.Cursor.executemany` " +"if :ref:`named placeholders ` are used and " +"*parameters* is a sequence instead of a :class:`dict`." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:102 +msgid "" +":mod:`typing`: :class:`~typing.ByteString`, deprecated since Python 3.9, now " +"causes a :exc:`DeprecationWarning` to be emitted when it is used." +msgstr "" + +#: deprecations/pending-removal-in-3.14.rst:105 +msgid "" +":mod:`urllib`: :class:`!urllib.parse.Quoter` is deprecated: it was not " +"intended to be a public API. (Contributed by Gregory P. Smith " +"in :gh:`88168`.)" +msgstr "" diff --git a/deprecations/pending-removal-in-3.15.po b/deprecations/pending-removal-in-3.15.po new file mode 100644 index 00000000..3704c772 --- /dev/null +++ b/deprecations/pending-removal-in-3.15.po @@ -0,0 +1,128 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: deprecations/pending-removal-in-3.15.rst:2 +msgid "Pending Removal in Python 3.15" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:4 +msgid "" +":class:`http.server.CGIHTTPRequestHandler` will be removed along with its " +"related ``--cgi`` flag to ``python -m http.server``. It was obsolete and " +"rarely used. No direct replacement exists. *Anything* is better than CGI " +"to interface a web server with a request handler." +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:9 +msgid ":mod:`importlib`:" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:11 +msgid "``load_module()`` method: use ``exec_module()`` instead." +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:13 +msgid "" +":class:`locale`: :func:`locale.getdefaultlocale` was deprecated in Python " +"3.11 and originally planned for removal in Python 3.13 (:gh:`90817`), but " +"removal has been postponed to Python 3.15. " +"Use :func:`locale.setlocale`, :func:`locale.getencoding` " +"and :func:`locale.getlocale` instead. (Contributed by Hugo van Kemenade " +"in :gh:`111187`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:20 +msgid "" +":mod:`pathlib`: :meth:`pathlib.PurePath.is_reserved` is deprecated and " +"scheduled for removal in Python 3.15. From Python 3.13 onwards, use " +"``os.path.isreserved`` to detect reserved paths on Windows." +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:25 +msgid "" +":mod:`platform`: :func:`~platform.java_ver` is deprecated and will be " +"removed in 3.15. It was largely untested, had a confusing API, and was only " +"useful for Jython support. (Contributed by Nikita Sobolev in :gh:`116349`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:31 +msgid "" +":mod:`threading`: Passing any arguments to :func:`threading.RLock` is now " +"deprecated. C version allows any numbers of args and kwargs, but they are " +"just ignored. Python version does not allow any arguments. All arguments " +"will be removed from :func:`threading.RLock` in Python 3.15. (Contributed by " +"Nikita Sobolev in :gh:`102029`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:38 +msgid ":class:`typing.NamedTuple`:" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:40 +msgid "" +"The undocumented keyword argument syntax for creating :class:`!NamedTuple` " +"classes (``NT = NamedTuple(\"NT\", x=int)``) is deprecated, and will be " +"disallowed in 3.15. Use the class-based syntax or the functional syntax " +"instead." +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:44 +msgid ":mod:`types`:" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:46 +msgid "" +":class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was " +"deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " +"but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " +"in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:53 +msgid ":mod:`typing`:" +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:55 +msgid "" +"When using the functional syntax to create a :class:`!NamedTuple` class, " +"failing to pass a value to the *fields* parameter (``NT = " +"NamedTuple(\"NT\")``) is deprecated. Passing ``None`` to the *fields* " +"parameter (``NT = NamedTuple(\"NT\", None)``) is also deprecated. Both will " +"be disallowed in Python 3.15. To create a :class:`!NamedTuple` class with 0 " +"fields, use ``class NT(NamedTuple): pass`` or ``NT = NamedTuple(\"NT\", " +"[])``." +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:62 +msgid "" +":class:`typing.TypedDict`: When using the functional syntax to create " +"a :class:`!TypedDict` class, failing to pass a value to the *fields* " +"parameter (``TD = TypedDict(\"TD\")``) is deprecated. Passing ``None`` to " +"the *fields* parameter (``TD = TypedDict(\"TD\", None)``) is also " +"deprecated. Both will be disallowed in Python 3.15. To create a :class:`!" +"TypedDict` class with 0 fields, use ``class TD(TypedDict): pass`` or ``TD = " +"TypedDict(\"TD\", {})``." +msgstr "" + +#: deprecations/pending-removal-in-3.15.rst:69 +msgid "" +":mod:`wave`: Deprecate the ``getmark()``, ``setmark()`` and ``getmarkers()`` " +"methods of the :class:`wave.Wave_read` and :class:`wave.Wave_write` classes. " +"They will be removed in Python 3.15. (Contributed by Victor Stinner " +"in :gh:`105096`.)" +msgstr "" diff --git a/deprecations/pending-removal-in-3.16.po b/deprecations/pending-removal-in-3.16.po new file mode 100644 index 00000000..d6fdc378 --- /dev/null +++ b/deprecations/pending-removal-in-3.16.po @@ -0,0 +1,49 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: deprecations/pending-removal-in-3.16.rst:2 +msgid "Pending Removal in Python 3.16" +msgstr "" + +#: deprecations/pending-removal-in-3.16.rst:4 +msgid "The import system:" +msgstr "" + +#: deprecations/pending-removal-in-3.16.rst:6 +msgid "" +"Setting :attr:`~module.__loader__` on a module while failing to " +"set :attr:`__spec__.loader ` is " +"deprecated. In Python 3.16, :attr:`!__loader__` will cease to be set or " +"taken into consideration by the import system or the standard library." +msgstr "" + +#: deprecations/pending-removal-in-3.16.rst:11 +msgid "" +":mod:`array`: :class:`array.array` ``'u'`` type (:c:type:`wchar_t`): use the " +"``'w'`` type instead (``Py_UCS4``)." +msgstr "" + +#: deprecations/pending-removal-in-3.16.rst:15 +msgid ":mod:`builtins`: ``~bool``, bitwise inversion on bool." +msgstr "" + +#: deprecations/pending-removal-in-3.16.rst:18 +msgid "" +":mod:`symtable`: Deprecate :meth:`symtable.Class.get_methods` due to the " +"lack of interest. (Contributed by Bénédikt Tran in :gh:`119698`.)" +msgstr "" diff --git a/deprecations/pending-removal-in-future.po b/deprecations/pending-removal-in-future.po new file mode 100644 index 00000000..13f446b4 --- /dev/null +++ b/deprecations/pending-removal-in-future.po @@ -0,0 +1,371 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: deprecations/pending-removal-in-future.rst:2 +msgid "Pending Removal in Future Versions" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:4 +msgid "" +"The following APIs will be removed in the future, although there is " +"currently no date scheduled for their removal." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:7 +msgid "" +":mod:`argparse`: Nesting argument groups and nesting mutually exclusive " +"groups are deprecated." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:10 +msgid ":mod:`array`'s ``'u'`` format code (:gh:`57281`)" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:12 +msgid ":mod:`builtins`:" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:14 +msgid "``bool(NotImplemented)``." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:15 +msgid "" +"Generators: ``throw(type, exc, tb)`` and ``athrow(type, exc, tb)`` signature " +"is deprecated: use ``throw(exc)`` and ``athrow(exc)`` instead, the single " +"argument signature." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:18 +msgid "" +"Currently Python accepts numeric literals immediately followed by keywords, " +"for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing and " +"ambiguous expressions like ``[0x1for x in y]`` (which can be interpreted as " +"``[0x1 for x in y]`` or ``[0x1f or x in y]``). A syntax warning is raised " +"if the numeric literal is immediately followed by one of " +"keywords :keyword:`and`, :keyword:`else`, :keyword:`for`, :keyword:`if`, :keyword:`in`, :keyword:`is` " +"and :keyword:`or`. In a future release it will be changed to a syntax " +"error. (:gh:`87999`)" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:26 +msgid "" +"Support for ``__index__()`` and ``__int__()`` method returning non-int type: " +"these methods will be required to return an instance of a strict subclass " +"of :class:`int`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:29 +msgid "" +"Support for ``__float__()`` method returning a strict subclass " +"of :class:`float`: these methods will be required to return an instance " +"of :class:`float`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:32 +msgid "" +"Support for ``__complex__()`` method returning a strict subclass " +"of :class:`complex`: these methods will be required to return an instance " +"of :class:`complex`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:35 +msgid "Delegation of ``int()`` to ``__trunc__()`` method." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:36 +msgid "" +"Passing a complex number as the *real* or *imag* argument in " +"the :func:`complex` constructor is now deprecated; it should only be passed " +"as a single positional argument. (Contributed by Serhiy Storchaka " +"in :gh:`109218`.)" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:41 +msgid "" +":mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants " +"are deprecated and replaced by :data:`calendar.JANUARY` " +"and :data:`calendar.FEBRUARY`. (Contributed by Prince Roshan " +"in :gh:`103636`.)" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:46 +msgid "" +":attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " +"instead." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:49 +msgid ":mod:`datetime`:" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:51 +msgid "" +":meth:`~datetime.datetime.utcnow`: use " +"``datetime.datetime.now(tz=datetime.UTC)``." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:53 +msgid "" +":meth:`~datetime.datetime.utcfromtimestamp`: use " +"``datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)``." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:56 +msgid ":mod:`gettext`: Plural value must be an integer." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:58 +msgid ":mod:`importlib`:" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:60 +msgid "" +":func:`~importlib.util.cache_from_source` *debug_override* parameter is " +"deprecated: use the *optimization* parameter instead." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:63 +msgid ":mod:`importlib.metadata`:" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:65 +msgid "``EntryPoints`` tuple interface." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:66 +msgid "Implicit ``None`` on return values." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:68 +msgid "" +":mod:`mailbox`: Use of StringIO input and text mode is deprecated, use " +"BytesIO and binary mode instead." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:71 +msgid "" +":mod:`os`: Calling :func:`os.register_at_fork` in multi-threaded process." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:73 +msgid "" +":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " +"deprecated, use an exception instance." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:76 +msgid "" +":mod:`re`: More strict rules are now applied for numerical group references " +"and group names in regular expressions. Only sequence of ASCII digits is " +"now accepted as a numerical reference. The group name in bytes patterns and " +"replacement strings can now only contain ASCII letters and digits and " +"underscore. (Contributed by Serhiy Storchaka in :gh:`91760`.)" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:83 +msgid "" +":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:85 +msgid "" +":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " +"Python 3.12; use the *onexc* parameter instead." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:88 +msgid ":mod:`ssl` options and protocols:" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:90 +msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:91 +msgid "" +":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` " +"and :meth:`!selected_npn_protocol` are deprecated: use ALPN instead." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:94 +msgid "``ssl.OP_NO_SSL*`` options" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:95 +msgid "``ssl.OP_NO_TLS*`` options" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:96 +msgid "``ssl.PROTOCOL_SSLv3``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:97 +msgid "``ssl.PROTOCOL_TLS``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:98 +msgid "``ssl.PROTOCOL_TLSv1``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:99 +msgid "``ssl.PROTOCOL_TLSv1_1``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:100 +msgid "``ssl.PROTOCOL_TLSv1_2``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:101 +msgid "``ssl.TLSVersion.SSLv3``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:102 +msgid "``ssl.TLSVersion.TLSv1``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:103 +msgid "``ssl.TLSVersion.TLSv1_1``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:105 +msgid "" +":func:`sysconfig.is_python_build` *check_home* parameter is deprecated and " +"ignored." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:108 +msgid ":mod:`threading` methods:" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:110 +msgid "" +":meth:`!threading.Condition.notifyAll`: " +"use :meth:`~threading.Condition.notify_all`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:111 +msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:112 +msgid "" +":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: " +"use :attr:`threading.Thread.daemon` attribute." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:114 +msgid "" +":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: " +"use :attr:`threading.Thread.name` attribute." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:116 +msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:117 +msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:119 +msgid ":class:`typing.Text` (:gh:`92332`)." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:121 +msgid "" +":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " +"value that is not ``None`` from a test case." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:124 +msgid "" +":mod:`urllib.parse` deprecated functions: :func:`~urllib.parse.urlparse` " +"instead" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:126 +msgid "``splitattr()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:127 +msgid "``splithost()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:128 +msgid "``splitnport()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:129 +msgid "``splitpasswd()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:130 +msgid "``splitport()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:131 +msgid "``splitquery()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:132 +msgid "``splittag()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:133 +msgid "``splittype()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:134 +msgid "``splituser()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:135 +msgid "``splitvalue()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:136 +msgid "``to_bytes()``" +msgstr "" + +#: deprecations/pending-removal-in-future.rst:138 +msgid "" +":mod:`urllib.request`: :class:`~urllib.request.URLopener` " +"and :class:`~urllib.request.FancyURLopener` style of invoking requests is " +"deprecated. Use newer :func:`~urllib.request.urlopen` functions and methods." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:142 +msgid "" +":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " +"writes." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:145 +msgid "" +":mod:`xml.etree.ElementTree`: Testing the truth value of " +"an :class:`~xml.etree.ElementTree.Element` is deprecated. In a future " +"release it will always return ``True``. Prefer explicit ``len(elem)`` or " +"``elem is not None`` tests instead." +msgstr "" + +#: deprecations/pending-removal-in-future.rst:150 +msgid "" +":meth:`zipimport.zipimporter.load_module` is deprecated: " +"use :meth:`~zipimport.zipimporter.exec_module` instead." +msgstr "" diff --git a/dictionaries/main.txt b/dictionaries/main.txt index 072fac3c..35d7d6ba 100644 --- a/dictionaries/main.txt +++ b/dictionaries/main.txt @@ -800,6 +800,7 @@ zlib αρχές αρχείο αρχειοθετημένη +αρχικοποιήθηκε αρχικοποιημένο αρχικός βλ @@ -870,7 +871,9 @@ zlib κατάσταση κατέληγες κατακερματιστέες +κατηργημένο κεφαλίδας +κεφαλίδες κεφαλίδων κωδικοποίηση κωδικοποιητή diff --git a/distributing/index.po b/distributing/index.po index 879d0808..4d506a14 100644 --- a/distributing/index.po +++ b/distributing/index.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-11-25 20:18+0000\n" "Last-Translator: Artemis Leonardou \n" "Language-Team: PyGreece \n" diff --git a/extending/building.po b/extending/building.po index 23d8b062..c817b3a4 100644 --- a/extending/building.po +++ b/extending/building.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -28,10 +29,10 @@ msgstr "" #: extending/building.rst:12 msgid "" -"To be importable, the shared library must be available on :envvar:" -"`PYTHONPATH`, and must be named after the module name, with an appropriate " -"extension. When using setuptools, the correct filename is generated " -"automatically." +"To be importable, the shared library must be available " +"on :envvar:`PYTHONPATH`, and must be named after the module name, with an " +"appropriate extension. When using setuptools, the correct filename is " +"generated automatically." msgstr "" #: extending/building.rst:16 @@ -54,6 +55,16 @@ msgid "" "*punycode* encoding with hyphens replaced by underscores. In Python::" msgstr "" +#: extending/building.rst:32 +msgid "" +"def initfunc_name(name):\n" +" try:\n" +" suffix = b'_' + name.encode('ascii')\n" +" except UnicodeEncodeError:\n" +" suffix = b'U_' + name.encode('punycode').replace(b'-', b'_')\n" +" return b'PyInit' + suffix" +msgstr "" + #: extending/building.rst:39 msgid "" "It is possible to export multiple modules from a single shared library by " diff --git a/extending/embedding.po b/extending/embedding.po index 0693c49a..5485a1d5 100644 --- a/extending/embedding.po +++ b/extending/embedding.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -46,10 +47,10 @@ msgstr "" msgid "" "So if you are embedding Python, you are providing your own main program. " "One of the things this main program has to do is initialize the Python " -"interpreter. At the very least, you have to call the function :c:func:" -"`Py_Initialize`. There are optional calls to pass command line arguments to " -"Python. Then later you can call the interpreter from any part of the " -"application." +"interpreter. At the very least, you have to call the " +"function :c:func:`Py_Initialize`. There are optional calls to pass command " +"line arguments to Python. Then later you can call the interpreter from any " +"part of the application." msgstr "" #: extending/embedding.rst:32 @@ -62,7 +63,7 @@ msgid "" "Python objects." msgstr "" -#: extending/embedding.rst:42 +#: extending/embedding.rst:41 msgid ":ref:`c-api-index`" msgstr "" @@ -84,19 +85,44 @@ msgid "" "used to perform some operation on a file. ::" msgstr "" +#: extending/embedding.rst:56 +msgid "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"\n" +"int\n" +"main(int argc, char *argv[])\n" +"{\n" +" wchar_t *program = Py_DecodeLocale(argv[0], NULL);\n" +" if (program == NULL) {\n" +" fprintf(stderr, \"Fatal error: cannot decode argv[0]\\n\");\n" +" exit(1);\n" +" }\n" +" Py_SetProgramName(program); /* optional but recommended */\n" +" Py_Initialize();\n" +" PyRun_SimpleString(\"from time import time,ctime\\n\"\n" +" \"print('Today is', ctime(time()))\\n\");\n" +" if (Py_FinalizeEx() < 0) {\n" +" exit(120);\n" +" }\n" +" PyMem_RawFree(program);\n" +" return 0;\n" +"}" +msgstr "" + #: extending/embedding.rst:78 msgid "" -"The :c:func:`Py_SetProgramName` function should be called before :c:func:" -"`Py_Initialize` to inform the interpreter about paths to Python run-time " -"libraries. Next, the Python interpreter is initialized with :c:func:" -"`Py_Initialize`, followed by the execution of a hard-coded Python script " -"that prints the date and time. Afterwards, the :c:func:`Py_FinalizeEx` call " -"shuts the interpreter down, followed by the end of the program. In a real " -"program, you may want to get the Python script from another source, perhaps " -"a text-editor routine, a file, or a database. Getting the Python code from " -"a file can better be done by using the :c:func:`PyRun_SimpleFile` function, " -"which saves you the trouble of allocating memory space and loading the file " -"contents." +"The :c:func:`Py_SetProgramName` function should be called " +"before :c:func:`Py_Initialize` to inform the interpreter about paths to " +"Python run-time libraries. Next, the Python interpreter is initialized " +"with :c:func:`Py_Initialize`, followed by the execution of a hard-coded " +"Python script that prints the date and time. Afterwards, " +"the :c:func:`Py_FinalizeEx` call shuts the interpreter down, followed by the " +"end of the program. In a real program, you may want to get the Python " +"script from another source, perhaps a text-editor routine, a file, or a " +"database. Getting the Python code from a file can better be done by using " +"the :c:func:`PyRun_SimpleFile` function, which saves you the trouble of " +"allocating memory space and loading the file contents." msgstr "" #: extending/embedding.rst:93 @@ -182,6 +208,82 @@ msgstr "" msgid "The code to run a function defined in a Python script is:" msgstr "" +#: extending/embedding.rst:143 +msgid "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"\n" +"int\n" +"main(int argc, char *argv[])\n" +"{\n" +" PyObject *pName, *pModule, *pFunc;\n" +" PyObject *pArgs, *pValue;\n" +" int i;\n" +"\n" +" if (argc < 3) {\n" +" fprintf(stderr,\"Usage: call pythonfile funcname [args]\\n\");\n" +" return 1;\n" +" }\n" +"\n" +" Py_Initialize();\n" +" pName = PyUnicode_DecodeFSDefault(argv[1]);\n" +" /* Error checking of pName left out */\n" +"\n" +" pModule = PyImport_Import(pName);\n" +" Py_DECREF(pName);\n" +"\n" +" if (pModule != NULL) {\n" +" pFunc = PyObject_GetAttrString(pModule, argv[2]);\n" +" /* pFunc is a new reference */\n" +"\n" +" if (pFunc && PyCallable_Check(pFunc)) {\n" +" pArgs = PyTuple_New(argc - 3);\n" +" for (i = 0; i < argc - 3; ++i) {\n" +" pValue = PyLong_FromLong(atoi(argv[i + 3]));\n" +" if (!pValue) {\n" +" Py_DECREF(pArgs);\n" +" Py_DECREF(pModule);\n" +" fprintf(stderr, \"Cannot convert argument\\n\");\n" +" return 1;\n" +" }\n" +" /* pValue reference stolen here: */\n" +" PyTuple_SetItem(pArgs, i, pValue);\n" +" }\n" +" pValue = PyObject_CallObject(pFunc, pArgs);\n" +" Py_DECREF(pArgs);\n" +" if (pValue != NULL) {\n" +" printf(\"Result of call: %ld\\n\", PyLong_AsLong(pValue));\n" +" Py_DECREF(pValue);\n" +" }\n" +" else {\n" +" Py_DECREF(pFunc);\n" +" Py_DECREF(pModule);\n" +" PyErr_Print();\n" +" fprintf(stderr,\"Call failed\\n\");\n" +" return 1;\n" +" }\n" +" }\n" +" else {\n" +" if (PyErr_Occurred())\n" +" PyErr_Print();\n" +" fprintf(stderr, \"Cannot find function \\\"%s\\\"\\n\", " +"argv[2]);\n" +" }\n" +" Py_XDECREF(pFunc);\n" +" Py_DECREF(pModule);\n" +" }\n" +" else {\n" +" PyErr_Print();\n" +" fprintf(stderr, \"Failed to load \\\"%s\\\"\\n\", argv[1]);\n" +" return 1;\n" +" }\n" +" if (Py_FinalizeEx() < 0) {\n" +" return 120;\n" +" }\n" +" return 0;\n" +"}\n" +msgstr "" + #: extending/embedding.rst:146 msgid "" "This code loads a Python script using ``argv[1]``, and calls the function " @@ -191,10 +293,27 @@ msgid "" "a Python script, such as:" msgstr "" +#: extending/embedding.rst:152 +msgid "" +"def multiply(a,b):\n" +" print(\"Will compute\", a, \"times\", b)\n" +" c = 0\n" +" for i in range(0, a):\n" +" c = c + b\n" +" return c" +msgstr "" + #: extending/embedding.rst:161 msgid "then the result should be:" msgstr "" +#: extending/embedding.rst:163 +msgid "" +"$ call multiply multiply 3 2\n" +"Will compute 3 times 2\n" +"Result of call: 6" +msgstr "" + #: extending/embedding.rst:169 msgid "" "Although the program is quite large for its functionality, most of the code " @@ -202,21 +321,44 @@ msgid "" "interesting part with respect to embedding Python starts with ::" msgstr "" +#: extending/embedding.rst:173 +msgid "" +"Py_Initialize();\n" +"pName = PyUnicode_DecodeFSDefault(argv[1]);\n" +"/* Error checking of pName left out */\n" +"pModule = PyImport_Import(pName);" +msgstr "" + #: extending/embedding.rst:178 msgid "" -"After initializing the interpreter, the script is loaded using :c:func:" -"`PyImport_Import`. This routine needs a Python string as its argument, " -"which is constructed using the :c:func:`PyUnicode_FromString` data " +"After initializing the interpreter, the script is loaded " +"using :c:func:`PyImport_Import`. This routine needs a Python string as its " +"argument, which is constructed using the :c:func:`PyUnicode_FromString` data " "conversion routine. ::" msgstr "" +#: extending/embedding.rst:183 +msgid "" +"pFunc = PyObject_GetAttrString(pModule, argv[2]);\n" +"/* pFunc is a new reference */\n" +"\n" +"if (pFunc && PyCallable_Check(pFunc)) {\n" +" ...\n" +"}\n" +"Py_XDECREF(pFunc);" +msgstr "" + #: extending/embedding.rst:191 msgid "" -"Once the script is loaded, the name we're looking for is retrieved using :c:" -"func:`PyObject_GetAttrString`. If the name exists, and the object returned " -"is callable, you can safely assume that it is a function. The program then " -"proceeds by constructing a tuple of arguments as normal. The call to the " -"Python function is then made with::" +"Once the script is loaded, the name we're looking for is retrieved " +"using :c:func:`PyObject_GetAttrString`. If the name exists, and the object " +"returned is callable, you can safely assume that it is a function. The " +"program then proceeds by constructing a tuple of arguments as normal. The " +"call to the Python function is then made with::" +msgstr "" + +#: extending/embedding.rst:197 +msgid "pValue = PyObject_CallObject(pFunc, pArgs);" msgstr "" #: extending/embedding.rst:199 @@ -242,12 +384,49 @@ msgid "" "like you would write a normal Python extension. For example::" msgstr "" +#: extending/embedding.rst:218 +msgid "" +"static int numargs=0;\n" +"\n" +"/* Return the number of arguments of the application command line */\n" +"static PyObject*\n" +"emb_numargs(PyObject *self, PyObject *args)\n" +"{\n" +" if(!PyArg_ParseTuple(args, \":numargs\"))\n" +" return NULL;\n" +" return PyLong_FromLong(numargs);\n" +"}\n" +"\n" +"static PyMethodDef EmbMethods[] = {\n" +" {\"numargs\", emb_numargs, METH_VARARGS,\n" +" \"Return the number of arguments received by the process.\"},\n" +" {NULL, NULL, 0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef EmbModule = {\n" +" PyModuleDef_HEAD_INIT, \"emb\", NULL, -1, EmbMethods,\n" +" NULL, NULL, NULL, NULL\n" +"};\n" +"\n" +"static PyObject*\n" +"PyInit_emb(void)\n" +"{\n" +" return PyModule_Create(&EmbModule);\n" +"}" +msgstr "" + #: extending/embedding.rst:246 msgid "" "Insert the above code just above the :c:func:`main` function. Also, insert " "the following two statements before the call to :c:func:`Py_Initialize`::" msgstr "" +#: extending/embedding.rst:249 +msgid "" +"numargs = argc;\n" +"PyImport_AppendInittab(\"emb\", &PyInit_emb);" +msgstr "" + #: extending/embedding.rst:252 msgid "" "These two lines initialize the ``numargs`` variable, and make the :func:`!" @@ -255,6 +434,12 @@ msgid "" "these extensions, the Python script can do things like" msgstr "" +#: extending/embedding.rst:256 +msgid "" +"import emb\n" +"print(\"Number of arguments\", emb.numargs())" +msgstr "" + #: extending/embedding.rst:261 msgid "" "In a real application, the methods will expose an API of the application to " @@ -288,8 +473,8 @@ msgstr "" #: extending/embedding.rst:290 msgid "" -"To find out the required compiler and linker flags, you can execute the :" -"file:`python{X.Y}-config` script which is generated as part of the " +"To find out the required compiler and linker flags, you can execute " +"the :file:`python{X.Y}-config` script which is generated as part of the " "installation process (a :file:`python3-config` script may also be " "available). This script has several options, of which the following will be " "directly useful to you:" @@ -301,12 +486,26 @@ msgid "" "compiling:" msgstr "" +#: extending/embedding.rst:299 +msgid "" +"$ /opt/bin/python3.11-config --cflags\n" +"-I/opt/include/python3.11 -I/opt/include/python3.11 -Wsign-compare -DNDEBUG " +"-g -fwrapv -O3 -Wall" +msgstr "" + #: extending/embedding.rst:304 msgid "" "``pythonX.Y-config --ldflags --embed`` will give you the recommended flags " "when linking:" msgstr "" +#: extending/embedding.rst:307 +msgid "" +"$ /opt/bin/python3.11-config --ldflags --embed\n" +"-L/opt/lib/python3.11/config-3.11-x86_64-linux-gnu -L/opt/lib -lpython3.11 " +"-lpthread -ldl -lutil -lm" +msgstr "" + #: extending/embedding.rst:313 msgid "" "To avoid confusion between several Python installations (and especially " @@ -320,9 +519,18 @@ msgid "" "If this procedure doesn't work for you (it is not guaranteed to work for all " "Unix-like platforms; however, we welcome :ref:`bug reports `) you will have to read your system's documentation about dynamic " -"linking and/or examine Python's :file:`Makefile` (use :func:`sysconfig." -"get_makefile_filename` to find its location) and compilation options. In " -"this case, the :mod:`sysconfig` module is a useful tool to programmatically " -"extract the configuration values that you will want to combine together. " -"For example:" +"linking and/or examine Python's :file:`Makefile` " +"(use :func:`sysconfig.get_makefile_filename` to find its location) and " +"compilation options. In this case, the :mod:`sysconfig` module is a useful " +"tool to programmatically extract the configuration values that you will want " +"to combine together. For example:" +msgstr "" + +#: extending/embedding.rst:327 +msgid "" +">>> import sysconfig\n" +">>> sysconfig.get_config_var('LIBS')\n" +"'-lpthread -ldl -lutil'\n" +">>> sysconfig.get_config_var('LINKFORSHARED')\n" +"'-Xlinker -export-dynamic'" msgstr "" diff --git a/extending/extending.po b/extending/extending.po index d543cae9..84a192b5 100644 --- a/extending/extending.po +++ b/extending/extending.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -68,18 +69,30 @@ msgid "" "this function to be callable from Python as follows:" msgstr "" +#: extending/extending.rst:48 +msgid "" +">>> import spam\n" +">>> status = spam.system(\"ls -l\")" +msgstr "" + #: extending/extending.rst:53 msgid "" "Begin by creating a file :file:`spammodule.c`. (Historically, if a module " -"is called ``spam``, the C file containing its implementation is called :file:" -"`spammodule.c`; if the module name is very long, like ``spammify``, the " -"module name can be just :file:`spammify.c`.)" +"is called ``spam``, the C file containing its implementation is " +"called :file:`spammodule.c`; if the module name is very long, like " +"``spammify``, the module name can be just :file:`spammify.c`.)" msgstr "" #: extending/extending.rst:58 msgid "The first two lines of our file can be::" msgstr "" +#: extending/extending.rst:60 +msgid "" +"#define PY_SSIZE_T_CLEAN\n" +"#include " +msgstr "" + #: extending/extending.rst:63 msgid "" "which pulls in the Python API (you can add a comment describing the purpose " @@ -103,11 +116,11 @@ msgstr "" msgid "" "All user-visible symbols defined by :file:`Python.h` have a prefix of ``Py`` " "or ``PY``, except those defined in standard header files. For convenience, " -"and since they are used extensively by the Python interpreter, ``\"Python." -"h\"`` includes a few standard header files: ````, ````, " -"````, and ````. If the latter header file does not exist " -"on your system, it declares the functions :c:func:`malloc`, :c:func:`free` " -"and :c:func:`realloc` directly." +"and since they are used extensively by the Python interpreter, " +"``\"Python.h\"`` includes a few standard header files: ````, " +"````, ````, and ````. If the latter header " +"file does not exist on your system, it declares the " +"functions :c:func:`malloc`, :c:func:`free` and :c:func:`realloc` directly." msgstr "" #: extending/extending.rst:83 @@ -117,6 +130,21 @@ msgid "" "(we'll see shortly how it ends up being called)::" msgstr "" +#: extending/extending.rst:87 +msgid "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *args)\n" +"{\n" +" const char *command;\n" +" int sts;\n" +"\n" +" if (!PyArg_ParseTuple(args, \"s\", &command))\n" +" return NULL;\n" +" sts = system(command);\n" +" return PyLong_FromLong(sts);\n" +"}" +msgstr "" + #: extending/extending.rst:99 msgid "" "There is a straightforward translation from the argument list in Python (for " @@ -188,19 +216,19 @@ msgstr "" msgid "" "Another useful function is :c:func:`PyErr_SetFromErrno`, which only takes an " "exception argument and constructs the associated value by inspection of the " -"global variable :c:data:`errno`. The most general function is :c:func:" -"`PyErr_SetObject`, which takes two object arguments, the exception and its " -"associated value. You don't need to :c:func:`Py_INCREF` the objects passed " -"to any of these functions." +"global variable :c:data:`errno`. The most general function " +"is :c:func:`PyErr_SetObject`, which takes two object arguments, the " +"exception and its associated value. You don't need to :c:func:`Py_INCREF` " +"the objects passed to any of these functions." msgstr "" #: extending/extending.rst:152 msgid "" -"You can test non-destructively whether an exception has been set with :c:" -"func:`PyErr_Occurred`. This returns the current exception object, or " -"``NULL`` if no exception has occurred. You normally don't need to call :c:" -"func:`PyErr_Occurred` to see whether an error occurred in a function call, " -"since you should be able to tell from the return value." +"You can test non-destructively whether an exception has been set " +"with :c:func:`PyErr_Occurred`. This returns the current exception object, " +"or ``NULL`` if no exception has occurred. You normally don't need to " +"call :c:func:`PyErr_Occurred` to see whether an error occurred in a function " +"call, since you should be able to tell from the return value." msgstr "" #: extending/extending.rst:158 @@ -237,10 +265,11 @@ msgstr "" #: extending/extending.rst:180 msgid "" "Every failing :c:func:`malloc` call must be turned into an exception --- the " -"direct caller of :c:func:`malloc` (or :c:func:`realloc`) must call :c:func:" -"`PyErr_NoMemory` and return a failure indicator itself. All the object-" -"creating functions (for example, :c:func:`PyLong_FromLong`) already do this, " -"so this note is only relevant to those who call :c:func:`malloc` directly." +"direct caller of :c:func:`malloc` (or :c:func:`realloc`) must " +"call :c:func:`PyErr_NoMemory` and return a failure indicator itself. All " +"the object-creating functions (for example, :c:func:`PyLong_FromLong`) " +"already do this, so this note is only relevant to those who " +"call :c:func:`malloc` directly." msgstr "" #: extending/extending.rst:186 @@ -253,8 +282,8 @@ msgstr "" #: extending/extending.rst:190 msgid "" -"Finally, be careful to clean up garbage (by making :c:func:`Py_XDECREF` or :" -"c:func:`Py_DECREF` calls for objects you have already created) when you " +"Finally, be careful to clean up garbage (by making :c:func:`Py_XDECREF` " +"or :c:func:`Py_DECREF` calls for objects you have already created) when you " "return an error indicator!" msgstr "" @@ -264,11 +293,12 @@ msgid "" "predeclared C objects corresponding to all built-in Python exceptions, such " "as :c:data:`PyExc_ZeroDivisionError`, which you can use directly. Of course, " "you should choose exceptions wisely --- don't use :c:data:`PyExc_TypeError` " -"to mean that a file couldn't be opened (that should probably be :c:data:" -"`PyExc_OSError`). If something's wrong with the argument list, the :c:func:" -"`PyArg_ParseTuple` function usually raises :c:data:`PyExc_TypeError`. If " -"you have an argument whose value must be in a particular range or must " -"satisfy other conditions, :c:data:`PyExc_ValueError` is appropriate." +"to mean that a file couldn't be opened (that should probably " +"be :c:data:`PyExc_OSError`). If something's wrong with the argument list, " +"the :c:func:`PyArg_ParseTuple` function usually " +"raises :c:data:`PyExc_TypeError`. If you have an argument whose value must " +"be in a particular range or must satisfy other " +"conditions, :c:data:`PyExc_ValueError` is appropriate." msgstr "" #: extending/extending.rst:204 @@ -277,12 +307,40 @@ msgid "" "you usually declare a static object variable at the beginning of your file::" msgstr "" +#: extending/extending.rst:207 +msgid "static PyObject *SpamError;" +msgstr "" + #: extending/extending.rst:209 msgid "" "and initialize it in your module's initialization function (:c:func:`!" "PyInit_spam`) with an exception object::" msgstr "" +#: extending/extending.rst:212 +msgid "" +"PyMODINIT_FUNC\n" +"PyInit_spam(void)\n" +"{\n" +" PyObject *m;\n" +"\n" +" m = PyModule_Create(&spammodule);\n" +" if (m == NULL)\n" +" return NULL;\n" +"\n" +" SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);\n" +" Py_XINCREF(SpamError);\n" +" if (PyModule_AddObject(m, \"error\", SpamError) < 0) {\n" +" Py_XDECREF(SpamError);\n" +" Py_CLEAR(SpamError);\n" +" Py_DECREF(m);\n" +" return NULL;\n" +" }\n" +"\n" +" return m;\n" +"}" +msgstr "" + #: extending/extending.rst:233 msgid "" "Note that the Python name for the exception object is :exc:`!spam.error`. " @@ -314,6 +372,25 @@ msgid "" "using a call to :c:func:`PyErr_SetString` as shown below::" msgstr "" +#: extending/extending.rst:251 +msgid "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *args)\n" +"{\n" +" const char *command;\n" +" int sts;\n" +"\n" +" if (!PyArg_ParseTuple(args, \"s\", &command))\n" +" return NULL;\n" +" sts = system(command);\n" +" if (sts < 0) {\n" +" PyErr_SetString(SpamError, \"System command failed\");\n" +" return NULL;\n" +" }\n" +" return PyLong_FromLong(sts);\n" +"}" +msgstr "" + #: extending/extending.rst:271 msgid "Back to the Example" msgstr "" @@ -324,6 +401,12 @@ msgid "" "this statement::" msgstr "" +#: extending/extending.rst:276 +msgid "" +"if (!PyArg_ParseTuple(args, \"s\", &command))\n" +" return NULL;" +msgstr "" + #: extending/extending.rst:279 msgid "" "It returns ``NULL`` (the error indicator for functions returning object " @@ -341,11 +424,19 @@ msgid "" "it the string we just got from :c:func:`PyArg_ParseTuple`::" msgstr "" +#: extending/extending.rst:290 +msgid "sts = system(command);" +msgstr "" + #: extending/extending.rst:292 msgid "" "Our :func:`!spam.system` function must return the value of :c:data:`!sts` as " -"a Python object. This is done using the function :c:func:" -"`PyLong_FromLong`. ::" +"a Python object. This is done using the " +"function :c:func:`PyLong_FromLong`. ::" +msgstr "" + +#: extending/extending.rst:295 +msgid "return PyLong_FromLong(sts);" msgstr "" #: extending/extending.rst:297 @@ -358,8 +449,14 @@ msgstr "" msgid "" "If you have a C function that returns no useful argument (a function " "returning :c:expr:`void`), the corresponding Python function must return " -"``None``. You need this idiom to do so (which is implemented by the :c:" -"macro:`Py_RETURN_NONE` macro)::" +"``None``. You need this idiom to do so (which is implemented by " +"the :c:macro:`Py_RETURN_NONE` macro)::" +msgstr "" + +#: extending/extending.rst:305 +msgid "" +"Py_INCREF(Py_None);\n" +"return Py_None;" msgstr "" #: extending/extending.rst:308 @@ -379,6 +476,17 @@ msgid "" "programs. First, we need to list its name and address in a \"method table\"::" msgstr "" +#: extending/extending.rst:321 +msgid "" +"static PyMethodDef SpamMethods[] = {\n" +" ...\n" +" {\"system\", spam_system, METH_VARARGS,\n" +" \"Execute a shell command.\"},\n" +" ...\n" +" {NULL, NULL, 0, NULL} /* Sentinel */\n" +"};" +msgstr "" + #: extending/extending.rst:329 msgid "" "Note the third entry (``METH_VARARGS``). This is a flag telling the " @@ -391,8 +499,9 @@ msgstr "" #: extending/extending.rst:334 msgid "" "When using only ``METH_VARARGS``, the function should expect the Python-" -"level parameters to be passed in as a tuple acceptable for parsing via :c:" -"func:`PyArg_ParseTuple`; more information on this function is provided below." +"level parameters to be passed in as a tuple acceptable for parsing " +"via :c:func:`PyArg_ParseTuple`; more information on this function is " +"provided below." msgstr "" #: extending/extending.rst:338 @@ -409,12 +518,33 @@ msgid "" "The method table must be referenced in the module definition structure::" msgstr "" +#: extending/extending.rst:346 +msgid "" +"static struct PyModuleDef spammodule = {\n" +" PyModuleDef_HEAD_INIT,\n" +" \"spam\", /* name of module */\n" +" spam_doc, /* module documentation, may be NULL */\n" +" -1, /* size of per-interpreter state of the module,\n" +" or -1 if the module keeps state in global variables. */\n" +" SpamMethods\n" +"};" +msgstr "" + #: extending/extending.rst:355 msgid "" "This structure, in turn, must be passed to the interpreter in the module's " -"initialization function. The initialization function must be named :c:func:" -"`!PyInit_name`, where *name* is the name of the module, and should be the " -"only non-\\ ``static`` item defined in the module file::" +"initialization function. The initialization function must be " +"named :c:func:`!PyInit_name`, where *name* is the name of the module, and " +"should be the only non-\\ ``static`` item defined in the module file::" +msgstr "" + +#: extending/extending.rst:360 +msgid "" +"PyMODINIT_FUNC\n" +"PyInit_spam(void)\n" +"{\n" +" return PyModule_Create(&spammodule);\n" +"}" msgstr "" #: extending/extending.rst:366 @@ -426,24 +556,66 @@ msgstr "" #: extending/extending.rst:370 msgid "" -"When the Python program imports module :mod:`!spam` for the first time, :c:" -"func:`!PyInit_spam` is called. (See below for comments about embedding " -"Python.) It calls :c:func:`PyModule_Create`, which returns a module object, " -"and inserts built-in function objects into the newly created module based " -"upon the table (an array of :c:type:`PyMethodDef` structures) found in the " -"module definition. :c:func:`PyModule_Create` returns a pointer to the module " -"object that it creates. It may abort with a fatal error for certain errors, " -"or return ``NULL`` if the module could not be initialized satisfactorily. " -"The init function must return the module object to its caller, so that it " -"then gets inserted into ``sys.modules``." +"When the Python program imports module :mod:`!spam` for the first " +"time, :c:func:`!PyInit_spam` is called. (See below for comments about " +"embedding Python.) It calls :c:func:`PyModule_Create`, which returns a " +"module object, and inserts built-in function objects into the newly created " +"module based upon the table (an array of :c:type:`PyMethodDef` structures) " +"found in the module definition. :c:func:`PyModule_Create` returns a pointer " +"to the module object that it creates. It may abort with a fatal error for " +"certain errors, or return ``NULL`` if the module could not be initialized " +"satisfactorily. The init function must return the module object to its " +"caller, so that it then gets inserted into ``sys.modules``." msgstr "" #: extending/extending.rst:381 msgid "" "When embedding Python, the :c:func:`!PyInit_spam` function is not called " "automatically unless there's an entry in the :c:data:`PyImport_Inittab` " -"table. To add the module to the initialization table, use :c:func:" -"`PyImport_AppendInittab`, optionally followed by an import of the module::" +"table. To add the module to the initialization table, " +"use :c:func:`PyImport_AppendInittab`, optionally followed by an import of " +"the module::" +msgstr "" + +#: extending/extending.rst:386 +msgid "" +"int\n" +"main(int argc, char *argv[])\n" +"{\n" +" wchar_t *program = Py_DecodeLocale(argv[0], NULL);\n" +" if (program == NULL) {\n" +" fprintf(stderr, \"Fatal error: cannot decode argv[0]\\n\");\n" +" exit(1);\n" +" }\n" +"\n" +" /* Add a built-in module, before Py_Initialize */\n" +" if (PyImport_AppendInittab(\"spam\", PyInit_spam) == -1) {\n" +" fprintf(stderr, \"Error: could not extend in-built modules " +"table\\n\");\n" +" exit(1);\n" +" }\n" +"\n" +" /* Pass argv[0] to the Python interpreter */\n" +" Py_SetProgramName(program);\n" +"\n" +" /* Initialize the Python interpreter. Required.\n" +" If this step fails, it will be a fatal error. */\n" +" Py_Initialize();\n" +"\n" +" /* Optionally import the module; alternatively,\n" +" import can be deferred until the embedded script\n" +" imports it. */\n" +" PyObject *pmodule = PyImport_ImportModule(\"spam\");\n" +" if (!pmodule) {\n" +" PyErr_Print();\n" +" fprintf(stderr, \"Error: could not import module 'spam'\\n\");\n" +" }\n" +"\n" +" ...\n" +"\n" +" PyMem_RawFree(program);\n" +" return 0;\n" +"}" msgstr "" #: extending/extending.rst:425 @@ -479,9 +651,10 @@ msgid "" "There are two more things to do before you can use your new extension: " "compiling and linking it with the Python system. If you use dynamic " "loading, the details may depend on the style of dynamic loading your system " -"uses; see the chapters about building extension modules (chapter :ref:" -"`building`) and additional information that pertains only to building on " -"Windows (chapter :ref:`building-on-windows`) for more information about this." +"uses; see the chapters about building extension modules " +"(chapter :ref:`building`) and additional information that pertains only to " +"building on Windows (chapter :ref:`building-on-windows`) for more " +"information about this." msgstr "" #: extending/extending.rst:455 @@ -494,6 +667,10 @@ msgid "" "line to the file :file:`Modules/Setup.local` describing your file:" msgstr "" +#: extending/extending.rst:462 +msgid "spam spammodule.o" +msgstr "" + #: extending/extending.rst:466 msgid "" "and rebuild the interpreter by running :program:`make` in the toplevel " @@ -509,6 +686,10 @@ msgid "" "listed on the line in the configuration file as well, for instance:" msgstr "" +#: extending/extending.rst:475 +msgid "spam spammodule.o -lX11" +msgstr "" + #: extending/extending.rst:483 msgid "Calling Python Functions from C" msgstr "" @@ -543,12 +724,39 @@ msgid "" "function might be part of a module definition::" msgstr "" +#: extending/extending.rst:506 +msgid "" +"static PyObject *my_callback = NULL;\n" +"\n" +"static PyObject *\n" +"my_set_callback(PyObject *dummy, PyObject *args)\n" +"{\n" +" PyObject *result = NULL;\n" +" PyObject *temp;\n" +"\n" +" if (PyArg_ParseTuple(args, \"O:set_callback\", &temp)) {\n" +" if (!PyCallable_Check(temp)) {\n" +" PyErr_SetString(PyExc_TypeError, \"parameter must be " +"callable\");\n" +" return NULL;\n" +" }\n" +" Py_XINCREF(temp); /* Add a reference to new callback */\n" +" Py_XDECREF(my_callback); /* Dispose of previous callback */\n" +" my_callback = temp; /* Remember new callback */\n" +" /* Boilerplate to return \"None\" */\n" +" Py_INCREF(Py_None);\n" +" result = Py_None;\n" +" }\n" +" return result;\n" +"}" +msgstr "" + #: extending/extending.rst:529 msgid "" -"This function must be registered with the interpreter using the :c:macro:" -"`METH_VARARGS` flag; this is described in section :ref:`methodtable`. The :" -"c:func:`PyArg_ParseTuple` function and its arguments are documented in " -"section :ref:`parsetuple`." +"This function must be registered with the interpreter using " +"the :c:macro:`METH_VARARGS` flag; this is described in " +"section :ref:`methodtable`. The :c:func:`PyArg_ParseTuple` function and its " +"arguments are documented in section :ref:`parsetuple`." msgstr "" #: extending/extending.rst:534 @@ -561,14 +769,29 @@ msgstr "" #: extending/extending.rst:541 msgid "" -"Later, when it is time to call the function, you call the C function :c:func:" -"`PyObject_CallObject`. This function has two arguments, both pointers to " -"arbitrary Python objects: the Python function, and the argument list. The " -"argument list must always be a tuple object, whose length is the number of " -"arguments. To call the Python function with no arguments, pass in ``NULL``, " -"or an empty tuple; to call it with one argument, pass a singleton tuple. :c:" -"func:`Py_BuildValue` returns a tuple when its format string consists of zero " -"or more format codes between parentheses. For example::" +"Later, when it is time to call the function, you call the C " +"function :c:func:`PyObject_CallObject`. This function has two arguments, " +"both pointers to arbitrary Python objects: the Python function, and the " +"argument list. The argument list must always be a tuple object, whose " +"length is the number of arguments. To call the Python function with no " +"arguments, pass in ``NULL``, or an empty tuple; to call it with one " +"argument, pass a singleton tuple. :c:func:`Py_BuildValue` returns a tuple " +"when its format string consists of zero or more format codes between " +"parentheses. For example::" +msgstr "" + +#: extending/extending.rst:550 +msgid "" +"int arg;\n" +"PyObject *arglist;\n" +"PyObject *result;\n" +"...\n" +"arg = 123;\n" +"...\n" +"/* Time to call the callback */\n" +"arglist = Py_BuildValue(\"(i)\", arg);\n" +"result = PyObject_CallObject(my_callback, arglist);\n" +"Py_DECREF(arglist);" msgstr "" #: extending/extending.rst:561 @@ -576,8 +799,9 @@ msgid "" ":c:func:`PyObject_CallObject` returns a Python object pointer: this is the " "return value of the Python function. :c:func:`PyObject_CallObject` is " "\"reference-count-neutral\" with respect to its arguments. In the example a " -"new tuple was created to serve as the argument list, which is :c:func:" -"`Py_DECREF`\\ -ed immediately after the :c:func:`PyObject_CallObject` call." +"new tuple was created to serve as the argument list, which " +"is :c:func:`Py_DECREF`\\ -ed immediately after " +"the :c:func:`PyObject_CallObject` call." msgstr "" #: extending/extending.rst:568 @@ -600,6 +824,14 @@ msgid "" "should be cleared by calling :c:func:`PyErr_Clear`. For example::" msgstr "" +#: extending/extending.rst:582 +msgid "" +"if (result == NULL)\n" +" return NULL; /* Pass error back */\n" +"...use result...\n" +"Py_DECREF(result);" +msgstr "" + #: extending/extending.rst:587 msgid "" "Depending on the desired interface to the Python callback function, you may " @@ -612,6 +844,19 @@ msgid "" "you want to pass an integral event code, you might use the following code::" msgstr "" +#: extending/extending.rst:596 +msgid "" +"PyObject *arglist;\n" +"...\n" +"arglist = Py_BuildValue(\"(l)\", eventcode);\n" +"result = PyObject_CallObject(my_callback, arglist);\n" +"Py_DECREF(arglist);\n" +"if (result == NULL)\n" +" return NULL; /* Pass error back */\n" +"/* Here maybe use the result */\n" +"Py_DECREF(result);" +msgstr "" + #: extending/extending.rst:606 msgid "" "Note the placement of ``Py_DECREF(arglist)`` immediately after the call, " @@ -622,9 +867,23 @@ msgstr "" #: extending/extending.rst:610 msgid "" -"You may also call a function with keyword arguments by using :c:func:" -"`PyObject_Call`, which supports arguments and keyword arguments. As in the " -"above example, we use :c:func:`Py_BuildValue` to construct the dictionary. ::" +"You may also call a function with keyword arguments by " +"using :c:func:`PyObject_Call`, which supports arguments and keyword " +"arguments. As in the above example, we use :c:func:`Py_BuildValue` to " +"construct the dictionary. ::" +msgstr "" + +#: extending/extending.rst:614 +msgid "" +"PyObject *dict;\n" +"...\n" +"dict = Py_BuildValue(\"{s:i}\", \"name\", val);\n" +"result = PyObject_Call(my_callback, NULL, dict);\n" +"Py_DECREF(dict);\n" +"if (result == NULL)\n" +" return NULL; /* Pass error back */\n" +"/* Here maybe use the result */\n" +"Py_DECREF(result);" msgstr "" #: extending/extending.rst:628 @@ -635,6 +894,10 @@ msgstr "" msgid "The :c:func:`PyArg_ParseTuple` function is declared as follows::" msgstr "" +#: extending/extending.rst:634 +msgid "int PyArg_ParseTuple(PyObject *arg, const char *format, ...);" +msgstr "" + #: extending/extending.rst:636 msgid "" "The *arg* argument must be a tuple object containing an argument list passed " @@ -662,6 +925,81 @@ msgstr "" msgid "Some example calls::" msgstr "" +#: extending/extending.rst:652 +msgid "" +"#define PY_SSIZE_T_CLEAN /* Make \"s#\" use Py_ssize_t rather than int. */\n" +"#include " +msgstr "" + +#: extending/extending.rst:657 +msgid "" +"int ok;\n" +"int i, j;\n" +"long k, l;\n" +"const char *s;\n" +"Py_ssize_t size;\n" +"\n" +"ok = PyArg_ParseTuple(args, \"\"); /* No arguments */\n" +" /* Python call: f() */" +msgstr "" + +#: extending/extending.rst:668 +msgid "" +"ok = PyArg_ParseTuple(args, \"s\", &s); /* A string */\n" +" /* Possible Python call: f('whoops!') */" +msgstr "" + +#: extending/extending.rst:673 +msgid "" +"ok = PyArg_ParseTuple(args, \"lls\", &k, &l, &s); /* Two longs and a string " +"*/\n" +" /* Possible Python call: f(1, 2, 'three') */" +msgstr "" + +#: extending/extending.rst:678 +msgid "" +"ok = PyArg_ParseTuple(args, \"(ii)s#\", &i, &j, &s, &size);\n" +" /* A pair of ints and a string, whose size is also returned */\n" +" /* Possible Python call: f((1, 2), 'three') */" +msgstr "" + +#: extending/extending.rst:684 +msgid "" +"{\n" +" const char *file;\n" +" const char *mode = \"r\";\n" +" int bufsize = 0;\n" +" ok = PyArg_ParseTuple(args, \"s|si\", &file, &mode, &bufsize);\n" +" /* A string, and optionally another string and an integer */\n" +" /* Possible Python calls:\n" +" f('spam')\n" +" f('spam', 'w')\n" +" f('spam', 'wb', 100000) */\n" +"}" +msgstr "" + +#: extending/extending.rst:698 +msgid "" +"{\n" +" int left, top, right, bottom, h, v;\n" +" ok = PyArg_ParseTuple(args, \"((ii)(ii))(ii)\",\n" +" &left, &top, &right, &bottom, &h, &v);\n" +" /* A rectangle and a point */\n" +" /* Possible Python call:\n" +" f(((0, 0), (400, 300)), (10, 10)) */\n" +"}" +msgstr "" + +#: extending/extending.rst:709 +msgid "" +"{\n" +" Py_complex c;\n" +" ok = PyArg_ParseTuple(args, \"D:myfunction\", &c);\n" +" /* a complex, also providing a function name for errors */\n" +" /* Possible Python call: myfunction(1+2j) */\n" +"}" +msgstr "" + #: extending/extending.rst:720 msgid "Keyword Parameters for Extension Functions" msgstr "" @@ -671,23 +1009,29 @@ msgid "" "The :c:func:`PyArg_ParseTupleAndKeywords` function is declared as follows::" msgstr "" +#: extending/extending.rst:726 +msgid "" +"int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict,\n" +" const char *format, char *kwlist[], ...);" +msgstr "" + #: extending/extending.rst:729 msgid "" -"The *arg* and *format* parameters are identical to those of the :c:func:" -"`PyArg_ParseTuple` function. The *kwdict* parameter is the dictionary of " -"keywords received as the third parameter from the Python runtime. The " -"*kwlist* parameter is a ``NULL``-terminated list of strings which identify " -"the parameters; the names are matched with the type information from " -"*format* from left to right. On success, :c:func:" -"`PyArg_ParseTupleAndKeywords` returns true, otherwise it returns false and " -"raises an appropriate exception." +"The *arg* and *format* parameters are identical to those of " +"the :c:func:`PyArg_ParseTuple` function. The *kwdict* parameter is the " +"dictionary of keywords received as the third parameter from the Python " +"runtime. The *kwlist* parameter is a ``NULL``-terminated list of strings " +"which identify the parameters; the names are matched with the type " +"information from *format* from left to right. On " +"success, :c:func:`PyArg_ParseTupleAndKeywords` returns true, otherwise it " +"returns false and raises an appropriate exception." msgstr "" #: extending/extending.rst:739 msgid "" "Nested tuples cannot be parsed when using keyword arguments! Keyword " -"parameters passed in which are not present in the *kwlist* will cause :exc:" -"`TypeError` to be raised." +"parameters passed in which are not present in the *kwlist* will " +"cause :exc:`TypeError` to be raised." msgstr "" #: extending/extending.rst:745 @@ -696,6 +1040,60 @@ msgid "" "Philbrick (philbrick@hks.com)::" msgstr "" +#: extending/extending.rst:748 +msgid "" +"#define PY_SSIZE_T_CLEAN /* Make \"s#\" use Py_ssize_t rather than int. */\n" +"#include \n" +"\n" +"static PyObject *\n" +"keywdarg_parrot(PyObject *self, PyObject *args, PyObject *keywds)\n" +"{\n" +" int voltage;\n" +" const char *state = \"a stiff\";\n" +" const char *action = \"voom\";\n" +" const char *type = \"Norwegian Blue\";\n" +"\n" +" static char *kwlist[] = {\"voltage\", \"state\", \"action\", \"type\", " +"NULL};\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, keywds, \"i|sss\", kwlist,\n" +" &voltage, &state, &action, &type))\n" +" return NULL;\n" +"\n" +" printf(\"-- This parrot wouldn't %s if you put %i Volts through it." +"\\n\",\n" +" action, voltage);\n" +" printf(\"-- Lovely plumage, the %s -- It's %s!\\n\", type, state);\n" +"\n" +" Py_RETURN_NONE;\n" +"}\n" +"\n" +"static PyMethodDef keywdarg_methods[] = {\n" +" /* The cast of the function is necessary since PyCFunction values\n" +" * only take two PyObject* parameters, and keywdarg_parrot() takes\n" +" * three.\n" +" */\n" +" {\"parrot\", (PyCFunction)(void(*)(void))keywdarg_parrot, METH_VARARGS | " +"METH_KEYWORDS,\n" +" \"Print a lovely skit to standard output.\"},\n" +" {NULL, NULL, 0, NULL} /* sentinel */\n" +"};\n" +"\n" +"static struct PyModuleDef keywdargmodule = {\n" +" PyModuleDef_HEAD_INIT,\n" +" \"keywdarg\",\n" +" NULL,\n" +" -1,\n" +" keywdarg_methods\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_keywdarg(void)\n" +"{\n" +" return PyModule_Create(&keywdargmodule);\n" +"}" +msgstr "" + #: extending/extending.rst:800 msgid "Building Arbitrary Values" msgstr "" @@ -706,12 +1104,16 @@ msgid "" "declared as follows::" msgstr "" +#: extending/extending.rst:805 +msgid "PyObject *Py_BuildValue(const char *format, ...);" +msgstr "" + #: extending/extending.rst:807 msgid "" -"It recognizes a set of format units similar to the ones recognized by :c:" -"func:`PyArg_ParseTuple`, but the arguments (which are input to the function, " -"not output) must not be pointers, just values. It returns a new Python " -"object, suitable for returning from a C function called from Python." +"It recognizes a set of format units similar to the ones recognized " +"by :c:func:`PyArg_ParseTuple`, but the arguments (which are input to the " +"function, not output) must not be pointers, just values. It returns a new " +"Python object, suitable for returning from a C function called from Python." msgstr "" #: extending/extending.rst:812 @@ -731,6 +1133,27 @@ msgid "" "Examples (to the left the call, to the right the resulting Python value):" msgstr "" +#: extending/extending.rst:822 +msgid "" +"Py_BuildValue(\"\") None\n" +"Py_BuildValue(\"i\", 123) 123\n" +"Py_BuildValue(\"iii\", 123, 456, 789) (123, 456, 789)\n" +"Py_BuildValue(\"s\", \"hello\") 'hello'\n" +"Py_BuildValue(\"y\", \"hello\") b'hello'\n" +"Py_BuildValue(\"ss\", \"hello\", \"world\") ('hello', 'world')\n" +"Py_BuildValue(\"s#\", \"hello\", 4) 'hell'\n" +"Py_BuildValue(\"y#\", \"hello\", 4) b'hell'\n" +"Py_BuildValue(\"()\") ()\n" +"Py_BuildValue(\"(i)\", 123) (123,)\n" +"Py_BuildValue(\"(ii)\", 123, 456) (123, 456)\n" +"Py_BuildValue(\"(i,i)\", 123, 456) (123, 456)\n" +"Py_BuildValue(\"[i,i]\", 123, 456) [123, 456]\n" +"Py_BuildValue(\"{s:i,s:i}\",\n" +" \"abc\", 123, \"def\", 456) {'abc': 123, 'def': 456}\n" +"Py_BuildValue(\"((ii)(ii)) (ii)\",\n" +" 1, 2, 3, 4, 5, 6) (((1, 2), (3, 4)), (5, 6))" +msgstr "" + #: extending/extending.rst:846 msgid "Reference Counts" msgstr "" @@ -747,16 +1170,16 @@ msgstr "" #: extending/extending.rst:854 msgid "" "Every block of memory allocated with :c:func:`malloc` should eventually be " -"returned to the pool of available memory by exactly one call to :c:func:" -"`free`. It is important to call :c:func:`free` at the right time. If a " -"block's address is forgotten but :c:func:`free` is not called for it, the " -"memory it occupies cannot be reused until the program terminates. This is " -"called a :dfn:`memory leak`. On the other hand, if a program calls :c:func:" -"`free` for a block and then continues to use the block, it creates a " -"conflict with re-use of the block through another :c:func:`malloc` call. " -"This is called :dfn:`using freed memory`. It has the same bad consequences " -"as referencing uninitialized data --- core dumps, wrong results, mysterious " -"crashes." +"returned to the pool of available memory by exactly one call " +"to :c:func:`free`. It is important to call :c:func:`free` at the right " +"time. If a block's address is forgotten but :c:func:`free` is not called " +"for it, the memory it occupies cannot be reused until the program " +"terminates. This is called a :dfn:`memory leak`. On the other hand, if a " +"program calls :c:func:`free` for a block and then continues to use the " +"block, it creates a conflict with reuse of the block through " +"another :c:func:`malloc` call. This is called :dfn:`using freed memory`. It " +"has the same bad consequences as referencing uninitialized data --- core " +"dumps, wrong results, mysterious crashes." msgstr "" #: extending/extending.rst:865 @@ -820,9 +1243,9 @@ msgstr "" #: extending/extending.rst:909 msgid "" "The cycle detector is able to detect garbage cycles and can reclaim them. " -"The :mod:`gc` module exposes a way to run the detector (the :func:`~gc." -"collect` function), as well as configuration interfaces and the ability to " -"disable the detector at runtime." +"The :mod:`gc` module exposes a way to run the detector " +"(the :func:`~gc.collect` function), as well as configuration interfaces and " +"the ability to disable the detector at runtime." msgstr "" #: extending/extending.rst:918 @@ -832,12 +1255,12 @@ msgstr "" #: extending/extending.rst:920 msgid "" "There are two macros, ``Py_INCREF(x)`` and ``Py_DECREF(x)``, which handle " -"the incrementing and decrementing of the reference count. :c:func:" -"`Py_DECREF` also frees the object when the count reaches zero. For " -"flexibility, it doesn't call :c:func:`free` directly --- rather, it makes a " -"call through a function pointer in the object's :dfn:`type object`. For " -"this purpose (and others), every object also contains a pointer to its type " -"object." +"the incrementing and decrementing of the reference " +"count. :c:func:`Py_DECREF` also frees the object when the count reaches " +"zero. For flexibility, it doesn't call :c:func:`free` directly --- rather, " +"it makes a call through a function pointer in the object's :dfn:`type " +"object`. For this purpose (and others), every object also contains a " +"pointer to its type object." msgstr "" #: extending/extending.rst:927 @@ -875,11 +1298,11 @@ msgstr "" #: extending/extending.rst:950 msgid "" -"A borrowed reference can be changed into an owned reference by calling :c:" -"func:`Py_INCREF`. This does not affect the status of the owner from which " -"the reference was borrowed --- it creates a new owned reference, and gives " -"full owner responsibilities (the new owner must dispose of the reference " -"properly, as well as the previous owner)." +"A borrowed reference can be changed into an owned reference by " +"calling :c:func:`Py_INCREF`. This does not affect the status of the owner " +"from which the reference was borrowed --- it creates a new owned reference, " +"and gives full owner responsibilities (the new owner must dispose of the " +"reference properly, as well as the previous owner)." msgstr "" #: extending/extending.rst:960 @@ -899,20 +1322,20 @@ msgid "" "the reference. In particular, all functions whose function it is to create " "a new object, such as :c:func:`PyLong_FromLong` and :c:func:`Py_BuildValue`, " "pass ownership to the receiver. Even if the object is not actually new, you " -"still receive ownership of a new reference to that object. For instance, :c:" -"func:`PyLong_FromLong` maintains a cache of popular values and can return a " -"reference to a cached item." +"still receive ownership of a new reference to that object. For " +"instance, :c:func:`PyLong_FromLong` maintains a cache of popular values and " +"can return a reference to a cached item." msgstr "" #: extending/extending.rst:974 msgid "" "Many functions that extract objects from other objects also transfer " -"ownership with the reference, for instance :c:func:" -"`PyObject_GetAttrString`. The picture is less clear, here, however, since a " -"few common routines are exceptions: :c:func:`PyTuple_GetItem`, :c:func:" -"`PyList_GetItem`, :c:func:`PyDict_GetItem`, and :c:func:" -"`PyDict_GetItemString` all return references that you borrow from the tuple, " -"list or dictionary." +"ownership with the reference, for " +"instance :c:func:`PyObject_GetAttrString`. The picture is less clear, here, " +"however, since a few common routines are " +"exceptions: :c:func:`PyTuple_GetItem`, :c:func:`PyList_GetItem`, :c:func:`PyDict_GetItem`, " +"and :c:func:`PyDict_GetItemString` all return references that you borrow " +"from the tuple, list or dictionary." msgstr "" #: extending/extending.rst:981 @@ -927,10 +1350,11 @@ msgid "" "When you pass an object reference into another function, in general, the " "function borrows the reference from you --- if it needs to store it, it will " "use :c:func:`Py_INCREF` to become an independent owner. There are exactly " -"two important exceptions to this rule: :c:func:`PyTuple_SetItem` and :c:func:" -"`PyList_SetItem`. These functions take over ownership of the item passed to " -"them --- even if they fail! (Note that :c:func:`PyDict_SetItem` and friends " -"don't take over ownership --- they are \"normal.\")" +"two important exceptions to this rule: :c:func:`PyTuple_SetItem` " +"and :c:func:`PyList_SetItem`. These functions take over ownership of the " +"item passed to them --- even if they fail! (Note " +"that :c:func:`PyDict_SetItem` and friends don't take over ownership --- they " +"are \"normal.\")" msgstr "" #: extending/extending.rst:993 @@ -968,6 +1392,18 @@ msgid "" "instance::" msgstr "" +#: extending/extending.rst:1016 +msgid "" +"void\n" +"bug(PyObject *list)\n" +"{\n" +" PyObject *item = PyList_GetItem(list, 0);\n" +"\n" +" PyList_SetItem(list, 1, PyLong_FromLong(0L));\n" +" PyObject_Print(item, stdout, 0); /* BUG! */\n" +"}" +msgstr "" + #: extending/extending.rst:1025 msgid "" "This function first borrows a reference to ``list[0]``, then replaces " @@ -1002,6 +1438,20 @@ msgid "" "increment the reference count. The correct version of the function reads::" msgstr "" +#: extending/extending.rst:1047 +msgid "" +"void\n" +"no_bug(PyObject *list)\n" +"{\n" +" PyObject *item = PyList_GetItem(list, 0);\n" +"\n" +" Py_INCREF(item);\n" +" PyList_SetItem(list, 1, PyLong_FromLong(0L));\n" +" PyObject_Print(item, stdout, 0);\n" +" Py_DECREF(item);\n" +"}" +msgstr "" + #: extending/extending.rst:1058 msgid "" "This is a true story. An older version of Python contained variants of this " @@ -1022,6 +1472,19 @@ msgid "" "previous one::" msgstr "" +#: extending/extending.rst:1071 +msgid "" +"void\n" +"bug(PyObject *list)\n" +"{\n" +" PyObject *item = PyList_GetItem(list, 0);\n" +" Py_BEGIN_ALLOW_THREADS\n" +" ...some blocking I/O call...\n" +" Py_END_ALLOW_THREADS\n" +" PyObject_Print(item, stdout, 0); /* BUG! */\n" +"}" +msgstr "" + #: extending/extending.rst:1085 msgid "NULL Pointers" msgstr "" @@ -1048,8 +1511,8 @@ msgstr "" #: extending/extending.rst:1099 msgid "" "The macros :c:func:`Py_INCREF` and :c:func:`Py_DECREF` do not check for " -"``NULL`` pointers --- however, their variants :c:func:`Py_XINCREF` and :c:" -"func:`Py_XDECREF` do." +"``NULL`` pointers --- however, their variants :c:func:`Py_XINCREF` " +"and :c:func:`Py_XDECREF` do." msgstr "" #: extending/extending.rst:1103 @@ -1170,6 +1633,10 @@ msgid "" "following this convention::" msgstr "" +#: extending/extending.rst:1196 +msgid "modulename.attributename" +msgstr "" + #: extending/extending.rst:1198 msgid "" "The convenience function :c:func:`PyCapsule_Import` makes it easy to load a " @@ -1206,18 +1673,52 @@ msgid "" "``static`` like everything else::" msgstr "" +#: extending/extending.rst:1221 +msgid "" +"static int\n" +"PySpam_System(const char *command)\n" +"{\n" +" return system(command);\n" +"}" +msgstr "" + #: extending/extending.rst:1227 msgid "The function :c:func:`!spam_system` is modified in a trivial way::" msgstr "" +#: extending/extending.rst:1229 +msgid "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *args)\n" +"{\n" +" const char *command;\n" +" int sts;\n" +"\n" +" if (!PyArg_ParseTuple(args, \"s\", &command))\n" +" return NULL;\n" +" sts = PySpam_System(command);\n" +" return PyLong_FromLong(sts);\n" +"}" +msgstr "" + #: extending/extending.rst:1241 msgid "In the beginning of the module, right after the line ::" msgstr "" +#: extending/extending.rst:1243 +msgid "#include " +msgstr "" + #: extending/extending.rst:1245 msgid "two more lines must be added::" msgstr "" +#: extending/extending.rst:1247 +msgid "" +"#define SPAM_MODULE\n" +"#include \"spammodule.h\"" +msgstr "" + #: extending/extending.rst:1250 msgid "" "The ``#define`` is used to tell the header file that it is being included in " @@ -1226,6 +1727,36 @@ msgid "" "array::" msgstr "" +#: extending/extending.rst:1254 +msgid "" +"PyMODINIT_FUNC\n" +"PyInit_spam(void)\n" +"{\n" +" PyObject *m;\n" +" static void *PySpam_API[PySpam_API_pointers];\n" +" PyObject *c_api_object;\n" +"\n" +" m = PyModule_Create(&spammodule);\n" +" if (m == NULL)\n" +" return NULL;\n" +"\n" +" /* Initialize the C API pointer array */\n" +" PySpam_API[PySpam_System_NUM] = (void *)PySpam_System;\n" +"\n" +" /* Create a Capsule containing the API pointer array's address */\n" +" c_api_object = PyCapsule_New((void *)PySpam_API, \"spam._C_API\", " +"NULL);\n" +"\n" +" if (PyModule_AddObject(m, \"_C_API\", c_api_object) < 0) {\n" +" Py_XDECREF(c_api_object);\n" +" Py_DECREF(m);\n" +" return NULL;\n" +" }\n" +"\n" +" return m;\n" +"}" +msgstr "" + #: extending/extending.rst:1280 msgid "" "Note that ``PySpam_API`` is declared ``static``; otherwise the pointer array " @@ -1238,11 +1769,80 @@ msgid "" "like this::" msgstr "" +#: extending/extending.rst:1286 +msgid "" +"#ifndef Py_SPAMMODULE_H\n" +"#define Py_SPAMMODULE_H\n" +"#ifdef __cplusplus\n" +"extern \"C\" {\n" +"#endif\n" +"\n" +"/* Header file for spammodule */\n" +"\n" +"/* C API functions */\n" +"#define PySpam_System_NUM 0\n" +"#define PySpam_System_RETURN int\n" +"#define PySpam_System_PROTO (const char *command)\n" +"\n" +"/* Total number of C API pointers */\n" +"#define PySpam_API_pointers 1\n" +"\n" +"\n" +"#ifdef SPAM_MODULE\n" +"/* This section is used when compiling spammodule.c */\n" +"\n" +"static PySpam_System_RETURN PySpam_System PySpam_System_PROTO;\n" +"\n" +"#else\n" +"/* This section is used in modules that use spammodule's API */\n" +"\n" +"static void **PySpam_API;\n" +"\n" +"#define PySpam_System \\\n" +" (*(PySpam_System_RETURN (*)PySpam_System_PROTO) " +"PySpam_API[PySpam_System_NUM])\n" +"\n" +"/* Return -1 on error, 0 on success.\n" +" * PyCapsule_Import will set an exception if there's an error.\n" +" */\n" +"static int\n" +"import_spam(void)\n" +"{\n" +" PySpam_API = (void **)PyCapsule_Import(\"spam._C_API\", 0);\n" +" return (PySpam_API != NULL) ? 0 : -1;\n" +"}\n" +"\n" +"#endif\n" +"\n" +"#ifdef __cplusplus\n" +"}\n" +"#endif\n" +"\n" +"#endif /* !defined(Py_SPAMMODULE_H) */" +msgstr "" + #: extending/extending.rst:1334 msgid "" -"All that a client module must do in order to have access to the function :c:" -"func:`!PySpam_System` is to call the function (or rather macro) :c:func:`!" -"import_spam` in its initialization function::" +"All that a client module must do in order to have access to the " +"function :c:func:`!PySpam_System` is to call the function (or rather " +"macro) :c:func:`!import_spam` in its initialization function::" +msgstr "" + +#: extending/extending.rst:1338 +msgid "" +"PyMODINIT_FUNC\n" +"PyInit_client(void)\n" +"{\n" +" PyObject *m;\n" +"\n" +" m = PyModule_Create(&clientmodule);\n" +" if (m == NULL)\n" +" return NULL;\n" +" if (import_spam() < 0)\n" +" return NULL;\n" +" /* additional initialization can happen here */\n" +" return m;\n" +"}" msgstr "" #: extending/extending.rst:1352 @@ -1268,8 +1868,8 @@ msgstr "" #: extending/extending.rst:1365 msgid "" -"An interface for this function already exists in the standard module :mod:" -"`os` --- it was chosen as a simple and straightforward example." +"An interface for this function already exists in the standard " +"module :mod:`os` --- it was chosen as a simple and straightforward example." msgstr "" #: extending/extending.rst:1368 diff --git a/extending/index.po b/extending/index.po index 0f854298..23f331d1 100644 --- a/extending/index.po +++ b/extending/index.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -42,8 +43,8 @@ msgstr "" #: extending/index.rst:21 msgid "" -"For a detailed description of the whole Python/C API, see the separate :ref:" -"`c-api-index`." +"For a detailed description of the whole Python/C API, see the " +"separate :ref:`c-api-index`." msgstr "" #: extending/index.rst:26 @@ -54,15 +55,16 @@ msgstr "" msgid "" "This guide only covers the basic tools for creating extensions provided as " "part of this version of CPython. Third party tools like `Cython `_, `cffi `_, `SWIG `_ and `Numba `_ offer both simpler and " -"more sophisticated approaches to creating C and C++ extensions for Python." +"cython.org/>`_, `cffi `_, `SWIG `_ and `Numba `_ offer both simpler " +"and more sophisticated approaches to creating C and C++ extensions for " +"Python." msgstr "" -#: extending/index.rst:40 +#: extending/index.rst:37 msgid "" -"`Python Packaging User Guide: Binary Extensions `_" +"`Python Packaging User Guide: Binary Extensions `_" msgstr "" #: extending/index.rst:38 diff --git a/extending/newtypes.po b/extending/newtypes.po index 4c117ccd..b6e43609 100644 --- a/extending/newtypes.po +++ b/extending/newtypes.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -32,6 +33,96 @@ msgid "" "in :ref:`debug builds ` omitted:" msgstr "" +#: extending/newtypes.rst:17 +msgid "" +"typedef struct _typeobject {\n" +" PyObject_VAR_HEAD\n" +" const char *tp_name; /* For printing, in format \".\" */\n" +" Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */\n" +"\n" +" /* Methods to implement standard operations */\n" +"\n" +" destructor tp_dealloc;\n" +" Py_ssize_t tp_vectorcall_offset;\n" +" getattrfunc tp_getattr;\n" +" setattrfunc tp_setattr;\n" +" PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)\n" +" or tp_reserved (Python 3) */\n" +" reprfunc tp_repr;\n" +"\n" +" /* Method suites for standard classes */\n" +"\n" +" PyNumberMethods *tp_as_number;\n" +" PySequenceMethods *tp_as_sequence;\n" +" PyMappingMethods *tp_as_mapping;\n" +"\n" +" /* More standard operations (here for binary compatibility) */\n" +"\n" +" hashfunc tp_hash;\n" +" ternaryfunc tp_call;\n" +" reprfunc tp_str;\n" +" getattrofunc tp_getattro;\n" +" setattrofunc tp_setattro;\n" +"\n" +" /* Functions to access object as input/output buffer */\n" +" PyBufferProcs *tp_as_buffer;\n" +"\n" +" /* Flags to define presence of optional/expanded features */\n" +" unsigned long tp_flags;\n" +"\n" +" const char *tp_doc; /* Documentation string */\n" +"\n" +" /* Assigned meaning in release 2.0 */\n" +" /* call function for all accessible objects */\n" +" traverseproc tp_traverse;\n" +"\n" +" /* delete references to contained objects */\n" +" inquiry tp_clear;\n" +"\n" +" /* Assigned meaning in release 2.1 */\n" +" /* rich comparisons */\n" +" richcmpfunc tp_richcompare;\n" +"\n" +" /* weak reference enabler */\n" +" Py_ssize_t tp_weaklistoffset;\n" +"\n" +" /* Iterators */\n" +" getiterfunc tp_iter;\n" +" iternextfunc tp_iternext;\n" +"\n" +" /* Attribute descriptor and subclassing stuff */\n" +" struct PyMethodDef *tp_methods;\n" +" struct PyMemberDef *tp_members;\n" +" struct PyGetSetDef *tp_getset;\n" +" // Strong reference on a heap type, borrowed reference on a static type\n" +" struct _typeobject *tp_base;\n" +" PyObject *tp_dict;\n" +" descrgetfunc tp_descr_get;\n" +" descrsetfunc tp_descr_set;\n" +" Py_ssize_t tp_dictoffset;\n" +" initproc tp_init;\n" +" allocfunc tp_alloc;\n" +" newfunc tp_new;\n" +" freefunc tp_free; /* Low-level free-memory routine */\n" +" inquiry tp_is_gc; /* For PyObject_IS_GC */\n" +" PyObject *tp_bases;\n" +" PyObject *tp_mro; /* method resolution order */\n" +" PyObject *tp_cache;\n" +" PyObject *tp_subclasses;\n" +" PyObject *tp_weaklist;\n" +" destructor tp_del;\n" +"\n" +" /* Type attribute cache version tag. Added in version 2.6 */\n" +" unsigned int tp_version_tag;\n" +"\n" +" destructor tp_finalize;\n" +" vectorcallfunc tp_vectorcall;\n" +"\n" +" /* bitset of which type-watchers care about this type */\n" +" unsigned char tp_watched;\n" +"} PyTypeObject;\n" +msgstr "" + #: extending/newtypes.rst:20 msgid "" "Now that's a *lot* of methods. Don't worry too much though -- if you have a " @@ -49,6 +140,10 @@ msgid "" "new type. ::" msgstr "" +#: extending/newtypes.rst:31 +msgid "const char *tp_name; /* For printing */" +msgstr "" + #: extending/newtypes.rst:33 msgid "" "The name of the type -- as mentioned in the previous chapter, this will " @@ -56,13 +151,21 @@ msgid "" "choose something that will be helpful in such a situation! ::" msgstr "" +#: extending/newtypes.rst:37 +msgid "Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */" +msgstr "" + #: extending/newtypes.rst:39 msgid "" "These fields tell the runtime how much memory to allocate when new objects " "of this type are created. Python has some built-in support for variable " -"length structures (think: strings, tuples) which is where the :c:member:" -"`~PyTypeObject.tp_itemsize` field comes in. This will be dealt with " -"later. ::" +"length structures (think: strings, tuples) which is where " +"the :c:member:`~PyTypeObject.tp_itemsize` field comes in. This will be " +"dealt with later. ::" +msgstr "" + +#: extending/newtypes.rst:44 +msgid "const char *tp_doc;" msgstr "" #: extending/newtypes.rst:46 @@ -81,6 +184,10 @@ msgstr "" msgid "Finalization and De-allocation" msgstr "" +#: extending/newtypes.rst:64 +msgid "destructor tp_dealloc;" +msgstr "" + #: extending/newtypes.rst:66 msgid "" "This function is called when the reference count of the instance of your " @@ -90,10 +197,32 @@ msgid "" "of this function::" msgstr "" +#: extending/newtypes.rst:72 +msgid "" +"static void\n" +"newdatatype_dealloc(newdatatypeobject *obj)\n" +"{\n" +" free(obj->obj_UnderlyingDatatypePtr);\n" +" Py_TYPE(obj)->tp_free((PyObject *)obj);\n" +"}" +msgstr "" + #: extending/newtypes.rst:79 msgid "" -"If your type supports garbage collection, the destructor should call :c:func:" -"`PyObject_GC_UnTrack` before clearing any member fields::" +"If your type supports garbage collection, the destructor should " +"call :c:func:`PyObject_GC_UnTrack` before clearing any member fields::" +msgstr "" + +#: extending/newtypes.rst:82 +msgid "" +"static void\n" +"newdatatype_dealloc(newdatatypeobject *obj)\n" +"{\n" +" PyObject_GC_UnTrack(obj);\n" +" Py_CLEAR(obj->other_obj);\n" +" ...\n" +" Py_TYPE(obj)->tp_free((PyObject *)obj);\n" +"}" msgstr "" #: extending/newtypes.rst:95 @@ -107,21 +236,52 @@ msgid "" "additional Python code to be executed may detect that an exception has been " "set. This can lead to misleading errors from the interpreter. The proper " "way to protect against this is to save a pending exception before performing " -"the unsafe action, and restoring it when done. This can be done using the :" -"c:func:`PyErr_Fetch` and :c:func:`PyErr_Restore` functions::" +"the unsafe action, and restoring it when done. This can be done using " +"the :c:func:`PyErr_Fetch` and :c:func:`PyErr_Restore` functions::" +msgstr "" + +#: extending/newtypes.rst:107 +msgid "" +"static void\n" +"my_dealloc(PyObject *obj)\n" +"{\n" +" MyObject *self = (MyObject *) obj;\n" +" PyObject *cbresult;\n" +"\n" +" if (self->my_callback != NULL) {\n" +" PyObject *err_type, *err_value, *err_traceback;\n" +"\n" +" /* This saves the current exception state */\n" +" PyErr_Fetch(&err_type, &err_value, &err_traceback);\n" +"\n" +" cbresult = PyObject_CallNoArgs(self->my_callback);\n" +" if (cbresult == NULL)\n" +" PyErr_WriteUnraisable(self->my_callback);\n" +" else\n" +" Py_DECREF(cbresult);\n" +"\n" +" /* This restores the saved exception state */\n" +" PyErr_Restore(err_type, err_value, err_traceback);\n" +"\n" +" Py_DECREF(self->my_callback);\n" +" }\n" +" Py_TYPE(obj)->tp_free((PyObject*)self);\n" +"}" msgstr "" #: extending/newtypes.rst:134 msgid "" "There are limitations to what you can safely do in a deallocator function. " -"First, if your type supports garbage collection (using :c:member:" -"`~PyTypeObject.tp_traverse` and/or :c:member:`~PyTypeObject.tp_clear`), some " -"of the object's members can have been cleared or finalized by the time :c:" -"member:`~PyTypeObject.tp_dealloc` is called. Second, in :c:member:" -"`~PyTypeObject.tp_dealloc`, your object is in an unstable state: its " -"reference count is equal to zero. Any call to a non-trivial object or API " -"(as in the example above) might end up calling :c:member:`~PyTypeObject." -"tp_dealloc` again, causing a double free and a crash." +"First, if your type supports garbage collection " +"(using :c:member:`~PyTypeObject.tp_traverse` and/" +"or :c:member:`~PyTypeObject.tp_clear`), some of the object's members can " +"have been cleared or finalized by the " +"time :c:member:`~PyTypeObject.tp_dealloc` is called. Second, " +"in :c:member:`~PyTypeObject.tp_dealloc`, your object is in an unstable " +"state: its reference count is equal to zero. Any call to a non-trivial " +"object or API (as in the example above) might end up " +"calling :c:member:`~PyTypeObject.tp_dealloc` again, causing a double free " +"and a crash." msgstr "" #: extending/newtypes.rst:143 @@ -142,8 +302,15 @@ msgstr "" #: extending/newtypes.rst:157 msgid "" "In Python, there are two ways to generate a textual representation of an " -"object: the :func:`repr` function, and the :func:`str` function. (The :func:" -"`print` function just calls :func:`str`.) These handlers are both optional." +"object: the :func:`repr` function, and the :func:`str` function. " +"(The :func:`print` function just calls :func:`str`.) These handlers are " +"both optional." +msgstr "" + +#: extending/newtypes.rst:163 +msgid "" +"reprfunc tp_repr;\n" +"reprfunc tp_str;" msgstr "" #: extending/newtypes.rst:166 @@ -153,28 +320,49 @@ msgid "" "a simple example::" msgstr "" +#: extending/newtypes.rst:170 +msgid "" +"static PyObject *\n" +"newdatatype_repr(newdatatypeobject *obj)\n" +"{\n" +" return PyUnicode_FromFormat(\"Repr-ified_newdatatype{{size:%d}}\",\n" +" obj->obj_UnderlyingDatatypePtr->size);\n" +"}" +msgstr "" + #: extending/newtypes.rst:177 msgid "" "If no :c:member:`~PyTypeObject.tp_repr` handler is specified, the " -"interpreter will supply a representation that uses the type's :c:member:" -"`~PyTypeObject.tp_name` and a uniquely identifying value for the object." +"interpreter will supply a representation that uses the " +"type's :c:member:`~PyTypeObject.tp_name` and a uniquely identifying value " +"for the object." msgstr "" #: extending/newtypes.rst:181 msgid "" -"The :c:member:`~PyTypeObject.tp_str` handler is to :func:`str` what the :c:" -"member:`~PyTypeObject.tp_repr` handler described above is to :func:`repr`; " -"that is, it is called when Python code calls :func:`str` on an instance of " -"your object. Its implementation is very similar to the :c:member:" -"`~PyTypeObject.tp_repr` function, but the resulting string is intended for " -"human consumption. If :c:member:`~PyTypeObject.tp_str` is not specified, " -"the :c:member:`~PyTypeObject.tp_repr` handler is used instead." +"The :c:member:`~PyTypeObject.tp_str` handler is to :func:`str` what " +"the :c:member:`~PyTypeObject.tp_repr` handler described above is " +"to :func:`repr`; that is, it is called when Python code calls :func:`str` on " +"an instance of your object. Its implementation is very similar to " +"the :c:member:`~PyTypeObject.tp_repr` function, but the resulting string is " +"intended for human consumption. If :c:member:`~PyTypeObject.tp_str` is not " +"specified, the :c:member:`~PyTypeObject.tp_repr` handler is used instead." msgstr "" #: extending/newtypes.rst:188 msgid "Here is a simple example::" msgstr "" +#: extending/newtypes.rst:190 +msgid "" +"static PyObject *\n" +"newdatatype_str(newdatatypeobject *obj)\n" +"{\n" +" return PyUnicode_FromFormat(\"Stringified_newdatatype{{size:%d}}\",\n" +" obj->obj_UnderlyingDatatypePtr->size);\n" +"}" +msgstr "" + #: extending/newtypes.rst:200 msgid "Attribute Management" msgstr "" @@ -193,9 +381,19 @@ msgstr "" msgid "" "Python supports two pairs of attribute handlers; a type that supports " "attributes only needs to implement the functions for one pair. The " -"difference is that one pair takes the name of the attribute as a :c:expr:" -"`char\\*`, while the other accepts a :c:expr:`PyObject*`. Each type can use " -"whichever pair makes more sense for the implementation's convenience. ::" +"difference is that one pair takes the name of the attribute as " +"a :c:expr:`char\\*`, while the other accepts a :c:expr:`PyObject*`. Each " +"type can use whichever pair makes more sense for the implementation's " +"convenience. ::" +msgstr "" + +#: extending/newtypes.rst:214 +msgid "" +"getattrfunc tp_getattr; /* char * version */\n" +"setattrfunc tp_setattr;\n" +"/* ... */\n" +"getattrofunc tp_getattro; /* PyObject * version */\n" +"setattrofunc tp_setattro;" msgstr "" #: extending/newtypes.rst:220 @@ -244,15 +442,23 @@ msgid "" "dictionary of the type object. Each descriptor controls access to one " "attribute of the instance object. Each of the tables is optional; if all " "three are ``NULL``, instances of the type will only have attributes that are " -"inherited from their base type, and should leave the :c:member:" -"`~PyTypeObject.tp_getattro` and :c:member:`~PyTypeObject.tp_setattro` fields " -"``NULL`` as well, allowing the base type to handle attributes." +"inherited from their base type, and should leave " +"the :c:member:`~PyTypeObject.tp_getattro` " +"and :c:member:`~PyTypeObject.tp_setattro` fields ``NULL`` as well, allowing " +"the base type to handle attributes." msgstr "" #: extending/newtypes.rst:253 msgid "The tables are declared as three fields of the type object::" msgstr "" +#: extending/newtypes.rst:255 +msgid "" +"struct PyMethodDef *tp_methods;\n" +"struct PyMemberDef *tp_members;\n" +"struct PyGetSetDef *tp_getset;" +msgstr "" + #: extending/newtypes.rst:259 msgid "" "If :c:member:`~PyTypeObject.tp_methods` is not ``NULL``, it must refer to an " @@ -260,12 +466,22 @@ msgid "" "instance of this structure::" msgstr "" +#: extending/newtypes.rst:263 +msgid "" +"typedef struct PyMethodDef {\n" +" const char *ml_name; /* method name */\n" +" PyCFunction ml_meth; /* implementation function */\n" +" int ml_flags; /* flags */\n" +" const char *ml_doc; /* docstring */\n" +"} PyMethodDef;" +msgstr "" + #: extending/newtypes.rst:270 msgid "" "One entry should be defined for each method provided by the type; no entries " "are needed for methods inherited from a base type. One additional entry is " -"needed at the end; it is a sentinel that marks the end of the array. The :c:" -"member:`~PyMethodDef.ml_name` field of the sentinel must be ``NULL``." +"needed at the end; it is a sentinel that marks the end of the array. " +"The :c:member:`~PyMethodDef.ml_name` field of the sentinel must be ``NULL``." msgstr "" #: extending/newtypes.rst:275 @@ -276,16 +492,27 @@ msgid "" "defined as::" msgstr "" +#: extending/newtypes.rst:279 +msgid "" +"typedef struct PyMemberDef {\n" +" const char *name;\n" +" int type;\n" +" int offset;\n" +" int flags;\n" +" const char *doc;\n" +"} PyMemberDef;" +msgstr "" + #: extending/newtypes.rst:287 msgid "" "For each entry in the table, a :term:`descriptor` will be constructed and " "added to the type which will be able to extract a value from the instance " "structure. The :c:member:`~PyMemberDef.type` field should contain a type " "code like :c:macro:`Py_T_INT` or :c:macro:`Py_T_DOUBLE`; the value will be " -"used to determine how to convert Python values to and from C values. The :c:" -"member:`~PyMemberDef.flags` field is used to store flags which control how " -"the attribute can be accessed: you can set it to :c:macro:`Py_READONLY` to " -"prevent Python code from setting it." +"used to determine how to convert Python values to and from C values. " +"The :c:member:`~PyMemberDef.flags` field is used to store flags which " +"control how the attribute can be accessed: you can set it " +"to :c:macro:`Py_READONLY` to prevent Python code from setting it." msgstr "" #: extending/newtypes.rst:295 @@ -294,8 +521,8 @@ msgid "" "table to build descriptors that are used at runtime is that any attribute " "defined this way can have an associated doc string simply by providing the " "text in the table. An application can use the introspection API to retrieve " -"the descriptor from the class object, and get the doc string using its :attr:" -"`!__doc__` attribute." +"the descriptor from the class object, and get the doc string using " +"its :attr:`~type.__doc__` attribute." msgstr "" #: extending/newtypes.rst:301 @@ -311,8 +538,8 @@ msgstr "" #: extending/newtypes.rst:317 msgid "" "For simplicity, only the :c:expr:`char\\*` version will be demonstrated " -"here; the type of the name parameter is the only difference between the :c:" -"expr:`char\\*` and :c:expr:`PyObject*` flavors of the interface. This " +"here; the type of the name parameter is the only difference between " +"the :c:expr:`char\\*` and :c:expr:`PyObject*` flavors of the interface. This " "example effectively does the same thing as the generic example above, but " "does not use the generic support added in Python 2.2. It explains how the " "handler functions are called, so that if you do need to extend their " @@ -330,26 +557,58 @@ msgstr "" msgid "Here is an example::" msgstr "" +#: extending/newtypes.rst:331 +msgid "" +"static PyObject *\n" +"newdatatype_getattr(newdatatypeobject *obj, char *name)\n" +"{\n" +" if (strcmp(name, \"data\") == 0)\n" +" {\n" +" return PyLong_FromLong(obj->data);\n" +" }\n" +"\n" +" PyErr_Format(PyExc_AttributeError,\n" +" \"'%.100s' object has no attribute '%.400s'\",\n" +" Py_TYPE(obj)->tp_name, name);\n" +" return NULL;\n" +"}" +msgstr "" + #: extending/newtypes.rst:345 msgid "" -"The :c:member:`~PyTypeObject.tp_setattr` handler is called when the :meth:" -"`~object.__setattr__` or :meth:`~object.__delattr__` method of a class " -"instance would be called. When an attribute should be deleted, the third " -"parameter will be ``NULL``. Here is an example that simply raises an " -"exception; if this were really all you wanted, the :c:member:`~PyTypeObject." -"tp_setattr` handler should be set to ``NULL``. ::" +"The :c:member:`~PyTypeObject.tp_setattr` handler is called when " +"the :meth:`~object.__setattr__` or :meth:`~object.__delattr__` method of a " +"class instance would be called. When an attribute should be deleted, the " +"third parameter will be ``NULL``. Here is an example that simply raises an " +"exception; if this were really all you wanted, " +"the :c:member:`~PyTypeObject.tp_setattr` handler should be set to " +"``NULL``. ::" +msgstr "" + +#: extending/newtypes.rst:351 +msgid "" +"static int\n" +"newdatatype_setattr(newdatatypeobject *obj, char *name, PyObject *v)\n" +"{\n" +" PyErr_Format(PyExc_RuntimeError, \"Read-only attribute: %s\", name);\n" +" return -1;\n" +"}" msgstr "" #: extending/newtypes.rst:359 msgid "Object Comparison" msgstr "" +#: extending/newtypes.rst:363 +msgid "richcmpfunc tp_richcompare;" +msgstr "" + #: extending/newtypes.rst:365 msgid "" "The :c:member:`~PyTypeObject.tp_richcompare` handler is called when " "comparisons are needed. It is analogous to the :ref:`rich comparison " -"methods `, like :meth:`!__lt__`, and also called by :c:func:" -"`PyObject_RichCompare` and :c:func:`PyObject_RichCompareBool`." +"methods `, like :meth:`!__lt__`, and also called " +"by :c:func:`PyObject_RichCompare` and :c:func:`PyObject_RichCompareBool`." msgstr "" #: extending/newtypes.rst:370 @@ -369,6 +628,35 @@ msgid "" "the size of an internal pointer is equal::" msgstr "" +#: extending/newtypes.rst:381 +msgid "" +"static PyObject *\n" +"newdatatype_richcmp(newdatatypeobject *obj1, newdatatypeobject *obj2, int " +"op)\n" +"{\n" +" PyObject *result;\n" +" int c, size1, size2;\n" +"\n" +" /* code to make sure that both arguments are of type\n" +" newdatatype omitted */\n" +"\n" +" size1 = obj1->obj_UnderlyingDatatypePtr->size;\n" +" size2 = obj2->obj_UnderlyingDatatypePtr->size;\n" +"\n" +" switch (op) {\n" +" case Py_LT: c = size1 < size2; break;\n" +" case Py_LE: c = size1 <= size2; break;\n" +" case Py_EQ: c = size1 == size2; break;\n" +" case Py_NE: c = size1 != size2; break;\n" +" case Py_GT: c = size1 > size2; break;\n" +" case Py_GE: c = size1 >= size2; break;\n" +" }\n" +" result = c ? Py_True : Py_False;\n" +" Py_INCREF(result);\n" +" return result;\n" +" }" +msgstr "" + #: extending/newtypes.rst:408 msgid "Abstract Protocol Support" msgstr "" @@ -394,23 +682,47 @@ msgid "" "slot, but a slot may still be unfilled.) ::" msgstr "" +#: extending/newtypes.rst:425 +msgid "" +"PyNumberMethods *tp_as_number;\n" +"PySequenceMethods *tp_as_sequence;\n" +"PyMappingMethods *tp_as_mapping;" +msgstr "" + #: extending/newtypes.rst:429 msgid "" "If you wish your object to be able to act like a number, a sequence, or a " "mapping object, then you place the address of a structure that implements " -"the C type :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, or :c:" -"type:`PyMappingMethods`, respectively. It is up to you to fill in this " +"the C type :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, " +"or :c:type:`PyMappingMethods`, respectively. It is up to you to fill in this " "structure with appropriate values. You can find examples of the use of each " "of these in the :file:`Objects` directory of the Python source " "distribution. ::" msgstr "" +#: extending/newtypes.rst:436 +msgid "hashfunc tp_hash;" +msgstr "" + #: extending/newtypes.rst:438 msgid "" "This function, if you choose to provide it, should return a hash number for " "an instance of your data type. Here is a simple example::" msgstr "" +#: extending/newtypes.rst:441 +msgid "" +"static Py_hash_t\n" +"newdatatype_hash(newdatatypeobject *obj)\n" +"{\n" +" Py_hash_t result;\n" +" result = obj->some_size + 32767 * obj->some_number;\n" +" if (result == -1)\n" +" result = -2;\n" +" return result;\n" +"}" +msgstr "" + #: extending/newtypes.rst:451 msgid "" ":c:type:`!Py_hash_t` is a signed integer type with a platform-varying width. " @@ -419,6 +731,10 @@ msgid "" "computation is successful, as seen above." msgstr "" +#: extending/newtypes.rst:458 +msgid "ternaryfunc tp_call;" +msgstr "" + #: extending/newtypes.rst:460 msgid "" "This function is called when an instance of your data type is \"called\", " @@ -439,39 +755,69 @@ msgstr "" #: extending/newtypes.rst:469 msgid "" -"*args* is a tuple containing the arguments to the call. You can use :c:func:" -"`PyArg_ParseTuple` to extract the arguments." +"*args* is a tuple containing the arguments to the call. You can " +"use :c:func:`PyArg_ParseTuple` to extract the arguments." msgstr "" #: extending/newtypes.rst:472 msgid "" "*kwds* is a dictionary of keyword arguments that were passed. If this is non-" -"``NULL`` and you support keyword arguments, use :c:func:" -"`PyArg_ParseTupleAndKeywords` to extract the arguments. If you do not want " -"to support keyword arguments and this is non-``NULL``, raise a :exc:" -"`TypeError` with a message saying that keyword arguments are not supported." +"``NULL`` and you support keyword arguments, " +"use :c:func:`PyArg_ParseTupleAndKeywords` to extract the arguments. If you " +"do not want to support keyword arguments and this is non-``NULL``, raise " +"a :exc:`TypeError` with a message saying that keyword arguments are not " +"supported." msgstr "" #: extending/newtypes.rst:478 msgid "Here is a toy ``tp_call`` implementation::" msgstr "" +#: extending/newtypes.rst:480 +msgid "" +"static PyObject *\n" +"newdatatype_call(newdatatypeobject *obj, PyObject *args, PyObject *kwds)\n" +"{\n" +" PyObject *result;\n" +" const char *arg1;\n" +" const char *arg2;\n" +" const char *arg3;\n" +"\n" +" if (!PyArg_ParseTuple(args, \"sss:call\", &arg1, &arg2, &arg3)) {\n" +" return NULL;\n" +" }\n" +" result = PyUnicode_FromFormat(\n" +" \"Returning -- value: [%d] arg1: [%s] arg2: [%s] arg3: [%s]\\n\",\n" +" obj->obj_UnderlyingDatatypePtr->size,\n" +" arg1, arg2, arg3);\n" +" return result;\n" +"}" +msgstr "" + +#: extending/newtypes.rst:500 +msgid "" +"/* Iterators */\n" +"getiterfunc tp_iter;\n" +"iternextfunc tp_iternext;" +msgstr "" + #: extending/newtypes.rst:504 msgid "" "These functions provide support for the iterator protocol. Both handlers " "take exactly one parameter, the instance for which they are being called, " "and return a new reference. In the case of an error, they should set an " "exception and return ``NULL``. :c:member:`~PyTypeObject.tp_iter` " -"corresponds to the Python :meth:`~object.__iter__` method, while :c:member:" -"`~PyTypeObject.tp_iternext` corresponds to the Python :meth:`~iterator." -"__next__` method." +"corresponds to the Python :meth:`~object.__iter__` method, " +"while :c:member:`~PyTypeObject.tp_iternext` corresponds to the " +"Python :meth:`~iterator.__next__` method." msgstr "" #: extending/newtypes.rst:511 msgid "" -"Any :term:`iterable` object must implement the :c:member:`~PyTypeObject." -"tp_iter` handler, which must return an :term:`iterator` object. Here the " -"same guidelines apply as for Python classes:" +"Any :term:`iterable` object must implement " +"the :c:member:`~PyTypeObject.tp_iter` handler, which must return " +"an :term:`iterator` object. Here the same guidelines apply as for Python " +"classes:" msgstr "" #: extending/newtypes.rst:515 @@ -484,24 +830,27 @@ msgstr "" #: extending/newtypes.rst:518 msgid "" "Objects which can only be iterated over once (usually due to side effects of " -"iteration, such as file objects) can implement :c:member:`~PyTypeObject." -"tp_iter` by returning a new reference to themselves -- and should also " -"therefore implement the :c:member:`~PyTypeObject.tp_iternext` handler." +"iteration, such as file objects) can " +"implement :c:member:`~PyTypeObject.tp_iter` by returning a new reference to " +"themselves -- and should also therefore implement " +"the :c:member:`~PyTypeObject.tp_iternext` handler." msgstr "" #: extending/newtypes.rst:523 msgid "" -"Any :term:`iterator` object should implement both :c:member:`~PyTypeObject." -"tp_iter` and :c:member:`~PyTypeObject.tp_iternext`. An iterator's :c:member:" -"`~PyTypeObject.tp_iter` handler should return a new reference to the " -"iterator. Its :c:member:`~PyTypeObject.tp_iternext` handler should return a " -"new reference to the next object in the iteration, if there is one. If the " -"iteration has reached the end, :c:member:`~PyTypeObject.tp_iternext` may " -"return ``NULL`` without setting an exception, or it may set :exc:" -"`StopIteration` *in addition* to returning ``NULL``; avoiding the exception " -"can yield slightly better performance. If an actual error occurs, :c:member:" -"`~PyTypeObject.tp_iternext` should always set an exception and return " -"``NULL``." +"Any :term:`iterator` object should implement " +"both :c:member:`~PyTypeObject.tp_iter` " +"and :c:member:`~PyTypeObject.tp_iternext`. An " +"iterator's :c:member:`~PyTypeObject.tp_iter` handler should return a new " +"reference to the iterator. Its :c:member:`~PyTypeObject.tp_iternext` " +"handler should return a new reference to the next object in the iteration, " +"if there is one. If the iteration has reached the " +"end, :c:member:`~PyTypeObject.tp_iternext` may return ``NULL`` without " +"setting an exception, or it may set :exc:`StopIteration` *in addition* to " +"returning ``NULL``; avoiding the exception can yield slightly better " +"performance. If an actual error " +"occurs, :c:member:`~PyTypeObject.tp_iternext` should always set an exception " +"and return ``NULL``." msgstr "" #: extending/newtypes.rst:539 @@ -521,7 +870,7 @@ msgstr "" #: extending/newtypes.rst:548 msgid "" -"For an object to be weakly referencable, the extension type must set the " +"For an object to be weakly referenceable, the extension type must set the " "``Py_TPFLAGS_MANAGED_WEAKREF`` bit of the :c:member:`~PyTypeObject.tp_flags` " "field. The legacy :c:member:`~PyTypeObject.tp_weaklistoffset` field should " "be left as zero." @@ -532,12 +881,33 @@ msgid "" "Concretely, here is how the statically declared type object would look::" msgstr "" +#: extending/newtypes.rst:555 +msgid "" +"static PyTypeObject TrivialType = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" /* ... other members omitted for brevity ... */\n" +" .tp_flags = Py_TPFLAGS_MANAGED_WEAKREF | ...,\n" +"};" +msgstr "" + #: extending/newtypes.rst:562 msgid "" "The only further addition is that ``tp_dealloc`` needs to clear any weak " "references (by calling :c:func:`PyObject_ClearWeakRefs`)::" msgstr "" +#: extending/newtypes.rst:565 +msgid "" +"static void\n" +"Trivial_dealloc(TrivialObject *self)\n" +"{\n" +" /* Clear weakrefs first before calling any destructors */\n" +" PyObject_ClearWeakRefs((PyObject *) self);\n" +" /* ... remainder of destruction code omitted for brevity ... */\n" +" Py_TYPE(self)->tp_free((PyObject *) self);\n" +"}" +msgstr "" + #: extending/newtypes.rst:576 msgid "More Suggestions" msgstr "" @@ -558,7 +928,15 @@ msgid "" "sample of its use might be something like the following::" msgstr "" -#: extending/newtypes.rst:595 +#: extending/newtypes.rst:588 +msgid "" +"if (!PyObject_TypeCheck(some_object, &MyType)) {\n" +" PyErr_SetString(PyExc_TypeError, \"arg #1 not a mything\");\n" +" return NULL;\n" +"}" +msgstr "" + +#: extending/newtypes.rst:594 msgid "Download CPython source releases." msgstr "" diff --git a/extending/newtypes_tutorial.po b/extending/newtypes_tutorial.po index 9e7bb7b3..2e3a1902 100644 --- a/extending/newtypes_tutorial.po +++ b/extending/newtypes_tutorial.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -35,14 +36,14 @@ msgstr "" #: extending/newtypes_tutorial.rst:26 msgid "" -"The :term:`CPython` runtime sees all Python objects as variables of type :c:" -"expr:`PyObject*`, which serves as a \"base type\" for all Python objects. " -"The :c:type:`PyObject` structure itself only contains the object's :term:" -"`reference count` and a pointer to the object's \"type object\". This is " -"where the action is; the type object determines which (C) functions get " -"called by the interpreter when, for instance, an attribute gets looked up on " -"an object, a method called, or it is multiplied by another object. These C " -"functions are called \"type methods\"." +"The :term:`CPython` runtime sees all Python objects as variables of " +"type :c:expr:`PyObject*`, which serves as a \"base type\" for all Python " +"objects. The :c:type:`PyObject` structure itself only contains the " +"object's :term:`reference count` and a pointer to the object's \"type " +"object\". This is where the action is; the type object determines which (C) " +"functions get called by the interpreter when, for instance, an attribute " +"gets looked up on an object, a method called, or it is multiplied by another " +"object. These C functions are called \"type methods\"." msgstr "" #: extending/newtypes_tutorial.rst:35 @@ -62,8 +63,57 @@ msgstr "" msgid "" "What we're showing here is the traditional way of defining *static* " "extension types. It should be adequate for most uses. The C API also " -"allows defining heap-allocated extension types using the :c:func:" -"`PyType_FromSpec` function, which isn't covered in this tutorial." +"allows defining heap-allocated extension types using " +"the :c:func:`PyType_FromSpec` function, which isn't covered in this tutorial." +msgstr "" + +#: extending/newtypes_tutorial.rst:48 +msgid "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"\n" +"typedef struct {\n" +" PyObject_HEAD\n" +" /* Type-specific fields go here. */\n" +"} CustomObject;\n" +"\n" +"static PyTypeObject CustomType = {\n" +" .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"custom.Custom\",\n" +" .tp_doc = PyDoc_STR(\"Custom objects\"),\n" +" .tp_basicsize = sizeof(CustomObject),\n" +" .tp_itemsize = 0,\n" +" .tp_flags = Py_TPFLAGS_DEFAULT,\n" +" .tp_new = PyType_GenericNew,\n" +"};\n" +"\n" +"static PyModuleDef custommodule = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"custom\",\n" +" .m_doc = \"Example module that creates an extension type.\",\n" +" .m_size = -1,\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_custom(void)\n" +"{\n" +" PyObject *m;\n" +" if (PyType_Ready(&CustomType) < 0)\n" +" return NULL;\n" +"\n" +" m = PyModule_Create(&custommodule);\n" +" if (m == NULL)\n" +" return NULL;\n" +"\n" +" Py_INCREF(&CustomType);\n" +" if (PyModule_AddObject(m, \"Custom\", (PyObject *) &CustomType) < 0) {\n" +" Py_DECREF(&CustomType);\n" +" Py_DECREF(m);\n" +" return NULL;\n" +" }\n" +"\n" +" return m;\n" +"}\n" msgstr "" #: extending/newtypes_tutorial.rst:50 @@ -95,6 +145,13 @@ msgstr "" msgid "The first bit is::" msgstr "" +#: extending/newtypes_tutorial.rst:63 +msgid "" +"typedef struct {\n" +" PyObject_HEAD\n" +"} CustomObject;" +msgstr "" + #: extending/newtypes_tutorial.rst:67 msgid "" "This is what a Custom object will contain. ``PyObject_HEAD`` is mandatory " @@ -119,10 +176,31 @@ msgid "" "standard Python floats::" msgstr "" +#: extending/newtypes_tutorial.rst:83 +msgid "" +"typedef struct {\n" +" PyObject_HEAD\n" +" double ob_fval;\n" +"} PyFloatObject;" +msgstr "" + #: extending/newtypes_tutorial.rst:88 msgid "The second bit is the definition of the type object. ::" msgstr "" +#: extending/newtypes_tutorial.rst:90 +msgid "" +"static PyTypeObject CustomType = {\n" +" .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"custom.Custom\",\n" +" .tp_doc = PyDoc_STR(\"Custom objects\"),\n" +" .tp_basicsize = sizeof(CustomObject),\n" +" .tp_itemsize = 0,\n" +" .tp_flags = Py_TPFLAGS_DEFAULT,\n" +" .tp_new = PyType_GenericNew,\n" +"};" +msgstr "" + #: extending/newtypes_tutorial.rst:101 msgid "" "We recommend using C99-style designated initializers as above, to avoid " @@ -142,32 +220,55 @@ msgstr "" msgid "We're going to pick it apart, one field at a time::" msgstr "" +#: extending/newtypes_tutorial.rst:112 +msgid ".ob_base = PyVarObject_HEAD_INIT(NULL, 0)" +msgstr "" + #: extending/newtypes_tutorial.rst:114 msgid "" "This line is mandatory boilerplate to initialize the ``ob_base`` field " "mentioned above. ::" msgstr "" +#: extending/newtypes_tutorial.rst:117 +msgid ".tp_name = \"custom.Custom\"," +msgstr "" + #: extending/newtypes_tutorial.rst:119 msgid "" "The name of our type. This will appear in the default textual " "representation of our objects and in some error messages, for example:" msgstr "" +#: extending/newtypes_tutorial.rst:122 +msgid "" +">>> \"\" + custom.Custom()\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: can only concatenate str (not \"custom.Custom\") to str" +msgstr "" + #: extending/newtypes_tutorial.rst:129 msgid "" "Note that the name is a dotted name that includes both the module name and " "the name of the type within the module. The module in this case is :mod:`!" -"custom` and the type is :class:`!Custom`, so we set the type name to :class:" -"`!custom.Custom`. Using the real dotted import path is important to make " -"your type compatible with the :mod:`pydoc` and :mod:`pickle` modules. ::" +"custom` and the type is :class:`!Custom`, so we set the type name " +"to :class:`!custom.Custom`. Using the real dotted import path is important " +"to make your type compatible with the :mod:`pydoc` and :mod:`pickle` " +"modules. ::" +msgstr "" + +#: extending/newtypes_tutorial.rst:135 +msgid "" +".tp_basicsize = sizeof(CustomObject),\n" +".tp_itemsize = 0," msgstr "" #: extending/newtypes_tutorial.rst:138 msgid "" -"This is so that Python knows how much memory to allocate when creating new :" -"class:`!Custom` instances. :c:member:`~PyTypeObject.tp_itemsize` is only " -"used for variable-sized objects and should otherwise be zero." +"This is so that Python knows how much memory to allocate when creating " +"new :class:`!Custom` instances. :c:member:`~PyTypeObject.tp_itemsize` is " +"only used for variable-sized objects and should otherwise be zero." msgstr "" #: extending/newtypes_tutorial.rst:144 @@ -175,8 +276,8 @@ msgid "" "If you want your type to be subclassable from Python, and your type has the " "same :c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have " "problems with multiple inheritance. A Python subclass of your type will " -"have to list your type first in its :attr:`~class.__bases__`, or else it " -"will not be able to call your type's :meth:`~object.__new__` method without " +"have to list your type first in its :attr:`~type.__bases__`, or else it will " +"not be able to call your type's :meth:`~object.__new__` method without " "getting an error. You can avoid this problem by ensuring that your type has " "a larger value for :c:member:`~PyTypeObject.tp_basicsize` than its base type " "does. Most of the time, this will be true anyway, because either your base " @@ -188,6 +289,10 @@ msgstr "" msgid "We set the class flags to :c:macro:`Py_TPFLAGS_DEFAULT`. ::" msgstr "" +#: extending/newtypes_tutorial.rst:156 +msgid ".tp_flags = Py_TPFLAGS_DEFAULT," +msgstr "" + #: extending/newtypes_tutorial.rst:158 msgid "" "All types should include this constant in their flags. It enables all of " @@ -200,19 +305,33 @@ msgid "" "We provide a doc string for the type in :c:member:`~PyTypeObject.tp_doc`. ::" msgstr "" +#: extending/newtypes_tutorial.rst:164 +msgid ".tp_doc = PyDoc_STR(\"Custom objects\")," +msgstr "" + #: extending/newtypes_tutorial.rst:166 msgid "" -"To enable object creation, we have to provide a :c:member:`~PyTypeObject." -"tp_new` handler. This is the equivalent of the Python method :meth:`~object." -"__new__`, but has to be specified explicitly. In this case, we can just use " -"the default implementation provided by the API function :c:func:" -"`PyType_GenericNew`. ::" +"To enable object creation, we have to provide " +"a :c:member:`~PyTypeObject.tp_new` handler. This is the equivalent of the " +"Python method :meth:`~object.__new__`, but has to be specified explicitly. " +"In this case, we can just use the default implementation provided by the API " +"function :c:func:`PyType_GenericNew`. ::" +msgstr "" + +#: extending/newtypes_tutorial.rst:171 +msgid ".tp_new = PyType_GenericNew," msgstr "" #: extending/newtypes_tutorial.rst:173 msgid "" -"Everything else in the file should be familiar, except for some code in :c:" -"func:`!PyInit_custom`::" +"Everything else in the file should be familiar, except for some code " +"in :c:func:`!PyInit_custom`::" +msgstr "" + +#: extending/newtypes_tutorial.rst:176 +msgid "" +"if (PyType_Ready(&CustomType) < 0)\n" +" return;" msgstr "" #: extending/newtypes_tutorial.rst:179 @@ -222,10 +341,26 @@ msgid "" "that we initially set to ``NULL``. ::" msgstr "" +#: extending/newtypes_tutorial.rst:183 +msgid "" +"Py_INCREF(&CustomType);\n" +"if (PyModule_AddObject(m, \"Custom\", (PyObject *) &CustomType) < 0) {\n" +" Py_DECREF(&CustomType);\n" +" Py_DECREF(m);\n" +" return NULL;\n" +"}" +msgstr "" + #: extending/newtypes_tutorial.rst:190 msgid "" -"This adds the type to the module dictionary. This allows us to create :" -"class:`!Custom` instances by calling the :class:`!Custom` class:" +"This adds the type to the module dictionary. This allows us to " +"create :class:`!Custom` instances by calling the :class:`!Custom` class:" +msgstr "" + +#: extending/newtypes_tutorial.rst:193 +msgid "" +">>> import custom\n" +">>> mycustom = custom.Custom()" msgstr "" #: extending/newtypes_tutorial.rst:198 @@ -234,14 +369,35 @@ msgid "" "called :file:`custom.c`," msgstr "" +#: extending/newtypes_tutorial.rst:201 +msgid "" +"[build-system]\n" +"requires = [\"setuptools\"]\n" +"build-backend = \"setuptools.build_meta\"\n" +"\n" +"[project]\n" +"name = \"custom\"\n" +"version = \"1\"\n" +msgstr "" + #: extending/newtypes_tutorial.rst:203 msgid "in a file called :file:`pyproject.toml`, and" msgstr "" +#: extending/newtypes_tutorial.rst:205 +msgid "" +"from setuptools import Extension, setup\n" +"setup(ext_modules=[Extension(\"custom\", [\"custom.c\"])])" +msgstr "" + #: extending/newtypes_tutorial.rst:210 msgid "in a file called :file:`setup.py`; then typing" msgstr "" +#: extending/newtypes_tutorial.rst:212 extending/newtypes_tutorial.rst:527 +msgid "$ python -m pip install ." +msgstr "" + #: extending/newtypes_tutorial.rst:216 msgid "" "in a shell should produce a file :file:`custom.so` in a subdirectory and " @@ -270,6 +426,141 @@ msgid "" "custom2` that adds these capabilities:" msgstr "" +#: extending/newtypes_tutorial.rst:233 +msgid "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"#include /* for offsetof() */\n" +"\n" +"typedef struct {\n" +" PyObject_HEAD\n" +" PyObject *first; /* first name */\n" +" PyObject *last; /* last name */\n" +" int number;\n" +"} CustomObject;\n" +"\n" +"static void\n" +"Custom_dealloc(CustomObject *self)\n" +"{\n" +" Py_XDECREF(self->first);\n" +" Py_XDECREF(self->last);\n" +" Py_TYPE(self)->tp_free((PyObject *) self);\n" +"}\n" +"\n" +"static PyObject *\n" +"Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self;\n" +" self = (CustomObject *) type->tp_alloc(type, 0);\n" +" if (self != NULL) {\n" +" self->first = PyUnicode_FromString(\"\");\n" +" if (self->first == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->last = PyUnicode_FromString(\"\");\n" +" if (self->last == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->number = 0;\n" +" }\n" +" return (PyObject *) self;\n" +"}\n" +"\n" +"static int\n" +"Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)\n" +"{\n" +" static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" +" PyObject *first = NULL, *last = NULL;\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|OOi\", kwlist,\n" +" &first, &last,\n" +" &self->number))\n" +" return -1;\n" +"\n" +" if (first) {\n" +" Py_XSETREF(self->first, Py_NewRef(first));\n" +" }\n" +" if (last) {\n" +" Py_XSETREF(self->last, Py_NewRef(last));\n" +" }\n" +" return 0;\n" +"}\n" +"\n" +"static PyMemberDef Custom_members[] = {\n" +" {\"first\", Py_T_OBJECT_EX, offsetof(CustomObject, first), 0,\n" +" \"first name\"},\n" +" {\"last\", Py_T_OBJECT_EX, offsetof(CustomObject, last), 0,\n" +" \"last name\"},\n" +" {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" +" \"custom number\"},\n" +" {NULL} /* Sentinel */\n" +"};\n" +"\n" +"static PyObject *\n" +"Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))\n" +"{\n" +" if (self->first == NULL) {\n" +" PyErr_SetString(PyExc_AttributeError, \"first\");\n" +" return NULL;\n" +" }\n" +" if (self->last == NULL) {\n" +" PyErr_SetString(PyExc_AttributeError, \"last\");\n" +" return NULL;\n" +" }\n" +" return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" +"}\n" +"\n" +"static PyMethodDef Custom_methods[] = {\n" +" {\"name\", (PyCFunction) Custom_name, METH_NOARGS,\n" +" \"Return the name, combining the first and last name\"\n" +" },\n" +" {NULL} /* Sentinel */\n" +"};\n" +"\n" +"static PyTypeObject CustomType = {\n" +" .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"custom2.Custom\",\n" +" .tp_doc = PyDoc_STR(\"Custom objects\"),\n" +" .tp_basicsize = sizeof(CustomObject),\n" +" .tp_itemsize = 0,\n" +" .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,\n" +" .tp_new = Custom_new,\n" +" .tp_init = (initproc) Custom_init,\n" +" .tp_dealloc = (destructor) Custom_dealloc,\n" +" .tp_members = Custom_members,\n" +" .tp_methods = Custom_methods,\n" +"};\n" +"\n" +"static PyModuleDef custommodule = {\n" +" .m_base =PyModuleDef_HEAD_INIT,\n" +" .m_name = \"custom2\",\n" +" .m_doc = \"Example module that creates an extension type.\",\n" +" .m_size = -1,\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_custom2(void)\n" +"{\n" +" PyObject *m;\n" +" if (PyType_Ready(&CustomType) < 0)\n" +" return NULL;\n" +"\n" +" m = PyModule_Create(&custommodule);\n" +" if (m == NULL)\n" +" return NULL;\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" Py_DECREF(m);\n" +" return NULL;\n" +" }\n" +"\n" +" return m;\n" +"}\n" +msgstr "" + #: extending/newtypes_tutorial.rst:236 msgid "This version of the module has a number of changes." msgstr "" @@ -286,25 +577,50 @@ msgstr "" msgid "The object structure is updated accordingly::" msgstr "" +#: extending/newtypes_tutorial.rst:244 +msgid "" +"typedef struct {\n" +" PyObject_HEAD\n" +" PyObject *first; /* first name */\n" +" PyObject *last; /* last name */\n" +" int number;\n" +"} CustomObject;" +msgstr "" + #: extending/newtypes_tutorial.rst:251 msgid "" "Because we now have data to manage, we have to be more careful about object " "allocation and deallocation. At a minimum, we need a deallocation method::" msgstr "" +#: extending/newtypes_tutorial.rst:254 +msgid "" +"static void\n" +"Custom_dealloc(CustomObject *self)\n" +"{\n" +" Py_XDECREF(self->first);\n" +" Py_XDECREF(self->last);\n" +" Py_TYPE(self)->tp_free((PyObject *) self);\n" +"}" +msgstr "" + #: extending/newtypes_tutorial.rst:262 msgid "which is assigned to the :c:member:`~PyTypeObject.tp_dealloc` member::" msgstr "" +#: extending/newtypes_tutorial.rst:264 +msgid ".tp_dealloc = (destructor) Custom_dealloc," +msgstr "" + #: extending/newtypes_tutorial.rst:266 msgid "" -"This method first clears the reference counts of the two Python attributes. :" -"c:func:`Py_XDECREF` correctly handles the case where its argument is " -"``NULL`` (which might happen here if ``tp_new`` failed midway). It then " -"calls the :c:member:`~PyTypeObject.tp_free` member of the object's type " -"(computed by ``Py_TYPE(self)``) to free the object's memory. Note that the " -"object's type might not be :class:`!CustomType`, because the object may be " -"an instance of a subclass." +"This method first clears the reference counts of the two Python " +"attributes. :c:func:`Py_XDECREF` correctly handles the case where its " +"argument is ``NULL`` (which might happen here if ``tp_new`` failed midway). " +"It then calls the :c:member:`~PyTypeObject.tp_free` member of the object's " +"type (computed by ``Py_TYPE(self)``) to free the object's memory. Note that " +"the object's type might not be :class:`!CustomType`, because the object may " +"be an instance of a subclass." msgstr "" #: extending/newtypes_tutorial.rst:275 @@ -322,19 +638,48 @@ msgid "" "strings, so we provide a ``tp_new`` implementation::" msgstr "" +#: extending/newtypes_tutorial.rst:284 +msgid "" +"static PyObject *\n" +"Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self;\n" +" self = (CustomObject *) type->tp_alloc(type, 0);\n" +" if (self != NULL) {\n" +" self->first = PyUnicode_FromString(\"\");\n" +" if (self->first == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->last = PyUnicode_FromString(\"\");\n" +" if (self->last == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->number = 0;\n" +" }\n" +" return (PyObject *) self;\n" +"}" +msgstr "" + #: extending/newtypes_tutorial.rst:305 msgid "and install it in the :c:member:`~PyTypeObject.tp_new` member::" msgstr "" +#: extending/newtypes_tutorial.rst:307 +msgid ".tp_new = Custom_new," +msgstr "" + #: extending/newtypes_tutorial.rst:309 msgid "" "The ``tp_new`` handler is responsible for creating (as opposed to " -"initializing) objects of the type. It is exposed in Python as the :meth:" -"`~object.__new__` method. It is not required to define a ``tp_new`` member, " -"and indeed many extension types will simply reuse :c:func:" -"`PyType_GenericNew` as done in the first version of the :class:`!Custom` " -"type above. In this case, we use the ``tp_new`` handler to initialize the " -"``first`` and ``last`` attributes to non-``NULL`` default values." +"initializing) objects of the type. It is exposed in Python as " +"the :meth:`~object.__new__` method. It is not required to define a " +"``tp_new`` member, and indeed many extension types will simply " +"reuse :c:func:`PyType_GenericNew` as done in the first version of " +"the :class:`!Custom` type above. In this case, we use the ``tp_new`` " +"handler to initialize the ``first`` and ``last`` attributes to non-``NULL`` " +"default values." msgstr "" #: extending/newtypes_tutorial.rst:317 @@ -343,8 +688,8 @@ msgid "" "``CustomType``, if a subclass is instantiated) and any arguments passed when " "the type was called, and is expected to return the instance created. " "``tp_new`` handlers always accept positional and keyword arguments, but they " -"often ignore the arguments, leaving the argument handling to initializer (a." -"k.a. ``tp_init`` in C or ``__init__`` in Python) methods." +"often ignore the arguments, leaving the argument handling to initializer " +"(a.k.a. ``tp_init`` in C or ``__init__`` in Python) methods." msgstr "" #: extending/newtypes_tutorial.rst:325 @@ -359,10 +704,15 @@ msgid "" "slot to allocate memory::" msgstr "" +#: extending/newtypes_tutorial.rst:331 +msgid "self = (CustomObject *) type->tp_alloc(type, 0);" +msgstr "" + #: extending/newtypes_tutorial.rst:333 msgid "" -"Since memory allocation may fail, we must check the :c:member:`~PyTypeObject." -"tp_alloc` result against ``NULL`` before proceeding." +"Since memory allocation may fail, we must check " +"the :c:member:`~PyTypeObject.tp_alloc` result against ``NULL`` before " +"proceeding." msgstr "" #: extending/newtypes_tutorial.rst:337 @@ -376,14 +726,15 @@ msgstr "" #: extending/newtypes_tutorial.rst:343 msgid "" "If you are creating a co-operative :c:member:`~PyTypeObject.tp_new` (one " -"that calls a base type's :c:member:`~PyTypeObject.tp_new` or :meth:`~object." -"__new__`), you must *not* try to determine what method to call using method " -"resolution order at runtime. Always statically determine what type you are " -"going to call, and call its :c:member:`~PyTypeObject.tp_new` directly, or " -"via ``type->tp_base->tp_new``. If you do not do this, Python subclasses of " -"your type that also inherit from other Python-defined classes may not work " -"correctly. (Specifically, you may not be able to create instances of such " -"subclasses without getting a :exc:`TypeError`.)" +"that calls a base type's :c:member:`~PyTypeObject.tp_new` " +"or :meth:`~object.__new__`), you must *not* try to determine what method to " +"call using method resolution order at runtime. Always statically determine " +"what type you are going to call, and call " +"its :c:member:`~PyTypeObject.tp_new` directly, or via ``type->tp_base-" +">tp_new``. If you do not do this, Python subclasses of your type that also " +"inherit from other Python-defined classes may not work correctly. " +"(Specifically, you may not be able to create instances of such subclasses " +"without getting a :exc:`TypeError`.)" msgstr "" #: extending/newtypes_tutorial.rst:353 @@ -392,16 +743,49 @@ msgid "" "initial values for our instance::" msgstr "" +#: extending/newtypes_tutorial.rst:356 +msgid "" +"static int\n" +"Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)\n" +"{\n" +" static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" +" PyObject *first = NULL, *last = NULL, *tmp;\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|OOi\", kwlist,\n" +" &first, &last,\n" +" &self->number))\n" +" return -1;\n" +"\n" +" if (first) {\n" +" tmp = self->first;\n" +" Py_INCREF(first);\n" +" self->first = first;\n" +" Py_XDECREF(tmp);\n" +" }\n" +" if (last) {\n" +" tmp = self->last;\n" +" Py_INCREF(last);\n" +" self->last = last;\n" +" Py_XDECREF(tmp);\n" +" }\n" +" return 0;\n" +"}" +msgstr "" + #: extending/newtypes_tutorial.rst:382 msgid "by filling the :c:member:`~PyTypeObject.tp_init` slot. ::" msgstr "" +#: extending/newtypes_tutorial.rst:384 +msgid ".tp_init = (initproc) Custom_init," +msgstr "" + #: extending/newtypes_tutorial.rst:386 msgid "" -"The :c:member:`~PyTypeObject.tp_init` slot is exposed in Python as the :meth:" -"`~object.__init__` method. It is used to initialize an object after it's " -"created. Initializers always accept positional and keyword arguments, and " -"they should return either ``0`` on success or ``-1`` on error." +"The :c:member:`~PyTypeObject.tp_init` slot is exposed in Python as " +"the :meth:`~object.__init__` method. It is used to initialize an object " +"after it's created. Initializers always accept positional and keyword " +"arguments, and they should return either ``0`` on success or ``-1`` on error." msgstr "" #: extending/newtypes_tutorial.rst:391 @@ -415,6 +799,15 @@ msgid "" "``first`` member like this::" msgstr "" +#: extending/newtypes_tutorial.rst:399 +msgid "" +"if (first) {\n" +" Py_XDECREF(self->first);\n" +" Py_INCREF(first);\n" +" self->first = first;\n" +"}" +msgstr "" + #: extending/newtypes_tutorial.rst:405 msgid "" "But this would be risky. Our type doesn't restrict the type of the " @@ -438,15 +831,15 @@ msgstr "" #: extending/newtypes_tutorial.rst:418 msgid "" -"when we know that deallocation of the object [#]_ will neither release the :" -"term:`GIL` nor cause any calls back into our type's code;" +"when we know that deallocation of the object [#]_ will neither release " +"the :term:`GIL` nor cause any calls back into our type's code;" msgstr "" #: extending/newtypes_tutorial.rst:421 msgid "" -"when decrementing a reference count in a :c:member:`~PyTypeObject." -"tp_dealloc` handler on a type which doesn't support cyclic garbage " -"collection [#]_." +"when decrementing a reference count in " +"a :c:member:`~PyTypeObject.tp_dealloc` handler on a type which doesn't " +"support cyclic garbage collection [#]_." msgstr "" #: extending/newtypes_tutorial.rst:424 @@ -455,11 +848,28 @@ msgid "" "of ways to do that. The simplest way is to define member definitions::" msgstr "" +#: extending/newtypes_tutorial.rst:427 +msgid "" +"static PyMemberDef Custom_members[] = {\n" +" {\"first\", Py_T_OBJECT_EX, offsetof(CustomObject, first), 0,\n" +" \"first name\"},\n" +" {\"last\", Py_T_OBJECT_EX, offsetof(CustomObject, last), 0,\n" +" \"last name\"},\n" +" {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" +" \"custom number\"},\n" +" {NULL} /* Sentinel */\n" +"};" +msgstr "" + #: extending/newtypes_tutorial.rst:437 msgid "" "and put the definitions in the :c:member:`~PyTypeObject.tp_members` slot::" msgstr "" +#: extending/newtypes_tutorial.rst:439 +msgid ".tp_members = Custom_members," +msgstr "" + #: extending/newtypes_tutorial.rst:441 msgid "" "Each member definition has a member name, type, offset, access flags and " @@ -480,27 +890,50 @@ msgstr "" #: extending/newtypes_tutorial.rst:452 msgid "" -"We define a single method, :meth:`!Custom.name()`, that outputs the objects " +"We define a single method, :meth:`!Custom.name`, that outputs the objects " "name as the concatenation of the first and last names. ::" msgstr "" +#: extending/newtypes_tutorial.rst:455 +msgid "" +"static PyObject *\n" +"Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))\n" +"{\n" +" if (self->first == NULL) {\n" +" PyErr_SetString(PyExc_AttributeError, \"first\");\n" +" return NULL;\n" +" }\n" +" if (self->last == NULL) {\n" +" PyErr_SetString(PyExc_AttributeError, \"last\");\n" +" return NULL;\n" +" }\n" +" return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" +"}" +msgstr "" + #: extending/newtypes_tutorial.rst:469 msgid "" -"The method is implemented as a C function that takes a :class:`!Custom` (or :" -"class:`!Custom` subclass) instance as the first argument. Methods always " -"take an instance as the first argument. Methods often take positional and " -"keyword arguments as well, but in this case we don't take any and don't need " -"to accept a positional argument tuple or keyword argument dictionary. This " -"method is equivalent to the Python method:" +"The method is implemented as a C function that takes a :class:`!Custom` " +"(or :class:`!Custom` subclass) instance as the first argument. Methods " +"always take an instance as the first argument. Methods often take positional " +"and keyword arguments as well, but in this case we don't take any and don't " +"need to accept a positional argument tuple or keyword argument dictionary. " +"This method is equivalent to the Python method:" +msgstr "" + +#: extending/newtypes_tutorial.rst:476 +msgid "" +"def name(self):\n" +" return \"%s %s\" % (self.first, self.last)" msgstr "" #: extending/newtypes_tutorial.rst:481 msgid "" -"Note that we have to check for the possibility that our :attr:`!first` and :" -"attr:`!last` members are ``NULL``. This is because they can be deleted, in " -"which case they are set to ``NULL``. It would be better to prevent deletion " -"of these attributes and to restrict the attribute values to be strings. " -"We'll see how to do that in the next section." +"Note that we have to check for the possibility that our :attr:`!first` " +"and :attr:`!last` members are ``NULL``. This is because they can be " +"deleted, in which case they are set to ``NULL``. It would be better to " +"prevent deletion of these attributes and to restrict the attribute values to " +"be strings. We'll see how to do that in the next section." msgstr "" #: extending/newtypes_tutorial.rst:487 @@ -509,6 +942,16 @@ msgid "" "definitions::" msgstr "" +#: extending/newtypes_tutorial.rst:490 +msgid "" +"static PyMethodDef Custom_methods[] = {\n" +" {\"name\", (PyCFunction) Custom_name, METH_NOARGS,\n" +" \"Return the name, combining the first and last name\"\n" +" },\n" +" {NULL} /* Sentinel */\n" +"};" +msgstr "" + #: extending/newtypes_tutorial.rst:497 msgid "" "(note that we used the :c:macro:`METH_NOARGS` flag to indicate that the " @@ -519,6 +962,10 @@ msgstr "" msgid "and assign it to the :c:member:`~PyTypeObject.tp_methods` slot::" msgstr "" +#: extending/newtypes_tutorial.rst:502 +msgid ".tp_methods = Custom_methods," +msgstr "" + #: extending/newtypes_tutorial.rst:504 msgid "" "Finally, we'll make our type usable as a base class for subclassing. We've " @@ -527,6 +974,10 @@ msgid "" "to add the :c:macro:`Py_TPFLAGS_BASETYPE` to our class flag definition::" msgstr "" +#: extending/newtypes_tutorial.rst:509 +msgid ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE," +msgstr "" + #: extending/newtypes_tutorial.rst:511 msgid "" "We rename :c:func:`!PyInit_custom` to :c:func:`!PyInit_custom2`, update the " @@ -538,6 +989,15 @@ msgstr "" msgid "Finally, we update our :file:`setup.py` file to include the new module," msgstr "" +#: extending/newtypes_tutorial.rst:517 +msgid "" +"from setuptools import Extension, setup\n" +"setup(ext_modules=[\n" +" Extension(\"custom\", [\"custom.c\"]),\n" +" Extension(\"custom2\", [\"custom2.c\"]),\n" +"])" +msgstr "" + #: extending/newtypes_tutorial.rst:525 msgid "and then we re-install so that we can ``import custom2``:" msgstr "" @@ -550,9 +1010,187 @@ msgstr "" msgid "" "In this section, we'll provide finer control over how the :attr:`!first` " "and :attr:`!last` attributes are set in the :class:`!Custom` example. In the " -"previous version of our module, the instance variables :attr:`!first` and :" -"attr:`!last` could be set to non-string values or even deleted. We want to " -"make sure that these attributes always contain strings." +"previous version of our module, the instance variables :attr:`!first` " +"and :attr:`!last` could be set to non-string values or even deleted. We want " +"to make sure that these attributes always contain strings." +msgstr "" + +#: extending/newtypes_tutorial.rst:540 +msgid "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"#include /* for offsetof() */\n" +"\n" +"typedef struct {\n" +" PyObject_HEAD\n" +" PyObject *first; /* first name */\n" +" PyObject *last; /* last name */\n" +" int number;\n" +"} CustomObject;\n" +"\n" +"static void\n" +"Custom_dealloc(CustomObject *self)\n" +"{\n" +" Py_XDECREF(self->first);\n" +" Py_XDECREF(self->last);\n" +" Py_TYPE(self)->tp_free((PyObject *) self);\n" +"}\n" +"\n" +"static PyObject *\n" +"Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self;\n" +" self = (CustomObject *) type->tp_alloc(type, 0);\n" +" if (self != NULL) {\n" +" self->first = PyUnicode_FromString(\"\");\n" +" if (self->first == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->last = PyUnicode_FromString(\"\");\n" +" if (self->last == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->number = 0;\n" +" }\n" +" return (PyObject *) self;\n" +"}\n" +"\n" +"static int\n" +"Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)\n" +"{\n" +" static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" +" PyObject *first = NULL, *last = NULL;\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|UUi\", kwlist,\n" +" &first, &last,\n" +" &self->number))\n" +" return -1;\n" +"\n" +" if (first) {\n" +" Py_SETREF(self->first, Py_NewRef(first));\n" +" }\n" +" if (last) {\n" +" Py_SETREF(self->last, Py_NewRef(last));\n" +" }\n" +" return 0;\n" +"}\n" +"\n" +"static PyMemberDef Custom_members[] = {\n" +" {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" +" \"custom number\"},\n" +" {NULL} /* Sentinel */\n" +"};\n" +"\n" +"static PyObject *\n" +"Custom_getfirst(CustomObject *self, void *closure)\n" +"{\n" +" return Py_NewRef(self->first);\n" +"}\n" +"\n" +"static int\n" +"Custom_setfirst(CustomObject *self, PyObject *value, void *closure)\n" +"{\n" +" if (value == NULL) {\n" +" PyErr_SetString(PyExc_TypeError, \"Cannot delete the first " +"attribute\");\n" +" return -1;\n" +" }\n" +" if (!PyUnicode_Check(value)) {\n" +" PyErr_SetString(PyExc_TypeError,\n" +" \"The first attribute value must be a string\");\n" +" return -1;\n" +" }\n" +" Py_SETREF(self->first, Py_NewRef(value));\n" +" return 0;\n" +"}\n" +"\n" +"static PyObject *\n" +"Custom_getlast(CustomObject *self, void *closure)\n" +"{\n" +" return Py_NewRef(self->last);\n" +"}\n" +"\n" +"static int\n" +"Custom_setlast(CustomObject *self, PyObject *value, void *closure)\n" +"{\n" +" if (value == NULL) {\n" +" PyErr_SetString(PyExc_TypeError, \"Cannot delete the last " +"attribute\");\n" +" return -1;\n" +" }\n" +" if (!PyUnicode_Check(value)) {\n" +" PyErr_SetString(PyExc_TypeError,\n" +" \"The last attribute value must be a string\");\n" +" return -1;\n" +" }\n" +" Py_SETREF(self->last, Py_NewRef(value));\n" +" return 0;\n" +"}\n" +"\n" +"static PyGetSetDef Custom_getsetters[] = {\n" +" {\"first\", (getter) Custom_getfirst, (setter) Custom_setfirst,\n" +" \"first name\", NULL},\n" +" {\"last\", (getter) Custom_getlast, (setter) Custom_setlast,\n" +" \"last name\", NULL},\n" +" {NULL} /* Sentinel */\n" +"};\n" +"\n" +"static PyObject *\n" +"Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))\n" +"{\n" +" return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" +"}\n" +"\n" +"static PyMethodDef Custom_methods[] = {\n" +" {\"name\", (PyCFunction) Custom_name, METH_NOARGS,\n" +" \"Return the name, combining the first and last name\"\n" +" },\n" +" {NULL} /* Sentinel */\n" +"};\n" +"\n" +"static PyTypeObject CustomType = {\n" +" .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"custom3.Custom\",\n" +" .tp_doc = PyDoc_STR(\"Custom objects\"),\n" +" .tp_basicsize = sizeof(CustomObject),\n" +" .tp_itemsize = 0,\n" +" .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,\n" +" .tp_new = Custom_new,\n" +" .tp_init = (initproc) Custom_init,\n" +" .tp_dealloc = (destructor) Custom_dealloc,\n" +" .tp_members = Custom_members,\n" +" .tp_methods = Custom_methods,\n" +" .tp_getset = Custom_getsetters,\n" +"};\n" +"\n" +"static PyModuleDef custommodule = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"custom3\",\n" +" .m_doc = \"Example module that creates an extension type.\",\n" +" .m_size = -1,\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_custom3(void)\n" +"{\n" +" PyObject *m;\n" +" if (PyType_Ready(&CustomType) < 0)\n" +" return NULL;\n" +"\n" +" m = PyModule_Create(&custommodule);\n" +" if (m == NULL)\n" +" return NULL;\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" Py_DECREF(m);\n" +" return NULL;\n" +" }\n" +"\n" +" return m;\n" +"}\n" msgstr "" #: extending/newtypes_tutorial.rst:543 @@ -562,6 +1200,37 @@ msgid "" "functions for getting and setting the :attr:`!first` attribute::" msgstr "" +#: extending/newtypes_tutorial.rst:547 +msgid "" +"static PyObject *\n" +"Custom_getfirst(CustomObject *self, void *closure)\n" +"{\n" +" Py_INCREF(self->first);\n" +" return self->first;\n" +"}\n" +"\n" +"static int\n" +"Custom_setfirst(CustomObject *self, PyObject *value, void *closure)\n" +"{\n" +" PyObject *tmp;\n" +" if (value == NULL) {\n" +" PyErr_SetString(PyExc_TypeError, \"Cannot delete the first " +"attribute\");\n" +" return -1;\n" +" }\n" +" if (!PyUnicode_Check(value)) {\n" +" PyErr_SetString(PyExc_TypeError,\n" +" \"The first attribute value must be a string\");\n" +" return -1;\n" +" }\n" +" tmp = self->first;\n" +" Py_INCREF(value);\n" +" self->first = value;\n" +" Py_DECREF(tmp);\n" +" return 0;\n" +"}" +msgstr "" + #: extending/newtypes_tutorial.rst:574 msgid "" "The getter function is passed a :class:`!Custom` object and a \"closure\", " @@ -584,10 +1253,25 @@ msgstr "" msgid "We create an array of :c:type:`PyGetSetDef` structures::" msgstr "" +#: extending/newtypes_tutorial.rst:587 +msgid "" +"static PyGetSetDef Custom_getsetters[] = {\n" +" {\"first\", (getter) Custom_getfirst, (setter) Custom_setfirst,\n" +" \"first name\", NULL},\n" +" {\"last\", (getter) Custom_getlast, (setter) Custom_setlast,\n" +" \"last name\", NULL},\n" +" {NULL} /* Sentinel */\n" +"};" +msgstr "" + #: extending/newtypes_tutorial.rst:595 msgid "and register it in the :c:member:`~PyTypeObject.tp_getset` slot::" msgstr "" +#: extending/newtypes_tutorial.rst:597 +msgid ".tp_getset = Custom_getsetters," +msgstr "" + #: extending/newtypes_tutorial.rst:599 msgid "" "The last item in a :c:type:`PyGetSetDef` structure is the \"closure\" " @@ -599,12 +1283,50 @@ msgstr "" msgid "We also remove the member definitions for these attributes::" msgstr "" +#: extending/newtypes_tutorial.rst:604 +msgid "" +"static PyMemberDef Custom_members[] = {\n" +" {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" +" \"custom number\"},\n" +" {NULL} /* Sentinel */\n" +"};" +msgstr "" + #: extending/newtypes_tutorial.rst:610 msgid "" "We also need to update the :c:member:`~PyTypeObject.tp_init` handler to only " "allow strings [#]_ to be passed::" msgstr "" +#: extending/newtypes_tutorial.rst:613 +msgid "" +"static int\n" +"Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)\n" +"{\n" +" static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" +" PyObject *first = NULL, *last = NULL, *tmp;\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|UUi\", kwlist,\n" +" &first, &last,\n" +" &self->number))\n" +" return -1;\n" +"\n" +" if (first) {\n" +" tmp = self->first;\n" +" Py_INCREF(first);\n" +" self->first = first;\n" +" Py_DECREF(tmp);\n" +" }\n" +" if (last) {\n" +" tmp = self->last;\n" +" Py_INCREF(last);\n" +" self->last = last;\n" +" Py_DECREF(tmp);\n" +" }\n" +" return 0;\n" +"}" +msgstr "" + #: extending/newtypes_tutorial.rst:639 msgid "" "With these changes, we can assure that the ``first`` and ``last`` members " @@ -633,6 +1355,13 @@ msgid "" "This can happen when objects are involved in cycles. For example, consider:" msgstr "" +#: extending/newtypes_tutorial.rst:658 +msgid "" +">>> l = []\n" +">>> l.append(l)\n" +">>> del l" +msgstr "" + #: extending/newtypes_tutorial.rst:664 msgid "" "In this example, we create a list that contains itself. When we delete it, " @@ -645,9 +1374,19 @@ msgstr "" msgid "" "In the second version of the :class:`!Custom` example, we allowed any kind " "of object to be stored in the :attr:`!first` or :attr:`!last` attributes " -"[#]_. Besides, in the second and third versions, we allowed subclassing :" -"class:`!Custom`, and subclasses may add arbitrary attributes. For any of " -"those two reasons, :class:`!Custom` objects can participate in cycles:" +"[#]_. Besides, in the second and third versions, we allowed " +"subclassing :class:`!Custom`, and subclasses may add arbitrary attributes. " +"For any of those two reasons, :class:`!Custom` objects can participate in " +"cycles:" +msgstr "" + +#: extending/newtypes_tutorial.rst:675 +msgid "" +">>> import custom3\n" +">>> class Derived(custom3.Custom): pass\n" +"...\n" +">>> n = Derived()\n" +">>> n.some_attribute = n" msgstr "" #: extending/newtypes_tutorial.rst:683 @@ -658,19 +1397,236 @@ msgid "" "these slots:" msgstr "" +#: extending/newtypes_tutorial.rst:687 +msgid "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"#include /* for offsetof() */\n" +"\n" +"typedef struct {\n" +" PyObject_HEAD\n" +" PyObject *first; /* first name */\n" +" PyObject *last; /* last name */\n" +" int number;\n" +"} CustomObject;\n" +"\n" +"static int\n" +"Custom_traverse(CustomObject *self, visitproc visit, void *arg)\n" +"{\n" +" Py_VISIT(self->first);\n" +" Py_VISIT(self->last);\n" +" return 0;\n" +"}\n" +"\n" +"static int\n" +"Custom_clear(CustomObject *self)\n" +"{\n" +" Py_CLEAR(self->first);\n" +" Py_CLEAR(self->last);\n" +" return 0;\n" +"}\n" +"\n" +"static void\n" +"Custom_dealloc(CustomObject *self)\n" +"{\n" +" PyObject_GC_UnTrack(self);\n" +" Custom_clear(self);\n" +" Py_TYPE(self)->tp_free((PyObject *) self);\n" +"}\n" +"\n" +"static PyObject *\n" +"Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self;\n" +" self = (CustomObject *) type->tp_alloc(type, 0);\n" +" if (self != NULL) {\n" +" self->first = PyUnicode_FromString(\"\");\n" +" if (self->first == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->last = PyUnicode_FromString(\"\");\n" +" if (self->last == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->number = 0;\n" +" }\n" +" return (PyObject *) self;\n" +"}\n" +"\n" +"static int\n" +"Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)\n" +"{\n" +" static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" +" PyObject *first = NULL, *last = NULL;\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|UUi\", kwlist,\n" +" &first, &last,\n" +" &self->number))\n" +" return -1;\n" +"\n" +" if (first) {\n" +" Py_SETREF(self->first, Py_NewRef(first));\n" +" }\n" +" if (last) {\n" +" Py_SETREF(self->last, Py_NewRef(last));\n" +" }\n" +" return 0;\n" +"}\n" +"\n" +"static PyMemberDef Custom_members[] = {\n" +" {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" +" \"custom number\"},\n" +" {NULL} /* Sentinel */\n" +"};\n" +"\n" +"static PyObject *\n" +"Custom_getfirst(CustomObject *self, void *closure)\n" +"{\n" +" return Py_NewRef(self->first);\n" +"}\n" +"\n" +"static int\n" +"Custom_setfirst(CustomObject *self, PyObject *value, void *closure)\n" +"{\n" +" if (value == NULL) {\n" +" PyErr_SetString(PyExc_TypeError, \"Cannot delete the first " +"attribute\");\n" +" return -1;\n" +" }\n" +" if (!PyUnicode_Check(value)) {\n" +" PyErr_SetString(PyExc_TypeError,\n" +" \"The first attribute value must be a string\");\n" +" return -1;\n" +" }\n" +" Py_XSETREF(self->first, Py_NewRef(value));\n" +" return 0;\n" +"}\n" +"\n" +"static PyObject *\n" +"Custom_getlast(CustomObject *self, void *closure)\n" +"{\n" +" return Py_NewRef(self->last);\n" +"}\n" +"\n" +"static int\n" +"Custom_setlast(CustomObject *self, PyObject *value, void *closure)\n" +"{\n" +" if (value == NULL) {\n" +" PyErr_SetString(PyExc_TypeError, \"Cannot delete the last " +"attribute\");\n" +" return -1;\n" +" }\n" +" if (!PyUnicode_Check(value)) {\n" +" PyErr_SetString(PyExc_TypeError,\n" +" \"The last attribute value must be a string\");\n" +" return -1;\n" +" }\n" +" Py_XSETREF(self->last, Py_NewRef(value));\n" +" return 0;\n" +"}\n" +"\n" +"static PyGetSetDef Custom_getsetters[] = {\n" +" {\"first\", (getter) Custom_getfirst, (setter) Custom_setfirst,\n" +" \"first name\", NULL},\n" +" {\"last\", (getter) Custom_getlast, (setter) Custom_setlast,\n" +" \"last name\", NULL},\n" +" {NULL} /* Sentinel */\n" +"};\n" +"\n" +"static PyObject *\n" +"Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))\n" +"{\n" +" return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" +"}\n" +"\n" +"static PyMethodDef Custom_methods[] = {\n" +" {\"name\", (PyCFunction) Custom_name, METH_NOARGS,\n" +" \"Return the name, combining the first and last name\"\n" +" },\n" +" {NULL} /* Sentinel */\n" +"};\n" +"\n" +"static PyTypeObject CustomType = {\n" +" .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"custom4.Custom\",\n" +" .tp_doc = PyDoc_STR(\"Custom objects\"),\n" +" .tp_basicsize = sizeof(CustomObject),\n" +" .tp_itemsize = 0,\n" +" .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | " +"Py_TPFLAGS_HAVE_GC,\n" +" .tp_new = Custom_new,\n" +" .tp_init = (initproc) Custom_init,\n" +" .tp_dealloc = (destructor) Custom_dealloc,\n" +" .tp_traverse = (traverseproc) Custom_traverse,\n" +" .tp_clear = (inquiry) Custom_clear,\n" +" .tp_members = Custom_members,\n" +" .tp_methods = Custom_methods,\n" +" .tp_getset = Custom_getsetters,\n" +"};\n" +"\n" +"static PyModuleDef custommodule = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"custom4\",\n" +" .m_doc = \"Example module that creates an extension type.\",\n" +" .m_size = -1,\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_custom4(void)\n" +"{\n" +" PyObject *m;\n" +" if (PyType_Ready(&CustomType) < 0)\n" +" return NULL;\n" +"\n" +" m = PyModule_Create(&custommodule);\n" +" if (m == NULL)\n" +" return NULL;\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" Py_DECREF(m);\n" +" return NULL;\n" +" }\n" +"\n" +" return m;\n" +"}\n" +msgstr "" + #: extending/newtypes_tutorial.rst:690 msgid "" "First, the traversal method lets the cyclic GC know about subobjects that " "could participate in cycles::" msgstr "" +#: extending/newtypes_tutorial.rst:693 +msgid "" +"static int\n" +"Custom_traverse(CustomObject *self, visitproc visit, void *arg)\n" +"{\n" +" int vret;\n" +" if (self->first) {\n" +" vret = visit(self->first, arg);\n" +" if (vret != 0)\n" +" return vret;\n" +" }\n" +" if (self->last) {\n" +" vret = visit(self->last, arg);\n" +" if (vret != 0)\n" +" return vret;\n" +" }\n" +" return 0;\n" +"}" +msgstr "" + #: extending/newtypes_tutorial.rst:710 msgid "" -"For each subobject that can participate in cycles, we need to call the :c:" -"func:`!visit` function, which is passed to the traversal method. The :c:func:" -"`!visit` function takes as arguments the subobject and the extra argument " -"*arg* passed to the traversal method. It returns an integer value that must " -"be returned if it is non-zero." +"For each subobject that can participate in cycles, we need to call " +"the :c:func:`!visit` function, which is passed to the traversal method. " +"The :c:func:`!visit` function takes as arguments the subobject and the extra " +"argument *arg* passed to the traversal method. It returns an integer value " +"that must be returned if it is non-zero." msgstr "" #: extending/newtypes_tutorial.rst:716 @@ -680,6 +1636,17 @@ msgid "" "boilerplate in ``Custom_traverse``::" msgstr "" +#: extending/newtypes_tutorial.rst:720 +msgid "" +"static int\n" +"Custom_traverse(CustomObject *self, visitproc visit, void *arg)\n" +"{\n" +" Py_VISIT(self->first);\n" +" Py_VISIT(self->last);\n" +" return 0;\n" +"}" +msgstr "" + #: extending/newtypes_tutorial.rst:729 msgid "" "The :c:member:`~PyTypeObject.tp_traverse` implementation must name its " @@ -692,6 +1659,17 @@ msgid "" "participate in cycles::" msgstr "" +#: extending/newtypes_tutorial.rst:735 +msgid "" +"static int\n" +"Custom_clear(CustomObject *self)\n" +"{\n" +" Py_CLEAR(self->first);\n" +" Py_CLEAR(self->last);\n" +" return 0;\n" +"}" +msgstr "" + #: extending/newtypes_tutorial.rst:743 msgid "" "Notice the use of the :c:func:`Py_CLEAR` macro. It is the recommended and " @@ -706,11 +1684,19 @@ msgstr "" msgid "You could emulate :c:func:`Py_CLEAR` by writing::" msgstr "" +#: extending/newtypes_tutorial.rst:753 +msgid "" +"PyObject *tmp;\n" +"tmp = self->first;\n" +"self->first = NULL;\n" +"Py_XDECREF(tmp);" +msgstr "" + #: extending/newtypes_tutorial.rst:758 msgid "" -"Nevertheless, it is much easier and less error-prone to always use :c:func:" -"`Py_CLEAR` when deleting an attribute. Don't try to micro-optimize at the " -"expense of robustness!" +"Nevertheless, it is much easier and less error-prone to always " +"use :c:func:`Py_CLEAR` when deleting an attribute. Don't try to micro-" +"optimize at the expense of robustness!" msgstr "" #: extending/newtypes_tutorial.rst:762 @@ -719,8 +1705,19 @@ msgid "" "attributes. It means the circular GC can be triggered inside the function. " "Since the GC assumes reference count is not zero, we need to untrack the " "object from the GC by calling :c:func:`PyObject_GC_UnTrack` before clearing " -"members. Here is our reimplemented deallocator using :c:func:" -"`PyObject_GC_UnTrack` and ``Custom_clear``::" +"members. Here is our reimplemented deallocator " +"using :c:func:`PyObject_GC_UnTrack` and ``Custom_clear``::" +msgstr "" + +#: extending/newtypes_tutorial.rst:769 +msgid "" +"static void\n" +"Custom_dealloc(CustomObject *self)\n" +"{\n" +" PyObject_GC_UnTrack(self);\n" +" Custom_clear(self);\n" +" Py_TYPE(self)->tp_free((PyObject *) self);\n" +"}" msgstr "" #: extending/newtypes_tutorial.rst:777 @@ -728,11 +1725,17 @@ msgid "" "Finally, we add the :c:macro:`Py_TPFLAGS_HAVE_GC` flag to the class flags::" msgstr "" +#: extending/newtypes_tutorial.rst:779 +msgid "" +".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC," +msgstr "" + #: extending/newtypes_tutorial.rst:781 msgid "" -"That's pretty much it. If we had written custom :c:member:`~PyTypeObject." -"tp_alloc` or :c:member:`~PyTypeObject.tp_free` handlers, we'd need to modify " -"them for cyclic garbage collection. Most extensions will use the versions " +"That's pretty much it. If we had written " +"custom :c:member:`~PyTypeObject.tp_alloc` " +"or :c:member:`~PyTypeObject.tp_free` handlers, we'd need to modify them for " +"cyclic garbage collection. Most extensions will use the versions " "automatically provided." msgstr "" @@ -756,6 +1759,93 @@ msgid "" "that increases an internal counter:" msgstr "" +#: extending/newtypes_tutorial.rst:799 +msgid "" +">>> import sublist\n" +">>> s = sublist.SubList(range(3))\n" +">>> s.extend(s)\n" +">>> print(len(s))\n" +"6\n" +">>> print(s.increment())\n" +"1\n" +">>> print(s.increment())\n" +"2" +msgstr "" + +#: extending/newtypes_tutorial.rst:811 +msgid "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"\n" +"typedef struct {\n" +" PyListObject list;\n" +" int state;\n" +"} SubListObject;\n" +"\n" +"static PyObject *\n" +"SubList_increment(SubListObject *self, PyObject *unused)\n" +"{\n" +" self->state++;\n" +" return PyLong_FromLong(self->state);\n" +"}\n" +"\n" +"static PyMethodDef SubList_methods[] = {\n" +" {\"increment\", (PyCFunction) SubList_increment, METH_NOARGS,\n" +" PyDoc_STR(\"increment state counter\")},\n" +" {NULL},\n" +"};\n" +"\n" +"static int\n" +"SubList_init(SubListObject *self, PyObject *args, PyObject *kwds)\n" +"{\n" +" if (PyList_Type.tp_init((PyObject *) self, args, kwds) < 0)\n" +" return -1;\n" +" self->state = 0;\n" +" return 0;\n" +"}\n" +"\n" +"static PyTypeObject SubListType = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"sublist.SubList\",\n" +" .tp_doc = PyDoc_STR(\"SubList objects\"),\n" +" .tp_basicsize = sizeof(SubListObject),\n" +" .tp_itemsize = 0,\n" +" .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,\n" +" .tp_init = (initproc) SubList_init,\n" +" .tp_methods = SubList_methods,\n" +"};\n" +"\n" +"static PyModuleDef sublistmodule = {\n" +" PyModuleDef_HEAD_INIT,\n" +" .m_name = \"sublist\",\n" +" .m_doc = \"Example module that creates an extension type.\",\n" +" .m_size = -1,\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_sublist(void)\n" +"{\n" +" PyObject *m;\n" +" SubListType.tp_base = &PyList_Type;\n" +" if (PyType_Ready(&SubListType) < 0)\n" +" return NULL;\n" +"\n" +" m = PyModule_Create(&sublistmodule);\n" +" if (m == NULL)\n" +" return NULL;\n" +"\n" +" Py_INCREF(&SubListType);\n" +" if (PyModule_AddObject(m, \"SubList\", (PyObject *) &SubListType) < 0) " +"{\n" +" Py_DECREF(&SubListType);\n" +" Py_DECREF(m);\n" +" return NULL;\n" +" }\n" +"\n" +" return m;\n" +"}\n" +msgstr "" + #: extending/newtypes_tutorial.rst:814 msgid "" "As you can see, the source code closely resembles the :class:`!Custom` " @@ -763,6 +1853,14 @@ msgid "" "between them. ::" msgstr "" +#: extending/newtypes_tutorial.rst:817 +msgid "" +"typedef struct {\n" +" PyListObject list;\n" +" int state;\n" +"} SubListObject;" +msgstr "" + #: extending/newtypes_tutorial.rst:822 msgid "" "The primary difference for derived type objects is that the base type's " @@ -777,6 +1875,18 @@ msgid "" "*``::" msgstr "" +#: extending/newtypes_tutorial.rst:829 +msgid "" +"static int\n" +"SubList_init(SubListObject *self, PyObject *args, PyObject *kwds)\n" +"{\n" +" if (PyList_Type.tp_init((PyObject *) self, args, kwds) < 0)\n" +" return -1;\n" +" self->state = 0;\n" +" return 0;\n" +"}" +msgstr "" + #: extending/newtypes_tutorial.rst:838 msgid "" "We see above how to call through to the :meth:`~object.__init__` method of " @@ -785,8 +1895,9 @@ msgstr "" #: extending/newtypes_tutorial.rst:841 msgid "" -"This pattern is important when writing a type with custom :c:member:" -"`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_dealloc` members. " +"This pattern is important when writing a type with " +"custom :c:member:`~PyTypeObject.tp_new` " +"and :c:member:`~PyTypeObject.tp_dealloc` members. " "The :c:member:`~PyTypeObject.tp_new` handler should not actually create the " "memory for the object with its :c:member:`~PyTypeObject.tp_alloc`, but let " "the base class handle it by calling its own :c:member:`~PyTypeObject.tp_new`." @@ -794,20 +1905,46 @@ msgstr "" #: extending/newtypes_tutorial.rst:847 msgid "" -"The :c:type:`PyTypeObject` struct supports a :c:member:`~PyTypeObject." -"tp_base` specifying the type's concrete base class. Due to cross-platform " -"compiler issues, you can't fill that field directly with a reference to :c:" -"type:`PyList_Type`; it should be done later in the module initialization " -"function::" +"The :c:type:`PyTypeObject` struct supports " +"a :c:member:`~PyTypeObject.tp_base` specifying the type's concrete base " +"class. Due to cross-platform compiler issues, you can't fill that field " +"directly with a reference to :c:type:`PyList_Type`; it should be done later " +"in the module initialization function::" +msgstr "" + +#: extending/newtypes_tutorial.rst:853 +msgid "" +"PyMODINIT_FUNC\n" +"PyInit_sublist(void)\n" +"{\n" +" PyObject* m;\n" +" SubListType.tp_base = &PyList_Type;\n" +" if (PyType_Ready(&SubListType) < 0)\n" +" return NULL;\n" +"\n" +" m = PyModule_Create(&sublistmodule);\n" +" if (m == NULL)\n" +" return NULL;\n" +"\n" +" Py_INCREF(&SubListType);\n" +" if (PyModule_AddObject(m, \"SubList\", (PyObject *) &SubListType) < 0) " +"{\n" +" Py_DECREF(&SubListType);\n" +" Py_DECREF(m);\n" +" return NULL;\n" +" }\n" +"\n" +" return m;\n" +"}" msgstr "" #: extending/newtypes_tutorial.rst:875 msgid "" -"Before calling :c:func:`PyType_Ready`, the type structure must have the :c:" -"member:`~PyTypeObject.tp_base` slot filled in. When we are deriving an " -"existing type, it is not necessary to fill out the :c:member:`~PyTypeObject." -"tp_alloc` slot with :c:func:`PyType_GenericNew` -- the allocation function " -"from the base type will be inherited." +"Before calling :c:func:`PyType_Ready`, the type structure must have " +"the :c:member:`~PyTypeObject.tp_base` slot filled in. When we are deriving " +"an existing type, it is not necessary to fill out " +"the :c:member:`~PyTypeObject.tp_alloc` slot with :c:func:`PyType_GenericNew` " +"-- the allocation function from the base type will be inherited." msgstr "" #: extending/newtypes_tutorial.rst:881 diff --git a/extending/windows.po b/extending/windows.po index d3c73163..43889401 100644 --- a/extending/windows.po +++ b/extending/windows.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -108,15 +109,15 @@ msgstr "" #: extending/windows.rst:76 msgid "" "In Windows, there are two types of library, a static library and an import " -"library (both called :file:`.lib`). A static library is like a Unix :file:`." -"a` file; it contains code to be included as necessary. An import library is " -"basically used only to reassure the linker that a certain identifier is " -"legal, and will be present in the program when the DLL is loaded. So the " -"linker uses the information from the import library to build the lookup " -"table for using identifiers that are not included in the DLL. When an " -"application or a DLL is linked, an import library may be generated, which " -"will need to be used for all future DLLs that depend on the symbols in the " -"application or DLL." +"library (both called :file:`.lib`). A static library is like a " +"Unix :file:`.a` file; it contains code to be included as necessary. An " +"import library is basically used only to reassure the linker that a certain " +"identifier is legal, and will be present in the program when the DLL is " +"loaded. So the linker uses the information from the import library to build " +"the lookup table for using identifiers that are not included in the DLL. " +"When an application or a DLL is linked, an import library may be generated, " +"which will need to be used for all future DLLs that depend on the symbols in " +"the application or DLL." msgstr "" #: extending/windows.rst:86 @@ -125,9 +126,10 @@ msgid "" "share another block of code A. On Unix, you would *not* pass :file:`A.a` to " "the linker for :file:`B.so` and :file:`C.so`; that would cause it to be " "included twice, so that B and C would each have their own copy. In Windows, " -"building :file:`A.dll` will also build :file:`A.lib`. You *do* pass :file:" -"`A.lib` to the linker for B and C. :file:`A.lib` does not contain code; it " -"just contains information which will be used at runtime to access A's code." +"building :file:`A.dll` will also build :file:`A.lib`. You *do* " +"pass :file:`A.lib` to the linker for B and C. :file:`A.lib` does not " +"contain code; it just contains information which will be used at runtime to " +"access A's code." msgstr "" #: extending/windows.rst:94 @@ -155,6 +157,12 @@ msgid "" "spam), you could use these commands::" msgstr "" +#: extending/windows.rst:115 +msgid "" +"cl /LD /I/python/include spam.c ../libs/pythonXY.lib\n" +"cl /LD /I/python/include ni.c spam.lib ../libs/pythonXY.lib" +msgstr "" + #: extending/windows.rst:118 msgid "" "The first command created three files: :file:`spam.obj`, :file:`spam.dll` " @@ -165,9 +173,9 @@ msgstr "" #: extending/windows.rst:123 msgid "" -"The second command created :file:`ni.dll` (and :file:`.obj` and :file:`." -"lib`), which knows how to find the necessary functions from spam, and also " -"from the Python executable." +"The second command created :file:`ni.dll` (and :file:`.obj` " +"and :file:`.lib`), which knows how to find the necessary functions from " +"spam, and also from the Python executable." msgstr "" #: extending/windows.rst:127 diff --git a/faq/design.po b/faq/design.po index c2fe6679..7c0710c4 100644 --- a/faq/design.po +++ b/faq/design.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -42,6 +43,14 @@ msgid "" "programmers will encounter a fragment of code like this::" msgstr "" +#: faq/design.rst:21 +msgid "" +"if (x <= y)\n" +" x++;\n" +" y--;\n" +"z++;" +msgstr "" + #: faq/design.rst:26 msgid "" "Only the ``x++`` statement is executed if the condition is true, but the " @@ -86,6 +95,12 @@ msgstr "" msgid "Users are often surprised by results like this::" msgstr "" +#: faq/design.rst:58 +msgid "" +">>> 1.2 - 1.0\n" +"0.19999999999999996" +msgstr "" + #: faq/design.rst:61 msgid "" "and think it is a bug in Python. It's not. This has little to do with " @@ -95,18 +110,23 @@ msgstr "" #: faq/design.rst:65 msgid "" -"The :class:`float` type in CPython uses a C ``double`` for storage. A :" -"class:`float` object's value is stored in binary floating-point with a fixed " -"precision (typically 53 bits) and Python uses C operations, which in turn " -"rely on the hardware implementation in the processor, to perform floating-" -"point operations. This means that as far as floating-point operations are " -"concerned, Python behaves like many popular languages including C and Java." +"The :class:`float` type in CPython uses a C ``double`` for storage. " +"A :class:`float` object's value is stored in binary floating-point with a " +"fixed precision (typically 53 bits) and Python uses C operations, which in " +"turn rely on the hardware implementation in the processor, to perform " +"floating-point operations. This means that as far as floating-point " +"operations are concerned, Python behaves like many popular languages " +"including C and Java." msgstr "" #: faq/design.rst:72 msgid "" "Many numbers that can be written easily in decimal notation cannot be " -"expressed exactly in binary floating-point. For example, after::" +"expressed exactly in binary floating point. For example, after::" +msgstr "" + +#: faq/design.rst:75 +msgid ">>> x = 1.2" msgstr "" #: faq/design.rst:77 @@ -116,10 +136,18 @@ msgid "" "actual stored value is::" msgstr "" +#: faq/design.rst:81 +msgid "1.0011001100110011001100110011001100110011001100110011 (binary)" +msgstr "" + #: faq/design.rst:83 msgid "which is exactly::" msgstr "" +#: faq/design.rst:85 +msgid "1.1999999999999999555910790149937383830547332763671875 (decimal)" +msgstr "" + #: faq/design.rst:87 msgid "" "The typical precision of 53 bits provides Python floats with 15--16 decimal " @@ -128,7 +156,7 @@ msgstr "" #: faq/design.rst:90 msgid "" -"For a fuller explanation, please see the :ref:`floating point arithmetic " +"For a fuller explanation, please see the :ref:`floating-point arithmetic " "` chapter in the Python tutorial." msgstr "" @@ -223,6 +251,12 @@ msgid "" "an expression::" msgstr "" +#: faq/design.rst:161 +msgid "" +"while chunk := fp.read(200):\n" +" print(chunk)" +msgstr "" + #: faq/design.rst:164 msgid "See :pep:`572` for more information." msgstr "" @@ -250,12 +284,12 @@ msgstr "" msgid "" "(b) When I read code that says len(x) I *know* that it is asking for the " "length of something. This tells me two things: the result is an integer, and " -"the argument is some kind of container. To the contrary, when I read x." -"len(), I have to already know that x is some kind of container implementing " -"an interface or inheriting from a class that has a standard len(). Witness " -"the confusion we occasionally have when a class that is not implementing a " -"mapping has a get() or keys() method, or something that isn't a file has a " -"write() method." +"the argument is some kind of container. To the contrary, when I read " +"x.len(), I have to already know that x is some kind of container " +"implementing an interface or inheriting from a class that has a standard " +"len(). Witness the confusion we occasionally have when a class that is not " +"implementing a mapping has a get() or keys() method, or something that isn't " +"a file has a write() method." msgstr "" #: faq/design.rst:189 @@ -275,10 +309,18 @@ msgid "" "programmers feel uncomfortable is::" msgstr "" +#: faq/design.rst:201 +msgid "\", \".join(['1', '2', '4', '8', '16'])" +msgstr "" + #: faq/design.rst:203 msgid "which gives the result::" msgstr "" +#: faq/design.rst:205 +msgid "\"1, 2, 4, 8, 16\"" +msgstr "" + #: faq/design.rst:207 msgid "There are two common arguments against this usage." msgstr "" @@ -296,8 +338,13 @@ msgstr "" msgid "" "The second objection is typically cast as: \"I am really telling a sequence " "to join its members together with a string constant\". Sadly, you aren't. " -"For some reason there seems to be much less difficulty with having :meth:" -"`~str.split` as a string method, since in that case it is easy to see that ::" +"For some reason there seems to be much less difficulty with " +"having :meth:`~str.split` as a string method, since in that case it is easy " +"to see that ::" +msgstr "" + +#: faq/design.rst:220 +msgid "\"1, 2, 4, 8, 16\".split(\", \")" msgstr "" #: faq/design.rst:222 @@ -326,12 +373,29 @@ msgid "" "versions of Python prior to 2.0 it was common to use this idiom::" msgstr "" +#: faq/design.rst:240 +msgid "" +"try:\n" +" value = mydict[key]\n" +"except KeyError:\n" +" mydict[key] = getvalue(key)\n" +" value = mydict[key]" +msgstr "" + #: faq/design.rst:246 msgid "" "This only made sense when you expected the dict to have the key almost all " "the time. If that wasn't the case, you coded it like this::" msgstr "" +#: faq/design.rst:249 +msgid "" +"if key in mydict:\n" +" value = mydict[key]\n" +"else:\n" +" value = mydict[key] = getvalue(key)" +msgstr "" + #: faq/design.rst:254 msgid "" "For this specific case, you could also use ``value = dict.setdefault(key, " @@ -359,10 +423,32 @@ msgid "" "to call. For example::" msgstr "" +#: faq/design.rst:272 +msgid "" +"functions = {'a': function_1,\n" +" 'b': function_2,\n" +" 'c': self.method_1}\n" +"\n" +"func = functions[value]\n" +"func()" +msgstr "" + #: faq/design.rst:279 msgid "" -"For calling methods on objects, you can simplify yet further by using the :" -"func:`getattr` built-in to retrieve methods with a particular name::" +"For calling methods on objects, you can simplify yet further by using " +"the :func:`getattr` built-in to retrieve methods with a particular name::" +msgstr "" + +#: faq/design.rst:282 +msgid "" +"class MyVisitor:\n" +" def visit_a(self):\n" +" ...\n" +"\n" +" def dispatch(self, value):\n" +" method_name = 'visit_' + str(value)\n" +" method = getattr(self, method_name)\n" +" method()" msgstr "" #: faq/design.rst:291 @@ -430,8 +516,8 @@ msgstr "" #: faq/design.rst:330 msgid "" "`Cython `_ compiles a modified version of Python with " -"optional annotations into C extensions. `Nuitka `_ " -"is an up-and-coming compiler of Python into C++ code, aiming to support the " +"optional annotations into C extensions. `Nuitka `_ is " +"an up-and-coming compiler of Python into C++ code, aiming to support the " "full Python language." msgstr "" @@ -453,10 +539,10 @@ msgstr "" #: faq/design.rst:347 msgid "" "Other implementations (such as `Jython `_ or `PyPy " -"`_), however, can rely on a different mechanism such " -"as a full-blown garbage collector. This difference can cause some subtle " -"porting problems if your Python code depends on the behavior of the " -"reference counting implementation." +"`_), however, can rely on a different mechanism such as a " +"full-blown garbage collector. This difference can cause some subtle porting " +"problems if your Python code depends on the behavior of the reference " +"counting implementation." msgstr "" #: faq/design.rst:353 @@ -465,6 +551,13 @@ msgid "" "CPython) will probably run out of file descriptors::" msgstr "" +#: faq/design.rst:356 +msgid "" +"for file in very_long_list_of_files:\n" +" f = open(file)\n" +" c = f.read(1)" +msgstr "" + #: faq/design.rst:360 msgid "" "Indeed, using CPython's reference counting and destructor scheme, each new " @@ -480,6 +573,13 @@ msgid "" "will work regardless of memory management scheme::" msgstr "" +#: faq/design.rst:369 +msgid "" +"for file in very_long_list_of_files:\n" +" with open(file) as f:\n" +" c = f.read(1)" +msgstr "" + #: faq/design.rst:375 msgid "Why doesn't CPython use a more traditional garbage collection scheme?" msgstr "" @@ -542,10 +642,10 @@ msgstr "" msgid "" "Lists, on the other hand, are more like arrays in other languages. They " "tend to hold a varying number of objects all of which have the same type and " -"which are operated on one-by-one. For example, :func:`os.listdir('.') ` returns a list of strings representing the files in the current " -"directory. Functions which operate on this output would generally not break " -"if you added another file or two to the directory." +"which are operated on one-by-one. For example, :func:`os.listdir('.') " +"` returns a list of strings representing the files in the " +"current directory. Functions which operate on this output would generally " +"not break if you added another file or two to the directory." msgstr "" #: faq/design.rst:423 @@ -643,12 +743,18 @@ msgid "" "construct a new list with the same value it won't be found; e.g.::" msgstr "" +#: faq/design.rst:483 +msgid "" +"mydict = {[1, 2]: '12'}\n" +"print(mydict[[1, 2]])" +msgstr "" + #: faq/design.rst:486 msgid "" "would raise a :exc:`KeyError` exception because the id of the ``[1, 2]`` " "used in the second line differs from that in the first line. In other " -"words, dictionary keys should be compared using ``==``, not using :keyword:" -"`is`." +"words, dictionary keys should be compared using ``==``, not " +"using :keyword:`is`." msgstr "" #: faq/design.rst:490 @@ -686,6 +792,26 @@ msgid "" "the object is in the dictionary (or other structure). ::" msgstr "" +#: faq/design.rst:513 +msgid "" +"class ListWrapper:\n" +" def __init__(self, the_list):\n" +" self.the_list = the_list\n" +"\n" +" def __eq__(self, other):\n" +" return self.the_list == other.the_list\n" +"\n" +" def __hash__(self):\n" +" l = self.the_list\n" +" result = 98767 - len(l)*555\n" +" for i, el in enumerate(l):\n" +" try:\n" +" result = result + (hash(el) % 9999999) * 1001 + i\n" +" except Exception:\n" +" result = (result % 7777777) + i * 333\n" +" return result" +msgstr "" + #: faq/design.rst:530 msgid "" "Note that the hash computation is complicated by the possibility that some " @@ -695,11 +821,11 @@ msgstr "" #: faq/design.rst:534 msgid "" -"Furthermore it must always be the case that if ``o1 == o2`` (ie ``o1." -"__eq__(o2) is True``) then ``hash(o1) == hash(o2)`` (ie, ``o1.__hash__() == " -"o2.__hash__()``), regardless of whether the object is in a dictionary or " -"not. If you fail to meet these restrictions dictionaries and other hash " -"based structures will misbehave." +"Furthermore it must always be the case that if ``o1 == o2`` (ie " +"``o1.__eq__(o2) is True``) then ``hash(o1) == hash(o2)`` (ie, " +"``o1.__hash__() == o2.__hash__()``), regardless of whether the object is in " +"a dictionary or not. If you fail to meet these restrictions dictionaries " +"and other hash based structures will misbehave." msgstr "" #: faq/design.rst:539 @@ -732,6 +858,12 @@ msgid "" "dictionary in sorted order::" msgstr "" +#: faq/design.rst:559 +msgid "" +"for key in sorted(mydict):\n" +" ... # do whatever with mydict[key]..." +msgstr "" + #: faq/design.rst:564 msgid "How do you specify and enforce an interface spec in Python?" msgstr "" @@ -748,10 +880,10 @@ msgstr "" msgid "" "Python 2.6 adds an :mod:`abc` module that lets you define Abstract Base " "Classes (ABCs). You can then use :func:`isinstance` and :func:`issubclass` " -"to check whether an instance or a class implements a particular ABC. The :" -"mod:`collections.abc` module defines a set of useful ABCs such as :class:" -"`~collections.abc.Iterable`, :class:`~collections.abc.Container`, and :class:" -"`~collections.abc.MutableMapping`." +"to check whether an instance or a class implements a particular ABC. " +"The :mod:`collections.abc` module defines a set of useful ABCs such " +"as :class:`~collections.abc.Iterable`, :class:`~collections.abc.Container`, " +"and :class:`~collections.abc.MutableMapping`." msgstr "" #: faq/design.rst:578 @@ -766,10 +898,10 @@ msgid "" "as a module interface specification and a set of examples. Many Python " "modules can be run as a script to provide a simple \"self test.\" Even " "modules which use complex external interfaces can often be tested in " -"isolation using trivial \"stub\" emulations of the external interface. The :" -"mod:`doctest` and :mod:`unittest` modules or third-party test frameworks can " -"be used to construct exhaustive test suites that exercise every line of code " -"in a module." +"isolation using trivial \"stub\" emulations of the external interface. " +"The :mod:`doctest` and :mod:`unittest` modules or third-party test " +"frameworks can be used to construct exhaustive test suites that exercise " +"every line of code in a module." msgstr "" #: faq/design.rst:589 @@ -803,9 +935,9 @@ msgid "" "\"spaghetti\" code that was hard to understand and revise. In a high-level " "language, it is also unneeded as long as there are ways to branch (in " "Python, with :keyword:`if` statements and :keyword:`or`, :keyword:`and`, " -"and :keyword:`if`/:keyword:`else` expressions) and loop (with :keyword:" -"`while` and :keyword:`for` statements, possibly containing :keyword:" -"`continue` and :keyword:`break`)." +"and :keyword:`if`/:keyword:`else` expressions) and loop " +"(with :keyword:`while` and :keyword:`for` statements, possibly " +"containing :keyword:`continue` and :keyword:`break`)." msgstr "" #: faq/design.rst:614 @@ -816,6 +948,19 @@ msgid "" "other languages. For example::" msgstr "" +#: faq/design.rst:620 +msgid "" +"class label(Exception): pass # declare a label\n" +"\n" +"try:\n" +" ...\n" +" if condition: raise label() # goto label\n" +" ...\n" +"except label: # where to goto\n" +" pass\n" +"..." +msgstr "" + #: faq/design.rst:630 msgid "" "This doesn't allow you to jump into the middle of a loop, but that's usually " @@ -849,11 +994,22 @@ msgid "" "calls accept forward slashes too::" msgstr "" +#: faq/design.rst:651 +msgid "f = open(\"/mydir/file.txt\") # works fine!" +msgstr "" + #: faq/design.rst:653 msgid "" "If you're trying to build a pathname for a DOS command, try e.g. one of ::" msgstr "" +#: faq/design.rst:655 +msgid "" +"dir = r\"\\this\\is\\my\\dos\\dir\" \"\\\\\"\n" +"dir = r\"\\this\\is\\my\\dos\\dir\\ \"[:-1]\n" +"dir = \"\\\\this\\\\is\\\\my\\\\dos\\\\dir\\\\\"" +msgstr "" + #: faq/design.rst:661 msgid "Why doesn't Python have a \"with\" statement for attribute assignments?" msgstr "" @@ -865,6 +1021,13 @@ msgid "" "construct that looks like this::" msgstr "" +#: faq/design.rst:667 +msgid "" +"with obj:\n" +" a = 1 # equivalent to obj.a = 1\n" +" total = total + 1 # obj.total = obj.total + 1" +msgstr "" + #: faq/design.rst:671 msgid "In Python, such a construct would be ambiguous." msgstr "" @@ -890,6 +1053,13 @@ msgstr "" msgid "For instance, take the following incomplete snippet::" msgstr "" +#: faq/design.rst:686 +msgid "" +"def foo(a):\n" +" with a:\n" +" print(x)" +msgstr "" + #: faq/design.rst:690 msgid "" "The snippet assumes that ``a`` must have a member attribute called ``x``. " @@ -906,10 +1076,25 @@ msgid "" "assignment. Instead of::" msgstr "" +#: faq/design.rst:699 +msgid "" +"function(args).mydict[index][index].a = 21\n" +"function(args).mydict[index][index].b = 42\n" +"function(args).mydict[index][index].c = 63" +msgstr "" + #: faq/design.rst:703 msgid "write this::" msgstr "" +#: faq/design.rst:705 +msgid "" +"ref = function(args).mydict[index][index]\n" +"ref.a = 21\n" +"ref.b = 42\n" +"ref.c = 63" +msgstr "" + #: faq/design.rst:710 msgid "" "This also has the side-effect of increasing execution speed because name " @@ -932,9 +1117,9 @@ msgstr "" msgid "" "For technical reasons, a generator used directly as a context manager would " "not work correctly. When, as is most common, a generator is used as an " -"iterator run to completion, no closing is needed. When it is, wrap it as :" -"func:`contextlib.closing(generator) ` in the :keyword:" -"`with` statement." +"iterator run to completion, no closing is needed. When it is, wrap it " +"as :func:`contextlib.closing(generator) ` in " +"the :keyword:`with` statement." msgstr "" #: faq/design.rst:730 @@ -947,10 +1132,22 @@ msgid "" "of the experimental ABC language). Consider this::" msgstr "" +#: faq/design.rst:735 +msgid "" +"if a == b\n" +" print(a)" +msgstr "" + #: faq/design.rst:738 msgid "versus ::" msgstr "" +#: faq/design.rst:740 +msgid "" +"if a == b:\n" +" print(a)" +msgstr "" + #: faq/design.rst:743 msgid "" "Notice how the second one is slightly easier to read. Notice further how a " @@ -976,6 +1173,16 @@ msgid "" "dictionaries::" msgstr "" +#: faq/design.rst:757 +msgid "" +"[1, 2, 3,]\n" +"('a', 'b', 'c',)\n" +"d = {\n" +" \"A\": [1, 5],\n" +" \"B\": [6, 7], # last trailing comma is optional but good style\n" +"}" +msgstr "" + #: faq/design.rst:765 msgid "There are several reasons to allow this." msgstr "" @@ -994,6 +1201,16 @@ msgid "" "diagnose. For example::" msgstr "" +#: faq/design.rst:775 +msgid "" +"x = [\n" +" \"fee\",\n" +" \"fie\"\n" +" \"foo\",\n" +" \"fum\"\n" +"]" +msgstr "" + #: faq/design.rst:782 msgid "" "This list looks like it has four elements, but it actually contains three: " diff --git a/faq/extending.po b/faq/extending.po index 10fd8d95..a9be62af 100644 --- a/faq/extending.po +++ b/faq/extending.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-10-31 12:22+0200\n" "Last-Translator: Panagiotis Skias \n" "Language-Team: PyGreece \n" @@ -33,8 +33,8 @@ msgstr "Μπορώ να δημιουργήσω τις δικές μου συνα #: faq/extending.rst:18 msgid "" "Yes, you can create built-in modules containing functions, variables, " -"exceptions and even new types in C. This is explained in the document :ref:" -"`extending-index`." +"exceptions and even new types in C. This is explained in the " +"document :ref:`extending-index`." msgstr "" "Ναι, μπορείτε να δημιουργήσετε ενσωματωμένα (built-in) modules που περιέχουν " "συναρτήσεις, μεταβλητές, εξαιρέσεις και ακόμη και νέους τύπους στην C. Αυτό " @@ -52,10 +52,10 @@ msgstr "Μπορώ να δημιουργήσω τις δικές μου συνα #: faq/extending.rst:28 msgid "" -"Yes, using the C compatibility features found in C++. Place ``extern " -"\"C\" { ... }`` around the Python include files and put ``extern \"C\"`` " -"before each function that is going to be called by the Python interpreter. " -"Global or static C++ objects with constructors are probably not a good idea." +"Yes, using the C compatibility features found in C++. Place ``extern \"C\" " +"{ ... }`` around the Python include files and put ``extern \"C\"`` before " +"each function that is going to be called by the Python interpreter. Global " +"or static C++ objects with constructors are probably not a good idea." msgstr "" "Ναι, χρησιμοποιώντας τις δυνατότητες συμβατότητας C που βρίσκονται στη C++. " "Τοποθετήστε το ``extern \"C\" { ... }`` γύρω από την Python να περιλαμβάνει " @@ -77,15 +77,15 @@ msgstr "" #: faq/extending.rst:44 msgid "" -"`Cython `_ and its relative `Pyrex `_ are compilers that accept a " -"slightly modified form of Python and generate the corresponding C code. " -"Cython and Pyrex make it possible to write an extension without having to " -"learn Python's C API." +"`Cython `_ and its relative `Pyrex `_ are compilers that " +"accept a slightly modified form of Python and generate the corresponding C " +"code. Cython and Pyrex make it possible to write an extension without " +"having to learn Python's C API." msgstr "" -"Το `Cython `_ και το σχετικό του `Pyrex `_ είναι μεταγλωττιστές που " -"δέχονται ελαφρώς τροποποιημένη μορφή της Python και δημιουργούν τον " +"Το `Cython `_ και το σχετικό του `Pyrex `_ είναι μεταγλωττιστές " +"που δέχονται ελαφρώς τροποποιημένη μορφή της Python και δημιουργούν τον " "αντίστοιχο C κώδικα. Το Cython και το Pyrex καθιστούν δυνατή τη σύνταξη " "μιας επέκτασης χωρίς να χρειάζεται να μάθετε το C API της Python." @@ -117,16 +117,17 @@ msgid "" "The highest-level function to do this is :c:func:`PyRun_SimpleString` which " "takes a single string argument to be executed in the context of the module " "``__main__`` and returns ``0`` for success and ``-1`` when an exception " -"occurred (including :exc:`SyntaxError`). If you want more control, use :c:" -"func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` in " -"``Python/pythonrun.c``." -msgstr "" -"Η συνάρτηση υψηλότερου επιπέδου για να γίνει αυτό είναι η :c:func:" -"`PyRun_SimpleString` η οποία εκτελεί ένα όρισμα συμβολοσειράς στο πλαίσιο " -"της ενότητας ``__main__`` και επιστρέφει ``0`` για επιτυχία και ``-1`` όταν " -"συμβαίνει μια εξαίρεση (συμπεριλαμβανομένου του :exc:`SyntaxError`). Εάν " -"θέλετε περισσότερο έλεγχο, χρησιμοποιήστε :c:func:`PyRun_String`· δείτε τον " -"πηγαίο κώδικα :c:func:`PyRun_SimpleString` στο``Python/pythonrun.c``." +"occurred (including :exc:`SyntaxError`). If you want more control, " +"use :c:func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` " +"in ``Python/pythonrun.c``." +msgstr "" +"Η συνάρτηση υψηλότερου επιπέδου για να γίνει αυτό είναι " +"η :c:func:`PyRun_SimpleString` η οποία εκτελεί ένα όρισμα συμβολοσειράς στο " +"πλαίσιο της ενότητας ``__main__`` και επιστρέφει ``0`` για επιτυχία και " +"``-1`` όταν συμβαίνει μια εξαίρεση (συμπεριλαμβανομένου " +"του :exc:`SyntaxError`). Εάν θέλετε περισσότερο έλεγχο, " +"χρησιμοποιήστε :c:func:`PyRun_String`· δείτε τον πηγαίο " +"κώδικα :c:func:`PyRun_SimpleString` στο``Python/pythonrun.c``." #: faq/extending.rst:72 msgid "How can I evaluate an arbitrary Python expression from C?" @@ -150,36 +151,38 @@ msgstr "Πως μπορώ να εξάγω τιμές C από ένα αντικ msgid "" "That depends on the object's type. If it's a tuple, :c:func:`PyTuple_Size` " "returns its length and :c:func:`PyTuple_GetItem` returns the item at a " -"specified index. Lists have similar functions, :c:func:`PyList_Size` and :c:" -"func:`PyList_GetItem`." +"specified index. Lists have similar functions, :c:func:`PyList_Size` " +"and :c:func:`PyList_GetItem`." msgstr "" "Αυτό εξαρτάται από τον τύπο του αντικειμένου. Εάν είναι μια πλειάδα " -"(tuple), :c:func:`PyTuple_Size` επιστρέφει το μήκος του και το :c:func:" -"`PyTuple_GetItem` επιστρέφει το στοιχείο σε ένα καθορισμένο index. Οι " -"λίστες έχουν παρόμοιες συναρτήσεις, :c:func:`PyList_Size` και :c:func:" -"`PyList_GetItem`." +"(tuple), :c:func:`PyTuple_Size` επιστρέφει το μήκος του και " +"το :c:func:`PyTuple_GetItem` επιστρέφει το στοιχείο σε ένα καθορισμένο " +"index. Οι λίστες έχουν παρόμοιες συναρτήσεις, :c:func:`PyList_Size` " +"και :c:func:`PyList_GetItem`." #: faq/extending.rst:87 msgid "" -"For bytes, :c:func:`PyBytes_Size` returns its length and :c:func:" -"`PyBytes_AsStringAndSize` provides a pointer to its value and its length. " -"Note that Python bytes objects may contain null bytes so C's :c:func:`!" -"strlen` should not be used." +"For bytes, :c:func:`PyBytes_Size` returns its length " +"and :c:func:`PyBytes_AsStringAndSize` provides a pointer to its value and " +"its length. Note that Python bytes objects may contain null bytes so " +"C's :c:func:`!strlen` should not be used." msgstr "" -"Για bytes, :c:func:`PyBytes_Size` επιστρέφει το μήκος του και το :c:func:" -"`PyBytes_AsStringAndSize` παρέχει έναν δείκτη στην τιμή και το μήκος του. " -"Λάβετε υπόψη ότι τα αντικείμενα byte της Python μπορεί να περιέχουν null " -"byte, επομένως η :c:func:`!strlen` της C δεν πρέπει να χρησιμοποιείται." +"Για bytes, :c:func:`PyBytes_Size` επιστρέφει το μήκος του και " +"το :c:func:`PyBytes_AsStringAndSize` παρέχει έναν δείκτη στην τιμή και το " +"μήκος του. Λάβετε υπόψη ότι τα αντικείμενα byte της Python μπορεί να " +"περιέχουν null byte, επομένως η :c:func:`!strlen` της C δεν πρέπει να " +"χρησιμοποιείται." #: faq/extending.rst:92 msgid "" "To test the type of an object, first make sure it isn't ``NULL``, and then " -"use :c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:" -"`PyList_Check`, etc." +"use :c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, " +"etc." msgstr "" "Για να ελέγξετε τον τύπο ενός αντικειμένου, πρώτα βεβαιωθείτε ότι δεν είναι " -"``NULL``, και μετά χρησιμοποιήστε τα :c:func:`PyBytes_Check`, :c:func:" -"`PyTuple_Check`, :c:func:`PyList_Check`, κλπ." +"``NULL``, και μετά χρησιμοποιήστε " +"τα :c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, " +"κλπ." #: faq/extending.rst:95 msgid "" @@ -193,10 +196,10 @@ msgstr "" "Υπάρχει επίσης ένα API υψηλού επιπέδου για αντικείμενα Python που παρέχεται " "από τη λεγόμενη 'abstract' διεπαφή (interface) -- διαβάστε ``Include/" "abstract.h`` για περισσότερες λεπτομέρειες. Επιτρέπει τη διασύνδεση με κάθε " -"είδους ακολουθίας Python χρησιμοποιώντας κλήσεις όπως :c:func:" -"`PySequence_Length`, :c:func:`PySequence_GetItem`, κλπ. καθώς και πολλά άλλα " -"χρήσιμα πρωτόκολλα όπως αριθμοί (:c:func:`PyNumber_Index` et al.) και " -"αντιστοιχίσεις στον PyMapping APIs." +"είδους ακολουθίας Python χρησιμοποιώντας κλήσεις " +"όπως :c:func:`PySequence_Length`, :c:func:`PySequence_GetItem`, κλπ. καθώς " +"και πολλά άλλα χρήσιμα πρωτόκολλα όπως αριθμοί (:c:func:`PyNumber_Index` et " +"al.) και αντιστοιχίσεις στον PyMapping APIs." #: faq/extending.rst:104 msgid "How do I use Py_BuildValue() to create a tuple of arbitrary length?" @@ -225,6 +228,13 @@ msgstr "" "αυτή που χρησιμοποιείται με τη :c:func:`Py_BuildValue`, και τις τιμές " "ορίσματος::" +#: faq/extending.rst:117 +msgid "" +"PyObject *\n" +"PyObject_CallMethod(PyObject *object, const char *method_name,\n" +" const char *arg_format, ...);" +msgstr "" + #: faq/extending.rst:121 msgid "" "This works for any object that has methods -- whether built-in or user-" @@ -244,6 +254,17 @@ msgstr "" "ορίσματα 10, 0 (υποθέτοντας ότι ο δείκτης του αντικειμένου αρχείου είναι " "\"f\")::" +#: faq/extending.rst:127 +msgid "" +"res = PyObject_CallMethod(f, \"seek\", \"(ii)\", 10, 0);\n" +"if (res == NULL) {\n" +" ... an exception occurred ...\n" +"}\n" +"else {\n" +" Py_DECREF(res);\n" +"}" +msgstr "" + #: faq/extending.rst:135 msgid "" "Note that since :c:func:`PyObject_CallObject` *always* wants a tuple for the " @@ -272,9 +293,9 @@ msgid "" "the output will go wherever your ``write()`` method sends it." msgstr "" "Στον κώδικα Python, ορίστε ένα αντικείμενο που υποστηρίζει τη μέθοδο " -"``write()``. Αντιστοιχίστε αυτό το αντικείμενο στα :data:`sys.stdout` και :" -"data:`sys.stderr`. Καλέστε το print_error, ή απλώς επιτρέψτε στον τυπικό " -"μηχανισμό ανίχνευσης να λειτουργήσει. Στη συνέχεια, η έξοδος θα πάει " +"``write()``. Αντιστοιχίστε αυτό το αντικείμενο στα :data:`sys.stdout` " +"και :data:`sys.stderr`. Καλέστε το print_error, ή απλώς επιτρέψτε στον " +"τυπικό μηχανισμό ανίχνευσης να λειτουργήσει. Στη συνέχεια, η έξοδος θα πάει " "οπουδήποτε την στείλει η μέθοδος ``write()``." #: faq/extending.rst:149 @@ -283,10 +304,39 @@ msgstr "" "Ο ευκολότερος τρόπος για να το κάνετε αυτό είναι να χρησιμοποιήσετε την " "κλάση :class:`io.StringIO`:" +#: faq/extending.rst:151 +msgid "" +">>> import io, sys\n" +">>> sys.stdout = io.StringIO()\n" +">>> print('foo')\n" +">>> print('hello world!')\n" +">>> sys.stderr.write(sys.stdout.getvalue())\n" +"foo\n" +"hello world!" +msgstr "" + #: faq/extending.rst:161 msgid "A custom object to do the same would look like this:" msgstr "Ένα προσαρμοσμένο αντικείμενο για να κάνει το ίδιο θα μοιάζει με αυτό:" +#: faq/extending.rst:163 +msgid "" +">>> import io, sys\n" +">>> class StdoutCatcher(io.TextIOBase):\n" +"... def __init__(self):\n" +"... self.data = []\n" +"... def write(self, stuff):\n" +"... self.data.append(stuff)\n" +"...\n" +">>> import sys\n" +">>> sys.stdout = StdoutCatcher()\n" +">>> print('foo')\n" +">>> print('hello world!')\n" +">>> sys.stderr.write(''.join(sys.stdout.data))\n" +"foo\n" +"hello world!" +msgstr "" + #: faq/extending.rst:182 msgid "How do I access a module written in Python from C?" msgstr "" @@ -296,19 +346,23 @@ msgstr "" msgid "You can get a pointer to the module object as follows::" msgstr "Μπορείτε να λάβετε έναν δείκτη στο αντικείμενο του module ως εξής::" +#: faq/extending.rst:186 +msgid "module = PyImport_ImportModule(\"\");" +msgstr "" + #: faq/extending.rst:188 msgid "" -"If the module hasn't been imported yet (i.e. it is not yet present in :data:" -"`sys.modules`), this initializes the module; otherwise it simply returns the " -"value of ``sys.modules[\"\"]``. Note that it doesn't enter the " -"module into any namespace -- it only ensures it has been initialized and is " -"stored in :data:`sys.modules`." +"If the module hasn't been imported yet (i.e. it is not yet present " +"in :data:`sys.modules`), this initializes the module; otherwise it simply " +"returns the value of ``sys.modules[\"\"]``. Note that it " +"doesn't enter the module into any namespace -- it only ensures it has been " +"initialized and is stored in :data:`sys.modules`." msgstr "" -"Εάν το module δεν έχει εισαχθεί ακόμα (δηλαδή δεν υπάρχει ακόμα στο :data:" -"`sys.modules`), αυτό αρχικοποιεί το module· διαφορετικά απλώς επιστρέφει την " -"τιμή του ``sys.modules[\"\"]``. Σημειώστε ότι δεν εισάγει το " -"module σε κανένα namespace -- διασφαλίζει μόνο ότι έχει αρχικοποιηθεί και " -"ότι είναι αποθηκευμένη στο :data:`sys.modules`." +"Εάν το module δεν έχει εισαχθεί ακόμα (δηλαδή δεν υπάρχει ακόμα " +"στο :data:`sys.modules`), αυτό αρχικοποιεί το module· διαφορετικά απλώς " +"επιστρέφει την τιμή του ``sys.modules[\"\"]``. Σημειώστε ότι " +"δεν εισάγει το module σε κανένα namespace -- διασφαλίζει μόνο ότι έχει " +"αρχικοποιηθεί και ότι είναι αποθηκευμένη στο :data:`sys.modules`." #: faq/extending.rst:194 msgid "" @@ -318,6 +372,10 @@ msgstr "" "Μπορείτε στη συνέχεια να αποκτήσετε πρόσβαση στα χαρακτηριστικά του module " "(δηλαδή οποιοδήποτε όνομα ορίζεται στο module) ως εξής::" +#: faq/extending.rst:197 +msgid "attr = PyObject_GetAttrString(module, \"\");" +msgstr "" + #: faq/extending.rst:199 msgid "" "Calling :c:func:`PyObject_SetAttrString` to assign to variables in the " @@ -384,10 +442,24 @@ msgstr "" msgid "In your ``.gdbinit`` file (or interactively), add the command:" msgstr "Στο αρχείο σας ``.gdbinit`` (ή διαδραστικά), προσθέστε την εντολή:" +#: faq/extending.rst:231 +msgid "br _PyImport_LoadDynamicModule" +msgstr "" + #: faq/extending.rst:235 msgid "Then, when you run GDB:" msgstr "Στη συνέχεια, όταν εκτελείτε το GDB:" +#: faq/extending.rst:237 +msgid "" +"$ gdb /local/bin/python\n" +"gdb) run myscript.py\n" +"gdb) continue # repeat until your extension is loaded\n" +"gdb) finish # so that your extension is loaded\n" +"gdb) br myfunction.c:50\n" +"gdb) continue" +msgstr "" + #: faq/extending.rst:247 msgid "" "I want to compile a Python module on my Linux system, but some files are " @@ -397,31 +469,33 @@ msgstr "" "ορισμένα αρχεία. Γιατί;" #: faq/extending.rst:249 +#, fuzzy msgid "" -"Most packaged versions of Python don't include the :file:`/usr/lib/python2." -"{x}/config/` directory, which contains various files required for compiling " +"Most packaged versions of Python omit some files required for compiling " "Python extensions." msgstr "" "Οι περισσότερες συσκευασμένες εκδόσεις της Python δεν περιλαμβάνουν τον " "κατάλογο :file:`/usr/lib/python2.{x}/config/`, ο οποίος περιέχει διάφορα " "αρχεία που απαιτούνται για τη μεταγλώττιση των επεκτάσεων Python." -#: faq/extending.rst:253 -msgid "For Red Hat, install the python-devel RPM to get the necessary files." +#: faq/extending.rst:252 +#, fuzzy +msgid "For Red Hat, install the python3-devel RPM to get the necessary files." msgstr "" "Για το Red Hat, εγκαταστήστε το RPM της python-devel για να λάβετε τα " "απαραίτητα αρχεία." -#: faq/extending.rst:255 -msgid "For Debian, run ``apt-get install python-dev``." +#: faq/extending.rst:254 +#, fuzzy +msgid "For Debian, run ``apt-get install python3-dev``." msgstr "Για το Debian, εκτελέστε το ``apt-get install python-dev``." -#: faq/extending.rst:258 +#: faq/extending.rst:257 msgid "How do I tell \"incomplete input\" from \"invalid input\"?" msgstr "" "Πώς μπορώ να ξεχωρίσω την \"ελλιπή εισαγωγή\" από την \"έγκυρη εισαγωγή\";" -#: faq/extending.rst:260 +#: faq/extending.rst:259 msgid "" "Sometimes you want to emulate the Python interactive interpreter's behavior, " "where it gives you a continuation prompt when the input is incomplete (e.g. " @@ -430,12 +504,12 @@ msgid "" "message immediately when the input is invalid." msgstr "" "Μερικές φορές θέλετε να μιμηθείτε τη συμπεριφορά του διαδραστικού διερμηνέα " -"Python, όπου σας δίνει ένα συνεχόμενο prompt όταν η είσοδος είναι ελλιπής (π." -"χ. πληκτρολογήσατε την αρχή μιας δήλωσης \"if\" ή δεν κλείσατε τις " +"Python, όπου σας δίνει ένα συνεχόμενο prompt όταν η είσοδος είναι ελλιπής " +"(π.χ. πληκτρολογήσατε την αρχή μιας δήλωσης \"if\" ή δεν κλείσατε τις " "παρενθέσεις ή τα τριπλά εισαγωγικά συμβολοσειρών), αλλά σας δίνει ένα μήνυμα " "συντακτικού σφάλματος αμέσως όταν η εισαγωγή δεν είναι έγκυρη." -#: faq/extending.rst:266 +#: faq/extending.rst:265 msgid "" "In Python you can use the :mod:`codeop` module, which approximates the " "parser's behavior sufficiently. IDLE uses this, for example." @@ -444,7 +518,7 @@ msgstr "" "προσεγγίζει επαρκώς τη συμπεριφορά του parser. Το IDLE χρησιμοποιεί αυτό, " "για παράδειγμα." -#: faq/extending.rst:269 +#: faq/extending.rst:268 msgid "" "The easiest way to do it in C is to call :c:func:`PyRun_InteractiveLoop` " "(perhaps in a separate thread) and let the Python interpreter handle the " @@ -452,19 +526,19 @@ msgid "" "to point at your custom input function. See ``Modules/readline.c`` and " "``Parser/myreadline.c`` for more hints." msgstr "" -"Ο ευκολότερος τρόπος για να το κάνετε στη C είναι να καλέσετε τη :c:func:" -"`PyRun_InteractiveLoop` (ίσως σε ξεχωριστό νήμα (thread)) και να αφήσετε τον " -"διερμηνέα Python να χειριστεί την είσοδο για εσάς. Μπορείτε επίσης να " -"ορίσετε :c:func:`PyOS_ReadlineFunctionPointer` για να δείξετε την δικιάς " -"προσαρμοσμένη συνάρτηση εισαγωγής. Δείτε τα ``Modules/readline.c`` και " -"``Parser/myreadline.c`` για περισσότερες συμβουλές." +"Ο ευκολότερος τρόπος για να το κάνετε στη C είναι να καλέσετε " +"τη :c:func:`PyRun_InteractiveLoop` (ίσως σε ξεχωριστό νήμα (thread)) και να " +"αφήσετε τον διερμηνέα Python να χειριστεί την είσοδο για εσάς. Μπορείτε " +"επίσης να ορίσετε :c:func:`PyOS_ReadlineFunctionPointer` για να δείξετε την " +"δικιάς προσαρμοσμένη συνάρτηση εισαγωγής. Δείτε τα ``Modules/readline.c`` " +"και ``Parser/myreadline.c`` για περισσότερες συμβουλές." -#: faq/extending.rst:276 +#: faq/extending.rst:275 msgid "How do I find undefined g++ symbols __builtin_new or __pure_virtual?" msgstr "" "Πώς μπορώ να βρω απροσδιόριστα σύμβολα g++ __builtin_new ή __pure_virtual;" -#: faq/extending.rst:278 +#: faq/extending.rst:277 msgid "" "To dynamically load g++ extension modules, you must recompile Python, relink " "it using g++ (change LINKCC in the Python Modules Makefile), and link your " @@ -475,7 +549,7 @@ msgstr "" "Python Modules Makefile), και να συνδέσετε το module επέκτασης σας " "χρησιμοποιώντας g++ (π.χ. ``g++ -shared -o mymodule.so mymodule.o``)." -#: faq/extending.rst:284 +#: faq/extending.rst:283 msgid "" "Can I create an object class with some methods implemented in C and others " "in Python (e.g. through inheritance)?" @@ -483,19 +557,19 @@ msgstr "" "Μπορώ να δημιουργήσω μια κλάση αντικειμένου με ορισμένες μεθόδους που " "υλοποιούνται στη C και άλλες στη Python (π.χ. μέσω κληρονομικότητας);" -#: faq/extending.rst:286 +#: faq/extending.rst:285 msgid "" -"Yes, you can inherit from built-in classes such as :class:`int`, :class:" -"`list`, :class:`dict`, etc." +"Yes, you can inherit from built-in classes such " +"as :class:`int`, :class:`list`, :class:`dict`, etc." msgstr "" -"Ναι, μπορείτε να κληρονομήσετε από ενσωματωμένες (built-in) κλάσεις όπως :" -"class:`int`, :class:`list`, :class:`dict`, κ.λπ." +"Ναι, μπορείτε να κληρονομήσετε από ενσωματωμένες (built-in) κλάσεις " +"όπως :class:`int`, :class:`list`, :class:`dict`, κ.λπ." -#: faq/extending.rst:289 +#: faq/extending.rst:288 msgid "" -"The Boost Python Library (BPL, https://www.boost.org/libs/python/doc/index." -"html) provides a way of doing this from C++ (i.e. you can inherit from an " -"extension class written in C++ using the BPL)." +"The Boost Python Library (BPL, https://www.boost.org/libs/python/doc/" +"index.html) provides a way of doing this from C++ (i.e. you can inherit from " +"an extension class written in C++ using the BPL)." msgstr "" "Η βιβλιοθήκη Boost Python Library (BPL, https://www.boost.org/libs/python/" "doc/index.html) παρέχει ένα τρόπο για να γίνει αυτό από την C++ (δηλαδή " diff --git a/faq/general.po b/faq/general.po index dbc1f74a..2bc0c436 100644 --- a/faq/general.po +++ b/faq/general.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -69,8 +70,8 @@ msgstr "" #: faq/general.rst:42 msgid "" "Donations to the PSF are tax-exempt in the US. If you use Python and find " -"it helpful, please contribute via `the PSF donation page `_." +"it helpful, please contribute via `the PSF donation page `_." msgstr "" #: faq/general.rst:48 @@ -187,32 +188,32 @@ msgid "" "packages of interest to you." msgstr "" -#: faq/general.rst:126 +#: faq/general.rst:128 msgid "How does the Python version numbering scheme work?" msgstr "" -#: faq/general.rst:128 +#: faq/general.rst:130 msgid "Python versions are numbered \"A.B.C\" or \"A.B\":" msgstr "" -#: faq/general.rst:130 +#: faq/general.rst:132 msgid "" "*A* is the major version number -- it is only incremented for really major " "changes in the language." msgstr "" -#: faq/general.rst:132 +#: faq/general.rst:134 msgid "" "*B* is the minor version number -- it is incremented for less earth-" "shattering changes." msgstr "" -#: faq/general.rst:134 +#: faq/general.rst:136 msgid "" "*C* is the micro version number -- it is incremented for each bugfix release." msgstr "" -#: faq/general.rst:136 +#: faq/general.rst:138 msgid "" "Not all releases are bugfix releases. In the run-up to a new feature " "release, a series of development releases are made, denoted as alpha, beta, " @@ -223,31 +224,31 @@ msgid "" "changes except as needed to fix critical bugs." msgstr "" -#: faq/general.rst:144 +#: faq/general.rst:146 msgid "Alpha, beta and release candidate versions have an additional suffix:" msgstr "" -#: faq/general.rst:146 +#: faq/general.rst:148 msgid "The suffix for an alpha version is \"aN\" for some small number *N*." msgstr "" -#: faq/general.rst:147 +#: faq/general.rst:149 msgid "The suffix for a beta version is \"bN\" for some small number *N*." msgstr "" -#: faq/general.rst:148 +#: faq/general.rst:150 msgid "" "The suffix for a release candidate version is \"rcN\" for some small number " "*N*." msgstr "" -#: faq/general.rst:150 +#: faq/general.rst:152 msgid "" "In other words, all versions labeled *2.0aN* precede the versions labeled " "*2.0bN*, which precede versions labeled *2.0rcN*, and *those* precede 2.0." msgstr "" -#: faq/general.rst:153 +#: faq/general.rst:155 msgid "" "You may also find version numbers with a \"+\" suffix, e.g. \"2.2+\". These " "are unreleased versions, built directly from the CPython development " @@ -256,7 +257,7 @@ msgid "" "e.g. \"2.4a0\"." msgstr "" -#: faq/general.rst:158 +#: faq/general.rst:160 msgid "" "See the `Developer's Guide `__ for more information about the development cycle, " @@ -265,18 +266,18 @@ msgid "" "and :data:`sys.version_info`." msgstr "" -#: faq/general.rst:167 +#: faq/general.rst:169 msgid "How do I obtain a copy of the Python source?" msgstr "" -#: faq/general.rst:169 +#: faq/general.rst:171 msgid "" "The latest Python source distribution is always available from python.org, " "at https://www.python.org/downloads/. The latest development sources can be " "obtained at https://github.com/python/cpython/." msgstr "" -#: faq/general.rst:173 +#: faq/general.rst:175 msgid "" "The source distribution is a gzipped tar file containing the complete C " "source, Sphinx-formatted documentation, Python library modules, example " @@ -284,14 +285,14 @@ msgid "" "source will compile and run out of the box on most UNIX platforms." msgstr "" -#: faq/general.rst:178 +#: faq/general.rst:180 msgid "" "Consult the `Getting Started section of the Python Developer's Guide " "`__ for more information on getting the " "source code and compiling it." msgstr "" -#: faq/general.rst:184 +#: faq/general.rst:186 msgid "How do I get documentation on Python?" msgstr "" @@ -336,16 +337,17 @@ msgid "" "There is a newsgroup, :newsgroup:`comp.lang.python`, and a mailing list, " "`python-list `_. The " "newsgroup and mailing list are gatewayed into each other -- if you can read " -"news it's unnecessary to subscribe to the mailing list. :newsgroup:`comp." -"lang.python` is high-traffic, receiving hundreds of postings every day, and " -"Usenet readers are often more able to cope with this volume." +"news it's unnecessary to subscribe to the mailing " +"list. :newsgroup:`comp.lang.python` is high-traffic, receiving hundreds of " +"postings every day, and Usenet readers are often more able to cope with this " +"volume." msgstr "" #: faq/general.rst:217 msgid "" -"Announcements of new software releases and events can be found in comp.lang." -"python.announce, a low-traffic moderated list that receives about five " -"postings per day. It's available as `the python-announce mailing list " +"Announcements of new software releases and events can be found in " +"comp.lang.python.announce, a low-traffic moderated list that receives about " +"five postings per day. It's available as `the python-announce mailing list " "`_." msgstr "" @@ -362,9 +364,9 @@ msgstr "" #: faq/general.rst:229 msgid "" "Alpha and beta releases are available from https://www.python.org/" -"downloads/. All releases are announced on the comp.lang.python and comp." -"lang.python.announce newsgroups and on the Python home page at https://www." -"python.org/; an RSS feed of news is available." +"downloads/. All releases are announced on the comp.lang.python and " +"comp.lang.python.announce newsgroups and on the Python home page at https://" +"www.python.org/; an RSS feed of news is available." msgstr "" #: faq/general.rst:234 @@ -379,8 +381,8 @@ msgstr "" #: faq/general.rst:241 msgid "" -"To report a bug or submit a patch, use the issue tracker at https://github." -"com/python/cpython/issues." +"To report a bug or submit a patch, use the issue tracker at https://" +"github.com/python/cpython/issues." msgstr "" #: faq/general.rst:244 @@ -433,8 +435,8 @@ msgstr "" #: faq/general.rst:274 msgid "" "The Python project's infrastructure is located all over the world and is " -"managed by the Python Infrastructure Team. Details `here `__." +"managed by the Python Infrastructure Team. Details `here `__." msgstr "" #: faq/general.rst:279 @@ -444,8 +446,8 @@ msgstr "" #: faq/general.rst:281 msgid "" "When he began implementing Python, Guido van Rossum was also reading the " -"published scripts from `\"Monty Python's Flying Circus\" `__, a BBC comedy series from the 1970s. " +"published scripts from `\"Monty Python's Flying Circus\" `__, a BBC comedy series from the 1970s. " "Van Rossum thought he needed a name that was short, unique, and slightly " "mysterious, so he decided to call the language Python." msgstr "" @@ -486,62 +488,61 @@ msgstr "" #: faq/general.rst:311 msgid "" "The latest stable releases can always be found on the `Python download page " -"`_. There are two production-ready " -"versions of Python: 2.x and 3.x. The recommended version is 3.x, which is " -"supported by most widely used libraries. Although 2.x is still widely used, " -"`it is not maintained anymore `_." +"`_. Python 3.x is the recommended version " +"and supported by most widely used libraries. Python 2.x :pep:`is not " +"maintained anymore <373>`." msgstr "" -#: faq/general.rst:318 +#: faq/general.rst:317 msgid "How many people are using Python?" msgstr "" -#: faq/general.rst:320 +#: faq/general.rst:319 msgid "" "There are probably millions of users, though it's difficult to obtain an " "exact count." msgstr "" -#: faq/general.rst:323 +#: faq/general.rst:322 msgid "" "Python is available for free download, so there are no sales figures, and " "it's available from many different sites and packaged with many Linux " "distributions, so download statistics don't tell the whole story either." msgstr "" -#: faq/general.rst:327 +#: faq/general.rst:326 msgid "" "The comp.lang.python newsgroup is very active, but not all Python users post " "to the group or even read it." msgstr "" -#: faq/general.rst:332 +#: faq/general.rst:331 msgid "Have any significant projects been done in Python?" msgstr "" -#: faq/general.rst:334 +#: faq/general.rst:333 msgid "" "See https://www.python.org/about/success for a list of projects that use " -"Python. Consulting the proceedings for `past Python conferences `_ will reveal contributions from many " +"Python. Consulting the proceedings for `past Python conferences `_ will reveal contributions from many " "different companies and organizations." msgstr "" -#: faq/general.rst:339 +#: faq/general.rst:338 msgid "" "High-profile Python projects include `the Mailman mailing list manager " -"`_ and `the Zope application server `_. Several Linux distributions, most notably `Red Hat `_, have written part or all of their installer and system " -"administration software in Python. Companies that use Python internally " -"include Google, Yahoo, and Lucasfilm Ltd." +"`_ and `the Zope application server `_. Several Linux distributions, most notably `Red Hat " +"`_, have written part or all of their installer and " +"system administration software in Python. Companies that use Python " +"internally include Google, Yahoo, and Lucasfilm Ltd." msgstr "" -#: faq/general.rst:348 +#: faq/general.rst:347 msgid "What new developments are expected for Python in the future?" msgstr "" -#: faq/general.rst:350 +#: faq/general.rst:349 msgid "" "See https://peps.python.org/ for the Python Enhancement Proposals (PEPs). " "PEPs are design documents describing a suggested new feature for Python, " @@ -550,17 +551,17 @@ msgid "" "been publicly released yet." msgstr "" -#: faq/general.rst:356 +#: faq/general.rst:355 msgid "" -"New development is discussed on `the python-dev mailing list `_." +"New development is discussed on `the python-dev mailing list `_." msgstr "" -#: faq/general.rst:361 +#: faq/general.rst:360 msgid "Is it reasonable to propose incompatible changes to Python?" msgstr "" -#: faq/general.rst:363 +#: faq/general.rst:362 msgid "" "In general, no. There are already millions of lines of Python code around " "the world, so any change in the language that invalidates more than a very " @@ -570,22 +571,22 @@ msgid "" "to invalidate them all at a single stroke." msgstr "" -#: faq/general.rst:370 +#: faq/general.rst:369 msgid "" "Providing a gradual upgrade path is necessary if a feature has to be " "changed. :pep:`5` describes the procedure followed for introducing backward-" "incompatible changes while minimizing disruption for users." msgstr "" -#: faq/general.rst:376 +#: faq/general.rst:375 msgid "Is Python a good language for beginning programmers?" msgstr "" -#: faq/general.rst:378 +#: faq/general.rst:377 msgid "Yes." msgstr "" -#: faq/general.rst:380 +#: faq/general.rst:379 msgid "" "It is still common to start students with a procedural and statically typed " "language such as Pascal, C, or a subset of C++ or Java. Students may be " @@ -598,7 +599,7 @@ msgid "" "with user-defined objects in their very first course." msgstr "" -#: faq/general.rst:390 +#: faq/general.rst:389 msgid "" "For a student who has never programmed before, using a statically typed " "language seems unnatural. It presents additional complexity that the " @@ -610,7 +611,7 @@ msgid "" "course." msgstr "" -#: faq/general.rst:398 +#: faq/general.rst:397 msgid "" "Many other aspects of Python make it a good first language. Like Java, " "Python has a large standard library so that students can be assigned " @@ -623,7 +624,7 @@ msgid "" "helpful in extending the students' reach." msgstr "" -#: faq/general.rst:407 +#: faq/general.rst:406 msgid "" "Python's interactive interpreter enables students to test language features " "while they're programming. They can keep a window with the interpreter " @@ -631,13 +632,41 @@ msgid "" "can't remember the methods for a list, they can do something like this::" msgstr "" -#: faq/general.rst:436 +#: faq/general.rst:411 +msgid "" +">>> L = []\n" +">>> dir(L) \n" +"['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',\n" +"'__dir__', '__doc__', '__eq__', '__format__', '__ge__',\n" +"'__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__',\n" +"'__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__',\n" +"'__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',\n" +"'__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__',\n" +"'__sizeof__', '__str__', '__subclasshook__', 'append', 'clear',\n" +"'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove',\n" +"'reverse', 'sort']\n" +">>> [d for d in dir(L) if '__' not in d]\n" +"['append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', " +"'remove', 'reverse', 'sort']\n" +"\n" +">>> help(L.append)\n" +"Help on built-in function append:\n" +"\n" +"append(...)\n" +" L.append(object) -> None -- append object to end\n" +"\n" +">>> L.append(1)\n" +">>> L\n" +"[1]" +msgstr "" + +#: faq/general.rst:435 msgid "" "With the interpreter, documentation is never far from the student as they " "are programming." msgstr "" -#: faq/general.rst:439 +#: faq/general.rst:438 msgid "" "There are also good IDEs for Python. IDLE is a cross-platform IDE for " "Python that is written in Python using Tkinter. Emacs users will be happy to " @@ -648,7 +677,7 @@ msgid "" "Python editing environments." msgstr "" -#: faq/general.rst:447 +#: faq/general.rst:446 msgid "" "If you want to discuss Python's use in education, you may be interested in " "joining `the edu-sig mailing list \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -38,8 +39,9 @@ msgid "" "widget set, called :ref:`tkinter `. This is probably the easiest " "to install (since it comes included with most `binary distributions `_ of Python) and use. For more info about Tk, " -"including pointers to the source, see the `Tcl/Tk home page `_. Tcl/Tk is fully portable to the macOS, Windows, and Unix platforms." +"including pointers to the source, see the `Tcl/Tk home page `_. Tcl/Tk is fully portable to the macOS, Windows, and Unix " +"platforms." msgstr "" #: faq/gui.rst:28 diff --git a/faq/index.po b/faq/index.po index 47e901c1..ce45eee0 100644 --- a/faq/index.po +++ b/faq/index.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-05-02 12:51+0000\n" "Last-Translator: Dimitrios Papadopoulos\n" "Language-Team: PyGreece \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/faq/installed.po b/faq/installed.po index 4bd6300b..ab6b3a33 100644 --- a/faq/installed.po +++ b/faq/installed.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-05-06 12:51+0000\n" "Last-Translator: Dimitrios Papadopoulos\n" "Language-Team: PyGreece \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/faq/library.po b/faq/library.po index dacd26ff..0420362c 100644 --- a/faq/library.po +++ b/faq/library.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -41,8 +42,8 @@ msgstr "" #: faq/library.rst:21 msgid "" -"For third-party packages, search the `Python Package Index `_ or try `Google `_ or another web search " +"For third-party packages, search the `Python Package Index `_ or try `Google `_ or another web search " "engine. Searching for \"Python\" plus a keyword or two for your topic of " "interest will usually find something helpful." msgstr "" @@ -55,9 +56,9 @@ msgstr "" msgid "" "If you can't find a source file for a module it may be a built-in or " "dynamically loaded module implemented in C, C++ or other compiled language. " -"In this case you may not have the source file or it may be something like :" -"file:`mathmodule.c`, somewhere in a C source directory (not on the Python " -"Path)." +"In this case you may not have the source file or it may be something " +"like :file:`mathmodule.c`, somewhere in a C source directory (not on the " +"Python Path)." msgstr "" #: faq/library.rst:35 @@ -79,6 +80,12 @@ msgid "" "these, type::" msgstr "" +#: faq/library.rst:42 +msgid "" +"import sys\n" +"print(sys.builtin_module_names)" +msgstr "" + #: faq/library.rst:47 msgid "How do I make a Python script executable on Unix?" msgstr "" @@ -102,6 +109,10 @@ msgid "" "to write ::" msgstr "" +#: faq/library.rst:59 +msgid "#!/usr/local/bin/python" +msgstr "" + #: faq/library.rst:61 msgid "" "as the very first line of your file, using the pathname for where the Python " @@ -116,6 +127,10 @@ msgid "" "directory on the user's :envvar:`PATH`::" msgstr "" +#: faq/library.rst:69 +msgid "#!/usr/bin/env python" +msgstr "" + #: faq/library.rst:71 msgid "" "*Don't* do this for CGI scripts. The :envvar:`PATH` variable for CGI " @@ -130,12 +145,24 @@ msgid "" "try the following hack (due to Alex Rezinsky):" msgstr "" +#: faq/library.rst:79 +msgid "" +"#! /bin/sh\n" +"\"\"\":\"\n" +"exec python $0 ${1+\"$@\"}\n" +"\"\"\"" +msgstr "" + #: faq/library.rst:86 msgid "" "The minor disadvantage is that this defines the script's __doc__ string. " "However, you can fix that by adding ::" msgstr "" +#: faq/library.rst:89 +msgid "__doc__ = \"\"\"...Whatever...\"\"\"" +msgstr "" + #: faq/library.rst:94 msgid "Is there a curses/termcap package for Python?" msgstr "" @@ -178,10 +205,20 @@ msgid "" "wrong argument list. It is called as ::" msgstr "" +#: faq/library.rst:123 +msgid "handler(signum, frame)" +msgstr "" + #: faq/library.rst:125 msgid "so it should be declared with two parameters::" msgstr "" +#: faq/library.rst:127 +msgid "" +"def handler(signum, frame):\n" +" ..." +msgstr "" + #: faq/library.rst:132 msgid "Common tasks" msgstr "" @@ -218,6 +255,12 @@ msgstr "" msgid "The \"global main logic\" of your program may be as simple as ::" msgstr "" +#: faq/library.rst:154 +msgid "" +"if __name__ == \"__main__\":\n" +" main_logic()" +msgstr "" + #: faq/library.rst:157 msgid "at the bottom of the main module of your program." msgstr "" @@ -240,6 +283,12 @@ msgid "" "may include a self-test of the module. ::" msgstr "" +#: faq/library.rst:170 +msgid "" +"if __name__ == \"__main__\":\n" +" self_test()" +msgstr "" + #: faq/library.rst:173 msgid "" "Even programs that interact with complex external interfaces may be tested " @@ -300,6 +349,21 @@ msgid "" "for all the threads to finish::" msgstr "" +#: faq/library.rst:253 +msgid "" +"import threading, time\n" +"\n" +"def thread_task(name, n):\n" +" for i in range(n):\n" +" print(name, i)\n" +"\n" +"for i in range(10):\n" +" T = threading.Thread(target=thread_task, args=(str(i), i))\n" +" T.start()\n" +"\n" +"time.sleep(10) # <---------------------------!" +msgstr "" + #: faq/library.rst:265 msgid "" "But now (on many platforms) the threads don't run in parallel, but appear to " @@ -311,13 +375,27 @@ msgstr "" msgid "A simple fix is to add a tiny sleep to the start of the run function::" msgstr "" +#: faq/library.rst:271 +msgid "" +"def thread_task(name, n):\n" +" time.sleep(0.001) # <--------------------!\n" +" for i in range(n):\n" +" print(name, i)\n" +"\n" +"for i in range(10):\n" +" T = threading.Thread(target=thread_task, args=(str(i), i))\n" +" T.start()\n" +"\n" +"time.sleep(10)" +msgstr "" + #: faq/library.rst:282 msgid "" "Instead of trying to guess a good delay value for :func:`time.sleep`, it's " -"better to use some kind of semaphore mechanism. One idea is to use the :mod:" -"`queue` module to create a queue object, let each thread append a token to " -"the queue when it finishes, and let the main thread read as many tokens from " -"the queue as there are threads." +"better to use some kind of semaphore mechanism. One idea is to use " +"the :mod:`queue` module to create a queue object, let each thread append a " +"token to the queue when it finishes, and let the main thread read as many " +"tokens from the queue as there are threads." msgstr "" #: faq/library.rst:290 @@ -344,14 +422,70 @@ msgstr "" msgid "Here's a trivial example::" msgstr "" +#: faq/library.rst:304 +msgid "" +"import threading, queue, time\n" +"\n" +"# The worker thread gets jobs off the queue. When the queue is empty, it\n" +"# assumes there will be no more work and exits.\n" +"# (Realistically workers will run until terminated.)\n" +"def worker():\n" +" print('Running worker')\n" +" time.sleep(0.1)\n" +" while True:\n" +" try:\n" +" arg = q.get(block=False)\n" +" except queue.Empty:\n" +" print('Worker', threading.current_thread(), end=' ')\n" +" print('queue empty')\n" +" break\n" +" else:\n" +" print('Worker', threading.current_thread(), end=' ')\n" +" print('running with argument', arg)\n" +" time.sleep(0.5)\n" +"\n" +"# Create queue\n" +"q = queue.Queue()\n" +"\n" +"# Start a pool of 5 workers\n" +"for i in range(5):\n" +" t = threading.Thread(target=worker, name='worker %i' % (i+1))\n" +" t.start()\n" +"\n" +"# Begin adding work to the queue\n" +"for i in range(50):\n" +" q.put(i)\n" +"\n" +"# Give threads time to run\n" +"print('Main thread sleeping')\n" +"time.sleep(5)" +msgstr "" + #: faq/library.rst:340 msgid "When run, this will produce the following output:" msgstr "" +#: faq/library.rst:342 +msgid "" +"Running worker\n" +"Running worker\n" +"Running worker\n" +"Running worker\n" +"Running worker\n" +"Main thread sleeping\n" +"Worker running with argument 0\n" +"Worker running with argument 1\n" +"Worker running with argument 2\n" +"Worker running with argument 3\n" +"Worker running with argument 4\n" +"Worker running with argument 5\n" +"..." +msgstr "" + #: faq/library.rst:358 msgid "" -"Consult the module's documentation for more details; the :class:`~queue." -"Queue` class provides a featureful interface." +"Consult the module's documentation for more details; " +"the :class:`~queue.Queue` class provides a featureful interface." msgstr "" #: faq/library.rst:363 @@ -382,16 +516,39 @@ msgid "" "D, D1, D2 are dicts, x, y are objects, i, j are ints)::" msgstr "" +#: faq/library.rst:380 +msgid "" +"L.append(x)\n" +"L1.extend(L2)\n" +"x = L[i]\n" +"x = L.pop()\n" +"L1[i:j] = L2\n" +"L.sort()\n" +"x = y\n" +"x.field = y\n" +"D[x] = y\n" +"D1.update(D2)\n" +"D.keys()" +msgstr "" + #: faq/library.rst:392 msgid "These aren't::" msgstr "" +#: faq/library.rst:394 +msgid "" +"i = i+1\n" +"L.append(L[-1])\n" +"L[i] = L[j]\n" +"D[x] = D[x] + 1" +msgstr "" + #: faq/library.rst:399 msgid "" -"Operations that replace other objects may invoke those other objects' :meth:" -"`~object.__del__` method when their reference count reaches zero, and that " -"can affect things. This is especially true for the mass updates to " -"dictionaries and lists. When in doubt, use a mutex!" +"Operations that replace other objects may invoke those other " +"objects' :meth:`~object.__del__` method when their reference count reaches " +"zero, and that can affect things. This is especially true for the mass " +"updates to dictionaries and lists. When in doubt, use a mutex!" msgstr "" #: faq/library.rst:406 @@ -422,11 +579,11 @@ msgstr "" msgid "" "This doesn't mean that you can't make good use of Python on multi-CPU " "machines! You just have to be creative with dividing the work up between " -"multiple *processes* rather than multiple *threads*. The :class:" -"`~concurrent.futures.ProcessPoolExecutor` class in the new :mod:`concurrent." -"futures` module provides an easy way of doing so; the :mod:`multiprocessing` " -"module provides a lower-level API in case you want more control over " -"dispatching of tasks." +"multiple *processes* rather than multiple *threads*. " +"The :class:`~concurrent.futures.ProcessPoolExecutor` class in the " +"new :mod:`concurrent.futures` module provides an easy way of doing so; " +"the :mod:`multiprocessing` module provides a lower-level API in case you " +"want more control over dispatching of tasks." msgstr "" #: faq/library.rst:431 @@ -434,8 +591,8 @@ msgid "" "Judicious use of C extensions will also help; if you use a C extension to " "perform a time-consuming task, the extension can release the GIL while the " "thread of execution is in the C code and allow other threads to get some " -"work done. Some standard library modules such as :mod:`zlib` and :mod:" -"`hashlib` already do this." +"work done. Some standard library modules such as :mod:`zlib` " +"and :mod:`hashlib` already do this." msgstr "" #: faq/library.rst:437 @@ -475,8 +632,9 @@ msgstr "" #: faq/library.rst:461 msgid "" "Use ``os.remove(filename)`` or ``os.unlink(filename)``; for documentation, " -"see the :mod:`os` module. The two functions are identical; :func:`~os." -"unlink` is simply the name of the Unix system call for this function." +"see the :mod:`os` module. The two functions are " +"identical; :func:`~os.unlink` is simply the name of the Unix system call for " +"this function." msgstr "" #: faq/library.rst:465 @@ -496,15 +654,15 @@ msgstr "" msgid "" "To truncate a file, open it using ``f = open(filename, \"rb+\")``, and use " "``f.truncate(offset)``; offset defaults to the current seek position. " -"There's also ``os.ftruncate(fd, offset)`` for files opened with :func:`os." -"open`, where *fd* is the file descriptor (a small integer)." +"There's also ``os.ftruncate(fd, offset)`` for files opened " +"with :func:`os.open`, where *fd* is the file descriptor (a small integer)." msgstr "" #: faq/library.rst:478 msgid "" "The :mod:`shutil` module also contains a number of functions to work on " -"files including :func:`~shutil.copyfile`, :func:`~shutil.copytree`, and :" -"func:`~shutil.rmtree`." +"files including :func:`~shutil.copyfile`, :func:`~shutil.copytree`, " +"and :func:`~shutil.rmtree`." msgstr "" #: faq/library.rst:484 @@ -528,9 +686,9 @@ msgstr "" #: faq/library.rst:499 msgid "" -"To read or write complex binary data formats, it's best to use the :mod:" -"`struct` module. It allows you to take a string containing binary data " -"(usually numbers) and convert it to Python objects; and vice versa." +"To read or write complex binary data formats, it's best to use " +"the :mod:`struct` module. It allows you to take a string containing binary " +"data (usually numbers) and convert it to Python objects; and vice versa." msgstr "" #: faq/library.rst:503 @@ -539,6 +697,15 @@ msgid "" "integer in big-endian format from a file::" msgstr "" +#: faq/library.rst:506 +msgid "" +"import struct\n" +"\n" +"with open(filename, \"rb\") as f:\n" +" s = f.read(8)\n" +" x, y, z = struct.unpack(\">hhl\", s)" +msgstr "" + #: faq/library.rst:512 msgid "" "The '>' in the format string forces big-endian data; the letter 'h' reads " @@ -569,41 +736,41 @@ msgid "" ":func:`os.read` is a low-level function which takes a file descriptor, a " "small integer representing the opened file. :func:`os.popen` creates a high-" "level file object, the same type returned by the built-in :func:`open` " -"function. Thus, to read *n* bytes from a pipe *p* created with :func:`os." -"popen`, you need to use ``p.read(n)``." +"function. Thus, to read *n* bytes from a pipe *p* created " +"with :func:`os.popen`, you need to use ``p.read(n)``." msgstr "" -#: faq/library.rst:618 +#: faq/library.rst:617 msgid "How do I access the serial (RS232) port?" msgstr "" -#: faq/library.rst:620 +#: faq/library.rst:619 msgid "For Win32, OSX, Linux, BSD, Jython, IronPython:" msgstr "" -#: faq/library.rst:622 -msgid "https://pypi.org/project/pyserial/" +#: faq/library.rst:621 +msgid ":pypi:`pyserial`" msgstr "" -#: faq/library.rst:624 +#: faq/library.rst:623 msgid "For Unix, see a Usenet post by Mitch Chapman:" msgstr "" -#: faq/library.rst:626 +#: faq/library.rst:625 msgid "https://groups.google.com/groups?selm=34A04430.CF9@ohioee.com" msgstr "" -#: faq/library.rst:630 +#: faq/library.rst:629 msgid "Why doesn't closing sys.stdout (stdin, stderr) really close it?" msgstr "" -#: faq/library.rst:632 +#: faq/library.rst:631 msgid "" "Python :term:`file objects ` are a high-level layer of " "abstraction on low-level C file descriptors." msgstr "" -#: faq/library.rst:635 +#: faq/library.rst:634 msgid "" "For most file objects you create in Python via the built-in :func:`open` " "function, ``f.close()`` marks the Python file object as being closed from " @@ -612,7 +779,7 @@ msgid "" "``f`` becomes garbage." msgstr "" -#: faq/library.rst:641 +#: faq/library.rst:640 msgid "" "But stdin, stdout and stderr are treated specially by Python, because of the " "special status also given to them by C. Running ``sys.stdout.close()`` " @@ -620,95 +787,145 @@ msgid "" "associated C file descriptor." msgstr "" -#: faq/library.rst:646 +#: faq/library.rst:645 msgid "" "To close the underlying C file descriptor for one of these three, you should " "first be sure that's what you really want to do (e.g., you may confuse " "extension modules trying to do I/O). If it is, use :func:`os.close`::" msgstr "" -#: faq/library.rst:654 +#: faq/library.rst:649 +msgid "" +"os.close(stdin.fileno())\n" +"os.close(stdout.fileno())\n" +"os.close(stderr.fileno())" +msgstr "" + +#: faq/library.rst:653 msgid "Or you can use the numeric constants 0, 1 and 2, respectively." msgstr "" -#: faq/library.rst:658 +#: faq/library.rst:657 msgid "Network/Internet Programming" msgstr "" -#: faq/library.rst:661 +#: faq/library.rst:660 msgid "What WWW tools are there for Python?" msgstr "" -#: faq/library.rst:663 +#: faq/library.rst:662 msgid "" "See the chapters titled :ref:`internet` and :ref:`netdata` in the Library " "Reference Manual. Python has many modules that will help you build server-" "side and client-side web systems." msgstr "" -#: faq/library.rst:669 +#: faq/library.rst:668 msgid "" "A summary of available frameworks is maintained by Paul Boddie at https://" "wiki.python.org/moin/WebProgramming\\ ." msgstr "" -#: faq/library.rst:672 +#: faq/library.rst:671 msgid "" "Cameron Laird maintains a useful set of pages about Python web technologies " -"at https://web.archive.org/web/20210224183619/http://phaseit.net/claird/comp." -"lang.python/web_python." +"at https://web.archive.org/web/20210224183619/http://phaseit.net/claird/" +"comp.lang.python/web_python." msgstr "" -#: faq/library.rst:677 +#: faq/library.rst:676 msgid "How can I mimic CGI form submission (METHOD=POST)?" msgstr "" -#: faq/library.rst:679 +#: faq/library.rst:678 msgid "" "I would like to retrieve web pages that are the result of POSTing a form. Is " "there existing code that would let me do this easily?" msgstr "" -#: faq/library.rst:682 +#: faq/library.rst:681 msgid "Yes. Here's a simple example that uses :mod:`urllib.request`::" msgstr "" -#: faq/library.rst:697 +#: faq/library.rst:683 +msgid "" +"#!/usr/local/bin/python\n" +"\n" +"import urllib.request\n" +"\n" +"# build the query string\n" +"qs = \"First=Josephine&MI=Q&Last=Public\"\n" +"\n" +"# connect and send the server a path\n" +"req = urllib.request.urlopen('http://www.some-server.out-there'\n" +" '/cgi-bin/some-cgi-script', data=qs)\n" +"with req:\n" +" msg, hdrs = req.read(), req.info()" +msgstr "" + +#: faq/library.rst:696 msgid "" "Note that in general for percent-encoded POST operations, query strings must " "be quoted using :func:`urllib.parse.urlencode`. For example, to send " "``name=Guy Steele, Jr.``::" msgstr "" -#: faq/library.rst:705 +#: faq/library.rst:700 +msgid "" +">>> import urllib.parse\n" +">>> urllib.parse.urlencode({'name': 'Guy Steele, Jr.'})\n" +"'name=Guy+Steele%2C+Jr.'" +msgstr "" + +#: faq/library.rst:704 msgid ":ref:`urllib-howto` for extensive examples." msgstr "" -#: faq/library.rst:709 +#: faq/library.rst:708 msgid "What module should I use to help with generating HTML?" msgstr "" -#: faq/library.rst:713 +#: faq/library.rst:712 msgid "" "You can find a collection of useful links on the `Web Programming wiki page " "`_." msgstr "" -#: faq/library.rst:718 +#: faq/library.rst:717 msgid "How do I send mail from a Python script?" msgstr "" -#: faq/library.rst:720 +#: faq/library.rst:719 msgid "Use the standard library module :mod:`smtplib`." msgstr "" -#: faq/library.rst:722 +#: faq/library.rst:721 msgid "" "Here's a very simple interactive mail sender that uses it. This method will " "work on any host that supports an SMTP listener. ::" msgstr "" -#: faq/library.rst:742 +#: faq/library.rst:724 +msgid "" +"import sys, smtplib\n" +"\n" +"fromaddr = input(\"From: \")\n" +"toaddrs = input(\"To: \").split(',')\n" +"print(\"Enter message, end with ^D:\")\n" +"msg = ''\n" +"while True:\n" +" line = sys.stdin.readline()\n" +" if not line:\n" +" break\n" +" msg += line\n" +"\n" +"# The actual mail send\n" +"server = smtplib.SMTP('localhost')\n" +"server.sendmail(fromaddr, toaddrs, msg)\n" +"server.quit()" +msgstr "" + +#: faq/library.rst:741 msgid "" "A Unix-only alternative uses sendmail. The location of the sendmail program " "varies between systems; sometimes it is ``/usr/lib/sendmail``, sometimes ``/" @@ -716,17 +933,33 @@ msgid "" "some sample code::" msgstr "" -#: faq/library.rst:762 +#: faq/library.rst:746 +msgid "" +"import os\n" +"\n" +"SENDMAIL = \"/usr/sbin/sendmail\" # sendmail location\n" +"p = os.popen(\"%s -t -i\" % SENDMAIL, \"w\")\n" +"p.write(\"To: receiver@example.com\\n\")\n" +"p.write(\"Subject: test\\n\")\n" +"p.write(\"\\n\") # blank line separating headers from body\n" +"p.write(\"Some text\\n\")\n" +"p.write(\"some more text\\n\")\n" +"sts = p.close()\n" +"if sts != 0:\n" +" print(\"Sendmail exit status\", sts)" +msgstr "" + +#: faq/library.rst:761 msgid "How do I avoid blocking in the connect() method of a socket?" msgstr "" -#: faq/library.rst:764 +#: faq/library.rst:763 msgid "" "The :mod:`select` module is commonly used to help with asynchronous I/O on " "sockets." msgstr "" -#: faq/library.rst:767 +#: faq/library.rst:766 msgid "" "To prevent the TCP connect from blocking, you can set the socket to non-" "blocking mode. Then when you do the :meth:`~socket.socket.connect`, you " @@ -737,16 +970,16 @@ msgid "" "your system." msgstr "" -#: faq/library.rst:775 +#: faq/library.rst:774 msgid "" "You can use the :meth:`~socket.socket.connect_ex` method to avoid creating " -"an exception. It will just return the errno value. To poll, you can call :" -"meth:`~socket.socket.connect_ex` again later -- ``0`` or ``errno.EISCONN`` " -"indicate that you're connected -- or you can pass this socket to :meth:" -"`select.select` to check if it's writable." +"an exception. It will just return the errno value. To poll, you can " +"call :meth:`~socket.socket.connect_ex` again later -- ``0`` or " +"``errno.EISCONN`` indicate that you're connected -- or you can pass this " +"socket to :meth:`select.select` to check if it's writable." msgstr "" -#: faq/library.rst:783 +#: faq/library.rst:782 msgid "" "The :mod:`asyncio` module provides a general purpose single-threaded and " "concurrent asynchronous library, which can be used for writing non-blocking " @@ -754,94 +987,100 @@ msgid "" "popular and feature-rich alternative." msgstr "" -#: faq/library.rst:791 +#: faq/library.rst:790 msgid "Databases" msgstr "" -#: faq/library.rst:794 +#: faq/library.rst:793 msgid "Are there any interfaces to database packages in Python?" msgstr "" -#: faq/library.rst:796 +#: faq/library.rst:795 msgid "Yes." msgstr "" -#: faq/library.rst:798 +#: faq/library.rst:797 msgid "" "Interfaces to disk-based hashes such as :mod:`DBM ` and :mod:`GDBM " -"` are also included with standard Python. There is also the :mod:" -"`sqlite3` module, which provides a lightweight disk-based relational " -"database." +"` are also included with standard Python. There is also " +"the :mod:`sqlite3` module, which provides a lightweight disk-based " +"relational database." msgstr "" -#: faq/library.rst:803 +#: faq/library.rst:802 msgid "" "Support for most relational databases is available. See the " "`DatabaseProgramming wiki page `_ for details." msgstr "" -#: faq/library.rst:809 +#: faq/library.rst:808 msgid "How do you implement persistent objects in Python?" msgstr "" -#: faq/library.rst:811 +#: faq/library.rst:810 msgid "" "The :mod:`pickle` library module solves this in a very general way (though " -"you still can't store things like open files, sockets or windows), and the :" -"mod:`shelve` library module uses pickle and (g)dbm to create persistent " +"you still can't store things like open files, sockets or windows), and " +"the :mod:`shelve` library module uses pickle and (g)dbm to create persistent " "mappings containing arbitrary Python objects." msgstr "" -#: faq/library.rst:818 +#: faq/library.rst:817 msgid "Mathematics and Numerics" msgstr "" -#: faq/library.rst:821 +#: faq/library.rst:820 msgid "How do I generate random numbers in Python?" msgstr "" -#: faq/library.rst:823 +#: faq/library.rst:822 msgid "" "The standard module :mod:`random` implements a random number generator. " "Usage is simple::" msgstr "" -#: faq/library.rst:829 -msgid "This returns a random floating point number in the range [0, 1)." +#: faq/library.rst:825 +msgid "" +"import random\n" +"random.random()" +msgstr "" + +#: faq/library.rst:828 +msgid "This returns a random floating-point number in the range [0, 1)." msgstr "" -#: faq/library.rst:831 +#: faq/library.rst:830 msgid "" "There are also many other specialized generators in this module, such as:" msgstr "" -#: faq/library.rst:833 +#: faq/library.rst:832 msgid "``randrange(a, b)`` chooses an integer in the range [a, b)." msgstr "" -#: faq/library.rst:834 -msgid "``uniform(a, b)`` chooses a floating point number in the range [a, b)." +#: faq/library.rst:833 +msgid "``uniform(a, b)`` chooses a floating-point number in the range [a, b)." msgstr "" -#: faq/library.rst:835 +#: faq/library.rst:834 msgid "" "``normalvariate(mean, sdev)`` samples the normal (Gaussian) distribution." msgstr "" -#: faq/library.rst:837 +#: faq/library.rst:836 msgid "Some higher-level functions operate on sequences directly, such as:" msgstr "" -#: faq/library.rst:839 +#: faq/library.rst:838 msgid "``choice(S)`` chooses a random element from a given sequence." msgstr "" -#: faq/library.rst:840 +#: faq/library.rst:839 msgid "``shuffle(L)`` shuffles a list in-place, i.e. permutes it randomly." msgstr "" -#: faq/library.rst:842 +#: faq/library.rst:841 msgid "" "There's also a ``Random`` class you can instantiate to create independent " "multiple random number generators." diff --git a/faq/programming.po b/faq/programming.po index 92d34afa..a234332d 100644 --- a/faq/programming.po +++ b/faq/programming.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-06-12 23:09+0300\n" "Last-Translator: Panagiotis Skias \n" "Language-Team: PyGreece \n" @@ -44,8 +44,8 @@ msgstr "Ναι." #: faq/programming.rst:19 msgid "" -"Several debuggers for Python are described below, and the built-in function :" -"func:`breakpoint` allows you to drop into any of them." +"Several debuggers for Python are described below, and the built-in " +"function :func:`breakpoint` allows you to drop into any of them." msgstr "" "Πολλοί εντοπιστές σφαλμάτων για την Python περιγράφονται παρακάτω και η " "ενσωματωμένη συνάρτηση :func:`breakpoint` σάς επιτρέπει να μεταβείτε σε " @@ -394,6 +394,13 @@ msgstr "" "Ας υποθέσουμε ότι χρησιμοποιείτε έναν βρόχο for για να ορίσετε μερικά " "διαφορετικά lambdas (ή ακόμα και απλές συναρτήσεις), π.χ.::" +#: faq/programming.rst:213 +msgid "" +">>> squares = []\n" +">>> for x in range(5):\n" +"... squares.append(lambda: x**2)" +msgstr "" + #: faq/programming.rst:217 msgid "" "This gives you a list that contains 5 lambdas that calculate ``x**2``. You " @@ -406,6 +413,14 @@ msgstr "" "αντίστοιχα, ``0``, ``1``, ``4``, ``9`` και ``16``. Ωστόσο, όταν δοκιμάσετε " "πραγματικά θα δείτε ότι όλα επιστρέφουν ``16``::" +#: faq/programming.rst:222 +msgid "" +">>> squares[2]()\n" +"16\n" +">>> squares[4]()\n" +"16" +msgstr "" + #: faq/programming.rst:227 msgid "" "This happens because ``x`` is not local to the lambdas, but is defined in " @@ -421,6 +436,13 @@ msgstr "" "Μπορείτε επίσης να το επαληθεύσετε αλλάζοντας την τιμή του ``x`` και δείτε " "πως αλλάζουν τα αποτελέσματα του lambda::" +#: faq/programming.rst:233 +msgid "" +">>> x = 8\n" +">>> squares[2]()\n" +"64" +msgstr "" + #: faq/programming.rst:237 msgid "" "In order to avoid this, you need to save the values in variables local to " @@ -430,6 +452,13 @@ msgstr "" "τοπικές στο lambda, έτσι ώστε να μην βασίζονται στην τιμή του καθολικού " "``x``::" +#: faq/programming.rst:240 +msgid "" +">>> squares = []\n" +">>> for x in range(5):\n" +"... squares.append(lambda n=x: n**2)" +msgstr "" + #: faq/programming.rst:244 msgid "" "Here, ``n=x`` creates a new variable ``n`` local to the lambda and computed " @@ -444,6 +473,14 @@ msgstr "" "θα είναι ``0`` στο πρώτο lambda, ``1`` στο δεύτερο , ``2`` στο τρίτο και " "ούτω καθεξής. Επομένως κάθε lambda θα επιστρέψει τώρα το σωστό αποτέλεσμα::" +#: faq/programming.rst:250 +msgid "" +">>> squares[2]()\n" +"4\n" +">>> squares[4]()\n" +"16" +msgstr "" + #: faq/programming.rst:255 msgid "" "Note that this behaviour is not peculiar to lambdas, but applies to regular " @@ -477,14 +514,31 @@ msgstr "" msgid "config.py::" msgstr "config.py::" +#: faq/programming.rst:270 +msgid "x = 0 # Default value of the 'x' configuration setting" +msgstr "" + #: faq/programming.rst:272 msgid "mod.py::" msgstr "mod.py::" +#: faq/programming.rst:274 +msgid "" +"import config\n" +"config.x = 1" +msgstr "" + #: faq/programming.rst:277 msgid "main.py::" msgstr "main.py::" +#: faq/programming.rst:279 +msgid "" +"import config\n" +"import mod\n" +"print(config.x)" +msgstr "" + #: faq/programming.rst:283 msgid "" "Note that using a module is also the basis for implementing the singleton " @@ -528,11 +582,11 @@ msgstr "Είναι καλή πρακτική εάν εισάγετε module με #: faq/programming.rst:301 msgid "" -"standard library modules -- e.g. :mod:`sys`, :mod:`os`, :mod:`argparse`, :" -"mod:`re`" +"standard library modules -- " +"e.g. :mod:`sys`, :mod:`os`, :mod:`argparse`, :mod:`re`" msgstr "" -"τυπικά module βιβλιοθήκης -- π.χ. :mod:`sys`, :mod:`os`, :mod:`argparse`, :" -"mod:`re`" +"τυπικά module βιβλιοθήκης -- " +"π.χ. :mod:`sys`, :mod:`os`, :mod:`argparse`, :mod:`re`" #: faq/programming.rst:302 msgid "" @@ -540,8 +594,8 @@ msgid "" "directory) -- e.g. :mod:`!dateutil`, :mod:`!requests`, :mod:`!PIL.Image`" msgstr "" "module βιβλιοθήκης τρίτων (ό, τι είναι εγκατεστημένο στο κατάλογο site-" -"packages της Python) -- π.χ. :mod:`!dateutil`, :mod:`! requests`, :mod:`!PIL." -"Image`" +"packages της Python) -- π.χ. :mod:`!dateutil`, :mod:`! requests`, :mod:`!" +"PIL.Image`" #: faq/programming.rst:304 msgid "locally developed modules" @@ -622,8 +676,8 @@ msgstr "" "είναι δαπανηρή λόγω της μιας φοράς της αρχικοποίησης του module, αλλά η " "φόρτωση ενός module πολλές φορές είναι σχεδόν δωρεάν, κοστίζοντας μόνο " "μερικές αναζητήσεις σε λεξικό. Ακόμα και αν το όνομα του module έχει " -"ξεφύγει από το πεδίο εφαρμογής του, το module είναι πιθανώς διαθέσιμο στο :" -"data:`sys.modules`." +"ξεφύγει από το πεδίο εφαρμογής του, το module είναι πιθανώς διαθέσιμο " +"στο :data:`sys.modules`." #: faq/programming.rst:338 msgid "Why are default values shared between objects?" @@ -637,6 +691,14 @@ msgstr "" "Αυτός ο τύπος σφάλματος συνήθως δαγκώνει νεοφυείς προγραμματιστές. Σκεφτείτε " "αυτήν τη συνάρτηση::" +#: faq/programming.rst:342 +msgid "" +"def foo(mydict={}): # Danger: shared reference to one dict for all calls\n" +" ... compute something ...\n" +" mydict[key] = value\n" +" return mydict" +msgstr "" + #: faq/programming.rst:347 msgid "" "The first time you call this function, ``mydict`` contains a single item. " @@ -685,10 +747,23 @@ msgstr "" "ελέγξτε εάν η παράμετρος είναι ``None`` και δημιουργήστε μια νέα λίστα/" "λεξικά/ό,τι και αν είναι. Για παράδειγμα μην γράψετε::" +#: faq/programming.rst:365 +msgid "" +"def foo(mydict={}):\n" +" ..." +msgstr "" + #: faq/programming.rst:368 msgid "but::" msgstr "αλλά::" +#: faq/programming.rst:370 +msgid "" +"def foo(mydict=None):\n" +" if mydict is None:\n" +" mydict = {} # create a new dict for local namespace" +msgstr "" + #: faq/programming.rst:374 msgid "" "This feature can be useful. When you have a function that's time-consuming " @@ -704,6 +779,20 @@ msgstr "" "ξανά η ίδια τιμή. Αυτό ονομάζεται \"memoizing\", και μπορεί να εφαρμοστεί ως " "εξής:" +#: faq/programming.rst:379 +msgid "" +"# Callers can only provide two parameters and optionally pass _cache by " +"keyword\n" +"def expensive(arg1, arg2, *, _cache={}):\n" +" if (arg1, arg2) in _cache:\n" +" return _cache[(arg1, arg2)]\n" +"\n" +" # Calculate the value\n" +" result = ... expensive computation ...\n" +" _cache[(arg1, arg2)] = result # Store result in the cache\n" +" return result" +msgstr "" + #: faq/programming.rst:389 msgid "" "You could use a global variable containing a dictionary instead of the " @@ -732,6 +821,15 @@ msgstr "" "μεταβιβάσετε αυτά τα ορίσματα κατά την κλήση άλλης συνάρτησης με τη χρήση " "των ``*`` και ``**``::" +#: faq/programming.rst:401 +msgid "" +"def f(x, *args, **kwargs):\n" +" ...\n" +" kwargs['width'] = '14.3c'\n" +" ...\n" +" g(x, *args, **kwargs)" +msgstr "" + #: faq/programming.rst:415 msgid "What is the difference between arguments and parameters?" msgstr "Ποια είναι η διαφορά μεταξύ ορισμάτων και παραμέτρων;" @@ -740,9 +838,9 @@ msgstr "Ποια είναι η διαφορά μεταξύ ορισμάτων κ msgid "" ":term:`Parameters ` are defined by the names that appear in a " "function definition, whereas :term:`arguments ` are the values " -"actually passed to a function when calling it. Parameters define what :term:" -"`kind of arguments ` a function can accept. For example, given " -"the function definition::" +"actually passed to a function when calling it. Parameters define " +"what :term:`kind of arguments ` a function can accept. For " +"example, given the function definition::" msgstr "" ":term:`Παράμετροι ` ορίζονται από τα ονόματα που εμφανίζονται " "στον ορισμό μιας συνάρτησης, ενώ τα :term:`ορίσματα ` είναι οι " @@ -750,6 +848,12 @@ msgstr "" "παράμετροι ορίζουν τι :term:`kind of arguments ` μπορεί να δεχτεί " "μια συνάρτηση. Για παράδειγμα δεδομένου του ορισμού της συνάρτησης::" +#: faq/programming.rst:423 +msgid "" +"def func(foo, bar=None, **kwargs):\n" +" pass" +msgstr "" + #: faq/programming.rst:426 msgid "" "*foo*, *bar* and *kwargs* are parameters of ``func``. However, when calling " @@ -758,6 +862,10 @@ msgstr "" "*foo*, *bar* και *kwargs* είναι παράμετροι της ``func``. Ωστόσο, όταν " "καλείται η ``func``, για παράδειγμα::" +#: faq/programming.rst:429 +msgid "func(42, bar=314, extra=somevar)" +msgstr "" + #: faq/programming.rst:431 msgid "the values ``42``, ``314``, and ``somevar`` are arguments." msgstr "οι τιμές ``42``, ``314``, και ``somevar`` είναι ορίσματα." @@ -770,6 +878,17 @@ msgstr "Γιατί η αλλαγή της λίστας 'y' αλλάζει επί msgid "If you wrote code like::" msgstr "Αν γράψατε κώδικα όπως::" +#: faq/programming.rst:439 +msgid "" +">>> x = []\n" +">>> y = x\n" +">>> y.append(10)\n" +">>> y\n" +"[10]\n" +">>> x\n" +"[10]" +msgstr "" + #: faq/programming.rst:447 msgid "" "you might be wondering why appending an element to ``y`` changed ``x`` too." @@ -816,6 +935,17 @@ msgstr "" msgid "If we instead assign an immutable object to ``x``::" msgstr "Αν αντιστοιχίσουμε ένα αμετάβλητο αντικείμενο σε ``x``::" +#: faq/programming.rst:463 +msgid "" +">>> x = 5 # ints are immutable\n" +">>> y = x\n" +">>> x = x + 1 # 5 can't be mutated, we are creating a new object here\n" +">>> x\n" +"6\n" +">>> y\n" +"5" +msgstr "" + #: faq/programming.rst:471 msgid "" "we can see that in this case ``x`` and ``y`` are not equal anymore. This is " @@ -869,9 +999,9 @@ msgstr "" "Ωστόσο, υπάρχει μία κατηγορία λειτουργιών όπου η ίδια πράξη έχει μερικές " "φορές διαφορετικές συμπεριφορές με διαφορετικούς τύπους: οι επαυξημένοι " "τελεστές ανάθεσης. Για παράδειγμα, ``+=`` μεταλλάσσει τις λίστες αλλά όχι " -"τις πλειάδες ή τους ints (``a_list += [1, 2, 3]`` είναι ίσο με ``a_list." -"extend([1, 2, 3])`` και μεταλλάσσει ``a_list``, ενώ το ``some_tuple += (1, " -"2, 3)`` και ``some_int += 1`` δημιουργεί νέα αντικείμενα)." +"τις πλειάδες ή τους ints (``a_list += [1, 2, 3]`` είναι ίσο με " +"``a_list.extend([1, 2, 3])`` και μεταλλάσσει ``a_list``, ενώ το ``some_tuple " +"+= (1, 2, 3)`` και ``some_int += 1`` δημιουργεί νέα αντικείμενα)." #: faq/programming.rst:495 msgid "In other words:" @@ -883,10 +1013,10 @@ msgid "" "etc.), we can use some specific operations to mutate it and all the " "variables that refer to it will see the change." msgstr "" -"Εάν έχουμε ένα μεταβλητό αντικείμενο (:class:`list`, :class:`dict`, :class:" -"`set`, κλπ.), μπορούμε να χρησιμοποιήσουμε ορισμένες συγκεκριμένες " -"λειτουργίες για να το μεταλλάξουμε και όλες τις μεταβλητές που αναφέρονται " -"σε αυτό θα δουν την αλλαγή." +"Εάν έχουμε ένα μεταβλητό αντικείμενο " +"(:class:`list`, :class:`dict`, :class:`set`, κλπ.), μπορούμε να " +"χρησιμοποιήσουμε ορισμένες συγκεκριμένες λειτουργίες για να το μεταλλάξουμε " +"και όλες τις μεταβλητές που αναφέρονται σε αυτό θα δουν την αλλαγή." #: faq/programming.rst:500 msgid "" @@ -895,10 +1025,11 @@ msgid "" "but operations that transform that value into a new value always return a " "new object." msgstr "" -"Εάν έχουμε ένα αμετάβλητο αντικείμενο (:class:`str`, :class:`int`, :class:" -"`tuple`, κλπ.), όλες οι μεταβλητές που αναφέρονται σε αυτό θα βλέπουν πάντα " -"την ίδια τιμή, αλλά οι λειτουργίες που θα μετατρέπουν αυτήν την τιμή σε μια " -"νέα τιμή επιστρέφουν πάντα ένα νέο αντικείμενο." +"Εάν έχουμε ένα αμετάβλητο αντικείμενο " +"(:class:`str`, :class:`int`, :class:`tuple`, κλπ.), όλες οι μεταβλητές που " +"αναφέρονται σε αυτό θα βλέπουν πάντα την ίδια τιμή, αλλά οι λειτουργίες που " +"θα μετατρέπουν αυτήν την τιμή σε μια νέα τιμή επιστρέφουν πάντα ένα νέο " +"αντικείμενο." #: faq/programming.rst:505 msgid "" @@ -931,6 +1062,18 @@ msgstr "" msgid "By returning a tuple of the results::" msgstr "Επιστρέφοντας μια πλειάδα των αποτελεσμάτων::" +#: faq/programming.rst:519 +msgid "" +">>> def func1(a, b):\n" +"... a = 'new-value' # a and b are local names\n" +"... b = b + 1 # assigned to new objects\n" +"... return a, b # return new values\n" +"...\n" +">>> x, y = 'old-value', 99\n" +">>> func1(x, y)\n" +"('new-value', 100)" +msgstr "" + #: faq/programming.rst:528 msgid "This is almost always the clearest solution." msgstr "Αυτή είναι σχεδόν πάντα η πιο ξεκάθαρη λύση." @@ -947,14 +1090,55 @@ msgid "By passing a mutable (changeable in-place) object::" msgstr "" "Περνώντας ένα μεταβλητό (με δυνατότητα αλλαγής επί τόπου) αντικείμενο::" +#: faq/programming.rst:534 +msgid "" +">>> def func2(a):\n" +"... a[0] = 'new-value' # 'a' references a mutable list\n" +"... a[1] = a[1] + 1 # changes a shared object\n" +"...\n" +">>> args = ['old-value', 99]\n" +">>> func2(args)\n" +">>> args\n" +"['new-value', 100]" +msgstr "" + #: faq/programming.rst:543 msgid "By passing in a dictionary that gets mutated::" msgstr "Περνώντας σε ένα λεξικό που μεταλλάσσεται::" +#: faq/programming.rst:545 +msgid "" +">>> def func3(args):\n" +"... args['a'] = 'new-value' # args is a mutable dictionary\n" +"... args['b'] = args['b'] + 1 # change it in-place\n" +"...\n" +">>> args = {'a': 'old-value', 'b': 99}\n" +">>> func3(args)\n" +">>> args\n" +"{'a': 'new-value', 'b': 100}" +msgstr "" + #: faq/programming.rst:554 msgid "Or bundle up values in a class instance::" msgstr "Ή ομαδοποιήστε τιμές σε μια παρουσία κλάσης::" +#: faq/programming.rst:556 +msgid "" +">>> class Namespace:\n" +"... def __init__(self, /, **args):\n" +"... for key, value in args.items():\n" +"... setattr(self, key, value)\n" +"...\n" +">>> def func4(args):\n" +"... args.a = 'new-value' # args is a mutable Namespace\n" +"... args.b = args.b + 1 # change object in-place\n" +"...\n" +">>> args = Namespace(a='old-value', b=99)\n" +">>> func4(args)\n" +">>> vars(args)\n" +"{'a': 'new-value', 'b': 100}" +msgstr "" + #: faq/programming.rst:571 msgid "There's almost never a good reason to get this complicated." msgstr "Δεν υπάρχει σχεδόν ποτέ καλός λόγος να γίνει αυτό περίπλοκο." @@ -981,14 +1165,37 @@ msgstr "" "θέλετε να ορίσετε το ``linear(a,b)`` που επιστρέφει μια συνάρτηση ``f(x)`` " "που υπολογίζει την τιμή ``a*x+b``. Χρησιμοποιώντας ένθετα πεδία::" +#: faq/programming.rst:583 +msgid "" +"def linear(a, b):\n" +" def result(x):\n" +" return a * x + b\n" +" return result" +msgstr "" + #: faq/programming.rst:588 msgid "Or using a callable object::" msgstr "Ή χρησιμοποιώντας ένα callable αντικείμενο::" +#: faq/programming.rst:590 +msgid "" +"class linear:\n" +"\n" +" def __init__(self, a, b):\n" +" self.a, self.b = a, b\n" +"\n" +" def __call__(self, x):\n" +" return self.a * x + self.b" +msgstr "" + #: faq/programming.rst:598 msgid "In both cases, ::" msgstr "Και στις δύο περιπτώσεις::" +#: faq/programming.rst:600 +msgid "taxes = linear(0.3, 2)" +msgstr "" + #: faq/programming.rst:602 msgid "gives a callable object where ``taxes(10e6) == 0.3 * 10e6 + 2``." msgstr "δίνει ένα callable αντικείμενο όπου ``taxes(10e6) == 0.3 * 10e6 + 2``." @@ -1004,11 +1211,38 @@ msgstr "" "συλλογή από callables μπορεί να μοιραστεί την υπογραφή τους μέσω " "κληρονομικότητας::" +#: faq/programming.rst:608 +msgid "" +"class exponential(linear):\n" +" # __init__ inherited\n" +" def __call__(self, x):\n" +" return self.a * (x ** self.b)" +msgstr "" + #: faq/programming.rst:613 msgid "Object can encapsulate state for several methods::" msgstr "" "Το αντικείμενο μπορεί να ενθυλακώσει την κατάσταση για πολλές μεθόδους::" +#: faq/programming.rst:615 +msgid "" +"class counter:\n" +"\n" +" value = 0\n" +"\n" +" def set(self, x):\n" +" self.value = x\n" +"\n" +" def up(self):\n" +" self.value = self.value + 1\n" +"\n" +" def down(self):\n" +" self.value = self.value - 1\n" +"\n" +"count = counter()\n" +"inc, dec, reset = count.up, count.down, count.set" +msgstr "" + #: faq/programming.rst:631 msgid "" "Here ``inc()``, ``dec()`` and ``reset()`` act like functions which share the " @@ -1032,16 +1266,24 @@ msgstr "" #: faq/programming.rst:641 msgid "" -"Some objects can be copied more easily. Dictionaries have a :meth:`~dict." -"copy` method::" +"Some objects can be copied more easily. Dictionaries have " +"a :meth:`~dict.copy` method::" msgstr "" "Ορισμένα αντικείμενα μπορούν να αντιγραφούν πιο εύκολα. Τα λεξικά έχουν μία " "μέθοδο :meth:`~dict.copy`::" +#: faq/programming.rst:644 +msgid "newdict = olddict.copy()" +msgstr "" + #: faq/programming.rst:646 msgid "Sequences can be copied by slicing::" msgstr "Οι ακολουθίες μπορούν να αντιγραφούν με τεμαχισμό::" +#: faq/programming.rst:648 +msgid "new_l = l[:]" +msgstr "" + #: faq/programming.rst:652 msgid "How can I find the methods or attributes of an object?" msgstr "Πως μπορώ να βρω τις μεθόδους ή τα χαρακτηριστικά ενός αντικειμένου;" @@ -1073,6 +1315,20 @@ msgstr "" "ίδιο ισχύει για τις δηλώσεις ``def`` και ``class``, αλλά σε αυτή την " "περίπτωση η τιμή είναι callable. Λάβετε υπόψη τον ακόλουθο κώδικα::" +#: faq/programming.rst:667 +msgid "" +">>> class A:\n" +"... pass\n" +"...\n" +">>> B = A\n" +">>> a = B()\n" +">>> b = a\n" +">>> print(b)\n" +"<__main__.A object at 0x16D07CC>\n" +">>> print(a)\n" +"<__main__.A object at 0x16D07CC>" +msgstr "" + #: faq/programming.rst:678 msgid "" "Arguably the class has a name: even though it is bound to two names and " @@ -1137,6 +1393,12 @@ msgid "Comma is not an operator in Python. Consider this session::" msgstr "" "Το κόμμα δεν είναι τελεστής στην Python. Σκεφτείτε αυτήν την συνεδρία::" +#: faq/programming.rst:705 +msgid "" +">>> \"a\" in \"b\", \"a\"\n" +"(False, 'a')" +msgstr "" + #: faq/programming.rst:708 msgid "" "Since the comma is not an operator, but a separator between expressions the " @@ -1145,10 +1407,18 @@ msgstr "" "Δεδομένου ότι το κόμμα δεν είναι τελεστής, αλλά διαχωριστικό μεταξύ των " "εκφράσεων, τα παραπάνω αξιολογούνται σαν να είχατε εισαγάγει::" +#: faq/programming.rst:711 +msgid "(\"a\" in \"b\"), \"a\"" +msgstr "" + #: faq/programming.rst:713 msgid "not::" msgstr "δεν::" +#: faq/programming.rst:715 +msgid "\"a\" in (\"b\", \"a\")" +msgstr "" + #: faq/programming.rst:717 msgid "" "The same is true of the various assignment operators (``=``, ``+=`` etc). " @@ -1167,6 +1437,14 @@ msgstr "Υπάρχει ισοδύναμο του τριαδικού τελεστ msgid "Yes, there is. The syntax is as follows::" msgstr "Ναι υπάρχει, Η σύνταξη έχει ως εξής::" +#: faq/programming.rst:726 +msgid "" +"[on_true] if [expression] else [on_false]\n" +"\n" +"x, y = 50, 25\n" +"small = x if x < y else y" +msgstr "" + #: faq/programming.rst:731 msgid "" "Before this syntax was introduced in Python 2.5, a common idiom was to use " @@ -1175,6 +1453,10 @@ msgstr "" "Πριν εισαχθεί αυτή η σύνταξη στην Python 2.5, ένα κοινό ιδίωμα ήταν η χρήση " "λογικών τελεστών::" +#: faq/programming.rst:734 +msgid "[expression] and [on_true] or [on_false]" +msgstr "" + #: faq/programming.rst:736 msgid "" "However, this idiom is unsafe, as it can give wrong results when *on_true* " @@ -1195,10 +1477,38 @@ msgid "" "lambda`. See the following three examples, slightly adapted from Ulf " "Bartelt::" msgstr "" -"Ναι. Συνήθως αυτό γίνεται με ένθεση του :keyword:`lambda` εντός του :" -"keyword:`!lambda`. Δείτε τα ακόλουθα τρία παραδείγματα, ελαφρώς " +"Ναι. Συνήθως αυτό γίνεται με ένθεση του :keyword:`lambda` εντός " +"του :keyword:`!lambda`. Δείτε τα ακόλουθα τρία παραδείγματα, ελαφρώς " "προσαρμοσμένα από τον Ulf Bartelt::" +#: faq/programming.rst:747 +msgid "" +"from functools import reduce\n" +"\n" +"# Primes < 1000\n" +"print(list(filter(None,map(lambda y:y*reduce(lambda x,y:x*y!=0,\n" +"map(lambda x,y=y:y%x,range(2,int(pow(y,0.5)+1))),1),range(2,1000)))))\n" +"\n" +"# First 10 Fibonacci numbers\n" +"print(list(map(lambda x,f=lambda x,f:(f(x-1,f)+f(x-2,f)) if x>1 else 1:\n" +"f(x,f), range(10))))\n" +"\n" +"# Mandelbrot set\n" +"print((lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+'\\n'+y,map(lambda " +"y,\n" +"Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM,\n" +"Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,\n" +"i=i,Sx=Sx,F=lambda xc,yc,x,y,k,f=lambda xc,yc,x,y,k,f:(k<=0)or (x*x+y*y\n" +">=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr(\n" +"64+F(Ru+x*(Ro-Ru)/Sx,yc,0,0,i)),range(Sx))):L(Iu+y*(Io-Iu)/Sy),range(Sy\n" +"))))(-2.1, 0.7, -1.2, 1.2, 30, 80, 24))\n" +"# \\___ ___/ \\___ ___/ | | |__ lines on screen\n" +"# V V | |______ columns on screen\n" +"# | | |__________ maximum of \"iterations\"\n" +"# | |_________________ range on y axis\n" +"# |____________________________ range on x axis" +msgstr "" + #: faq/programming.rst:771 msgid "Don't try this at home, kids!" msgstr "Μην το δοκιμάσετε στο σπίτι, παιδιά!" @@ -1224,6 +1534,15 @@ msgstr "" "είναι μια συνάρτηση που δέχεται μόνο παραμέτρους θέσης. Η τεκμηρίωσή τους " "μοιάζει με αυτό::" +#: faq/programming.rst:786 +msgid "" +">>> help(divmod)\n" +"Help on built-in function divmod in module builtins:\n" +"\n" +"divmod(x, y, /)\n" +" Return the tuple (x//y, x%y). Invariant: div*y + mod == x." +msgstr "" + #: faq/programming.rst:792 msgid "" "The slash at the end of the parameter list means that both parameters are " @@ -1234,6 +1553,14 @@ msgstr "" "είναι μόνο θέσης. Επομένως, η κλήση της :func:`divmod` με ορίσματα λέξεων " "κλειδιών θα οδηγούσε σε σφάλμα::" +#: faq/programming.rst:796 +msgid "" +">>> divmod(x=3, y=4)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: divmod() takes no keyword arguments" +msgstr "" + #: faq/programming.rst:803 msgid "Numbers and strings" msgstr "Αριθμοί και συμβολοσειρές" @@ -1253,6 +1580,13 @@ msgstr "" "τη μεταβλητή \"a\" στην οκταδική τιμή \"10\" (8 σε δεκαδικό), " "πληκτρολογήστε::" +#: faq/programming.rst:812 +msgid "" +">>> a = 0o10\n" +">>> a\n" +"8" +msgstr "" + #: faq/programming.rst:816 msgid "" "Hexadecimal is just as easy. Simply precede the hexadecimal number with a " @@ -1264,6 +1598,16 @@ msgstr "" "ψηφία μπορούν να καθοριστούν με πεζά ή κεφαλαία. Για παράδειγμα, στον " "διερμηνέα Python::" +#: faq/programming.rst:820 +msgid "" +">>> a = 0xa5\n" +">>> a\n" +"165\n" +">>> b = 0XB2\n" +">>> b\n" +"178" +msgstr "" + #: faq/programming.rst:829 msgid "Why does -22 // 10 return -3?" msgstr "Γιατί το -22 // 10 επιστρέφει -3;" @@ -1276,6 +1620,10 @@ msgstr "" "Οφείλεται κυρίως στην επιθυμία που το ``i % j`` να έχει το ίδιο πρόσημο με " "το ``j``. Εάν το θέλετε αυτό, και θέλετε επίσης::" +#: faq/programming.rst:834 +msgid "i == (i // j) * j + (i % j)" +msgstr "" + #: faq/programming.rst:836 msgid "" "then integer division has to return the floor. C also requires that " @@ -1308,13 +1656,22 @@ msgstr "" #: faq/programming.rst:850 msgid "" -"Trying to lookup an ``int`` literal attribute in the normal manner gives a :" -"exc:`SyntaxError` because the period is seen as a decimal point::" +"Trying to lookup an ``int`` literal attribute in the normal manner gives " +"a :exc:`SyntaxError` because the period is seen as a decimal point::" msgstr "" "Η προσπάθεια αναζήτησης ενός literal χαρακτηριστικού ``int`` με τον κανονικό " "τρόπο δίνει ένα :exc:`SyntaxError` επειδή η περίοδος θεωρείται ως " "υποδιαστολή::" +#: faq/programming.rst:853 +msgid "" +">>> 1.__class__\n" +" File \"\", line 1\n" +" 1.__class__\n" +" ^\n" +"SyntaxError: invalid decimal literal" +msgstr "" + #: faq/programming.rst:859 msgid "" "The solution is to separate the literal from the period with either a space " @@ -1328,13 +1685,14 @@ msgid "How do I convert a string to a number?" msgstr "Πως μετατρέπω μια συμβολοσειρά σε έναν αριθμό;" #: faq/programming.rst:871 +#, fuzzy msgid "" "For integers, use the built-in :func:`int` type constructor, e.g. " -"``int('144') == 144``. Similarly, :func:`float` converts to floating-point, " -"e.g. ``float('144') == 144.0``." +"``int('144') == 144``. Similarly, :func:`float` converts to a floating-" +"point number, e.g. ``float('144') == 144.0``." msgstr "" -"Για ακέραιους αριθμούς, χρησιμοποιήστε τον ενσωματωμένο κατασκευαστή τύπου :" -"func:`int` , π.χ. ``int('144') == 144``. Ομοίως, το :func:`float` " +"Για ακέραιους αριθμούς, χρησιμοποιήστε τον ενσωματωμένο κατασκευαστή " +"τύπου :func:`int` , π.χ. ``int('144') == 144``. Ομοίως, το :func:`float` " "μετατρέπει σε κινητή υποδιαστολή π.χ. ``float('144') == 144.0``." #: faq/programming.rst:875 @@ -1347,12 +1705,12 @@ msgid "" "octal, and '0x' indicates a hex number." msgstr "" "Από προεπιλογή, αυτά ερμηνεύουν τον αριθμό ως δεκαδικό, έτσι ώστε " -"``int('0144') == 144`` να είναι αληθές, και το ``int('0x144')`` να εγείρει :" -"exc:`ValueError`. Το ``int(string, base)`` παίρνει τη βάση για μετατροπή ως " -"δεύτερο προαιρετικό όρισμα, οπότε το ``int( '0x144', 16) == 324``. Εάν η " -"βάση έχει καθοριστεί ως 0, ο αριθμός ερμηνεύεται χρησιμοποιώντας κανόνες της " -"Python: ένα αρχικό '0o' υποδηλώνει οκταδικό , και το '0x' δείχνει έναν " -"δεκαεξαδικό αριθμό." +"``int('0144') == 144`` να είναι αληθές, και το ``int('0x144')`` να " +"εγείρει :exc:`ValueError`. Το ``int(string, base)`` παίρνει τη βάση για " +"μετατροπή ως δεύτερο προαιρετικό όρισμα, οπότε το ``int( '0x144', 16) == " +"324``. Εάν η βάση έχει καθοριστεί ως 0, ο αριθμός ερμηνεύεται " +"χρησιμοποιώντας κανόνες της Python: ένα αρχικό '0o' υποδηλώνει οκταδικό , " +"και το '0x' δείχνει έναν δεκαεξαδικό αριθμό." #: faq/programming.rst:882 msgid "" @@ -1392,15 +1750,15 @@ msgid "" "in type constructor :func:`str`. If you want a hexadecimal or octal " "representation, use the built-in functions :func:`hex` or :func:`oct`. For " "fancy formatting, see the :ref:`f-strings` and :ref:`formatstrings` " -"sections, e.g. ``\"{:04d}\".format(144)`` yields ``'0144'`` and ``\"{:.3f}\"." -"format(1.0/3.0)`` yields ``'0.333'``." +"sections, e.g. ``\"{:04d}\".format(144)`` yields ``'0144'`` and ``\"{:.3f}" +"\".format(1.0/3.0)`` yields ``'0.333'``." msgstr "" "Για να μετατρέψετε, πχ τον αριθμό ``144`` στη συμβολοσειρά ``'144'``, " "χρησιμοποιείστε τον ενσωματωμένο τύπο κατασκευής :func:`str`. Εάν θέλετε " "μια δεκαεξαδική ή οκταδική αναπαράσταση, χρησιμοποιήστε τις ενσωματωμένες " "συναρτήσεις :func:`hex` ή :func:`oct`. Για φανταχτερή μορφοποίηση, βλ. τις " -"ενότητες :ref:`f-strings` και :ref:`formatstrings` π.χ. ``\"{:04d}\"." -"format(144)`` αποδίδει ``'0144'`` και ``\"{:.3f}\".format(1.0/3.0)`` " +"ενότητες :ref:`f-strings` και :ref:`formatstrings` π.χ. ``\"{:04d}" +"\".format(144)`` αποδίδει ``'0144'`` και ``\"{:.3f}\".format(1.0/3.0)`` " "αποδίδει ``'0.333'``." #: faq/programming.rst:906 @@ -1422,6 +1780,31 @@ msgstr "" "δοκιμάστε να χρησιμοποιήσετε ένα αντικείμενο :class:`io.StringIO` ή το " "module :mod:`array`::" +#: faq/programming.rst:914 +msgid "" +">>> import io\n" +">>> s = \"Hello, world\"\n" +">>> sio = io.StringIO(s)\n" +">>> sio.getvalue()\n" +"'Hello, world'\n" +">>> sio.seek(7)\n" +"7\n" +">>> sio.write(\"there!\")\n" +"6\n" +">>> sio.getvalue()\n" +"'Hello, there!'\n" +"\n" +">>> import array\n" +">>> a = array.array('u', s)\n" +">>> print(a)\n" +"array('u', 'Hello, world')\n" +">>> a[0] = 'y'\n" +">>> print(a)\n" +"array('u', 'yello, world')\n" +">>> a.tounicode()\n" +"'yello, world'" +msgstr "" + #: faq/programming.rst:938 msgid "How do I use strings to call functions/methods?" msgstr "" @@ -1444,10 +1827,29 @@ msgstr "" "συναρτήσεων. Αυτή είναι επίσης η κύρια τεχνική που χρησιμοποιείται για την " "εξομοίωση μιας κατασκευής πεζών-κεφαλαίων::" +#: faq/programming.rst:947 +msgid "" +"def a():\n" +" pass\n" +"\n" +"def b():\n" +" pass\n" +"\n" +"dispatch = {'go': a, 'stop': b} # Note lack of parens for funcs\n" +"\n" +"dispatch[get_input()]() # Note trailing parens to call function" +msgstr "" + #: faq/programming.rst:957 msgid "Use the built-in function :func:`getattr`::" msgstr "Χρησιμοποιείστε την ενσωματωμένη συνάρτηση :func:`getattr`::" +#: faq/programming.rst:959 +msgid "" +"import foo\n" +"getattr(foo, 'bar')()" +msgstr "" + #: faq/programming.rst:962 msgid "" "Note that :func:`getattr` works on any object, including classes, class " @@ -1461,11 +1863,35 @@ msgid "This is used in several places in the standard library, like this::" msgstr "" "Αυτό χρησιμοποιείται σε πολλά σημεία της τυπικής βιβλιοθήκης, όπως αυτό::" +#: faq/programming.rst:967 +msgid "" +"class Foo:\n" +" def do_foo(self):\n" +" ...\n" +"\n" +" def do_bar(self):\n" +" ...\n" +"\n" +"f = getattr(foo_instance, 'do_' + opname)\n" +"f()" +msgstr "" + #: faq/programming.rst:978 msgid "Use :func:`locals` to resolve the function name::" msgstr "" "Χρησιμοποιήστε το :func:`locals` για να επιλύσετε το όνομα της συνάρτησης::" +#: faq/programming.rst:980 +msgid "" +"def myFunc():\n" +" print(\"hello\")\n" +"\n" +"fname = \"myFunc\"\n" +"\n" +"f = locals()[fname]\n" +"f()" +msgstr "" + #: faq/programming.rst:990 msgid "" "Is there an equivalent to Perl's chomp() for removing trailing newlines from " @@ -1488,6 +1914,15 @@ msgstr "" "αντιπροσωπεύει περισσότερες από μία γραμμές στο τέλος, οι terminators " "γραμμής για όλες τις κενές γραμμές θα αφαιρεθούν::" +#: faq/programming.rst:998 +msgid "" +">>> lines = (\"line 1 \\r\\n\"\n" +"... \"\\r\\n\"\n" +"... \"\\r\\n\")\n" +">>> lines.rstrip(\"\\n\\r\")\n" +"'line 1 '" +msgstr "" + #: faq/programming.rst:1004 msgid "" "Since this is typically only desired when reading text one line at a time, " @@ -1505,13 +1940,14 @@ msgid "Not as such." msgstr "Όχι ως τέτοιο." #: faq/programming.rst:1013 +#, fuzzy msgid "" "For simple input parsing, the easiest approach is usually to split the line " "into whitespace-delimited words using the :meth:`~str.split` method of " -"string objects and then convert decimal strings to numeric values using :" -"func:`int` or :func:`float`. :meth:`!split()` supports an optional \"sep\" " -"parameter which is useful if the line uses something other than whitespace " -"as a separator." +"string objects and then convert decimal strings to numeric values " +"using :func:`int` or :func:`float`. :meth:`!split` supports an optional " +"\"sep\" parameter which is useful if the line uses something other than " +"whitespace as a separator." msgstr "" "Για απλή ανάλυση εισόδου, η ευκολότερη προσέγγιση είναι συνήθως ο " "διαχωρισμός της γραμμής σε λέξεις οριοθετημένες με κενά διαστήματα " @@ -1551,6 +1987,15 @@ msgstr "" "Μια ακατέργαστη συμβολοσειρά που τελειώνει με περιττό αριθμό backslashes θα " "ξεφύγει από το απόσπασμα της συμβολοσειράς::" +#: faq/programming.rst:1036 +msgid "" +">>> r'C:\\this\\will\\not\\work\\'\n" +" File \"\", line 1\n" +" r'C:\\this\\will\\not\\work\\'\n" +" ^\n" +"SyntaxError: unterminated string literal (detected at line 1)" +msgstr "" + #: faq/programming.rst:1042 msgid "" "There are several workarounds for this. One is to use regular strings and " @@ -1559,6 +2004,12 @@ msgstr "" "Υπάρχουν αρκετές λύσεις για αυτό. Ο ένας είναι να χρησιμοποιήσετε κανονικές " "συμβολοσειρές και να διπλασιάσετε τα backslashes::" +#: faq/programming.rst:1045 +msgid "" +">>> 'C:\\\\this\\\\will\\\\work\\\\'\n" +"'C:\\\\this\\\\will\\\\work\\\\'" +msgstr "" + #: faq/programming.rst:1048 msgid "" "Another is to concatenate a regular string containing an escaped backslash " @@ -1567,6 +2018,12 @@ msgstr "" "Ένα άλλο είναι να συνδέσετε μια κανονική συμβολοσειρά που περιέχει ένα " "escaped backslash στην ακατέργαστη συμβολοσειρά::" +#: faq/programming.rst:1051 +msgid "" +">>> r'C:\\this\\will\\work' '\\\\'\n" +"'C:\\\\this\\\\will\\\\work\\\\'" +msgstr "" + #: faq/programming.rst:1054 msgid "" "It is also possible to use :func:`os.path.join` to append a backslash on " @@ -1575,6 +2032,12 @@ msgstr "" "Είναι επίσης δυνατό να χρησιμοποιήσετε το :func:`os.path.join` για να " "προσθέσετε ένα backslash στα Windows::" +#: faq/programming.rst:1056 +msgid "" +">>> os.path.join(r'C:\\this\\will\\work', '')\n" +"'C:\\\\this\\\\will\\\\work\\\\'" +msgstr "" + #: faq/programming.rst:1059 msgid "" "Note that while a backslash will \"escape\" a quote for the purposes of " @@ -1588,6 +2051,12 @@ msgstr "" "Δηλαδή, το backslash παραμένει παρόν στην τιμή της ακατέργαστης " "συμβολοσειράς::" +#: faq/programming.rst:1064 +msgid "" +">>> r'backslash\\'preserved'\n" +"\"backslash\\\\'preserved\"" +msgstr "" + #: faq/programming.rst:1067 msgid "Also see the specification in the :ref:`language reference `." msgstr "Δείτε επίσης την προδιαγραφή στην :ref:`language reference `." @@ -1630,8 +2099,8 @@ msgid "" "optimize any code (see the :mod:`profile` module)." msgstr "" "Θα πρέπει πάντα να βρίσκετε τα hot spot στο πρόγραμμά σας *πριν* " -"επιχειρήσετε να βελτιστοποιήσετε οποιονδήποτε κώδικα (βλ. το module :mod:" -"`profile`)." +"επιχειρήσετε να βελτιστοποιήσετε οποιονδήποτε κώδικα (βλ. το " +"module :mod:`profile`)." #: faq/programming.rst:1084 msgid "" @@ -1676,26 +2145,26 @@ msgid "" "Use the right data structures. Study documentation for the :ref:`bltin-" "types` and the :mod:`collections` module." msgstr "" -"Χρησιμοποιήστε τις σωστές δομές δεδομένων. Μελετήστε την τεκμηρίωση για το :" -"ref:`bltin-types` και το module :mod:`collections`." +"Χρησιμοποιήστε τις σωστές δομές δεδομένων. Μελετήστε την τεκμηρίωση για " +"το :ref:`bltin-types` και το module :mod:`collections`." #: faq/programming.rst:1101 msgid "" "When the standard library provides a primitive for doing something, it is " "likely (although not guaranteed) to be faster than any alternative you may " "come up with. This is doubly true for primitives written in C, such as " -"builtins and some extension types. For example, be sure to use either the :" -"meth:`list.sort` built-in method or the related :func:`sorted` function to " -"do sorting (and see the :ref:`sortinghowto` for examples of moderately " +"builtins and some extension types. For example, be sure to use either " +"the :meth:`list.sort` built-in method or the related :func:`sorted` function " +"to do sorting (and see the :ref:`sortinghowto` for examples of moderately " "advanced usage)." msgstr "" "Όταν η τυπική βιβλιοθήκη παρέχει ένα πρωτόγονο για να κάνετε κάτι, είναι " "πιθανό (αν και δεν είναι εγγυημένο) να είναι πιο γρήγορο από οποιαδήποτε " "εναλλακτική λύση που μπορείτε να βρείτε. Αυτό ισχύει διπλά για πρωτόγονα " "γραμμένα σε C, όπως ενσωματωμένα και ορισμένους τύπους επεκτάσεων. Για " -"παράδειγμα, φροντίστε να χρησιμοποιήσετε είτε την ενσωματωμένη μέθοδο :meth:" -"`list.sort` είτε τη σχετική συνάρτηση :func:`sorted` για να κάνετε " -"ταξινόμηση (και δείτε το :ref:`sortinghowto` για παραδείγματα μέτριος " +"παράδειγμα, φροντίστε να χρησιμοποιήσετε είτε την ενσωματωμένη " +"μέθοδο :meth:`list.sort` είτε τη σχετική συνάρτηση :func:`sorted` για να " +"κάνετε ταξινόμηση (και δείτε το :ref:`sortinghowto` για παραδείγματα μέτριος " "προηγμένης χρήσης)." #: faq/programming.rst:1109 @@ -1739,8 +2208,8 @@ msgid "" "The wiki page devoted to `performance tips `_." msgstr "" -"Η σελίδα wiki που είναι αφιερωμένη σε `συμβουλές απόδοσης `_." +"Η σελίδα wiki που είναι αφιερωμένη σε `συμβουλές απόδοσης `_." #: faq/programming.rst:1131 msgid "What is the most efficient way to concatenate many strings together?" @@ -1766,14 +2235,22 @@ msgid "" "them into a list and call :meth:`str.join` at the end::" msgstr "" "Για να συγκεντρώσετε πολλά αντικείμενα :class:`str`, το προτεινόμενο ιδίωμα " -"είναι να τα τοποθετήσετε σε μια λίστα και να καλέσετε το στο :meth:`str." -"join` τέλος::" +"είναι να τα τοποθετήσετε σε μια λίστα και να καλέσετε το " +"στο :meth:`str.join` τέλος::" + +#: faq/programming.rst:1141 +msgid "" +"chunks = []\n" +"for s in my_strings:\n" +" chunks.append(s)\n" +"result = ''.join(chunks)" +msgstr "" #: faq/programming.rst:1146 msgid "(another reasonably efficient idiom is to use :class:`io.StringIO`)" msgstr "" -"(ένα άλλο λογικά αποτελεσματικό ιδίωμα είναι να χρησιμοποιήσετε το :class:" -"`io.StringIO`)" +"(ένα άλλο λογικά αποτελεσματικό ιδίωμα είναι να χρησιμοποιήσετε " +"το :class:`io.StringIO`)" #: faq/programming.rst:1148 msgid "" @@ -1785,6 +2262,13 @@ msgstr "" "είναι η επέκταση ενός αντικειμένου :class:`bytearray` χρησιμοποιώντας " "επιτόπια συνένωση (ο τελεστής ``+=``)::" +#: faq/programming.rst:1151 +msgid "" +"result = bytearray()\n" +"for b in my_bytes_objects:\n" +" result += b" +msgstr "" + #: faq/programming.rst:1157 msgid "Sequences (Tuples/Lists)" msgstr "Ακολουθίες (Πλειάδες/Λίστες)" @@ -1865,6 +2349,12 @@ msgstr "Πώς μπορώ να επαναλάβω μια ακολουθία με msgid "Use the :func:`reversed` built-in function::" msgstr "Χρησιμοποιείστε την ενσωματωμένη συνάρτηση :func:`reversed`::" +#: faq/programming.rst:1194 +msgid "" +"for x in reversed(sequence):\n" +" ... # do something with x ..." +msgstr "" + #: faq/programming.rst:1197 msgid "" "This won't touch your original sequence, but build a new copy with reversed " @@ -1895,14 +2385,30 @@ msgstr "" "Εάν δεν σας πειράζει να αναδιατάξετε τη λίστα, ταξινομήστε την και μετά " "σαρώστε από το τέλος της λίστας, διαγράφοντας τα διπλότυπα καθώς προχωράτε::" +#: faq/programming.rst:1211 +msgid "" +"if mylist:\n" +" mylist.sort()\n" +" last = mylist[-1]\n" +" for i in range(len(mylist)-2, -1, -1):\n" +" if last == mylist[i]:\n" +" del mylist[i]\n" +" else:\n" +" last = mylist[i]" +msgstr "" + #: faq/programming.rst:1220 msgid "" -"If all elements of the list may be used as set keys (i.e. they are all :term:" -"`hashable`) this is often faster ::" +"If all elements of the list may be used as set keys (i.e. they are " +"all :term:`hashable`) this is often faster ::" msgstr "" "Εάν όλα τα στοιχεία της λίστας μπορούν να χρησιμοποιηθούν ως κλειδιά συνόλου " "(δηλαδή είναι όλα τα :term:`hashable`) αυτό είναι συχνά πιο γρήγορο::" +#: faq/programming.rst:1223 +msgid "mylist = list(set(mylist))" +msgstr "" + #: faq/programming.rst:1225 msgid "" "This converts the list into a set, thereby removing duplicates, and then " @@ -1927,6 +2433,13 @@ msgstr "" "πιο γρήγορο να χρησιμοποιήσετε την αντικατάσταση τμημάτων με ένα έμμεσο ή " "ρητώς προς τα εμπρός iteration. Ακολουθούν τρεις παραλλαγές::" +#: faq/programming.rst:1237 +msgid "" +"mylist[:] = filter(keep_function, mylist)\n" +"mylist[:] = (x for x in mylist if keep_condition)\n" +"mylist[:] = [x for x in mylist if keep_condition]" +msgstr "" + #: faq/programming.rst:1241 msgid "The list comprehension may be fastest." msgstr "Το comprehension της λίστας μπορεί να είναι ταχύτερο." @@ -1939,6 +2452,10 @@ msgstr "Πως μπορείτε να φτιάξετε έναν πίνακα στ msgid "Use a list::" msgstr "Χρησιμοποιήστε μια λίστα::" +#: faq/programming.rst:1249 +msgid "[\"this\", 1, \"is\", \"an\", \"array\"]" +msgstr "" + #: faq/programming.rst:1251 msgid "" "Lists are equivalent to C or Pascal arrays in their time complexity; the " @@ -1958,8 +2475,8 @@ msgid "" msgstr "" "Το module ``array`` παρέχει επίσης μεθόδους για τη δημιουργία πινάκων " "σταθερών τύπων με συμπαγείς αναπαραστάσεις, αλλά είναι πιο αργές στην " -"ευρετηρίαση από τις λίστες. Σημειώστε επίσης ότι το `NumPy `_ και άλλο πακέτα τρίτων, ορίζουν δομές τύπους array με διάφορα " +"ευρετηρίαση από τις λίστες. Σημειώστε επίσης ότι το `NumPy `_ και άλλο πακέτα τρίτων, ορίζουν δομές τύπους array με διάφορα " "χαρακτηριστικά επίσης." #: faq/programming.rst:1260 @@ -1969,6 +2486,10 @@ msgstr "" "Για να λάβετε συνδεδεμένες λίστες τύπου Lisp, μπορείτε να εξομοιώσετε *cons " "κελιά* χρησιμοποιώντας πλειάδες::" +#: faq/programming.rst:1262 +msgid "lisp_list = (\"like\", (\"this\", (\"example\", None) ) )" +msgstr "" + #: faq/programming.rst:1264 msgid "" "If mutability is desired, you could use lists instead of tuples. Here the " @@ -1990,14 +2511,31 @@ msgstr "Πως φτιάχνω μια πολυδιάστατη λίστα;" msgid "You probably tried to make a multidimensional array like this::" msgstr "Μάλλον προσπαθήσατε να φτιάξετε έναν πολυδιάστατο πίνακα σαν αυτόν::" +#: faq/programming.rst:1277 +msgid ">>> A = [[None] * 2] * 3" +msgstr "" + #: faq/programming.rst:1279 msgid "This looks correct if you print it:" msgstr "Αυτό φαίνεται σωστό αν το εκτυπώσετε:" +#: faq/programming.rst:1285 +msgid "" +">>> A\n" +"[[None, None], [None, None], [None, None]]" +msgstr "" + #: faq/programming.rst:1290 msgid "But when you assign a value, it shows up in multiple places:" msgstr "Αλλά όταν εκχωρείτε μια τιμή, εμφανίζεται σε πολλά σημεία:" +#: faq/programming.rst:1296 +msgid "" +">>> A[0][0] = 5\n" +">>> A\n" +"[[5, None], [5, None], [5, None]]" +msgstr "" + #: faq/programming.rst:1302 msgid "" "The reason is that replicating a list with ``*`` doesn't create copies, it " @@ -2020,6 +2558,13 @@ msgstr "" "επιθυμητό μήκος και στη συνέχεια να συμπληρώσετε κάθε στοιχείο με μια νέα " "λίστα::" +#: faq/programming.rst:1310 +msgid "" +"A = [None] * 3\n" +"for i in range(3):\n" +" A[i] = [None] * 2" +msgstr "" + #: faq/programming.rst:1314 msgid "" "This generates a list containing 3 different lists of length two. You can " @@ -2028,6 +2573,12 @@ msgstr "" "Αυτό δημιουργεί μια λίστα που περιέχει 3 διαφορετικές λίστες με μήκος δύο. " "Μπορείτε επίσης να χρησιμοποιήσετε ένα comprehension λίστας::" +#: faq/programming.rst:1317 +msgid "" +"w, h = 2, 3\n" +"A = [[None] * w for i in range(h)]" +msgstr "" + #: faq/programming.rst:1320 msgid "" "Or, you can use an extension that provides a matrix datatype; `NumPy " @@ -2045,13 +2596,20 @@ msgstr "" #: faq/programming.rst:1327 msgid "" -"To call a method or function and accumulate the return values is a list, a :" -"term:`list comprehension` is an elegant solution::" +"To call a method or function and accumulate the return values is a list, " +"a :term:`list comprehension` is an elegant solution::" msgstr "" "Για να καλέστε μια μέθοδο ή μια συνάρτηση και να συγκεντρώσετε τις " "επιστρεφόμενες τιμές είναι μια λίστα, ένα :term:`list comprehension` είναι " "μια κομψή λύση::" +#: faq/programming.rst:1330 +msgid "" +"result = [obj.method() for obj in mylist]\n" +"\n" +"result = [function(obj) for obj in mylist]" +msgstr "" + #: faq/programming.rst:1334 msgid "" "To just run the method or function without saving the return values, a " @@ -2060,6 +2618,15 @@ msgstr "" "Για να εκτελέσετε απλώς τη μέθοδο ή τη συνάρτηση χωρίς να αποθηκεύσετε τις " "επιστρεφόμενες τιμές, αρκεί ένας απλός βρόχος :keyword:`for`::" +#: faq/programming.rst:1337 +msgid "" +"for obj in mylist:\n" +" obj.method()\n" +"\n" +"for obj in mylist:\n" +" function(obj)" +msgstr "" + #: faq/programming.rst:1346 msgid "" "Why does a_tuple[i] += ['item'] raise an exception when the addition works?" @@ -2091,6 +2658,15 @@ msgstr "" msgid "If you wrote::" msgstr "Εάν γράψετε::" +#: faq/programming.rst:1358 +msgid "" +">>> a_tuple = (1, 2)\n" +">>> a_tuple[0] += 1\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: 'tuple' object does not support item assignment" +msgstr "" + #: faq/programming.rst:1364 msgid "" "The reason for the exception should be immediately clear: ``1`` is added to " @@ -2114,6 +2690,15 @@ msgstr "" "Κάτω από τα καλύμματα, αυτό που κάνει αυτή η επαυξημένη δήλωση ανάθεσης " "είναι περίπου το εξής::" +#: faq/programming.rst:1373 +msgid "" +">>> result = a_tuple[0] + 1\n" +">>> a_tuple[0] = result\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: 'tuple' object does not support item assignment" +msgstr "" + #: faq/programming.rst:1379 msgid "" "It is the assignment part of the operation that produces the error, since a " @@ -2126,6 +2711,15 @@ msgstr "" msgid "When you write something like::" msgstr "Όταν γράφετε κάτι σαν::" +#: faq/programming.rst:1384 +msgid "" +">>> a_tuple = (['foo'], 'bar')\n" +">>> a_tuple[0] += ['item']\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: 'tuple' object does not support item assignment" +msgstr "" + #: faq/programming.rst:1390 msgid "" "The exception is a bit more surprising, and even more surprising is the fact " @@ -2134,6 +2728,12 @@ msgstr "" "Η εξαίρεση είναι λίγο πιο εκπληκτική, και ακόμη πιο εκπληκτικό είναι το " "γεγονός ότι παρόλο που υπήρχε ένα σφάλμα, το παράρτημα λειτούργησε::" +#: faq/programming.rst:1393 +msgid "" +">>> a_tuple[0]\n" +"['foo', 'item']" +msgstr "" + #: faq/programming.rst:1396 msgid "" "To see why this happens, you need to know that (a) if an object implements " @@ -2146,15 +2746,29 @@ msgstr "" "Για να δείτε γιατί συμβαίνει αυτό, πρέπει να γνωρίζετε ότι (α) εάν ένα " "αντικείμενο υλοποιεί μια μαγική μέθοδο :meth:`~object.__iadd__`, που " "καλείται όταν εκτελείται η επαυξημένη ανάθεση ``+=`` και η τιμή επιστροφής " -"είναι αυτή που χρησιμοποιείται στη δήλωση εκχώρησης∙ και (β) για λίστες, :" -"meth:`!__iadd__` ισοδυναμεί με την κλήση του :meth:`!extend` στη λίστα και " -"επιστρέφει τη λίστα. Για αυτό λέμε ότι για λίστες ``+=`` είναι μια " -"\"συντομογραφία\" για :meth:`!list.extend`::" +"είναι αυτή που χρησιμοποιείται στη δήλωση εκχώρησης∙ και (β) για " +"λίστες, :meth:`!__iadd__` ισοδυναμεί με την κλήση του :meth:`!extend` στη " +"λίστα και επιστρέφει τη λίστα. Για αυτό λέμε ότι για λίστες ``+=`` είναι " +"μια \"συντομογραφία\" για :meth:`!list.extend`::" + +#: faq/programming.rst:1404 +msgid "" +">>> a_list = []\n" +">>> a_list += [1]\n" +">>> a_list\n" +"[1]" +msgstr "" #: faq/programming.rst:1409 msgid "This is equivalent to::" msgstr "Αυτό ισοδυναμεί με::" +#: faq/programming.rst:1411 +msgid "" +">>> result = a_list.__iadd__([1])\n" +">>> a_list = result" +msgstr "" + #: faq/programming.rst:1414 msgid "" "The object pointed to by a_list has been mutated, and the pointer to the " @@ -2172,6 +2786,15 @@ msgstr "" msgid "Thus, in our tuple example what is happening is equivalent to::" msgstr "Έτσι, στο παράδειγμά μας, αυτό που συμβαίνει είναι ισοδύναμο με::" +#: faq/programming.rst:1421 +msgid "" +">>> result = a_tuple[0].__iadd__(['item'])\n" +">>> a_tuple[0] = result\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: 'tuple' object does not support item assignment" +msgstr "" + #: faq/programming.rst:1427 msgid "" "The :meth:`!__iadd__` succeeds, and thus the list is extended, but even " @@ -2204,6 +2827,12 @@ msgstr "" "στοιχείο στην \" τιμή ταξινόμησης\" του. Στην Python, χρησιμοποιήστε το " "όρισμα ``key`` για τη μέθοδο :meth:`list.sort`::" +#: faq/programming.rst:1439 +msgid "" +"Isorted = L[:]\n" +"Isorted.sort(key=lambda s: int(s[10:15]))" +msgstr "" + #: faq/programming.rst:1444 msgid "How can I sort one list by values from another list?" msgstr "" @@ -2217,6 +2846,20 @@ msgstr "" "Συγχωνεύστε τα σε έναν iterator πλειάδων, ταξινομήστε τη λίστα που προκύπτει " "και, στην συνέχεια επιλέξτε το στοιχείο που θέλετε. ::" +#: faq/programming.rst:1449 +msgid "" +">>> list1 = [\"what\", \"I'm\", \"sorting\", \"by\"]\n" +">>> list2 = [\"something\", \"else\", \"to\", \"sort\"]\n" +">>> pairs = zip(list1, list2)\n" +">>> pairs = sorted(pairs)\n" +">>> pairs\n" +"[(\"I'm\", 'else'), ('by', 'sort'), ('sorting', 'to'), ('what', " +"'something')]\n" +">>> result = [x[1] for x in pairs]\n" +">>> result\n" +"['else', 'sort', 'to', 'something']" +msgstr "" + #: faq/programming.rst:1461 msgid "Objects" msgstr "Αντικείμενα" @@ -2262,14 +2905,21 @@ msgstr "Τι είναι μια μέθοδος;" #: faq/programming.rst:1481 msgid "" -"A method is a function on some object ``x`` that you normally call as ``x." -"name(arguments...)``. Methods are defined as functions inside the class " +"A method is a function on some object ``x`` that you normally call as " +"``x.name(arguments...)``. Methods are defined as functions inside the class " "definition::" msgstr "" "Μια μέθοδος είναι μια συνάρτηση σε κάποιο αντικείμενο ``x`` που συνήθως " "καλείτε ως ``x.name(ορίσματα...)``. Οι μέθοδοι ορίζονται ως συναρτήσεις " "εντός του ορισμού κλάσης::" +#: faq/programming.rst:1485 +msgid "" +"class C:\n" +" def meth(self, arg):\n" +" return arg * 2 + self.attribute" +msgstr "" + #: faq/programming.rst:1491 msgid "What is self?" msgstr "Τι είναι το self;" @@ -2282,8 +2932,8 @@ msgid "" "the called method will think it is called as ``meth(x, a, b, c)``." msgstr "" "Το self είναι απλώς ένα συμβατικό όνομα για το πρώτο όρισμα μιας μεθόδου. " -"Μια μέθοδος που ορίζεται ως ``meth(self, a, b, c)`` πρέπει να ονομάζεται ``x." -"meth(a, b, c)`` για κάποιο παράδειγμα ``x`` της κλάσης στην οποία " +"Μια μέθοδος που ορίζεται ως ``meth(self, a, b, c)`` πρέπει να ονομάζεται " +"``x.meth(a, b, c)`` για κάποιο παράδειγμα ``x`` της κλάσης στην οποία " "εμφανίζεται ο ορισμός∙ η καλούμενη μέθοδος θα ονομάζεται ``meth(x, a, b, " "c)``." @@ -2318,8 +2968,8 @@ msgstr "" #: faq/programming.rst:1511 msgid "" -"Note that :func:`isinstance` also checks for virtual inheritance from an :" -"term:`abstract base class`. So, the test will return ``True`` for a " +"Note that :func:`isinstance` also checks for virtual inheritance from " +"an :term:`abstract base class`. So, the test will return ``True`` for a " "registered class even if hasn't directly or indirectly inherited from it. " "To test for \"true inheritance\", scan the :term:`MRO` of the class:" msgstr "" @@ -2329,6 +2979,38 @@ msgstr "" "κληρονομήσει άμεσα ή έμμεσα από αυτό. Για να ελέγξετε μια \"αληθινή " "κληρονομικότητα\", σαρώστε το :term:`MRO` της κλάσης::" +#: faq/programming.rst:1516 +msgid "" +"from collections.abc import Mapping\n" +"\n" +"class P:\n" +" pass\n" +"\n" +"class C(P):\n" +" pass\n" +"\n" +"Mapping.register(P)" +msgstr "" + +#: faq/programming.rst:1528 +msgid "" +">>> c = C()\n" +">>> isinstance(c, C) # direct\n" +"True\n" +">>> isinstance(c, P) # indirect\n" +"True\n" +">>> isinstance(c, Mapping) # virtual\n" +"True\n" +"\n" +"# Actual inheritance chain\n" +">>> type(c).__mro__\n" +"(, , )\n" +"\n" +"# Test for \"true inheritance\"\n" +">>> Mapping in type(c).__mro__\n" +"False" +msgstr "" + #: faq/programming.rst:1546 msgid "" "Note that most programs do not use :func:`isinstance` on user-defined " @@ -2338,14 +3020,24 @@ msgid "" "and doing a different thing based on what class it is. For example, if you " "have a function that does something::" msgstr "" -"Λάβετε υπόψη ότι τα περισσότερα προγράμματα δεν χρησιμοποιούν το :func:" -"`isinstance` σε κλάσεις που ορίζονται από τη χρήστη πολύ συχνά. Εάν " -"αναπτύσσετε μόνοι σας τις κλάσεις, ένα πιο σωστό αντικειμενοστρεφής στυλ " +"Λάβετε υπόψη ότι τα περισσότερα προγράμματα δεν χρησιμοποιούν " +"το :func:`isinstance` σε κλάσεις που ορίζονται από τη χρήστη πολύ συχνά. " +"Εάν αναπτύσσετε μόνοι σας τις κλάσεις, ένα πιο σωστό αντικειμενοστρεφής στυλ " "είναι να ορίζετε μεθόδους στις κλάσεις που ενσωματώνουν μια συγκεκριμένη " "συμπεριφορά, αντί να ελέγχετε την κλάση του αντικειμένου και να κάνετε κάτι " "διαφορετικό με βάση την κλάση που είναι, για παράδειγμα, εάν έχετε μια " "συνάρτηση που κάνει κάτι::" +#: faq/programming.rst:1553 +msgid "" +"def search(obj):\n" +" if isinstance(obj, Mailbox):\n" +" ... # code to search a mailbox\n" +" elif isinstance(obj, Document):\n" +" ... # code to search a document\n" +" elif ..." +msgstr "" + #: faq/programming.rst:1560 msgid "" "A better approach is to define a ``search()`` method on all the classes and " @@ -2354,6 +3046,19 @@ msgstr "" "Μια καλύτερη προσέγγιση είναι να ορίσετε μια μέθοδο ``search()`` σε όλες τις " "κλάσεις και απλώς να την καλέσετε::" +#: faq/programming.rst:1563 +msgid "" +"class Mailbox:\n" +" def search(self):\n" +" ... # code to search a mailbox\n" +"\n" +"class Document:\n" +" def search(self):\n" +" ... # code to search a document\n" +"\n" +"obj.search()" +msgstr "" + #: faq/programming.rst:1575 msgid "What is delegation?" msgstr "Τι είναι το delegation;" @@ -2383,14 +3088,28 @@ msgstr "" "παράδειγμα, η ακόλουθη κλάση υλοποιεί μια κλάση που συμπεριφέρεται σαν " "αρχείο αλλά μετατρέπει όλα τα γραπτά δεδομένα σε κεφαλαία::" +#: faq/programming.rst:1587 +msgid "" +"class UpperOut:\n" +"\n" +" def __init__(self, outfile):\n" +" self._outfile = outfile\n" +"\n" +" def write(self, s):\n" +" self._outfile.write(s.upper())\n" +"\n" +" def __getattr__(self, name):\n" +" return getattr(self._outfile, name)" +msgstr "" + #: faq/programming.rst:1598 msgid "" "Here the ``UpperOut`` class redefines the ``write()`` method to convert the " -"argument string to uppercase before calling the underlying ``self._outfile." -"write()`` method. All other methods are delegated to the underlying ``self." -"_outfile`` object. The delegation is accomplished via the :meth:`~object." -"__getattr__` method; consult :ref:`the language reference ` for more information about controlling attribute access." +"argument string to uppercase before calling the underlying " +"``self._outfile.write()`` method. All other methods are delegated to the " +"underlying ``self._outfile`` object. The delegation is accomplished via " +"the :meth:`~object.__getattr__` method; consult :ref:`the language reference " +"` for more information about controlling attribute access." msgstr "" "Εδώ η κλάση ``UpperOut`` επαναπροσδιορίζει τη μέθοδο ``write()`` για να " "μετατρέψει τη συμβολοσειρά ορίσματος σε κεφαλαία πριν καλέσει την υποκείμενη " @@ -2403,9 +3122,9 @@ msgstr "" #: faq/programming.rst:1605 msgid "" "Note that for more general cases delegation can get trickier. When " -"attributes must be set as well as retrieved, the class must define a :meth:" -"`~object.__setattr__` method too, and it must do so carefully. The basic " -"implementation of :meth:`!__setattr__` is roughly equivalent to the " +"attributes must be set as well as retrieved, the class must define " +"a :meth:`~object.__setattr__` method too, and it must do so carefully. The " +"basic implementation of :meth:`!__setattr__` is roughly equivalent to the " "following::" msgstr "" "Λάβετε υπόψη ότι για πιο γενικές περιπτώσεις η ανάθεση μπορεί να γίνει πιο " @@ -2414,17 +3133,41 @@ msgstr "" "πρέπει να το κάνει προσεκτικά. Η βασική υλοποίηση του :meth:`!__setattr__` " "είναι περίπου ισοδύναμο με το εξής::" +#: faq/programming.rst:1610 +msgid "" +"class X:\n" +" ...\n" +" def __setattr__(self, name, value):\n" +" self.__dict__[name] = value\n" +" ..." +msgstr "" + #: faq/programming.rst:1616 +#, fuzzy msgid "" -"Most :meth:`!__setattr__` implementations must modify :meth:`self.__dict__ " -"` to store local state for self without causing an infinite " -"recursion." +"Many :meth:`~object.__setattr__` implementations call :meth:`!" +"object.__setattr__` to set an attribute on self without causing infinite " +"recursion::" msgstr "" -"Οι περισσότερες υλοποιήσεις :meth:`!__setattr__` πρέπει να τροποποιήσουν το :" -"meth:`self.__dict__ ` για να αποθηκεύουν την τοπική " +"Οι περισσότερες υλοποιήσεις :meth:`!__setattr__` πρέπει να τροποποιήσουν " +"το :meth:`self.__dict__ ` για να αποθηκεύουν την τοπική " "κατάσταση για τον εαυτό τους χωρίς να προκαλούν άπειρη αναδρομή." -#: faq/programming.rst:1622 +#: faq/programming.rst:1619 +msgid "" +"class X:\n" +" def __setattr__(self, name, value):\n" +" # Custom logic here...\n" +" object.__setattr__(self, name, value)" +msgstr "" + +#: faq/programming.rst:1624 +msgid "" +"Alternatively, it is possible to set attributes by inserting entries " +"into :attr:`self.__dict__ ` directly." +msgstr "" + +#: faq/programming.rst:1629 msgid "" "How do I call a method defined in a base class from a derived class that " "extends it?" @@ -2432,11 +3175,18 @@ msgstr "" "Πώς μπορώ να καλέσω μια μέθοδο που ορίζεται σε μια βασική κλάση από μια " "παράγωγη κλάση που την επεκτείνει;" -#: faq/programming.rst:1624 +#: faq/programming.rst:1631 msgid "Use the built-in :func:`super` function::" msgstr "Χρησιμοποιήστε την ενσωματωμένη συνάρτηση :func:`super`::" -#: faq/programming.rst:1630 +#: faq/programming.rst:1633 +msgid "" +"class Derived(Base):\n" +" def meth(self):\n" +" super().meth() # calls Base.meth" +msgstr "" + +#: faq/programming.rst:1637 msgid "" "In the example, :func:`super` will automatically determine the instance from " "which it was called (the ``self`` value), look up the :term:`method " @@ -2448,13 +3198,13 @@ msgstr "" "order` (MRO) με ``type(self).__mro__``, και επιστρέψτε το επόμενο στη σειρά " "μετά το ``Derived`` στο MRO: ``Base``." -#: faq/programming.rst:1637 +#: faq/programming.rst:1644 msgid "How can I organize my code to make it easier to change the base class?" msgstr "" "Πως μπορώ να οργανώσω τον κώδικα μου προκειμένου να διευκολύνω την αλλαγή " "της βασικής κλάσης;" -#: faq/programming.rst:1639 +#: faq/programming.rst:1646 msgid "" "You could assign the base class to an alias and derive from the alias. Then " "all you have to change is the value assigned to the alias. Incidentally, " @@ -2467,11 +3217,22 @@ msgstr "" "επίσης χρήσιμο εάν θέλετε να αποφασίσετε δυναμικά (π.χ. ανάλογα με την " "διαθεσιμότητα των πόρων) ποια βασική κλάση να χρησιμοποιήσετε Παράδειγμα::" -#: faq/programming.rst:1654 +#: faq/programming.rst:1651 +msgid "" +"class Base:\n" +" ...\n" +"\n" +"BaseAlias = Base\n" +"\n" +"class Derived(BaseAlias):\n" +" ..." +msgstr "" + +#: faq/programming.rst:1661 msgid "How do I create static class data and static class methods?" msgstr "Πως δημιουργώ δεδομένα στατικής κλάσης και μεθόδους στατικής κλάσης;" -#: faq/programming.rst:1656 +#: faq/programming.rst:1663 msgid "" "Both static data and static methods (in the sense of C++ or Java) are " "supported in Python." @@ -2479,7 +3240,7 @@ msgstr "" "Τόσο τα στατιστικά δεδομένα όσο και οι στατικές μέθοδοι (με την έννοια της C+" "+ ή της Java) υποστηρίζονται στην Python." -#: faq/programming.rst:1659 +#: faq/programming.rst:1666 msgid "" "For static data, simply define a class attribute. To assign a new value to " "the attribute, you have to explicitly use the class name in the assignment::" @@ -2488,7 +3249,19 @@ msgstr "" "εκχωρήσετε μια νέα τιμή στο χαρακτηριστικό, πρέπει να χρησιμοποιήσετε ρητά " "το όνομα κλάσης στην εκχώρηση::" -#: faq/programming.rst:1671 +#: faq/programming.rst:1669 +msgid "" +"class C:\n" +" count = 0 # number of times C.__init__ called\n" +"\n" +" def __init__(self):\n" +" C.count = C.count + 1\n" +"\n" +" def getcount(self):\n" +" return C.count # or return self.count" +msgstr "" + +#: faq/programming.rst:1678 msgid "" "``c.count`` also refers to ``C.count`` for any ``c`` such that " "``isinstance(c, C)`` holds, unless overridden by ``c`` itself or by some " @@ -2499,7 +3272,7 @@ msgstr "" "``c`` ή από κάποια κλάση στη διαδρομή αναζήτησης της βασικής κλάσης από το " "``c.__class__`` πίσω στο ``C``." -#: faq/programming.rst:1675 +#: faq/programming.rst:1682 msgid "" "Caution: within a method of C, an assignment like ``self.count = 42`` " "creates a new and unrelated instance named \"count\" in ``self``'s own " @@ -2511,11 +3284,24 @@ msgstr "" "dict του ``self``. Επανασύνδεση μιας κλάσης-στατικής όνομα δεδομένων πρέπει " "πάντα να προσδιορίζει την κλάση είτε βρίσκεται μέσα σε μια μέθοδο είτε όχι::" -#: faq/programming.rst:1682 +#: faq/programming.rst:1687 +msgid "C.count = 314" +msgstr "" + +#: faq/programming.rst:1689 msgid "Static methods are possible::" msgstr "Οι στατικές μέθοδοι είναι δυνατές::" -#: faq/programming.rst:1690 +#: faq/programming.rst:1691 +msgid "" +"class C:\n" +" @staticmethod\n" +" def static(arg1, arg2, arg3):\n" +" # No 'self' parameter!\n" +" ..." +msgstr "" + +#: faq/programming.rst:1697 msgid "" "However, a far more straightforward way to get the effect of a static method " "is via a simple module-level function::" @@ -2523,7 +3309,13 @@ msgstr "" "Ωστόσο, ένας πολύ πιο απλός τρόπος για να λάβετε το αποτέλεσμα μιας στατικής " "μεθόδου είναι μέσω μιας απλής συνάρτησης σε επίπεδο μονάδας::" -#: faq/programming.rst:1696 +#: faq/programming.rst:1700 +msgid "" +"def getcount():\n" +" return C.count" +msgstr "" + +#: faq/programming.rst:1703 msgid "" "If your code is structured so as to define one class (or tightly related " "class hierarchy) per module, this supplies the desired encapsulation." @@ -2532,11 +3324,11 @@ msgstr "" "συνδεδεμένη ιεραρχίας κλάσεων) ανά module, αυτό παρέχει την επιθυμητή " "ενθυλάκωση." -#: faq/programming.rst:1701 +#: faq/programming.rst:1708 msgid "How can I overload constructors (or methods) in Python?" msgstr "Πως μπορώ να υπερφορτώσω κατασκευαστές (ή μεθόδους) στην Python;" -#: faq/programming.rst:1703 +#: faq/programming.rst:1710 msgid "" "This answer actually applies to all methods, but the question usually comes " "up first in the context of constructors." @@ -2544,12 +3336,20 @@ msgstr "" "Αυτή η απάντηση ισχύει στην πραγματικότητα για όλες τις μεθόδους, αλλά η " "ερώτηση συνήθως εμφανίζεται πρώτη στο πλαίσιο των κατασκευαστών." -#: faq/programming.rst:1706 +#: faq/programming.rst:1713 msgid "In C++ you'd write" msgstr "Στην C++ θα γράφατε" #: faq/programming.rst:1715 msgid "" +"class C {\n" +" C() { cout << \"No arguments\\n\"; }\n" +" C(int i) { cout << \"Argument is \" << i << \"\\n\"; }\n" +"}" +msgstr "" + +#: faq/programming.rst:1722 +msgid "" "In Python you have to write a single constructor that catches all cases " "using default arguments. For example::" msgstr "" @@ -2557,26 +3357,42 @@ msgstr "" "τις περιπτώσεις χρησιμοποιώντας προεπιλεγμένα ορίσματα. Για παράδειγμα::" #: faq/programming.rst:1725 +msgid "" +"class C:\n" +" def __init__(self, i=None):\n" +" if i is None:\n" +" print(\"No arguments\")\n" +" else:\n" +" print(\"Argument is\", i)" +msgstr "" + +#: faq/programming.rst:1732 msgid "This is not entirely equivalent, but close enough in practice." msgstr "Αυτό δεν είναι εντελώς ισοδύναμο, αλλά αρκετά κοντά στην πράξη." -#: faq/programming.rst:1727 +#: faq/programming.rst:1734 msgid "You could also try a variable-length argument list, e.g. ::" msgstr "" -"Θα μπορούσατε επίσης να δοκιμάσετε μια λίστα ορισμάτων μεταβλητού μήκους, π." -"χ. ::" +"Θα μπορούσατε επίσης να δοκιμάσετε μια λίστα ορισμάτων μεταβλητού μήκους, " +"π.χ. ::" -#: faq/programming.rst:1732 +#: faq/programming.rst:1736 +msgid "" +"def __init__(self, *args):\n" +" ..." +msgstr "" + +#: faq/programming.rst:1739 msgid "The same approach works for all method definitions." msgstr "Η ίδια προσέγγιση λειτουργεί για όλους τους ορισμούς μεθόδων." -#: faq/programming.rst:1736 +#: faq/programming.rst:1743 msgid "I try to use __spam and I get an error about _SomeClassName__spam." msgstr "" "Προσπαθώ να χρησιμοποιήσω __spam και λαμβάνω ένα σφάλμα σχετικά με το " "_SomeClassName__spam." -#: faq/programming.rst:1738 +#: faq/programming.rst:1745 msgid "" "Variable names with double leading underscores are \"mangled\" to provide a " "simple but effective way to define class private variables. Any identifier " @@ -2592,38 +3408,65 @@ msgstr "" "αντικαθίσταται μέσω κειμένου το ``_classname__spam``, όπου το ``classname`` " "είναι το τρέχον όνομα κλάσης με απογυμνωμένες τυχόν προηγούμενες παύλες." -#: faq/programming.rst:1744 +#: faq/programming.rst:1751 +msgid "" +"The identifier can be used unchanged within the class, but to access it " +"outside the class, the mangled name must be used:" +msgstr "" + +#: faq/programming.rst:1754 +msgid "" +"class A:\n" +" def __one(self):\n" +" return 1\n" +" def two(self):\n" +" return 2 * self.__one()\n" +"\n" +"class B(A):\n" +" def three(self):\n" +" return 3 * self._A__one()\n" +"\n" +"four = 4 * A()._A__one()" +msgstr "" + +#: faq/programming.rst:1768 +#, fuzzy msgid "" -"This doesn't guarantee privacy: an outside user can still deliberately " -"access the \"_classname__spam\" attribute, and private values are visible in " -"the object's ``__dict__``. Many Python programmers never bother to use " -"private variable names at all." +"In particular, this does not guarantee privacy since an outside user can " +"still deliberately access the private attribute; many Python programmers " +"never bother to use private variable names at all." msgstr "" "Αυτό δεν εγγυάται το απόρρητο: ένα εξωτερικός χρήστης μπορεί ακόμα να έχει " "σκόπιμα πρόσβαση στο χαρακτηριστικό \"_classname__spam\" και οι ιδιωτικές " "τιμές είναι ορατές στο ``__dict__``. Πολλοί προγραμματιστές Python δεν " "μπαίνουν ποτέ στον κόπο να χρησιμοποιήσουν προσωπικά ονόματα μεταβλητών." -#: faq/programming.rst:1751 +#: faq/programming.rst:1774 +msgid "" +"The :ref:`private name mangling specifications ` for " +"details and special cases." +msgstr "" + +#: faq/programming.rst:1778 msgid "My class defines __del__ but it is not called when I delete the object." msgstr "" "Η κλάση μου ορίζει __del__ αλλά δεν καλείται όταν διαγράφω το αντικείμενο." -#: faq/programming.rst:1753 +#: faq/programming.rst:1780 msgid "There are several possible reasons for this." msgstr "Υπάρχουν διάφοροι πιθανοί λόγοι για αυτό." -#: faq/programming.rst:1755 +#: faq/programming.rst:1782 msgid "" -"The :keyword:`del` statement does not necessarily call :meth:`~object." -"__del__` -- it simply decrements the object's reference count, and if this " -"reaches zero :meth:`!__del__` is called." +"The :keyword:`del` statement does not necessarily " +"call :meth:`~object.__del__` -- it simply decrements the object's reference " +"count, and if this reaches zero :meth:`!__del__` is called." msgstr "" "Η πρόταση :keyword:`del` δεν καλεί απαραιτήτως το :meth:`~object.__del__` -- " "απλώς μειώνει τον αριθμό αναφοράς του αντικειμένου, και αν αυτό φτάσει στο " "μηδέν καλείται το :meth:`!__del__`." -#: faq/programming.rst:1759 +#: faq/programming.rst:1786 msgid "" "If your data structures contain circular links (e.g. a tree where each child " "has a parent reference and each parent has a list of children) the reference " @@ -2649,7 +3492,7 @@ msgstr "" "μια συλλογή, αλλά *υπάρχουν* παθολογικές περιπτώσεις όπου τα αντικείμενα δεν " "θα συλλεχθούν ποτέ." -#: faq/programming.rst:1770 +#: faq/programming.rst:1797 msgid "" "Despite the cycle collector, it's still a good idea to define an explicit " "``close()`` method on objects to be called whenever you're done with them. " @@ -2666,7 +3509,7 @@ msgstr "" "και το ``close()`` θα πρέπει να βεβαιωθεί ότι μπορεί να κληθεί περισσότερες " "από μία φορές για το ίδιο αντικείμενο." -#: faq/programming.rst:1777 +#: faq/programming.rst:1804 msgid "" "Another way to avoid cyclical references is to use the :mod:`weakref` " "module, which allows you to point to objects without incrementing their " @@ -2679,7 +3522,7 @@ msgstr "" "θα πρέπει να χρησιμοποιούν αδύναμες αναφορές για τις αναφορές γονέων και " "αδελφών ( αν τα χρειαστούν!)." -#: faq/programming.rst:1790 +#: faq/programming.rst:1817 msgid "" "Finally, if your :meth:`!__del__` method raises an exception, a warning " "message is printed to :data:`sys.stderr`." @@ -2687,12 +3530,12 @@ msgstr "" "Τέλος, εάν η μέθοδος :meth:`!__del__` εγείρει μια εξαίρεση, εκτυπώνεται ένα " "προειδοποιητικό μήνυμα στη διεύθυνση :data:`sys.stderr`." -#: faq/programming.rst:1795 +#: faq/programming.rst:1822 msgid "How do I get a list of all instances of a given class?" msgstr "" "Πως μπορώ να λάβω μια λίστα με όλες τις οντότητες μιας δεδομένης κλάσης;" -#: faq/programming.rst:1797 +#: faq/programming.rst:1824 msgid "" "Python does not keep track of all instances of a class (or of a built-in " "type). You can program the class's constructor to keep track of all " @@ -2703,11 +3546,11 @@ msgstr "" "κλάσης να παρακολουθεί όλες τις οντότητες διατηρώντας μια λίστα αδύναμων " "αναφορών σε κάθε παρουσία." -#: faq/programming.rst:1803 +#: faq/programming.rst:1830 msgid "Why does the result of ``id()`` appear to be not unique?" msgstr "Γιατί το αποτέλεσμα του ``id()`` φαίνεται να μην είναι μοναδικό;" -#: faq/programming.rst:1805 +#: faq/programming.rst:1832 msgid "" "The :func:`id` builtin returns an integer that is guaranteed to be unique " "during the lifetime of the object. Since in CPython, this is the object's " @@ -2722,7 +3565,7 @@ msgstr "" "αντικείμενο εκχωρείται στην ίδια θέση στη μνήμη. Αυτό φαίνεται από αυτό το " "παράδειγμα:" -#: faq/programming.rst:1816 +#: faq/programming.rst:1843 msgid "" "The two ids belong to different integer objects that are created before, and " "deleted immediately after execution of the ``id()`` call. To be sure that " @@ -2735,11 +3578,11 @@ msgstr "" "θέλετε να εξετάσετε είναι ακόμα ζωντανά, δημιουργήστε μια άλλη αναφορά στο " "αντικείμενο:" -#: faq/programming.rst:1829 +#: faq/programming.rst:1856 msgid "When can I rely on identity tests with the *is* operator?" msgstr "Πότε μπορώ να βασιστώ σε δοκιμές ταυτότητας με τον τελεστή *is*;" -#: faq/programming.rst:1831 +#: faq/programming.rst:1858 msgid "" "The ``is`` operator tests for object identity. The test ``a is b`` is " "equivalent to ``id(a) == id(b)``." @@ -2747,7 +3590,7 @@ msgstr "" "Ο τελεστής ``is`` ελέγχει την ταυτότητα του αντικειμένου. Η δοκιμή ``a is " "b`` ισοδυναμεί με ``id(a) == id(b)``." -#: faq/programming.rst:1834 +#: faq/programming.rst:1861 msgid "" "The most important property of an identity test is that an object is always " "identical to itself, ``a is a`` always returns ``True``. Identity tests are " @@ -2760,7 +3603,7 @@ msgstr "" "Και σε αντίθεση με τα τεστ ισότητας, τα τεστ ταυτότητας είναι εγγυημένα ότι " "θα επιστρέψουν ένα boolean ``True`` ή ``False``." -#: faq/programming.rst:1839 +#: faq/programming.rst:1866 msgid "" "However, identity tests can *only* be substituted for equality tests when " "object identity is assured. Generally, there are three circumstances where " @@ -2770,7 +3613,7 @@ msgstr "" "όταν είναι εξασφαλισμένη η ταυτότητα αντικειμένου. Γενικά, υπάρχουν τρεις " "περιπτώσεις όπου η ταυτότητα είναι εγγυημένη:" -#: faq/programming.rst:1843 +#: faq/programming.rst:1870 msgid "" "1) Assignments create new names but do not change object identity. After " "the assignment ``new = old``, it is guaranteed that ``new is old``." @@ -2779,7 +3622,7 @@ msgstr "" "αντικειμένου. Μετά την ανάθεση ``new = old``, είναι εγγυημένο ότι το ``new " "is old``." -#: faq/programming.rst:1846 +#: faq/programming.rst:1873 msgid "" "2) Putting an object in a container that stores object references does not " "change object identity. After the list assignment ``s[0] = x``, it is " @@ -2789,7 +3632,7 @@ msgstr "" "αντικειμένων δεν αλλάζει την ταυτότητα αντικειμένου. Μετά την ανάθεση " "λίστας ``s[0] = x``, είναι εγγυημένο ότι το ``s[0] is x``." -#: faq/programming.rst:1850 +#: faq/programming.rst:1877 msgid "" "3) If an object is a singleton, it means that only one instance of that " "object can exist. After the assignments ``a = None`` and ``b = None``, it " @@ -2800,7 +3643,7 @@ msgstr "" "``b = None``, είναι εγγυημένο ότι το ``a is b`` επειδή το ``None`` είναι " "singleton." -#: faq/programming.rst:1854 +#: faq/programming.rst:1881 msgid "" "In most other circumstances, identity tests are inadvisable and equality " "tests are preferred. In particular, identity tests should not be used to " @@ -2809,15 +3652,38 @@ msgid "" msgstr "" "Στις περισσότερες άλλες περιπτώσεις, τα τεστ ταυτότητας δεν ενδείκνυνται και " "προτιμώνται τα τεστ ισότητας. Ειδικότερα, τα τεστ ταυτότητας δεν θα πρέπει " -"να χρησιμοποιούνται για τον έλεγχο σταθερών όπως :class:`int` και :class:" -"`str` που δεν είναι εγγυημένα singletons::" +"να χρησιμοποιούνται για τον έλεγχο σταθερών όπως :class:`int` " +"και :class:`str` που δεν είναι εγγυημένα singletons::" + +#: faq/programming.rst:1886 +msgid "" +">>> a = 1000\n" +">>> b = 500\n" +">>> c = b + 500\n" +">>> a is c\n" +"False\n" +"\n" +">>> a = 'Python'\n" +">>> b = 'Py'\n" +">>> c = b + 'thon'\n" +">>> a is c\n" +"False" +msgstr "" -#: faq/programming.rst:1871 +#: faq/programming.rst:1898 msgid "Likewise, new instances of mutable containers are never identical::" msgstr "" "Ομοίως, τα νέα στιγμιότυπα μεταβλητών κοντέινερ δεν είναι ποτέ πανομοιότυπα::" -#: faq/programming.rst:1878 +#: faq/programming.rst:1900 +msgid "" +">>> a = []\n" +">>> b = []\n" +">>> a is b\n" +"False" +msgstr "" + +#: faq/programming.rst:1905 msgid "" "In the standard library code, you will see several common patterns for " "correctly using identity tests:" @@ -2825,21 +3691,22 @@ msgstr "" "Στον τυπικό κώδικα βιβλιοθήκης, θα δείτε πολλά κοινά μοτίβα για τη σωστή " "χρήση των δοκιμών ταυτότητας:" -#: faq/programming.rst:1881 +#: faq/programming.rst:1908 +#, fuzzy msgid "" -"1) As recommended by :pep:`8`, an identity test is the preferred way to " -"check for ``None``. This reads like plain English in code and avoids " -"confusion with other objects that may have boolean values that evaluate to " -"false." +"As recommended by :pep:`8`, an identity test is the preferred way to check " +"for ``None``. This reads like plain English in code and avoids confusion " +"with other objects that may have boolean values that evaluate to false." msgstr "" "1) Όπως προτείνεται από το :pep:`8`, ένας έλεγχος ταυτότητας είναι ο " "προτιμώμενος τρόπος για να ελέγξετε το ``None``. Αυτό είναι σαν απλά " "αγγλικά στον κώδικα και αποφεύγεται η σύγχυση με άλλα αντικείμενα που μπορεί " "να έχουν τιμές boolean που αξιολογούνται σε ψευδής." -#: faq/programming.rst:1885 +#: faq/programming.rst:1912 +#, fuzzy msgid "" -"2) Detecting optional arguments can be tricky when ``None`` is a valid input " +"Detecting optional arguments can be tricky when ``None`` is a valid input " "value. In those situations, you can create a singleton sentinel object " "guaranteed to be distinct from other objects. For example, here is how to " "implement a method that behaves like :meth:`dict.pop`:" @@ -2850,9 +3717,24 @@ msgstr "" "θα διαφέρει από άλλα αντικείμενα. Για παράδειγμα, δείτε πως μπορείτε να " "εφαρμόσετε μια μέθοδο που συμπεριφέρεται σαν :meth:`dict.pop`::" -#: faq/programming.rst:1901 +#: faq/programming.rst:1917 msgid "" -"3) Container implementations sometimes need to augment equality tests with " +"_sentinel = object()\n" +"\n" +"def pop(self, key, default=_sentinel):\n" +" if key in self:\n" +" value = self[key]\n" +" del self[key]\n" +" return value\n" +" if default is _sentinel:\n" +" raise KeyError(key)\n" +" return default" +msgstr "" + +#: faq/programming.rst:1930 +#, fuzzy +msgid "" +"Container implementations sometimes need to augment equality tests with " "identity tests. This prevents the code from being confused by objects such " "as ``float('NaN')`` that are not equal to themselves." msgstr "" @@ -2860,34 +3742,43 @@ msgstr "" "ισότητας με δοκιμές ταυτότητας. Αυτό αποτρέπει τη σύγχυση του κώδικα από " "αντικείμενα όπως το ``float('NaN')`` που δεν είναι ίσα με τα ίδια." -#: faq/programming.rst:1905 +#: faq/programming.rst:1934 +msgid "" +"For example, here is the implementation of :meth:`!" +"collections.abc.Sequence.__contains__`::" +msgstr "" +"Για παράδειγμα, εδώ είναι η υλοποίηση του :meth:`!" +"collections.abc.Sequence.__contains__`::" + +#: faq/programming.rst:1937 msgid "" -"For example, here is the implementation of :meth:`!collections.abc.Sequence." -"__contains__`::" +"def __contains__(self, value):\n" +" for v in self:\n" +" if v is value or v == value:\n" +" return True\n" +" return False" msgstr "" -"Για παράδειγμα, εδώ είναι η υλοποίηση του :meth:`!collections.abc.Sequence." -"__contains__`::" -#: faq/programming.rst:1916 +#: faq/programming.rst:1945 msgid "" "How can a subclass control what data is stored in an immutable instance?" msgstr "" "Πώς μπορεί μια υποκλάση να ελέγξει ποια δεδομένα αποθηκεύονται σε μια " "αμετάβλητη παρουσία;" -#: faq/programming.rst:1918 +#: faq/programming.rst:1947 msgid "" "When subclassing an immutable type, override the :meth:`~object.__new__` " "method instead of the :meth:`~object.__init__` method. The latter only runs " "*after* an instance is created, which is too late to alter data in an " "immutable instance." msgstr "" -"Κατά την υποκλάση ενός αμετάβλητου τύπου, παρακάμψετε τη μέθοδο :meth:" -"`~object.__new__` αντί για τη μέθοδο :meth:`~object.__init__`. Η τελευταία " -"εκτελείται μόνο αφού δημιουργηθεί μια παρουσία, η οποία είναι πολύ αργά για " -"να αλλάζει δεδομένα σε μια αμετάβλητη περίπτωση." +"Κατά την υποκλάση ενός αμετάβλητου τύπου, παρακάμψετε τη " +"μέθοδο :meth:`~object.__new__` αντί για τη μέθοδο :meth:`~object.__init__`. " +"Η τελευταία εκτελείται μόνο αφού δημιουργηθεί μια παρουσία, η οποία είναι " +"πολύ αργά για να αλλάζει δεδομένα σε μια αμετάβλητη περίπτωση." -#: faq/programming.rst:1923 +#: faq/programming.rst:1952 msgid "" "All of these immutable classes have a different signature than their parent " "class:" @@ -2895,26 +3786,63 @@ msgstr "" "Όλες αυτές οι αμετάβλητες κλάσεις έχουν διαφορετική υπογραφή από τη μητρική " "τους κλάση:" -#: faq/programming.rst:1949 +#: faq/programming.rst:1955 +msgid "" +"from datetime import date\n" +"\n" +"class FirstOfMonthDate(date):\n" +" \"Always choose the first day of the month\"\n" +" def __new__(cls, year, month, day):\n" +" return super().__new__(cls, year, month, 1)\n" +"\n" +"class NamedInt(int):\n" +" \"Allow text names for some numbers\"\n" +" xlat = {'zero': 0, 'one': 1, 'ten': 10}\n" +" def __new__(cls, value):\n" +" value = cls.xlat.get(value, value)\n" +" return super().__new__(cls, value)\n" +"\n" +"class TitleStr(str):\n" +" \"Convert str to name suitable for a URL path\"\n" +" def __new__(cls, s):\n" +" s = s.lower().replace(' ', '-')\n" +" s = ''.join([c for c in s if c.isalnum() or c == '-'])\n" +" return super().__new__(cls, s)" +msgstr "" + +#: faq/programming.rst:1978 msgid "The classes can be used like this:" msgstr "Οι κλάσεις μπορούν να χρησιμοποιηθούν έτσι:" -#: faq/programming.rst:1966 +#: faq/programming.rst:1980 +msgid "" +">>> FirstOfMonthDate(2012, 2, 14)\n" +"FirstOfMonthDate(2012, 2, 1)\n" +">>> NamedInt('ten')\n" +"10\n" +">>> NamedInt(20)\n" +"20\n" +">>> TitleStr('Blog: Why Python Rocks')\n" +"'blog-why-python-rocks'" +msgstr "" + +#: faq/programming.rst:1995 msgid "How do I cache method calls?" msgstr "Πώς μπορώ να αποθηκεύσω τις κλήσεις μεθόδου στην κρυφή μνήμη;" -#: faq/programming.rst:1968 +#: faq/programming.rst:1997 msgid "" -"The two principal tools for caching methods are :func:`functools." -"cached_property` and :func:`functools.lru_cache`. The former stores results " -"at the instance level and the latter at the class level." +"The two principal tools for caching methods " +"are :func:`functools.cached_property` and :func:`functools.lru_cache`. The " +"former stores results at the instance level and the latter at the class " +"level." msgstr "" "Τα δύο βασικά εργαλεία για τις μεθόδους αποθήκευσης στην προσωρινή μνήμη " "είναι τα :func:`functools.cached_property` και :func:`functools.lru_cache`. " "Το πρώτο αποθηκεύει τα αποτελέσματα σε επίπεδο παρουσίας και το δεύτερο σε " "επίπεδο κλάσης." -#: faq/programming.rst:1973 +#: faq/programming.rst:2002 msgid "" "The *cached_property* approach only works with methods that do not take any " "arguments. It does not create a reference to the instance. The cached " @@ -2924,7 +3852,7 @@ msgstr "" "ορίσματα. Δεν δημιουργεί αναφορά στο στιγμιότυπο. Το αποτέλεσμα της cached " "μεθόδους θα διατηρηθεί μόνο όσο το στιγμιότυπο είναι ζωντανό." -#: faq/programming.rst:1977 +#: faq/programming.rst:2006 msgid "" "The advantage is that when an instance is no longer used, the cached method " "result will be released right away. The disadvantage is that if instances " @@ -2937,17 +3865,17 @@ msgstr "" "αποτελέσματα της συσσωρευμένης μεθόδου. Μπορούν να αναπτυχθούν χωρίς " "περιορισμούς." -#: faq/programming.rst:1982 +#: faq/programming.rst:2011 msgid "" "The *lru_cache* approach works with methods that have :term:`hashable` " "arguments. It creates a reference to the instance unless special efforts " "are made to pass in weak references." msgstr "" -"Η προσέγγιση *lru_cache* λειτουργεί με μεθόδους που έχουν ορίσματα :term:" -"`hashable`. Δημιουργεί μια αναφορά στο στιγμιότυπο, εκτός εάν καταβληθούν " -"ειδικές προσπάθειες για να περάσει σε αδύναμες αναφορές." +"Η προσέγγιση *lru_cache* λειτουργεί με μεθόδους που έχουν " +"ορίσματα :term:`hashable`. Δημιουργεί μια αναφορά στο στιγμιότυπο, εκτός " +"εάν καταβληθούν ειδικές προσπάθειες για να περάσει σε αδύναμες αναφορές." -#: faq/programming.rst:1986 +#: faq/programming.rst:2015 msgid "" "The advantage of the least recently used algorithm is that the cache is " "bounded by the specified *maxsize*. The disadvantage is that instances are " @@ -2958,11 +3886,36 @@ msgstr "" "είναι ότι τα στιγμιότυπα διατηρούνται ζωντανά έως ότου παλαιώσουν από την " "κρυφή μνήμη ή μέχρι να διαγραφεί η κρυφή μνήμη." -#: faq/programming.rst:1991 +#: faq/programming.rst:2020 msgid "This example shows the various techniques::" msgstr "Αυτό το παράδειγμα δείχνει τις διάφορες τεχνικές::" -#: faq/programming.rst:2015 +#: faq/programming.rst:2022 +msgid "" +"class Weather:\n" +" \"Lookup weather information on a government website\"\n" +"\n" +" def __init__(self, station_id):\n" +" self._station_id = station_id\n" +" # The _station_id is private and immutable\n" +"\n" +" def current_temperature(self):\n" +" \"Latest hourly observation\"\n" +" # Do not cache this because old results\n" +" # can be out of date.\n" +"\n" +" @cached_property\n" +" def location(self):\n" +" \"Return the longitude/latitude coordinates of the station\"\n" +" # Result only depends on the station_id\n" +"\n" +" @lru_cache(maxsize=20)\n" +" def historic_rainfall(self, date, units='mm'):\n" +" \"Rainfall on a given date\"\n" +" # Depends on the station_id, date, and units." +msgstr "" + +#: faq/programming.rst:2044 msgid "" "The above example assumes that the *station_id* never changes. If the " "relevant instance attributes are mutable, the *cached_property* approach " @@ -2973,26 +3926,50 @@ msgstr "" "*cached_property* δεν μπορεί να λειτουργήσει επειδή δεν μπορεί να εντοπίσει " "αλλαγές στα χαρακτηριστικά." -#: faq/programming.rst:2020 +#: faq/programming.rst:2049 msgid "" "To make the *lru_cache* approach work when the *station_id* is mutable, the " -"class needs to define the :meth:`~object.__eq__` and :meth:`~object." -"__hash__` methods so that the cache can detect relevant attribute updates::" +"class needs to define the :meth:`~object.__eq__` " +"and :meth:`~object.__hash__` methods so that the cache can detect relevant " +"attribute updates::" msgstr "" "Για να λειτουργήσει η προσέγγιση *lru_cache* όταν το *station_id* είναι " -"μεταβλητό, η κλάση πρέπει να ορίσει τις μεθόδους :meth:`~object.__eq__` και :" -"meth:`~object.__hash__` ώστε η κρυφή μνήμη να μπορεί να εντοπίσει σχετικές " -"ενημερώσεις χαρακτηριστικών::" - -#: faq/programming.rst:2046 +"μεταβλητό, η κλάση πρέπει να ορίσει τις μεθόδους :meth:`~object.__eq__` " +"και :meth:`~object.__hash__` ώστε η κρυφή μνήμη να μπορεί να εντοπίσει " +"σχετικές ενημερώσεις χαρακτηριστικών::" + +#: faq/programming.rst:2053 +msgid "" +"class Weather:\n" +" \"Example with a mutable station identifier\"\n" +"\n" +" def __init__(self, station_id):\n" +" self.station_id = station_id\n" +"\n" +" def change_station(self, station_id):\n" +" self.station_id = station_id\n" +"\n" +" def __eq__(self, other):\n" +" return self.station_id == other.station_id\n" +"\n" +" def __hash__(self):\n" +" return hash(self.station_id)\n" +"\n" +" @lru_cache(maxsize=20)\n" +" def historic_rainfall(self, date, units='cm'):\n" +" 'Rainfall on a given date'\n" +" # Depends on the station_id, date, and units." +msgstr "" + +#: faq/programming.rst:2075 msgid "Modules" msgstr "Modules" -#: faq/programming.rst:2049 +#: faq/programming.rst:2078 msgid "How do I create a .pyc file?" msgstr "Πως δημιουργώ ένα .pyc αρχείο;" -#: faq/programming.rst:2051 +#: faq/programming.rst:2080 msgid "" "When a module is imported for the first time (or when the source file has " "changed since the current compiled file was created) a ``.pyc`` file " @@ -3011,7 +3988,7 @@ msgstr "" "που εξαρτάται από το συγκεκριμένο δυαδικό αρχείο ``python`` που το " "δημιούργησε. (Βλ. :pep:`3147` για λεπτομέρειες.)" -#: faq/programming.rst:2059 +#: faq/programming.rst:2088 msgid "" "One reason that a ``.pyc`` file may not be created is a permissions problem " "with the directory containing the source file, meaning that the " @@ -3026,7 +4003,7 @@ msgstr "" "ένας χρήστης αλλά εκτελείται ως άλλος, όπως εάν δοκιμάζετε με έναν " "διακομιστή ιστού." -#: faq/programming.rst:2064 +#: faq/programming.rst:2093 msgid "" "Unless the :envvar:`PYTHONDONTWRITEBYTECODE` environment variable is set, " "creation of a .pyc file is automatic if you're importing a module and Python " @@ -3034,18 +4011,19 @@ msgid "" "``__pycache__`` subdirectory and write the compiled module to that " "subdirectory." msgstr "" -"Εκτός και αν έχει οριστεί η μεταβλητή περιβάλλοντος :envvar:" -"`PYTHONDONTWRITEBYTECODE`, η δημιουργία ενός αρχείου .pyc είναι αυτόματη εάν " -"εισάγετε ένα module και η Python έχει τη δυνατότητα (δικαιώματα, ελεύθερος " -"χώρος, κ.λπ...) να δημιουργήσει ένα ``__pycache__`` υποκατάλογο και γράψτε " -"το μεταγλωττισμένο module σε αυτόν τον υποκατάλογο." +"Εκτός και αν έχει οριστεί η μεταβλητή " +"περιβάλλοντος :envvar:`PYTHONDONTWRITEBYTECODE`, η δημιουργία ενός " +"αρχείου .pyc είναι αυτόματη εάν εισάγετε ένα module και η Python έχει τη " +"δυνατότητα (δικαιώματα, ελεύθερος χώρος, κ.λπ...) να δημιουργήσει ένα " +"``__pycache__`` υποκατάλογο και γράψτε το μεταγλωττισμένο module σε αυτόν " +"τον υποκατάλογο." -#: faq/programming.rst:2069 +#: faq/programming.rst:2098 msgid "" -"Running Python on a top level script is not considered an import and no ``." -"pyc`` will be created. For example, if you have a top-level module ``foo." -"py`` that imports another module ``xyz.py``, when you run ``foo`` (by typing " -"``python foo.py`` as a shell command), a ``.pyc`` will be created for " +"Running Python on a top level script is not considered an import and no " +"``.pyc`` will be created. For example, if you have a top-level module " +"``foo.py`` that imports another module ``xyz.py``, when you run ``foo`` (by " +"typing ``python foo.py`` as a shell command), a ``.pyc`` will be created for " "``xyz`` because ``xyz`` is imported, but no ``.pyc`` file will be created " "for ``foo`` since ``foo.py`` isn't being imported." msgstr "" @@ -3057,18 +4035,18 @@ msgstr "" "έχει εισαχθεί, αλλά δεν θα δημιουργηθεί αρχείο ``.pyc`` για το ``foo`` καθώς " "το ``foo.py`` δεν εισάγεται." -#: faq/programming.rst:2076 +#: faq/programming.rst:2105 msgid "" -"If you need to create a ``.pyc`` file for ``foo`` -- that is, to create a ``." -"pyc`` file for a module that is not imported -- you can, using the :mod:" -"`py_compile` and :mod:`compileall` modules." +"If you need to create a ``.pyc`` file for ``foo`` -- that is, to create a " +"``.pyc`` file for a module that is not imported -- you can, using " +"the :mod:`py_compile` and :mod:`compileall` modules." msgstr "" "Εάν χρειάζεται να δημιουργήσετε ένα αρχείο ``.pyc`` για το ``foo`` -- " "δηλαδή, να δημιουργήσετε ένα αρχείο ``.pyc`` για ένα module που δεν έχει " -"εισαχθεί -- μπορείτε, χρησιμοποιώντας τα modules :mod:`py_compile` και :mod:" -"`compileall`." +"εισαχθεί -- μπορείτε, χρησιμοποιώντας τα modules :mod:`py_compile` " +"και :mod:`compileall`." -#: faq/programming.rst:2080 +#: faq/programming.rst:2109 msgid "" "The :mod:`py_compile` module can manually compile any module. One way is to " "use the ``compile()`` function in that module interactively::" @@ -3077,7 +4055,13 @@ msgstr "" "module. Ένας τρόπος είναι να χρησιμοποιήσετε τη συνάρτηση ``compile()`` σε " "αυτήν την ενότητα διαδραστικά::" -#: faq/programming.rst:2086 +#: faq/programming.rst:2112 +msgid "" +">>> import py_compile\n" +">>> py_compile.compile('foo.py') " +msgstr "" + +#: faq/programming.rst:2115 msgid "" "This will write the ``.pyc`` to a ``__pycache__`` subdirectory in the same " "location as ``foo.py`` (or you can override that with the optional parameter " @@ -3087,7 +4071,7 @@ msgstr "" "θέση με το ``foo.py`` (ή μπορείτε να το παρακάμψετε με την προαιρετική " "παράμετρο ``cfile``)." -#: faq/programming.rst:2090 +#: faq/programming.rst:2119 msgid "" "You can also automatically compile all files in a directory or directories " "using the :mod:`compileall` module. You can do it from the shell prompt by " @@ -3099,11 +4083,15 @@ msgstr "" "από το shell prompt εκτελώντας το ``compileall.py`` και παρέχοντας τη " "διαδρομή ενός καταλόγου που περιέχει αρχεία Python για μεταγλώττιση::" -#: faq/programming.rst:2099 +#: faq/programming.rst:2124 +msgid "python -m compileall ." +msgstr "" + +#: faq/programming.rst:2128 msgid "How do I find the current module name?" msgstr "Πως μπορώ να βρω το όνομα του τρέχοντος module;" -#: faq/programming.rst:2101 +#: faq/programming.rst:2130 msgid "" "A module can find out its own module name by looking at the predefined " "global variable ``__name__``. If this has the value ``'__main__'``, the " @@ -3118,51 +4106,73 @@ msgstr "" "γραμμής εντολών ή έναν αυτοέλεγχο και εκτελέστε αυτόν τον κώδικα μόνο αφού " "ελέγξετε το ``__name__``::" -#: faq/programming.rst:2116 +#: faq/programming.rst:2136 +msgid "" +"def main():\n" +" print('Running test...')\n" +" ...\n" +"\n" +"if __name__ == '__main__':\n" +" main()" +msgstr "" + +#: faq/programming.rst:2145 msgid "How can I have modules that mutually import each other?" msgstr "Πως μπορώ να έχω modules που εισάγουν αμοιβαία το ένα το άλλο;" -#: faq/programming.rst:2118 +#: faq/programming.rst:2147 msgid "Suppose you have the following modules:" msgstr "Υποθέστε ότι έχετε τα ακόλουθα modules::" -#: faq/programming.rst:2120 +#: faq/programming.rst:2149 msgid ":file:`foo.py`::" msgstr ":file:`foo.py`::" -#: faq/programming.rst:2125 +#: faq/programming.rst:2151 +msgid "" +"from bar import bar_var\n" +"foo_var = 1" +msgstr "" + +#: faq/programming.rst:2154 msgid ":file:`bar.py`::" msgstr ":file:`bar.py`::" -#: faq/programming.rst:2130 +#: faq/programming.rst:2156 +msgid "" +"from foo import foo_var\n" +"bar_var = 2" +msgstr "" + +#: faq/programming.rst:2159 msgid "The problem is that the interpreter will perform the following steps:" msgstr "Το πρόβλημα είναι ότι ο διερμηνέας θα εκτελέσει τα ακόλουθα βήματα:" -#: faq/programming.rst:2132 +#: faq/programming.rst:2161 msgid "main imports ``foo``" msgstr "main εισάγει ``foo``" -#: faq/programming.rst:2133 +#: faq/programming.rst:2162 msgid "Empty globals for ``foo`` are created" msgstr "Δημιουργούνται κενά καθολικά για το ``foo``" -#: faq/programming.rst:2134 +#: faq/programming.rst:2163 msgid "``foo`` is compiled and starts executing" msgstr "Το ``foo`` μεταγλωττίζεται και ξεκινά η εκτέλεση" -#: faq/programming.rst:2135 +#: faq/programming.rst:2164 msgid "``foo`` imports ``bar``" msgstr "``foo`` εισάγει ``bar``" -#: faq/programming.rst:2136 +#: faq/programming.rst:2165 msgid "Empty globals for ``bar`` are created" msgstr "Δημιουργούνται κενά καθολικά για ``bar``" -#: faq/programming.rst:2137 +#: faq/programming.rst:2166 msgid "``bar`` is compiled and starts executing" msgstr "Το ``bar`` μεταγλωττίζεται και αρχίζει να εκτελείται" -#: faq/programming.rst:2138 +#: faq/programming.rst:2167 msgid "" "``bar`` imports ``foo`` (which is a no-op since there already is a module " "named ``foo``)" @@ -3170,7 +4180,7 @@ msgstr "" "Το ``bar`` εισάγει το ``foo`` (το οποίο είναι απαγορευτικό, καθώς υπάρχει " "ήδη ένα module με το όνομα ``foo``)" -#: faq/programming.rst:2139 +#: faq/programming.rst:2168 msgid "" "The import mechanism tries to read ``foo_var`` from ``foo`` globals, to set " "``bar.foo_var = foo.foo_var``" @@ -3178,7 +4188,7 @@ msgstr "" "Ο μηχανισμός εισαγωγής προσπαθεί να διαβάσει το ``foo_var`` από τα παγκόσμια " "``foo``, για να ορίσει το ``bar.foo_var = foo.foo_var``" -#: faq/programming.rst:2141 +#: faq/programming.rst:2170 msgid "" "The last step fails, because Python isn't done with interpreting ``foo`` yet " "and the global symbol dictionary for ``foo`` is still empty." @@ -3187,7 +4197,7 @@ msgstr "" "την ερμηνεία του ``foo`` και το global λεξικό συμβόλων για το ``foo`` είναι " "ακόμα κενό." -#: faq/programming.rst:2144 +#: faq/programming.rst:2173 msgid "" "The same thing happens when you use ``import foo``, and then try to access " "``foo.foo_var`` in global code." @@ -3195,19 +4205,19 @@ msgstr "" "Το ίδιο συμβαίνει όταν χρησιμοποιείτε το ``import foo`` και, στη συνέχεια, " "προσπαθείτε να αποκτήσετε πρόσβαση στο ``foo.foo_var`` σε καθολικό κώδικα." -#: faq/programming.rst:2147 +#: faq/programming.rst:2176 msgid "There are (at least) three possible workarounds for this problem." msgstr "" "Υπάρχουν (τουλάχιστον) τρεις πιθανοί τρόποι αντιμετώπισης αυτού του " "προβλήματος." -#: faq/programming.rst:2149 +#: faq/programming.rst:2178 msgid "" -"Guido van Rossum recommends avoiding all uses of ``from import ..." -"``, and placing all code inside functions. Initializations of global " -"variables and class variables should use constants or built-in functions " -"only. This means everything from an imported module is referenced as " -"``.``." +"Guido van Rossum recommends avoiding all uses of ``from " +"import ...``, and placing all code inside functions. Initializations of " +"global variables and class variables should use constants or built-in " +"functions only. This means everything from an imported module is referenced " +"as ``.``." msgstr "" "Ο Guido van Rossum συνιστά την αποφυγή όλων των χρήσεων του ``from " "import ...`` και την τοποθέτηση όλου του κώδικα μέσα σε συναρτήσεις. Τα " @@ -3215,14 +4225,14 @@ msgstr "" "χρησιμοποιηθούν μόνο σταθερές ή ενσωματωμένες συναρτήσεις. Αυτό σημαίνει " "ότι ένα εισαγόμενο module αναφέρεται ως ``.``." -#: faq/programming.rst:2154 +#: faq/programming.rst:2183 msgid "" "Jim Roskind suggests performing steps in the following order in each module:" msgstr "" "Ο Jim Roskind προτείνει να εκτελέσετε τα βήματα με την ακόλουθη σειρά σε " "κάθε module:" -#: faq/programming.rst:2156 +#: faq/programming.rst:2185 msgid "" "exports (globals, functions, and classes that don't need imported base " "classes)" @@ -3230,18 +4240,18 @@ msgstr "" "εξαγωγές (globals, συναρτήσεις, και κλάσεις που δεν χρειάζονται εισαγόμενες " "βασικές κλάσεις)" -#: faq/programming.rst:2158 +#: faq/programming.rst:2187 msgid "``import`` statements" msgstr "δηλώσεις ``import``" -#: faq/programming.rst:2159 +#: faq/programming.rst:2188 msgid "" "active code (including globals that are initialized from imported values)." msgstr "" "ενεργός κώδικας (συμπεριλαμβανομένων των καθολικών που αρχικοποιούνται από " "εισαγόμενες τιμές)." -#: faq/programming.rst:2161 +#: faq/programming.rst:2190 msgid "" "Van Rossum doesn't like this approach much because the imports appear in a " "strange place, but it does work." @@ -3249,7 +4259,7 @@ msgstr "" "Ο Van Rossum δεν αρέσει πολύ αυτή η προσέγγιση επειδή οι εισαγωγές " "εμφανίζονται σε ένα περίεργο μέρος, αλλά λειτουργεί." -#: faq/programming.rst:2164 +#: faq/programming.rst:2193 msgid "" "Matthias Urlichs recommends restructuring your code so that the recursive " "import is not necessary in the first place." @@ -3257,23 +4267,27 @@ msgstr "" "Ο Matthias Urlichs συνιστά την αναδιάρθρωση του κώδικά σας έτσι ώστε η " "αναδρομική εισαγωγή να μην είναι απαραίτητη εξαρχής." -#: faq/programming.rst:2167 +#: faq/programming.rst:2196 msgid "These solutions are not mutually exclusive." msgstr "Αυτές οι λύσεις δεν αλληλοαποκλείονται." -#: faq/programming.rst:2171 +#: faq/programming.rst:2200 msgid "__import__('x.y.z') returns ; how do I get z?" msgstr "__import__('x.y.z') επιστρέφει ∙ πως μπορώ να πάρω το z?" -#: faq/programming.rst:2173 +#: faq/programming.rst:2202 msgid "" "Consider using the convenience function :func:`~importlib.import_module` " "from :mod:`importlib` instead::" msgstr "" -"Σκεφτείτε να χρησιμοποιήσετε τη συνάρτηση ευκολίας :func:`~importlib." -"import_module` από το :mod:`importlib` αντί::" +"Σκεφτείτε να χρησιμοποιήσετε τη συνάρτηση " +"ευκολίας :func:`~importlib.import_module` από το :mod:`importlib` αντί::" + +#: faq/programming.rst:2205 +msgid "z = importlib.import_module('x.y.z')" +msgstr "" -#: faq/programming.rst:2180 +#: faq/programming.rst:2209 msgid "" "When I edit an imported module and reimport it, the changes don't show up. " "Why does this happen?" @@ -3281,7 +4295,7 @@ msgstr "" "Όταν επεξεργάζομαι ένα module που έχει εισαχθεί και την επανεισάγω, οι " "αλλαγές δεν εμφανίζονται. Γιατί συμβαίνει αυτό;" -#: faq/programming.rst:2182 +#: faq/programming.rst:2211 msgid "" "For reasons of efficiency as well as consistency, Python only reads the " "module file on the first time a module is imported. If it didn't, in a " @@ -3296,7 +4310,14 @@ msgstr "" "αναλυθεί και θα αναλυθεί ξανά πολλές φορές. Για να αναγκάσετε τη εκ νέου " "ανάγνωση μιας αλλαγμένης ενότητας , κάντε το εξής::" -#: faq/programming.rst:2192 +#: faq/programming.rst:2217 +msgid "" +"import importlib\n" +"import modname\n" +"importlib.reload(modname)" +msgstr "" + +#: faq/programming.rst:2221 msgid "" "Warning: this technique is not 100% fool-proof. In particular, modules " "containing statements like ::" @@ -3304,7 +4325,11 @@ msgstr "" "Προειδοποίηση: αυτή η τεχνική δεν είναι 100% ασφαλής. Ειδικότερα, modules " "που περιέχουν δηλώσεις όπως ::" -#: faq/programming.rst:2197 +#: faq/programming.rst:2224 +msgid "from modname import some_objects" +msgstr "" + +#: faq/programming.rst:2226 msgid "" "will continue to work with the old version of the imported objects. If the " "module contains class definitions, existing class instances will *not* be " @@ -3317,7 +4342,18 @@ msgstr "" "ορισμό της νέας κλάσης. Αυτό μπορεί να οδηγήσει στην ακόλουθη παράδοξη " "συμπεριφορά::" -#: faq/programming.rst:2210 +#: faq/programming.rst:2231 +msgid "" +">>> import importlib\n" +">>> import cls\n" +">>> c = cls.C() # Create an instance of C\n" +">>> importlib.reload(cls)\n" +"\n" +">>> isinstance(c, cls.C) # isinstance is false?!?\n" +"False" +msgstr "" + +#: faq/programming.rst:2239 msgid "" "The nature of the problem is made clear if you print out the \"identity\" of " "the class objects::" @@ -3325,6 +4361,14 @@ msgstr "" "Η φύση του προβλήματος καθίσταται σαφής εάν εκτυπώσετε την \"ταυτότητα\" των " "αντικειμένων κλάσης::" +#: faq/programming.rst:2242 +msgid "" +">>> hex(id(c.__class__))\n" +"'0x7352a0'\n" +">>> hex(id(cls.C))\n" +"'0x4198d0'" +msgstr "" + #: faq/programming.rst:408 msgid "argument" msgstr "όρισμα" diff --git a/faq/windows.po b/faq/windows.po index 87572e59..f65d83c5 100644 --- a/faq/windows.po +++ b/faq/windows.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-05-31 22:08+0300\n" "Last-Translator: Panagiotis Skias \n" "Language-Team: PyGreece \n" @@ -58,6 +58,10 @@ msgstr "" "τέτοιο παράθυρο επειδή θα δείτε ένα \"command prompt\" των Windows, η οποία " "συνήθως μοιάζει με αυτό:" +#: faq/windows.rst:35 +msgid "C:\\>" +msgstr "" + #: faq/windows.rst:39 msgid "" "The letter may be different, and there might be other things after it, so " @@ -66,6 +70,10 @@ msgstr "" "Το γράμμα μπορεί να είναι διαφορετικό, και μπορεί να υπάρχουνε άλλα πράγματα " "μετά από αυτό, έτσι μπορείτε να δείτε εξίσου εύκολα κάτι σαν:" +#: faq/windows.rst:42 +msgid "D:\\YourName\\Projects\\Python>" +msgstr "" + #: faq/windows.rst:46 msgid "" "depending on how your computer has been set up and what else you have " @@ -101,10 +109,23 @@ msgstr "" "έχετε ανοίξει ένα παράθυρο εντολών, θα πρέπει να δοκιμάσετε να εισαγάγετε " "την εντολή ``py`` και να πατήσετε return:" +#: faq/windows.rst:60 +msgid "C:\\Users\\YourName> py" +msgstr "" + #: faq/windows.rst:64 msgid "You should then see something like:" msgstr "Στη συνέχεια, θα πρέπει να δείτε κάτι σαν:" +#: faq/windows.rst:66 +msgid "" +"Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit " +"(Intel)] on win32\n" +"Type \"help\", \"copyright\", \"credits\" or \"license\" for more " +"information.\n" +">>>" +msgstr "" + #: faq/windows.rst:72 msgid "" "You have started the interpreter in \"interactive mode\". That means you can " @@ -118,13 +139,21 @@ msgstr "" "ισχυρότερα χαρακτηριστικά της Python. Ελέγξτε το εισάγοντας μερικές " "εκφράσεις της επιλογή σας και βλέποντας τα αποτελέσματα:" +#: faq/windows.rst:77 +msgid "" +">>> print(\"Hello\")\n" +"Hello\n" +">>> \"Hello\" * 3\n" +"'HelloHelloHello'" +msgstr "" + #: faq/windows.rst:84 msgid "" "Many people use the interactive mode as a convenient yet highly programmable " -"calculator. When you want to end your interactive Python session, call the :" -"func:`exit` function or hold the :kbd:`Ctrl` key down while you enter a :kbd:" -"`Z`, then hit the \":kbd:`Enter`\" key to get back to your Windows command " -"prompt." +"calculator. When you want to end your interactive Python session, call " +"the :func:`exit` function or hold the :kbd:`Ctrl` key down while you enter " +"a :kbd:`Z`, then hit the \":kbd:`Enter`\" key to get back to your Windows " +"command prompt." msgstr "" "Πολλοί άνθρωποι χρησιμοποιούν τη διαδραστική λειτουργία ως μια βολική αλλά " "εξαιρετικά προγραμματιζόμενη αριθμομηχανή. Όταν θέλετε να τερματίσετε τη " @@ -135,16 +164,16 @@ msgstr "" #: faq/windows.rst:90 msgid "" -"You may also find that you have a Start-menu entry such as :menuselection:" -"`Start --> Programs --> Python 3.x --> Python (command line)` that results " -"in you seeing the ``>>>`` prompt in a new window. If so, the window will " -"disappear after you call the :func:`exit` function or enter the :kbd:`Ctrl-" -"Z` character; Windows is running a single \"python\" command in the window, " -"and closes it when you terminate the interpreter." +"You may also find that you have a Start-menu entry such " +"as :menuselection:`Start --> Programs --> Python 3.x --> Python (command " +"line)` that results in you seeing the ``>>>`` prompt in a new window. If " +"so, the window will disappear after you call the :func:`exit` function or " +"enter the :kbd:`Ctrl-Z` character; Windows is running a single \"python\" " +"command in the window, and closes it when you terminate the interpreter." msgstr "" -"Μπορεί επίσης να διαπιστώσετε ότι έχετε μια καταχώρηση στο Start-menu όπως :" -"menuselection:`Start --> Programs --> Python 3.x --> Python (command line)` " -"που έχει ως αποτέλεσμα να βλέπετε το ``>>>`` σε ένα νέο παράθυρο, το " +"Μπορεί επίσης να διαπιστώσετε ότι έχετε μια καταχώρηση στο Start-menu " +"όπως :menuselection:`Start --> Programs --> Python 3.x --> Python (command " +"line)` που έχει ως αποτέλεσμα να βλέπετε το ``>>>`` σε ένα νέο παράθυρο, το " "παράθυρο θα εξαφανιστεί αφού καλέσετε τη συνάρτηση :func:`exit` ή εισαγάγετε " "τον χαρακτήρα :kbd:`Ctrl-Z`' τα Windows εκτελούν μία μόνο εντολή \"python\" " "στο παράθυρο και την κλείνουν όταν τερματίζετε τον interpreter." @@ -160,9 +189,13 @@ msgstr "" "Τώρα που γνωρίζουμε ότι η εντολή ``py`` αναγνωρίζεται, μπορείτε να της " "δώσετε το σενάριο Python σας. Θα πρέπει να δώσετε είτε μια απόλυτη είτε μια " "σχετική διαδρομή προς στο σενάριο Python. Ας υποθέσουμε ότι το σενάριο " -"Python σας βρίσκεται στην επιφάνεια εργασίας σας και ονομάζεται ``hello." -"py``, και η γραμμή εντολών σας ανοίγει όμορφα στον αρχικό σας κατάλογο, ώστε " -"να βλέπετε κάτι παρόμοιο με::" +"Python σας βρίσκεται στην επιφάνεια εργασίας σας και ονομάζεται " +"``hello.py``, και η γραμμή εντολών σας ανοίγει όμορφα στον αρχικό σας " +"κατάλογο, ώστε να βλέπετε κάτι παρόμοιο με::" + +#: faq/windows.rst:104 +msgid "C:\\Users\\YourName>" +msgstr "" #: faq/windows.rst:106 msgid "" @@ -173,6 +206,12 @@ msgstr "" "Python πληκτρολογώντας ``py`` ακολουθούμενη από τη διαδρομή του σεναρίου " "σας::" +#: faq/windows.rst:110 +msgid "" +"C:\\Users\\YourName> py Desktop\\hello.py\n" +"hello" +msgstr "" + #: faq/windows.rst:114 msgid "How do I make Python scripts executable?" msgstr "Πως κάνω τα Python scripts εκτελέσιμα;" @@ -190,10 +229,10 @@ msgstr "" "Στα Windows, το τυπικό πρόγραμμα εγκατάστασης Python ήδη συσχετίζει την " "επέκταση .py με έναν τύπο αρχείου μια ανοιχτή εντολή που εκτελεί τον " "διερμηνέα (``D:\\Program Files\\Python\\python.exe \"%1\" %*``). Αυτό είναι " -"αρκετό για να κάνετε τα scripts εκτελέσιμα από τη γραμμή εντολών ως 'foo." -"py'. Εάν προτιμάτε να μπορείτε να εκτελέσετε το σενάριο πληκτρολογώντας " -"απλά 'foo' χωρίς επέκταση, πρέπει να προσθέσετε .py στη μεταβλητή " -"περιβάλλοντος PATHTEXT." +"αρκετό για να κάνετε τα scripts εκτελέσιμα από τη γραμμή εντολών ως " +"'foo.py'. Εάν προτιμάτε να μπορείτε να εκτελέσετε το σενάριο " +"πληκτρολογώντας απλά 'foo' χωρίς επέκταση, πρέπει να προσθέσετε .py στη " +"μεταβλητή περιβάλλοντος PATHTEXT." #: faq/windows.rst:124 msgid "Why does Python sometimes take so long to start?" @@ -299,9 +338,10 @@ msgstr "" msgid "" "Do **not** build Python into your .exe file directly. On Windows, Python " "must be a DLL to handle importing modules that are themselves DLL's. (This " -"is the first key undocumented fact.) Instead, link to :file:`python{NN}." -"dll`; it is typically installed in ``C:\\Windows\\System``. *NN* is the " -"Python version, a number such as \"33\" for Python 3.3." +"is the first key undocumented fact.) Instead, link " +"to :file:`python{NN}.dll`; it is typically installed in ``C:" +"\\Windows\\System``. *NN* is the Python version, a number such as \"33\" " +"for Python 3.3." msgstr "" "Να **μην** δημιουργείτε απευθείας την Python στο αρχείο σας .exe. Στα " "Windows, η Python πρέπει να είναι DLL για να χειρίζεται την εισαγωγή " @@ -320,10 +360,10 @@ msgid "" msgstr "" "Μπορείτε να συνδεθείτε με την Python με δύο διαφορετικούς τρόπους. Σύνδεση " "χρόνου φόρτωσης σημαίνει σύνδεση ενάντια στο :file:`python{NN}.lib`, ενώ η " -"σύνδεση χρόνου εκτέλεσης σημαίνει σύνδεση ενάντια στο :file:`python{NN}." -"dll`. (Γενική σημείωση: :file:`python{NN}.lib` είναι το λεγόμενο \"import " -"lib\" που αντιστοιχεί στο :file:`python{NN}.dll`. Απλώς ορίζει σύμβολα για " -"το σύνδεσμο.)" +"σύνδεση χρόνου εκτέλεσης σημαίνει σύνδεση ενάντια " +"στο :file:`python{NN}.dll`. (Γενική σημείωση: :file:`python{NN}.lib` είναι " +"το λεγόμενο \"import lib\" που αντιστοιχεί στο :file:`python{NN}.dll`. " +"Απλώς ορίζει σύμβολα για το σύνδεσμο.)" #: faq/windows.rst:182 msgid "" @@ -336,14 +376,14 @@ msgid "" "API." msgstr "" "Η σύνδεση χρόνου εκτέλεσης απλοποιεί σημαντικά τις επιλογές συνδέσμων. Όλα " -"συμβαίνουν κατά την εκτέλεση. Ο κώδικα σας πρέπει να φορτώσει :file:" -"`python{NN}.dll` χρησιμοποιώντας την ρουτίνα ``LoadLibraryEx()`` των " -"Windows. Ο κώδικας πρέπει επίσης να χρησιμοποιεί ρουτίνες πρόσβασης και " -"δεδομένα στο :file:`python{NN}.dll` (δηλαδή, το C API της Python) " -"χρησιμοποιώντας δείκτες που λαμβάνονται από τη ρουτίνα των Windows " -"``GetProcAddress()``. Οι μακροεντολές μπορούν να κάνουν χρησιμοποιώντας " -"αυτούς τους δείκτες διαφανείς σε οποιονδήποτε κώδικα C που καλεί ρουτίνες " -"στο C API της Python." +"συμβαίνουν κατά την εκτέλεση. Ο κώδικα σας πρέπει να " +"φορτώσει :file:`python{NN}.dll` χρησιμοποιώντας την ρουτίνα " +"``LoadLibraryEx()`` των Windows. Ο κώδικας πρέπει επίσης να χρησιμοποιεί " +"ρουτίνες πρόσβασης και δεδομένα στο :file:`python{NN}.dll` (δηλαδή, το C API " +"της Python) χρησιμοποιώντας δείκτες που λαμβάνονται από τη ρουτίνα των " +"Windows ``GetProcAddress()``. Οι μακροεντολές μπορούν να κάνουν " +"χρησιμοποιώντας αυτούς τους δείκτες διαφανείς σε οποιονδήποτε κώδικα C που " +"καλεί ρουτίνες στο C API της Python." #: faq/windows.rst:191 msgid "" @@ -394,6 +434,15 @@ msgstr "" "Με λίγα λόγια, μπορείτε να χρησιμοποιήσετε τον ακόλουθο κώδικα για να " "αρχικοποιήσετε τον Python interpreter με το module επέκτασης." +#: faq/windows.rst:210 +msgid "" +"#include \n" +"...\n" +"Py_Initialize(); // Initialize Python.\n" +"initmyAppc(); // Initialize (import) the helper class.\n" +"PyRun_SimpleString(\"import myApp\"); // Import the shadow class." +msgstr "" + #: faq/windows.rst:218 msgid "" "There are two problems with Python's C API which will become apparent if you " @@ -423,6 +472,13 @@ msgstr "" "Πρόβλημα 2: Το SWIG δημιουργεί τον ακόλουθο κώδικα όταν δημιουργεί wrappers " "σε void συναρτήσεις:" +#: faq/windows.rst:229 +msgid "" +"Py_INCREF(Py_None);\n" +"_resultobj = Py_None;\n" +"return _resultobj;" +msgstr "" + #: faq/windows.rst:235 msgid "" "Alas, Py_None is a macro that expands to a reference to a complex data " @@ -434,6 +490,10 @@ msgstr "" "pythonNN.dll. Και πάλι, αυτός ο κώδικας θα αποτύχει σε ένα mult-compiler " "περιβάλλον. Αντικαταστήστε αυτόν τον κώδικα με:" +#: faq/windows.rst:239 +msgid "return Py_BuildValue(\"\");" +msgstr "" + #: faq/windows.rst:243 msgid "" "It may be possible to use SWIG's ``%typemap`` command to make the change " @@ -484,10 +544,10 @@ msgstr "" #: faq/windows.rst:262 msgid "" "Under any editor, mixing tabs and spaces is a bad idea. MSVC is no " -"different in this respect, and is easily configured to use spaces: Take :" -"menuselection:`Tools --> Options --> Tabs`, and for file type \"Default\" " -"set \"Tab size\" and \"Indent size\" to 4, and select the \"Insert spaces\" " -"radio button." +"different in this respect, and is easily configured to use spaces: " +"Take :menuselection:`Tools --> Options --> Tabs`, and for file type " +"\"Default\" set \"Tab size\" and \"Indent size\" to 4, and select the " +"\"Insert spaces\" radio button." msgstr "" "Σε οποιονδήποτε editor, η μίξη tabs και spaces είναι κακή ιδέα. Το MSVC δεν " "διαφέρει από αυτή την άποψη και ρυθμίζεται εύκολα για να χρησιμοποιεί κενά: " @@ -498,8 +558,8 @@ msgstr "" #: faq/windows.rst:267 msgid "" "Python raises :exc:`IndentationError` or :exc:`TabError` if mixed tabs and " -"spaces are causing problems in leading whitespace. You may also run the :mod:" -"`tabnanny` module to check a directory tree in batch mode." +"spaces are causing problems in leading whitespace. You may also run " +"the :mod:`tabnanny` module to check a directory tree in batch mode." msgstr "" "Η Python εγείρει το :exc:`IndentationError` ή :exc:`TabError` εάν τα μικτά " "tabs και spaces προκαλούν προβλήματα στο leading whitespace. Μπορείτε επίσης " @@ -524,8 +584,8 @@ msgstr "" #: faq/windows.rst:281 msgid "How do I solve the missing api-ms-win-crt-runtime-l1-1-0.dll error?" msgstr "" -"Πως μπορώ να διορθώσω το σφάλμα που λείπει το api-ms-win-crt-runtime-l1-1-0." -"dll;" +"Πως μπορώ να διορθώσω το σφάλμα που λείπει το api-ms-win-crt-runtime-" +"l1-1-0.dll;" #: faq/windows.rst:283 msgid "" @@ -539,6 +599,6 @@ msgstr "" "χρησιμοποιείτε Windows 8.1 ή νεότερη έκδοση χωρίς να έχουν εγκατασταθεί όλες " "οι ενημερώσεις. Πρώτα βεβαιωθείτε ότι το λειτουργικό σας σύστημα " "υποστηρίζεται και είναι ενημερωμένο και εάν αυτό δεν επιλύσει το πρόβλημα, " -"επισκεφθείτε τη `σελίδα υποστήριξης της Microsoft `_ για καθοδήγηση σχετικά με τη μη αυτόματη " -"εγκατάσταση της ενημέρωσης C Runtime." +"επισκεφθείτε τη `σελίδα υποστήριξης της Microsoft `_ για καθοδήγηση σχετικά με τη μη " +"αυτόματη εγκατάσταση της ενημέρωσης C Runtime." diff --git a/glossary.po b/glossary.po index ce28b2b4..e075de5d 100644 --- a/glossary.po +++ b/glossary.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-05-28 22:27+0300\n" "Last-Translator: Panagiotis Skias \n" "Language-Team: PyGreece \n" @@ -91,24 +91,26 @@ msgid "" "define interfaces when other techniques like :func:`hasattr` would be clumsy " "or subtly wrong (for example with :ref:`magic methods `). " "ABCs introduce virtual subclasses, which are classes that don't inherit from " -"a class but are still recognized by :func:`isinstance` and :func:" -"`issubclass`; see the :mod:`abc` module documentation. Python comes with " -"many built-in ABCs for data structures (in the :mod:`collections.abc` " -"module), numbers (in the :mod:`numbers` module), streams (in the :mod:`io` " -"module), import finders and loaders (in the :mod:`importlib.abc` module). " -"You can create your own ABCs with the :mod:`abc` module." +"a class but are still recognized by :func:`isinstance` " +"and :func:`issubclass`; see the :mod:`abc` module documentation. Python " +"comes with many built-in ABCs for data structures (in " +"the :mod:`collections.abc` module), numbers (in the :mod:`numbers` module), " +"streams (in the :mod:`io` module), import finders and loaders (in " +"the :mod:`importlib.abc` module). You can create your own ABCs with " +"the :mod:`abc` module." msgstr "" "Οι αφηρημένες βασικές κλάσεις συμπληρώνουν το :term:`duck-typing` παρέχοντας " "έναν τρόπο ορισμού interfaces όταν άλλες τεχνικές όπως η :func:`hasattr` θα " "ήταν αδέξιες ή ανεπαίσθητα λανθασμένες (για παράδειγμα με :ref:`magic " "methods `). Τα ABC (abstract base class) εισάγουν εικονικές " "υποκλάσεις, οι οποίες είναι κλάσεις που δεν κληρονομούνται από μια κλάση, " -"αλλά εξακολουθούν να αναγνωρίζονται από το :func:`isinstance` και από το :" -"func:`issubclass`' βλ. την τεκμηρίωση του module :mod:`abc`. Η Python " -"διαθέτει πολλά ενσωματωμένα ABC για δομές δεδομένων (στο module :mod:" -"`collections.abc`), αριθμούς (στο module :mod:`numbers`), ροές (στο module " -"μονάδα :mod:`io`), εισαγωγή finders και loaders (στο module :mod:`importlib." -"abc`). Μπορείτε να δημιουργήσετε τα δικά σας ABC με το module :mod:`abc`." +"αλλά εξακολουθούν να αναγνωρίζονται από το :func:`isinstance` και από " +"το :func:`issubclass`' βλ. την τεκμηρίωση του module :mod:`abc`. Η Python " +"διαθέτει πολλά ενσωματωμένα ABC για δομές δεδομένων (στο " +"module :mod:`collections.abc`), αριθμούς (στο module :mod:`numbers`), ροές " +"(στο module μονάδα :mod:`io`), εισαγωγή finders και loaders (στο " +"module :mod:`importlib.abc`). Μπορείτε να δημιουργήσετε τα δικά σας ABC με " +"το module :mod:`abc`." #: glossary.rst:46 msgid "annotation" @@ -139,12 +141,13 @@ msgstr "" #: glossary.rst:58 msgid "" "See :term:`variable annotation`, :term:`function annotation`, :pep:`484` " -"and :pep:`526`, which describe this functionality. Also see :ref:" -"`annotations-howto` for best practices on working with annotations." +"and :pep:`526`, which describe this functionality. Also " +"see :ref:`annotations-howto` for best practices on working with annotations." msgstr "" "Βλ. :term:`variable annotation`, :term:`function annotation`, :pep:`484` " -"και :pep:`526`, τα οποία περιγράφουν την λειτουργικότητα. Επίσης βλ. :ref:" -"`annotations-howto` για τις βέλτιστες πρακτικές δουλεύοντας με annotations." +"και :pep:`526`, τα οποία περιγράφουν την λειτουργικότητα. Επίσης " +"βλ. :ref:`annotations-howto` για τις βέλτιστες πρακτικές δουλεύοντας με " +"annotations." #: glossary.rst:62 msgid "argument" @@ -170,6 +173,12 @@ msgstr "" "από ``**``. Για παράδειγμα, το ``3`` και το ``5`` αποτελούν ορίσματα λέξεων-" "κλειδιών στις ακόλουθες κλήσεις προς :func:`complex`::" +#: glossary.rst:72 +msgid "" +"complex(real=3, imag=5)\n" +"complex(**{'real': 3, 'imag': 5})" +msgstr "" + #: glossary.rst:75 msgid "" ":dfn:`positional argument`: an argument that is not a keyword argument. " @@ -183,6 +192,12 @@ msgstr "" "παράδειγμα, το ``3`` και το ``5`` αποτελούν ορίσματα θέσης στις παρακάτω " "κλήσεις::" +#: glossary.rst:81 +msgid "" +"complex(3, 5)\n" +"complex(*(3, 5))" +msgstr "" + #: glossary.rst:84 msgid "" "Arguments are assigned to the named local variables in a function body. See " @@ -213,12 +228,13 @@ msgstr "ασύγχρονος διαχειριστής context" #: glossary.rst:94 msgid "" "An object which controls the environment seen in an :keyword:`async with` " -"statement by defining :meth:`~object.__aenter__` and :meth:`~object." -"__aexit__` methods. Introduced by :pep:`492`." +"statement by defining :meth:`~object.__aenter__` " +"and :meth:`~object.__aexit__` methods. Introduced by :pep:`492`." msgstr "" -"Ένα αντικείμενο που ελέγχει το ορατό περιβάλλον σε μια δήλωση :keyword:" -"`async with` ορίζοντας τις μεθόδους :meth:`~object.__aenter__` και :meth:" -"`~object.__aexit__`. Που εισήχθη από :pep:`492`." +"Ένα αντικείμενο που ελέγχει το ορατό περιβάλλον σε μια " +"δήλωση :keyword:`async with` ορίζοντας τις " +"μεθόδους :meth:`~object.__aenter__` και :meth:`~object.__aexit__`. Που " +"εισήχθη από :pep:`492`." #: glossary.rst:97 msgid "asynchronous generator" @@ -253,8 +269,9 @@ msgid "" "An asynchronous generator function may contain :keyword:`await` expressions " "as well as :keyword:`async for`, and :keyword:`async with` statements." msgstr "" -"Μια συνάρτηση ασύγχρονου generator μπορεί να περιέχει εκφράσεις :keyword:" -"`await` , καθώς και δηλώσεις :keyword:`async for`, και :keyword:`async with`." +"Μια συνάρτηση ασύγχρονου generator μπορεί να περιέχει " +"εκφράσεις :keyword:`await` , καθώς και δηλώσεις :keyword:`async for`, " +"και :keyword:`async with`." #: glossary.rst:111 msgid "asynchronous generator iterator" @@ -268,10 +285,10 @@ msgstr "" #: glossary.rst:115 msgid "" -"This is an :term:`asynchronous iterator` which when called using the :meth:" -"`~object.__anext__` method returns an awaitable object which will execute " -"the body of the asynchronous generator function until the next :keyword:" -"`yield` expression." +"This is an :term:`asynchronous iterator` which when called using " +"the :meth:`~object.__anext__` method returns an awaitable object which will " +"execute the body of the asynchronous generator function until the " +"next :keyword:`yield` expression." msgstr "" "Αυτός είναι ένας :term:`asynchronous iterator` που όταν καλείται " "χρησιμοποιώντας την μέθοδο :meth:`~object.__anext__` επιστρέφει ένα " @@ -279,12 +296,13 @@ msgstr "" "ασύγχρονου generator μέχρι την επόμενη :keyword:`yield` έκφραση." #: glossary.rst:120 +#, fuzzy msgid "" "Each :keyword:`yield` temporarily suspends processing, remembering the " -"location execution state (including local variables and pending try-" -"statements). When the *asynchronous generator iterator* effectively resumes " -"with another awaitable returned by :meth:`~object.__anext__`, it picks up " -"where it left off. See :pep:`492` and :pep:`525`." +"execution state (including local variables and pending try-statements). " +"When the *asynchronous generator iterator* effectively resumes with another " +"awaitable returned by :meth:`~object.__anext__`, it picks up where it left " +"off. See :pep:`492` and :pep:`525`." msgstr "" "Κάθε :keyword:`yield` αναστέλλει προσωρινά την επεξεργασία, θυμάται την " "τοποθεσία της κατάστασης εκτέλεσης (συμπεριλαμβανομένων των τοπικών " @@ -304,8 +322,8 @@ msgid "" "method. Introduced by :pep:`492`." msgstr "" "Ένα αντικείμενο, που μπορεί να χρησιμοποιηθεί σε μια δήλωση :keyword:`async " -"for`. Πρέπει να επιστρέφει ένα :term:`asynchronous iterator` από την μέθοδο :" -"meth:`~object.__aiter__`. Που εισήχθη από :pep:`492`." +"for`. Πρέπει να επιστρέφει ένα :term:`asynchronous iterator` από την " +"μέθοδο :meth:`~object.__aiter__`. Που εισήχθη από :pep:`492`." #: glossary.rst:130 msgid "asynchronous iterator" @@ -313,18 +331,19 @@ msgstr "ασύγχρονος iterator" #: glossary.rst:132 msgid "" -"An object that implements the :meth:`~object.__aiter__` and :meth:`~object." -"__anext__` methods. :meth:`~object.__anext__` must return an :term:" -"`awaitable` object. :keyword:`async for` resolves the awaitables returned by " -"an asynchronous iterator's :meth:`~object.__anext__` method until it raises " -"a :exc:`StopAsyncIteration` exception. Introduced by :pep:`492`." +"An object that implements the :meth:`~object.__aiter__` " +"and :meth:`~object.__anext__` methods. :meth:`~object.__anext__` must " +"return an :term:`awaitable` object. :keyword:`async for` resolves the " +"awaitables returned by an asynchronous iterator's :meth:`~object.__anext__` " +"method until it raises a :exc:`StopAsyncIteration` exception. Introduced " +"by :pep:`492`." msgstr "" -"Ένα αντικείμενο που υλοποιεί τις μεθόδους :meth:`~object.__aiter__` και :" -"meth:`~object.__anext__`. Η μέθοδος :meth:`~object.__anext__` πρέπει να " +"Ένα αντικείμενο που υλοποιεί τις μεθόδους :meth:`~object.__aiter__` " +"και :meth:`~object.__anext__`. Η μέθοδος :meth:`~object.__anext__` πρέπει να " "επιστρέφει ένα :term:`awaitable` αντικείμενο. Το :keyword:`async for` " -"επιλύει τα αναμενόμενα που επιστρέφονται από τη μέθοδο :meth:`~object." -"__anext__` ενός ασύγχρονου iterator έως ότου εγείρει μια εξαίρεση :exc:" -"`StopAsyncIteration`. Εισήχθη από :pep:`492`." +"επιλύει τα αναμενόμενα που επιστρέφονται από τη " +"μέθοδο :meth:`~object.__anext__` ενός ασύγχρονου iterator έως ότου εγείρει " +"μια εξαίρεση :exc:`StopAsyncIteration`. Εισήχθη από :pep:`492`." #: glossary.rst:137 msgid "attribute" @@ -343,10 +362,10 @@ msgstr "" #: glossary.rst:144 msgid "" "It is possible to give an object an attribute whose name is not an " -"identifier as defined by :ref:`identifiers`, for example using :func:" -"`setattr`, if the object allows it. Such an attribute will not be accessible " -"using a dotted expression, and would instead need to be retrieved with :func:" -"`getattr`." +"identifier as defined by :ref:`identifiers`, for example " +"using :func:`setattr`, if the object allows it. Such an attribute will not " +"be accessible using a dotted expression, and would instead need to be " +"retrieved with :func:`getattr`." msgstr "" "Είναι δυνατό να δώσουμε σε ένα αντικείμενο ένα χαρακτηριστικό που το όνομα " "του δεν είναι αναγνωριστικό όπως ορίζεται από :ref:`identifiers`, για " @@ -361,13 +380,13 @@ msgstr "awaitable" #: glossary.rst:151 msgid "" -"An object that can be used in an :keyword:`await` expression. Can be a :" -"term:`coroutine` or an object with an :meth:`~object.__await__` method. See " -"also :pep:`492`." +"An object that can be used in an :keyword:`await` expression. Can be " +"a :term:`coroutine` or an object with an :meth:`~object.__await__` method. " +"See also :pep:`492`." msgstr "" "Ένα αντικείμενο που μπορεί να χρησιμοποιηθεί στην έκφραση :keyword:`await`. " -"Μπορεί να είναι :term:`coroutine` ή ένα αντικείμενο με μια :meth:`~object." -"__await__` μέθοδο. Βλ. επίσης :pep:`492`." +"Μπορεί να είναι :term:`coroutine` ή ένα αντικείμενο με " +"μια :meth:`~object.__await__` μέθοδο. Βλ. επίσης :pep:`492`." #: glossary.rst:154 msgid "BDFL" @@ -375,8 +394,8 @@ msgstr "BDFL" #: glossary.rst:156 msgid "" -"Benevolent Dictator For Life, a.k.a. `Guido van Rossum `_, Python's creator." +"Benevolent Dictator For Life, a.k.a. `Guido van Rossum `_, Python's creator." msgstr "" "Ακρωνύμιο του *Benevolent Dictator For Life*, καλοκάγαθος δικτάτορας της " "ζωής, δηλαδή `Guido van Rossum `_, ο " @@ -390,20 +409,21 @@ msgstr "δυαδικό αρχείο" msgid "" "A :term:`file object` able to read and write :term:`bytes-like objects " "`. Examples of binary files are files opened in binary " -"mode (``'rb'``, ``'wb'`` or ``'rb+'``), :data:`sys.stdin.buffer `, :data:`sys.stdout.buffer `, and instances of :class:`io." -"BytesIO` and :class:`gzip.GzipFile`." +"mode (``'rb'``, ``'wb'`` or ``'rb+'``), :data:`sys.stdin.buffer " +"`, :data:`sys.stdout.buffer `, and instances " +"of :class:`io.BytesIO` and :class:`gzip.GzipFile`." msgstr "" "Ένα :term:`file object` ικανό να διαβάζει και να γράφει :term:`δυαδικού " "τύπου αντικείμενα `. Παραδείγματα δυαδικών αρχείων είναι " -"αρχεία που ανοίγουν σε δυαδική λειτουργία (``'rb'``, ``'wb'`` ή ``'rb+'``), :" -"data:`sys.stdin.buffer `, :data:`sys.stdout.buffer `, " -"και στιγμιοτύπων των :class:`io.BytesIO` και :class:`gzip.GzipFile`." +"αρχεία που ανοίγουν σε δυαδική λειτουργία (``'rb'``, ``'wb'`` ή " +"``'rb+'``), :data:`sys.stdin.buffer `, :data:`sys.stdout.buffer " +"`, και στιγμιοτύπων των :class:`io.BytesIO` " +"και :class:`gzip.GzipFile`." #: glossary.rst:167 msgid "" -"See also :term:`text file` for a file object able to read and write :class:" -"`str` objects." +"See also :term:`text file` for a file object able to read and " +"write :class:`str` objects." msgstr "" "Βλ. επίσης :term:`text file` για ένα αντικείμενο τύπου αρχείο ικανό να " "διαβάσει και να γράψει :class:`str` αντικείμενα." @@ -430,16 +450,16 @@ msgstr "" msgid "" "Calling :c:func:`Py_INCREF` on the :term:`borrowed reference` is recommended " "to convert it to a :term:`strong reference` in-place, except when the object " -"cannot be destroyed before the last usage of the borrowed reference. The :c:" -"func:`Py_NewRef` function can be used to create a new :term:`strong " +"cannot be destroyed before the last usage of the borrowed reference. " +"The :c:func:`Py_NewRef` function can be used to create a new :term:`strong " "reference`." msgstr "" "Συνίσταται η κλήση του :c:func:`Py_INCREF` στο :term:`δανεική αναφορά " "` με σκοπό να μετατραπεί σε ένα :term:`ισχυρή αναφορά " "` επιτόπου, εκτός όταν το αντικείμενο δεν μπορεί να " -"καταστραφεί πριν από την τελευταία χρήση της δανεικής αναφοράς. Η συνάρτηση :" -"c:func:`Py_NewRef` μπορεί να χρησιμοποιηθεί ώστε να δημιουργηθεί ένα :term:" -"`ισχυρή αναφορά `." +"καταστραφεί πριν από την τελευταία χρήση της δανεικής αναφοράς. Η " +"συνάρτηση :c:func:`Py_NewRef` μπορεί να χρησιμοποιηθεί ώστε να δημιουργηθεί " +"ένα :term:`ισχυρή αναφορά `." #: glossary.rst:182 msgid "bytes-like object" @@ -447,39 +467,39 @@ msgstr "bytes-like αντικείμενα" #: glossary.rst:184 msgid "" -"An object that supports the :ref:`bufferobjects` and can export a C-:term:" -"`contiguous` buffer. This includes all :class:`bytes`, :class:`bytearray`, " -"and :class:`array.array` objects, as well as many common :class:`memoryview` " -"objects. Bytes-like objects can be used for various operations that work " -"with binary data; these include compression, saving to a binary file, and " -"sending over a socket." +"An object that supports the :ref:`bufferobjects` and can export a " +"C-:term:`contiguous` buffer. This includes " +"all :class:`bytes`, :class:`bytearray`, and :class:`array.array` objects, as " +"well as many common :class:`memoryview` objects. Bytes-like objects can be " +"used for various operations that work with binary data; these include " +"compression, saving to a binary file, and sending over a socket." msgstr "" "Ένα αντικείμενο που υποστηρίζει το :ref:`bufferobjects` και μπορεί να εξάγει " -"ένα C-:term:`contiguous` buffer. Αυτό περιλαμβάνει όλα τα αντικείμενα :class:" -"`bytes`, :class:`bytearray`, και :class:`array.array`, καθώς και πολλά " -"κοινά :class:`memoryview` αντικείμενα. Τα δυαδικού τύπου (bytes-like) " -"αντικείμενα μπορούν να χρησιμοποιηθούν για διάφορες λειτουργίες που " -"διαχειρίζονται δυαδικά δεδομένα' αυτά περιλαμβάνουν συμπίεση αποθήκευση σε " -"δυαδικό αρχείο και αποστολή μέσω socket." +"ένα C-:term:`contiguous` buffer. Αυτό περιλαμβάνει όλα τα " +"αντικείμενα :class:`bytes`, :class:`bytearray`, και :class:`array.array`, " +"καθώς και πολλά κοινά :class:`memoryview` αντικείμενα. Τα δυαδικού τύπου " +"(bytes-like) αντικείμενα μπορούν να χρησιμοποιηθούν για διάφορες λειτουργίες " +"που διαχειρίζονται δυαδικά δεδομένα' αυτά περιλαμβάνουν συμπίεση αποθήκευση " +"σε δυαδικό αρχείο και αποστολή μέσω socket." #: glossary.rst:191 msgid "" "Some operations need the binary data to be mutable. The documentation often " "refers to these as \"read-write bytes-like objects\". Example mutable " -"buffer objects include :class:`bytearray` and a :class:`memoryview` of a :" -"class:`bytearray`. Other operations require the binary data to be stored in " -"immutable objects (\"read-only bytes-like objects\"); examples of these " +"buffer objects include :class:`bytearray` and a :class:`memoryview` of " +"a :class:`bytearray`. Other operations require the binary data to be stored " +"in immutable objects (\"read-only bytes-like objects\"); examples of these " "include :class:`bytes` and a :class:`memoryview` of a :class:`bytes` object." msgstr "" "Ορισμένες λειτουργίες χρειάζονται τα δυαδικά δεδομένα να είναι μεταβλητά. Η " "τεκμηρίωση συχνά αναφέρεται σε αυτά ως \"δυαδικά αντικείμενα ανάγνωσης-" "εγγραφής\" (read-write bytes-like objects). Παραδείγματα μεταβλητών " -"αντικειμένων προσωρινής αποθήκευσης περιέχουν :class:`bytearray` και ένα :" -"class:`memoryview` ενός :class:`bytearray`. Άλλες λειτουργίες απαιτούν την " -"αποθήκευσης των δυαδικών δεδομένα σε αμετάβλητα αντικείμενα (\"δυαδικά " +"αντικειμένων προσωρινής αποθήκευσης περιέχουν :class:`bytearray` και " +"ένα :class:`memoryview` ενός :class:`bytearray`. Άλλες λειτουργίες απαιτούν " +"την αποθήκευσης των δυαδικών δεδομένα σε αμετάβλητα αντικείμενα (\"δυαδικά " "αντικείμενα μόνο ανάγνωσης\"' (read-only bytes-like objects) παραδείγματα " -"αυτών περιέχουν :class:`bytes` και ένα :class:`memoryview` ενός :class:" -"`bytes` αντικειμένου." +"αυτών περιέχουν :class:`bytes` και ένα :class:`memoryview` " +"ενός :class:`bytes` αντικειμένου." #: glossary.rst:199 msgid "bytecode" @@ -509,8 +529,8 @@ msgstr "" #: glossary.rst:211 msgid "" -"A list of bytecode instructions can be found in the documentation for :ref:" -"`the dis module `." +"A list of bytecode instructions can be found in the documentation " +"for :ref:`the dis module `." msgstr "" "Μια λίστα από οδηγίες σχετικά με τα bytecode μπορεί να βρεθεί στην " "τεκμηρίωση για :ref:`το module dis `." @@ -527,6 +547,10 @@ msgstr "" "Ένα callable είναι ένα αντικείμενο που μπορεί να καλεστεί, πιθανά με ένα " "σύνολο ορισμάτων (βλ. :term:`argument`), με την παρακάτω σύνταξη::" +#: glossary.rst:218 +msgid "callable(argument1, argument2, argumentN)" +msgstr "" + #: glossary.rst:220 msgid "" "A :term:`function`, and by extension a :term:`method`, is a callable. An " @@ -612,9 +636,9 @@ msgid "" "by defining :meth:`~object.__enter__` and :meth:`~object.__exit__` methods. " "See :pep:`343`." msgstr "" -"Ένα αντικείμενο που ελέγχει το περιβάλλον που εμφανίζεται σε μια δήλωση :" -"keyword:`with` ορίζοντας τις μεθόδους :meth:`~object.__enter__` και :meth:" -"`~object.__exit__`. Βλ. :pep:`343`." +"Ένα αντικείμενο που ελέγχει το περιβάλλον που εμφανίζεται σε μια " +"δήλωση :keyword:`with` ορίζοντας τις μεθόδους :meth:`~object.__enter__` " +"και :meth:`~object.__exit__`. Βλ. :pep:`343`." #: glossary.rst:253 msgid "context variable" @@ -673,8 +697,8 @@ msgstr "" "Οι coroutines είναι μια πιο γενικευμένη μορφή subroutines. Οι subroutines " "εισάγονται σε ένα σημείο και εξάγονται σε άλλο σημείο. Οι coroutines μπορεί " "να εισαχθούν, να εξαχθούν και να συνεχιστούν σε πολλά διαφορετικά σημεία. " -"Μπορούν να υλοποιήσουν με την δήλωση :keyword:`async def`. Βλ. επίσης :pep:" -"`492`." +"Μπορούν να υλοποιήσουν με την δήλωση :keyword:`async def`. Βλ. " +"επίσης :pep:`492`." #: glossary.rst:281 msgid "coroutine function" @@ -683,14 +707,14 @@ msgstr "coroutine συνάρτηση" #: glossary.rst:283 msgid "" "A function which returns a :term:`coroutine` object. A coroutine function " -"may be defined with the :keyword:`async def` statement, and may contain :" -"keyword:`await`, :keyword:`async for`, and :keyword:`async with` keywords. " -"These were introduced by :pep:`492`." +"may be defined with the :keyword:`async def` statement, and may " +"contain :keyword:`await`, :keyword:`async for`, and :keyword:`async with` " +"keywords. These were introduced by :pep:`492`." msgstr "" "Μια συνάρτηση που επιστρέφει ένα :term:`coroutine` αντικείμενο. Μια " "συνάρτηση coroutine μπορεί να ορίζεται από τη δήλωση :keyword:`async def`, " -"και μπορεί να περιέχει :keyword:`await`, :keyword:`async for`, και :keyword:" -"`async with` λέξεις κλειδιά. Αυτές εισήχθησαν από το :pep:`492`." +"και μπορεί να περιέχει :keyword:`await`, :keyword:`async for`, " +"και :keyword:`async with` λέξεις κλειδιά. Αυτές εισήχθησαν από το :pep:`492`." #: glossary.rst:288 msgid "CPython" @@ -720,8 +744,8 @@ msgid "" msgstr "" "Μια συνάρτηση που επιστρέφει μια άλλη συνάρτηση, συνήθως εφαρμόζεται ως " "μετασχηματισμός συνάρτησης χρησιμοποιώντας την ``@wrapper`` σύνταξη. " -"Συνηθισμένα παραδείγματα για τους decorators είναι :func:`classmethod` και :" -"func:`staticmethod`." +"Συνηθισμένα παραδείγματα για τους decorators είναι :func:`classmethod` " +"και :func:`staticmethod`." #: glossary.rst:300 msgid "" @@ -731,6 +755,17 @@ msgstr "" "Η σύνταξη του decorator είναι απλώς καλλωπιστική, οι ακόλουθοι δύο ορισμοί " "συναρτήσεων είναι σημασιολογικά ισοδύναμοι::" +#: glossary.rst:303 +msgid "" +"def f(arg):\n" +" ...\n" +"f = staticmethod(f)\n" +"\n" +"@staticmethod\n" +"def f(arg):\n" +" ..." +msgstr "" + #: glossary.rst:311 msgid "" "The same concept exists for classes, but is less commonly used there. See " @@ -738,8 +773,9 @@ msgid "" "definitions ` for more about decorators." msgstr "" "Η ίδια έννοια υπάρχει για τις κλάσεις, αλλά χρησιμοποιείται λιγότερο συχνά " -"εκεί. Βλ. την τεκμηρίωση για :ref:`function definitions ` και :ref:" -"`class definitions ` για περισσότερα σχετικά με τους decorators." +"εκεί. Βλ. την τεκμηρίωση για :ref:`function definitions ` " +"και :ref:`class definitions ` για περισσότερα σχετικά με τους " +"decorators." #: glossary.rst:314 msgid "descriptor" @@ -747,26 +783,28 @@ msgstr "descriptor" #: glossary.rst:316 msgid "" -"Any object which defines the methods :meth:`~object.__get__`, :meth:`~object." -"__set__`, or :meth:`~object.__delete__`. When a class attribute is a " -"descriptor, its special binding behavior is triggered upon attribute " -"lookup. Normally, using *a.b* to get, set or delete an attribute looks up " -"the object named *b* in the class dictionary for *a*, but if *b* is a " -"descriptor, the respective descriptor method gets called. Understanding " -"descriptors is a key to a deep understanding of Python because they are the " -"basis for many features including functions, methods, properties, class " -"methods, static methods, and reference to super classes." -msgstr "" -"Κάθε αντικείμενο που ορίζει τις μεθόδους :meth:`~object.__get__`, :meth:" -"`~object.__set__`, ή :meth:`~object.__delete__`. Όταν ένα χαρακτηριστικό " -"κλάσης είναι descriptor, η ειδική δεσμευτική του συμπεριφορά ενεργοποιείται " -"κατά την αναζήτηση χαρακτηριστικών. Κανονικά, χρησιμοποιώντας *a.b* για να " -"λάβετε, να ορίσετε ή να διαγράψετε ένα χαρακτηριστικό αναζητά το αντικείμενο " -"με το όνομα *b* στο λεξικό της κλάσης για *a*, αλλά εάν το *b* είναι " -"descriptor, καλείται η αντίστοιχη μέθοδος descriptor. Η κατανόηση των " -"descriptors είναι το κλειδί για την καλύτερη κατανόηση της Python γιατί αυτό " -"αποτελεί την βάση για πολλά χαρακτηριστικά όπως συναρτήσεις, μεθόδους, " -"ιδιότητες, μέθοδοι κλάσης στατικές μέθοδοι, και αναφορά σε σούπερ κλάσεις." +"Any object which defines the " +"methods :meth:`~object.__get__`, :meth:`~object.__set__`, " +"or :meth:`~object.__delete__`. When a class attribute is a descriptor, its " +"special binding behavior is triggered upon attribute lookup. Normally, " +"using *a.b* to get, set or delete an attribute looks up the object named *b* " +"in the class dictionary for *a*, but if *b* is a descriptor, the respective " +"descriptor method gets called. Understanding descriptors is a key to a deep " +"understanding of Python because they are the basis for many features " +"including functions, methods, properties, class methods, static methods, and " +"reference to super classes." +msgstr "" +"Κάθε αντικείμενο που ορίζει τις " +"μεθόδους :meth:`~object.__get__`, :meth:`~object.__set__`, " +"ή :meth:`~object.__delete__`. Όταν ένα χαρακτηριστικό κλάσης είναι " +"descriptor, η ειδική δεσμευτική του συμπεριφορά ενεργοποιείται κατά την " +"αναζήτηση χαρακτηριστικών. Κανονικά, χρησιμοποιώντας *a.b* για να λάβετε, να " +"ορίσετε ή να διαγράψετε ένα χαρακτηριστικό αναζητά το αντικείμενο με το " +"όνομα *b* στο λεξικό της κλάσης για *a*, αλλά εάν το *b* είναι descriptor, " +"καλείται η αντίστοιχη μέθοδος descriptor. Η κατανόηση των descriptors είναι " +"το κλειδί για την καλύτερη κατανόηση της Python γιατί αυτό αποτελεί την βάση " +"για πολλά χαρακτηριστικά όπως συναρτήσεις, μεθόδους, ιδιότητες, μέθοδοι " +"κλάσης στατικές μέθοδοι, και αναφορά σε σούπερ κλάσεις." #: glossary.rst:327 msgid "" @@ -788,8 +826,9 @@ msgid "" "methods. Called a hash in Perl." msgstr "" "Ένα προσεταιριστικός πίνακα, όπου αυθαίρετα κλειδιά αντιστοιχίζονται σε " -"τιμές. Τα κλειδιά μπορεί να είναι οποιοδήποτε αντικείμενο με μεθόδους :meth:" -"`~object.__hash__` και :meth:`~object.__eq__`. Ονομάζεται ως hash στο Perl." +"τιμές. Τα κλειδιά μπορεί να είναι οποιοδήποτε αντικείμενο με " +"μεθόδους :meth:`~object.__hash__` και :meth:`~object.__eq__`. Ονομάζεται ως " +"hash στο Perl." #: glossary.rst:335 msgid "dictionary comprehension" @@ -805,8 +844,8 @@ msgstr "" "Ένα συμπαγής τρόπος για να επεξεργαστείτε όλα ή μέρος των στοιχείων σε ένα " "επαναληπτικό και να επιστραφεί ένα με λεξικό με τα αποτελέσματα. ``results = " "{n: n ** 2 for n in range(10)}`` δημιουργεί ένα λεξικό που περιέχει το " -"κλειδί ``n`` που αντιστοιχίζεται με την τιμή ``n ** 2``. Βλ. :ref:" -"`comprehensions`." +"κλειδί ``n`` που αντιστοιχίζεται με την τιμή ``n ** 2``. " +"Βλ. :ref:`comprehensions`." #: glossary.rst:341 msgid "dictionary view" @@ -814,11 +853,11 @@ msgstr "όψη λεξικού" #: glossary.rst:343 msgid "" -"The objects returned from :meth:`dict.keys`, :meth:`dict.values`, and :meth:" -"`dict.items` are called dictionary views. They provide a dynamic view on the " -"dictionary’s entries, which means that when the dictionary changes, the view " -"reflects these changes. To force the dictionary view to become a full list " -"use ``list(dictview)``. See :ref:`dict-views`." +"The objects returned from :meth:`dict.keys`, :meth:`dict.values`, " +"and :meth:`dict.items` are called dictionary views. They provide a dynamic " +"view on the dictionary’s entries, which means that when the dictionary " +"changes, the view reflects these changes. To force the dictionary view to " +"become a full list use ``list(dictview)``. See :ref:`dict-views`." msgstr "" "Τα αντικείμενα που επιστρέφονται από :meth:`dict.keys`, :meth:`dict.values`, " "και :meth:`dict.items` καλούνται όψεις λεξικού. Αυτές παρέχουν μια δυναμική " @@ -832,19 +871,20 @@ msgid "docstring" msgstr "docstring" #: glossary.rst:351 +#, fuzzy msgid "" "A string literal which appears as the first expression in a class, function " "or module. While ignored when the suite is executed, it is recognized by " -"the compiler and put into the :attr:`!__doc__` attribute of the enclosing " -"class, function or module. Since it is available via introspection, it is " -"the canonical place for documentation of the object." +"the compiler and put into the :attr:`~definition.__doc__` attribute of the " +"enclosing class, function or module. Since it is available via " +"introspection, it is the canonical place for documentation of the object." msgstr "" "Μια literal συμβολοσειρά που εμφανίζεται ως η πρώτη έκφραση σε μια κλάση, " "συνάρτηση ή module. Ενώ αγνοείται κατά την εκτέλεση της σουίτας, " -"αναγνωρίζεται από τον μεταγλωττιστή και τοποθετείται στο χαρακτηριστικό :" -"attr:`!__doc__` της κλάσης, της συνάρτησης ή του module που περικλείει. " -"Δεδομένου ότι είναι διαθέσιμο μέσω ενδοσκόπησης, το κανονικό μέρος για την " -"τεκμηρίωση του αντικειμένου." +"αναγνωρίζεται από τον μεταγλωττιστή και τοποθετείται στο " +"χαρακτηριστικό :attr:`!__doc__` της κλάσης, της συνάρτησης ή του module που " +"περικλείει. Δεδομένου ότι είναι διαθέσιμο μέσω ενδοσκόπησης, το κανονικό " +"μέρος για την τεκμηρίωση του αντικειμένου." #: glossary.rst:357 msgid "duck-typing" @@ -857,10 +897,10 @@ msgid "" "called or used (\"If it looks like a duck and quacks like a duck, it must be " "a duck.\") By emphasizing interfaces rather than specific types, well-" "designed code improves its flexibility by allowing polymorphic " -"substitution. Duck-typing avoids tests using :func:`type` or :func:" -"`isinstance`. (Note, however, that duck-typing can be complemented with :" -"term:`abstract base classes `.) Instead, it typically " -"employs :func:`hasattr` tests or :term:`EAFP` programming." +"substitution. Duck-typing avoids tests using :func:`type` " +"or :func:`isinstance`. (Note, however, that duck-typing can be complemented " +"with :term:`abstract base classes `.) Instead, it " +"typically employs :func:`hasattr` tests or :term:`EAFP` programming." msgstr "" "Ένα στυλ προγραμματισμού που δεν εξετάζει τον τύπο ενός αντικειμένου για να " "προσδιορίσει αν έχει τη σωστή διεπαφή' αντίθετα, η μέθοδος ή το " @@ -939,8 +979,8 @@ msgid "" "See also :pep:`498`." msgstr "" "Οι κυριολεκτικές συμβολοσειρές χρησιμοποιούν με πρόθεμα ``'f'`` ή ``'F'`` " -"ονομάζονται συνήθως \"f-strings\" που είναι συντομογραφία του :ref:" -"`formatted string literals `. Βλ. επίσης :pep:`498`." +"ονομάζονται συνήθως \"f-strings\" που είναι συντομογραφία " +"του :ref:`formatted string literals `. Βλ. επίσης :pep:`498`." #: glossary.rst:394 msgid "file object" @@ -960,8 +1000,8 @@ msgstr "" "τρόπο που δημιουργήθηκε, ένα αντικείμενο αρχείου μπορεί να μεσολαβήσει στην " "πρόσβαση σε ένα πραγματικό αρχείο στο δίσκο ή σε άλλο τύπο συσκευής " "αποθήκευσης ή επικοινωνίας (για παράδειγμα τυπική είσοδος/ έξοδος, in-memory " -"buffers, sockets, pipes, κλπ.). Αντικείμενο αρχείου ονομάζονται επίσης :dfn:" -"`file-like objects` ή :dfn:`streams`." +"buffers, sockets, pipes, κλπ.). Αντικείμενο αρχείου ονομάζονται " +"επίσης :dfn:`file-like objects` ή :dfn:`streams`." #: glossary.rst:404 msgid "" @@ -971,11 +1011,11 @@ msgid "" "The canonical way to create a file object is by using the :func:`open` " "function." msgstr "" -"Στην πραγματικότητα υπάρχουν τρεις κατηγορίες αντικειμένων αρχείου raw :term:" -"`δυαδικά αρχεία `, buffered :term:`δυαδικά αρχεία ` και :term:`αρχεία κειμένου `. Οι διεπαφές τους ορίζονται " -"στην ενότητα :mod:`io`. Ο κανονικός τρόπος για να δημιουργήσετε ένα " -"αντικείμενο αρχείου είναι χρησιμοποιώντας την συνάρτηση :func:`open`." +"Στην πραγματικότητα υπάρχουν τρεις κατηγορίες αντικειμένων αρχείου " +"raw :term:`δυαδικά αρχεία `, buffered :term:`δυαδικά αρχεία " +"` και :term:`αρχεία κειμένου `. Οι διεπαφές τους " +"ορίζονται στην ενότητα :mod:`io`. Ο κανονικός τρόπος για να δημιουργήσετε " +"ένα αντικείμενο αρχείου είναι χρησιμοποιώντας την συνάρτηση :func:`open`." #: glossary.rst:409 msgid "file-like object" @@ -1011,25 +1051,25 @@ msgstr "" #: glossary.rst:421 msgid "" -"The :func:`sys.getfilesystemencoding` and :func:`sys." -"getfilesystemencodeerrors` functions can be used to get the filesystem " -"encoding and error handler." +"The :func:`sys.getfilesystemencoding` " +"and :func:`sys.getfilesystemencodeerrors` functions can be used to get the " +"filesystem encoding and error handler." msgstr "" -"Οι συναρτήσεις :func:`sys.getfilesystemencoding` και :func:`sys." -"getfilesystemencodeerrors` μπορούν να χρησιμοποιηθούν για να λάβετε την " -"κωδικοποίηση του συστήματος αρχείων και του χειριστή σφαλμάτων." +"Οι συναρτήσεις :func:`sys.getfilesystemencoding` " +"και :func:`sys.getfilesystemencodeerrors` μπορούν να χρησιμοποιηθούν για να " +"λάβετε την κωδικοποίηση του συστήματος αρχείων και του χειριστή σφαλμάτων." #: glossary.rst:425 msgid "" "The :term:`filesystem encoding and error handler` are configured at Python " -"startup by the :c:func:`PyConfig_Read` function: see :c:member:`~PyConfig." -"filesystem_encoding` and :c:member:`~PyConfig.filesystem_errors` members of :" -"c:type:`PyConfig`." +"startup by the :c:func:`PyConfig_Read` function: " +"see :c:member:`~PyConfig.filesystem_encoding` " +"and :c:member:`~PyConfig.filesystem_errors` members of :c:type:`PyConfig`." msgstr "" "Ο :term:`filesystem encoding and error handler` διαμορφώνονται κατά την " -"εκκίνηση της Python από τη συνάρτηση :c:func:`PyConfig_Read` βλ. :c:member:" -"`~PyConfig.filesystem_encoding` και :c:member:`~PyConfig.filesystem_errors` " -"μέλη του :c:type:`PyConfig`." +"εκκίνηση της Python από τη συνάρτηση :c:func:`PyConfig_Read` " +"βλ. :c:member:`~PyConfig.filesystem_encoding` " +"και :c:member:`~PyConfig.filesystem_errors` μέλη του :c:type:`PyConfig`." #: glossary.rst:430 msgid "See also the :term:`locale encoding`." @@ -1048,17 +1088,20 @@ msgstr "" "εισήχθη." #: glossary.rst:436 +#, fuzzy msgid "" -"Since Python 3.3, there are two types of finder: :term:`meta path finders " -"` for use with :data:`sys.meta_path`, and :term:`path " -"entry finders ` for use with :data:`sys.path_hooks`." +"There are two types of finder: :term:`meta path finders ` " +"for use with :data:`sys.meta_path`, and :term:`path entry finders ` for use with :data:`sys.path_hooks`." msgstr "" "Από την Python 3.3, υπάρχουν δύο τύποι finder: :term:`finders μετα διαδρομής " "` για χρήση με :data:`sys.meta_path`, και :term:`finders " "εισόδου διαδρομής ` για χρήση με :data:`sys.path_hooks`." #: glossary.rst:440 -msgid "See :pep:`302`, :pep:`420` and :pep:`451` for much more detail." +#, fuzzy +msgid "" +"See :ref:`finders-and-loaders` and :mod:`importlib` for much more detail." msgstr "" "Βλ. :pep:`302`, :pep:`420` και :pep:`451` για περισσότερες λεπτομέρειες." @@ -1089,8 +1132,8 @@ msgstr "συνάρτηση" msgid "" "A series of statements which returns some value to a caller. It can also be " "passed zero or more :term:`arguments ` which may be used in the " -"execution of the body. See also :term:`parameter`, :term:`method`, and the :" -"ref:`function` section." +"execution of the body. See also :term:`parameter`, :term:`method`, and " +"the :ref:`function` section." msgstr "" "Μια σειρά από δηλώσεις που επιστρέφουν κάποια τιμή σε αυτόν που την κάλεσε. " "Σε αυτές μπορούν να περαστούν κανένα ή περισσότερα :term:`ορίσματα " @@ -1114,8 +1157,14 @@ msgid "" msgstr "" "Οι συναρτήσεις annotations συχνά χρησιμοποιούνται για :term:`υποδείξεις " "τύπου `: για παράδειγμα, αυτή η συνάρτηση αναμένεται να πάρει δύο " -"ορίσματα :class:`int` και επίσης αναμένεται να έχει μία επιστρεφόμενη τιμή :" -"class:`int`::" +"ορίσματα :class:`int` και επίσης αναμένεται να έχει μία επιστρεφόμενη " +"τιμή :class:`int`::" + +#: glossary.rst:463 +msgid "" +"def sum_two_numbers(a: int, b: int) -> int:\n" +" return a + b" +msgstr "" #: glossary.rst:466 msgid "Function annotation syntax is explained in section :ref:`function`." @@ -1140,8 +1189,8 @@ msgstr "__future__" msgid "" "A :ref:`future statement `, ``from __future__ import ``, " "directs the compiler to compile the current module using syntax or semantics " -"that will become standard in a future release of Python. The :mod:" -"`__future__` module documents the possible values of *feature*. By " +"that will become standard in a future release of Python. " +"The :mod:`__future__` module documents the possible values of *feature*. By " "importing this module and evaluating its variables, you can see when a new " "feature was first added to the language and when it will (or did) become the " "default::" @@ -1155,6 +1204,13 @@ msgstr "" "προστέθηκε για πρώτη φορά στην γλώσσα και πότε θα γίνει (ή έγινε) η " "προεπιλογή::" +#: glossary.rst:482 +msgid "" +">>> import __future__\n" +">>> __future__.division\n" +"_Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)" +msgstr "" + #: glossary.rst:485 msgid "garbage collection" msgstr "συλλογή απορριμάτων" @@ -1209,11 +1265,12 @@ msgid "An object created by a :term:`generator` function." msgstr "Ένα αντικείμενο που δημιουργείται από μια συνάρτηση :term:`generator`." #: glossary.rst:507 +#, fuzzy msgid "" "Each :keyword:`yield` temporarily suspends processing, remembering the " -"location execution state (including local variables and pending try-" -"statements). When the *generator iterator* resumes, it picks up where it " -"left off (in contrast to functions which start fresh on every invocation)." +"execution state (including local variables and pending try-statements). " +"When the *generator iterator* resumes, it picks up where it left off (in " +"contrast to functions which start fresh on every invocation)." msgstr "" "Κάθε :keyword:`yield` αναστέλλει προσωρινά την επεξεργασία, θυμάται την " "τοποθεσία κατάστασης εκτέλεσης (συμπεριλαμβανομένων των τοπικών μεταβλητών " @@ -1237,6 +1294,12 @@ msgstr "" "βρόχου, ένα εύρος και μια προαιρετική πρόταση :keyword:`!if`. Η συνδυασμένη " "έκφραση δημιουργεί τιμές για μια συνάρτηση εγκλεισμού::" +#: glossary.rst:521 +msgid "" +">>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81\n" +"285" +msgstr "" + #: glossary.rst:523 msgid "generic function" msgstr "γενική συνάρτηση" @@ -1254,11 +1317,11 @@ msgstr "" #: glossary.rst:529 msgid "" -"See also the :term:`single dispatch` glossary entry, the :func:`functools." -"singledispatch` decorator, and :pep:`443`." +"See also the :term:`single dispatch` glossary entry, " +"the :func:`functools.singledispatch` decorator, and :pep:`443`." msgstr "" -"Βλ. επίσης την καταχώρηση του :term:`single dispatch`, τον decorator :func:" -"`functools.singledispatch` και :pep:`443`." +"Βλ. επίσης την καταχώρηση του :term:`single dispatch`, τον " +"decorator :func:`functools.singledispatch` και :pep:`443`." #: glossary.rst:531 msgid "generic type" @@ -1267,22 +1330,23 @@ msgstr "γενικός τύπος" #: glossary.rst:533 msgid "" "A :term:`type` that can be parameterized; typically a :ref:`container " -"class` such as :class:`list` or :class:`dict`. Used for :" -"term:`type hints ` and :term:`annotations `." +"class` such as :class:`list` or :class:`dict`. Used " +"for :term:`type hints ` and :term:`annotations `." msgstr "" -"Ένας :term:`type` που μπορεί να παραμετροποιηθεί' συνήθως μια :ref:" -"`container class`, όπως :class:`list` ή :class:`dict`. " -"Χρησιμοποιείται για :term:`type hints ` και :term:`annotations " -"`." +"Ένας :term:`type` που μπορεί να παραμετροποιηθεί' συνήθως " +"μια :ref:`container class`, όπως :class:`list` " +"ή :class:`dict`. Χρησιμοποιείται για :term:`type hints ` " +"και :term:`annotations `." #: glossary.rst:538 msgid "" -"For more details, see :ref:`generic alias types`, :pep:" -"`483`, :pep:`484`, :pep:`585`, and the :mod:`typing` module." +"For more details, see :ref:`generic alias types`, :pep:`483`, :pep:`484`, :pep:`585`, and the :mod:`typing` " +"module." msgstr "" "Για περισσότερες λεπτομέρειες, βλ. :ref:`generic alias types` :pep:`483`, :pep:`484`, :pep:`585`, και το module :mod:" -"`typing`." +"genericalias>` :pep:`483`, :pep:`484`, :pep:`585`, και το " +"module :mod:`typing`." #: glossary.rst:540 msgid "GIL" @@ -1368,11 +1432,11 @@ msgid "" "Hashable objects which compare equal must have the same hash value." msgstr "" "Ένα αντικείμενο είναι *hashable* εάν έχει μια τιμή κατακερματισμού που δεν " -"αλλάζει ποτέ κατά τη διάρκεια της ζωής του (χρειάζεται μια μέθοδο :meth:" -"`~object.__hash__`) , και μπορεί να συγκριθεί με άλλα αντικείμενα " -"(χρειάζεται μια μέθοδο :meth:`~object.__eq__`) . Τα *hashable* αντικείμενα " -"που συγκρίνονται ως προς την ισότητα τους πρέπει να έχουν την ίδια τιμή " -"κατακερματισμού." +"αλλάζει ποτέ κατά τη διάρκεια της ζωής του (χρειάζεται μια " +"μέθοδο :meth:`~object.__hash__`) , και μπορεί να συγκριθεί με άλλα " +"αντικείμενα (χρειάζεται μια μέθοδο :meth:`~object.__eq__`) . Τα *hashable* " +"αντικείμενα που συγκρίνονται ως προς την ισότητα τους πρέπει να έχουν την " +"ίδια τιμή κατακερματισμού." #: glossary.rst:578 msgid "" @@ -1410,15 +1474,32 @@ msgid "" "is a basic editor and interpreter environment which ships with the standard " "distribution of Python." msgstr "" -"Ένα ολοκληρωμένο περιβάλλον ανάπτυξης και μάθησης για την Python. :ref:" -"`idle` είναι ένα βασικό περιβάλλον επεξεργασίας και διερμηνέα που " -"συνοδεύεται από την τυπική διανομή της Python." +"Ένα ολοκληρωμένο περιβάλλον ανάπτυξης και μάθησης για την " +"Python. :ref:`idle` είναι ένα βασικό περιβάλλον επεξεργασίας και διερμηνέα " +"που συνοδεύεται από την τυπική διανομή της Python." #: glossary.rst:593 +msgid "immortal" +msgstr "" + +#: glossary.rst:595 +msgid "" +"*Immortal objects* are a CPython implementation detail introduced " +"in :pep:`683`." +msgstr "" + +#: glossary.rst:598 +msgid "" +"If an object is immortal, its :term:`reference count` is never modified, and " +"therefore it is never deallocated while the interpreter is running. For " +"example, :const:`True` and :const:`None` are immortal in CPython." +msgstr "" + +#: glossary.rst:601 msgid "immutable" msgstr "immutable" -#: glossary.rst:595 +#: glossary.rst:603 msgid "" "An object with a fixed value. Immutable objects include numbers, strings " "and tuples. Such an object cannot be altered. A new object has to be " @@ -1432,11 +1513,11 @@ msgstr "" "αποθηκευτεί μια διαφορετική τιμή. Παίζουν σημαντικό ρόλο σε μέρη όπου μια " "σταθερά απαιτείται, για παράδειγμα ως κλειδί σε ένα λεξικό." -#: glossary.rst:600 +#: glossary.rst:608 msgid "import path" msgstr "εισαγόμενο path" -#: glossary.rst:602 +#: glossary.rst:610 msgid "" "A list of locations (or :term:`path entries `) that are searched " "by the :term:`path based finder` for modules to import. During import, this " @@ -1449,11 +1530,11 @@ msgstr "" "από :data:`sys.path`, αλλά για τα υποπακέτα μπορεί επίσης να έρθει από το " "χαρακτηριστικό του πακέτου γονέα ``__path__``." -#: glossary.rst:607 +#: glossary.rst:615 msgid "importing" msgstr "εισαγωγή" -#: glossary.rst:609 +#: glossary.rst:617 msgid "" "The process by which Python code in one module is made available to Python " "code in another module." @@ -1461,23 +1542,23 @@ msgstr "" "Η διαδικασία κατά την οποία ο κώδικας της Python σε ένα module είναι " "διαθέσιμη στον κώδικα Python ενός άλλου module." -#: glossary.rst:611 +#: glossary.rst:619 msgid "importer" msgstr "εισαγωγέας" -#: glossary.rst:613 +#: glossary.rst:621 msgid "" -"An object that both finds and loads a module; both a :term:`finder` and :" -"term:`loader` object." +"An object that both finds and loads a module; both a :term:`finder` " +"and :term:`loader` object." msgstr "" -"Ένα αντικείμενο μπορεί και να αναζητεί και να φορτώνει ένα module' και ένα :" -"term:`finder` και :term:`loader` αντικείμενο." +"Ένα αντικείμενο μπορεί και να αναζητεί και να φορτώνει ένα module' και " +"ένα :term:`finder` και :term:`loader` αντικείμενο." -#: glossary.rst:615 +#: glossary.rst:623 msgid "interactive" msgstr "διαδραστικός" -#: glossary.rst:617 +#: glossary.rst:625 msgid "" "Python has an interactive interpreter which means you can enter statements " "and expressions at the interpreter prompt, immediately execute them and see " @@ -1492,11 +1573,11 @@ msgstr "" "υπολογιστή σας). Αποτελεί έναν αποδοτικό τρόπο για να δοκιμάστε νέες ιδέες ή " "να εξετάστε λειτουργικές μονάδες και πακέτα (θυμηθείτε ``help(x)``)." -#: glossary.rst:623 +#: glossary.rst:631 msgid "interpreted" msgstr "interpreted" -#: glossary.rst:625 +#: glossary.rst:633 msgid "" "Python is an interpreted language, as opposed to a compiled one, though the " "distinction can be blurry because of the presence of the bytecode compiler. " @@ -1513,20 +1594,20 @@ msgstr "" "εντοπισμού σφαλμάτων από τις μεταγλωττισμένες, αν και τα προγράμματά τους " "γενικά εκτελούνται πιο αργά. Βλ. επίσης :term:`interactive`." -#: glossary.rst:632 +#: glossary.rst:640 msgid "interpreter shutdown" msgstr "τερματισμός λειτουργίας διερμηνέα" -#: glossary.rst:634 +#: glossary.rst:642 msgid "" "When asked to shut down, the Python interpreter enters a special phase where " "it gradually releases all allocated resources, such as modules and various " -"critical internal structures. It also makes several calls to the :term:" -"`garbage collector `. This can trigger the execution of " -"code in user-defined destructors or weakref callbacks. Code executed during " -"the shutdown phase can encounter various exceptions as the resources it " -"relies on may not function anymore (common examples are library modules or " -"the warnings machinery)." +"critical internal structures. It also makes several calls to " +"the :term:`garbage collector `. This can trigger the " +"execution of code in user-defined destructors or weakref callbacks. Code " +"executed during the shutdown phase can encounter various exceptions as the " +"resources it relies on may not function anymore (common examples are library " +"modules or the warnings machinery)." msgstr "" "Όταν ζητείται τερματισμός λειτουργίας, ο διερμηνέας της Python εισέρχεται σε " "μια ειδική φάση όπου απελευθερώνει σταδιακά όλους τους διατιθέμενους πόρους, " @@ -1539,7 +1620,7 @@ msgstr "" "βασίζεται ενδέχεται να μην λειτουργούν πλέον (συνήθη παραδείγματα είναι οι " "λειτουργικές μονάδες βιβλιοθήκης ή ο μηχανισμός ειδοποιήσεων)." -#: glossary.rst:643 +#: glossary.rst:651 msgid "" "The main reason for interpreter shutdown is that the ``__main__`` module or " "the script being run has finished executing." @@ -1547,71 +1628,75 @@ msgstr "" "Ο βασικός λόγος τερματισμού λειτουργίας του διερμηνέα είναι ότι το " "``__main__`` module ή ολοκληρώθηκε η εκτέλεση του κώδικα που έτρεχε." -#: glossary.rst:645 +#: glossary.rst:653 msgid "iterable" msgstr "iterable" -#: glossary.rst:647 +#: glossary.rst:655 msgid "" "An object capable of returning its members one at a time. Examples of " "iterables include all sequence types (such as :class:`list`, :class:`str`, " -"and :class:`tuple`) and some non-sequence types like :class:`dict`, :term:" -"`file objects `, and objects of any classes you define with an :" -"meth:`~iterator.__iter__` method or with a :meth:`~object.__getitem__` " -"method that implements :term:`sequence` semantics." +"and :class:`tuple`) and some non-sequence types " +"like :class:`dict`, :term:`file objects `, and objects of any " +"classes you define with an :meth:`~iterator.__iter__` method or with " +"a :meth:`~object.__getitem__` method that implements :term:`sequence` " +"semantics." msgstr "" "Ένα αντικείμενο ικανό να επιστρέψει τα μέλη του ένα κάθε φορά. Παραδείγματα " -"iterables περιλαμβάνουν όλους του τύπους ακολουθιών (όπως :class:`list`, :" -"class:`str`, και :class:`tuple`) και μερικούς τύπους μη ακολουθίας όπως :" -"class:`dict`, :term:`αντικείμενο αρχείου `, και αντικείμενα " -"οποιονδήποτε κλάσεων που μπορούν να οριστούν με μια μέθοδο :meth:`~iterator." -"__iter__` ή με μία μέθοδο :meth:`~object.__getitem__` που υλοποιεί τη " +"iterables περιλαμβάνουν όλους του τύπους ακολουθιών " +"(όπως :class:`list`, :class:`str`, και :class:`tuple`) και μερικούς τύπους " +"μη ακολουθίας όπως :class:`dict`, :term:`αντικείμενο αρχείου `, " +"και αντικείμενα οποιονδήποτε κλάσεων που μπορούν να οριστούν με μια " +"μέθοδο :meth:`~iterator.__iter__` ή με μία " +"μέθοδο :meth:`~object.__getitem__` που υλοποιεί τη " "σημασιολογία :term:`sequence`." -#: glossary.rst:655 +#: glossary.rst:663 msgid "" "Iterables can be used in a :keyword:`for` loop and in many other places " "where a sequence is needed (:func:`zip`, :func:`map`, ...). When an " -"iterable object is passed as an argument to the built-in function :func:" -"`iter`, it returns an iterator for the object. This iterator is good for " -"one pass over the set of values. When using iterables, it is usually not " -"necessary to call :func:`iter` or deal with iterator objects yourself. The :" -"keyword:`for` statement does that automatically for you, creating a " -"temporary unnamed variable to hold the iterator for the duration of the " -"loop. See also :term:`iterator`, :term:`sequence`, and :term:`generator`." +"iterable object is passed as an argument to the built-in " +"function :func:`iter`, it returns an iterator for the object. This iterator " +"is good for one pass over the set of values. When using iterables, it is " +"usually not necessary to call :func:`iter` or deal with iterator objects " +"yourself. The :keyword:`for` statement does that automatically for you, " +"creating a temporary unnamed variable to hold the iterator for the duration " +"of the loop. See also :term:`iterator`, :term:`sequence`, " +"and :term:`generator`." msgstr "" "Τα iterables μπορούν να χρησιμοποιηθούν σε ένα :keyword:`for` βρόχο και σε " -"πολλά άλλα σημεία όπου χρειάζεται μια ακολουθία (:func:`zip`, :func:" -"`map`, ...). Όταν ένα iterable αντικείμενο μεταβιβάζεται ως όρισμα στην " -"ενσωματωμένη συνάρτηση :func:`iter`, επιστρέφει έναν iterator για " -"αντικείμενο. Αυτός ο iterator είναι καλός για ένα πέρασμα από ένα σύνολο " +"πολλά άλλα σημεία όπου χρειάζεται μια ακολουθία " +"(:func:`zip`, :func:`map`, ...). Όταν ένα iterable αντικείμενο μεταβιβάζεται " +"ως όρισμα στην ενσωματωμένη συνάρτηση :func:`iter`, επιστρέφει έναν iterator " +"για αντικείμενο. Αυτός ο iterator είναι καλός για ένα πέρασμα από ένα σύνολο " "τιμών. Όταν χρησιμοποιείται επαναληπτικά, συνήθως δεν είναι απαραίτητο να " "καλέσετε το :func:`iter` ή να ασχοληθείτε μόνοι σας με αντικείμενα iterator. " "Η δήλωση :keyword:`for` το κάνει αυτόματα για εσάς, δημιουργώντας μια " "προσωρινή μεταβλητή χωρίς όνομα για να κρατά τον iterator για την διάρκεια " -"του βρόχου. Βλ. επίσης :term:`iterator`, :term:`sequence`, και :term:" -"`generator`." +"του βρόχου. Βλ. επίσης :term:`iterator`, :term:`sequence`, " +"και :term:`generator`." -#: glossary.rst:665 +#: glossary.rst:673 msgid "iterator" msgstr "iterator" -#: glossary.rst:667 -msgid "" -"An object representing a stream of data. Repeated calls to the iterator's :" -"meth:`~iterator.__next__` method (or passing it to the built-in function :" -"func:`next`) return successive items in the stream. When no more data are " -"available a :exc:`StopIteration` exception is raised instead. At this " -"point, the iterator object is exhausted and any further calls to its :meth:`!" -"__next__` method just raise :exc:`StopIteration` again. Iterators are " -"required to have an :meth:`~iterator.__iter__` method that returns the " -"iterator object itself so every iterator is also iterable and may be used in " -"most places where other iterables are accepted. One notable exception is " -"code which attempts multiple iteration passes. A container object (such as " -"a :class:`list`) produces a fresh new iterator each time you pass it to the :" -"func:`iter` function or use it in a :keyword:`for` loop. Attempting this " -"with an iterator will just return the same exhausted iterator object used in " -"the previous iteration pass, making it appear like an empty container." +#: glossary.rst:675 +msgid "" +"An object representing a stream of data. Repeated calls to the " +"iterator's :meth:`~iterator.__next__` method (or passing it to the built-in " +"function :func:`next`) return successive items in the stream. When no more " +"data are available a :exc:`StopIteration` exception is raised instead. At " +"this point, the iterator object is exhausted and any further calls to " +"its :meth:`!__next__` method just raise :exc:`StopIteration` again. " +"Iterators are required to have an :meth:`~iterator.__iter__` method that " +"returns the iterator object itself so every iterator is also iterable and " +"may be used in most places where other iterables are accepted. One notable " +"exception is code which attempts multiple iteration passes. A container " +"object (such as a :class:`list`) produces a fresh new iterator each time you " +"pass it to the :func:`iter` function or use it in a :keyword:`for` loop. " +"Attempting this with an iterator will just return the same exhausted " +"iterator object used in the previous iteration pass, making it appear like " +"an empty container." msgstr "" "Ένα αντικείμενο που αντιπροσωπεύει μια ροή δεδομένων. Επαναλαμβανόμενες " "κλήσεις προς τη μέθοδο :meth:`~iterator.__next__` του iterator (ή μεταβίβαση " @@ -1631,23 +1716,23 @@ msgstr "" "εξαντλημένο αντικείμενο iterator που χρησιμοποιήθηκε στο προηγούμενο πέρασμα " "iteration , κάνοντας το να φαίνεται σαν ένα άδειο κοντέινερ." -#: glossary.rst:682 +#: glossary.rst:690 msgid "More information can be found in :ref:`typeiter`." msgstr "Περισσότερες πληροφορίες μπορούν να βρεθούν στο :ref:`typeiter`." -#: glossary.rst:686 +#: glossary.rst:694 msgid "" -"CPython does not consistently apply the requirement that an iterator define :" -"meth:`~iterator.__iter__`." +"CPython does not consistently apply the requirement that an iterator " +"define :meth:`~iterator.__iter__`." msgstr "" -"Το CPython δεν εφαρμόζει με συνέπεια την απαίτηση να ορίζει ένας iterator :" -"meth:`~iterator.__iter__`." +"Το CPython δεν εφαρμόζει με συνέπεια την απαίτηση να ορίζει ένας " +"iterator :meth:`~iterator.__iter__`." -#: glossary.rst:688 +#: glossary.rst:696 msgid "key function" msgstr "συνάρτηση key" -#: glossary.rst:690 +#: glossary.rst:698 msgid "" "A key function or collation function is a callable that returns a value used " "for sorting or ordering. For example, :func:`locale.strxfrm` is used to " @@ -1659,67 +1744,67 @@ msgstr "" "κλειδιού ταξινόμησης που γνωρίζει τις συμβάσεις ταξινόμησης για " "συγκεκριμένες τοπικές ρυθμίσεις." -#: glossary.rst:695 +#: glossary.rst:703 msgid "" "A number of tools in Python accept key functions to control how elements are " -"ordered or grouped. They include :func:`min`, :func:`max`, :func:`sorted`, :" -"meth:`list.sort`, :func:`heapq.merge`, :func:`heapq.nsmallest`, :func:`heapq." -"nlargest`, and :func:`itertools.groupby`." +"ordered or grouped. They " +"include :func:`min`, :func:`max`, :func:`sorted`, :meth:`list.sort`, :func:`heapq.merge`, :func:`heapq.nsmallest`, :func:`heapq.nlargest`, " +"and :func:`itertools.groupby`." msgstr "" "Ένα αριθμός εργαλείων στην Python δέχεται βασικές συναρτήσεις για τον έλεγχο " "του τρόπου με τον οποίο τα στοιχεία ταξινομούνται ή ομαδοποιούνται. Αυτά " -"περιέχουν :func:`min`, :func:`max`, :func:`sorted`, :meth:`list.sort`, :func:" -"`heapq.merge`, :func:`heapq.nsmallest`, :func:`heapq. nlargest`, και :func:" -"`itertools.groupby`." +"περιέχουν :func:`min`, :func:`max`, :func:`sorted`, :meth:`list.sort`, :func:`heapq.merge`, :func:`heapq.nsmallest`, :func:`heapq. " +"nlargest`, και :func:`itertools.groupby`." -#: glossary.rst:701 +#: glossary.rst:709 msgid "" -"There are several ways to create a key function. For example. the :meth:" -"`str.lower` method can serve as a key function for case insensitive sorts. " -"Alternatively, a key function can be built from a :keyword:`lambda` " -"expression such as ``lambda r: (r[0], r[2])``. Also, :func:`operator." -"attrgetter`, :func:`operator.itemgetter`, and :func:`operator.methodcaller` " -"are three key function constructors. See the :ref:`Sorting HOW TO " -"` for examples of how to create and use key functions." +"There are several ways to create a key function. For example. " +"the :meth:`str.lower` method can serve as a key function for case " +"insensitive sorts. Alternatively, a key function can be built from " +"a :keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. " +"Also, :func:`operator.attrgetter`, :func:`operator.itemgetter`, " +"and :func:`operator.methodcaller` are three key function constructors. See " +"the :ref:`Sorting HOW TO ` for examples of how to create and " +"use key functions." msgstr "" "Υπάρχουν διάφοροι τρόποι για να δημιουργήσετε μια συνάρτηση κλειδιού. Για " "παράδειγμα. η μέθοδος :meth:`str.lower` μπορεί να χρησιμεύσει ως συνάρτηση " "κλειδί για την περίπτωση μη διάκρισης πεζών-κεφαλαίων. Εναλλακτικά, μια " "συνάρτηση κλειδιού μπορεί να δημιουργηθεί από μια :keyword:`lambda` έκφραση " -"όπως ``lambda r: (r[0], r[2])``. Επίσης, :func:`operator.attrgetter`, :func:" -"`operator.itemgetter` και :func:`operator.methodcaller` είναι τρεις " -"κατασκευαστές βασικών συναρτήσεων. Βλ. το :ref:`Ταξινόμηση HOW " -"TO` για παραδείγματα δημιουργίας και χρήσης βασικών " -"συναρτήσεων." +"όπως ``lambda r: (r[0], r[2])``. " +"Επίσης, :func:`operator.attrgetter`, :func:`operator.itemgetter` " +"και :func:`operator.methodcaller` είναι τρεις κατασκευαστές βασικών " +"συναρτήσεων. Βλ. το :ref:`Ταξινόμηση HOW TO` για παραδείγματα " +"δημιουργίας και χρήσης βασικών συναρτήσεων." -#: glossary.rst:708 +#: glossary.rst:716 msgid "keyword argument" msgstr "όρισμα keyword" -#: glossary.rst:1001 +#: glossary.rst:1020 msgid "See :term:`argument`." msgstr "Βλ. :term:`argument`." -#: glossary.rst:711 +#: glossary.rst:719 msgid "lambda" msgstr "lambda" -#: glossary.rst:713 +#: glossary.rst:721 msgid "" "An anonymous inline function consisting of a single :term:`expression` which " "is evaluated when the function is called. The syntax to create a lambda " "function is ``lambda [parameters]: expression``" msgstr "" -"Μια ανώνυμη ενσωματωμένη συνάρτηση που αποτελείται από μια μοναδική :term:" -"`expression` η οποία αξιολογείται όταν καλείται η συνάρτηση. Η σύνταξη για " -"τη δημιουργία μιας συνάρτησης lambda είναι ``lambda [parameters]: " -"expression``" +"Μια ανώνυμη ενσωματωμένη συνάρτηση που αποτελείται από μια " +"μοναδική :term:`expression` η οποία αξιολογείται όταν καλείται η συνάρτηση. " +"Η σύνταξη για τη δημιουργία μιας συνάρτησης lambda είναι ``lambda " +"[parameters]: expression``" -#: glossary.rst:716 +#: glossary.rst:724 msgid "LBYL" msgstr "LBYL" -#: glossary.rst:718 +#: glossary.rst:726 msgid "" "Look before you leap. This coding style explicitly tests for pre-conditions " "before making calls or lookups. This style contrasts with the :term:`EAFP` " @@ -1731,7 +1816,7 @@ msgstr "" "έρχεται σε αντίθεση με την προσέγγιση :term:`EAFP` και χαρακτηρίζεται από " "την παρουσία πολλών δηλώσεων :keyword:`if`." -#: glossary.rst:723 +#: glossary.rst:731 msgid "" "In a multi-threaded environment, the LBYL approach can risk introducing a " "race condition between \"the looking\" and \"the leaping\". For example, " @@ -1746,45 +1831,11 @@ msgstr "" "το *mapping* μετά τη δοκιμή, αλλά πριν από την αναζήτηση. Αυτό το πρόβλημα " "μπορεί να λυθεί με κλειδώματα ή χρησιμοποιώντας την προσέγγιση EAFP." -#: glossary.rst:728 -msgid "locale encoding" -msgstr "τοπική κωδικοποίηση" - -#: glossary.rst:730 -msgid "" -"On Unix, it is the encoding of the LC_CTYPE locale. It can be set with :func:" -"`locale.setlocale(locale.LC_CTYPE, new_locale) `." -msgstr "" -"Στο Unix, είναι η κωδικοποίηση της τοπική ρύθμισης LC_CTYPE. Μπορεί να " -"ρυθμιστεί με :func:`locale.setlocale(locale.LC_CTYPE, new_locale) `." - -#: glossary.rst:733 -msgid "On Windows, it is the ANSI code page (ex: ``\"cp1252\"``)." -msgstr "Στα Windows, είναι η code page ANSI (π.χ. ``\"cp1252\"``)." - -#: glossary.rst:735 -msgid "" -"On Android and VxWorks, Python uses ``\"utf-8\"`` as the locale encoding." -msgstr "" -"Στο Android και το VxWorks, η Python χρησιμοποιεί το ``\"utf-8\"`` ως τοπική " -"κωδικοποίηση." - -#: glossary.rst:737 -msgid "``locale.getencoding()`` can be used to get the locale encoding." -msgstr "" -"``locale.getencoding()`` μπορεί να χρησιμοποιηθεί για την ανάκτηση της " -"τοπικής κωδικοποίησης." - -#: glossary.rst:739 -msgid "See also the :term:`filesystem encoding and error handler`." -msgstr "Βλ. επίσης το :term:`filesystem encoding and error handler`." - -#: glossary.rst:740 +#: glossary.rst:736 msgid "list" msgstr "λίστα" -#: glossary.rst:742 +#: glossary.rst:738 msgid "" "A built-in Python :term:`sequence`. Despite its name it is more akin to an " "array in other languages than to a linked list since access to elements is " @@ -1794,11 +1845,11 @@ msgstr "" "περισσότερο με έναν πίνακα σε άλλες γλώσσες παρά με μια συνδεδεμένη λίστα, " "καθώς η πρόσβαση στα στοιχεί είναι *O*\\ (1)." -#: glossary.rst:745 +#: glossary.rst:741 msgid "list comprehension" msgstr "list comprehension" -#: glossary.rst:747 +#: glossary.rst:743 msgid "" "A compact way to process all or part of the elements in a sequence and " "return a list with the results. ``result = ['{:#04x}'.format(x) for x in " @@ -1807,61 +1858,112 @@ msgid "" "optional. If omitted, all elements in ``range(256)`` are processed." msgstr "" "Ένα συμπαγής τρόπος για να επεξεργαστείτε όλα ή μέρος των στοιχείων σε μια " -"ακολουθία και να επιστρέψετε μια λίστα με τα αποτελέσματα. ``result = ['{:" -"#04x}'.format(x) for x in range(256) if x % 2 == 0]`` δημιουργεί μια λίστα " -"συμβολοσειρών που περιέχουν ζυγούς δεκαεξαδικούς αριθμούς (0x..) στο εύρος " -"από 0 έως 255. Η πρόταση :keyword:`if` είναι προαιρετική. Εάν παραλειφθεί, " -"όλα τα στοιχεία στο ``range(256)`` υποβάλλονται σε επεξεργασία." +"ακολουθία και να επιστρέψετε μια λίστα με τα αποτελέσματα. ``result = " +"['{:#04x}'.format(x) for x in range(256) if x % 2 == 0]`` δημιουργεί μια " +"λίστα συμβολοσειρών που περιέχουν ζυγούς δεκαεξαδικούς αριθμούς (0x..) στο " +"εύρος από 0 έως 255. Η πρόταση :keyword:`if` είναι προαιρετική. Εάν " +"παραλειφθεί, όλα τα στοιχεία στο ``range(256)`` υποβάλλονται σε επεξεργασία." -#: glossary.rst:753 +#: glossary.rst:749 msgid "loader" msgstr "loader" -#: glossary.rst:755 +#: glossary.rst:751 +#, fuzzy msgid "" -"An object that loads a module. It must define a method named :meth:" -"`load_module`. A loader is typically returned by a :term:`finder`. See :pep:" -"`302` for details and :class:`importlib.abc.Loader` for an :term:`abstract " -"base class`." +"An object that loads a module. It must define the :meth:`!exec_module` " +"and :meth:`!create_module` methods to implement " +"the :class:`~importlib.abc.Loader` interface. A loader is typically returned " +"by a :term:`finder`. See also:" msgstr "" "Ένα αντικείμενο που φορτώνει ένα module. Πρέπει να ορίσει μια μέθοδο με το " -"όνομα :meth:`load_module`. Ένας loader συνήθως επιστρέφεται από έναν :term:" -"`finder`. Βλ. :pep:`302` για λεπτομέρειες και :class:`importlib.abc.Loader` " -"για μια :term:`abstract base class`." +"όνομα :meth:`load_module`. Ένας loader συνήθως επιστρέφεται από " +"έναν :term:`finder`. Βλ. :pep:`302` για λεπτομέρειες " +"και :class:`importlib.abc.Loader` για μια :term:`abstract base class`." + +#: glossary.rst:757 +msgid ":ref:`finders-and-loaders`" +msgstr "" + +#: glossary.rst:758 +msgid ":class:`importlib.abc.Loader`" +msgstr "" #: glossary.rst:759 +#, fuzzy +msgid ":pep:`302`" +msgstr "Βλ. :pep:`1`." + +#: glossary.rst:760 +msgid "locale encoding" +msgstr "τοπική κωδικοποίηση" + +#: glossary.rst:762 +msgid "" +"On Unix, it is the encoding of the LC_CTYPE locale. It can be set " +"with :func:`locale.setlocale(locale.LC_CTYPE, new_locale) " +"`." +msgstr "" +"Στο Unix, είναι η κωδικοποίηση της τοπική ρύθμισης LC_CTYPE. Μπορεί να " +"ρυθμιστεί με :func:`locale.setlocale(locale.LC_CTYPE, new_locale) " +"`." + +#: glossary.rst:765 +msgid "On Windows, it is the ANSI code page (ex: ``\"cp1252\"``)." +msgstr "Στα Windows, είναι η code page ANSI (π.χ. ``\"cp1252\"``)." + +#: glossary.rst:767 +msgid "" +"On Android and VxWorks, Python uses ``\"utf-8\"`` as the locale encoding." +msgstr "" +"Στο Android και το VxWorks, η Python χρησιμοποιεί το ``\"utf-8\"`` ως τοπική " +"κωδικοποίηση." + +#: glossary.rst:769 +#, fuzzy +msgid ":func:`locale.getencoding` can be used to get the locale encoding." +msgstr "" +"``locale.getencoding()`` μπορεί να χρησιμοποιηθεί για την ανάκτηση της " +"τοπικής κωδικοποίησης." + +#: glossary.rst:771 +msgid "See also the :term:`filesystem encoding and error handler`." +msgstr "Βλ. επίσης το :term:`filesystem encoding and error handler`." + +#: glossary.rst:772 msgid "magic method" msgstr "μαγική μέθοδος" -#: glossary.rst:763 +#: glossary.rst:776 msgid "An informal synonym for :term:`special method`." msgstr "Ένα άτυπο συνώνυμο για :term:`special method`." -#: glossary.rst:764 +#: glossary.rst:777 msgid "mapping" msgstr "mapping" -#: glossary.rst:766 +#: glossary.rst:779 msgid "" "A container object that supports arbitrary key lookups and implements the " -"methods specified in the :class:`collections.abc.Mapping` or :class:" -"`collections.abc.MutableMapping` :ref:`abstract base classes `. Examples include :class:`dict`, :class:" -"`collections.defaultdict`, :class:`collections.OrderedDict` and :class:" -"`collections.Counter`." +"methods specified in the :class:`collections.abc.Mapping` " +"or :class:`collections.abc.MutableMapping` :ref:`abstract base classes " +"`. Examples " +"include :class:`dict`, :class:`collections.defaultdict`, :class:`collections.OrderedDict` " +"and :class:`collections.Counter`." msgstr "" "Ένα αντικείμενο κοντέινερ που υποστηρίζει αυθαίρετες αναζητήσεις κλειδιών " -"και υλοποιεί τις μεθόδους που καθορίζονται στο :class:`collections.abc." -"Mapping` ή :class:`collections.abc.MutableMapping` :ref:`abstract base " -"classes `. Τα παραδείγματα περιλαμβάνουν :" -"class:`dict`, :class:`collections.defaultdict`, :class:`collections." -"OrderedDict` και :class:`collections.Counter`." - -#: glossary.rst:772 +"και υλοποιεί τις μεθόδους που καθορίζονται " +"στο :class:`collections.abc.Mapping` " +"ή :class:`collections.abc.MutableMapping` :ref:`abstract base classes " +"`. Τα παραδείγματα " +"περιλαμβάνουν :class:`dict`, :class:`collections.defaultdict`, :class:`collections.OrderedDict` " +"και :class:`collections.Counter`." + +#: glossary.rst:785 msgid "meta path finder" msgstr "meta path finder" -#: glossary.rst:774 +#: glossary.rst:787 msgid "" "A :term:`finder` returned by a search of :data:`sys.meta_path`. Meta path " "finders are related to, but different from :term:`path entry finders `." -#: glossary.rst:778 +#: glossary.rst:791 msgid "" "See :class:`importlib.abc.MetaPathFinder` for the methods that meta path " "finders implement." @@ -1879,11 +1981,11 @@ msgstr "" "Βλ. :class:`importlib.abc.MetaPathFinder` για τις μεθόδους που υλοποιούν οι " "meta path finders." -#: glossary.rst:780 +#: glossary.rst:793 msgid "metaclass" msgstr "μετα-κλάση" -#: glossary.rst:782 +#: glossary.rst:795 msgid "" "The class of a class. Class definitions create a class name, a class " "dictionary, and a list of base classes. The metaclass is responsible for " @@ -1907,36 +2009,36 @@ msgstr "" "ασφάλειας νημάτων, την παρακολούθηση δημιουργίας αντικειμένων, την υλοποίηση " "*singletons*, και πολλές άλλες εργασίες." -#: glossary.rst:792 +#: glossary.rst:805 msgid "More information can be found in :ref:`metaclasses`." msgstr "Περισσότερες πληροφορίες μπορούν να βρεθούν στο :ref:`metaclasses`." -#: glossary.rst:1131 +#: glossary.rst:1161 msgid "method" msgstr "μέθοδος" -#: glossary.rst:795 +#: glossary.rst:808 msgid "" "A function which is defined inside a class body. If called as an attribute " "of an instance of that class, the method will get the instance object as its " -"first :term:`argument` (which is usually called ``self``). See :term:" -"`function` and :term:`nested scope`." +"first :term:`argument` (which is usually called ``self``). " +"See :term:`function` and :term:`nested scope`." msgstr "" "Μια συνάρτηση που ορίζεται μέσα στο σώμα μιας κλάσης. Εάν καλείται ως " "χαρακτηριστικό μιας περίπτωσης αυτής της κλάσης, η μέθοδος θα λάβει " "αντικείμενο περίπτωσης ως πρώτο της :term:`argument` (το οποίο συνήθως " "ονομάζεται ``self``). Βλ. :term:`function` και :term:`nested scope`." -#: glossary.rst:799 +#: glossary.rst:812 msgid "method resolution order" msgstr "σειρά ανάλυσης μεθόδων" -#: glossary.rst:801 +#: glossary.rst:814 +#, fuzzy msgid "" "Method Resolution Order is the order in which base classes are searched for " -"a member during lookup. See `The Python 2.3 Method Resolution Order `_ for details of the algorithm " -"used by the Python interpreter since the 2.3 release." +"a member during lookup. See :ref:`python_2.3_mro` for details of the " +"algorithm used by the Python interpreter since the 2.3 release." msgstr "" "Η σειρά ανάλυσης μεθόδων είναι η σειρά με την οποία οι βασικές κλάσεις " "αναζητούνται για ένα μέλος κατά την αναζήτησης. Βλ. `The Python 2.3 Method " @@ -1944,11 +2046,11 @@ msgstr "" "λεπτομέρειες του αλγορίθμου που χρησιμοποιείται από τον διερμηνέα της Python " "από την έκδοση 2.3." -#: glossary.rst:805 +#: glossary.rst:817 msgid "module" msgstr "module" -#: glossary.rst:807 +#: glossary.rst:819 msgid "" "An object that serves as an organizational unit of Python code. Modules " "have a namespace containing arbitrary Python objects. Modules are loaded " @@ -1956,51 +2058,56 @@ msgid "" msgstr "" "Ένα αντικείμενο που χρησιμεύει ως οργανωτική μονάδα του κώδικα της Python. " "Τα modules έχουν έναν χώρο ονομάτων που περιέχει αυθαίρετα αντικείμενα " -"Python. Τα modules φορτώνονται στην Python με την διαδικασία :term:" -"`importing`." +"Python. Τα modules φορτώνονται στην Python με την " +"διαδικασία :term:`importing`." -#: glossary.rst:811 +#: glossary.rst:823 msgid "See also :term:`package`." msgstr "Βλ. επίσης :term:`package`." -#: glossary.rst:812 +#: glossary.rst:824 msgid "module spec" msgstr "τεχνικές προδιαγραφές module" -#: glossary.rst:814 +#: glossary.rst:826 msgid "" "A namespace containing the import-related information used to load a module. " "An instance of :class:`importlib.machinery.ModuleSpec`." msgstr "" "Ένα namespace που περιέχει τις πληροφορίες που σχετίζονται με την εισαγωγή " -"που χρησιμοποιούνται για την φόρτωση ενός module. Μια περίπτωση του :class:" -"`importlib.machinery.ModuleSpec`." +"που χρησιμοποιούνται για την φόρτωση ενός module. Μια περίπτωση " +"του :class:`importlib.machinery.ModuleSpec`." + +#: glossary.rst:829 +#, fuzzy +msgid "See also :ref:`module-specs`." +msgstr "Βλ. επίσης :term:`module`." -#: glossary.rst:816 +#: glossary.rst:830 msgid "MRO" msgstr "MRO" -#: glossary.rst:818 +#: glossary.rst:832 msgid "See :term:`method resolution order`." msgstr "Βλ. :term:`method resolution order`." -#: glossary.rst:819 +#: glossary.rst:833 msgid "mutable" msgstr "mutable" -#: glossary.rst:821 +#: glossary.rst:835 msgid "" -"Mutable objects can change their value but keep their :func:`id`. See also :" -"term:`immutable`." +"Mutable objects can change their value but keep their :func:`id`. See " +"also :term:`immutable`." msgstr "" "Τα ευμετάβλητα αντικείμενα μπορούν να αλλάξουν τις τιμές αλλά να κρατήσουν " "τα :func:`id`. Βλ. επίσης :term:`immutable`." -#: glossary.rst:823 +#: glossary.rst:837 msgid "named tuple" msgstr "named tuple" -#: glossary.rst:825 +#: glossary.rst:839 msgid "" "The term \"named tuple\" applies to any type or class that inherits from " "tuple and whose indexable elements are also accessible using named " @@ -2011,50 +2118,63 @@ msgstr "" "ευρετηριοποιηθούν είναι προσβάσιμα χρησιμοποιώντας επώνυμα χαρακτηριστικά. " "Ο τύπος ή η κλάση μπορεί να έχει και άλλα χαρακτηριστικά." -#: glossary.rst:829 +#: glossary.rst:843 msgid "" -"Several built-in types are named tuples, including the values returned by :" -"func:`time.localtime` and :func:`os.stat`. Another example is :data:`sys." -"float_info`::" +"Several built-in types are named tuples, including the values returned " +"by :func:`time.localtime` and :func:`os.stat`. Another example " +"is :data:`sys.float_info`::" msgstr "" "Πολλοί ενσωματωμένοι τύποι είναι named tuples, συμπεριλαμβανομένων των τιμών " "που επιστρέφονται από :func:`time.localtime` και :func:`os.stat`. Ένα άλλο " "παράδειγμα είναι το :data:`sys.float_info`::" -#: glossary.rst:840 +#: glossary.rst:847 +msgid "" +">>> sys.float_info[1] # indexed access\n" +"1024\n" +">>> sys.float_info.max_exp # named field access\n" +"1024\n" +">>> isinstance(sys.float_info, tuple) # kind of tuple\n" +"True" +msgstr "" + +#: glossary.rst:854 msgid "" "Some named tuples are built-in types (such as the above examples). " "Alternatively, a named tuple can be created from a regular class definition " "that inherits from :class:`tuple` and that defines named fields. Such a " -"class can be written by hand, or it can be created by inheriting :class:" -"`typing.NamedTuple`, or with the factory function :func:`collections." -"namedtuple`. The latter techniques also add some extra methods that may not " -"be found in hand-written or built-in named tuples." +"class can be written by hand, or it can be created by " +"inheriting :class:`typing.NamedTuple`, or with the factory " +"function :func:`collections.namedtuple`. The latter techniques also add " +"some extra methods that may not be found in hand-written or built-in named " +"tuples." msgstr "" "Ορισμένες αναγνωρισμένες πλειάδες είναι ενσωματωμένοι τύποι (όπως τα " "παραπάνω παραδείγματα). Εναλλακτικά, μια αναγνωρισμένη πλειάδα μπορεί να " -"δημιουργηθεί από έναν ορισμό κανονικής κλάσης που κληρονομεί από :class:" -"`tuple` και που ορίζει έγκυρα πεδία. Μια τέτοια κλάση μπορεί να είναι " -"γραμμένη με το χέρι ή μπορεί να δημιουργηθεί κληρονομώντας το :class:`typing." -"NamedTuple`, ή με την factory συνάρτηση :func:`collections.namedtuple`. Οι " -"τελευταίες τεχνικές προσθέτουν επίσης μερικές επιπλέον μεθόδους που μπορεί " -"να μην βρεθούν σε χειρόγραφες ή ενσωματωμένες πλειάδες με όνομα." - -#: glossary.rst:848 +"δημιουργηθεί από έναν ορισμό κανονικής κλάσης που κληρονομεί " +"από :class:`tuple` και που ορίζει έγκυρα πεδία. Μια τέτοια κλάση μπορεί να " +"είναι γραμμένη με το χέρι ή μπορεί να δημιουργηθεί κληρονομώντας " +"το :class:`typing.NamedTuple`, ή με την factory " +"συνάρτηση :func:`collections.namedtuple`. Οι τελευταίες τεχνικές προσθέτουν " +"επίσης μερικές επιπλέον μεθόδους που μπορεί να μην βρεθούν σε χειρόγραφες ή " +"ενσωματωμένες πλειάδες με όνομα." + +#: glossary.rst:862 msgid "namespace" msgstr "namespace" -#: glossary.rst:850 +#: glossary.rst:864 msgid "" "The place where a variable is stored. Namespaces are implemented as " "dictionaries. There are the local, global and built-in namespaces as well " "as nested namespaces in objects (in methods). Namespaces support modularity " -"by preventing naming conflicts. For instance, the functions :func:`builtins." -"open <.open>` and :func:`os.open` are distinguished by their namespaces. " -"Namespaces also aid readability and maintainability by making it clear which " -"module implements a function. For instance, writing :func:`random.seed` or :" -"func:`itertools.islice` makes it clear that those functions are implemented " -"by the :mod:`random` and :mod:`itertools` modules, respectively." +"by preventing naming conflicts. For instance, the " +"functions :func:`builtins.open <.open>` and :func:`os.open` are " +"distinguished by their namespaces. Namespaces also aid readability and " +"maintainability by making it clear which module implements a function. For " +"instance, writing :func:`random.seed` or :func:`itertools.islice` makes it " +"clear that those functions are implemented by the :mod:`random` " +"and :mod:`itertools` modules, respectively." msgstr "" "Το μέρος όπου αποθηκεύεται μια μεταβλητή. Τα namespaces υλοποιούνται ως " "λεξικά. Υπάρχουν οι τοπικοί, οι καθολικοί και οι ενσωματωμένοι namespaces " @@ -2062,35 +2182,48 @@ msgstr "" "παράδειγμα οι συναρτήσεις :func:`builtins.open <.open>` και :func:`os.open` " "διακρίνονται από τους χώρους ονομάτων τους. Οι χώροι ονομάτων βοηθούν " "επίσης την αναγνωσιμότητα και τη συντηρησιμότητα καθιστώντας σαφές ποιο " -"module υλοποιεί μια λειτουργία. Για παράδειγμα, γράφοντας :func:`random." -"seed` ή :func:`itertools.islice` καθιστά σαφές ότι αυτές οι συναρτήσεις " -"υλοποιούνται από τα module :mod:`random` και :mod:`itertools`, αντίστοιχα." +"module υλοποιεί μια λειτουργία. Για παράδειγμα, " +"γράφοντας :func:`random.seed` ή :func:`itertools.islice` καθιστά σαφές ότι " +"αυτές οι συναρτήσεις υλοποιούνται από τα module :mod:`random` " +"και :mod:`itertools`, αντίστοιχα." -#: glossary.rst:860 +#: glossary.rst:874 msgid "namespace package" msgstr "πακέτο namespace" -#: glossary.rst:862 +#: glossary.rst:876 +#, fuzzy msgid "" -"A :pep:`420` :term:`package` which serves only as a container for " -"subpackages. Namespace packages may have no physical representation, and " -"specifically are not like a :term:`regular package` because they have no " -"``__init__.py`` file." +"A :term:`package` which serves only as a container for subpackages. " +"Namespace packages may have no physical representation, and specifically are " +"not like a :term:`regular package` because they have no ``__init__.py`` file." msgstr "" "Ένα :pep:`420` :term:`package` που χρησιμεύει μόνο ως κοντέινερ για " "υποπακέτα. Τα πακέτα χώρου ονομάτων μπορεί να μην έχουν φυσική αναπαράσταση " "και συγκεκριμένα να μην είναι σαν ένα :term:`regular package` επειδή δεν " "έχουν το ``__init__.py`` αρχείο." -#: glossary.rst:867 +#: glossary.rst:881 +msgid "" +"Namespace packages allow several individually installable packages to have a " +"common parent package. Otherwise, it is recommended to use a :term:`regular " +"package`." +msgstr "" + +#: glossary.rst:884 +msgid "" +"For more information, see :pep:`420` and :ref:`reference-namespace-package`." +msgstr "" + +#: glossary.rst:886 msgid "See also :term:`module`." msgstr "Βλ. επίσης :term:`module`." -#: glossary.rst:868 +#: glossary.rst:887 msgid "nested scope" msgstr "nested scope" -#: glossary.rst:870 +#: glossary.rst:889 msgid "" "The ability to refer to a variable in an enclosing definition. For " "instance, a function defined inside another function can refer to variables " @@ -2107,28 +2240,30 @@ msgstr "" "Ομοίως, οι καθολικές μεταβλητές διαβάζουν και γράφουν στον καθολικό χώρο " "ονομάτων. Το :keyword:`nonlocal` επιτρέπει την εγγραφή σε εξωτερικά πεδία." -#: glossary.rst:877 +#: glossary.rst:896 msgid "new-style class" msgstr "κλάση νέου στυλ" -#: glossary.rst:879 +#: glossary.rst:898 msgid "" "Old name for the flavor of classes now used for all class objects. In " "earlier Python versions, only new-style classes could use Python's newer, " -"versatile features like :attr:`~object.__slots__`, descriptors, properties, :" -"meth:`~object.__getattribute__`, class methods, and static methods." +"versatile features like :attr:`~object.__slots__`, descriptors, " +"properties, :meth:`~object.__getattribute__`, class methods, and static " +"methods." msgstr "" "Το παλιό όνομα για το είδος των κλάσεων χρησιμοποιείται πλέον για όλα τα " "αντικείμενα. Σε παλιότερες εκδόσεις της Python, μόνο οι κλάσεις νέου στυλ " "μπορούσαν να χρησιμοποιήσουν τις νεότερες, ευέλικτες δυνατότητες της Python " -"όπως :attr:`~object.__slots__`, descriptors, ιδιότητες :meth:`~object." -"__getattribute__`, μέθοδοι κλάσης, και στατικές μέθοδοι." +"όπως :attr:`~object.__slots__`, descriptors, " +"ιδιότητες :meth:`~object.__getattribute__`, μέθοδοι κλάσης, και στατικές " +"μέθοδοι." -#: glossary.rst:884 +#: glossary.rst:903 msgid "object" msgstr "αντικείμενο" -#: glossary.rst:886 +#: glossary.rst:905 msgid "" "Any data with state (attributes or value) and defined behavior (methods). " "Also the ultimate base class of any :term:`new-style class`." @@ -2137,11 +2272,11 @@ msgstr "" "συμπεριφορά (μέθοδοι). Επίσης, η τελική βασική κλάση οποιασδήποτε :term:`new-" "style class`." -#: glossary.rst:889 +#: glossary.rst:908 msgid "package" msgstr "πακέτο" -#: glossary.rst:891 +#: glossary.rst:910 msgid "" "A Python :term:`module` which can contain submodules or recursively, " "subpackages. Technically, a package is a Python module with a ``__path__`` " @@ -2151,15 +2286,15 @@ msgstr "" "υποπακέτα. Τεχνικά, ένα πακέτο είναι μια λειτουργική μονάδα Python με ένα " "``__path__`` χαρακτηριστικό." -#: glossary.rst:895 +#: glossary.rst:914 msgid "See also :term:`regular package` and :term:`namespace package`." msgstr "Βλ. επίσης :term:`regular package` και :term:`namespace package`." -#: glossary.rst:896 +#: glossary.rst:915 msgid "parameter" msgstr "παράμετρος" -#: glossary.rst:898 +#: glossary.rst:917 msgid "" "A named entity in a :term:`function` (or method) definition that specifies " "an :term:`argument` (or in some cases, arguments) that the function can " @@ -2169,7 +2304,7 @@ msgstr "" "καθορίζει ένα :term:`argument` (ή σε ορισμένες περιπτώσεις, ορίσματα) που " "μπορεί να δεχθεί η συνάρτηση. Υπάρχουν πέντε είδη παραμέτρων:" -#: glossary.rst:902 +#: glossary.rst:921 msgid "" ":dfn:`positional-or-keyword`: specifies an argument that can be passed " "either :term:`positionally ` or as a :term:`keyword argument " @@ -2181,7 +2316,11 @@ msgstr "" "`. Αυτό είναι το προεπιλεγμένο είδος παραμέτρου, για παράδειγμα " "*foo* και *bar* στα ακόλουθα::" -#: glossary.rst:911 +#: glossary.rst:926 +msgid "def func(foo, bar=None): ..." +msgstr "" + +#: glossary.rst:930 msgid "" ":dfn:`positional-only`: specifies an argument that can be supplied only by " "position. Positional-only parameters can be defined by including a ``/`` " @@ -2193,7 +2332,11 @@ msgstr "" "χαρακτήρα ``/`` στη λίστα παραμέτρων του ορισμού συνάρτησης μετά από αυτές, " "για παράδειγμα *posonly1* και *posonly2* στα εξής::" -#: glossary.rst:920 +#: glossary.rst:935 +msgid "def func(posonly1, posonly2, /, positional_or_keyword): ..." +msgstr "" + +#: glossary.rst:939 msgid "" ":dfn:`keyword-only`: specifies an argument that can be supplied only by " "keyword. Keyword-only parameters can be defined by including a single var-" @@ -2207,7 +2350,11 @@ msgstr "" "του ορισμού συνάρτησης πριν από αυτές, για παράδειγμα *kw_only1* και " "*kw_only2* στα ακόλουθα::" -#: glossary.rst:928 +#: glossary.rst:945 +msgid "def func(arg, *, kw_only1, kw_only2): ..." +msgstr "" + +#: glossary.rst:947 msgid "" ":dfn:`var-positional`: specifies that an arbitrary sequence of positional " "arguments can be provided (in addition to any positional arguments already " @@ -2221,7 +2368,11 @@ msgstr "" "προσαρτώντας το όνομα της παραμέτρου με ``*``, για παράδειγμα *args* στα " "ακόλουθα::" -#: glossary.rst:936 +#: glossary.rst:953 +msgid "def func(*args, **kwargs): ..." +msgstr "" + +#: glossary.rst:955 msgid "" ":dfn:`var-keyword`: specifies that arbitrarily many keyword arguments can be " "provided (in addition to any keyword arguments already accepted by other " @@ -2234,7 +2385,7 @@ msgstr "" "οριστεί προσαρτώντας το όνομα της παραμέτρου με ``**``, για παράδειγμα " "*kwargs* όπως παραπάνω." -#: glossary.rst:942 +#: glossary.rst:961 msgid "" "Parameters can specify both optional and required arguments, as well as " "default values for some optional arguments." @@ -2243,45 +2394,45 @@ msgstr "" "απαιτούμενα ορίσματα , καθώς και προεπιλεγμένες τιμές για ορισμένα " "προαιρετικά ορίσματα." -#: glossary.rst:945 +#: glossary.rst:964 msgid "" "See also the :term:`argument` glossary entry, the FAQ question on :ref:`the " "difference between arguments and parameters `, " -"the :class:`inspect.Parameter` class, the :ref:`function` section, and :pep:" -"`362`." +"the :class:`inspect.Parameter` class, the :ref:`function` section, " +"and :pep:`362`." msgstr "" "Βλ. επίσης την :term:`argument` καταχώριση ευρετηρίου, την ερώτηση FAQ " "σχετικά με :ref:`η διαφορά μεταξύ ορισμάτων και παραμέτρων `, την κλάση :class:`inspect.Parameter`, την ενότητα :ref:" -"`function` και :pep:`362`." +"parameter>`, την κλάση :class:`inspect.Parameter`, την " +"ενότητα :ref:`function` και :pep:`362`." -#: glossary.rst:949 +#: glossary.rst:968 msgid "path entry" msgstr "path entry" -#: glossary.rst:951 +#: glossary.rst:970 msgid "" "A single location on the :term:`import path` which the :term:`path based " "finder` consults to find modules for importing." msgstr "" -"Μια μεμονωμένη τοποθεσία στο :term:`import path` την οποία συμβουλεύεται ο :" -"term:`path based finder` για να βρει modules για εισαγωγή." +"Μια μεμονωμένη τοποθεσία στο :term:`import path` την οποία συμβουλεύεται " +"ο :term:`path based finder` για να βρει modules για εισαγωγή." -#: glossary.rst:953 +#: glossary.rst:972 msgid "path entry finder" msgstr "path entry finder" -#: glossary.rst:955 +#: glossary.rst:974 msgid "" -"A :term:`finder` returned by a callable on :data:`sys.path_hooks` (i.e. a :" -"term:`path entry hook`) which knows how to locate modules given a :term:" -"`path entry`." +"A :term:`finder` returned by a callable on :data:`sys.path_hooks` (i.e. " +"a :term:`path entry hook`) which knows how to locate modules given " +"a :term:`path entry`." msgstr "" -"Ένας :term:`finder` που επιστρέφεται από έναν καλούμενο στο :data:`sys." -"path_hooks` (δηλαδή ένα :term:`path entry hook`) που ξέρει πως να εντοπίζει " -"modules με :term:`path entry`." +"Ένας :term:`finder` που επιστρέφεται από έναν καλούμενο " +"στο :data:`sys.path_hooks` (δηλαδή ένα :term:`path entry hook`) που ξέρει " +"πως να εντοπίζει modules με :term:`path entry`." -#: glossary.rst:959 +#: glossary.rst:978 msgid "" "See :class:`importlib.abc.PathEntryFinder` for the methods that path entry " "finders implement." @@ -2289,25 +2440,25 @@ msgstr "" "Βλ. :class:`importlib.abc.PathEntryFinder` για τις μεθόδους που ο entry " "finder διαδρομής υλοποιεί." -#: glossary.rst:961 +#: glossary.rst:980 msgid "path entry hook" msgstr "path entry hook" -#: glossary.rst:963 +#: glossary.rst:982 msgid "" "A callable on the :data:`sys.path_hooks` list which returns a :term:`path " "entry finder` if it knows how to find modules on a specific :term:`path " "entry`." msgstr "" -"Ένα καλούμενο στη λίστα :data:`sys.path_hooks`, το οποίο επιστρέφει ένα :" -"term:`path entry finder` εάν ξέρει πως να βρίσκει module σε μια " +"Ένα καλούμενο στη λίστα :data:`sys.path_hooks`, το οποίο επιστρέφει " +"ένα :term:`path entry finder` εάν ξέρει πως να βρίσκει module σε μια " "συγκεκριμένη :term:`path entry`." -#: glossary.rst:966 +#: glossary.rst:985 msgid "path based finder" msgstr "path based finder" -#: glossary.rst:968 +#: glossary.rst:987 msgid "" "One of the default :term:`meta path finders ` which " "searches an :term:`import path` for modules." @@ -2315,36 +2466,36 @@ msgstr "" "Ένα από τα προεπιλεγμένα :term:`meta path finders ` που " "αναζητά ένα :term:`import path` για modules." -#: glossary.rst:970 +#: glossary.rst:989 msgid "path-like object" msgstr "path-like αντικείμενο" -#: glossary.rst:972 +#: glossary.rst:991 msgid "" -"An object representing a file system path. A path-like object is either a :" -"class:`str` or :class:`bytes` object representing a path, or an object " -"implementing the :class:`os.PathLike` protocol. An object that supports the :" -"class:`os.PathLike` protocol can be converted to a :class:`str` or :class:" -"`bytes` file system path by calling the :func:`os.fspath` function; :func:" -"`os.fsdecode` and :func:`os.fsencode` can be used to guarantee a :class:" -"`str` or :class:`bytes` result instead, respectively. Introduced by :pep:" -"`519`." +"An object representing a file system path. A path-like object is either " +"a :class:`str` or :class:`bytes` object representing a path, or an object " +"implementing the :class:`os.PathLike` protocol. An object that supports " +"the :class:`os.PathLike` protocol can be converted to a :class:`str` " +"or :class:`bytes` file system path by calling the :func:`os.fspath` " +"function; :func:`os.fsdecode` and :func:`os.fsencode` can be used to " +"guarantee a :class:`str` or :class:`bytes` result instead, respectively. " +"Introduced by :pep:`519`." msgstr "" "Ένα αντικείμενο που αντιπροσωπεύει ένα path συστήματος αρχείων. Ένα " "αντικείμενο path είναι είτε ένα αντικείμενο :class:`str` ή :class:`bytes` " -"που αντιπροσωπεύει ένα path ή ένα αντικείμενο που υλοποιεί το πρωτόκολλο :" -"class:`os.PathLike`. Ένα αντικείμενο που υποστηρίζει το πρωτόκολλο :class:" -"`os.PathLike` μπορεί να μετατραπεί σε path συστήματος αρχείων :class:`str` " -"ή :class:`bytes` καλώντας την συνάρτηση :func:`os.fspath`' τα :func:`os." -"fsdecode` και :func:`os.fsencode` μπορούν να χρησιμοποιηθούν για την εγγύηση " -"ενός αποτελέσματος :class:`str` ή :class:`bytes`, αντίστοιχα. Εισήχθη από " -"τον :pep:`519`." +"που αντιπροσωπεύει ένα path ή ένα αντικείμενο που υλοποιεί το " +"πρωτόκολλο :class:`os.PathLike`. Ένα αντικείμενο που υποστηρίζει το " +"πρωτόκολλο :class:`os.PathLike` μπορεί να μετατραπεί σε path συστήματος " +"αρχείων :class:`str` ή :class:`bytes` καλώντας την " +"συνάρτηση :func:`os.fspath`' τα :func:`os.fsdecode` και :func:`os.fsencode` " +"μπορούν να χρησιμοποιηθούν για την εγγύηση ενός αποτελέσματος :class:`str` " +"ή :class:`bytes`, αντίστοιχα. Εισήχθη από τον :pep:`519`." -#: glossary.rst:980 +#: glossary.rst:999 msgid "PEP" msgstr "PEP" -#: glossary.rst:982 +#: glossary.rst:1001 msgid "" "Python Enhancement Proposal. A PEP is a design document providing " "information to the Python community, or describing a new feature for Python " @@ -2357,7 +2508,7 @@ msgstr "" "μια συνοπτική τεχνική προδιαγραφή και μια λογική για τα προτεινόμενα " "χαρακτηριστικά." -#: glossary.rst:988 +#: glossary.rst:1007 msgid "" "PEPs are intended to be the primary mechanisms for proposing major new " "features, for collecting community input on an issue, and for documenting " @@ -2371,32 +2522,32 @@ msgstr "" "στην Python. Ο συγγραφέας του PEP είναι υπεύθυνος για την οικοδόμηση " "συναίνεσης εντός της κοινότητας και την τεκμηρίωση αντίθετων απόψεων." -#: glossary.rst:994 +#: glossary.rst:1013 msgid "See :pep:`1`." msgstr "Βλ. :pep:`1`." -#: glossary.rst:995 +#: glossary.rst:1014 msgid "portion" msgstr "τμήμα" -#: glossary.rst:997 +#: glossary.rst:1016 msgid "" "A set of files in a single directory (possibly stored in a zip file) that " "contribute to a namespace package, as defined in :pep:`420`." msgstr "" "Ένα σύνολο από αρχεία σε έναν μόνο κατάλογο (ενδεχομένως αποθηκευμένο σε " -"αρχείο *zip*) που συμβάλλουν σε ένα namespace πακέτο, όπως ορίζεται στο :pep:" -"`420`." +"αρχείο *zip*) που συμβάλλουν σε ένα namespace πακέτο, όπως ορίζεται " +"στο :pep:`420`." -#: glossary.rst:999 +#: glossary.rst:1018 msgid "positional argument" msgstr "όρισμα θέσης" -#: glossary.rst:1002 +#: glossary.rst:1021 msgid "provisional API" msgstr "provisional API" -#: glossary.rst:1004 +#: glossary.rst:1023 msgid "" "A provisional API is one which has been deliberately excluded from the " "standard library's backwards compatibility guarantees. While major changes " @@ -2415,7 +2566,7 @@ msgstr "" "αποκαλυφθούν σοβαρά θεμελιώδη ελαττώματα που παραλείφθηκαν πριν από τη " "συμπερίληψη του API." -#: glossary.rst:1013 +#: glossary.rst:1032 msgid "" "Even for provisional APIs, backwards incompatible changes are seen as a " "\"solution of last resort\" - every attempt will still be made to find a " @@ -2425,7 +2576,7 @@ msgstr "" "\"λύση έσχατης ανάγκης\"- θα εξακολουθεί να γίνεται κάθε προσπάθεια για να " "βρεθεί μια λύση backwards συμβατή σε τυχόν εντοπισμένα προβλήματα." -#: glossary.rst:1017 +#: glossary.rst:1036 msgid "" "This process allows the standard library to continue to evolve over time, " "without locking in problematic design errors for extended periods of time. " @@ -2436,19 +2587,19 @@ msgstr "" "σφάλματα σχεδιασμού για εκτεταμένες χρονικές περιόδους. Βλ. :pep:`411` για " "περισσότερες λεπτομέρειες." -#: glossary.rst:1020 +#: glossary.rst:1039 msgid "provisional package" msgstr "provisional πακέτο" -#: glossary.rst:1022 +#: glossary.rst:1041 msgid "See :term:`provisional API`." msgstr "Βλ. :term:`provisional API`." -#: glossary.rst:1023 +#: glossary.rst:1042 msgid "Python 3000" msgstr "Python 3000" -#: glossary.rst:1025 +#: glossary.rst:1044 msgid "" "Nickname for the Python 3.x release line (coined long ago when the release " "of version 3 was something in the distant future.) This is also abbreviated " @@ -2458,11 +2609,11 @@ msgstr "" "όταν η κυκλοφορία της έκδοσης 3 ήταν κάτι στο μακρινό μέλλον.) Αυτό " "ονομάζεται επίσης ως συντομογραφία \"Py3k\"." -#: glossary.rst:1028 +#: glossary.rst:1047 msgid "Pythonic" msgstr "Pythonic" -#: glossary.rst:1030 +#: glossary.rst:1049 msgid "" "An idea or piece of code which closely follows the most common idioms of the " "Python language, rather than implementing code using concepts common to " @@ -2479,15 +2630,27 @@ msgstr "" "κατασκευής, έτσι οι άνθρωποι που δεν είναι εξοικειωμένοι με την Python " "χρησιμοποιούν μερικές φορές έναν αριθμητικό μετρητή::" -#: glossary.rst:1040 +#: glossary.rst:1056 +msgid "" +"for i in range(len(food)):\n" +" print(food[i])" +msgstr "" + +#: glossary.rst:1059 msgid "As opposed to the cleaner, Pythonic method::" msgstr "Αντίθετα, μια πιο καθαρή μέθοδος Pythonic::" -#: glossary.rst:1044 +#: glossary.rst:1061 +msgid "" +"for piece in food:\n" +" print(piece)" +msgstr "" + +#: glossary.rst:1063 msgid "qualified name" msgstr "αναγνωρισμένο όνομα" -#: glossary.rst:1046 +#: glossary.rst:1065 msgid "" "A dotted name showing the \"path\" from a module's global scope to a class, " "function or method defined in that module, as defined in :pep:`3155`. For " @@ -2499,21 +2662,43 @@ msgstr "" "ενότητα, όπως ορίζεται στο :pep:`3155`. Για συναρτήσεις και κλάσεις ανώτατου " "επιπέδου, το αναγνωρισμένο όνομα είναι ίδιο με το όνομα του αντικειμένου::" -#: glossary.rst:1063 +#: glossary.rst:1070 +msgid "" +">>> class C:\n" +"... class D:\n" +"... def meth(self):\n" +"... pass\n" +"...\n" +">>> C.__qualname__\n" +"'C'\n" +">>> C.D.__qualname__\n" +"'C.D'\n" +">>> C.D.meth.__qualname__\n" +"'C.D.meth'" +msgstr "" + +#: glossary.rst:1082 msgid "" "When used to refer to modules, the *fully qualified name* means the entire " -"dotted path to the module, including any parent packages, e.g. ``email.mime." -"text``::" +"dotted path to the module, including any parent packages, e.g. " +"``email.mime.text``::" msgstr "" "Όταν χρησιμοποιείται για αναφορά σε modules , το *πλήρως αναγνωρισμένο " "όνομα* σημαίνει ολόκληρο το διακεκομμένο path προς το module, " "συμπεριλαμβανομένων τυχόν γονικών πακέτων π.χ. ``email.mime.text``::" -#: glossary.rst:1070 +#: glossary.rst:1086 +msgid "" +">>> import email.mime.text\n" +">>> email.mime.text.__name__\n" +"'email.mime.text'" +msgstr "" + +#: glossary.rst:1089 msgid "reference count" msgstr "πλήθος αναφοράς" -#: glossary.rst:1072 +#: glossary.rst:1091 msgid "" "The number of references to an object. When the reference count of an " "object drops to zero, it is deallocated. Some objects are \"immortal\" and " @@ -2532,27 +2717,27 @@ msgstr "" "συνάρτηση :func:`sys.getrefcount` για να επιστρέψουν το πλήθος αναφοράς για " "ένα συγκεκριμένο αντικείμενο." -#: glossary.rst:1080 +#: glossary.rst:1099 msgid "regular package" msgstr "κανονικό πακέτο" -#: glossary.rst:1082 +#: glossary.rst:1101 msgid "" -"A traditional :term:`package`, such as a directory containing an ``__init__." -"py`` file." +"A traditional :term:`package`, such as a directory containing an " +"``__init__.py`` file." msgstr "" "Ένα παραδοσιακό :term:`package`, όπως ένας κατάλογος που περιέχει ένα " "``__init__.py`` αρχείο." -#: glossary.rst:1085 +#: glossary.rst:1104 msgid "See also :term:`namespace package`." msgstr "Βλ. επίσης :term:`namespace package`." -#: glossary.rst:1086 +#: glossary.rst:1105 msgid "__slots__" msgstr "__slots__" -#: glossary.rst:1088 +#: glossary.rst:1107 msgid "" "A declaration inside a class that saves memory by pre-declaring space for " "instance attributes and eliminating instance dictionaries. Though popular, " @@ -2566,71 +2751,73 @@ msgstr "" "σωστή και προορίζεται καλύτερα για σπάνιες περιπτώσεις όπου υπάρχει μεγάλος " "αριθμός στιγμιοτύπων σε μια εφαρμογή κρίσιμης-μνήμης." -#: glossary.rst:1093 +#: glossary.rst:1112 msgid "sequence" msgstr "ακολουθία" -#: glossary.rst:1095 +#: glossary.rst:1114 +#, fuzzy msgid "" "An :term:`iterable` which supports efficient element access using integer " -"indices via the :meth:`~object.__getitem__` special method and defines a :" -"meth:`~object.__len__` method that returns the length of the sequence. Some " -"built-in sequence types are :class:`list`, :class:`str`, :class:`tuple`, " -"and :class:`bytes`. Note that :class:`dict` also supports :meth:`~object." -"__getitem__` and :meth:`!__len__`, but is considered a mapping rather than a " -"sequence because the lookups use arbitrary :term:`immutable` keys rather " -"than integers." +"indices via the :meth:`~object.__getitem__` special method and defines " +"a :meth:`~object.__len__` method that returns the length of the sequence. " +"Some built-in sequence types " +"are :class:`list`, :class:`str`, :class:`tuple`, and :class:`bytes`. Note " +"that :class:`dict` also supports :meth:`~object.__getitem__` and :meth:`!" +"__len__`, but is considered a mapping rather than a sequence because the " +"lookups use arbitrary :term:`hashable` keys rather than integers." msgstr "" "Ένας :term:`iterable` που υποστηρίζει την αποτελεσματική πρόσβαση στο " -"στοιχείο χρησιμοποιώντας ακέραιους δείκτες μέσω της ειδική μεθόδου :meth:" -"`~object.__getitem__` και ορίζει μια μέθοδο :meth:`~object.__len__` που " -"επιστρέφει το μήκος της ακολουθίας. Ορισμένοι ενσωματωμένοι τύποι ακολουθιών " +"στοιχείο χρησιμοποιώντας ακέραιους δείκτες μέσω της ειδική " +"μεθόδου :meth:`~object.__getitem__` και ορίζει μια " +"μέθοδο :meth:`~object.__len__` που επιστρέφει το μήκος της ακολουθίας. " +"Ορισμένοι ενσωματωμένοι τύποι ακολουθιών " "είναι :class:`list`, :class:`str`, :class:`tuple`, και :class:`bytes`. " -"Σημειώστε ότι το :class:`dict` υποστηρίζει επίσης :meth:`~object." -"__getitem__` και :meth:`!__len__`, αλλά θεωρείται αντιστοίχιση και όχι " -"ακολουθία επειδή οι αναζητήσεις χρησιμοποιούν αυθαίρετα :term:`immutable` " -"κλειδιά παρά ακέραιοι." +"Σημειώστε ότι το :class:`dict` υποστηρίζει " +"επίσης :meth:`~object.__getitem__` και :meth:`!__len__`, αλλά θεωρείται " +"αντιστοίχιση και όχι ακολουθία επειδή οι αναζητήσεις χρησιμοποιούν " +"αυθαίρετα :term:`immutable` κλειδιά παρά ακέραιοι." -#: glossary.rst:1104 +#: glossary.rst:1123 msgid "" "The :class:`collections.abc.Sequence` abstract base class defines a much " -"richer interface that goes beyond just :meth:`~object.__getitem__` and :meth:" -"`~object.__len__`, adding :meth:`!count`, :meth:`!index`, :meth:`~object." -"__contains__`, and :meth:`~object.__reversed__`. Types that implement this " -"expanded interface can be registered explicitly using :func:`~abc.ABCMeta." -"register`. For more documentation on sequence methods generally, see :ref:" -"`Common Sequence Operations `." +"richer interface that goes beyond just :meth:`~object.__getitem__` " +"and :meth:`~object.__len__`, adding :meth:`!count`, :meth:`!" +"index`, :meth:`~object.__contains__`, and :meth:`~object.__reversed__`. " +"Types that implement this expanded interface can be registered explicitly " +"using :func:`~abc.ABCMeta.register`. For more documentation on sequence " +"methods generally, see :ref:`Common Sequence Operations `." msgstr "" "Η αφηρημένη βασική κλάση :class:`collections.abc.Sequence` ορίζει μια πολύ " -"πιο πλούσια διεπαφή που ξεπερνά τα απλά `~object.__getitem__` and :meth:" -"`~object.__len__`, adding :meth:`!count`, :meth:`!index`, :meth:`~object." -"__contains__`, και :meth:`~object.__reversed__`. Οι τύποι που υλοποιούν " -"αυτήν την διευρυμένη διεπαφή μπορούν να καταχωρηθούν ρητά χρησιμοποιώντας :" -"func:`~abc.ABCMeta.register`. Για περισσότερη τεκμηρίωση σχετικά με τις " -"μεθόδους ακολουθίας γενικά, ανατρέξτε στο :ref:`Common Sequence Operations " -"`." - -#: glossary.rst:1113 +"πιο πλούσια διεπαφή που ξεπερνά τα απλά `~object.__getitem__` " +"and :meth:`~object.__len__`, adding :meth:`!count`, :meth:`!" +"index`, :meth:`~object.__contains__`, και :meth:`~object.__reversed__`. Οι " +"τύποι που υλοποιούν αυτήν την διευρυμένη διεπαφή μπορούν να καταχωρηθούν " +"ρητά χρησιμοποιώντας :func:`~abc.ABCMeta.register`. Για περισσότερη " +"τεκμηρίωση σχετικά με τις μεθόδους ακολουθίας γενικά, ανατρέξτε " +"στο :ref:`Common Sequence Operations `." + +#: glossary.rst:1132 msgid "set comprehension" msgstr "set comprehension" -#: glossary.rst:1115 +#: glossary.rst:1134 msgid "" "A compact way to process all or part of the elements in an iterable and " "return a set with the results. ``results = {c for c in 'abracadabra' if c " -"not in 'abc'}`` generates the set of strings ``{'r', 'd'}``. See :ref:" -"`comprehensions`." +"not in 'abc'}`` generates the set of strings ``{'r', 'd'}``. " +"See :ref:`comprehensions`." msgstr "" "Ένας συμπαγής τρόπος για να επεξεργαστείτε όλα ή μέρος των στοιχείων σε ένα " "iterable και να επιστραφεί ένα σύνολο με τα αποτελέσματα. ``results = {c for " "c in 'abracadabra' if c not in 'abc'}`` δημιουργεί το σύνολο συμβολοσειρών " "``{'r', 'd'}``. Βλ. :ref:`comprehensions`." -#: glossary.rst:1119 +#: glossary.rst:1138 msgid "single dispatch" msgstr "μοναδικό dispatch" -#: glossary.rst:1121 +#: glossary.rst:1140 msgid "" "A form of :term:`generic function` dispatch where the implementation is " "chosen based on the type of a single argument." @@ -2638,77 +2825,100 @@ msgstr "" "Μια μορφή dispatch :term:`generic function` όπου η υλοποίηση επιλέγεται με " "βάση τον τύπο ενός μεμονωμένου ορίσματος." -#: glossary.rst:1123 +#: glossary.rst:1142 msgid "slice" msgstr "slice" -#: glossary.rst:1125 +#: glossary.rst:1144 msgid "" "An object usually containing a portion of a :term:`sequence`. A slice is " "created using the subscript notation, ``[]`` with colons between numbers " "when several are given, such as in ``variable_name[1:3:5]``. The bracket " "(subscript) notation uses :class:`slice` objects internally." msgstr "" -"Ένα αντικείμενο που συνήθως περιέχει ένα τμήμα μιας ακολουθίας :term:" -"`sequence`. Δημιουργείται ένα slice χρησιμοποιώντας τη σημείωση subscript, " -"``[]`` με άνω και κάτω τελείες μεταξύ αριθμών όταν δίνονται πολλοί, όπως στο " -"``variable_name[1:3:5]``. Η σημείωση αγκύλης (subscript) χρησιμοποιεί " -"εσωτερικά αντικείμενα :class:`slice`." +"Ένα αντικείμενο που συνήθως περιέχει ένα τμήμα μιας " +"ακολουθίας :term:`sequence`. Δημιουργείται ένα slice χρησιμοποιώντας τη " +"σημείωση subscript, ``[]`` με άνω και κάτω τελείες μεταξύ αριθμών όταν " +"δίνονται πολλοί, όπως στο ``variable_name[1:3:5]``. Η σημείωση αγκύλης " +"(subscript) χρησιμοποιεί εσωτερικά αντικείμενα :class:`slice`." + +#: glossary.rst:1148 +msgid "soft deprecated" +msgstr "" + +#: glossary.rst:1150 +msgid "" +"A soft deprecated API should not be used in new code, but it is safe for " +"already existing code to use it. The API remains documented and tested, but " +"will not be enhanced further." +msgstr "" + +#: glossary.rst:1154 +msgid "" +"Soft deprecation, unlike normal deprecation, does not plan on removing the " +"API and will not emit warnings." +msgstr "" -#: glossary.rst:1129 +#: glossary.rst:1157 +msgid "" +"See `PEP 387: Soft Deprecation `_." +msgstr "" + +#: glossary.rst:1159 msgid "special method" msgstr "ειδική μέθοδος" -#: glossary.rst:1133 +#: glossary.rst:1163 msgid "" "A method that is called implicitly by Python to execute a certain operation " "on a type, such as addition. Such methods have names starting and ending " -"with double underscores. Special methods are documented in :ref:" -"`specialnames`." +"with double underscores. Special methods are documented " +"in :ref:`specialnames`." msgstr "" "Μια μέθοδος που καλείται σιωπηρά από την Python για να εκτελέσει μια " "συγκεκριμένη λειτουργία σε έναν τύπο, όπως η προσθήκη. Τέτοιες μέθοδοι " "έχουνε ονόματα που ξεκινούν και τελειώνουν με διπλές κάτω παύλες. Οι ειδικές " "μέθοδοι τεκμηριώνονται στο :ref:`specialnames`." -#: glossary.rst:1137 +#: glossary.rst:1167 msgid "statement" msgstr "δήλωση" -#: glossary.rst:1139 +#: glossary.rst:1169 msgid "" "A statement is part of a suite (a \"block\" of code). A statement is either " -"an :term:`expression` or one of several constructs with a keyword, such as :" -"keyword:`if`, :keyword:`while` or :keyword:`for`." +"an :term:`expression` or one of several constructs with a keyword, such " +"as :keyword:`if`, :keyword:`while` or :keyword:`for`." msgstr "" "Μια πρόταση είναι μέρος μιας σουίτας (ένα \"μπλοκ\" κώδικα). Μια πρόταση " "είναι είτε ένας :term:`expression` είτε μια από πολλές δομές με μια λέξη-" "κλειδί όπως :keyword:`if`, :keyword:`while` ή :keyword:`for`." -#: glossary.rst:1142 +#: glossary.rst:1172 msgid "static type checker" msgstr "ελεγκτής στατικού τύπου" -#: glossary.rst:1144 +#: glossary.rst:1174 msgid "" "An external tool that reads Python code and analyzes it, looking for issues " -"such as incorrect types. See also :term:`type hints ` and the :" -"mod:`typing` module." +"such as incorrect types. See also :term:`type hints ` and " +"the :mod:`typing` module." msgstr "" "Ένα εξωτερικό εργαλείο όπου διαβάζει τον Python κώδικα και τον αναλύει, " "αναζητώντας προβλήματα όπως λανθασμένοι τύποι. Βλ. επίσης :term:`type hints " "` και το module :mod:`typing`." -#: glossary.rst:1147 +#: glossary.rst:1177 msgid "strong reference" msgstr "strong reference" -#: glossary.rst:1149 +#: glossary.rst:1179 msgid "" "In Python's C API, a strong reference is a reference to an object which is " "owned by the code holding the reference. The strong reference is taken by " -"calling :c:func:`Py_INCREF` when the reference is created and released with :" -"c:func:`Py_DECREF` when the reference is deleted." +"calling :c:func:`Py_INCREF` when the reference is created and released " +"with :c:func:`Py_DECREF` when the reference is deleted." msgstr "" "Στο C API της Python, μια ισχυρή αναφορά είναι μια αναφορά σε ένα " "αντικείμενο που ανήκει στον κώδικα που περιέχει την αναφορά. Η ισχυρή " @@ -2716,7 +2926,7 @@ msgstr "" "δημιουργείται και απελευθερώνεται με :c:func:`Py_DECREF` όταν διαγραφεί η " "αναφορά." -#: glossary.rst:1155 +#: glossary.rst:1185 msgid "" "The :c:func:`Py_NewRef` function can be used to create a strong reference to " "an object. Usually, the :c:func:`Py_DECREF` function must be called on the " @@ -2724,19 +2934,20 @@ msgid "" "leaking one reference." msgstr "" "Η συνάρτηση :c:func:`Py_NewRef` μπορεί να χρησιμοποιηθεί για τη δημιουργία " -"ισχυρής αναφοράς σε ένα αντικείμενο. Συνήθως, η συνάρτηση :c:func:" -"`Py_DECREF` πρέπει να καλείται στην ισχυρή αναφορά πριν βγει από το εύρος " -"της ισχυρής αναφοράς, για να αποφευχθεί η διαρροή μιας αναφοράς." +"ισχυρής αναφοράς σε ένα αντικείμενο. Συνήθως, η " +"συνάρτηση :c:func:`Py_DECREF` πρέπει να καλείται στην ισχυρή αναφορά πριν " +"βγει από το εύρος της ισχυρής αναφοράς, για να αποφευχθεί η διαρροή μιας " +"αναφοράς." -#: glossary.rst:1160 +#: glossary.rst:1190 msgid "See also :term:`borrowed reference`." msgstr "Βλ. επίσης :term:`borrowed reference`." -#: glossary.rst:1161 +#: glossary.rst:1191 msgid "text encoding" msgstr "κωδικοποίηση κειμένου" -#: glossary.rst:1163 +#: glossary.rst:1193 msgid "" "A string in Python is a sequence of Unicode code points (in range " "``U+0000``--``U+10FFFF``). To store or transfer a string, it needs to be " @@ -2746,7 +2957,7 @@ msgstr "" "εύρος ``U+0000``--``U+10FFFF``). Για να αποθηκεύσετε ή να μεταφέρετε μια " "συμβολοσειρά, πρέπει να σειριοποιηθεί ως δυαδική ακολουθία." -#: glossary.rst:1167 +#: glossary.rst:1197 msgid "" "Serializing a string into a sequence of bytes is known as \"encoding\", and " "recreating the string from the sequence of bytes is known as \"decoding\"." @@ -2755,7 +2966,7 @@ msgstr "" "\"κωδικοποίηση\" , και η αναδημιουργία της συμβολοσειράς από την δυαδική " "ακολουθία είναι γνωστή ως \"αποκωδικοποίηση\"." -#: glossary.rst:1170 +#: glossary.rst:1200 msgid "" "There are a variety of different text serialization :ref:`codecs `, which are collectively referred to as \"text encodings\"." @@ -2764,38 +2975,40 @@ msgstr "" "`, οι οποίοι συλλογικά αναφέρονται ως \"κωδικοποιήσεις " "κειμένου\"." -#: glossary.rst:1173 +#: glossary.rst:1203 msgid "text file" msgstr "αρχείο κειμένου" -#: glossary.rst:1175 +#: glossary.rst:1205 msgid "" "A :term:`file object` able to read and write :class:`str` objects. Often, a " -"text file actually accesses a byte-oriented datastream and handles the :term:" -"`text encoding` automatically. Examples of text files are files opened in " -"text mode (``'r'`` or ``'w'``), :data:`sys.stdin`, :data:`sys.stdout`, and " -"instances of :class:`io.StringIO`." +"text file actually accesses a byte-oriented datastream and handles " +"the :term:`text encoding` automatically. Examples of text files are files " +"opened in text mode (``'r'`` or " +"``'w'``), :data:`sys.stdin`, :data:`sys.stdout`, and instances " +"of :class:`io.StringIO`." msgstr "" -"Ένα :term:`file object` ικανό να διαβάζει και να γράφει αντικείμενα :class:" -"`str`. Συχνά, ένα αρχείο κειμένου αποκτά πραγματικά πρόσβαση σε μια ροή " -"δυαδική ροή δεδομένων και χειρίζεται αυτόματα την :term:`text encoding`. " -"Παραδείγματα αρχείων κειμένου είναι αρχεία που ανοίγουν σε λειτουργία " -"κειμένου (``'r'`` ή ``'w'``), :data:`sys.stdin`, :data:`sys.stdout`, και " -"στιγμιότυπα του :class:`io.StringIO`." +"Ένα :term:`file object` ικανό να διαβάζει και να γράφει " +"αντικείμενα :class:`str`. Συχνά, ένα αρχείο κειμένου αποκτά πραγματικά " +"πρόσβαση σε μια ροή δυαδική ροή δεδομένων και χειρίζεται αυτόματα " +"την :term:`text encoding`. Παραδείγματα αρχείων κειμένου είναι αρχεία που " +"ανοίγουν σε λειτουργία κειμένου (``'r'`` ή " +"``'w'``), :data:`sys.stdin`, :data:`sys.stdout`, και στιγμιότυπα " +"του :class:`io.StringIO`." -#: glossary.rst:1182 +#: glossary.rst:1212 msgid "" -"See also :term:`binary file` for a file object able to read and write :term:" -"`bytes-like objects `." +"See also :term:`binary file` for a file object able to read and " +"write :term:`bytes-like objects `." msgstr "" "Βλ. επίσης :term:`binary file` για ένα αντικείμενο αρχείου με δυνατότητα " "ανάγνωσης και εγγραφής :term:`δυαδικά αντικείμενα `." -#: glossary.rst:1184 +#: glossary.rst:1214 msgid "triple-quoted string" msgstr "συμβολοσειρά τριπλών εισαγωγικών" -#: glossary.rst:1186 +#: glossary.rst:1216 msgid "" "A string which is bound by three instances of either a quotation mark (\") " "or an apostrophe ('). While they don't provide any functionality not " @@ -2813,32 +3026,34 @@ msgstr "" "γραμμές χωρίς τη χρήση του χαρακτήρα συνέχεια, καθιστώντας τα ιδιαίτερα " "χρήσιμα κατά τη σύνταξη εγγράφων με συμβολοσειρές." -#: glossary.rst:1193 +#: glossary.rst:1223 msgid "type" msgstr "τύπος" -#: glossary.rst:1195 +#: glossary.rst:1225 +#, fuzzy msgid "" "The type of a Python object determines what kind of object it is; every " -"object has a type. An object's type is accessible as its :attr:`~instance." -"__class__` attribute or can be retrieved with ``type(obj)``." +"object has a type. An object's type is accessible as " +"its :attr:`~object.__class__` attribute or can be retrieved with " +"``type(obj)``." msgstr "" "Ο τύπος ενός Python αντικειμένου καθορίζει τι είδους αντικείμενο είναι' κάθε " "αντικείμενο έχει έναν τύπο. Ο τύπος ενός αντικειμένου είναι προσβάσιμος ως " "το χαρακτηριστικό :attr:`~instance.__class__` ή μπορεί να ανακτηθεί με " "``type(obj)``." -#: glossary.rst:1199 +#: glossary.rst:1229 msgid "type alias" msgstr "type alias" -#: glossary.rst:1201 +#: glossary.rst:1231 msgid "A synonym for a type, created by assigning the type to an identifier." msgstr "" "Ένα συνώνυμο για έναν τύπο, που δημιουργείται με την ανάθεση τύπου σε ένα " "αναγνωριστικό." -#: glossary.rst:1203 +#: glossary.rst:1233 msgid "" "Type aliases are useful for simplifying :term:`type hints `. For " "example::" @@ -2846,20 +3061,35 @@ msgstr "" "Τα type aliases είναι χρήσιμα για την απλοποίηση :term:`type alias `. Για παράδειγμα::" -#: glossary.rst:1210 +#: glossary.rst:1236 +msgid "" +"def remove_gray_shades(\n" +" colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:\n" +" pass" +msgstr "" + +#: glossary.rst:1240 msgid "could be made more readable like this::" msgstr "μπορεί να γίνει πιο ευανάγνωστο όπως::" -#: glossary.rst:1231 +#: glossary.rst:1242 +msgid "" +"Color = tuple[int, int, int]\n" +"\n" +"def remove_gray_shades(colors: list[Color]) -> list[Color]:\n" +" pass" +msgstr "" + +#: glossary.rst:1261 msgid "See :mod:`typing` and :pep:`484`, which describe this functionality." msgstr "" "Βλ. :mod:`typing` και :pep:`484`, που περιγράφει αυτήν την λειτουργικότητα." -#: glossary.rst:1218 +#: glossary.rst:1248 msgid "type hint" msgstr "type hint" -#: glossary.rst:1220 +#: glossary.rst:1250 msgid "" "An :term:`annotation` that specifies the expected type for a variable, a " "class attribute, or a function parameter or return value." @@ -2868,7 +3098,7 @@ msgstr "" "μεταβλητή, ένα χαρακτηριστικό κλάσης ή μια παράμετρο συνάρτησης ή τιμή " "επιστροφής." -#: glossary.rst:1223 +#: glossary.rst:1253 msgid "" "Type hints are optional and are not enforced by Python but they are useful " "to :term:`static type checkers `. They can also aid " @@ -2879,7 +3109,7 @@ msgstr "" "checker>`. Μπορούν επίσης να βοηθήσουν τους IDEs με τη συμπλήρωση και την " "αναδιαμόρφωση κώδικα." -#: glossary.rst:1227 +#: glossary.rst:1257 msgid "" "Type hints of global variables, class attributes, and functions, but not " "local variables, can be accessed using :func:`typing.get_type_hints`." @@ -2888,17 +3118,17 @@ msgstr "" "κλάσης και συναρτήσεις , αλλά όχι τοπικές μεταβλητές, μπορούν να " "προσπελαστούν χρησιμοποιώντας το :func:`typing.get_type_hints`." -#: glossary.rst:1232 +#: glossary.rst:1262 msgid "universal newlines" msgstr "καθολικές νέες γραμμές" -#: glossary.rst:1234 +#: glossary.rst:1264 msgid "" "A manner of interpreting text streams in which all of the following are " "recognized as ending a line: the Unix end-of-line convention ``'\\n'``, the " "Windows convention ``'\\r\\n'``, and the old Macintosh convention " -"``'\\r'``. See :pep:`278` and :pep:`3116`, as well as :func:`bytes." -"splitlines` for an additional use." +"``'\\r'``. See :pep:`278` and :pep:`3116`, as well " +"as :func:`bytes.splitlines` for an additional use." msgstr "" "Ένα τρόπος ερμηνείας ροών κειμένου στον οποίο όλα τα ακόλουθα αναγνωρίζονται " "ως λήξεις μιας γραμμής: η σύμβαση τέλους γραμμής του Unix ``'\\n'``, η " @@ -2906,36 +3136,46 @@ msgstr "" "Βλ. :pep:`278` και :pep:`3116`, καθώς και :func:`bytes.splitlines` για " "πρόσθετη χρήση." -#: glossary.rst:1239 +#: glossary.rst:1269 msgid "variable annotation" msgstr "annotation μεταβλητής" -#: glossary.rst:1241 +#: glossary.rst:1271 msgid "An :term:`annotation` of a variable or a class attribute." msgstr "Ένας :term:`annotation` μια μεταβλητής ή ενός χαρακτηριστικού κλάσης." -#: glossary.rst:1243 +#: glossary.rst:1273 msgid "" "When annotating a variable or a class attribute, assignment is optional::" msgstr "" "Όταν annotating μια μεταβλητή ή ένα χαρακτηριστικό κλάσης, η ανάθεση είναι " "προαιρετική::" -#: glossary.rst:1248 +#: glossary.rst:1275 +msgid "" +"class C:\n" +" field: 'annotation'" +msgstr "" + +#: glossary.rst:1278 msgid "" "Variable annotations are usually used for :term:`type hints `: " "for example this variable is expected to take :class:`int` values::" msgstr "" "Τα annotations μεταβλητών χρησιμοποιούνται συνήθως για :term:`type hints " -"`: για παράδειγμα αυτή η μεταβλητή αναμένεται να λάβει τιμές :" -"class:`int`::" +"`: για παράδειγμα αυτή η μεταβλητή αναμένεται να λάβει " +"τιμές :class:`int`::" + +#: glossary.rst:1282 +msgid "count: int = 0" +msgstr "" -#: glossary.rst:1254 +#: glossary.rst:1284 msgid "Variable annotation syntax is explained in section :ref:`annassign`." msgstr "" "Η σύνταξη annotation μεταβλητής περιγράφεται στην ενότητα :ref:`annassign`." -#: glossary.rst:1256 +#: glossary.rst:1286 msgid "" "See :term:`function annotation`, :pep:`484` and :pep:`526`, which describe " "this functionality. Also see :ref:`annotations-howto` for best practices on " @@ -2945,11 +3185,11 @@ msgstr "" "αυτή τη λειτουργία. Δείτε επίσης :ref:`annotations-howto` για βέλτιστες " "πρακτικές σχετικά με την εργασία με σχολιασμούς." -#: glossary.rst:1260 +#: glossary.rst:1290 msgid "virtual environment" msgstr "virtual environment" -#: glossary.rst:1262 +#: glossary.rst:1292 msgid "" "A cooperatively isolated runtime environment that allows Python users and " "applications to install and upgrade Python distribution packages without " @@ -2961,15 +3201,15 @@ msgstr "" "πακέτα διανομής Python χωρίς να παρεμβαίνουν στη συμπεριφορά άλλων εφαρμογών " "Python που εκτελούνται στο ίδιο σύστημα." -#: glossary.rst:1267 +#: glossary.rst:1297 msgid "See also :mod:`venv`." msgstr "Βλ. επίσης :mod:`venv`." -#: glossary.rst: +#: glossary.rst:1298 msgid "virtual machine" msgstr "virtual machine" -#: glossary.rst:1270 +#: glossary.rst:1300 msgid "" "A computer defined entirely in software. Python's virtual machine executes " "the :term:`bytecode` emitted by the bytecode compiler." @@ -2978,11 +3218,11 @@ msgstr "" "της Python εκτελεί το :term:`bytecode` που εκπέμπεται από τον μεταγλωττιστή " "bytecode." -#: glossary.rst:1272 +#: glossary.rst:1302 msgid "Zen of Python" msgstr "Zen της Python" -#: glossary.rst:1274 +#: glossary.rst:1304 msgid "" "Listing of Python design principles and philosophies that are helpful in " "understanding and using the language. The listing can be found by typing " @@ -3000,10 +3240,10 @@ msgstr "C-contiguous" msgid "Fortran contiguous" msgstr "Fortran contiguous" -#: glossary.rst:761 +#: glossary.rst:774 msgid "magic" msgstr "magic" -#: glossary.rst:1131 +#: glossary.rst:1161 msgid "special" msgstr "special" diff --git a/howto/annotations.po b/howto/annotations.po index f0a481d1..a1bf4499 100644 --- a/howto/annotations.po +++ b/howto/annotations.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -53,8 +54,8 @@ msgstr "" msgid "" "Note that this document is specifically about working with " "``__annotations__``, not uses *for* annotations. If you're looking for " -"information on how to use \"type hints\" in your code, please see the :mod:" -"`typing` module." +"information on how to use \"type hints\" in your code, please see " +"the :mod:`typing` module." msgstr "" #: howto/annotations.rst:33 @@ -63,19 +64,19 @@ msgstr "" #: howto/annotations.rst:35 msgid "" -"Python 3.10 adds a new function to the standard library: :func:`inspect." -"get_annotations`. In Python versions 3.10 and newer, calling this function " -"is the best practice for accessing the annotations dict of any object that " -"supports annotations. This function can also \"un-stringize\" stringized " -"annotations for you." +"Python 3.10 adds a new function to the standard " +"library: :func:`inspect.get_annotations`. In Python versions 3.10 and " +"newer, calling this function is the best practice for accessing the " +"annotations dict of any object that supports annotations. This function can " +"also \"un-stringize\" stringized annotations for you." msgstr "" #: howto/annotations.rst:42 msgid "" "If for some reason :func:`inspect.get_annotations` isn't viable for your use " "case, you may access the ``__annotations__`` data member manually. Best " -"practice for this changed in Python 3.10 as well: as of Python 3.10, ``o." -"__annotations__`` is guaranteed to *always* work on Python functions, " +"practice for this changed in Python 3.10 as well: as of Python 3.10, " +"``o.__annotations__`` is guaranteed to *always* work on Python functions, " "classes, and modules. If you're certain the object you're examining is one " "of these three *specific* objects, you may simply use ``o.__annotations__`` " "to get at the object's annotations dict." @@ -83,11 +84,12 @@ msgstr "" #: howto/annotations.rst:52 msgid "" -"However, other types of callables--for example, callables created by :func:" -"`functools.partial`--may not have an ``__annotations__`` attribute defined. " -"When accessing the ``__annotations__`` of a possibly unknown object, best " -"practice in Python versions 3.10 and newer is to call :func:`getattr` with " -"three arguments, for example ``getattr(o, '__annotations__', None)``." +"However, other types of callables--for example, callables created " +"by :func:`functools.partial`--may not have an ``__annotations__`` attribute " +"defined. When accessing the ``__annotations__`` of a possibly unknown " +"object, best practice in Python versions 3.10 and newer is to " +"call :func:`getattr` with three arguments, for example ``getattr(o, " +"'__annotations__', None)``." msgstr "" #: howto/annotations.rst:60 @@ -127,6 +129,18 @@ msgid "" "annotations dict of a *base class.* As an example::" msgstr "" +#: howto/annotations.rst:89 +msgid "" +"class Base:\n" +" a: int = 3\n" +" b: str = 'abc'\n" +"\n" +"class Derived(Base):\n" +" pass\n" +"\n" +"print(Derived.__annotations__)" +msgstr "" + #: howto/annotations.rst:98 msgid "This will print the annotations dict from ``Base``, not ``Derived``." msgstr "" @@ -136,9 +150,9 @@ msgid "" "Your code will have to have a separate code path if the object you're " "examining is a class (``isinstance(o, type)``). In that case, best practice " "relies on an implementation detail of Python 3.9 and before: if a class has " -"annotations defined, they are stored in the class's ``__dict__`` " +"annotations defined, they are stored in the class's :attr:`~type.__dict__` " "dictionary. Since the class may or may not have annotations defined, best " -"practice is to call the ``get`` method on the class dict." +"practice is to call the :meth:`~dict.get` method on the class dict." msgstr "" #: howto/annotations.rst:109 @@ -148,18 +162,26 @@ msgid "" "before::" msgstr "" +#: howto/annotations.rst:113 +msgid "" +"if isinstance(o, type):\n" +" ann = o.__dict__.get('__annotations__', None)\n" +"else:\n" +" ann = getattr(o, '__annotations__', None)" +msgstr "" + #: howto/annotations.rst:118 msgid "" "After running this code, ``ann`` should be either a dictionary or ``None``. " -"You're encouraged to double-check the type of ``ann`` using :func:" -"`isinstance` before further examination." +"You're encouraged to double-check the type of ``ann`` " +"using :func:`isinstance` before further examination." msgstr "" #: howto/annotations.rst:123 msgid "" -"Note that some exotic or malformed type objects may not have a ``__dict__`` " -"attribute, so for extra safety you may also wish to use :func:`getattr` to " -"access ``__dict__``." +"Note that some exotic or malformed type objects may not have " +"a :attr:`~type.__dict__` attribute, so for extra safety you may also wish to " +"use :func:`getattr` to access :attr:`!__dict__`." msgstr "" #: howto/annotations.rst:129 @@ -176,10 +198,11 @@ msgstr "" #: howto/annotations.rst:137 msgid "" -"If you're using Python 3.9 or older, or if for some reason you can't use :" -"func:`inspect.get_annotations`, you'll need to duplicate its logic. You're " -"encouraged to examine the implementation of :func:`inspect.get_annotations` " -"in the current Python version and follow a similar approach." +"If you're using Python 3.9 or older, or if for some reason you can't " +"use :func:`inspect.get_annotations`, you'll need to duplicate its logic. " +"You're encouraged to examine the implementation " +"of :func:`inspect.get_annotations` in the current Python version and follow " +"a similar approach." msgstr "" #: howto/annotations.rst:143 @@ -190,29 +213,30 @@ msgstr "" #: howto/annotations.rst:146 msgid "" -"If ``o`` is a module, use ``o.__dict__`` as the ``globals`` when calling :" -"func:`eval`." +"If ``o`` is a module, use ``o.__dict__`` as the ``globals`` when " +"calling :func:`eval`." msgstr "" #: howto/annotations.rst:148 msgid "" "If ``o`` is a class, use ``sys.modules[o.__module__].__dict__`` as the " -"``globals``, and ``dict(vars(o))`` as the ``locals``, when calling :func:" -"`eval`." +"``globals``, and ``dict(vars(o))`` as the ``locals``, when " +"calling :func:`eval`." msgstr "" #: howto/annotations.rst:151 msgid "" -"If ``o`` is a wrapped callable using :func:`functools.update_wrapper`, :func:" -"`functools.wraps`, or :func:`functools.partial`, iteratively unwrap it by " -"accessing either ``o.__wrapped__`` or ``o.func`` as appropriate, until you " -"have found the root unwrapped function." +"If ``o`` is a wrapped callable " +"using :func:`functools.update_wrapper`, :func:`functools.wraps`, " +"or :func:`functools.partial`, iteratively unwrap it by accessing either " +"``o.__wrapped__`` or ``o.func`` as appropriate, until you have found the " +"root unwrapped function." msgstr "" #: howto/annotations.rst:155 msgid "" -"If ``o`` is a callable (but not a class), use :attr:`o.__globals__ ` as the globals when calling :func:`eval`." +"If ``o`` is a callable (but not a class), use :attr:`o.__globals__ " +"` as the globals when calling :func:`eval`." msgstr "" #: howto/annotations.rst:159 @@ -232,8 +256,8 @@ msgstr "" #: howto/annotations.rst:168 msgid "" -"Definitions that aren't needed at runtime, only imported when :const:`typing." -"TYPE_CHECKING` is true." +"Definitions that aren't needed at runtime, only imported " +"when :const:`typing.TYPE_CHECKING` is true." msgstr "" #: howto/annotations.rst:171 @@ -317,6 +341,14 @@ msgid "" "example::" msgstr "" +#: howto/annotations.rst:227 +msgid "" +"from __future__ import annotations\n" +"def foo(a: \"str\"): pass\n" +"\n" +"print(foo.__annotations__)" +msgstr "" + #: howto/annotations.rst:232 msgid "" "This prints ``{'a': \"'str'\"}``. This shouldn't really be considered a " diff --git a/howto/argparse-optparse.po b/howto/argparse-optparse.po new file mode 100644 index 00000000..18e39505 --- /dev/null +++ b/howto/argparse-optparse.po @@ -0,0 +1,119 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: howto/argparse-optparse.rst:7 +msgid "Upgrading optparse code" +msgstr "" + +#: howto/argparse-optparse.rst:9 +msgid "" +"Originally, the :mod:`argparse` module had attempted to maintain " +"compatibility with :mod:`optparse`. However, :mod:`optparse` was difficult " +"to extend transparently, particularly with the changes required to support " +"``nargs=`` specifiers and better usage messages. When most everything " +"in :mod:`optparse` had either been copy-pasted over or monkey-patched, it no " +"longer seemed practical to try to maintain the backwards compatibility." +msgstr "" + +#: howto/argparse-optparse.rst:16 +msgid "" +"The :mod:`argparse` module improves on the :mod:`optparse` module in a " +"number of ways including:" +msgstr "" + +#: howto/argparse-optparse.rst:19 +msgid "Handling positional arguments." +msgstr "" + +#: howto/argparse-optparse.rst:20 +msgid "Supporting subcommands." +msgstr "" + +#: howto/argparse-optparse.rst:21 +msgid "Allowing alternative option prefixes like ``+`` and ``/``." +msgstr "" + +#: howto/argparse-optparse.rst:22 +msgid "Handling zero-or-more and one-or-more style arguments." +msgstr "" + +#: howto/argparse-optparse.rst:23 +msgid "Producing more informative usage messages." +msgstr "" + +#: howto/argparse-optparse.rst:24 +msgid "Providing a much simpler interface for custom ``type`` and ``action``." +msgstr "" + +#: howto/argparse-optparse.rst:26 +msgid "A partial upgrade path from :mod:`optparse` to :mod:`argparse`:" +msgstr "" + +#: howto/argparse-optparse.rst:28 +msgid "" +"Replace all :meth:`optparse.OptionParser.add_option` calls " +"with :meth:`ArgumentParser.add_argument` calls." +msgstr "" + +#: howto/argparse-optparse.rst:31 +msgid "" +"Replace ``(options, args) = parser.parse_args()`` with ``args = " +"parser.parse_args()`` and add additional :meth:`ArgumentParser.add_argument` " +"calls for the positional arguments. Keep in mind that what was previously " +"called ``options``, now in the :mod:`argparse` context is called ``args``." +msgstr "" + +#: howto/argparse-optparse.rst:36 +msgid "" +"Replace :meth:`optparse.OptionParser.disable_interspersed_args` by " +"using :meth:`~ArgumentParser.parse_intermixed_args` instead " +"of :meth:`~ArgumentParser.parse_args`." +msgstr "" + +#: howto/argparse-optparse.rst:40 +msgid "" +"Replace callback actions and the ``callback_*`` keyword arguments with " +"``type`` or ``action`` arguments." +msgstr "" + +#: howto/argparse-optparse.rst:43 +msgid "" +"Replace string names for ``type`` keyword arguments with the corresponding " +"type objects (e.g. int, float, complex, etc)." +msgstr "" + +#: howto/argparse-optparse.rst:46 +msgid "" +"Replace :class:`optparse.Values` with :class:`Namespace` " +"and :exc:`optparse.OptionError` and :exc:`optparse.OptionValueError` " +"with :exc:`ArgumentError`." +msgstr "" + +#: howto/argparse-optparse.rst:50 +msgid "" +"Replace strings with implicit arguments such as ``%default`` or ``%prog`` " +"with the standard Python syntax to use dictionaries to format strings, that " +"is, ``%(default)s`` and ``%(prog)s``." +msgstr "" + +#: howto/argparse-optparse.rst:54 +msgid "" +"Replace the OptionParser constructor ``version`` argument with a call to " +"``parser.add_argument('--version', action='version', version='')``." +msgstr "" diff --git a/howto/argparse.po b/howto/argparse.po index 96f13dfb..217f4390 100644 --- a/howto/argparse.po +++ b/howto/argparse.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -37,9 +38,9 @@ msgstr "" #: howto/argparse.rst:16 msgid "" "There are two other modules that fulfill the same task, namely :mod:`getopt` " -"(an equivalent for ``getopt()`` from the C language) and the deprecated :mod:" -"`optparse`. Note also that :mod:`argparse` is based on :mod:`optparse`, and " -"therefore very similar in terms of usage." +"(an equivalent for ``getopt()`` from the C language) and the " +"deprecated :mod:`optparse`. Note also that :mod:`argparse` is based " +"on :mod:`optparse`, and therefore very similar in terms of usage." msgstr "" #: howto/argparse.rst:24 @@ -52,6 +53,26 @@ msgid "" "introductory tutorial by making use of the :command:`ls` command:" msgstr "" +#: howto/argparse.rst:29 +msgid "" +"$ ls\n" +"cpython devguide prog.py pypy rm-unused-function.patch\n" +"$ ls pypy\n" +"ctypes_configure demo dotviewer include lib_pypy lib-python ...\n" +"$ ls -l\n" +"total 20\n" +"drwxr-xr-x 19 wena wena 4096 Feb 18 18:51 cpython\n" +"drwxr-xr-x 4 wena wena 4096 Feb 8 12:04 devguide\n" +"-rwxr-xr-x 1 wena wena 535 Feb 19 00:05 prog.py\n" +"drwxr-xr-x 14 wena wena 4096 Feb 7 00:59 pypy\n" +"-rw-r--r-- 1 wena wena 741 Feb 18 01:01 rm-unused-function.patch\n" +"$ ls --help\n" +"Usage: ls [OPTION]... [FILE]...\n" +"List information about the FILEs (the current directory by default).\n" +"Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.\n" +"..." +msgstr "" + #: howto/argparse.rst:48 msgid "A few concepts we can learn from the four commands:" msgstr "" @@ -96,10 +117,33 @@ msgstr "" msgid "Let us start with a very simple example which does (almost) nothing::" msgstr "" +#: howto/argparse.rst:76 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.parse_args()" +msgstr "" + #: howto/argparse.rst:188 howto/argparse.rst:209 msgid "Following is a result of running the code:" msgstr "" +#: howto/argparse.rst:82 +msgid "" +"$ python prog.py\n" +"$ python prog.py --help\n" +"usage: prog.py [-h]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"$ python prog.py --verbose\n" +"usage: prog.py [-h]\n" +"prog.py: error: unrecognized arguments: --verbose\n" +"$ python prog.py foo\n" +"usage: prog.py [-h]\n" +"prog.py: error: unrecognized arguments: foo" +msgstr "" + #: howto/argparse.rst:254 howto/argparse.rst:298 msgid "Here is what is happening:" msgstr "" @@ -132,10 +176,36 @@ msgstr "" msgid "An example::" msgstr "" +#: howto/argparse.rst:116 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"echo\")\n" +"args = parser.parse_args()\n" +"print(args.echo)" +msgstr "" + #: howto/argparse.rst:122 msgid "And running the code:" msgstr "" +#: howto/argparse.rst:124 +msgid "" +"$ python prog.py\n" +"usage: prog.py [-h] echo\n" +"prog.py: error: the following arguments are required: echo\n" +"$ python prog.py --help\n" +"usage: prog.py [-h] echo\n" +"\n" +"positional arguments:\n" +" echo\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"$ python prog.py foo\n" +"foo" +msgstr "" + #: howto/argparse.rst:140 msgid "Here is what's happening:" msgstr "" @@ -175,19 +245,79 @@ msgid "" "useful::" msgstr "" +#: howto/argparse.rst:161 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"echo\", help=\"echo the string you use here\")\n" +"args = parser.parse_args()\n" +"print(args.echo)" +msgstr "" + #: howto/argparse.rst:167 msgid "And we get:" msgstr "" +#: howto/argparse.rst:169 +msgid "" +"$ python prog.py -h\n" +"usage: prog.py [-h] echo\n" +"\n" +"positional arguments:\n" +" echo echo the string you use here\n" +"\n" +"options:\n" +" -h, --help show this help message and exit" +msgstr "" + #: howto/argparse.rst:180 msgid "Now, how about doing something even more useful::" msgstr "" +#: howto/argparse.rst:182 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", help=\"display a square of a given " +"number\")\n" +"args = parser.parse_args()\n" +"print(args.square**2)" +msgstr "" + +#: howto/argparse.rst:190 +msgid "" +"$ python prog.py 4\n" +"Traceback (most recent call last):\n" +" File \"prog.py\", line 5, in \n" +" print(args.square**2)\n" +"TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'" +msgstr "" + #: howto/argparse.rst:198 msgid "" "That didn't go so well. That's because :mod:`argparse` treats the options we " -"give it as strings, unless we tell it otherwise. So, let's tell :mod:" -"`argparse` to treat that input as an integer::" +"give it as strings, unless we tell it otherwise. So, let's " +"tell :mod:`argparse` to treat that input as an integer::" +msgstr "" + +#: howto/argparse.rst:202 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", help=\"display a square of a given " +"number\",\n" +" type=int)\n" +"args = parser.parse_args()\n" +"print(args.square**2)" +msgstr "" + +#: howto/argparse.rst:211 +msgid "" +"$ python prog.py 4\n" +"16\n" +"$ python prog.py four\n" +"usage: prog.py [-h] square\n" +"prog.py: error: argument square: invalid int value: 'four'" msgstr "" #: howto/argparse.rst:219 @@ -206,10 +336,37 @@ msgid "" "how to add optional ones::" msgstr "" +#: howto/argparse.rst:229 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"--verbosity\", help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"if args.verbosity:\n" +" print(\"verbosity turned on\")" +msgstr "" + #: howto/argparse.rst:282 howto/argparse.rst:432 msgid "And the output:" msgstr "" +#: howto/argparse.rst:238 +msgid "" +"$ python prog.py --verbosity 1\n" +"verbosity turned on\n" +"$ python prog.py\n" +"$ python prog.py --help\n" +"usage: prog.py [-h] [--verbosity VERBOSITY]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --verbosity VERBOSITY\n" +" increase output verbosity\n" +"$ python prog.py --verbosity\n" +"usage: prog.py [-h] [--verbosity VERBOSITY]\n" +"prog.py: error: argument --verbosity: expected one argument" +msgstr "" + #: howto/argparse.rst:256 msgid "" "The program is written so as to display something when ``--verbosity`` is " @@ -221,8 +378,8 @@ msgid "" "To show that the option is actually optional, there is no error when running " "the program without it. Note that by default, if an optional argument isn't " "used, the relevant variable, in this case ``args.verbosity``, is given " -"``None`` as a value, which is the reason it fails the truth test of the :" -"keyword:`if` statement." +"``None`` as a value, which is the reason it fails the truth test of " +"the :keyword:`if` statement." msgstr "" #: howto/argparse.rst:265 @@ -242,6 +399,32 @@ msgid "" "``False``. Let's modify the code accordingly::" msgstr "" +#: howto/argparse.rst:274 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"--verbose\", help=\"increase output verbosity\",\n" +" action=\"store_true\")\n" +"args = parser.parse_args()\n" +"if args.verbose:\n" +" print(\"verbosity turned on\")" +msgstr "" + +#: howto/argparse.rst:284 +msgid "" +"$ python prog.py --verbose\n" +"verbosity turned on\n" +"$ python prog.py --verbose 1\n" +"usage: prog.py [-h] [--verbose]\n" +"prog.py: error: unrecognized arguments: 1\n" +"$ python prog.py --help\n" +"usage: prog.py [-h] [--verbose]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --verbose increase output verbosity" +msgstr "" + #: howto/argparse.rst:300 msgid "" "The option is now more of a flag than something that requires a value. We " @@ -272,10 +455,34 @@ msgid "" "simple::" msgstr "" +#: howto/argparse.rst:320 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"-v\", \"--verbose\", help=\"increase output " +"verbosity\",\n" +" action=\"store_true\")\n" +"args = parser.parse_args()\n" +"if args.verbose:\n" +" print(\"verbosity turned on\")" +msgstr "" + #: howto/argparse.rst:328 msgid "And here goes:" msgstr "" +#: howto/argparse.rst:330 +msgid "" +"$ python prog.py -v\n" +"verbosity turned on\n" +"$ python prog.py --help\n" +"usage: prog.py [-h] [-v]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -v, --verbose increase output verbosity" +msgstr "" + #: howto/argparse.rst:341 msgid "Note that the new ability is also reflected in the help text." msgstr "" @@ -288,10 +495,39 @@ msgstr "" msgid "Our program keeps growing in complexity::" msgstr "" +#: howto/argparse.rst:349 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", type=int,\n" +" help=\"display a square of a given number\")\n" +"parser.add_argument(\"-v\", \"--verbose\", action=\"store_true\",\n" +" help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"answer = args.square**2\n" +"if args.verbose:\n" +" print(f\"the square of {args.square} equals {answer}\")\n" +"else:\n" +" print(answer)" +msgstr "" + #: howto/argparse.rst:362 msgid "And now the output:" msgstr "" +#: howto/argparse.rst:364 +msgid "" +"$ python prog.py\n" +"usage: prog.py [-h] [-v] square\n" +"prog.py: error: the following arguments are required: square\n" +"$ python prog.py 4\n" +"16\n" +"$ python prog.py 4 --verbose\n" +"the square of 4 equals 16\n" +"$ python prog.py --verbose 4\n" +"the square of 4 equals 16" +msgstr "" + #: howto/argparse.rst:376 msgid "We've brought back a positional argument, hence the complaint." msgstr "" @@ -306,6 +542,39 @@ msgid "" "verbosity values, and actually get to use them::" msgstr "" +#: howto/argparse.rst:383 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", type=int,\n" +" help=\"display a square of a given number\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", type=int,\n" +" help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"answer = args.square**2\n" +"if args.verbosity == 2:\n" +" print(f\"the square of {args.square} equals {answer}\")\n" +"elif args.verbosity == 1:\n" +" print(f\"{args.square}^2 == {answer}\")\n" +"else:\n" +" print(answer)" +msgstr "" + +#: howto/argparse.rst:400 +msgid "" +"$ python prog.py 4\n" +"16\n" +"$ python prog.py 4 -v\n" +"usage: prog.py [-h] [-v VERBOSITY] square\n" +"prog.py: error: argument -v/--verbosity: expected one argument\n" +"$ python prog.py 4 -v 1\n" +"4^2 == 16\n" +"$ python prog.py 4 -v 2\n" +"the square of 4 equals 16\n" +"$ python prog.py 4 -v 3\n" +"16" +msgstr "" + #: howto/argparse.rst:414 msgid "" "These all look good except the last one, which exposes a bug in our program. " @@ -313,6 +582,42 @@ msgid "" "accept::" msgstr "" +#: howto/argparse.rst:417 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", type=int,\n" +" help=\"display a square of a given number\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", type=int, choices=[0, 1, 2],\n" +" help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"answer = args.square**2\n" +"if args.verbosity == 2:\n" +" print(f\"the square of {args.square} equals {answer}\")\n" +"elif args.verbosity == 1:\n" +" print(f\"{args.square}^2 == {answer}\")\n" +"else:\n" +" print(answer)" +msgstr "" + +#: howto/argparse.rst:434 +msgid "" +"$ python prog.py 4 -v 3\n" +"usage: prog.py [-h] [-v {0,1,2}] square\n" +"prog.py: error: argument -v/--verbosity: invalid choice: 3 (choose from 0, " +"1, 2)\n" +"$ python prog.py 4 -h\n" +"usage: prog.py [-h] [-v {0,1,2}] square\n" +"\n" +"positional arguments:\n" +" square display a square of a given number\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -v {0,1,2}, --verbosity {0,1,2}\n" +" increase output verbosity" +msgstr "" + #: howto/argparse.rst:450 msgid "" "Note that the change also reflects both in the error message as well as the " @@ -326,12 +631,56 @@ msgid "" "own verbosity argument (check the output of ``python --help``)::" msgstr "" +#: howto/argparse.rst:457 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", type=int,\n" +" help=\"display the square of a given number\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", action=\"count\",\n" +" help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"answer = args.square**2\n" +"if args.verbosity == 2:\n" +" print(f\"the square of {args.square} equals {answer}\")\n" +"elif args.verbosity == 1:\n" +" print(f\"{args.square}^2 == {answer}\")\n" +"else:\n" +" print(answer)" +msgstr "" + #: howto/argparse.rst:472 msgid "" "We have introduced another action, \"count\", to count the number of " "occurrences of specific options." msgstr "" +#: howto/argparse.rst:476 +msgid "" +"$ python prog.py 4\n" +"16\n" +"$ python prog.py 4 -v\n" +"4^2 == 16\n" +"$ python prog.py 4 -vv\n" +"the square of 4 equals 16\n" +"$ python prog.py 4 --verbosity --verbosity\n" +"the square of 4 equals 16\n" +"$ python prog.py 4 -v 1\n" +"usage: prog.py [-h] [-v] square\n" +"prog.py: error: unrecognized arguments: 1\n" +"$ python prog.py 4 -h\n" +"usage: prog.py [-h] [-v] square\n" +"\n" +"positional arguments:\n" +" square display a square of a given number\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -v, --verbosity increase output verbosity\n" +"$ python prog.py 4 -vvv\n" +"16" +msgstr "" + #: howto/argparse.rst:501 msgid "" "Yes, it's now more of a flag (similar to ``action=\"store_true\"``) in the " @@ -375,10 +724,43 @@ msgstr "" msgid "Let's fix::" msgstr "" +#: howto/argparse.rst:524 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", type=int,\n" +" help=\"display a square of a given number\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", action=\"count\",\n" +" help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"answer = args.square**2\n" +"\n" +"# bugfix: replace == with >=\n" +"if args.verbosity >= 2:\n" +" print(f\"the square of {args.square} equals {answer}\")\n" +"elif args.verbosity >= 1:\n" +" print(f\"{args.square}^2 == {answer}\")\n" +"else:\n" +" print(answer)" +msgstr "" + #: howto/argparse.rst:541 msgid "And this is what it gives:" msgstr "" +#: howto/argparse.rst:543 +msgid "" +"$ python prog.py 4 -vvv\n" +"the square of 4 equals 16\n" +"$ python prog.py 4 -vvvv\n" +"the square of 4 equals 16\n" +"$ python prog.py 4\n" +"Traceback (most recent call last):\n" +" File \"prog.py\", line 11, in \n" +" if args.verbosity >= 2:\n" +"TypeError: '>=' not supported between instances of 'NoneType' and 'int'" +msgstr "" + #: howto/argparse.rst:556 msgid "" "First output went well, and fixes the bug we had before. That is, we want " @@ -393,19 +775,43 @@ msgstr "" msgid "Let's fix that bug::" msgstr "" +#: howto/argparse.rst:563 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", type=int,\n" +" help=\"display a square of a given number\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", action=\"count\", default=0,\n" +" help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"answer = args.square**2\n" +"if args.verbosity >= 2:\n" +" print(f\"the square of {args.square} equals {answer}\")\n" +"elif args.verbosity >= 1:\n" +" print(f\"{args.square}^2 == {answer}\")\n" +"else:\n" +" print(answer)" +msgstr "" + #: howto/argparse.rst:578 msgid "" "We've just introduced yet another keyword, ``default``. We've set it to " "``0`` in order to make it comparable to the other int values. Remember that " "by default, if an optional argument isn't specified, it gets the ``None`` " -"value, and that cannot be compared to an int value (hence the :exc:" -"`TypeError` exception)." +"value, and that cannot be compared to an int value (hence " +"the :exc:`TypeError` exception)." msgstr "" #: howto/argparse.rst:585 msgid "And:" msgstr "" +#: howto/argparse.rst:587 +msgid "" +"$ python prog.py 4\n" +"16" +msgstr "" + #: howto/argparse.rst:592 msgid "" "You can go quite far just with what we've learned so far, and we have only " @@ -423,10 +829,46 @@ msgid "" "just squares::" msgstr "" -#: howto/argparse.rst:656 +#: howto/argparse.rst:604 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"x\", type=int, help=\"the base\")\n" +"parser.add_argument(\"y\", type=int, help=\"the exponent\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", action=\"count\", default=0)\n" +"args = parser.parse_args()\n" +"answer = args.x**args.y\n" +"if args.verbosity >= 2:\n" +" print(f\"{args.x} to the power {args.y} equals {answer}\")\n" +"elif args.verbosity >= 1:\n" +" print(f\"{args.x}^{args.y} == {answer}\")\n" +"else:\n" +" print(answer)" +msgstr "" + +#: howto/argparse.rst:656 howto/argparse.rst:872 msgid "Output:" msgstr "" +#: howto/argparse.rst:620 +msgid "" +"$ python prog.py\n" +"usage: prog.py [-h] [-v] x y\n" +"prog.py: error: the following arguments are required: x, y\n" +"$ python prog.py -h\n" +"usage: prog.py [-h] [-v] x y\n" +"\n" +"positional arguments:\n" +" x the base\n" +" y the exponent\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -v, --verbosity\n" +"$ python prog.py 4 2 -v\n" +"4^2 == 16" +msgstr "" + #: howto/argparse.rst:639 msgid "" "Notice that so far we've been using verbosity level to *change* the text " @@ -434,6 +876,33 @@ msgid "" "display *more* text instead::" msgstr "" +#: howto/argparse.rst:643 +msgid "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"x\", type=int, help=\"the base\")\n" +"parser.add_argument(\"y\", type=int, help=\"the exponent\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", action=\"count\", default=0)\n" +"args = parser.parse_args()\n" +"answer = args.x**args.y\n" +"if args.verbosity >= 2:\n" +" print(f\"Running '{__file__}'\")\n" +"if args.verbosity >= 1:\n" +" print(f\"{args.x}^{args.y} == \", end=\"\")\n" +"print(answer)" +msgstr "" + +#: howto/argparse.rst:658 +msgid "" +"$ python prog.py 4 2\n" +"16\n" +"$ python prog.py 4 2 -v\n" +"4^2 == 16\n" +"$ python prog.py 4 2 -vv\n" +"Running 'prog.py'\n" +"4^2 == 16" +msgstr "" + #: howto/argparse.rst:672 msgid "Specifying ambiguous arguments" msgstr "" @@ -445,18 +914,62 @@ msgid "" "that everything after that is a positional argument::" msgstr "" +#: howto/argparse.rst:678 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-n', nargs='+')\n" +">>> parser.add_argument('args', nargs='*')\n" +"\n" +">>> # ambiguous, so parse_args assumes it's an option\n" +">>> parser.parse_args(['-f'])\n" +"usage: PROG [-h] [-n N [N ...]] [args ...]\n" +"PROG: error: unrecognized arguments: -f\n" +"\n" +">>> parser.parse_args(['--', '-f'])\n" +"Namespace(args=['-f'], n=None)\n" +"\n" +">>> # ambiguous, so the -n option greedily accepts arguments\n" +">>> parser.parse_args(['-n', '1', '2', '3'])\n" +"Namespace(args=[], n=['1', '2', '3'])\n" +"\n" +">>> parser.parse_args(['-n', '1', '--', '2', '3'])\n" +"Namespace(args=['2', '3'], n=['1'])" +msgstr "" + #: howto/argparse.rst:699 msgid "Conflicting options" msgstr "" #: howto/argparse.rst:701 msgid "" -"So far, we have been working with two methods of an :class:`argparse." -"ArgumentParser` instance. Let's introduce a third one, :meth:" -"`~ArgumentParser.add_mutually_exclusive_group`. It allows for us to specify " -"options that conflict with each other. Let's also change the rest of the " -"program so that the new functionality makes more sense: we'll introduce the " -"``--quiet`` option, which will be the opposite of the ``--verbose`` one::" +"So far, we have been working with two methods of " +"an :class:`argparse.ArgumentParser` instance. Let's introduce a third " +"one, :meth:`~ArgumentParser.add_mutually_exclusive_group`. It allows for us " +"to specify options that conflict with each other. Let's also change the rest " +"of the program so that the new functionality makes more sense: we'll " +"introduce the ``--quiet`` option, which will be the opposite of the ``--" +"verbose`` one::" +msgstr "" + +#: howto/argparse.rst:709 +msgid "" +"import argparse\n" +"\n" +"parser = argparse.ArgumentParser()\n" +"group = parser.add_mutually_exclusive_group()\n" +"group.add_argument(\"-v\", \"--verbose\", action=\"store_true\")\n" +"group.add_argument(\"-q\", \"--quiet\", action=\"store_true\")\n" +"parser.add_argument(\"x\", type=int, help=\"the base\")\n" +"parser.add_argument(\"y\", type=int, help=\"the exponent\")\n" +"args = parser.parse_args()\n" +"answer = args.x**args.y\n" +"\n" +"if args.quiet:\n" +" print(answer)\n" +"elif args.verbose:\n" +" print(f\"{args.x} to the power {args.y} equals {answer}\")\n" +"else:\n" +" print(f\"{args.x}^{args.y} == {answer}\")" msgstr "" #: howto/argparse.rst:727 @@ -465,6 +978,22 @@ msgid "" "of demonstration. Anyways, here's the output:" msgstr "" +#: howto/argparse.rst:730 +msgid "" +"$ python prog.py 4 2\n" +"4^2 == 16\n" +"$ python prog.py 4 2 -q\n" +"16\n" +"$ python prog.py 4 2 -v\n" +"4 to the power 2 equals 16\n" +"$ python prog.py 4 2 -vq\n" +"usage: prog.py [-h] [-v | -q] x y\n" +"prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose\n" +"$ python prog.py 4 2 -v --quiet\n" +"usage: prog.py [-h] [-v | -q] x y\n" +"prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose" +msgstr "" + #: howto/argparse.rst:745 msgid "" "That should be easy to follow. I've added that last output so you can see " @@ -478,6 +1007,28 @@ msgid "" "your program, just in case they don't know::" msgstr "" +#: howto/argparse.rst:752 +msgid "" +"import argparse\n" +"\n" +"parser = argparse.ArgumentParser(description=\"calculate X to the power of " +"Y\")\n" +"group = parser.add_mutually_exclusive_group()\n" +"group.add_argument(\"-v\", \"--verbose\", action=\"store_true\")\n" +"group.add_argument(\"-q\", \"--quiet\", action=\"store_true\")\n" +"parser.add_argument(\"x\", type=int, help=\"the base\")\n" +"parser.add_argument(\"y\", type=int, help=\"the exponent\")\n" +"args = parser.parse_args()\n" +"answer = args.x**args.y\n" +"\n" +"if args.quiet:\n" +" print(answer)\n" +"elif args.verbose:\n" +" print(f\"{args.x} to the power {args.y} equals {answer}\")\n" +"else:\n" +" print(f\"{args.x}^{args.y} == {answer}\")" +msgstr "" + #: howto/argparse.rst:770 msgid "" "Note that slight difference in the usage text. Note the ``[-v | -q]``, which " @@ -485,6 +1036,23 @@ msgid "" "time:" msgstr "" +#: howto/argparse.rst:801 +msgid "" +"$ python prog.py --help\n" +"usage: prog.py [-h] [-v | -q] x y\n" +"\n" +"calculate X to the power of Y\n" +"\n" +"positional arguments:\n" +" x the base\n" +" y the exponent\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -v, --verbose\n" +" -q, --quiet" +msgstr "" + #: howto/argparse.rst:792 msgid "How to translate the argparse output" msgstr "" @@ -509,9 +1077,13 @@ msgstr "" #: howto/argparse.rst:820 msgid "" -"In order to translate these strings, they must first be extracted into a ``." -"po`` file. For example, using `Babel `__, run this " -"command:" +"In order to translate these strings, they must first be extracted into a " +"``.po`` file. For example, using `Babel `__, run " +"this command:" +msgstr "" + +#: howto/argparse.rst:824 +msgid "$ pybabel extract -o messages.po /usr/lib/python3.12/argparse.py" msgstr "" #: howto/argparse.rst:828 @@ -527,6 +1099,12 @@ msgid "" "using this script::" msgstr "" +#: howto/argparse.rst:835 +msgid "" +"import argparse\n" +"print(argparse.__file__)" +msgstr "" + #: howto/argparse.rst:838 msgid "" "Once the messages in the ``.po`` file are translated and the translations " @@ -536,16 +1114,88 @@ msgstr "" #: howto/argparse.rst:842 msgid "" -"To translate your own strings in the :mod:`argparse` output, use :mod:" -"`gettext`." +"To translate your own strings in the :mod:`argparse` output, " +"use :mod:`gettext`." msgstr "" #: howto/argparse.rst:845 -msgid "Conclusion" +msgid "Custom type converters" msgstr "" #: howto/argparse.rst:847 msgid "" +"The :mod:`argparse` module allows you to specify custom type converters for " +"your command-line arguments. This allows you to modify user input before " +"it's stored in the :class:`argparse.Namespace`. This can be useful when you " +"need to pre-process the input before it is used in your program." +msgstr "" + +#: howto/argparse.rst:852 +msgid "" +"When using a custom type converter, you can use any callable that takes a " +"single string argument (the argument value) and returns the converted value. " +"However, if you need to handle more complex scenarios, you can use a custom " +"action class with the **action** parameter instead." +msgstr "" + +#: howto/argparse.rst:857 +msgid "" +"For example, let's say you want to handle arguments with different prefixes " +"and process them accordingly::" +msgstr "" + +#: howto/argparse.rst:860 +msgid "" +"import argparse\n" +"\n" +"parser = argparse.ArgumentParser(prefix_chars='-+')\n" +"\n" +"parser.add_argument('-a', metavar='', action='append',\n" +" type=lambda x: ('-', x))\n" +"parser.add_argument('+a', metavar='', action='append',\n" +" type=lambda x: ('+', x))\n" +"\n" +"args = parser.parse_args()\n" +"print(args)" +msgstr "" + +#: howto/argparse.rst:874 +msgid "" +"$ python prog.py -a value1 +a value2\n" +"Namespace(a=[('-', 'value1'), ('+', 'value2')])" +msgstr "" + +#: howto/argparse.rst:879 +msgid "In this example, we:" +msgstr "" + +#: howto/argparse.rst:881 +msgid "" +"Created a parser with custom prefix characters using the ``prefix_chars`` " +"parameter." +msgstr "" + +#: howto/argparse.rst:884 +msgid "" +"Defined two arguments, ``-a`` and ``+a``, which used the ``type`` parameter " +"to create custom type converters to store the value in a tuple with the " +"prefix." +msgstr "" + +#: howto/argparse.rst:887 +msgid "" +"Without the custom type converters, the arguments would have treated the ``-" +"a`` and ``+a`` as the same argument, which would have been undesirable. By " +"using custom type converters, we were able to differentiate between the two " +"arguments." +msgstr "" + +#: howto/argparse.rst:892 +msgid "Conclusion" +msgstr "" + +#: howto/argparse.rst:894 +msgid "" "The :mod:`argparse` module offers a lot more than shown here. Its docs are " "quite detailed and thorough, and full of examples. Having gone through this " "tutorial, you should easily digest them without feeling overwhelmed." diff --git a/howto/clinic.po b/howto/clinic.po index 1fd5b5f0..75ef2243 100644 --- a/howto/clinic.po +++ b/howto/clinic.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/howto/cporting.po b/howto/cporting.po index 015541bd..250ddfb5 100644 --- a/howto/cporting.po +++ b/howto/cporting.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/howto/curses.po b/howto/curses.po index f244db17..cb933810 100644 --- a/howto/curses.po +++ b/howto/curses.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -80,8 +81,7 @@ msgid "" "curses library will figure out what control codes need to be sent to the " "terminal to produce the right output. curses doesn't provide many user-" "interface concepts such as buttons, checkboxes, or dialogs; if you need such " -"features, consider a user interface library such as `Urwid `_." +"features, consider a user interface library such as :pypi:`Urwid`." msgstr "" #: howto/curses.rst:48 @@ -100,15 +100,14 @@ msgstr "" #: howto/curses.rst:58 msgid "" "The Windows version of Python doesn't include the :mod:`curses` module. A " -"ported version called `UniCurses `_ is " -"available." +"ported version called :pypi:`UniCurses` is available." msgstr "" -#: howto/curses.rst:64 +#: howto/curses.rst:63 msgid "The Python curses module" msgstr "" -#: howto/curses.rst:66 +#: howto/curses.rst:65 msgid "" "The Python module is a fairly simple wrapper over the C functions provided " "by curses; if you're already familiar with curses programming in C, it's " @@ -119,7 +118,7 @@ msgid "" "this covered in more detail later." msgstr "" -#: howto/curses.rst:74 +#: howto/curses.rst:73 msgid "" "This HOWTO is an introduction to writing text-mode programs with curses and " "Python. It doesn't attempt to be a complete guide to the curses API; for " @@ -127,11 +126,11 @@ msgid "" "pages for ncurses. It will, however, give you the basic ideas." msgstr "" -#: howto/curses.rst:81 +#: howto/curses.rst:80 msgid "Starting and ending a curses application" msgstr "" -#: howto/curses.rst:83 +#: howto/curses.rst:82 msgid "" "Before doing anything, curses must be initialized. This is done by calling " "the :func:`~curses.initscr` function, which will determine the terminal " @@ -141,44 +140,73 @@ msgid "" "after the name of the corresponding C variable. ::" msgstr "" -#: howto/curses.rst:94 +#: howto/curses.rst:90 +msgid "" +"import curses\n" +"stdscr = curses.initscr()" +msgstr "" + +#: howto/curses.rst:93 msgid "" "Usually curses applications turn off automatic echoing of keys to the " "screen, in order to be able to read keys and only display them under certain " "circumstances. This requires calling the :func:`~curses.noecho` function. ::" msgstr "" -#: howto/curses.rst:101 +#: howto/curses.rst:98 +msgid "curses.noecho()" +msgstr "" + +#: howto/curses.rst:100 msgid "" "Applications will also commonly need to react to keys instantly, without " "requiring the Enter key to be pressed; this is called cbreak mode, as " "opposed to the usual buffered input mode. ::" msgstr "" -#: howto/curses.rst:107 +#: howto/curses.rst:104 +msgid "curses.cbreak()" +msgstr "" + +#: howto/curses.rst:106 msgid "" "Terminals usually return special keys, such as the cursor keys or navigation " "keys such as Page Up and Home, as a multibyte escape sequence. While you " "could write your application to expect such sequences and process them " -"accordingly, curses can do it for you, returning a special value such as :" -"const:`curses.KEY_LEFT`. To get curses to do the job, you'll have to enable " -"keypad mode. ::" +"accordingly, curses can do it for you, returning a special value such " +"as :const:`curses.KEY_LEFT`. To get curses to do the job, you'll have to " +"enable keypad mode. ::" msgstr "" -#: howto/curses.rst:116 +#: howto/curses.rst:113 +msgid "stdscr.keypad(True)" +msgstr "" + +#: howto/curses.rst:115 msgid "" "Terminating a curses application is much easier than starting one. You'll " "need to call::" msgstr "" -#: howto/curses.rst:123 +#: howto/curses.rst:118 msgid "" -"to reverse the curses-friendly terminal settings. Then call the :func:" -"`~curses.endwin` function to restore the terminal to its original operating " -"mode. ::" +"curses.nocbreak()\n" +"stdscr.keypad(False)\n" +"curses.echo()" msgstr "" -#: howto/curses.rst:129 +#: howto/curses.rst:122 +msgid "" +"to reverse the curses-friendly terminal settings. Then call " +"the :func:`~curses.endwin` function to restore the terminal to its original " +"operating mode. ::" +msgstr "" + +#: howto/curses.rst:126 +msgid "curses.endwin()" +msgstr "" + +#: howto/curses.rst:128 msgid "" "A common problem when debugging a curses application is to get your terminal " "messed up when the application dies without restoring the terminal to its " @@ -187,47 +215,73 @@ msgid "" "you type them, for example, which makes using the shell difficult." msgstr "" -#: howto/curses.rst:135 +#: howto/curses.rst:134 msgid "" "In Python you can avoid these complications and make debugging much easier " "by importing the :func:`curses.wrapper` function and using it like this::" msgstr "" -#: howto/curses.rst:154 +#: howto/curses.rst:137 +msgid "" +"from curses import wrapper\n" +"\n" +"def main(stdscr):\n" +" # Clear screen\n" +" stdscr.clear()\n" +"\n" +" # This raises ZeroDivisionError when i == 10.\n" +" for i in range(0, 11):\n" +" v = i-10\n" +" stdscr.addstr(i, 0, '10 divided by {} is {}'.format(v, 10/v))\n" +"\n" +" stdscr.refresh()\n" +" stdscr.getkey()\n" +"\n" +"wrapper(main)" +msgstr "" + +#: howto/curses.rst:153 msgid "" "The :func:`~curses.wrapper` function takes a callable object and does the " "initializations described above, also initializing colors if color support " "is present. :func:`!wrapper` then runs your provided callable. Once the " "callable returns, :func:`!wrapper` will restore the original state of the " -"terminal. The callable is called inside a :keyword:`try`...\\ :keyword:" -"`except` that catches exceptions, restores the state of the terminal, and " -"then re-raises the exception. Therefore your terminal won't be left in a " -"funny state on exception and you'll be able to read the exception's message " -"and traceback." +"terminal. The callable is called inside a :keyword:`try`..." +"\\ :keyword:`except` that catches exceptions, restores the state of the " +"terminal, and then re-raises the exception. Therefore your terminal won't " +"be left in a funny state on exception and you'll be able to read the " +"exception's message and traceback." msgstr "" -#: howto/curses.rst:166 +#: howto/curses.rst:165 msgid "Windows and Pads" msgstr "" -#: howto/curses.rst:168 +#: howto/curses.rst:167 msgid "" "Windows are the basic abstraction in curses. A window object represents a " "rectangular area of the screen, and supports methods to display text, erase " "it, allow the user to input strings, and so forth." msgstr "" -#: howto/curses.rst:172 +#: howto/curses.rst:171 msgid "" "The ``stdscr`` object returned by the :func:`~curses.initscr` function is a " "window object that covers the entire screen. Many programs may need only " "this single window, but you might wish to divide the screen into smaller " -"windows, in order to redraw or clear them separately. The :func:`~curses." -"newwin` function creates a new window of a given size, returning the new " -"window object. ::" +"windows, in order to redraw or clear them separately. " +"The :func:`~curses.newwin` function creates a new window of a given size, " +"returning the new window object. ::" +msgstr "" + +#: howto/curses.rst:178 +msgid "" +"begin_x = 20; begin_y = 7\n" +"height = 5; width = 40\n" +"win = curses.newwin(height, width, begin_y, begin_x)" msgstr "" -#: howto/curses.rst:183 +#: howto/curses.rst:182 msgid "" "Note that the coordinate system used in curses is unusual. Coordinates are " "always passed in the order *y,x*, and the top-left corner of a window is " @@ -237,33 +291,34 @@ msgid "" "curses since it was first written, and it's too late to change things now." msgstr "" -#: howto/curses.rst:191 +#: howto/curses.rst:190 msgid "" -"Your application can determine the size of the screen by using the :data:" -"`curses.LINES` and :data:`curses.COLS` variables to obtain the *y* and *x* " -"sizes. Legal coordinates will then extend from ``(0,0)`` to ``(curses.LINES " -"- 1, curses.COLS - 1)``." +"Your application can determine the size of the screen by using " +"the :data:`curses.LINES` and :data:`curses.COLS` variables to obtain the *y* " +"and *x* sizes. Legal coordinates will then extend from ``(0,0)`` to " +"``(curses.LINES - 1, curses.COLS - 1)``." msgstr "" -#: howto/curses.rst:196 +#: howto/curses.rst:195 msgid "" "When you call a method to display or erase text, the effect doesn't " -"immediately show up on the display. Instead you must call the :meth:" -"`~curses.window.refresh` method of window objects to update the screen." +"immediately show up on the display. Instead you must call " +"the :meth:`~curses.window.refresh` method of window objects to update the " +"screen." msgstr "" -#: howto/curses.rst:201 +#: howto/curses.rst:200 msgid "" "This is because curses was originally written with slow 300-baud terminal " "connections in mind; with these terminals, minimizing the time required to " "redraw the screen was very important. Instead curses accumulates changes to " -"the screen and displays them in the most efficient manner when you call :" -"meth:`!refresh`. For example, if your program displays some text in a " +"the screen and displays them in the most efficient manner when you " +"call :meth:`!refresh`. For example, if your program displays some text in a " "window and then clears the window, there's no need to send the original text " "because they're never visible." msgstr "" -#: howto/curses.rst:210 +#: howto/curses.rst:209 msgid "" "In practice, explicitly telling curses to redraw a window doesn't really " "complicate programming with curses much. Most programs go into a flurry of " @@ -273,7 +328,7 @@ msgid "" "stdscr.refresh` or the :meth:`!refresh` method of some other relevant window." msgstr "" -#: howto/curses.rst:218 +#: howto/curses.rst:217 msgid "" "A pad is a special case of a window; it can be larger than the actual " "display screen, and only a portion of the pad displayed at a time. Creating " @@ -282,7 +337,25 @@ msgid "" "will be displayed. ::" msgstr "" -#: howto/curses.rst:239 +#: howto/curses.rst:223 +msgid "" +"pad = curses.newpad(100, 100)\n" +"# These loops fill the pad with letters; addch() is\n" +"# explained in the next section\n" +"for y in range(0, 99):\n" +" for x in range(0, 99):\n" +" pad.addch(y,x, ord('a') + (x*x+y*y) % 26)\n" +"\n" +"# Displays a section of the pad in the middle of the screen.\n" +"# (0,0) : coordinate of upper-left corner of pad area to display.\n" +"# (5,5) : coordinate of upper-left corner of window area to be filled\n" +"# with pad content.\n" +"# (20, 75) : coordinate of lower-right corner of window area to be\n" +"# : filled with pad content.\n" +"pad.refresh( 0,0, 5,5, 20,75)" +msgstr "" + +#: howto/curses.rst:238 msgid "" "The :meth:`!refresh` call displays a section of the pad in the rectangle " "extending from coordinate (5,5) to coordinate (20,75) on the screen; the " @@ -291,36 +364,36 @@ msgid "" "the same methods." msgstr "" -#: howto/curses.rst:245 +#: howto/curses.rst:244 msgid "" "If you have multiple windows and pads on screen there is a more efficient " "way to update the screen and prevent annoying screen flicker as each part of " "the screen gets updated. :meth:`!refresh` actually does two things:" msgstr "" -#: howto/curses.rst:250 +#: howto/curses.rst:249 msgid "" "Calls the :meth:`~curses.window.noutrefresh` method of each window to update " "an underlying data structure representing the desired state of the screen." msgstr "" -#: howto/curses.rst:253 +#: howto/curses.rst:252 msgid "" "Calls the function :func:`~curses.doupdate` function to change the physical " "screen to match the desired state recorded in the data structure." msgstr "" -#: howto/curses.rst:256 +#: howto/curses.rst:255 msgid "" "Instead you can call :meth:`!noutrefresh` on a number of windows to update " "the data structure, and then call :func:`!doupdate` to update the screen." msgstr "" -#: howto/curses.rst:262 +#: howto/curses.rst:261 msgid "Displaying Text" msgstr "" -#: howto/curses.rst:264 +#: howto/curses.rst:263 msgid "" "From a C programmer's point of view, curses may sometimes look like a twisty " "maze of functions, all subtly different. For example, :c:func:`!addstr` " @@ -332,66 +405,66 @@ msgid "" "coordinate." msgstr "" -#: howto/curses.rst:273 +#: howto/curses.rst:272 msgid "" "Fortunately the Python interface hides all these details. ``stdscr`` is a " -"window object like any other, and methods such as :meth:`~curses.window." -"addstr` accept multiple argument forms. Usually there are four different " -"forms." +"window object like any other, and methods such " +"as :meth:`~curses.window.addstr` accept multiple argument forms. Usually " +"there are four different forms." msgstr "" -#: howto/curses.rst:279 +#: howto/curses.rst:278 msgid "Form" msgstr "" -#: howto/curses.rst:347 +#: howto/curses.rst:346 msgid "Description" msgstr "" -#: howto/curses.rst:281 +#: howto/curses.rst:280 msgid "*str* or *ch*" msgstr "" -#: howto/curses.rst:281 +#: howto/curses.rst:280 msgid "Display the string *str* or character *ch* at the current position" msgstr "" -#: howto/curses.rst:284 +#: howto/curses.rst:283 msgid "*str* or *ch*, *attr*" msgstr "" -#: howto/curses.rst:284 +#: howto/curses.rst:283 msgid "" "Display the string *str* or character *ch*, using attribute *attr* at the " "current position" msgstr "" -#: howto/curses.rst:288 +#: howto/curses.rst:287 msgid "*y*, *x*, *str* or *ch*" msgstr "" -#: howto/curses.rst:288 +#: howto/curses.rst:287 msgid "Move to position *y,x* within the window, and display *str* or *ch*" msgstr "" -#: howto/curses.rst:291 +#: howto/curses.rst:290 msgid "*y*, *x*, *str* or *ch*, *attr*" msgstr "" -#: howto/curses.rst:291 +#: howto/curses.rst:290 msgid "" "Move to position *y,x* within the window, and display *str* or *ch*, using " "attribute *attr*" msgstr "" -#: howto/curses.rst:295 +#: howto/curses.rst:294 msgid "" "Attributes allow displaying text in highlighted forms such as boldface, " "underline, reverse code, or in color. They'll be explained in more detail " "in the next subsection." msgstr "" -#: howto/curses.rst:300 +#: howto/curses.rst:299 msgid "" "The :meth:`~curses.window.addstr` method takes a Python string or bytestring " "as the value to be displayed. The contents of bytestrings are sent to the " @@ -400,13 +473,13 @@ msgid "" "system encoding as returned by :func:`locale.getencoding`." msgstr "" -#: howto/curses.rst:306 +#: howto/curses.rst:305 msgid "" "The :meth:`~curses.window.addch` methods take a character, which can be " "either a string of length 1, a bytestring of length 1, or an integer." msgstr "" -#: howto/curses.rst:309 +#: howto/curses.rst:308 msgid "" "Constants are provided for extension characters; these constants are " "integers greater than 255. For example, :const:`ACS_PLMINUS` is a +/- " @@ -414,7 +487,7 @@ msgid "" "for drawing borders). You can also use the appropriate Unicode character." msgstr "" -#: howto/curses.rst:315 +#: howto/curses.rst:314 msgid "" "Windows remember where the cursor was left after the last operation, so if " "you leave out the *y,x* coordinates, the string or character will be " @@ -425,21 +498,21 @@ msgid "" "cursor blinking at some apparently random location." msgstr "" -#: howto/curses.rst:323 +#: howto/curses.rst:322 msgid "" "If your application doesn't need a blinking cursor at all, you can call " "``curs_set(False)`` to make it invisible. For compatibility with older " -"curses versions, there's a ``leaveok(bool)`` function that's a synonym for :" -"func:`~curses.curs_set`. When *bool* is true, the curses library will " +"curses versions, there's a ``leaveok(bool)`` function that's a synonym " +"for :func:`~curses.curs_set`. When *bool* is true, the curses library will " "attempt to suppress the flashing cursor, and you won't need to worry about " "leaving it in odd locations." msgstr "" -#: howto/curses.rst:332 +#: howto/curses.rst:331 msgid "Attributes and Color" msgstr "" -#: howto/curses.rst:334 +#: howto/curses.rst:333 msgid "" "Characters can be displayed in different ways. Status lines in a text-based " "application are commonly shown in reverse video, or a text viewer may need " @@ -447,7 +520,7 @@ msgid "" "an attribute for each cell on the screen." msgstr "" -#: howto/curses.rst:339 +#: howto/curses.rst:338 msgid "" "An attribute is an integer, each bit representing a different attribute. " "You can try to display text with multiple attribute bits set, but curses " @@ -457,72 +530,79 @@ msgid "" "attributes, listed here." msgstr "" -#: howto/curses.rst:347 +#: howto/curses.rst:346 msgid "Attribute" msgstr "" -#: howto/curses.rst:349 +#: howto/curses.rst:348 msgid ":const:`A_BLINK`" msgstr "" -#: howto/curses.rst:349 +#: howto/curses.rst:348 msgid "Blinking text" msgstr "" -#: howto/curses.rst:351 +#: howto/curses.rst:350 msgid ":const:`A_BOLD`" msgstr "" -#: howto/curses.rst:351 +#: howto/curses.rst:350 msgid "Extra bright or bold text" msgstr "" -#: howto/curses.rst:353 +#: howto/curses.rst:352 msgid ":const:`A_DIM`" msgstr "" -#: howto/curses.rst:353 +#: howto/curses.rst:352 msgid "Half bright text" msgstr "" -#: howto/curses.rst:355 +#: howto/curses.rst:354 msgid ":const:`A_REVERSE`" msgstr "" -#: howto/curses.rst:355 +#: howto/curses.rst:354 msgid "Reverse-video text" msgstr "" -#: howto/curses.rst:357 +#: howto/curses.rst:356 msgid ":const:`A_STANDOUT`" msgstr "" -#: howto/curses.rst:357 +#: howto/curses.rst:356 msgid "The best highlighting mode available" msgstr "" -#: howto/curses.rst:359 +#: howto/curses.rst:358 msgid ":const:`A_UNDERLINE`" msgstr "" -#: howto/curses.rst:359 +#: howto/curses.rst:358 msgid "Underlined text" msgstr "" -#: howto/curses.rst:362 +#: howto/curses.rst:361 msgid "" "So, to display a reverse-video status line on the top line of the screen, " "you could code::" msgstr "" -#: howto/curses.rst:369 +#: howto/curses.rst:364 +msgid "" +"stdscr.addstr(0, 0, \"Current mode: Typing mode\",\n" +" curses.A_REVERSE)\n" +"stdscr.refresh()" +msgstr "" + +#: howto/curses.rst:368 msgid "" "The curses library also supports color on those terminals that provide it. " "The most common such terminal is probably the Linux console, followed by " "color xterms." msgstr "" -#: howto/curses.rst:373 +#: howto/curses.rst:372 msgid "" "To use color, you must call the :func:`~curses.start_color` function soon " "after calling :func:`~curses.initscr`, to initialize the default color set " @@ -534,21 +614,27 @@ msgid "" "for the sake of these functions.)" msgstr "" -#: howto/curses.rst:383 +#: howto/curses.rst:382 msgid "" "The curses library maintains a finite number of color pairs, containing a " "foreground (or text) color and a background color. You can get the " -"attribute value corresponding to a color pair with the :func:`~curses." -"color_pair` function; this can be bitwise-OR'ed with other attributes such " -"as :const:`A_REVERSE`, but again, such combinations are not guaranteed to " -"work on all terminals." +"attribute value corresponding to a color pair with " +"the :func:`~curses.color_pair` function; this can be bitwise-OR'ed with " +"other attributes such as :const:`A_REVERSE`, but again, such combinations " +"are not guaranteed to work on all terminals." msgstr "" -#: howto/curses.rst:390 +#: howto/curses.rst:389 msgid "An example, which displays a line of text using color pair 1::" msgstr "" -#: howto/curses.rst:395 +#: howto/curses.rst:391 +msgid "" +"stdscr.addstr(\"Pretty text\", curses.color_pair(1))\n" +"stdscr.refresh()" +msgstr "" + +#: howto/curses.rst:394 msgid "" "As I said before, a color pair consists of a foreground and background " "color. The ``init_pair(n, f, b)`` function changes the definition of color " @@ -556,57 +642,64 @@ msgid "" "hard-wired to white on black, and cannot be changed." msgstr "" -#: howto/curses.rst:400 +#: howto/curses.rst:399 msgid "" "Colors are numbered, and :func:`start_color` initializes 8 basic colors when " -"it activates color mode. They are: 0:black, 1:red, 2:green, 3:yellow, 4:" -"blue, 5:magenta, 6:cyan, and 7:white. The :mod:`curses` module defines " -"named constants for each of these colors: :const:`curses.COLOR_BLACK`, :" -"const:`curses.COLOR_RED`, and so forth." +"it activates color mode. They are: 0:black, 1:red, 2:green, 3:yellow, " +"4:blue, 5:magenta, 6:cyan, and 7:white. The :mod:`curses` module defines " +"named constants for each of these " +"colors: :const:`curses.COLOR_BLACK`, :const:`curses.COLOR_RED`, and so forth." msgstr "" -#: howto/curses.rst:406 +#: howto/curses.rst:405 msgid "" "Let's put all this together. To change color 1 to red text on a white " "background, you would call::" msgstr "" -#: howto/curses.rst:411 +#: howto/curses.rst:408 +msgid "curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)" +msgstr "" + +#: howto/curses.rst:410 msgid "" "When you change a color pair, any text already displayed using that color " "pair will change to the new colors. You can also display new text in this " "color with::" msgstr "" -#: howto/curses.rst:417 +#: howto/curses.rst:414 +msgid "stdscr.addstr(0,0, \"RED ALERT!\", curses.color_pair(1))" +msgstr "" + +#: howto/curses.rst:416 msgid "" "Very fancy terminals can change the definitions of the actual colors to a " "given RGB value. This lets you change color 1, which is usually red, to " "purple or blue or any other color you like. Unfortunately, the Linux " "console doesn't support this, so I'm unable to try it out, and can't provide " -"any examples. You can check if your terminal can do this by calling :func:" -"`~curses.can_change_color`, which returns ``True`` if the capability is " -"there. If you're lucky enough to have such a talented terminal, consult " -"your system's man pages for more information." +"any examples. You can check if your terminal can do this by " +"calling :func:`~curses.can_change_color`, which returns ``True`` if the " +"capability is there. If you're lucky enough to have such a talented " +"terminal, consult your system's man pages for more information." msgstr "" -#: howto/curses.rst:428 +#: howto/curses.rst:427 msgid "User Input" msgstr "" -#: howto/curses.rst:430 +#: howto/curses.rst:429 msgid "" -"The C curses library offers only very simple input mechanisms. Python's :mod:" -"`curses` module adds a basic text-input widget. (Other libraries such as " -"`Urwid `_ have more extensive collections " -"of widgets.)" +"The C curses library offers only very simple input mechanisms. " +"Python's :mod:`curses` module adds a basic text-input widget. (Other " +"libraries such as :pypi:`Urwid` have more extensive collections of widgets.)" msgstr "" -#: howto/curses.rst:435 +#: howto/curses.rst:433 msgid "There are two methods for getting input from a window:" msgstr "" -#: howto/curses.rst:437 +#: howto/curses.rst:435 msgid "" ":meth:`~curses.window.getch` refreshes the screen and then waits for the " "user to hit a key, displaying the key if :func:`~curses.echo` has been " @@ -614,7 +707,7 @@ msgid "" "should be moved before pausing." msgstr "" -#: howto/curses.rst:442 +#: howto/curses.rst:440 msgid "" ":meth:`~curses.window.getkey` does the same thing but converts the integer " "to a string. Individual characters are returned as 1-character strings, and " @@ -622,29 +715,43 @@ msgid "" "name such as ``KEY_UP`` or ``^G``." msgstr "" -#: howto/curses.rst:447 +#: howto/curses.rst:445 msgid "" -"It's possible to not wait for the user using the :meth:`~curses.window." -"nodelay` window method. After ``nodelay(True)``, :meth:`!getch` and :meth:`!" -"getkey` for the window become non-blocking. To signal that no input is " -"ready, :meth:`!getch` returns ``curses.ERR`` (a value of -1) and :meth:`!" -"getkey` raises an exception. There's also a :func:`~curses.halfdelay` " -"function, which can be used to (in effect) set a timer on each :meth:`!" -"getch`; if no input becomes available within a specified delay (measured in " -"tenths of a second), curses raises an exception." +"It's possible to not wait for the user using " +"the :meth:`~curses.window.nodelay` window method. After " +"``nodelay(True)``, :meth:`!getch` and :meth:`!getkey` for the window become " +"non-blocking. To signal that no input is ready, :meth:`!getch` returns " +"``curses.ERR`` (a value of -1) and :meth:`!getkey` raises an exception. " +"There's also a :func:`~curses.halfdelay` function, which can be used to (in " +"effect) set a timer on each :meth:`!getch`; if no input becomes available " +"within a specified delay (measured in tenths of a second), curses raises an " +"exception." msgstr "" -#: howto/curses.rst:457 +#: howto/curses.rst:455 msgid "" "The :meth:`!getch` method returns an integer; if it's between 0 and 255, it " "represents the ASCII code of the key pressed. Values greater than 255 are " "special keys such as Page Up, Home, or the cursor keys. You can compare the " -"value returned to constants such as :const:`curses.KEY_PPAGE`, :const:" -"`curses.KEY_HOME`, or :const:`curses.KEY_LEFT`. The main loop of your " -"program may look something like this::" +"value returned to constants such " +"as :const:`curses.KEY_PPAGE`, :const:`curses.KEY_HOME`, " +"or :const:`curses.KEY_LEFT`. The main loop of your program may look " +"something like this::" +msgstr "" + +#: howto/curses.rst:462 +msgid "" +"while True:\n" +" c = stdscr.getch()\n" +" if c == ord('p'):\n" +" PrintDocument()\n" +" elif c == ord('q'):\n" +" break # Exit the while loop\n" +" elif c == curses.KEY_HOME:\n" +" x = y = 0" msgstr "" -#: howto/curses.rst:473 +#: howto/curses.rst:471 msgid "" "The :mod:`curses.ascii` module supplies ASCII class membership functions " "that take either integer or 1-character string arguments; these may be " @@ -654,33 +761,63 @@ msgid "" "returns the control character corresponding to its argument." msgstr "" -#: howto/curses.rst:480 +#: howto/curses.rst:478 msgid "" -"There's also a method to retrieve an entire string, :meth:`~curses.window." -"getstr`. It isn't used very often, because its functionality is quite " -"limited; the only editing keys available are the backspace key and the Enter " -"key, which terminates the string. It can optionally be limited to a fixed " -"number of characters. ::" +"There's also a method to retrieve an entire " +"string, :meth:`~curses.window.getstr`. It isn't used very often, because " +"its functionality is quite limited; the only editing keys available are the " +"backspace key and the Enter key, which terminates the string. It can " +"optionally be limited to a fixed number of characters. ::" msgstr "" -#: howto/curses.rst:491 +#: howto/curses.rst:484 msgid "" -"The :mod:`curses.textpad` module supplies a text box that supports an Emacs-" -"like set of keybindings. Various methods of the :class:`~curses.textpad." -"Textbox` class support editing with input validation and gathering the edit " -"results either with or without trailing spaces. Here's an example::" +"curses.echo() # Enable echoing of characters\n" +"\n" +"# Get a 15-character string, with the cursor on the top line\n" +"s = stdscr.getstr(0,0, 15)" msgstr "" -#: howto/curses.rst:515 +#: howto/curses.rst:489 +msgid "" +"The :mod:`curses.textpad` module supplies a text box that supports an Emacs-" +"like set of keybindings. Various methods of " +"the :class:`~curses.textpad.Textbox` class support editing with input " +"validation and gathering the edit results either with or without trailing " +"spaces. Here's an example::" +msgstr "" + +#: howto/curses.rst:495 +msgid "" +"import curses\n" +"from curses.textpad import Textbox, rectangle\n" +"\n" +"def main(stdscr):\n" +" stdscr.addstr(0, 0, \"Enter IM message: (hit Ctrl-G to send)\")\n" +"\n" +" editwin = curses.newwin(5,30, 2,1)\n" +" rectangle(stdscr, 1,0, 1+5+1, 1+30+1)\n" +" stdscr.refresh()\n" +"\n" +" box = Textbox(editwin)\n" +"\n" +" # Let the user edit until Ctrl-G is struck.\n" +" box.edit()\n" +"\n" +" # Get resulting contents\n" +" message = box.gather()" +msgstr "" + +#: howto/curses.rst:513 msgid "" "See the library documentation on :mod:`curses.textpad` for more details." msgstr "" -#: howto/curses.rst:519 +#: howto/curses.rst:517 msgid "For More Information" msgstr "" -#: howto/curses.rst:521 +#: howto/curses.rst:519 msgid "" "This HOWTO doesn't cover some advanced topics, such as reading the contents " "of the screen or capturing mouse events from an xterm instance, but the " @@ -688,48 +825,48 @@ msgid "" "complete. You should browse it next." msgstr "" -#: howto/curses.rst:526 +#: howto/curses.rst:524 msgid "" "If you're in doubt about the detailed behavior of the curses functions, " "consult the manual pages for your curses implementation, whether it's " "ncurses or a proprietary Unix vendor's. The manual pages will document any " -"quirks, and provide complete lists of all the functions, attributes, and :" -"ref:`ACS_\\* ` characters available to you." +"quirks, and provide complete lists of all the functions, attributes, " +"and :ref:`ACS_\\* ` characters available to you." msgstr "" -#: howto/curses.rst:533 +#: howto/curses.rst:531 msgid "" "Because the curses API is so large, some functions aren't supported in the " "Python interface. Often this isn't because they're difficult to implement, " "but because no one has needed them yet. Also, Python doesn't yet support " "the menu library associated with ncurses. Patches adding support for these " -"would be welcome; see `the Python Developer's Guide `_ to learn more about submitting patches to Python." +"would be welcome; see `the Python Developer's Guide `_ to learn more about submitting patches to Python." msgstr "" -#: howto/curses.rst:541 +#: howto/curses.rst:539 msgid "" "`Writing Programs with NCURSES `_: a lengthy tutorial for C programmers." msgstr "" -#: howto/curses.rst:543 +#: howto/curses.rst:541 msgid "`The ncurses man page `_" msgstr "" -#: howto/curses.rst:544 +#: howto/curses.rst:542 msgid "" "`The ncurses FAQ `_" msgstr "" -#: howto/curses.rst:545 +#: howto/curses.rst:543 msgid "" "`\"Use curses... don't swear\" `_: video of a PyCon 2013 talk on controlling terminals using " "curses or Urwid." msgstr "" -#: howto/curses.rst:547 +#: howto/curses.rst:545 msgid "" "`\"Console Applications with Urwid\" `_: video of a PyCon CA 2012 talk demonstrating some " diff --git a/howto/descriptor.po b/howto/descriptor.po index e9ebf34f..ca0e7f10 100644 --- a/howto/descriptor.po +++ b/howto/descriptor.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -73,8 +74,9 @@ msgstr "" msgid "" "The last section has pure Python equivalents for built-in descriptors that " "are written in C. Read this if you're curious about how functions turn into " -"bound methods or about the implementation of common tools like :func:" -"`classmethod`, :func:`staticmethod`, :func:`property`, and :term:`__slots__`." +"bound methods or about the implementation of common tools " +"like :func:`classmethod`, :func:`staticmethod`, :func:`property`, " +"and :term:`__slots__`." msgstr "" #: howto/descriptor.rst:36 @@ -93,8 +95,15 @@ msgstr "" #: howto/descriptor.rst:45 msgid "" -"The :class:`Ten` class is a descriptor whose :meth:`__get__` method always " -"returns the constant ``10``:" +"The :class:`!Ten` class is a descriptor whose :meth:`~object.__get__` method " +"always returns the constant ``10``:" +msgstr "" + +#: howto/descriptor.rst:48 +msgid "" +"class Ten:\n" +" def __get__(self, obj, objtype=None):\n" +" return 10" msgstr "" #: howto/descriptor.rst:54 @@ -103,12 +112,28 @@ msgid "" "class:" msgstr "" +#: howto/descriptor.rst:56 +msgid "" +"class A:\n" +" x = 5 # Regular class attribute\n" +" y = Ten() # Descriptor instance" +msgstr "" + #: howto/descriptor.rst:62 msgid "" "An interactive session shows the difference between normal attribute lookup " "and descriptor lookup:" msgstr "" +#: howto/descriptor.rst:65 +msgid "" +">>> a = A() # Make an instance of class A\n" +">>> a.x # Normal attribute lookup\n" +"5\n" +">>> a.y # Descriptor lookup\n" +"10" +msgstr "" + #: howto/descriptor.rst:73 msgid "" "In the ``a.x`` attribute lookup, the dot operator finds ``'x': 5`` in the " @@ -144,20 +169,53 @@ msgid "" "constants:" msgstr "" +#: howto/descriptor.rst:93 +msgid "" +"import os\n" +"\n" +"class DirectorySize:\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" return len(os.listdir(obj.dirname))\n" +"\n" +"class Directory:\n" +"\n" +" size = DirectorySize() # Descriptor instance\n" +"\n" +" def __init__(self, dirname):\n" +" self.dirname = dirname # Regular instance attribute" +msgstr "" + #: howto/descriptor.rst:109 msgid "" "An interactive session shows that the lookup is dynamic — it computes " "different, updated answers each time::" msgstr "" +#: howto/descriptor.rst:112 +msgid "" +">>> s = Directory('songs')\n" +">>> g = Directory('games')\n" +">>> s.size # The songs directory has twenty " +"files\n" +"20\n" +">>> g.size # The games directory has three " +"files\n" +"3\n" +">>> os.remove('games/chess') # Delete a game\n" +">>> g.size # File count is automatically " +"updated\n" +"2" +msgstr "" + #: howto/descriptor.rst:122 msgid "" "Besides showing how descriptors can run computations, this example also " -"reveals the purpose of the parameters to :meth:`__get__`. The *self* " -"parameter is *size*, an instance of *DirectorySize*. The *obj* parameter is " -"either *g* or *s*, an instance of *Directory*. It is the *obj* parameter " -"that lets the :meth:`__get__` method learn the target directory. The " -"*objtype* parameter is the class *Directory*." +"reveals the purpose of the parameters to :meth:`~object.__get__`. The " +"*self* parameter is *size*, an instance of *DirectorySize*. The *obj* " +"parameter is either *g* or *s*, an instance of *Directory*. It is the *obj* " +"parameter that lets the :meth:`~object.__get__` method learn the target " +"directory. The *objtype* parameter is the class *Directory*." msgstr "" #: howto/descriptor.rst:131 @@ -169,8 +227,9 @@ msgid "" "A popular use for descriptors is managing access to instance data. The " "descriptor is assigned to a public attribute in the class dictionary while " "the actual data is stored as a private attribute in the instance " -"dictionary. The descriptor's :meth:`__get__` and :meth:`__set__` methods " -"are triggered when the public attribute is accessed." +"dictionary. The descriptor's :meth:`~object.__get__` " +"and :meth:`~object.__set__` methods are triggered when the public attribute " +"is accessed." msgstr "" #: howto/descriptor.rst:139 @@ -180,12 +239,71 @@ msgid "" "logs the lookup or update:" msgstr "" +#: howto/descriptor.rst:143 +msgid "" +"import logging\n" +"\n" +"logging.basicConfig(level=logging.INFO)\n" +"\n" +"class LoggedAgeAccess:\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" value = obj._age\n" +" logging.info('Accessing %r giving %r', 'age', value)\n" +" return value\n" +"\n" +" def __set__(self, obj, value):\n" +" logging.info('Updating %r to %r', 'age', value)\n" +" obj._age = value\n" +"\n" +"class Person:\n" +"\n" +" age = LoggedAgeAccess() # Descriptor instance\n" +"\n" +" def __init__(self, name, age):\n" +" self.name = name # Regular instance attribute\n" +" self.age = age # Calls __set__()\n" +"\n" +" def birthday(self):\n" +" self.age += 1 # Calls both __get__() and __set__()" +msgstr "" + #: howto/descriptor.rst:172 msgid "" "An interactive session shows that all access to the managed attribute *age* " "is logged, but that the regular attribute *name* is not logged:" msgstr "" +#: howto/descriptor.rst:181 +msgid "" +">>> mary = Person('Mary M', 30) # The initial age update is logged\n" +"INFO:root:Updating 'age' to 30\n" +">>> dave = Person('David D', 40)\n" +"INFO:root:Updating 'age' to 40\n" +"\n" +">>> vars(mary) # The actual data is in a private " +"attribute\n" +"{'name': 'Mary M', '_age': 30}\n" +">>> vars(dave)\n" +"{'name': 'David D', '_age': 40}\n" +"\n" +">>> mary.age # Access the data and log the " +"lookup\n" +"INFO:root:Accessing 'age' giving 30\n" +"30\n" +">>> mary.birthday() # Updates are logged as well\n" +"INFO:root:Accessing 'age' giving 30\n" +"INFO:root:Updating 'age' to 31\n" +"\n" +">>> dave.name # Regular attribute lookup isn't " +"logged\n" +"'David D'\n" +">>> dave.age # Only the managed attribute is " +"logged\n" +"INFO:root:Accessing 'age' giving 40\n" +"40" +msgstr "" + #: howto/descriptor.rst:206 msgid "" "One major issue with this example is that the private name *_age* is " @@ -206,44 +324,106 @@ msgstr "" #: howto/descriptor.rst:218 msgid "" -"In this example, the :class:`Person` class has two descriptor instances, " -"*name* and *age*. When the :class:`Person` class is defined, it makes a " -"callback to :meth:`__set_name__` in *LoggedAccess* so that the field names " -"can be recorded, giving each descriptor its own *public_name* and " +"In this example, the :class:`!Person` class has two descriptor instances, " +"*name* and *age*. When the :class:`!Person` class is defined, it makes a " +"callback to :meth:`~object.__set_name__` in *LoggedAccess* so that the field " +"names can be recorded, giving each descriptor its own *public_name* and " "*private_name*:" msgstr "" +#: howto/descriptor.rst:223 +msgid "" +"import logging\n" +"\n" +"logging.basicConfig(level=logging.INFO)\n" +"\n" +"class LoggedAccess:\n" +"\n" +" def __set_name__(self, owner, name):\n" +" self.public_name = name\n" +" self.private_name = '_' + name\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" value = getattr(obj, self.private_name)\n" +" logging.info('Accessing %r giving %r', self.public_name, value)\n" +" return value\n" +"\n" +" def __set__(self, obj, value):\n" +" logging.info('Updating %r to %r', self.public_name, value)\n" +" setattr(obj, self.private_name, value)\n" +"\n" +"class Person:\n" +"\n" +" name = LoggedAccess() # First descriptor instance\n" +" age = LoggedAccess() # Second descriptor instance\n" +"\n" +" def __init__(self, name, age):\n" +" self.name = name # Calls the first descriptor\n" +" self.age = age # Calls the second descriptor\n" +"\n" +" def birthday(self):\n" +" self.age += 1" +msgstr "" + #: howto/descriptor.rst:256 msgid "" -"An interactive session shows that the :class:`Person` class has called :meth:" -"`__set_name__` so that the field names would be recorded. Here we call :" -"func:`vars` to look up the descriptor without triggering it:" +"An interactive session shows that the :class:`!Person` class has " +"called :meth:`~object.__set_name__` so that the field names would be " +"recorded. Here we call :func:`vars` to look up the descriptor without " +"triggering it:" +msgstr "" + +#: howto/descriptor.rst:260 +msgid "" +">>> vars(vars(Person)['name'])\n" +"{'public_name': 'name', 'private_name': '_name'}\n" +">>> vars(vars(Person)['age'])\n" +"{'public_name': 'age', 'private_name': '_age'}" msgstr "" #: howto/descriptor.rst:267 msgid "The new class now logs access to both *name* and *age*:" msgstr "" +#: howto/descriptor.rst:275 +msgid "" +">>> pete = Person('Peter P', 10)\n" +"INFO:root:Updating 'name' to 'Peter P'\n" +"INFO:root:Updating 'age' to 10\n" +">>> kate = Person('Catherine C', 20)\n" +"INFO:root:Updating 'name' to 'Catherine C'\n" +"INFO:root:Updating 'age' to 20" +msgstr "" + #: howto/descriptor.rst:284 msgid "The two *Person* instances contain only the private names:" msgstr "" +#: howto/descriptor.rst:286 +msgid "" +">>> vars(pete)\n" +"{'_name': 'Peter P', '_age': 10}\n" +">>> vars(kate)\n" +"{'_name': 'Catherine C', '_age': 20}" +msgstr "" + #: howto/descriptor.rst:295 msgid "Closing thoughts" msgstr "" #: howto/descriptor.rst:297 msgid "" -"A :term:`descriptor` is what we call any object that defines :meth:" -"`__get__`, :meth:`__set__`, or :meth:`__delete__`." +"A :term:`descriptor` is what we call any object that " +"defines :meth:`~object.__get__`, :meth:`~object.__set__`, " +"or :meth:`~object.__delete__`." msgstr "" #: howto/descriptor.rst:300 msgid "" -"Optionally, descriptors can have a :meth:`__set_name__` method. This is " -"only used in cases where a descriptor needs to know either the class where " -"it was created or the name of class variable it was assigned to. (This " -"method, if present, is called even if the class is not a descriptor.)" +"Optionally, descriptors can have a :meth:`~object.__set_name__` method. " +"This is only used in cases where a descriptor needs to know either the class " +"where it was created or the name of class variable it was assigned to. " +"(This method, if present, is called even if the class is not a descriptor.)" msgstr "" #: howto/descriptor.rst:305 @@ -275,9 +455,9 @@ msgstr "" #: howto/descriptor.rst:319 msgid "" "Descriptors are used throughout the language. It is how functions turn into " -"bound methods. Common tools like :func:`classmethod`, :func:" -"`staticmethod`, :func:`property`, and :func:`functools.cached_property` are " -"all implemented as descriptors." +"bound methods. Common tools " +"like :func:`classmethod`, :func:`staticmethod`, :func:`property`, " +"and :func:`functools.cached_property` are all implemented as descriptors." msgstr "" #: howto/descriptor.rst:326 @@ -304,14 +484,35 @@ msgstr "" #: howto/descriptor.rst:340 msgid "" -"This :class:`Validator` class is both an :term:`abstract base class` and a " +"This :class:`!Validator` class is both an :term:`abstract base class` and a " "managed attribute descriptor:" msgstr "" +#: howto/descriptor.rst:343 +msgid "" +"from abc import ABC, abstractmethod\n" +"\n" +"class Validator(ABC):\n" +"\n" +" def __set_name__(self, owner, name):\n" +" self.private_name = '_' + name\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" return getattr(obj, self.private_name)\n" +"\n" +" def __set__(self, obj, value):\n" +" self.validate(value)\n" +" setattr(obj, self.private_name, value)\n" +"\n" +" @abstractmethod\n" +" def validate(self, value):\n" +" pass" +msgstr "" + #: howto/descriptor.rst:363 msgid "" -"Custom validators need to inherit from :class:`Validator` and must supply a :" -"meth:`validate` method to test various restrictions as needed." +"Custom validators need to inherit from :class:`!Validator` and must supply " +"a :meth:`!validate` method to test various restrictions as needed." msgstr "" #: howto/descriptor.rst:368 @@ -324,24 +525,79 @@ msgstr "" #: howto/descriptor.rst:372 msgid "" -":class:`OneOf` verifies that a value is one of a restricted set of options." +":class:`!OneOf` verifies that a value is one of a restricted set of options." msgstr "" #: howto/descriptor.rst:374 msgid "" -":class:`Number` verifies that a value is either an :class:`int` or :class:" -"`float`. Optionally, it verifies that a value is between a given minimum or " -"maximum." +":class:`!Number` verifies that a value is either an :class:`int` " +"or :class:`float`. Optionally, it verifies that a value is between a given " +"minimum or maximum." msgstr "" #: howto/descriptor.rst:378 msgid "" -":class:`String` verifies that a value is a :class:`str`. Optionally, it " +":class:`!String` verifies that a value is a :class:`str`. Optionally, it " "validates a given minimum or maximum length. It can validate a user-defined " "`predicate `_ " "as well." msgstr "" +#: howto/descriptor.rst:383 +msgid "" +"class OneOf(Validator):\n" +"\n" +" def __init__(self, *options):\n" +" self.options = set(options)\n" +"\n" +" def validate(self, value):\n" +" if value not in self.options:\n" +" raise ValueError(f'Expected {value!r} to be one of {self.options!" +"r}')\n" +"\n" +"class Number(Validator):\n" +"\n" +" def __init__(self, minvalue=None, maxvalue=None):\n" +" self.minvalue = minvalue\n" +" self.maxvalue = maxvalue\n" +"\n" +" def validate(self, value):\n" +" if not isinstance(value, (int, float)):\n" +" raise TypeError(f'Expected {value!r} to be an int or float')\n" +" if self.minvalue is not None and value < self.minvalue:\n" +" raise ValueError(\n" +" f'Expected {value!r} to be at least {self.minvalue!r}'\n" +" )\n" +" if self.maxvalue is not None and value > self.maxvalue:\n" +" raise ValueError(\n" +" f'Expected {value!r} to be no more than {self.maxvalue!r}'\n" +" )\n" +"\n" +"class String(Validator):\n" +"\n" +" def __init__(self, minsize=None, maxsize=None, predicate=None):\n" +" self.minsize = minsize\n" +" self.maxsize = maxsize\n" +" self.predicate = predicate\n" +"\n" +" def validate(self, value):\n" +" if not isinstance(value, str):\n" +" raise TypeError(f'Expected {value!r} to be an str')\n" +" if self.minsize is not None and len(value) < self.minsize:\n" +" raise ValueError(\n" +" f'Expected {value!r} to be no smaller than {self.minsize!" +"r}'\n" +" )\n" +" if self.maxsize is not None and len(value) > self.maxsize:\n" +" raise ValueError(\n" +" f'Expected {value!r} to be no bigger than {self.maxsize!r}'\n" +" )\n" +" if self.predicate is not None and not self.predicate(value):\n" +" raise ValueError(\n" +" f'Expected {self.predicate} to be true for {value!r}'\n" +" )" +msgstr "" + #: howto/descriptor.rst:437 msgid "Practical application" msgstr "" @@ -350,10 +606,50 @@ msgstr "" msgid "Here's how the data validators can be used in a real class:" msgstr "" +#: howto/descriptor.rst:441 +msgid "" +"class Component:\n" +"\n" +" name = String(minsize=3, maxsize=10, predicate=str.isupper)\n" +" kind = OneOf('wood', 'metal', 'plastic')\n" +" quantity = Number(minvalue=0)\n" +"\n" +" def __init__(self, name, kind, quantity):\n" +" self.name = name\n" +" self.kind = kind\n" +" self.quantity = quantity" +msgstr "" + #: howto/descriptor.rst:454 msgid "The descriptors prevent invalid instances from being created:" msgstr "" +#: howto/descriptor.rst:456 +msgid "" +">>> Component('Widget', 'metal', 5) # Blocked: 'Widget' is not all " +"uppercase\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: Expected to be true for " +"'Widget'\n" +"\n" +">>> Component('WIDGET', 'metle', 5) # Blocked: 'metle' is misspelled\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: Expected 'metle' to be one of {'metal', 'plastic', 'wood'}\n" +"\n" +">>> Component('WIDGET', 'metal', -5) # Blocked: -5 is negative\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: Expected -5 to be at least 0\n" +">>> Component('WIDGET', 'metal', 'V') # Blocked: 'V' isn't a number\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: Expected 'V' to be an int or float\n" +"\n" +">>> c = Component('WIDGET', 'metal', 5) # Allowed: The inputs are valid" +msgstr "" + #: howto/descriptor.rst:481 msgid "Technical Tutorial" msgstr "" @@ -387,9 +683,10 @@ msgstr "" #: howto/descriptor.rst:500 msgid "" "In general, a descriptor is an attribute value that has one of the methods " -"in the descriptor protocol. Those methods are :meth:`__get__`, :meth:" -"`__set__`, and :meth:`__delete__`. If any of those methods are defined for " -"an attribute, it is said to be a :term:`descriptor`." +"in the descriptor protocol. Those methods " +"are :meth:`~object.__get__`, :meth:`~object.__set__`, " +"and :meth:`~object.__delete__`. If any of those methods are defined for an " +"attribute, it is said to be a :term:`descriptor`." msgstr "" #: howto/descriptor.rst:505 @@ -407,8 +704,8 @@ msgstr "" #: howto/descriptor.rst:514 msgid "" "Descriptors are a powerful, general purpose protocol. They are the " -"mechanism behind properties, methods, static methods, class methods, and :" -"func:`super()`. They are used throughout Python itself. Descriptors " +"mechanism behind properties, methods, static methods, class methods, " +"and :func:`super`. They are used throughout Python itself. Descriptors " "simplify the underlying C code and offer a flexible set of new tools for " "everyday Python programs." msgstr "" @@ -438,10 +735,10 @@ msgstr "" #: howto/descriptor.rst:534 msgid "" -"If an object defines :meth:`__set__` or :meth:`__delete__`, it is considered " -"a data descriptor. Descriptors that only define :meth:`__get__` are called " -"non-data descriptors (they are often used for methods but other uses are " -"possible)." +"If an object defines :meth:`~object.__set__` or :meth:`~object.__delete__`, " +"it is considered a data descriptor. Descriptors that only " +"define :meth:`~object.__get__` are called non-data descriptors (they are " +"often used for methods but other uses are possible)." msgstr "" #: howto/descriptor.rst:539 @@ -455,10 +752,11 @@ msgstr "" #: howto/descriptor.rst:545 msgid "" -"To make a read-only data descriptor, define both :meth:`__get__` and :meth:" -"`__set__` with the :meth:`__set__` raising an :exc:`AttributeError` when " -"called. Defining the :meth:`__set__` method with an exception raising " -"placeholder is enough to make it a data descriptor." +"To make a read-only data descriptor, define both :meth:`~object.__get__` " +"and :meth:`~object.__set__` with the :meth:`~object.__set__` raising " +"an :exc:`AttributeError` when called. Defining the :meth:`~object.__set__` " +"method with an exception raising placeholder is enough to make it a data " +"descriptor." msgstr "" #: howto/descriptor.rst:552 @@ -467,8 +765,8 @@ msgstr "" #: howto/descriptor.rst:554 msgid "" -"A descriptor can be called directly with ``desc.__get__(obj)`` or ``desc." -"__get__(None, cls)``." +"A descriptor can be called directly with ``desc.__get__(obj)`` or " +"``desc.__get__(None, cls)``." msgstr "" #: howto/descriptor.rst:557 @@ -481,8 +779,8 @@ msgstr "" msgid "" "The expression ``obj.x`` looks up the attribute ``x`` in the chain of " "namespaces for ``obj``. If the search finds a descriptor outside of the " -"instance ``__dict__``, its :meth:`__get__` method is invoked according to " -"the precedence rules listed below." +"instance :attr:`~object.__dict__`, its :meth:`~object.__get__` method is " +"invoked according to the precedence rules listed below." msgstr "" #: howto/descriptor.rst:565 @@ -499,14 +797,14 @@ msgstr "" msgid "" "Instance lookup scans through a chain of namespaces giving data descriptors " "the highest priority, followed by instance variables, then non-data " -"descriptors, then class variables, and lastly :meth:`__getattr__` if it is " -"provided." +"descriptors, then class variables, and lastly :meth:`~object.__getattr__` if " +"it is provided." msgstr "" #: howto/descriptor.rst:577 msgid "" -"If a descriptor is found for ``a.x``, then it is invoked with: ``desc." -"__get__(a, type(a))``." +"If a descriptor is found for ``a.x``, then it is invoked with: " +"``desc.__get__(a, type(a))``." msgstr "" #: howto/descriptor.rst:580 @@ -515,19 +813,62 @@ msgid "" "is a pure Python equivalent:" msgstr "" +#: howto/descriptor.rst:583 +msgid "" +"def find_name_in_mro(cls, name, default):\n" +" \"Emulate _PyType_Lookup() in Objects/typeobject.c\"\n" +" for base in cls.__mro__:\n" +" if name in vars(base):\n" +" return vars(base)[name]\n" +" return default\n" +"\n" +"def object_getattribute(obj, name):\n" +" \"Emulate PyObject_GenericGetAttr() in Objects/object.c\"\n" +" null = object()\n" +" objtype = type(obj)\n" +" cls_var = find_name_in_mro(objtype, name, null)\n" +" descr_get = getattr(type(cls_var), '__get__', null)\n" +" if descr_get is not null:\n" +" if (hasattr(type(cls_var), '__set__')\n" +" or hasattr(type(cls_var), '__delete__')):\n" +" return descr_get(cls_var, obj, objtype) # data descriptor\n" +" if hasattr(obj, '__dict__') and name in vars(obj):\n" +" return vars(obj)[name] # instance variable\n" +" if descr_get is not null:\n" +" return descr_get(cls_var, obj, objtype) # non-data " +"descriptor\n" +" if cls_var is not null:\n" +" return cls_var # class variable\n" +" raise AttributeError(name)" +msgstr "" + #: howto/descriptor.rst:719 msgid "" -"Note, there is no :meth:`__getattr__` hook in the :meth:`__getattribute__` " -"code. That is why calling :meth:`__getattribute__` directly or with " -"``super().__getattribute__`` will bypass :meth:`__getattr__` entirely." +"Note, there is no :meth:`~object.__getattr__` hook in " +"the :meth:`~object.__getattribute__` code. That is why " +"calling :meth:`~object.__getattribute__` directly or with " +"``super().__getattribute__`` will bypass :meth:`~object.__getattr__` " +"entirely." msgstr "" #: howto/descriptor.rst:723 msgid "" "Instead, it is the dot operator and the :func:`getattr` function that are " -"responsible for invoking :meth:`__getattr__` whenever :meth:" -"`__getattribute__` raises an :exc:`AttributeError`. Their logic is " -"encapsulated in a helper function:" +"responsible for invoking :meth:`~object.__getattr__` " +"whenever :meth:`~object.__getattribute__` raises an :exc:`AttributeError`. " +"Their logic is encapsulated in a helper function:" +msgstr "" + +#: howto/descriptor.rst:728 +msgid "" +"def getattr_hook(obj, name):\n" +" \"Emulate slot_tp_getattr_hook() in Objects/typeobject.c\"\n" +" try:\n" +" return obj.__getattribute__(name)\n" +" except AttributeError:\n" +" if not hasattr(type(obj), '__getattr__'):\n" +" raise\n" +" return type(obj).__getattr__(obj, name) # __getattr__" msgstr "" #: howto/descriptor.rst:773 @@ -536,10 +877,10 @@ msgstr "" #: howto/descriptor.rst:775 msgid "" -"The logic for a dotted lookup such as ``A.x`` is in :meth:`type." -"__getattribute__`. The steps are similar to those for :meth:`object." -"__getattribute__` but the instance dictionary lookup is replaced by a search " -"through the class's :term:`method resolution order`." +"The logic for a dotted lookup such as ``A.x`` is in :meth:`!" +"type.__getattribute__`. The steps are similar to those for :meth:`!" +"object.__getattribute__` but the instance dictionary lookup is replaced by a " +"search through the class's :term:`method resolution order`." msgstr "" #: howto/descriptor.rst:780 @@ -548,8 +889,8 @@ msgstr "" #: howto/descriptor.rst:782 msgid "" -"The full C implementation can be found in :c:func:`!type_getattro` and :c:" -"func:`!_PyType_Lookup` in :source:`Objects/typeobject.c`." +"The full C implementation can be found in :c:func:`!type_getattro` " +"and :c:func:`!_PyType_Lookup` in :source:`Objects/typeobject.c`." msgstr "" #: howto/descriptor.rst:787 @@ -558,22 +899,23 @@ msgstr "" #: howto/descriptor.rst:789 msgid "" -"The logic for super's dotted lookup is in the :meth:`__getattribute__` " -"method for object returned by :class:`super()`." +"The logic for super's dotted lookup is in " +"the :meth:`~object.__getattribute__` method for object returned " +"by :func:`super`." msgstr "" #: howto/descriptor.rst:792 msgid "" -"A dotted lookup such as ``super(A, obj).m`` searches ``obj.__class__." -"__mro__`` for the base class ``B`` immediately following ``A`` and then " -"returns ``B.__dict__['m'].__get__(obj, A)``. If not a descriptor, ``m`` is " -"returned unchanged." +"A dotted lookup such as ``super(A, obj).m`` searches " +"``obj.__class__.__mro__`` for the base class ``B`` immediately following " +"``A`` and then returns ``B.__dict__['m'].__get__(obj, A)``. If not a " +"descriptor, ``m`` is returned unchanged." msgstr "" #: howto/descriptor.rst:797 msgid "" -"The full C implementation can be found in :c:func:`!super_getattro` in :" -"source:`Objects/typeobject.c`. A pure Python equivalent can be found in " +"The full C implementation can be found in :c:func:`!super_getattro` " +"in :source:`Objects/typeobject.c`. A pure Python equivalent can be found in " "`Guido's Tutorial `_." msgstr "" @@ -584,8 +926,9 @@ msgstr "" #: howto/descriptor.rst:806 msgid "" -"The mechanism for descriptors is embedded in the :meth:`__getattribute__()` " -"methods for :class:`object`, :class:`type`, and :func:`super`." +"The mechanism for descriptors is embedded in " +"the :meth:`~object.__getattribute__` methods " +"for :class:`object`, :class:`type`, and :func:`super`." msgstr "" #: howto/descriptor.rst:809 @@ -593,27 +936,27 @@ msgid "The important points to remember are:" msgstr "" #: howto/descriptor.rst:811 -msgid "Descriptors are invoked by the :meth:`__getattribute__` method." +msgid "Descriptors are invoked by the :meth:`~object.__getattribute__` method." msgstr "" #: howto/descriptor.rst:813 msgid "" -"Classes inherit this machinery from :class:`object`, :class:`type`, or :func:" -"`super`." +"Classes inherit this machinery from :class:`object`, :class:`type`, " +"or :func:`super`." msgstr "" #: howto/descriptor.rst:816 msgid "" -"Overriding :meth:`__getattribute__` prevents automatic descriptor calls " -"because all the descriptor logic is in that method." +"Overriding :meth:`~object.__getattribute__` prevents automatic descriptor " +"calls because all the descriptor logic is in that method." msgstr "" #: howto/descriptor.rst:819 msgid "" -":meth:`object.__getattribute__` and :meth:`type.__getattribute__` make " -"different calls to :meth:`__get__`. The first includes the instance and may " -"include the class. The second puts in ``None`` for the instance and always " -"includes the class." +":meth:`!object.__getattribute__` and :meth:`!type.__getattribute__` make " +"different calls to :meth:`~object.__get__`. The first includes the instance " +"and may include the class. The second puts in ``None`` for the instance and " +"always includes the class." msgstr "" #: howto/descriptor.rst:824 @@ -633,9 +976,9 @@ msgid "" "Sometimes it is desirable for a descriptor to know what class variable name " "it was assigned to. When a new class is created, the :class:`type` " "metaclass scans the dictionary of the new class. If any of the entries are " -"descriptors and if they define :meth:`__set_name__`, that method is called " -"with two arguments. The *owner* is the class where the descriptor is used, " -"and the *name* is the class variable the descriptor was assigned to." +"descriptors and if they define :meth:`~object.__set_name__`, that method is " +"called with two arguments. The *owner* is the class where the descriptor is " +"used, and the *name* is the class variable the descriptor was assigned to." msgstr "" #: howto/descriptor.rst:839 @@ -646,9 +989,9 @@ msgstr "" #: howto/descriptor.rst:842 msgid "" -"Since the update logic is in :meth:`type.__new__`, notifications only take " +"Since the update logic is in :meth:`!type.__new__`, notifications only take " "place at the time of class creation. If descriptors are added to the class " -"afterwards, :meth:`__set_name__` will need to be called manually." +"afterwards, :meth:`~object.__set_name__` will need to be called manually." msgstr "" #: howto/descriptor.rst:848 @@ -658,8 +1001,8 @@ msgstr "" #: howto/descriptor.rst:850 msgid "" "The following code is a simplified skeleton showing how data descriptors " -"could be used to implement an `object relational mapping `_." +"could be used to implement an `object relational mapping `_." msgstr "" #: howto/descriptor.rst:854 @@ -669,23 +1012,85 @@ msgid "" "care of lookups or updates:" msgstr "" +#: howto/descriptor.rst:858 +msgid "" +"class Field:\n" +"\n" +" def __set_name__(self, owner, name):\n" +" self.fetch = f'SELECT {name} FROM {owner.table} WHERE {owner.key}" +"=?;'\n" +" self.store = f'UPDATE {owner.table} SET {name}=? WHERE {owner.key}" +"=?;'\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" return conn.execute(self.fetch, [obj.key]).fetchone()[0]\n" +"\n" +" def __set__(self, obj, value):\n" +" conn.execute(self.store, [value, obj.key])\n" +" conn.commit()" +msgstr "" + #: howto/descriptor.rst:873 msgid "" -"We can use the :class:`Field` class to define `models `_ that describe the schema for each table in a " -"database:" +"We can use the :class:`!Field` class to define `models `_ that describe the schema for each " +"table in a database:" +msgstr "" + +#: howto/descriptor.rst:877 +msgid "" +"class Movie:\n" +" table = 'Movies' # Table name\n" +" key = 'title' # Primary key\n" +" director = Field()\n" +" year = Field()\n" +"\n" +" def __init__(self, key):\n" +" self.key = key\n" +"\n" +"class Song:\n" +" table = 'Music'\n" +" key = 'title'\n" +" artist = Field()\n" +" year = Field()\n" +" genre = Field()\n" +"\n" +" def __init__(self, key):\n" +" self.key = key" msgstr "" #: howto/descriptor.rst:898 msgid "To use the models, first connect to the database::" msgstr "" +#: howto/descriptor.rst:900 +msgid "" +">>> import sqlite3\n" +">>> conn = sqlite3.connect('entertainment.db')" +msgstr "" + #: howto/descriptor.rst:903 msgid "" "An interactive session shows how data is retrieved from the database and how " "it can be updated:" msgstr "" +#: howto/descriptor.rst:931 +msgid "" +">>> Movie('Star Wars').director\n" +"'George Lucas'\n" +">>> jaws = Movie('Jaws')\n" +">>> f'Released in {jaws.year} by {jaws.director}'\n" +"'Released in 1975 by Steven Spielberg'\n" +"\n" +">>> Song('Country Roads').artist\n" +"'John Denver'\n" +"\n" +">>> Movie('Star Wars').director = 'J.J. Abrams'\n" +">>> Movie('Star Wars').director\n" +"'J.J. Abrams'" +msgstr "" + #: howto/descriptor.rst:952 msgid "Pure Python Equivalents" msgstr "" @@ -709,17 +1114,89 @@ msgid "" "is::" msgstr "" +#: howto/descriptor.rst:966 +msgid "property(fget=None, fset=None, fdel=None, doc=None) -> property" +msgstr "" + #: howto/descriptor.rst:968 msgid "" "The documentation shows a typical use to define a managed attribute ``x``:" msgstr "" +#: howto/descriptor.rst:970 +msgid "" +"class C:\n" +" def getx(self): return self.__x\n" +" def setx(self, value): self.__x = value\n" +" def delx(self): del self.__x\n" +" x = property(getx, setx, delx, \"I'm the 'x' property.\")" +msgstr "" + #: howto/descriptor.rst:992 msgid "" "To see how :func:`property` is implemented in terms of the descriptor " "protocol, here is a pure Python equivalent:" msgstr "" +#: howto/descriptor.rst:995 +msgid "" +"class Property:\n" +" \"Emulate PyProperty_Type() in Objects/descrobject.c\"\n" +"\n" +" def __init__(self, fget=None, fset=None, fdel=None, doc=None):\n" +" self.fget = fget\n" +" self.fset = fset\n" +" self.fdel = fdel\n" +" if doc is None and fget is not None:\n" +" doc = fget.__doc__\n" +" self.__doc__ = doc\n" +" self._name = ''\n" +"\n" +" def __set_name__(self, owner, name):\n" +" self._name = name\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" if obj is None:\n" +" return self\n" +" if self.fget is None:\n" +" raise AttributeError(\n" +" f'property {self._name!r} of {type(obj).__name__!r} object " +"has no getter'\n" +" )\n" +" return self.fget(obj)\n" +"\n" +" def __set__(self, obj, value):\n" +" if self.fset is None:\n" +" raise AttributeError(\n" +" f'property {self._name!r} of {type(obj).__name__!r} object " +"has no setter'\n" +" )\n" +" self.fset(obj, value)\n" +"\n" +" def __delete__(self, obj):\n" +" if self.fdel is None:\n" +" raise AttributeError(\n" +" f'property {self._name!r} of {type(obj).__name__!r} object " +"has no deleter'\n" +" )\n" +" self.fdel(obj)\n" +"\n" +" def getter(self, fget):\n" +" prop = type(self)(fget, self.fset, self.fdel, self.__doc__)\n" +" prop._name = self._name\n" +" return prop\n" +"\n" +" def setter(self, fset):\n" +" prop = type(self)(self.fget, fset, self.fdel, self.__doc__)\n" +" prop._name = self._name\n" +" return prop\n" +"\n" +" def deleter(self, fdel):\n" +" prop = type(self)(self.fget, self.fset, fdel, self.__doc__)\n" +" prop._name = self._name\n" +" return prop" +msgstr "" + #: howto/descriptor.rst:1132 msgid "" "The :func:`property` builtin helps whenever a user interface has granted " @@ -737,9 +1214,21 @@ msgid "" "descriptor:" msgstr "" +#: howto/descriptor.rst:1142 +msgid "" +"class Cell:\n" +" ...\n" +"\n" +" @property\n" +" def value(self):\n" +" \"Recalculate the cell before returning value\"\n" +" self.recalc()\n" +" return self._value" +msgstr "" + #: howto/descriptor.rst:1153 msgid "" -"Either the built-in :func:`property` or our :func:`Property` equivalent " +"Either the built-in :func:`property` or our :func:`!Property` equivalent " "would work in this example." msgstr "" @@ -767,12 +1256,39 @@ msgid "" "roughly equivalent to:" msgstr "" +#: howto/descriptor.rst:1171 +msgid "" +"class MethodType:\n" +" \"Emulate PyMethod_Type in Objects/classobject.c\"\n" +"\n" +" def __init__(self, func, obj):\n" +" self.__func__ = func\n" +" self.__self__ = obj\n" +"\n" +" def __call__(self, *args, **kwargs):\n" +" func = self.__func__\n" +" obj = self.__self__\n" +" return func(obj, *args, **kwargs)" +msgstr "" + #: howto/descriptor.rst:1185 msgid "" -"To support automatic creation of methods, functions include the :meth:" -"`__get__` method for binding methods during attribute access. This means " -"that functions are non-data descriptors that return bound methods during " -"dotted lookup from an instance. Here's how it works:" +"To support automatic creation of methods, functions include " +"the :meth:`~object.__get__` method for binding methods during attribute " +"access. This means that functions are non-data descriptors that return " +"bound methods during dotted lookup from an instance. Here's how it works:" +msgstr "" + +#: howto/descriptor.rst:1190 +msgid "" +"class Function:\n" +" ...\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" \"Simulate func_descr_get() in Objects/funcobject.c\"\n" +" if obj is None:\n" +" return self\n" +" return MethodType(self, obj)" msgstr "" #: howto/descriptor.rst:1201 @@ -781,27 +1297,61 @@ msgid "" "descriptor works in practice:" msgstr "" +#: howto/descriptor.rst:1204 +msgid "" +"class D:\n" +" def f(self, x):\n" +" return x" +msgstr "" + #: howto/descriptor.rst:1210 msgid "" "The function has a :term:`qualified name` attribute to support introspection:" msgstr "" +#: howto/descriptor.rst:1212 +msgid "" +">>> D.f.__qualname__\n" +"'D.f'" +msgstr "" + #: howto/descriptor.rst:1217 msgid "" -"Accessing the function through the class dictionary does not invoke :meth:" -"`__get__`. Instead, it just returns the underlying function object::" +"Accessing the function through the class dictionary does not " +"invoke :meth:`~object.__get__`. Instead, it just returns the underlying " +"function object::" +msgstr "" + +#: howto/descriptor.rst:1220 +msgid "" +">>> D.__dict__['f']\n" +"" msgstr "" #: howto/descriptor.rst:1223 msgid "" -"Dotted access from a class calls :meth:`__get__` which just returns the " -"underlying function unchanged::" +"Dotted access from a class calls :meth:`~object.__get__` which just returns " +"the underlying function unchanged::" +msgstr "" + +#: howto/descriptor.rst:1226 +msgid "" +">>> D.f\n" +"" msgstr "" #: howto/descriptor.rst:1229 msgid "" "The interesting behavior occurs during dotted access from an instance. The " -"dotted lookup calls :meth:`__get__` which returns a bound method object::" +"dotted lookup calls :meth:`~object.__get__` which returns a bound method " +"object::" +msgstr "" + +#: howto/descriptor.rst:1232 +msgid "" +">>> d = D()\n" +">>> d.f\n" +">" msgstr "" #: howto/descriptor.rst:1236 @@ -810,6 +1360,15 @@ msgid "" "instance::" msgstr "" +#: howto/descriptor.rst:1239 +msgid "" +">>> d.f.__func__\n" +"\n" +"\n" +">>> d.f.__self__\n" +"<__main__.D object at 0x00B18C90>" +msgstr "" + #: howto/descriptor.rst:1245 msgid "" "If you have ever wondered where *self* comes from in regular methods or " @@ -828,10 +1387,10 @@ msgstr "" #: howto/descriptor.rst:1255 msgid "" -"To recap, functions have a :meth:`__get__` method so that they can be " -"converted to a method when accessed as attributes. The non-data descriptor " -"transforms an ``obj.f(*args)`` call into ``f(obj, *args)``. Calling ``cls." -"f(*args)`` becomes ``f(*args)``." +"To recap, functions have a :meth:`~object.__get__` method so that they can " +"be converted to a method when accessed as attributes. The non-data " +"descriptor transforms an ``obj.f(*args)`` call into ``f(obj, *args)``. " +"Calling ``cls.f(*args)`` becomes ``f(*args)``." msgstr "" #: howto/descriptor.rst:1260 @@ -885,10 +1444,10 @@ msgstr "" #: howto/descriptor.rst:1277 msgid "" "Static methods return the underlying function without changes. Calling " -"either ``c.f`` or ``C.f`` is the equivalent of a direct lookup into ``object." -"__getattribute__(c, \"f\")`` or ``object.__getattribute__(C, \"f\")``. As a " -"result, the function becomes identically accessible from either an object or " -"a class." +"either ``c.f`` or ``C.f`` is the equivalent of a direct lookup into " +"``object.__getattribute__(c, \"f\")`` or ``object.__getattribute__(C, " +"\"f\")``. As a result, the function becomes identically accessible from " +"either an object or a class." msgstr "" #: howto/descriptor.rst:1283 @@ -915,19 +1474,53 @@ msgid "" "example calls are unexciting:" msgstr "" +#: howto/descriptor.rst:1298 +msgid "" +"class E:\n" +" @staticmethod\n" +" def f(x):\n" +" return x * 10" +msgstr "" + +#: howto/descriptor.rst:1305 +msgid "" +">>> E.f(3)\n" +"30\n" +">>> E().f(3)\n" +"30" +msgstr "" + #: howto/descriptor.rst:1312 msgid "" -"Using the non-data descriptor protocol, a pure Python version of :func:" -"`staticmethod` would look like this:" +"Using the non-data descriptor protocol, a pure Python version " +"of :func:`staticmethod` would look like this:" +msgstr "" + +#: howto/descriptor.rst:1315 +msgid "" +"import functools\n" +"\n" +"class StaticMethod:\n" +" \"Emulate PyStaticMethod_Type() in Objects/funcobject.c\"\n" +"\n" +" def __init__(self, f):\n" +" self.f = f\n" +" functools.update_wrapper(self, f)\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" return self.f\n" +"\n" +" def __call__(self, *args, **kwds):\n" +" return self.f(*args, **kwds)" msgstr "" #: howto/descriptor.rst:1332 msgid "" "The :func:`functools.update_wrapper` call adds a ``__wrapped__`` attribute " "that refers to the underlying function. Also it carries forward the " -"attributes necessary to make the wrapper look like the wrapped function: :" -"attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function." -"__doc__`, and :attr:`~function.__annotations__`." +"attributes necessary to make the wrapper look like the wrapped " +"function: :attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function.__doc__`, " +"and :attr:`~function.__annotations__`." msgstr "" #: howto/descriptor.rst:1401 @@ -941,6 +1534,22 @@ msgid "" "whether the caller is an object or a class:" msgstr "" +#: howto/descriptor.rst:1407 +msgid "" +"class F:\n" +" @classmethod\n" +" def f(cls, x):\n" +" return cls.__name__, x" +msgstr "" + +#: howto/descriptor.rst:1414 +msgid "" +">>> F.f(3)\n" +"('F', 3)\n" +">>> F().f(3)\n" +"('F', 3)" +msgstr "" + #: howto/descriptor.rst:1421 msgid "" "This behavior is useful whenever the method only needs to have a class " @@ -950,14 +1559,56 @@ msgid "" "of keys. The pure Python equivalent is:" msgstr "" +#: howto/descriptor.rst:1427 +msgid "" +"class Dict(dict):\n" +" @classmethod\n" +" def fromkeys(cls, iterable, value=None):\n" +" \"Emulate dict_fromkeys() in Objects/dictobject.c\"\n" +" d = cls()\n" +" for key in iterable:\n" +" d[key] = value\n" +" return d" +msgstr "" + #: howto/descriptor.rst:1438 msgid "Now a new dictionary of unique keys can be constructed like this:" msgstr "" +#: howto/descriptor.rst:1440 +msgid "" +">>> d = Dict.fromkeys('abracadabra')\n" +">>> type(d) is Dict\n" +"True\n" +">>> d\n" +"{'a': None, 'b': None, 'r': None, 'c': None, 'd': None}" +msgstr "" + #: howto/descriptor.rst:1448 msgid "" -"Using the non-data descriptor protocol, a pure Python version of :func:" -"`classmethod` would look like this:" +"Using the non-data descriptor protocol, a pure Python version " +"of :func:`classmethod` would look like this:" +msgstr "" + +#: howto/descriptor.rst:1451 +msgid "" +"import functools\n" +"\n" +"class ClassMethod:\n" +" \"Emulate PyClassMethod_Type() in Objects/funcobject.c\"\n" +"\n" +" def __init__(self, f):\n" +" self.f = f\n" +" functools.update_wrapper(self, f)\n" +"\n" +" def __get__(self, obj, cls=None):\n" +" if cls is None:\n" +" cls = type(obj)\n" +" if hasattr(type(self.f), '__get__'):\n" +" # This code path was added in Python 3.9\n" +" # and was deprecated in Python 3.11.\n" +" return self.f.__get__(cls, cls)\n" +" return MethodType(self.f, cls)" msgstr "" #: howto/descriptor.rst:1526 @@ -968,14 +1619,29 @@ msgid "" "together. In Python 3.11, this functionality was deprecated." msgstr "" +#: howto/descriptor.rst:1531 +msgid "" +"class G:\n" +" @classmethod\n" +" @property\n" +" def __doc__(cls):\n" +" return f'A doc for {cls.__name__!r}'" +msgstr "" + +#: howto/descriptor.rst:1539 +msgid "" +">>> G.__doc__\n" +"\"A doc for 'G'\"" +msgstr "" + #: howto/descriptor.rst:1544 msgid "" "The :func:`functools.update_wrapper` call in ``ClassMethod`` adds a " "``__wrapped__`` attribute that refers to the underlying function. Also it " "carries forward the attributes necessary to make the wrapper look like the " -"wrapped function: :attr:`~function.__name__`, :attr:`~function." -"__qualname__`, :attr:`~function.__doc__`, and :attr:`~function." -"__annotations__`." +"wrapped " +"function: :attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function.__doc__`, " +"and :attr:`~function.__annotations__`." msgstr "" #: howto/descriptor.rst:1553 @@ -995,12 +1661,62 @@ msgid "" "assignments. Only attribute names specified in ``__slots__`` are allowed:" msgstr "" +#: howto/descriptor.rst:1562 +msgid "" +"class Vehicle:\n" +" __slots__ = ('id_number', 'make', 'model')" +msgstr "" + +#: howto/descriptor.rst:1567 +msgid "" +">>> auto = Vehicle()\n" +">>> auto.id_nubmer = 'VYE483814LQEX'\n" +"Traceback (most recent call last):\n" +" ...\n" +"AttributeError: 'Vehicle' object has no attribute 'id_nubmer'" +msgstr "" + #: howto/descriptor.rst:1575 msgid "" "2. Helps create immutable objects where descriptors manage access to private " "attributes stored in ``__slots__``:" msgstr "" +#: howto/descriptor.rst:1578 +msgid "" +"class Immutable:\n" +"\n" +" __slots__ = ('_dept', '_name') # Replace the instance " +"dictionary\n" +"\n" +" def __init__(self, dept, name):\n" +" self._dept = dept # Store to private attribute\n" +" self._name = name # Store to private attribute\n" +"\n" +" @property # Read-only descriptor\n" +" def dept(self):\n" +" return self._dept\n" +"\n" +" @property\n" +" def name(self): # Read-only descriptor\n" +" return self._name" +msgstr "" + +#: howto/descriptor.rst:1596 +msgid "" +">>> mark = Immutable('Botany', 'Mark Watney')\n" +">>> mark.dept\n" +"'Botany'\n" +">>> mark.dept = 'Space Pirate'\n" +"Traceback (most recent call last):\n" +" ...\n" +"AttributeError: property 'dept' of 'Immutable' object has no setter\n" +">>> mark.location = 'Mars'\n" +"Traceback (most recent call last):\n" +" ...\n" +"AttributeError: 'Immutable' object has no attribute 'location'" +msgstr "" + #: howto/descriptor.rst:1610 msgid "" "3. Saves memory. On a 64-bit Linux build, an instance with two attributes " @@ -1021,6 +1737,27 @@ msgid "" "instance dictionary to function correctly:" msgstr "" +#: howto/descriptor.rst:1621 +msgid "" +"from functools import cached_property\n" +"\n" +"class CP:\n" +" __slots__ = () # Eliminates the instance dict\n" +"\n" +" @cached_property # Requires an instance dict\n" +" def pi(self):\n" +" return 4 * sum((-1.0)**n / (2.0*n + 1.0)\n" +" for n in reversed(range(100_000)))" +msgstr "" + +#: howto/descriptor.rst:1633 +msgid "" +">>> CP().pi\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: No '__dict__' attribute on 'CP' instance to cache 'pi' property." +msgstr "" + #: howto/descriptor.rst:1640 msgid "" "It is not possible to create an exact drop-in pure Python version of " @@ -1031,10 +1768,63 @@ msgid "" "managed by member descriptors:" msgstr "" +#: howto/descriptor.rst:1647 +msgid "" +"null = object()\n" +"\n" +"class Member:\n" +"\n" +" def __init__(self, name, clsname, offset):\n" +" 'Emulate PyMemberDef in Include/structmember.h'\n" +" # Also see descr_new() in Objects/descrobject.c\n" +" self.name = name\n" +" self.clsname = clsname\n" +" self.offset = offset\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" 'Emulate member_get() in Objects/descrobject.c'\n" +" # Also see PyMember_GetOne() in Python/structmember.c\n" +" if obj is None:\n" +" return self\n" +" value = obj._slotvalues[self.offset]\n" +" if value is null:\n" +" raise AttributeError(self.name)\n" +" return value\n" +"\n" +" def __set__(self, obj, value):\n" +" 'Emulate member_set() in Objects/descrobject.c'\n" +" obj._slotvalues[self.offset] = value\n" +"\n" +" def __delete__(self, obj):\n" +" 'Emulate member_delete() in Objects/descrobject.c'\n" +" value = obj._slotvalues[self.offset]\n" +" if value is null:\n" +" raise AttributeError(self.name)\n" +" obj._slotvalues[self.offset] = null\n" +"\n" +" def __repr__(self):\n" +" 'Emulate member_repr() in Objects/descrobject.c'\n" +" return f''" +msgstr "" + #: howto/descriptor.rst:1685 msgid "" -"The :meth:`type.__new__` method takes care of adding member objects to class " -"variables:" +"The :meth:`!type.__new__` method takes care of adding member objects to " +"class variables:" +msgstr "" + +#: howto/descriptor.rst:1688 +msgid "" +"class Type(type):\n" +" 'Simulate how the type metaclass adds member objects for slots'\n" +"\n" +" def __new__(mcls, clsname, bases, mapping, **kwargs):\n" +" 'Emulate type_new() in Objects/typeobject.c'\n" +" # type_new() calls PyTypeReady() which calls add_methods()\n" +" slot_names = mapping.get('slot_names', [])\n" +" for offset, name in enumerate(slot_names):\n" +" mapping[name] = Member(name, clsname, offset)\n" +" return type.__new__(mcls, clsname, bases, mapping, **kwargs)" msgstr "" #: howto/descriptor.rst:1701 @@ -1044,10 +1834,54 @@ msgid "" "Python:" msgstr "" +#: howto/descriptor.rst:1705 +msgid "" +"class Object:\n" +" 'Simulate how object.__new__() allocates memory for __slots__'\n" +"\n" +" def __new__(cls, *args, **kwargs):\n" +" 'Emulate object_new() in Objects/typeobject.c'\n" +" inst = super().__new__(cls)\n" +" if hasattr(cls, 'slot_names'):\n" +" empty_slots = [null] * len(cls.slot_names)\n" +" object.__setattr__(inst, '_slotvalues', empty_slots)\n" +" return inst\n" +"\n" +" def __setattr__(self, name, value):\n" +" 'Emulate _PyObject_GenericSetAttrWithDict() Objects/object.c'\n" +" cls = type(self)\n" +" if hasattr(cls, 'slot_names') and name not in cls.slot_names:\n" +" raise AttributeError(\n" +" f'{cls.__name__!r} object has no attribute {name!r}'\n" +" )\n" +" super().__setattr__(name, value)\n" +"\n" +" def __delattr__(self, name):\n" +" 'Emulate _PyObject_GenericSetAttrWithDict() Objects/object.c'\n" +" cls = type(self)\n" +" if hasattr(cls, 'slot_names') and name not in cls.slot_names:\n" +" raise AttributeError(\n" +" f'{cls.__name__!r} object has no attribute {name!r}'\n" +" )\n" +" super().__delattr__(name)" +msgstr "" + #: howto/descriptor.rst:1736 msgid "" -"To use the simulation in a real class, just inherit from :class:`Object` and " -"set the :term:`metaclass` to :class:`Type`:" +"To use the simulation in a real class, just inherit from :class:`!Object` " +"and set the :term:`metaclass` to :class:`Type`:" +msgstr "" + +#: howto/descriptor.rst:1739 +msgid "" +"class H(Object, metaclass=Type):\n" +" 'Instance variables stored in slots'\n" +"\n" +" slot_names = ['x', 'y']\n" +"\n" +" def __init__(self, x, y):\n" +" self.x = x\n" +" self.y = y" msgstr "" #: howto/descriptor.rst:1750 @@ -1055,12 +1889,42 @@ msgid "" "At this point, the metaclass has loaded member objects for *x* and *y*::" msgstr "" +#: howto/descriptor.rst:1752 +msgid "" +">>> from pprint import pp\n" +">>> pp(dict(vars(H)))\n" +"{'__module__': '__main__',\n" +" '__doc__': 'Instance variables stored in slots',\n" +" 'slot_names': ['x', 'y'],\n" +" '__init__': ,\n" +" 'x': ,\n" +" 'y': }" +msgstr "" + #: howto/descriptor.rst:1771 msgid "" "When instances are created, they have a ``slot_values`` list where the " "attributes are stored:" msgstr "" +#: howto/descriptor.rst:1774 +msgid "" +">>> h = H(10, 20)\n" +">>> vars(h)\n" +"{'_slotvalues': [10, 20]}\n" +">>> h.x = 55\n" +">>> vars(h)\n" +"{'_slotvalues': [55, 20]}" +msgstr "" + #: howto/descriptor.rst:1783 msgid "Misspelled or unassigned attributes will raise an exception:" msgstr "" + +#: howto/descriptor.rst:1785 +msgid "" +">>> h.xz\n" +"Traceback (most recent call last):\n" +" ...\n" +"AttributeError: 'H' object has no attribute 'xz'" +msgstr "" diff --git a/howto/enum.po b/howto/enum.po index 5fc6240d..4ccb9a82 100644 --- a/howto/enum.po +++ b/howto/enum.po @@ -8,46 +8,69 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: howto/enum.rst:3 +#: howto/enum.rst:5 msgid "Enum HOWTO" msgstr "" -#: howto/enum.rst:9 +#: howto/enum.rst:11 msgid "" "An :class:`Enum` is a set of symbolic names bound to unique values. They " -"are similar to global variables, but they offer a more useful :func:" -"`repr()`, grouping, type-safety, and a few other features." +"are similar to global variables, but they offer a more useful :func:`repr`, " +"grouping, type-safety, and a few other features." msgstr "" -#: howto/enum.rst:13 +#: howto/enum.rst:15 msgid "" "They are most useful when you have a variable that can take one of a limited " "selection of values. For example, the days of the week::" msgstr "" -#: howto/enum.rst:26 +#: howto/enum.rst:18 +msgid "" +">>> from enum import Enum\n" +">>> class Weekday(Enum):\n" +"... MONDAY = 1\n" +"... TUESDAY = 2\n" +"... WEDNESDAY = 3\n" +"... THURSDAY = 4\n" +"... FRIDAY = 5\n" +"... SATURDAY = 6\n" +"... SUNDAY = 7" +msgstr "" + +#: howto/enum.rst:28 msgid "Or perhaps the RGB primary colors::" msgstr "" -#: howto/enum.rst:34 +#: howto/enum.rst:30 +msgid "" +">>> from enum import Enum\n" +">>> class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 3" +msgstr "" + +#: howto/enum.rst:36 msgid "" "As you can see, creating an :class:`Enum` is as simple as writing a class " "that inherits from :class:`Enum` itself." msgstr "" -#: howto/enum.rst:37 +#: howto/enum.rst:39 msgid "Case of Enum Members" msgstr "" -#: howto/enum.rst:39 +#: howto/enum.rst:41 msgid "" "Because Enums are used to represent constants, and to help avoid issues with " "name clashes between mixin-class methods/attributes and enum names, we " @@ -55,129 +78,299 @@ msgid "" "that style in our examples." msgstr "" -#: howto/enum.rst:44 +#: howto/enum.rst:46 msgid "" "Depending on the nature of the enum a member's value may or may not be " "important, but either way that value can be used to get the corresponding " "member::" msgstr "" -#: howto/enum.rst:51 +#: howto/enum.rst:50 +msgid "" +">>> Weekday(3)\n" +"" +msgstr "" + +#: howto/enum.rst:53 msgid "" "As you can see, the ``repr()`` of a member shows the enum name, the member " "name, and the value. The ``str()`` of a member shows only the enum name and " "member name::" msgstr "" -#: howto/enum.rst:58 +#: howto/enum.rst:57 +msgid "" +">>> print(Weekday.THURSDAY)\n" +"Weekday.THURSDAY" +msgstr "" + +#: howto/enum.rst:60 msgid "The *type* of an enumeration member is the enum it belongs to::" msgstr "" -#: howto/enum.rst:65 -msgid "Enum members have an attribute that contains just their :attr:`name`::" +#: howto/enum.rst:62 +msgid "" +">>> type(Weekday.MONDAY)\n" +"\n" +">>> isinstance(Weekday.FRIDAY, Weekday)\n" +"True" +msgstr "" + +#: howto/enum.rst:67 +msgid "Enum members have an attribute that contains just their :attr:`!name`::" +msgstr "" + +#: howto/enum.rst:69 +msgid "" +">>> print(Weekday.TUESDAY.name)\n" +"TUESDAY" +msgstr "" + +#: howto/enum.rst:72 +msgid "Likewise, they have an attribute for their :attr:`!value`::" msgstr "" -#: howto/enum.rst:70 -msgid "Likewise, they have an attribute for their :attr:`value`::" +#: howto/enum.rst:75 +msgid "" +">>> Weekday.WEDNESDAY.value\n" +"3" msgstr "" -#: howto/enum.rst:76 +#: howto/enum.rst:78 msgid "" "Unlike many languages that treat enumerations solely as name/value pairs, " "Python Enums can have behavior added. For example, :class:`datetime.date` " -"has two methods for returning the weekday: :meth:`weekday` and :meth:" -"`isoweekday`. The difference is that one of them counts from 0-6 and the " -"other from 1-7. Rather than keep track of that ourselves we can add a method " -"to the :class:`Weekday` enum to extract the day from the :class:`date` " -"instance and return the matching enum member::" +"has two methods for returning the weekday: :meth:`~datetime.date.weekday` " +"and :meth:`~datetime.date.isoweekday`. The difference is that one of them " +"counts from 0-6 and the other from 1-7. Rather than keep track of that " +"ourselves we can add a method to the :class:`!Weekday` enum to extract the " +"day from the :class:`~datetime.date` instance and return the matching enum " +"member::" +msgstr "" + +#: howto/enum.rst:87 +msgid "" +"@classmethod\n" +"def from_date(cls, date):\n" +" return cls(date.isoweekday())" msgstr "" -#: howto/enum.rst:88 -msgid "The complete :class:`Weekday` enum now looks like this::" +#: howto/enum.rst:91 +msgid "The complete :class:`!Weekday` enum now looks like this::" +msgstr "" + +#: howto/enum.rst:93 +msgid "" +">>> class Weekday(Enum):\n" +"... MONDAY = 1\n" +"... TUESDAY = 2\n" +"... WEDNESDAY = 3\n" +"... THURSDAY = 4\n" +"... FRIDAY = 5\n" +"... SATURDAY = 6\n" +"... SUNDAY = 7\n" +"... #\n" +"... @classmethod\n" +"... def from_date(cls, date):\n" +"... return cls(date.isoweekday())" msgstr "" -#: howto/enum.rst:103 +#: howto/enum.rst:106 msgid "Now we can find out what today is! Observe::" msgstr "" -#: howto/enum.rst:109 +#: howto/enum.rst:108 +msgid "" +">>> from datetime import date\n" +">>> Weekday.from_date(date.today()) \n" +"" +msgstr "" + +#: howto/enum.rst:112 msgid "" "Of course, if you're reading this on some other day, you'll see that day " "instead." msgstr "" -#: howto/enum.rst:111 +#: howto/enum.rst:114 msgid "" -"This :class:`Weekday` enum is great if our variable only needs one day, but " +"This :class:`!Weekday` enum is great if our variable only needs one day, but " "what if we need several? Maybe we're writing a function to plot chores " "during a week, and don't want to use a :class:`list` -- we could use a " "different type of :class:`Enum`::" msgstr "" -#: howto/enum.rst:126 +#: howto/enum.rst:119 +msgid "" +">>> from enum import Flag\n" +">>> class Weekday(Flag):\n" +"... MONDAY = 1\n" +"... TUESDAY = 2\n" +"... WEDNESDAY = 4\n" +"... THURSDAY = 8\n" +"... FRIDAY = 16\n" +"... SATURDAY = 32\n" +"... SUNDAY = 64" +msgstr "" + +#: howto/enum.rst:129 msgid "" "We've changed two things: we're inherited from :class:`Flag`, and the values " "are all powers of 2." msgstr "" -#: howto/enum.rst:129 +#: howto/enum.rst:132 msgid "" -"Just like the original :class:`Weekday` enum above, we can have a single " +"Just like the original :class:`!Weekday` enum above, we can have a single " "selection::" msgstr "" -#: howto/enum.rst:135 +#: howto/enum.rst:134 +msgid "" +">>> first_week_day = Weekday.MONDAY\n" +">>> first_week_day\n" +"" +msgstr "" + +#: howto/enum.rst:138 msgid "" "But :class:`Flag` also allows us to combine several members into a single " "variable::" msgstr "" -#: howto/enum.rst:142 +#: howto/enum.rst:141 +msgid "" +">>> weekend = Weekday.SATURDAY | Weekday.SUNDAY\n" +">>> weekend\n" +"" +msgstr "" + +#: howto/enum.rst:145 msgid "You can even iterate over a :class:`Flag` variable::" msgstr "" -#: howto/enum.rst:149 +#: howto/enum.rst:147 +msgid "" +">>> for day in weekend:\n" +"... print(day)\n" +"Weekday.SATURDAY\n" +"Weekday.SUNDAY" +msgstr "" + +#: howto/enum.rst:152 msgid "Okay, let's get some chores set up::" msgstr "" -#: howto/enum.rst:157 +#: howto/enum.rst:154 +msgid "" +">>> chores_for_ethan = {\n" +"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | " +"Weekday.FRIDAY,\n" +"... 'do the dishes': Weekday.TUESDAY | Weekday.THURSDAY,\n" +"... 'answer SO questions': Weekday.SATURDAY,\n" +"... }" +msgstr "" + +#: howto/enum.rst:160 msgid "And a function to display the chores for a given day::" msgstr "" -#: howto/enum.rst:167 +#: howto/enum.rst:162 +msgid "" +">>> def show_chores(chores, day):\n" +"... for chore, days in chores.items():\n" +"... if day in days:\n" +"... print(chore)\n" +"...\n" +">>> show_chores(chores_for_ethan, Weekday.SATURDAY)\n" +"answer SO questions" +msgstr "" + +#: howto/enum.rst:170 msgid "" "In cases where the actual values of the members do not matter, you can save " -"yourself some work and use :func:`auto()` for the values::" +"yourself some work and use :func:`auto` for the values::" +msgstr "" + +#: howto/enum.rst:173 +msgid "" +">>> from enum import auto\n" +">>> class Weekday(Flag):\n" +"... MONDAY = auto()\n" +"... TUESDAY = auto()\n" +"... WEDNESDAY = auto()\n" +"... THURSDAY = auto()\n" +"... FRIDAY = auto()\n" +"... SATURDAY = auto()\n" +"... SUNDAY = auto()\n" +"... WEEKEND = SATURDAY | SUNDAY" msgstr "" -#: howto/enum.rst:186 +#: howto/enum.rst:189 msgid "Programmatic access to enumeration members and their attributes" msgstr "" -#: howto/enum.rst:188 +#: howto/enum.rst:191 msgid "" -"Sometimes it's useful to access members in enumerations programmatically (i." -"e. situations where ``Color.RED`` won't do because the exact color is not " +"Sometimes it's useful to access members in enumerations programmatically " +"(i.e. situations where ``Color.RED`` won't do because the exact color is not " "known at program-writing time). ``Enum`` allows such access::" msgstr "" -#: howto/enum.rst:197 +#: howto/enum.rst:195 +msgid "" +">>> Color(1)\n" +"\n" +">>> Color(3)\n" +"" +msgstr "" + +#: howto/enum.rst:200 msgid "If you want to access enum members by *name*, use item access::" msgstr "" -#: howto/enum.rst:204 -msgid "If you have an enum member and need its :attr:`name` or :attr:`value`::" +#: howto/enum.rst:202 +msgid "" +">>> Color['RED']\n" +"\n" +">>> Color['GREEN']\n" +"" +msgstr "" + +#: howto/enum.rst:207 +msgid "" +"If you have an enum member and need its :attr:`!name` or :attr:`!value`::" +msgstr "" + +#: howto/enum.rst:209 +msgid "" +">>> member = Color.RED\n" +">>> member.name\n" +"'RED'\n" +">>> member.value\n" +"1" msgstr "" -#: howto/enum.rst:214 +#: howto/enum.rst:217 msgid "Duplicating enum members and values" msgstr "" -#: howto/enum.rst:216 +#: howto/enum.rst:219 msgid "Having two enum members with the same name is invalid::" msgstr "" -#: howto/enum.rst:226 +#: howto/enum.rst:221 +msgid "" +">>> class Shape(Enum):\n" +"... SQUARE = 2\n" +"... SQUARE = 3\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"TypeError: 'SQUARE' already defined as 2" +msgstr "" + +#: howto/enum.rst:229 msgid "" "However, an enum member can have other names associated with it. Given two " "entries ``A`` and ``B`` with the same value (and ``A`` defined first), ``B`` " @@ -186,112 +379,235 @@ msgid "" "member ``A``. By-name lookup of ``B`` will also return the member ``A``::" msgstr "" -#: howto/enum.rst:247 +#: howto/enum.rst:235 +msgid "" +">>> class Shape(Enum):\n" +"... SQUARE = 2\n" +"... DIAMOND = 1\n" +"... CIRCLE = 3\n" +"... ALIAS_FOR_SQUARE = 2\n" +"...\n" +">>> Shape.SQUARE\n" +"\n" +">>> Shape.ALIAS_FOR_SQUARE\n" +"\n" +">>> Shape(2)\n" +"" +msgstr "" + +#: howto/enum.rst:250 msgid "" "Attempting to create a member with the same name as an already defined " "attribute (another member, a method, etc.) or attempting to create an " "attribute with the same name as a member is not allowed." msgstr "" -#: howto/enum.rst:253 +#: howto/enum.rst:256 msgid "Ensuring unique enumeration values" msgstr "" -#: howto/enum.rst:255 +#: howto/enum.rst:258 msgid "" "By default, enumerations allow multiple names as aliases for the same value. " "When this behavior isn't desired, you can use the :func:`unique` decorator::" msgstr "" -#: howto/enum.rst:272 +#: howto/enum.rst:261 +msgid "" +">>> from enum import Enum, unique\n" +">>> @unique\n" +"... class Mistake(Enum):\n" +"... ONE = 1\n" +"... TWO = 2\n" +"... THREE = 3\n" +"... FOUR = 3\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: duplicate values found in : FOUR -> THREE" +msgstr "" + +#: howto/enum.rst:275 msgid "Using automatic values" msgstr "" -#: howto/enum.rst:274 +#: howto/enum.rst:277 msgid "If the exact value is unimportant you can use :class:`auto`::" msgstr "" -#: howto/enum.rst:285 +#: howto/enum.rst:279 msgid "" -"The values are chosen by :func:`_generate_next_value_`, which can be " +">>> from enum import Enum, auto\n" +">>> class Color(Enum):\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"...\n" +">>> [member.value for member in Color]\n" +"[1, 2, 3]" +msgstr "" + +#: howto/enum.rst:288 +msgid "" +"The values are chosen by :func:`~Enum._generate_next_value_`, which can be " "overridden::" msgstr "" -#: howto/enum.rst:304 +#: howto/enum.rst:291 msgid "" -"The :meth:`_generate_next_value_` method must be defined before any members." +">>> class AutoName(Enum):\n" +"... @staticmethod\n" +"... def _generate_next_value_(name, start, count, last_values):\n" +"... return name\n" +"...\n" +">>> class Ordinal(AutoName):\n" +"... NORTH = auto()\n" +"... SOUTH = auto()\n" +"... EAST = auto()\n" +"... WEST = auto()\n" +"...\n" +">>> [member.value for member in Ordinal]\n" +"['NORTH', 'SOUTH', 'EAST', 'WEST']" msgstr "" #: howto/enum.rst:307 +msgid "" +"The :meth:`~Enum._generate_next_value_` method must be defined before any " +"members." +msgstr "" + +#: howto/enum.rst:310 msgid "Iteration" msgstr "" -#: howto/enum.rst:309 +#: howto/enum.rst:312 msgid "Iterating over the members of an enum does not provide the aliases::" msgstr "" -#: howto/enum.rst:316 +#: howto/enum.rst:314 +msgid "" +">>> list(Shape)\n" +"[, , ]\n" +">>> list(Weekday)\n" +"[, , , " +", , , " +"]" +msgstr "" + +#: howto/enum.rst:319 msgid "" "Note that the aliases ``Shape.ALIAS_FOR_SQUARE`` and ``Weekday.WEEKEND`` " "aren't shown." msgstr "" -#: howto/enum.rst:318 +#: howto/enum.rst:321 msgid "" "The special attribute ``__members__`` is a read-only ordered mapping of " "names to members. It includes all names defined in the enumeration, " "including the aliases::" msgstr "" -#: howto/enum.rst:330 +#: howto/enum.rst:325 +msgid "" +">>> for name, member in Shape.__members__.items():\n" +"... name, member\n" +"...\n" +"('SQUARE', )\n" +"('DIAMOND', )\n" +"('CIRCLE', )\n" +"('ALIAS_FOR_SQUARE', )" +msgstr "" + +#: howto/enum.rst:333 msgid "" "The ``__members__`` attribute can be used for detailed programmatic access " "to the enumeration members. For example, finding all the aliases::" msgstr "" -#: howto/enum.rst:338 +#: howto/enum.rst:336 +msgid "" +">>> [name for name, member in Shape.__members__.items() if member.name != " +"name]\n" +"['ALIAS_FOR_SQUARE']" +msgstr "" + +#: howto/enum.rst:341 msgid "" "Aliases for flags include values with multiple flags set, such as ``3``, and " "no flags set, i.e. ``0``." msgstr "" -#: howto/enum.rst:343 +#: howto/enum.rst:346 msgid "Comparisons" msgstr "" -#: howto/enum.rst:345 +#: howto/enum.rst:348 msgid "Enumeration members are compared by identity::" msgstr "" -#: howto/enum.rst:354 +#: howto/enum.rst:350 +msgid "" +">>> Color.RED is Color.RED\n" +"True\n" +">>> Color.RED is Color.BLUE\n" +"False\n" +">>> Color.RED is not Color.BLUE\n" +"True" +msgstr "" + +#: howto/enum.rst:357 msgid "" "Ordered comparisons between enumeration values are *not* supported. Enum " "members are not integers (but see `IntEnum`_ below)::" msgstr "" -#: howto/enum.rst:362 +#: howto/enum.rst:360 +msgid "" +">>> Color.RED < Color.BLUE\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: '<' not supported between instances of 'Color' and 'Color'" +msgstr "" + +#: howto/enum.rst:365 msgid "Equality comparisons are defined though::" msgstr "" -#: howto/enum.rst:371 +#: howto/enum.rst:367 +msgid "" +">>> Color.BLUE == Color.RED\n" +"False\n" +">>> Color.BLUE != Color.RED\n" +"True\n" +">>> Color.BLUE == Color.BLUE\n" +"True" +msgstr "" + +#: howto/enum.rst:374 msgid "" "Comparisons against non-enumeration values will always compare not equal " "(again, :class:`IntEnum` was explicitly designed to behave differently, see " "below)::" msgstr "" -#: howto/enum.rst:380 +#: howto/enum.rst:378 +msgid "" +">>> Color.BLUE == 2\n" +"False" +msgstr "" + +#: howto/enum.rst:383 msgid "" "It is possible to reload modules -- if a reloaded module contains enums, " "they will be recreated, and the new members may not compare identical/equal " "to the original members." msgstr "" -#: howto/enum.rst:385 +#: howto/enum.rst:388 msgid "Allowed members and attributes of enumerations" msgstr "" -#: howto/enum.rst:387 +#: howto/enum.rst:390 msgid "" "Most of the examples above use integers for enumeration values. Using " "integers is short and handy (and provided by default by the `Functional " @@ -300,46 +616,77 @@ msgid "" "*is* important, enumerations can have arbitrary values." msgstr "" -#: howto/enum.rst:393 +#: howto/enum.rst:396 msgid "" "Enumerations are Python classes, and can have methods and special methods as " "usual. If we have this enumeration::" msgstr "" -#: howto/enum.rst:413 +#: howto/enum.rst:399 +msgid "" +">>> class Mood(Enum):\n" +"... FUNKY = 1\n" +"... HAPPY = 3\n" +"...\n" +"... def describe(self):\n" +"... # self is the member here\n" +"... return self.name, self.value\n" +"...\n" +"... def __str__(self):\n" +"... return 'my custom str! {0}'.format(self.value)\n" +"...\n" +"... @classmethod\n" +"... def favorite_mood(cls):\n" +"... # cls here is the enumeration\n" +"... return cls.HAPPY\n" +"..." +msgstr "" + +#: howto/enum.rst:416 msgid "Then::" msgstr "" -#: howto/enum.rst:422 +#: howto/enum.rst:418 +msgid "" +">>> Mood.favorite_mood()\n" +"\n" +">>> Mood.HAPPY.describe()\n" +"('HAPPY', 3)\n" +">>> str(Mood.FUNKY)\n" +"'my custom str! 1'" +msgstr "" + +#: howto/enum.rst:425 msgid "" "The rules for what is allowed are as follows: names that start and end with " "a single underscore are reserved by enum and cannot be used; all other " "attributes defined within an enumeration will become members of this " -"enumeration, with the exception of special methods (:meth:`__str__`, :meth:" -"`__add__`, etc.), descriptors (methods are also descriptors), and variable " -"names listed in :attr:`_ignore_`." +"enumeration, with the exception of special methods " +"(:meth:`~object.__str__`, :meth:`~object.__add__`, etc.), descriptors " +"(methods are also descriptors), and variable names listed " +"in :attr:`~Enum._ignore_`." msgstr "" -#: howto/enum.rst:429 +#: howto/enum.rst:432 msgid "" -"Note: if your enumeration defines :meth:`__new__` and/or :meth:`__init__`, " -"any value(s) given to the enum member will be passed into those methods. See " -"`Planet`_ for an example." +"Note: if your enumeration defines :meth:`~object.__new__` and/" +"or :meth:`~object.__init__`, any value(s) given to the enum member will be " +"passed into those methods. See `Planet`_ for an example." msgstr "" -#: howto/enum.rst:435 +#: howto/enum.rst:438 msgid "" -"The :meth:`__new__` method, if defined, is used during creation of the Enum " -"members; it is then replaced by Enum's :meth:`__new__` which is used after " -"class creation for lookup of existing members. See :ref:`new-vs-init` for " -"more details." +"The :meth:`~object.__new__` method, if defined, is used during creation of " +"the Enum members; it is then replaced by Enum's :meth:`~object.__new__` " +"which is used after class creation for lookup of existing members. " +"See :ref:`new-vs-init` for more details." msgstr "" -#: howto/enum.rst:442 +#: howto/enum.rst:445 msgid "Restricted Enum subclassing" msgstr "" -#: howto/enum.rst:444 +#: howto/enum.rst:447 msgid "" "A new :class:`Enum` class must have one base enum class, up to one concrete " "data type, and as many :class:`object`-based mixin classes as needed. The " @@ -348,15 +695,43 @@ msgstr "" #: howto/enum.rst:451 msgid "" +"class EnumName([mix-in, ...,] [data-type,] base-enum):\n" +" pass" +msgstr "" + +#: howto/enum.rst:454 +msgid "" "Also, subclassing an enumeration is allowed only if the enumeration does not " "define any members. So this is forbidden::" msgstr "" -#: howto/enum.rst:461 +#: howto/enum.rst:457 +msgid "" +">>> class MoreColor(Color):\n" +"... PINK = 17\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"TypeError: cannot extend " +msgstr "" + +#: howto/enum.rst:464 msgid "But this is allowed::" msgstr "" -#: howto/enum.rst:472 +#: howto/enum.rst:466 +msgid "" +">>> class Foo(Enum):\n" +"... def some_behavior(self):\n" +"... pass\n" +"...\n" +">>> class Bar(Foo):\n" +"... HAPPY = 1\n" +"... SAD = 2\n" +"..." +msgstr "" + +#: howto/enum.rst:475 msgid "" "Allowing subclassing of enums that define members would lead to a violation " "of some important invariants of types and instances. On the other hand, it " @@ -364,78 +739,122 @@ msgid "" "enumerations. (See `OrderedEnum`_ for an example.)" msgstr "" -#: howto/enum.rst:481 +#: howto/enum.rst:484 msgid "Dataclass support" msgstr "" -#: howto/enum.rst:483 +#: howto/enum.rst:486 msgid "" -"When inheriting from a :class:`~dataclasses.dataclass`, the :meth:`~Enum." -"__repr__` omits the inherited class' name. For example::" +"When inheriting from a :class:`~dataclasses.dataclass`, " +"the :meth:`~Enum.__repr__` omits the inherited class' name. For example::" msgstr "" -#: howto/enum.rst:500 +#: howto/enum.rst:489 msgid "" -"Use the :func:`!dataclass` argument ``repr=False`` to use the standard :func:" -"`repr`." +">>> from dataclasses import dataclass, field\n" +">>> @dataclass\n" +"... class CreatureDataMixin:\n" +"... size: str\n" +"... legs: int\n" +"... tail: bool = field(repr=False, default=True)\n" +"...\n" +">>> class Creature(CreatureDataMixin, Enum):\n" +"... BEETLE = 'small', 6\n" +"... DOG = 'medium', 4\n" +"...\n" +">>> Creature.DOG\n" +"" msgstr "" #: howto/enum.rst:503 msgid "" +"Use the :func:`!dataclass` argument ``repr=False`` to use the " +"standard :func:`repr`." +msgstr "" + +#: howto/enum.rst:506 +msgid "" "Only the dataclass fields are shown in the value area, not the dataclass' " "name." msgstr "" -#: howto/enum.rst:509 +#: howto/enum.rst:512 msgid "Pickling" msgstr "" -#: howto/enum.rst:511 +#: howto/enum.rst:514 msgid "Enumerations can be pickled and unpickled::" msgstr "" -#: howto/enum.rst:518 +#: howto/enum.rst:516 +msgid "" +">>> from test.test_enum import Fruit\n" +">>> from pickle import dumps, loads\n" +">>> Fruit.TOMATO is loads(dumps(Fruit.TOMATO))\n" +"True" +msgstr "" + +#: howto/enum.rst:521 msgid "" "The usual restrictions for pickling apply: picklable enums must be defined " "in the top level of a module, since unpickling requires them to be " "importable from that module." msgstr "" -#: howto/enum.rst:524 +#: howto/enum.rst:527 msgid "" "With pickle protocol version 4 it is possible to easily pickle enums nested " "in other classes." msgstr "" -#: howto/enum.rst:527 +#: howto/enum.rst:530 msgid "" -"It is possible to modify how enum members are pickled/unpickled by defining :" -"meth:`__reduce_ex__` in the enumeration class. The default method is by-" -"value, but enums with complicated values may want to use by-name::" +"It is possible to modify how enum members are pickled/unpickled by " +"defining :meth:`~object.__reduce_ex__` in the enumeration class. The " +"default method is by-value, but enums with complicated values may want to " +"use by-name::" msgstr "" -#: howto/enum.rst:537 +#: howto/enum.rst:534 +msgid "" +">>> import enum\n" +">>> class MyEnum(enum.Enum):\n" +"... __reduce_ex__ = enum.pickle_by_enum_name" +msgstr "" + +#: howto/enum.rst:540 msgid "" "Using by-name for flags is not recommended, as unnamed aliases will not " "unpickle." msgstr "" -#: howto/enum.rst:542 +#: howto/enum.rst:545 msgid "Functional API" msgstr "" -#: howto/enum.rst:544 +#: howto/enum.rst:547 msgid "" "The :class:`Enum` class is callable, providing the following functional API::" msgstr "" -#: howto/enum.rst:554 +#: howto/enum.rst:549 +msgid "" +">>> Animal = Enum('Animal', 'ANT BEE CAT DOG')\n" +">>> Animal\n" +"\n" +">>> Animal.ANT\n" +"\n" +">>> list(Animal)\n" +"[, , , ]" +msgstr "" + +#: howto/enum.rst:557 msgid "" "The semantics of this API resemble :class:`~collections.namedtuple`. The " "first argument of the call to :class:`Enum` is the name of the enumeration." msgstr "" -#: howto/enum.rst:557 +#: howto/enum.rst:560 msgid "" "The second argument is the *source* of enumeration member names. It can be " "a whitespace-separated string of names, a sequence of names, a sequence of 2-" @@ -444,17 +863,27 @@ msgid "" "enumerations; the others auto-assign increasing integers starting with 1 " "(use the ``start`` parameter to specify a different starting value). A new " "class derived from :class:`Enum` is returned. In other words, the above " -"assignment to :class:`Animal` is equivalent to::" +"assignment to :class:`!Animal` is equivalent to::" +msgstr "" + +#: howto/enum.rst:569 +msgid "" +">>> class Animal(Enum):\n" +"... ANT = 1\n" +"... BEE = 2\n" +"... CAT = 3\n" +"... DOG = 4\n" +"..." msgstr "" -#: howto/enum.rst:573 +#: howto/enum.rst:576 msgid "" "The reason for defaulting to ``1`` as the starting number and not ``0`` is " "that ``0`` is ``False`` in a boolean sense, but by default enum members all " "evaluate to ``True``." msgstr "" -#: howto/enum.rst:577 +#: howto/enum.rst:580 msgid "" "Pickling enums created with the functional API can be tricky as frame stack " "implementation details are used to try and figure out which module the " @@ -463,99 +892,180 @@ msgid "" "Jython). The solution is to specify the module name explicitly as follows::" msgstr "" -#: howto/enum.rst:587 +#: howto/enum.rst:586 +msgid ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', module=__name__)" +msgstr "" + +#: howto/enum.rst:590 msgid "" "If ``module`` is not supplied, and Enum cannot determine what it is, the new " "Enum members will not be unpicklable; to keep errors closer to the source, " "pickling will be disabled." msgstr "" -#: howto/enum.rst:591 +#: howto/enum.rst:594 msgid "" -"The new pickle protocol 4 also, in some circumstances, relies on :attr:" -"`~definition.__qualname__` being set to the location where pickle will be " +"The new pickle protocol 4 also, in some circumstances, relies " +"on :attr:`~type.__qualname__` being set to the location where pickle will be " "able to find the class. For example, if the class was made available in " "class SomeData in the global scope::" msgstr "" -#: howto/enum.rst:598 +#: howto/enum.rst:599 +msgid "" +">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', qualname='SomeData.Animal')" +msgstr "" + +#: howto/enum.rst:601 msgid "The complete signature is::" msgstr "" -#: howto/enum.rst:610 +#: howto/enum.rst:603 +msgid "" +"Enum(\n" +" value='NewEnumName',\n" +" names=<...>,\n" +" *,\n" +" module='...',\n" +" qualname='...',\n" +" type=,\n" +" start=1,\n" +" )" +msgstr "" + +#: howto/enum.rst:613 msgid "*value*: What the new enum class will record as its name." msgstr "" -#: howto/enum.rst:612 +#: howto/enum.rst:615 msgid "" "*names*: The enum members. This can be a whitespace- or comma-separated " "string (values will start at 1 unless otherwise specified)::" msgstr "" -#: howto/enum.rst:617 +#: howto/enum.rst:618 +msgid "'RED GREEN BLUE' | 'RED,GREEN,BLUE' | 'RED, GREEN, BLUE'" +msgstr "" + +#: howto/enum.rst:620 msgid "or an iterator of names::" msgstr "" -#: howto/enum.rst:621 +#: howto/enum.rst:622 +msgid "['RED', 'GREEN', 'BLUE']" +msgstr "" + +#: howto/enum.rst:624 msgid "or an iterator of (name, value) pairs::" msgstr "" -#: howto/enum.rst:625 +#: howto/enum.rst:626 +msgid "[('CYAN', 4), ('MAGENTA', 5), ('YELLOW', 6)]" +msgstr "" + +#: howto/enum.rst:628 msgid "or a mapping::" msgstr "" -#: howto/enum.rst:629 +#: howto/enum.rst:630 +msgid "{'CHARTREUSE': 7, 'SEA_GREEN': 11, 'ROSEMARY': 42}" +msgstr "" + +#: howto/enum.rst:632 msgid "*module*: name of module where new enum class can be found." msgstr "" -#: howto/enum.rst:631 +#: howto/enum.rst:634 msgid "*qualname*: where in module new enum class can be found." msgstr "" -#: howto/enum.rst:633 +#: howto/enum.rst:636 msgid "*type*: type to mix in to new enum class." msgstr "" -#: howto/enum.rst:635 +#: howto/enum.rst:638 msgid "*start*: number to start counting at if only names are passed in." msgstr "" -#: howto/enum.rst:637 +#: howto/enum.rst:640 msgid "The *start* parameter was added." msgstr "" -#: howto/enum.rst:642 +#: howto/enum.rst:645 msgid "Derived Enumerations" msgstr "" -#: howto/enum.rst:645 +#: howto/enum.rst:648 msgid "IntEnum" msgstr "" -#: howto/enum.rst:647 +#: howto/enum.rst:650 msgid "" -"The first variation of :class:`Enum` that is provided is also a subclass of :" -"class:`int`. Members of an :class:`IntEnum` can be compared to integers; by " -"extension, integer enumerations of different types can also be compared to " -"each other::" +"The first variation of :class:`Enum` that is provided is also a subclass " +"of :class:`int`. Members of an :class:`IntEnum` can be compared to " +"integers; by extension, integer enumerations of different types can also be " +"compared to each other::" msgstr "" -#: howto/enum.rst:668 +#: howto/enum.rst:655 +msgid "" +">>> from enum import IntEnum\n" +">>> class Shape(IntEnum):\n" +"... CIRCLE = 1\n" +"... SQUARE = 2\n" +"...\n" +">>> class Request(IntEnum):\n" +"... POST = 1\n" +"... GET = 2\n" +"...\n" +">>> Shape == 1\n" +"False\n" +">>> Shape.CIRCLE == 1\n" +"True\n" +">>> Shape.CIRCLE == Request.POST\n" +"True" +msgstr "" + +#: howto/enum.rst:671 msgid "" "However, they still can't be compared to standard :class:`Enum` " "enumerations::" msgstr "" -#: howto/enum.rst:681 +#: howto/enum.rst:673 +msgid "" +">>> class Shape(IntEnum):\n" +"... CIRCLE = 1\n" +"... SQUARE = 2\n" +"...\n" +">>> class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"...\n" +">>> Shape.CIRCLE == Color.RED\n" +"False" +msgstr "" + +#: howto/enum.rst:684 msgid "" ":class:`IntEnum` values behave like integers in other ways you'd expect::" msgstr "" -#: howto/enum.rst:692 +#: howto/enum.rst:686 +msgid "" +">>> int(Shape.CIRCLE)\n" +"1\n" +">>> ['a', 'b', 'c'][Shape.CIRCLE]\n" +"'b'\n" +">>> [i for i in range(Shape.SQUARE)]\n" +"[0, 1]" +msgstr "" + +#: howto/enum.rst:695 msgid "StrEnum" msgstr "" -#: howto/enum.rst:694 +#: howto/enum.rst:697 msgid "" "The second variation of :class:`Enum` that is provided is also a subclass " "of :class:`str`. Members of a :class:`StrEnum` can be compared to strings; " @@ -563,121 +1073,230 @@ msgid "" "each other." msgstr "" -#: howto/enum.rst:703 +#: howto/enum.rst:706 msgid "IntFlag" msgstr "" -#: howto/enum.rst:705 +#: howto/enum.rst:708 msgid "" "The next variation of :class:`Enum` provided, :class:`IntFlag`, is also " "based on :class:`int`. The difference being :class:`IntFlag` members can be " "combined using the bitwise operators (&, \\|, ^, ~) and the result is still " -"an :class:`IntFlag` member, if possible. Like :class:`IntEnum`, :class:" -"`IntFlag` members are also integers and can be used wherever an :class:`int` " -"is used." +"an :class:`IntFlag` member, if possible. " +"Like :class:`IntEnum`, :class:`IntFlag` members are also integers and can be " +"used wherever an :class:`int` is used." msgstr "" -#: howto/enum.rst:713 +#: howto/enum.rst:716 msgid "" "Any operation on an :class:`IntFlag` member besides the bit-wise operations " "will lose the :class:`IntFlag` membership." msgstr "" -#: howto/enum.rst:716 +#: howto/enum.rst:719 msgid "" "Bit-wise operations that result in invalid :class:`IntFlag` values will lose " "the :class:`IntFlag` membership. See :class:`FlagBoundary` for details." msgstr "" -#: howto/enum.rst:723 +#: howto/enum.rst:726 msgid "Sample :class:`IntFlag` class::" msgstr "" -#: howto/enum.rst:739 +#: howto/enum.rst:728 +msgid "" +">>> from enum import IntFlag\n" +">>> class Perm(IntFlag):\n" +"... R = 4\n" +"... W = 2\n" +"... X = 1\n" +"...\n" +">>> Perm.R | Perm.W\n" +"\n" +">>> Perm.R + Perm.W\n" +"6\n" +">>> RW = Perm.R | Perm.W\n" +">>> Perm.R in RW\n" +"True" +msgstr "" + +#: howto/enum.rst:742 msgid "It is also possible to name the combinations::" msgstr "" -#: howto/enum.rst:756 +#: howto/enum.rst:744 +msgid "" +">>> class Perm(IntFlag):\n" +"... R = 4\n" +"... W = 2\n" +"... X = 1\n" +"... RWX = 7\n" +"...\n" +">>> Perm.RWX\n" +"\n" +">>> ~Perm.RWX\n" +"\n" +">>> Perm(7)\n" +"" +msgstr "" + +#: howto/enum.rst:759 msgid "" "Named combinations are considered aliases. Aliases do not show up during " "iteration, but can be returned from by-value lookups." msgstr "" -#: howto/enum.rst:761 +#: howto/enum.rst:764 msgid "" "Another important difference between :class:`IntFlag` and :class:`Enum` is " -"that if no flags are set (the value is 0), its boolean evaluation is :data:" -"`False`::" +"that if no flags are set (the value is 0), its boolean evaluation " +"is :data:`False`::" +msgstr "" + +#: howto/enum.rst:767 +msgid "" +">>> Perm.R & Perm.X\n" +"\n" +">>> bool(Perm.R & Perm.X)\n" +"False" msgstr "" -#: howto/enum.rst:769 +#: howto/enum.rst:772 msgid "" "Because :class:`IntFlag` members are also subclasses of :class:`int` they " "can be combined with them (but may lose :class:`IntFlag` membership::" msgstr "" -#: howto/enum.rst:780 +#: howto/enum.rst:775 +msgid "" +">>> Perm.X | 4\n" +"\n" +"\n" +">>> Perm.X + 8\n" +"9" +msgstr "" + +#: howto/enum.rst:783 msgid "" "The negation operator, ``~``, always returns an :class:`IntFlag` member with " "a positive value::" msgstr "" #: howto/enum.rst:786 +msgid "" +">>> (~Perm.X).value == (Perm.R|Perm.W).value == 6\n" +"True" +msgstr "" + +#: howto/enum.rst:789 msgid ":class:`IntFlag` members can also be iterated over::" msgstr "" -#: howto/enum.rst:795 +#: howto/enum.rst:791 +msgid "" +">>> list(RW)\n" +"[, ]" +msgstr "" + +#: howto/enum.rst:798 msgid "Flag" msgstr "" -#: howto/enum.rst:797 +#: howto/enum.rst:800 msgid "" "The last variation is :class:`Flag`. Like :class:`IntFlag`, :class:`Flag` " -"members can be combined using the bitwise operators (&, \\|, ^, ~). Unlike :" -"class:`IntFlag`, they cannot be combined with, nor compared against, any " -"other :class:`Flag` enumeration, nor :class:`int`. While it is possible to " -"specify the values directly it is recommended to use :class:`auto` as the " +"members can be combined using the bitwise operators (&, \\|, ^, ~). " +"Unlike :class:`IntFlag`, they cannot be combined with, nor compared against, " +"any other :class:`Flag` enumeration, nor :class:`int`. While it is possible " +"to specify the values directly it is recommended to use :class:`auto` as the " "value and let :class:`Flag` select an appropriate value." msgstr "" -#: howto/enum.rst:806 +#: howto/enum.rst:809 msgid "" "Like :class:`IntFlag`, if a combination of :class:`Flag` members results in " "no flags being set, the boolean evaluation is :data:`False`::" msgstr "" -#: howto/enum.rst:820 +#: howto/enum.rst:812 +msgid "" +">>> from enum import Flag, auto\n" +">>> class Color(Flag):\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"...\n" +">>> Color.RED & Color.GREEN\n" +"\n" +">>> bool(Color.RED & Color.GREEN)\n" +"False" +msgstr "" + +#: howto/enum.rst:823 msgid "" "Individual flags should have values that are powers of two (1, 2, 4, " "8, ...), while combinations of flags will not::" msgstr "" -#: howto/enum.rst:832 +#: howto/enum.rst:826 +msgid "" +">>> class Color(Flag):\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"... WHITE = RED | BLUE | GREEN\n" +"...\n" +">>> Color.WHITE\n" +"" +msgstr "" + +#: howto/enum.rst:835 msgid "" "Giving a name to the \"no flags set\" condition does not change its boolean " "value::" msgstr "" -#: howto/enum.rst:846 +#: howto/enum.rst:838 +msgid "" +">>> class Color(Flag):\n" +"... BLACK = 0\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"...\n" +">>> Color.BLACK\n" +"\n" +">>> bool(Color.BLACK)\n" +"False" +msgstr "" + +#: howto/enum.rst:849 msgid ":class:`Flag` members can also be iterated over::" msgstr "" -#: howto/enum.rst:856 +#: howto/enum.rst:851 +msgid "" +">>> purple = Color.RED | Color.BLUE\n" +">>> list(purple)\n" +"[, ]" +msgstr "" + +#: howto/enum.rst:859 msgid "" "For the majority of new code, :class:`Enum` and :class:`Flag` are strongly " "recommended, since :class:`IntEnum` and :class:`IntFlag` break some semantic " "promises of an enumeration (by being comparable to integers, and thus by " -"transitivity to other unrelated enumerations). :class:`IntEnum` and :class:" -"`IntFlag` should be used only in cases where :class:`Enum` and :class:`Flag` " -"will not do; for example, when integer constants are replaced with " -"enumerations, or for interoperability with other systems." +"transitivity to other unrelated enumerations). :class:`IntEnum` " +"and :class:`IntFlag` should be used only in cases where :class:`Enum` " +"and :class:`Flag` will not do; for example, when integer constants are " +"replaced with enumerations, or for interoperability with other systems." msgstr "" -#: howto/enum.rst:866 +#: howto/enum.rst:869 msgid "Others" msgstr "" -#: howto/enum.rst:868 +#: howto/enum.rst:871 msgid "" "While :class:`IntEnum` is part of the :mod:`enum` module, it would be very " "simple to implement independently::" @@ -685,200 +1304,252 @@ msgstr "" #: howto/enum.rst:874 msgid "" -"This demonstrates how similar derived enumerations can be defined; for " -"example a :class:`FloatEnum` that mixes in :class:`float` instead of :class:" -"`int`." +"class IntEnum(int, Enum):\n" +" pass" msgstr "" #: howto/enum.rst:877 -msgid "Some rules:" +msgid "" +"This demonstrates how similar derived enumerations can be defined; for " +"example a :class:`!FloatEnum` that mixes in :class:`float` instead " +"of :class:`int`." msgstr "" -#: howto/enum.rst:879 -msgid "" -"When subclassing :class:`Enum`, mix-in types must appear before :class:" -"`Enum` itself in the sequence of bases, as in the :class:`IntEnum` example " -"above." +#: howto/enum.rst:880 +msgid "Some rules:" msgstr "" #: howto/enum.rst:882 msgid "" -"Mix-in types must be subclassable. For example, :class:`bool` and :class:" -"`range` are not subclassable and will throw an error during Enum creation if " -"used as the mix-in type." +"When subclassing :class:`Enum`, mix-in types must appear " +"before :class:`Enum` itself in the sequence of bases, as in " +"the :class:`IntEnum` example above." msgstr "" #: howto/enum.rst:885 msgid "" -"While :class:`Enum` can have members of any type, once you mix in an " -"additional type, all the members must have values of that type, e.g. :class:" -"`int` above. This restriction does not apply to mix-ins which only add " -"methods and don't specify another type." +"Mix-in types must be subclassable. For example, :class:`bool` " +"and :class:`range` are not subclassable and will throw an error during Enum " +"creation if used as the mix-in type." msgstr "" -#: howto/enum.rst:889 +#: howto/enum.rst:888 msgid "" -"When another data type is mixed in, the :attr:`value` attribute is *not the " -"same* as the enum member itself, although it is equivalent and will compare " -"equal." +"While :class:`Enum` can have members of any type, once you mix in an " +"additional type, all the members must have values of that type, " +"e.g. :class:`int` above. This restriction does not apply to mix-ins which " +"only add methods and don't specify another type." msgstr "" #: howto/enum.rst:892 msgid "" -"A ``data type`` is a mixin that defines :meth:`__new__`, or a :class:" -"`~dataclasses.dataclass`" +"When another data type is mixed in, the :attr:`~Enum.value` attribute is " +"*not the same* as the enum member itself, although it is equivalent and will " +"compare equal." msgstr "" -#: howto/enum.rst:894 +#: howto/enum.rst:895 msgid "" -"%-style formatting: ``%s`` and ``%r`` call the :class:`Enum` class's :meth:" -"`__str__` and :meth:`__repr__` respectively; other codes (such as ``%i`` or " -"``%h`` for IntEnum) treat the enum member as its mixed-in type." +"A ``data type`` is a mixin that defines :meth:`~object.__new__`, or " +"a :class:`~dataclasses.dataclass`" msgstr "" #: howto/enum.rst:897 msgid "" -":ref:`Formatted string literals `, :meth:`str.format`, and :func:" -"`format` will use the enum's :meth:`__str__` method." +"%-style formatting: ``%s`` and ``%r`` call the :class:`Enum` " +"class's :meth:`~object.__str__` and :meth:`~object.__repr__` respectively; " +"other codes (such as ``%i`` or ``%h`` for IntEnum) treat the enum member as " +"its mixed-in type." +msgstr "" + +#: howto/enum.rst:900 +msgid "" +":ref:`Formatted string literals `, :meth:`str.format`, " +"and :func:`format` will use the enum's :meth:`~object.__str__` method." msgstr "" -#: howto/enum.rst:902 +#: howto/enum.rst:905 msgid "" "Because :class:`IntEnum`, :class:`IntFlag`, and :class:`StrEnum` are " -"designed to be drop-in replacements for existing constants, their :meth:" -"`__str__` method has been reset to their data types' :meth:`__str__` method." +"designed to be drop-in replacements for existing constants, " +"their :meth:`~object.__str__` method has been reset to their data " +"types' :meth:`~object.__str__` method." msgstr "" -#: howto/enum.rst:910 -msgid "When to use :meth:`__new__` vs. :meth:`__init__`" +#: howto/enum.rst:913 +msgid "When to use :meth:`~object.__new__` vs. :meth:`~object.__init__`" msgstr "" -#: howto/enum.rst:912 +#: howto/enum.rst:915 msgid "" -":meth:`__new__` must be used whenever you want to customize the actual value " -"of the :class:`Enum` member. Any other modifications may go in either :meth:" -"`__new__` or :meth:`__init__`, with :meth:`__init__` being preferred." +":meth:`~object.__new__` must be used whenever you want to customize the " +"actual value of the :class:`Enum` member. Any other modifications may go in " +"either :meth:`~object.__new__` or :meth:`~object.__init__`, " +"with :meth:`~object.__init__` being preferred." msgstr "" -#: howto/enum.rst:916 +#: howto/enum.rst:919 msgid "" "For example, if you want to pass several items to the constructor, but only " "want one of them to be the value::" msgstr "" -#: howto/enum.rst:943 +#: howto/enum.rst:922 +msgid "" +">>> class Coordinate(bytes, Enum):\n" +"... \"\"\"\n" +"... Coordinate with binary codes that can be indexed by the int code.\n" +"... \"\"\"\n" +"... def __new__(cls, value, label, unit):\n" +"... obj = bytes.__new__(cls, [value])\n" +"... obj._value_ = value\n" +"... obj.label = label\n" +"... obj.unit = unit\n" +"... return obj\n" +"... PX = (0, 'P.X', 'km')\n" +"... PY = (1, 'P.Y', 'km')\n" +"... VX = (2, 'V.X', 'km/s')\n" +"... VY = (3, 'V.Y', 'km/s')\n" +"...\n" +"\n" +">>> print(Coordinate['PY'])\n" +"Coordinate.PY\n" +"\n" +">>> print(Coordinate(3))\n" +"Coordinate.VY" +msgstr "" + +#: howto/enum.rst:946 msgid "" "*Do not* call ``super().__new__()``, as the lookup-only ``__new__`` is the " "one that is found; instead, use the data type directly." msgstr "" -#: howto/enum.rst:948 +#: howto/enum.rst:951 msgid "Finer Points" msgstr "" -#: howto/enum.rst:951 +#: howto/enum.rst:954 msgid "Supported ``__dunder__`` names" msgstr "" -#: howto/enum.rst:953 +#: howto/enum.rst:956 msgid "" -":attr:`__members__` is a read-only ordered mapping of ``member_name``:" -"``member`` items. It is only available on the class." +":attr:`~enum.EnumType.__members__` is a read-only ordered mapping of " +"``member_name``:``member`` items. It is only available on the class." msgstr "" -#: howto/enum.rst:956 +#: howto/enum.rst:959 msgid "" -":meth:`__new__`, if specified, must create and return the enum members; it " -"is also a very good idea to set the member's :attr:`_value_` appropriately. " -"Once all the members are created it is no longer used." +":meth:`~object.__new__`, if specified, must create and return the enum " +"members; it is also a very good idea to set the " +"member's :attr:`~Enum._value_` appropriately. Once all the members are " +"created it is no longer used." msgstr "" -#: howto/enum.rst:962 +#: howto/enum.rst:965 msgid "Supported ``_sunder_`` names" msgstr "" -#: howto/enum.rst:964 -msgid "``_name_`` -- name of the member" +#: howto/enum.rst:967 +msgid ":attr:`~Enum._name_` -- name of the member" msgstr "" -#: howto/enum.rst:965 +#: howto/enum.rst:968 msgid "" -"``_value_`` -- value of the member; can be set / modified in ``__new__``" +":attr:`~Enum._value_` -- value of the member; can be set / modified in " +"``__new__``" msgstr "" -#: howto/enum.rst:967 +#: howto/enum.rst:970 msgid "" -"``_missing_`` -- a lookup function used when a value is not found; may be " -"overridden" +":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " +"may be overridden" msgstr "" -#: howto/enum.rst:969 +#: howto/enum.rst:972 msgid "" -"``_ignore_`` -- a list of names, either as a :class:`list` or a :class:" -"`str`, that will not be transformed into members, and will be removed from " -"the final class" +":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or " +"a :class:`str`, that will not be transformed into members, and will be " +"removed from the final class" msgstr "" -#: howto/enum.rst:972 +#: howto/enum.rst:975 msgid "" -"``_order_`` -- used in Python 2/3 code to ensure member order is consistent " -"(class attribute, removed during class creation)" +":attr:`~Enum._order_` -- used in Python 2/3 code to ensure member order is " +"consistent (class attribute, removed during class creation)" msgstr "" -#: howto/enum.rst:974 +#: howto/enum.rst:977 msgid "" -"``_generate_next_value_`` -- used by the `Functional API`_ and by :class:" -"`auto` to get an appropriate value for an enum member; may be overridden" +":meth:`~Enum._generate_next_value_` -- used by the `Functional API`_ and " +"by :class:`auto` to get an appropriate value for an enum member; may be " +"overridden" msgstr "" -#: howto/enum.rst:980 +#: howto/enum.rst:983 msgid "" "For standard :class:`Enum` classes the next value chosen is the last value " "seen incremented by one." msgstr "" -#: howto/enum.rst:983 +#: howto/enum.rst:986 msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " "power-of-two, regardless of the last value seen." msgstr "" -#: howto/enum.rst:986 +#: howto/enum.rst:989 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "" -#: howto/enum.rst:987 +#: howto/enum.rst:990 msgid "``_ignore_``" msgstr "" -#: howto/enum.rst:989 +#: howto/enum.rst:992 msgid "" -"To help keep Python 2 / Python 3 code in sync an :attr:`_order_` attribute " -"can be provided. It will be checked against the actual order of the " -"enumeration and raise an error if the two do not match::" +"To help keep Python 2 / Python 3 code in sync an :attr:`~Enum._order_` " +"attribute can be provided. It will be checked against the actual order of " +"the enumeration and raise an error if the two do not match::" msgstr "" -#: howto/enum.rst:1007 +#: howto/enum.rst:996 msgid "" -"In Python 2 code the :attr:`_order_` attribute is necessary as definition " -"order is lost before it can be recorded." +">>> class Color(Enum):\n" +"... _order_ = 'RED GREEN BLUE'\n" +"... RED = 1\n" +"... BLUE = 3\n" +"... GREEN = 2\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"TypeError: member order does not match _order_:\n" +" ['RED', 'BLUE', 'GREEN']\n" +" ['RED', 'GREEN', 'BLUE']" msgstr "" -#: howto/enum.rst:1012 +#: howto/enum.rst:1010 +msgid "" +"In Python 2 code the :attr:`~Enum._order_` attribute is necessary as " +"definition order is lost before it can be recorded." +msgstr "" + +#: howto/enum.rst:1015 msgid "_Private__names" msgstr "" -#: howto/enum.rst:1014 +#: howto/enum.rst:1017 msgid "" ":ref:`Private names ` are not converted to enum " "members, but remain normal attributes." msgstr "" -#: howto/enum.rst:1021 +#: howto/enum.rst:1024 msgid "``Enum`` member type" msgstr "" -#: howto/enum.rst:1023 +#: howto/enum.rst:1026 msgid "" "Enum members are instances of their enum class, and are normally accessed as " "``EnumClass.member``. In certain situations, such as writing custom enum " @@ -888,384 +1559,708 @@ msgid "" "strongly recommended." msgstr "" -#: howto/enum.rst:1034 +#: howto/enum.rst:1037 msgid "Creating members that are mixed with other data types" msgstr "" -#: howto/enum.rst:1036 +#: howto/enum.rst:1039 msgid "" "When subclassing other data types, such as :class:`int` or :class:`str`, " "with an :class:`Enum`, all values after the ``=`` are passed to that data " "type's constructor. For example::" msgstr "" -#: howto/enum.rst:1048 +#: howto/enum.rst:1043 +msgid "" +">>> class MyEnum(IntEnum): # help(int) -> int(x, base=10) -> integer\n" +"... example = '11', 16 # so x='11' and base=16\n" +"...\n" +">>> MyEnum.example.value # and hex(11) is...\n" +"17" +msgstr "" + +#: howto/enum.rst:1051 msgid "Boolean value of ``Enum`` classes and members" msgstr "" -#: howto/enum.rst:1050 +#: howto/enum.rst:1053 msgid "" -"Enum classes that are mixed with non-:class:`Enum` types (such as :class:" -"`int`, :class:`str`, etc.) are evaluated according to the mixed-in type's " -"rules; otherwise, all members evaluate as :data:`True`. To make your own " -"enum's boolean evaluation depend on the member's value add the following to " -"your class::" +"Enum classes that are mixed with non-:class:`Enum` types (such " +"as :class:`int`, :class:`str`, etc.) are evaluated according to the mixed-in " +"type's rules; otherwise, all members evaluate as :data:`True`. To make your " +"own enum's boolean evaluation depend on the member's value add the following " +"to your class::" msgstr "" #: howto/enum.rst:1059 +msgid "" +"def __bool__(self):\n" +" return bool(self.value)" +msgstr "" + +#: howto/enum.rst:1062 msgid "Plain :class:`Enum` classes always evaluate as :data:`True`." msgstr "" -#: howto/enum.rst:1063 +#: howto/enum.rst:1066 msgid "``Enum`` classes with methods" msgstr "" -#: howto/enum.rst:1065 +#: howto/enum.rst:1068 msgid "" "If you give your enum subclass extra methods, like the `Planet`_ class " "below, those methods will show up in a :func:`dir` of the member, but not of " "the class::" msgstr "" -#: howto/enum.rst:1076 +#: howto/enum.rst:1072 +msgid "" +">>> dir(Planet) \n" +"['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', " +"'VENUS', '__class__', '__doc__', '__members__', '__module__']\n" +">>> dir(Planet.EARTH) \n" +"['__class__', '__doc__', '__module__', 'mass', 'name', 'radius', " +"'surface_gravity', 'value']" +msgstr "" + +#: howto/enum.rst:1079 msgid "Combining members of ``Flag``" msgstr "" -#: howto/enum.rst:1078 +#: howto/enum.rst:1081 msgid "" "Iterating over a combination of :class:`Flag` members will only return the " "members that are comprised of a single bit::" msgstr "" -#: howto/enum.rst:1096 +#: howto/enum.rst:1084 +msgid "" +">>> class Color(Flag):\n" +"... RED = auto()\n" +"... GREEN = auto()\n" +"... BLUE = auto()\n" +"... MAGENTA = RED | BLUE\n" +"... YELLOW = RED | GREEN\n" +"... CYAN = GREEN | BLUE\n" +"...\n" +">>> Color(3) # named combination\n" +"\n" +">>> Color(7) # not named combination\n" +"" +msgstr "" + +#: howto/enum.rst:1099 msgid "``Flag`` and ``IntFlag`` minutia" msgstr "" -#: howto/enum.rst:1098 +#: howto/enum.rst:1101 msgid "Using the following snippet for our examples::" msgstr "" -#: howto/enum.rst:1109 +#: howto/enum.rst:1103 +msgid "" +">>> class Color(IntFlag):\n" +"... BLACK = 0\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 4\n" +"... PURPLE = RED | BLUE\n" +"... WHITE = RED | GREEN | BLUE\n" +"..." +msgstr "" + +#: howto/enum.rst:1112 msgid "the following are true:" msgstr "" -#: howto/enum.rst:1111 +#: howto/enum.rst:1114 msgid "single-bit flags are canonical" msgstr "" -#: howto/enum.rst:1112 +#: howto/enum.rst:1115 msgid "multi-bit and zero-bit flags are aliases" msgstr "" -#: howto/enum.rst:1113 +#: howto/enum.rst:1116 msgid "only canonical flags are returned during iteration::" msgstr "" #: howto/enum.rst:1118 msgid "" +">>> list(Color.WHITE)\n" +"[, , ]" +msgstr "" + +#: howto/enum.rst:1121 +msgid "" "negating a flag or flag set returns a new flag/flag set with the " "corresponding positive integer value::" msgstr "" -#: howto/enum.rst:1127 +#: howto/enum.rst:1124 +msgid "" +">>> Color.BLUE\n" +"\n" +"\n" +">>> ~Color.BLUE\n" +"" +msgstr "" + +#: howto/enum.rst:1130 msgid "names of pseudo-flags are constructed from their members' names::" msgstr "" #: howto/enum.rst:1132 -msgid "multi-bit flags, aka aliases, can be returned from operations::" +msgid "" +">>> (Color.RED | Color.GREEN).name\n" +"'RED|GREEN'\n" +"\n" +">>> class Perm(IntFlag):\n" +"... R = 4\n" +"... W = 2\n" +"... X = 1\n" +"...\n" +">>> (Perm.R & Perm.W).name is None # effectively Perm(0)\n" +"True" msgstr "" #: howto/enum.rst:1143 +msgid "multi-bit flags, aka aliases, can be returned from operations::" +msgstr "" + +#: howto/enum.rst:1145 +msgid "" +">>> Color.RED | Color.BLUE\n" +"\n" +"\n" +">>> Color(7) # or Color(-1)\n" +"\n" +"\n" +">>> Color(0)\n" +"" +msgstr "" + +#: howto/enum.rst:1154 msgid "" "membership / containment checking: zero-valued flags are always considered " "to be contained::" msgstr "" -#: howto/enum.rst:1149 +#: howto/enum.rst:1157 +msgid "" +">>> Color.BLACK in Color.WHITE\n" +"True" +msgstr "" + +#: howto/enum.rst:1160 msgid "" "otherwise, only if all bits of one flag are in the other flag will True be " "returned::" msgstr "" -#: howto/enum.rst:1158 +#: howto/enum.rst:1163 +msgid "" +">>> Color.PURPLE in Color.WHITE\n" +"True\n" +"\n" +">>> Color.GREEN in Color.PURPLE\n" +"False" +msgstr "" + +#: howto/enum.rst:1169 msgid "" "There is a new boundary mechanism that controls how out-of-range / invalid " "bits are handled: ``STRICT``, ``CONFORM``, ``EJECT``, and ``KEEP``:" msgstr "" -#: howto/enum.rst:1161 +#: howto/enum.rst:1172 msgid "STRICT --> raises an exception when presented with invalid values" msgstr "" -#: howto/enum.rst:1162 +#: howto/enum.rst:1173 msgid "CONFORM --> discards any invalid bits" msgstr "" -#: howto/enum.rst:1163 +#: howto/enum.rst:1174 msgid "EJECT --> lose Flag status and become a normal int with the given value" msgstr "" -#: howto/enum.rst:1164 +#: howto/enum.rst:1175 msgid "KEEP --> keep the extra bits" msgstr "" -#: howto/enum.rst:1166 +#: howto/enum.rst:1177 msgid "keeps Flag status and extra bits" msgstr "" -#: howto/enum.rst:1167 +#: howto/enum.rst:1178 msgid "extra bits do not show up in iteration" msgstr "" -#: howto/enum.rst:1168 +#: howto/enum.rst:1179 msgid "extra bits do show up in repr() and str()" msgstr "" -#: howto/enum.rst:1170 +#: howto/enum.rst:1181 msgid "" "The default for Flag is ``STRICT``, the default for ``IntFlag`` is " -"``EJECT``, and the default for ``_convert_`` is ``KEEP`` (see ``ssl." -"Options`` for an example of when ``KEEP`` is needed)." +"``EJECT``, and the default for ``_convert_`` is ``KEEP`` (see " +"``ssl.Options`` for an example of when ``KEEP`` is needed)." msgstr "" -#: howto/enum.rst:1178 +#: howto/enum.rst:1189 msgid "How are Enums and Flags different?" msgstr "" -#: howto/enum.rst:1180 +#: howto/enum.rst:1191 msgid "" -"Enums have a custom metaclass that affects many aspects of both derived :" -"class:`Enum` classes and their instances (members)." +"Enums have a custom metaclass that affects many aspects of both " +"derived :class:`Enum` classes and their instances (members)." msgstr "" -#: howto/enum.rst:1185 +#: howto/enum.rst:1196 msgid "Enum Classes" msgstr "" -#: howto/enum.rst:1187 +#: howto/enum.rst:1198 msgid "" -"The :class:`EnumType` metaclass is responsible for providing the :meth:" -"`__contains__`, :meth:`__dir__`, :meth:`__iter__` and other methods that " -"allow one to do things with an :class:`Enum` class that fail on a typical " -"class, such as ``list(Color)`` or ``some_enum_var in Color``. :class:" -"`EnumType` is responsible for ensuring that various other methods on the " -"final :class:`Enum` class are correct (such as :meth:`__new__`, :meth:" -"`__getnewargs__`, :meth:`__str__` and :meth:`__repr__`)." +"The :class:`EnumType` metaclass is responsible for providing " +"the :meth:`~object.__contains__`, :meth:`~object.__dir__`, :meth:`~object.__iter__` " +"and other methods that allow one to do things with an :class:`Enum` class " +"that fail on a typical class, such as ``list(Color)`` or ``some_enum_var in " +"Color``. :class:`EnumType` is responsible for ensuring that various other " +"methods on the final :class:`Enum` class are correct (such " +"as :meth:`~object.__new__`, :meth:`~object.__getnewargs__`, :meth:`~object.__str__` " +"and :meth:`~object.__repr__`)." msgstr "" -#: howto/enum.rst:1196 +#: howto/enum.rst:1207 msgid "Flag Classes" msgstr "" -#: howto/enum.rst:1198 +#: howto/enum.rst:1209 msgid "" "Flags have an expanded view of aliasing: to be canonical, the value of a " "flag needs to be a power-of-two value, and not a duplicate name. So, in " -"addition to the :class:`Enum` definition of alias, a flag with no value (a.k." -"a. ``0``) or with more than one power-of-two value (e.g. ``3``) is " +"addition to the :class:`Enum` definition of alias, a flag with no value " +"(a.k.a. ``0``) or with more than one power-of-two value (e.g. ``3``) is " "considered an alias." msgstr "" -#: howto/enum.rst:1204 +#: howto/enum.rst:1215 msgid "Enum Members (aka instances)" msgstr "" -#: howto/enum.rst:1206 +#: howto/enum.rst:1217 msgid "" -"The most interesting thing about enum members is that they are singletons. :" -"class:`EnumType` creates them all while it is creating the enum class " -"itself, and then puts a custom :meth:`__new__` in place to ensure that no " -"new ones are ever instantiated by returning only the existing member " -"instances." +"The most interesting thing about enum members is that they are " +"singletons. :class:`EnumType` creates them all while it is creating the enum " +"class itself, and then puts a custom :meth:`~object.__new__` in place to " +"ensure that no new ones are ever instantiated by returning only the existing " +"member instances." msgstr "" -#: howto/enum.rst:1212 +#: howto/enum.rst:1223 msgid "Flag Members" msgstr "" -#: howto/enum.rst:1214 +#: howto/enum.rst:1225 msgid "" "Flag members can be iterated over just like the :class:`Flag` class, and " "only the canonical members will be returned. For example::" msgstr "" -#: howto/enum.rst:1220 +#: howto/enum.rst:1228 +msgid "" +">>> list(Color)\n" +"[, , ]" +msgstr "" + +#: howto/enum.rst:1231 msgid "(Note that ``BLACK``, ``PURPLE``, and ``WHITE`` do not show up.)" msgstr "" -#: howto/enum.rst:1222 +#: howto/enum.rst:1233 msgid "" "Inverting a flag member returns the corresponding positive value, rather " "than a negative value --- for example::" msgstr "" -#: howto/enum.rst:1228 +#: howto/enum.rst:1236 +msgid "" +">>> ~Color.RED\n" +"" +msgstr "" + +#: howto/enum.rst:1239 msgid "" "Flag members have a length corresponding to the number of power-of-two " "values they contain. For example::" msgstr "" -#: howto/enum.rst:1238 +#: howto/enum.rst:1242 +msgid "" +">>> len(Color.PURPLE)\n" +"2" +msgstr "" + +#: howto/enum.rst:1249 msgid "Enum Cookbook" msgstr "" -#: howto/enum.rst:1241 +#: howto/enum.rst:1252 msgid "" -"While :class:`Enum`, :class:`IntEnum`, :class:`StrEnum`, :class:`Flag`, and :" -"class:`IntFlag` are expected to cover the majority of use-cases, they cannot " -"cover them all. Here are recipes for some different types of enumerations " -"that can be used directly, or as examples for creating one's own." +"While :class:`Enum`, :class:`IntEnum`, :class:`StrEnum`, :class:`Flag`, " +"and :class:`IntFlag` are expected to cover the majority of use-cases, they " +"cannot cover them all. Here are recipes for some different types of " +"enumerations that can be used directly, or as examples for creating one's " +"own." msgstr "" -#: howto/enum.rst:1248 +#: howto/enum.rst:1259 msgid "Omitting values" msgstr "" -#: howto/enum.rst:1250 +#: howto/enum.rst:1261 msgid "" "In many use-cases, one doesn't care what the actual value of an enumeration " "is. There are several ways to define this type of simple enumeration:" msgstr "" -#: howto/enum.rst:1253 +#: howto/enum.rst:1264 msgid "use instances of :class:`auto` for the value" msgstr "" -#: howto/enum.rst:1254 +#: howto/enum.rst:1265 msgid "use instances of :class:`object` as the value" msgstr "" -#: howto/enum.rst:1255 +#: howto/enum.rst:1266 msgid "use a descriptive string as the value" msgstr "" -#: howto/enum.rst:1256 +#: howto/enum.rst:1267 msgid "" -"use a tuple as the value and a custom :meth:`__new__` to replace the tuple " -"with an :class:`int` value" +"use a tuple as the value and a custom :meth:`~object.__new__` to replace the " +"tuple with an :class:`int` value" msgstr "" -#: howto/enum.rst:1259 +#: howto/enum.rst:1270 msgid "" "Using any of these methods signifies to the user that these values are not " "important, and also enables one to add, remove, or reorder members without " "having to renumber the remaining members." msgstr "" -#: howto/enum.rst:1265 +#: howto/enum.rst:1276 msgid "Using :class:`auto`" msgstr "" -#: howto/enum.rst:1267 +#: howto/enum.rst:1278 msgid "Using :class:`auto` would look like::" msgstr "" -#: howto/enum.rst:1279 +#: howto/enum.rst:1280 +msgid "" +">>> class Color(Enum):\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"...\n" +">>> Color.GREEN\n" +"" +msgstr "" + +#: howto/enum.rst:1290 msgid "Using :class:`object`" msgstr "" -#: howto/enum.rst:1281 +#: howto/enum.rst:1292 msgid "Using :class:`object` would look like::" msgstr "" -#: howto/enum.rst:1291 +#: howto/enum.rst:1294 +msgid "" +">>> class Color(Enum):\n" +"... RED = object()\n" +"... GREEN = object()\n" +"... BLUE = object()\n" +"...\n" +">>> Color.GREEN \n" +">" +msgstr "" + +#: howto/enum.rst:1302 msgid "" -"This is also a good example of why you might want to write your own :meth:" -"`__repr__`::" +"This is also a good example of why you might want to write your " +"own :meth:`~object.__repr__`::" msgstr "" -#: howto/enum.rst:1307 +#: howto/enum.rst:1305 +msgid "" +">>> class Color(Enum):\n" +"... RED = object()\n" +"... GREEN = object()\n" +"... BLUE = object()\n" +"... def __repr__(self):\n" +"... return \"<%s.%s>\" % (self.__class__.__name__, self._name_)\n" +"...\n" +">>> Color.GREEN\n" +"" +msgstr "" + +#: howto/enum.rst:1318 msgid "Using a descriptive string" msgstr "" -#: howto/enum.rst:1309 +#: howto/enum.rst:1320 msgid "Using a string as the value would look like::" msgstr "" -#: howto/enum.rst:1321 -msgid "Using a custom :meth:`__new__`" +#: howto/enum.rst:1322 +msgid "" +">>> class Color(Enum):\n" +"... RED = 'stop'\n" +"... GREEN = 'go'\n" +"... BLUE = 'too fast!'\n" +"...\n" +">>> Color.GREEN\n" +"" msgstr "" -#: howto/enum.rst:1323 -msgid "Using an auto-numbering :meth:`__new__` would look like::" +#: howto/enum.rst:1332 +msgid "Using a custom :meth:`~object.__new__`" msgstr "" -#: howto/enum.rst:1340 +#: howto/enum.rst:1334 +msgid "Using an auto-numbering :meth:`~object.__new__` would look like::" +msgstr "" + +#: howto/enum.rst:1336 +msgid "" +">>> class AutoNumber(Enum):\n" +"... def __new__(cls):\n" +"... value = len(cls.__members__) + 1\n" +"... obj = object.__new__(cls)\n" +"... obj._value_ = value\n" +"... return obj\n" +"...\n" +">>> class Color(AutoNumber):\n" +"... RED = ()\n" +"... GREEN = ()\n" +"... BLUE = ()\n" +"...\n" +">>> Color.GREEN\n" +"" +msgstr "" + +#: howto/enum.rst:1351 msgid "" "To make a more general purpose ``AutoNumber``, add ``*args`` to the " "signature::" msgstr "" -#: howto/enum.rst:1350 +#: howto/enum.rst:1353 +msgid "" +">>> class AutoNumber(Enum):\n" +"... def __new__(cls, *args): # this is the only change from above\n" +"... value = len(cls.__members__) + 1\n" +"... obj = object.__new__(cls)\n" +"... obj._value_ = value\n" +"... return obj\n" +"..." +msgstr "" + +#: howto/enum.rst:1361 msgid "" "Then when you inherit from ``AutoNumber`` you can write your own " "``__init__`` to handle any extra arguments::" msgstr "" -#: howto/enum.rst:1369 +#: howto/enum.rst:1364 msgid "" -"The :meth:`__new__` method, if defined, is used during creation of the Enum " -"members; it is then replaced by Enum's :meth:`__new__` which is used after " -"class creation for lookup of existing members." +">>> class Swatch(AutoNumber):\n" +"... def __init__(self, pantone='unknown'):\n" +"... self.pantone = pantone\n" +"... AUBURN = '3497'\n" +"... SEA_GREEN = '1246'\n" +"... BLEACHED_CORAL = () # New color, no Pantone code yet!\n" +"...\n" +">>> Swatch.SEA_GREEN\n" +"\n" +">>> Swatch.SEA_GREEN.pantone\n" +"'1246'\n" +">>> Swatch.BLEACHED_CORAL.pantone\n" +"'unknown'" msgstr "" -#: howto/enum.rst:1375 +#: howto/enum.rst:1380 +msgid "" +"The :meth:`~object.__new__` method, if defined, is used during creation of " +"the Enum members; it is then replaced by Enum's :meth:`~object.__new__` " +"which is used after class creation for lookup of existing members." +msgstr "" + +#: howto/enum.rst:1386 msgid "" "*Do not* call ``super().__new__()``, as the lookup-only ``__new__`` is the " "one that is found; instead, use the data type directly -- e.g.::" msgstr "" -#: howto/enum.rst:1382 +#: howto/enum.rst:1389 +msgid "obj = int.__new__(cls, value)" +msgstr "" + +#: howto/enum.rst:1393 msgid "OrderedEnum" msgstr "" -#: howto/enum.rst:1384 +#: howto/enum.rst:1395 msgid "" "An ordered enumeration that is not based on :class:`IntEnum` and so " "maintains the normal :class:`Enum` invariants (such as not being comparable " "to other enumerations)::" msgstr "" -#: howto/enum.rst:1418 +#: howto/enum.rst:1399 +msgid "" +">>> class OrderedEnum(Enum):\n" +"... def __ge__(self, other):\n" +"... if self.__class__ is other.__class__:\n" +"... return self.value >= other.value\n" +"... return NotImplemented\n" +"... def __gt__(self, other):\n" +"... if self.__class__ is other.__class__:\n" +"... return self.value > other.value\n" +"... return NotImplemented\n" +"... def __le__(self, other):\n" +"... if self.__class__ is other.__class__:\n" +"... return self.value <= other.value\n" +"... return NotImplemented\n" +"... def __lt__(self, other):\n" +"... if self.__class__ is other.__class__:\n" +"... return self.value < other.value\n" +"... return NotImplemented\n" +"...\n" +">>> class Grade(OrderedEnum):\n" +"... A = 5\n" +"... B = 4\n" +"... C = 3\n" +"... D = 2\n" +"... F = 1\n" +"...\n" +">>> Grade.C < Grade.A\n" +"True" +msgstr "" + +#: howto/enum.rst:1429 msgid "DuplicateFreeEnum" msgstr "" -#: howto/enum.rst:1420 +#: howto/enum.rst:1431 msgid "" "Raises an error if a duplicate member value is found instead of creating an " "alias::" msgstr "" -#: howto/enum.rst:1445 +#: howto/enum.rst:1434 +msgid "" +">>> class DuplicateFreeEnum(Enum):\n" +"... def __init__(self, *args):\n" +"... cls = self.__class__\n" +"... if any(self.value == e.value for e in cls):\n" +"... a = self.name\n" +"... e = cls(self.value).name\n" +"... raise ValueError(\n" +"... \"aliases not allowed in DuplicateFreeEnum: %r --> " +"%r\"\n" +"... % (a, e))\n" +"...\n" +">>> class Color(DuplicateFreeEnum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 3\n" +"... GRENE = 2\n" +"...\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: aliases not allowed in DuplicateFreeEnum: 'GRENE' --> 'GREEN'" +msgstr "" + +#: howto/enum.rst:1456 msgid "" "This is a useful example for subclassing Enum to add or change other " "behaviors as well as disallowing aliases. If the only desired change is " "disallowing aliases, the :func:`unique` decorator can be used instead." msgstr "" -#: howto/enum.rst:1451 +#: howto/enum.rst:1462 msgid "Planet" msgstr "" -#: howto/enum.rst:1453 +#: howto/enum.rst:1464 msgid "" -"If :meth:`__new__` or :meth:`__init__` is defined, the value of the enum " -"member will be passed to those methods::" +"If :meth:`~object.__new__` or :meth:`~object.__init__` is defined, the value " +"of the enum member will be passed to those methods::" msgstr "" -#: howto/enum.rst:1482 +#: howto/enum.rst:1467 +msgid "" +">>> class Planet(Enum):\n" +"... MERCURY = (3.303e+23, 2.4397e6)\n" +"... VENUS = (4.869e+24, 6.0518e6)\n" +"... EARTH = (5.976e+24, 6.37814e6)\n" +"... MARS = (6.421e+23, 3.3972e6)\n" +"... JUPITER = (1.9e+27, 7.1492e7)\n" +"... SATURN = (5.688e+26, 6.0268e7)\n" +"... URANUS = (8.686e+25, 2.5559e7)\n" +"... NEPTUNE = (1.024e+26, 2.4746e7)\n" +"... def __init__(self, mass, radius):\n" +"... self.mass = mass # in kilograms\n" +"... self.radius = radius # in meters\n" +"... @property\n" +"... def surface_gravity(self):\n" +"... # universal gravitational constant (m3 kg-1 s-2)\n" +"... G = 6.67300E-11\n" +"... return G * self.mass / (self.radius * self.radius)\n" +"...\n" +">>> Planet.EARTH.value\n" +"(5.976e+24, 6378140.0)\n" +">>> Planet.EARTH.surface_gravity\n" +"9.802652743337129" +msgstr "" + +#: howto/enum.rst:1493 msgid "TimePeriod" msgstr "" -#: howto/enum.rst:1484 -msgid "An example to show the :attr:`_ignore_` attribute in use::" +#: howto/enum.rst:1495 +msgid "An example to show the :attr:`~Enum._ignore_` attribute in use::" +msgstr "" + +#: howto/enum.rst:1497 +msgid "" +">>> from datetime import timedelta\n" +">>> class Period(timedelta, Enum):\n" +"... \"different lengths of time\"\n" +"... _ignore_ = 'Period i'\n" +"... Period = vars()\n" +"... for i in range(367):\n" +"... Period['day_%d' % i] = i\n" +"...\n" +">>> list(Period)[:2]\n" +"[, ]\n" +">>> list(Period)[-2:]\n" +"[, ]" msgstr "" -#: howto/enum.rst:1503 +#: howto/enum.rst:1514 msgid "Subclassing EnumType" msgstr "" -#: howto/enum.rst:1505 +#: howto/enum.rst:1516 msgid "" "While most enum needs can be met by customizing :class:`Enum` subclasses, " "either with class decorators or custom functions, :class:`EnumType` can be " diff --git a/howto/functional.po b/howto/functional.po index a71d4ca1..af352861 100644 --- a/howto/functional.po +++ b/howto/functional.po @@ -8,15 +8,16 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: howto/functional.rst:3 +#: howto/functional.rst:5 msgid "Functional Programming HOWTO" msgstr "" @@ -24,7 +25,7 @@ msgstr "" msgid "Author" msgstr "" -#: howto/functional.rst:5 +#: howto/functional.rst:7 msgid "A. M. Kuchling" msgstr "" @@ -32,43 +33,43 @@ msgstr "" msgid "Release" msgstr "" -#: howto/functional.rst:6 +#: howto/functional.rst:8 msgid "0.32" msgstr "" -#: howto/functional.rst:8 +#: howto/functional.rst:10 msgid "" "In this document, we'll take a tour of Python's features suitable for " "implementing programs in a functional style. After an introduction to the " -"concepts of functional programming, we'll look at language features such as :" -"term:`iterator`\\s and :term:`generator`\\s and relevant library modules " +"concepts of functional programming, we'll look at language features such " +"as :term:`iterator`\\s and :term:`generator`\\s and relevant library modules " "such as :mod:`itertools` and :mod:`functools`." msgstr "" -#: howto/functional.rst:16 +#: howto/functional.rst:18 msgid "Introduction" msgstr "" -#: howto/functional.rst:18 +#: howto/functional.rst:20 msgid "" "This section explains the basic concept of functional programming; if you're " "just interested in learning about Python language features, skip to the next " "section on :ref:`functional-howto-iterators`." msgstr "" -#: howto/functional.rst:22 +#: howto/functional.rst:24 msgid "" "Programming languages support decomposing problems in several different ways:" msgstr "" -#: howto/functional.rst:24 +#: howto/functional.rst:26 msgid "" "Most programming languages are **procedural**: programs are lists of " "instructions that tell the computer what to do with the program's input. C, " "Pascal, and even Unix shells are procedural languages." msgstr "" -#: howto/functional.rst:28 +#: howto/functional.rst:30 msgid "" "In **declarative** languages, you write a specification that describes the " "problem to be solved, and the language implementation figures out how to " @@ -78,7 +79,7 @@ msgid "" "indexes, which subclauses should be performed first, etc." msgstr "" -#: howto/functional.rst:35 +#: howto/functional.rst:37 msgid "" "**Object-oriented** programs manipulate collections of objects. Objects " "have internal state and support methods that query or modify this internal " @@ -87,7 +88,7 @@ msgid "" "force the use of object-oriented features." msgstr "" -#: howto/functional.rst:41 +#: howto/functional.rst:43 msgid "" "**Functional** programming decomposes a problem into a set of functions. " "Ideally, functions only take inputs and produce outputs, and don't have any " @@ -96,7 +97,7 @@ msgid "" "other variants) and Haskell." msgstr "" -#: howto/functional.rst:47 +#: howto/functional.rst:49 msgid "" "The designers of some computer languages choose to emphasize one particular " "approach to programming. This often makes it difficult to write programs " @@ -109,7 +110,7 @@ msgid "" "functional, for example." msgstr "" -#: howto/functional.rst:58 +#: howto/functional.rst:60 msgid "" "In a functional program, input flows through a set of functions. Each " "function operates on its input and produces some output. Functional style " @@ -120,7 +121,7 @@ msgid "" "runs; every function's output must only depend on its input." msgstr "" -#: howto/functional.rst:66 +#: howto/functional.rst:68 msgid "" "Some languages are very strict about purity and don't even have assignment " "statements such as ``a=3`` or ``c = a + b``, but it's difficult to avoid all " @@ -131,7 +132,7 @@ msgid "" "for a second." msgstr "" -#: howto/functional.rst:73 +#: howto/functional.rst:75 msgid "" "Python programs written in functional style usually won't go to the extreme " "of avoiding all I/O or all assignments; instead, they'll provide a " @@ -141,7 +142,7 @@ msgid "" "other side effects." msgstr "" -#: howto/functional.rst:79 +#: howto/functional.rst:81 msgid "" "Functional programming can be considered the opposite of object-oriented " "programming. Objects are little capsules containing some internal state " @@ -153,40 +154,40 @@ msgid "" "objects in your application (e-mail messages, transactions, etc.)." msgstr "" -#: howto/functional.rst:88 +#: howto/functional.rst:90 msgid "" "Functional design may seem like an odd constraint to work under. Why should " "you avoid objects and side effects? There are theoretical and practical " "advantages to the functional style:" msgstr "" -#: howto/functional.rst:92 +#: howto/functional.rst:94 msgid "Formal provability." msgstr "" -#: howto/functional.rst:93 +#: howto/functional.rst:95 msgid "Modularity." msgstr "" -#: howto/functional.rst:94 +#: howto/functional.rst:96 msgid "Composability." msgstr "" -#: howto/functional.rst:95 +#: howto/functional.rst:97 msgid "Ease of debugging and testing." msgstr "" -#: howto/functional.rst:99 +#: howto/functional.rst:101 msgid "Formal provability" msgstr "" -#: howto/functional.rst:101 +#: howto/functional.rst:103 msgid "" "A theoretical benefit is that it's easier to construct a mathematical proof " "that a functional program is correct." msgstr "" -#: howto/functional.rst:104 +#: howto/functional.rst:106 msgid "" "For a long time researchers have been interested in finding ways to " "mathematically prove programs correct. This is different from testing a " @@ -196,7 +197,7 @@ msgid "" "the right result for all possible inputs." msgstr "" -#: howto/functional.rst:111 +#: howto/functional.rst:113 msgid "" "The technique used to prove programs correct is to write down " "**invariants**, properties of the input data and of the program's variables " @@ -207,7 +208,7 @@ msgid "" "invariants should match the desired conditions on the program's output." msgstr "" -#: howto/functional.rst:119 +#: howto/functional.rst:121 msgid "" "Functional programming's avoidance of assignments arose because assignments " "are difficult to handle with this technique; assignments can break " @@ -215,7 +216,7 @@ msgid "" "invariants that can be propagated onward." msgstr "" -#: howto/functional.rst:124 +#: howto/functional.rst:126 msgid "" "Unfortunately, proving programs correct is largely impractical and not " "relevant to Python software. Even trivial programs require proofs that are " @@ -227,11 +228,11 @@ msgid "" "wrongly believe you've proved the program correct." msgstr "" -#: howto/functional.rst:135 +#: howto/functional.rst:137 msgid "Modularity" msgstr "" -#: howto/functional.rst:137 +#: howto/functional.rst:139 msgid "" "A more practical benefit of functional programming is that it forces you to " "break apart your problem into small pieces. Programs are more modular as a " @@ -240,15 +241,15 @@ msgid "" "Small functions are also easier to read and to check for errors." msgstr "" -#: howto/functional.rst:145 +#: howto/functional.rst:147 msgid "Ease of debugging and testing" msgstr "" -#: howto/functional.rst:147 +#: howto/functional.rst:149 msgid "Testing and debugging a functional-style program is easier." msgstr "" -#: howto/functional.rst:149 +#: howto/functional.rst:151 msgid "" "Debugging is simplified because functions are generally small and clearly " "specified. When a program doesn't work, each function is an interface point " @@ -257,7 +258,7 @@ msgid "" "responsible for a bug." msgstr "" -#: howto/functional.rst:154 +#: howto/functional.rst:156 msgid "" "Testing is easier because each function is a potential subject for a unit " "test. Functions don't depend on system state that needs to be replicated " @@ -265,11 +266,11 @@ msgid "" "and then check that the output matches expectations." msgstr "" -#: howto/functional.rst:161 +#: howto/functional.rst:163 msgid "Composability" msgstr "" -#: howto/functional.rst:163 +#: howto/functional.rst:165 msgid "" "As you work on a functional-style program, you'll write a number of " "functions with varying inputs and outputs. Some of these functions will be " @@ -280,24 +281,24 @@ msgid "" "different situations." msgstr "" -#: howto/functional.rst:170 +#: howto/functional.rst:172 msgid "" "Over time you'll form a personal library of utilities. Often you'll " "assemble new programs by arranging existing functions in a new configuration " "and writing a few functions specialized for the current task." msgstr "" -#: howto/functional.rst:178 +#: howto/functional.rst:180 msgid "Iterators" msgstr "" -#: howto/functional.rst:180 +#: howto/functional.rst:182 msgid "" "I'll start by looking at a Python language feature that's an important " "foundation for writing functional-style programs: iterators." msgstr "" -#: howto/functional.rst:183 +#: howto/functional.rst:185 msgid "" "An iterator is an object representing a stream of data; this object returns " "the data one element at a time. A Python iterator must support a method " @@ -308,7 +309,7 @@ msgid "" "reasonable to write an iterator that produces an infinite stream of data." msgstr "" -#: howto/functional.rst:191 +#: howto/functional.rst:193 msgid "" "The built-in :func:`iter` function takes an arbitrary object and tries to " "return an iterator that will return the object's contents or elements, " @@ -318,11 +319,11 @@ msgid "" "an iterator for it." msgstr "" -#: howto/functional.rst:198 +#: howto/functional.rst:200 msgid "You can experiment with the iteration interface manually:" msgstr "" -#: howto/functional.rst:216 +#: howto/functional.rst:218 msgid "" "Python expects iterable objects in several different contexts, the most " "important being the :keyword:`for` statement. In the statement ``for X in " @@ -330,30 +331,40 @@ msgid "" "an iterator. These two statements are equivalent::" msgstr "" -#: howto/functional.rst:228 +#: howto/functional.rst:224 +msgid "" +"for i in iter(obj):\n" +" print(i)\n" +"\n" +"for i in obj:\n" +" print(i)" +msgstr "" + +#: howto/functional.rst:230 msgid "" "Iterators can be materialized as lists or tuples by using the :func:`list` " "or :func:`tuple` constructor functions:" msgstr "" -#: howto/functional.rst:237 +#: howto/functional.rst:239 msgid "" "Sequence unpacking also supports iterators: if you know an iterator will " "return N elements, you can unpack them into an N-tuple:" msgstr "" -#: howto/functional.rst:246 +#: howto/functional.rst:248 msgid "" "Built-in functions such as :func:`max` and :func:`min` can take a single " "iterator argument and will return the largest or smallest element. The " "``\"in\"`` and ``\"not in\"`` operators also support iterators: ``X in " "iterator`` is true if X is found in the stream returned by the iterator. " -"You'll run into obvious problems if the iterator is infinite; :func:`max`, :" -"func:`min` will never return, and if the element X never appears in the " -"stream, the ``\"in\"`` and ``\"not in\"`` operators won't return either." +"You'll run into obvious problems if the iterator is " +"infinite; :func:`max`, :func:`min` will never return, and if the element X " +"never appears in the stream, the ``\"in\"`` and ``\"not in\"`` operators " +"won't return either." msgstr "" -#: howto/functional.rst:254 +#: howto/functional.rst:256 msgid "" "Note that you can only go forward in an iterator; there's no way to get the " "previous element, reset the iterator, or make a copy of it. Iterator " @@ -364,62 +375,103 @@ msgid "" "new iterator." msgstr "" -#: howto/functional.rst:264 +#: howto/functional.rst:266 msgid "Data Types That Support Iterators" msgstr "" -#: howto/functional.rst:266 +#: howto/functional.rst:268 msgid "" "We've already seen how lists and tuples support iterators. In fact, any " "Python sequence type, such as strings, will automatically support creation " "of an iterator." msgstr "" -#: howto/functional.rst:270 +#: howto/functional.rst:272 msgid "" "Calling :func:`iter` on a dictionary returns an iterator that will loop over " "the dictionary's keys::" msgstr "" -#: howto/functional.rst:290 +#: howto/functional.rst:275 +msgid "" +">>> m = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6,\n" +"... 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}\n" +">>> for key in m:\n" +"... print(key, m[key])\n" +"Jan 1\n" +"Feb 2\n" +"Mar 3\n" +"Apr 4\n" +"May 5\n" +"Jun 6\n" +"Jul 7\n" +"Aug 8\n" +"Sep 9\n" +"Oct 10\n" +"Nov 11\n" +"Dec 12" +msgstr "" + +#: howto/functional.rst:292 msgid "" "Note that starting with Python 3.7, dictionary iteration order is guaranteed " "to be the same as the insertion order. In earlier versions, the behaviour " "was unspecified and could vary between implementations." msgstr "" -#: howto/functional.rst:294 +#: howto/functional.rst:296 msgid "" "Applying :func:`iter` to a dictionary always loops over the keys, but " "dictionaries have methods that return other iterators. If you want to " -"iterate over values or key/value pairs, you can explicitly call the :meth:" -"`~dict.values` or :meth:`~dict.items` methods to get an appropriate iterator." +"iterate over values or key/value pairs, you can explicitly call " +"the :meth:`~dict.values` or :meth:`~dict.items` methods to get an " +"appropriate iterator." msgstr "" -#: howto/functional.rst:300 +#: howto/functional.rst:302 msgid "" "The :func:`dict` constructor can accept an iterator that returns a finite " "stream of ``(key, value)`` tuples:" msgstr "" -#: howto/functional.rst:307 +#: howto/functional.rst:309 msgid "" "Files also support iteration by calling the :meth:`~io.TextIOBase.readline` " "method until there are no more lines in the file. This means you can read " "each line of a file like this::" msgstr "" -#: howto/functional.rst:315 +#: howto/functional.rst:313 +msgid "" +"for line in file:\n" +" # do something for each line\n" +" ..." +msgstr "" + +#: howto/functional.rst:317 msgid "" "Sets can take their contents from an iterable and let you iterate over the " "set's elements::" msgstr "" -#: howto/functional.rst:331 -msgid "Generator expressions and list comprehensions" +#: howto/functional.rst:320 +msgid "" +">>> S = {2, 3, 5, 7, 11, 13}\n" +">>> for i in S:\n" +"... print(i)\n" +"2\n" +"3\n" +"5\n" +"7\n" +"11\n" +"13" msgstr "" #: howto/functional.rst:333 +msgid "Generator expressions and list comprehensions" +msgstr "" + +#: howto/functional.rst:335 msgid "" "Two common operations on an iterator's output are 1) performing some " "operation for every element, 2) selecting a subset of elements that meet " @@ -428,7 +480,7 @@ msgid "" "containing a given substring." msgstr "" -#: howto/functional.rst:339 +#: howto/functional.rst:341 msgid "" "List comprehensions and generator expressions (short form: \"listcomps\" and " "\"genexps\") are a concise notation for such operations, borrowed from the " @@ -436,12 +488,29 @@ msgid "" "strip all the whitespace from a stream of strings with the following code::" msgstr "" -#: howto/functional.rst:352 +#: howto/functional.rst:346 +msgid "" +">>> line_list = [' line 1\\n', 'line 2 \\n', ' \\n', '']\n" +"\n" +">>> # Generator expression -- returns iterator\n" +">>> stripped_iter = (line.strip() for line in line_list)\n" +"\n" +">>> # List comprehension -- returns list\n" +">>> stripped_list = [line.strip() for line in line_list]" +msgstr "" + +#: howto/functional.rst:354 msgid "" "You can select only certain elements by adding an ``\"if\"`` condition::" msgstr "" -#: howto/functional.rst:357 +#: howto/functional.rst:356 +msgid "" +">>> stripped_list = [line.strip() for line in line_list\n" +"... if line != \"\"]" +msgstr "" + +#: howto/functional.rst:359 msgid "" "With a list comprehension, you get back a Python list; ``stripped_list`` is " "a list containing the resulting lines, not an iterator. Generator " @@ -452,20 +521,33 @@ msgid "" "preferable in these situations." msgstr "" -#: howto/functional.rst:364 +#: howto/functional.rst:366 msgid "" "Generator expressions are surrounded by parentheses (\"()\") and list " "comprehensions are surrounded by square brackets (\"[]\"). Generator " "expressions have the form::" msgstr "" -#: howto/functional.rst:378 +#: howto/functional.rst:370 +msgid "" +"( expression for expr in sequence1\n" +" if condition1\n" +" for expr2 in sequence2\n" +" if condition2\n" +" for expr3 in sequence3\n" +" ...\n" +" if condition3\n" +" for exprN in sequenceN\n" +" if conditionN )" +msgstr "" + +#: howto/functional.rst:380 msgid "" "Again, for a list comprehension only the outside brackets are different " "(square brackets instead of parentheses)." msgstr "" -#: howto/functional.rst:381 +#: howto/functional.rst:383 msgid "" "The elements of the generated output will be the successive values of " "``expression``. The ``if`` clauses are all optional; if present, " @@ -473,7 +555,7 @@ msgid "" "is true." msgstr "" -#: howto/functional.rst:385 +#: howto/functional.rst:387 msgid "" "Generator expressions always have to be written inside parentheses, but the " "parentheses signalling a function call also count. If you want to create an " @@ -481,6 +563,10 @@ msgid "" msgstr "" #: howto/functional.rst:391 +msgid "obj_total = sum(obj.count for obj in list_all_objects())" +msgstr "" + +#: howto/functional.rst:393 msgid "" "The ``for...in`` clauses contain the sequences to be iterated over. The " "sequences do not have to be the same length, because they are iterated over " @@ -490,13 +576,30 @@ msgid "" "``sequence2``." msgstr "" -#: howto/functional.rst:397 +#: howto/functional.rst:399 msgid "" "To put it another way, a list comprehension or generator expression is " "equivalent to the following Python code::" msgstr "" -#: howto/functional.rst:414 +#: howto/functional.rst:402 +msgid "" +"for expr1 in sequence1:\n" +" if not (condition1):\n" +" continue # Skip this element\n" +" for expr2 in sequence2:\n" +" if not (condition2):\n" +" continue # Skip this element\n" +" ...\n" +" for exprN in sequenceN:\n" +" if not (conditionN):\n" +" continue # Skip this element\n" +"\n" +" # Output the value of\n" +" # the expression." +msgstr "" + +#: howto/functional.rst:416 msgid "" "This means that when there are multiple ``for...in`` clauses but no ``if`` " "clauses, the length of the resulting output will be equal to the product of " @@ -504,25 +607,33 @@ msgid "" "output list is 9 elements long:" msgstr "" -#: howto/functional.rst:426 +#: howto/functional.rst:428 msgid "" "To avoid introducing an ambiguity into Python's grammar, if ``expression`` " "is creating a tuple, it must be surrounded with parentheses. The first list " "comprehension below is a syntax error, while the second one is correct::" msgstr "" -#: howto/functional.rst:437 -msgid "Generators" +#: howto/functional.rst:432 +msgid "" +"# Syntax error\n" +"[x, y for x in seq1 for y in seq2]\n" +"# Correct\n" +"[(x, y) for x in seq1 for y in seq2]" msgstr "" #: howto/functional.rst:439 +msgid "Generators" +msgstr "" + +#: howto/functional.rst:441 msgid "" "Generators are a special class of functions that simplify the task of " "writing iterators. Regular functions compute a value and return it, but " "generators return an iterator that returns a stream of values." msgstr "" -#: howto/functional.rst:443 +#: howto/functional.rst:445 msgid "" "You're doubtless familiar with how regular function calls work in Python or " "C. When you call a function, it gets a private namespace where its local " @@ -535,18 +646,18 @@ msgid "" "thought of as resumable functions." msgstr "" -#: howto/functional.rst:452 +#: howto/functional.rst:454 msgid "Here's the simplest example of a generator function:" msgstr "" -#: howto/functional.rst:458 +#: howto/functional.rst:460 msgid "" "Any function containing a :keyword:`yield` keyword is a generator function; " "this is detected by Python's :term:`bytecode` compiler which compiles the " "function specially as a result." msgstr "" -#: howto/functional.rst:462 +#: howto/functional.rst:464 msgid "" "When you call a generator function, it doesn't return a single value; " "instead it returns a generator object that supports the iterator protocol. " @@ -558,17 +669,17 @@ msgid "" "method, the function will resume executing." msgstr "" -#: howto/functional.rst:471 +#: howto/functional.rst:473 msgid "Here's a sample usage of the ``generate_ints()`` generator:" msgstr "" -#: howto/functional.rst:488 +#: howto/functional.rst:490 msgid "" "You could equally write ``for i in generate_ints(5)``, or ``a, b, c = " "generate_ints(3)``." msgstr "" -#: howto/functional.rst:491 +#: howto/functional.rst:493 msgid "" "Inside a generator function, ``return value`` causes " "``StopIteration(value)`` to be raised from the :meth:`~generator.__next__` " @@ -576,7 +687,7 @@ msgid "" "procession of values ends and the generator cannot yield any further values." msgstr "" -#: howto/functional.rst:496 +#: howto/functional.rst:498 msgid "" "You could achieve the effect of generators manually by writing your own " "class and storing all the local variables of the generator as instance " @@ -586,7 +697,7 @@ msgid "" "complicated generator, writing a corresponding class can be much messier." msgstr "" -#: howto/functional.rst:504 +#: howto/functional.rst:506 msgid "" "The test suite included with Python's library, :source:`Lib/test/" "test_generators.py`, contains a number of more interesting examples. Here's " @@ -594,7 +705,21 @@ msgid "" "generators recursively. ::" msgstr "" -#: howto/functional.rst:520 +#: howto/functional.rst:511 +msgid "" +"# A recursive generator that generates Tree leaves in in-order.\n" +"def inorder(t):\n" +" if t:\n" +" for x in inorder(t.left):\n" +" yield x\n" +"\n" +" yield t.label\n" +"\n" +" for x in inorder(t.right):\n" +" yield x" +msgstr "" + +#: howto/functional.rst:522 msgid "" "Two other examples in ``test_generators.py`` produce solutions for the N-" "Queens problem (placing N queens on an NxN chess board so that no queen " @@ -603,11 +728,11 @@ msgid "" "twice)." msgstr "" -#: howto/functional.rst:528 +#: howto/functional.rst:530 msgid "Passing values into a generator" msgstr "" -#: howto/functional.rst:530 +#: howto/functional.rst:532 msgid "" "In Python 2.4 and earlier, generators only produced output. Once a " "generator's code was invoked to create an iterator, there was no way to pass " @@ -617,14 +742,18 @@ msgid "" "these approaches are messy." msgstr "" -#: howto/functional.rst:537 +#: howto/functional.rst:539 msgid "" -"In Python 2.5 there's a simple way to pass values into a generator. :keyword:" -"`yield` became an expression, returning a value that can be assigned to a " -"variable or otherwise operated on::" +"In Python 2.5 there's a simple way to pass values into a " +"generator. :keyword:`yield` became an expression, returning a value that can " +"be assigned to a variable or otherwise operated on::" msgstr "" #: howto/functional.rst:543 +msgid "val = (yield i)" +msgstr "" + +#: howto/functional.rst:545 msgid "" "I recommend that you **always** put parentheses around a ``yield`` " "expression when you're doing something with the returned value, as in the " @@ -632,7 +761,7 @@ msgid "" "always add them instead of having to remember when they're needed." msgstr "" -#: howto/functional.rst:548 +#: howto/functional.rst:550 msgid "" "(:pep:`342` explains the exact rules, which are that a ``yield``-expression " "must always be parenthesized except when it occurs at the top-level " @@ -641,25 +770,39 @@ msgid "" "operation, as in ``val = (yield i) + 12``.)" msgstr "" -#: howto/functional.rst:554 +#: howto/functional.rst:556 msgid "" "Values are sent into a generator by calling its :meth:`send(value) " "` method. This method resumes the generator's code and the " -"``yield`` expression returns the specified value. If the regular :meth:" -"`~generator.__next__` method is called, the ``yield`` returns ``None``." +"``yield`` expression returns the specified value. If the " +"regular :meth:`~generator.__next__` method is called, the ``yield`` returns " +"``None``." msgstr "" -#: howto/functional.rst:559 +#: howto/functional.rst:561 msgid "" "Here's a simple counter that increments by 1 and allows changing the value " "of the internal counter." msgstr "" -#: howto/functional.rst:574 +#: howto/functional.rst:564 +msgid "" +"def counter(maximum):\n" +" i = 0\n" +" while i < maximum:\n" +" val = (yield i)\n" +" # If value provided, change counter\n" +" if val is not None:\n" +" i = val\n" +" else:\n" +" i += 1" +msgstr "" + +#: howto/functional.rst:576 msgid "And here's an example of changing the counter:" msgstr "" -#: howto/functional.rst:591 +#: howto/functional.rst:593 msgid "" "Because ``yield`` will often be returning ``None``, you should always check " "for this case. Don't just use its value in expressions unless you're sure " @@ -667,44 +810,44 @@ msgid "" "resume your generator function." msgstr "" -#: howto/functional.rst:596 +#: howto/functional.rst:598 msgid "" "In addition to :meth:`~generator.send`, there are two other methods on " "generators:" msgstr "" -#: howto/functional.rst:599 +#: howto/functional.rst:601 msgid "" ":meth:`throw(value) ` is used to raise an exception inside " "the generator; the exception is raised by the ``yield`` expression where the " "generator's execution is paused." msgstr "" -#: howto/functional.rst:603 +#: howto/functional.rst:605 msgid "" ":meth:`~generator.close` raises a :exc:`GeneratorExit` exception inside the " "generator to terminate the iteration. On receiving this exception, the " -"generator's code must either raise :exc:`GeneratorExit` or :exc:" -"`StopIteration`; catching the exception and doing anything else is illegal " -"and will trigger a :exc:`RuntimeError`. :meth:`~generator.close` will also " -"be called by Python's garbage collector when the generator is garbage-" -"collected." +"generator's code must either raise :exc:`GeneratorExit` " +"or :exc:`StopIteration`; catching the exception and doing anything else is " +"illegal and will trigger a :exc:`RuntimeError`. :meth:`~generator.close` " +"will also be called by Python's garbage collector when the generator is " +"garbage-collected." msgstr "" -#: howto/functional.rst:611 +#: howto/functional.rst:613 msgid "" "If you need to run cleanup code when a :exc:`GeneratorExit` occurs, I " -"suggest using a ``try: ... finally:`` suite instead of catching :exc:" -"`GeneratorExit`." +"suggest using a ``try: ... finally:`` suite instead of " +"catching :exc:`GeneratorExit`." msgstr "" -#: howto/functional.rst:614 +#: howto/functional.rst:616 msgid "" "The cumulative effect of these changes is to turn generators from one-way " "producers of information into both producers and consumers." msgstr "" -#: howto/functional.rst:617 +#: howto/functional.rst:619 msgid "" "Generators also become **coroutines**, a more generalized form of " "subroutines. Subroutines are entered at one point and exited at another " @@ -713,36 +856,36 @@ msgid "" "statements)." msgstr "" -#: howto/functional.rst:624 +#: howto/functional.rst:626 msgid "Built-in functions" msgstr "" -#: howto/functional.rst:626 +#: howto/functional.rst:628 msgid "" "Let's look in more detail at built-in functions often used with iterators." msgstr "" -#: howto/functional.rst:628 +#: howto/functional.rst:630 msgid "" "Two of Python's built-in functions, :func:`map` and :func:`filter` duplicate " "the features of generator expressions:" msgstr "" -#: howto/functional.rst:640 +#: howto/functional.rst:633 msgid "" ":func:`map(f, iterA, iterB, ...) ` returns an iterator over the sequence" msgstr "" -#: howto/functional.rst:632 +#: howto/functional.rst:634 msgid "" "``f(iterA[0], iterB[0]), f(iterA[1], iterB[1]), f(iterA[2], iterB[2]), ...``." msgstr "" -#: howto/functional.rst:642 +#: howto/functional.rst:644 msgid "You can of course achieve the same effect with a list comprehension." msgstr "" -#: howto/functional.rst:644 +#: howto/functional.rst:646 msgid "" ":func:`filter(predicate, iter) ` returns an iterator over all the " "sequence elements that meet a certain condition, and is similarly duplicated " @@ -751,24 +894,41 @@ msgid "" "must take a single value." msgstr "" -#: howto/functional.rst:657 +#: howto/functional.rst:659 msgid "This can also be written as a list comprehension:" msgstr "" -#: howto/functional.rst:663 +#: howto/functional.rst:665 msgid "" ":func:`enumerate(iter, start=0) ` counts off the elements in the " "iterable returning 2-tuples containing the count (from *start*) and each " "element. ::" msgstr "" -#: howto/functional.rst:673 +#: howto/functional.rst:669 +msgid "" +">>> for item in enumerate(['subject', 'verb', 'object']):\n" +"... print(item)\n" +"(0, 'subject')\n" +"(1, 'verb')\n" +"(2, 'object')" +msgstr "" + +#: howto/functional.rst:675 msgid "" ":func:`enumerate` is often used when looping through a list and recording " "the indexes at which certain conditions are met::" msgstr "" -#: howto/functional.rst:681 +#: howto/functional.rst:678 +msgid "" +"f = open('data.txt', 'r')\n" +"for i, line in enumerate(f):\n" +" if line.strip() == '':\n" +" print('Blank line at line #%i' % i)" +msgstr "" + +#: howto/functional.rst:683 msgid "" ":func:`sorted(iterable, key=None, reverse=False) ` collects all the " "elements of the iterable into a list, sorts the list, and returns the sorted " @@ -776,12 +936,25 @@ msgid "" "constructed list's :meth:`~list.sort` method. ::" msgstr "" -#: howto/functional.rst:696 +#: howto/functional.rst:688 +msgid "" +">>> import random\n" +">>> # Generate 8 random numbers between [0, 10000)\n" +">>> rand_list = random.sample(range(10000), 8)\n" +">>> rand_list \n" +"[769, 7953, 9828, 6431, 8442, 9878, 6213, 2207]\n" +">>> sorted(rand_list) \n" +"[769, 2207, 6213, 6431, 7953, 8442, 9828, 9878]\n" +">>> sorted(rand_list, reverse=True) \n" +"[9878, 9828, 8442, 7953, 6431, 6213, 2207, 769]" +msgstr "" + +#: howto/functional.rst:698 msgid "" "(For a more detailed discussion of sorting, see the :ref:`sortinghowto`.)" msgstr "" -#: howto/functional.rst:699 +#: howto/functional.rst:701 msgid "" "The :func:`any(iter) ` and :func:`all(iter) ` built-ins look at " "the truth values of an iterable's contents. :func:`any` returns ``True`` if " @@ -789,13 +962,19 @@ msgid "" "``True`` if all of the elements are true values:" msgstr "" -#: howto/functional.rst:718 +#: howto/functional.rst:720 msgid "" ":func:`zip(iterA, iterB, ...) ` takes one element from each iterable " "and returns them in a tuple::" msgstr "" -#: howto/functional.rst:724 +#: howto/functional.rst:723 +msgid "" +"zip(['a', 'b', 'c'], (1, 2, 3)) =>\n" +" ('a', 1), ('b', 2), ('c', 3)" +msgstr "" + +#: howto/functional.rst:726 msgid "" "It doesn't construct an in-memory list and exhaust all the input iterators " "before returning; instead tuples are constructed and returned only if " @@ -803,56 +982,62 @@ msgid "" "evaluation `__.)" msgstr "" -#: howto/functional.rst:729 +#: howto/functional.rst:731 msgid "" "This iterator is intended to be used with iterables that are all of the same " "length. If the iterables are of different lengths, the resulting stream " "will be the same length as the shortest iterable. ::" msgstr "" -#: howto/functional.rst:736 +#: howto/functional.rst:735 +msgid "" +"zip(['a', 'b'], (1, 2, 3)) =>\n" +" ('a', 1), ('b', 2)" +msgstr "" + +#: howto/functional.rst:738 msgid "" "You should avoid doing this, though, because an element may be taken from " "the longer iterators and discarded. This means you can't go on to use the " "iterators further because you risk skipping a discarded element." msgstr "" -#: howto/functional.rst:742 +#: howto/functional.rst:744 msgid "The itertools module" msgstr "" -#: howto/functional.rst:744 +#: howto/functional.rst:746 msgid "" "The :mod:`itertools` module contains a number of commonly used iterators as " "well as functions for combining several iterators. This section will " "introduce the module's contents by showing small examples." msgstr "" -#: howto/functional.rst:748 +#: howto/functional.rst:750 msgid "The module's functions fall into a few broad classes:" msgstr "" -#: howto/functional.rst:750 +#: howto/functional.rst:752 msgid "Functions that create a new iterator based on an existing iterator." msgstr "" -#: howto/functional.rst:751 +#: howto/functional.rst:753 msgid "Functions for treating an iterator's elements as function arguments." msgstr "" -#: howto/functional.rst:752 +#: howto/functional.rst:754 msgid "Functions for selecting portions of an iterator's output." msgstr "" -#: howto/functional.rst:753 +#: howto/functional.rst:755 msgid "A function for grouping an iterator's output." msgstr "" -#: howto/functional.rst:756 +#: howto/functional.rst:758 msgid "Creating new iterators" msgstr "" -#: howto/functional.rst:758 +#: howto/functional.rst:760 msgid "" ":func:`itertools.count(start, step) ` returns an infinite " "stream of evenly spaced values. You can optionally supply the starting " @@ -860,7 +1045,17 @@ msgid "" "defaults to 1::" msgstr "" -#: howto/functional.rst:769 +#: howto/functional.rst:764 +msgid "" +"itertools.count() =>\n" +" 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...\n" +"itertools.count(10) =>\n" +" 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...\n" +"itertools.count(10, 5) =>\n" +" 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, ..." +msgstr "" + +#: howto/functional.rst:771 msgid "" ":func:`itertools.cycle(iter) ` saves a copy of the contents " "of a provided iterable and returns a new iterator that returns its elements " @@ -868,14 +1063,28 @@ msgid "" "infinitely. ::" msgstr "" -#: howto/functional.rst:776 +#: howto/functional.rst:775 +msgid "" +"itertools.cycle([1, 2, 3, 4, 5]) =>\n" +" 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ..." +msgstr "" + +#: howto/functional.rst:778 msgid "" ":func:`itertools.repeat(elem, [n]) ` returns the provided " "element *n* times, or returns the element endlessly if *n* is not " "provided. ::" msgstr "" -#: howto/functional.rst:784 +#: howto/functional.rst:781 +msgid "" +"itertools.repeat('abc') =>\n" +" abc, abc, abc, abc, abc, abc, abc, abc, abc, abc, ...\n" +"itertools.repeat('abc', 5) =>\n" +" abc, abc, abc, abc, abc" +msgstr "" + +#: howto/functional.rst:786 msgid "" ":func:`itertools.chain(iterA, iterB, ...) ` takes an " "arbitrary number of iterables as input, and returns all the elements of the " @@ -883,7 +1092,13 @@ msgid "" "the iterables have been exhausted. ::" msgstr "" -#: howto/functional.rst:792 +#: howto/functional.rst:791 +msgid "" +"itertools.chain(['a', 'b', 'c'], (1, 2, 3)) =>\n" +" a, b, c, 1, 2, 3" +msgstr "" + +#: howto/functional.rst:794 msgid "" ":func:`itertools.islice(iter, [start], stop, [step]) ` " "returns a stream that's a slice of the iterator. With a single *stop* " @@ -894,7 +1109,17 @@ msgid "" "*step*. ::" msgstr "" -#: howto/functional.rst:806 +#: howto/functional.rst:801 +msgid "" +"itertools.islice(range(10), 8) =>\n" +" 0, 1, 2, 3, 4, 5, 6, 7\n" +"itertools.islice(range(10), 2, 8) =>\n" +" 2, 3, 4, 5, 6, 7\n" +"itertools.islice(range(10), 2, 8, 2) =>\n" +" 2, 4, 6" +msgstr "" + +#: howto/functional.rst:808 msgid "" ":func:`itertools.tee(iter, [n]) ` replicates an iterator; it " "returns *n* independent iterators that will all return the contents of the " @@ -904,58 +1129,107 @@ msgid "" "and one of the new iterators is consumed more than the others. ::" msgstr "" -#: howto/functional.rst:825 -msgid "Calling functions on elements" +#: howto/functional.rst:816 +msgid "" +"itertools.tee( itertools.count() ) =>\n" +" iterA, iterB\n" +"\n" +"where iterA ->\n" +" 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...\n" +"\n" +"and iterB ->\n" +" 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ..." msgstr "" #: howto/functional.rst:827 +msgid "Calling functions on elements" +msgstr "" + +#: howto/functional.rst:829 msgid "" "The :mod:`operator` module contains a set of functions corresponding to " -"Python's operators. Some examples are :func:`operator.add(a, b) ` (adds two values), :func:`operator.ne(a, b) ` (same as " -"``a != b``), and :func:`operator.attrgetter('id') ` " -"(returns a callable that fetches the ``.id`` attribute)." +"Python's operators. Some examples are :func:`operator.add(a, b) " +"` (adds two values), :func:`operator.ne(a, b) ` " +"(same as ``a != b``), and :func:`operator.attrgetter('id') " +"` (returns a callable that fetches the ``.id`` " +"attribute)." msgstr "" -#: howto/functional.rst:833 +#: howto/functional.rst:835 msgid "" ":func:`itertools.starmap(func, iter) ` assumes that the " "iterable will return a stream of tuples, and calls *func* using these tuples " "as the arguments::" msgstr "" -#: howto/functional.rst:845 -msgid "Selecting elements" +#: howto/functional.rst:839 +msgid "" +"itertools.starmap(os.path.join,\n" +" [('/bin', 'python'), ('/usr', 'bin', 'java'),\n" +" ('/usr', 'bin', 'perl'), ('/usr', 'bin', 'ruby')])\n" +"=>\n" +" /bin/python, /usr/bin/java, /usr/bin/perl, /usr/bin/ruby" msgstr "" #: howto/functional.rst:847 +msgid "Selecting elements" +msgstr "" + +#: howto/functional.rst:849 msgid "" "Another group of functions chooses a subset of an iterator's elements based " "on a predicate." msgstr "" -#: howto/functional.rst:850 +#: howto/functional.rst:852 msgid "" ":func:`itertools.filterfalse(predicate, iter) ` is " "the opposite of :func:`filter`, returning all elements for which the " "predicate returns false::" msgstr "" -#: howto/functional.rst:857 +#: howto/functional.rst:856 +msgid "" +"itertools.filterfalse(is_even, itertools.count()) =>\n" +" 1, 3, 5, 7, 9, 11, 13, 15, ..." +msgstr "" + +#: howto/functional.rst:859 msgid "" ":func:`itertools.takewhile(predicate, iter) ` returns " "elements for as long as the predicate returns true. Once the predicate " "returns false, the iterator will signal the end of its results. ::" msgstr "" -#: howto/functional.rst:870 +#: howto/functional.rst:863 +msgid "" +"def less_than_10(x):\n" +" return x < 10\n" +"\n" +"itertools.takewhile(less_than_10, itertools.count()) =>\n" +" 0, 1, 2, 3, 4, 5, 6, 7, 8, 9\n" +"\n" +"itertools.takewhile(is_even, itertools.count()) =>\n" +" 0" +msgstr "" + +#: howto/functional.rst:872 msgid "" ":func:`itertools.dropwhile(predicate, iter) ` discards " "elements while the predicate returns true, and then returns the rest of the " "iterable's results. ::" msgstr "" -#: howto/functional.rst:880 +#: howto/functional.rst:876 +msgid "" +"itertools.dropwhile(less_than_10, itertools.count()) =>\n" +" 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...\n" +"\n" +"itertools.dropwhile(is_even, itertools.count()) =>\n" +" 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ..." +msgstr "" + +#: howto/functional.rst:882 msgid "" ":func:`itertools.compress(data, selectors) ` takes two " "iterators and returns only those elements of *data* for which the " @@ -963,58 +1237,111 @@ msgid "" "is exhausted::" msgstr "" -#: howto/functional.rst:889 -msgid "Combinatoric functions" +#: howto/functional.rst:886 +msgid "" +"itertools.compress([1, 2, 3, 4, 5], [True, True, False, False, True]) =>\n" +" 1, 2, 5" msgstr "" #: howto/functional.rst:891 +msgid "Combinatoric functions" +msgstr "" + +#: howto/functional.rst:893 msgid "" "The :func:`itertools.combinations(iterable, r) ` " "returns an iterator giving all possible *r*-tuple combinations of the " "elements contained in *iterable*. ::" msgstr "" -#: howto/functional.rst:906 +#: howto/functional.rst:897 +msgid "" +"itertools.combinations([1, 2, 3, 4, 5], 2) =>\n" +" (1, 2), (1, 3), (1, 4), (1, 5),\n" +" (2, 3), (2, 4), (2, 5),\n" +" (3, 4), (3, 5),\n" +" (4, 5)\n" +"\n" +"itertools.combinations([1, 2, 3, 4, 5], 3) =>\n" +" (1, 2, 3), (1, 2, 4), (1, 2, 5), (1, 3, 4), (1, 3, 5), (1, 4, 5),\n" +" (2, 3, 4), (2, 3, 5), (2, 4, 5),\n" +" (3, 4, 5)" +msgstr "" + +#: howto/functional.rst:908 msgid "" "The elements within each tuple remain in the same order as *iterable* " "returned them. For example, the number 1 is always before 2, 3, 4, or 5 in " -"the examples above. A similar function, :func:`itertools." -"permutations(iterable, r=None) `, removes this " -"constraint on the order, returning all possible arrangements of length *r*::" +"the examples above. A similar " +"function, :func:`itertools.permutations(iterable, r=None) " +"`, removes this constraint on the order, returning " +"all possible arrangements of length *r*::" +msgstr "" + +#: howto/functional.rst:915 +msgid "" +"itertools.permutations([1, 2, 3, 4, 5], 2) =>\n" +" (1, 2), (1, 3), (1, 4), (1, 5),\n" +" (2, 1), (2, 3), (2, 4), (2, 5),\n" +" (3, 1), (3, 2), (3, 4), (3, 5),\n" +" (4, 1), (4, 2), (4, 3), (4, 5),\n" +" (5, 1), (5, 2), (5, 3), (5, 4)\n" +"\n" +"itertools.permutations([1, 2, 3, 4, 5]) =>\n" +" (1, 2, 3, 4, 5), (1, 2, 3, 5, 4), (1, 2, 4, 3, 5),\n" +" ...\n" +" (5, 4, 3, 2, 1)" msgstr "" -#: howto/functional.rst:925 +#: howto/functional.rst:927 msgid "" "If you don't supply a value for *r* the length of the iterable is used, " "meaning that all the elements are permuted." msgstr "" -#: howto/functional.rst:928 +#: howto/functional.rst:930 msgid "" "Note that these functions produce all of the possible combinations by " "position and don't require that the contents of *iterable* are unique::" msgstr "" -#: howto/functional.rst:935 +#: howto/functional.rst:933 +msgid "" +"itertools.permutations('aba', 3) =>\n" +" ('a', 'b', 'a'), ('a', 'a', 'b'), ('b', 'a', 'a'),\n" +" ('b', 'a', 'a'), ('a', 'a', 'b'), ('a', 'b', 'a')" +msgstr "" + +#: howto/functional.rst:937 msgid "" "The identical tuple ``('a', 'a', 'b')`` occurs twice, but the two 'a' " "strings came from different positions." msgstr "" -#: howto/functional.rst:938 +#: howto/functional.rst:940 msgid "" -"The :func:`itertools.combinations_with_replacement(iterable, r) ` function relaxes a different constraint: " -"elements can be repeated within a single tuple. Conceptually an element is " -"selected for the first position of each tuple and then is replaced before " -"the second element is selected. ::" +"The :func:`itertools.combinations_with_replacement(iterable, r) " +"` function relaxes a different " +"constraint: elements can be repeated within a single tuple. Conceptually an " +"element is selected for the first position of each tuple and then is " +"replaced before the second element is selected. ::" msgstr "" -#: howto/functional.rst:953 -msgid "Grouping elements" +#: howto/functional.rst:946 +msgid "" +"itertools.combinations_with_replacement([1, 2, 3, 4, 5], 2) =>\n" +" (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),\n" +" (2, 2), (2, 3), (2, 4), (2, 5),\n" +" (3, 3), (3, 4), (3, 5),\n" +" (4, 4), (4, 5),\n" +" (5, 5)" msgstr "" #: howto/functional.rst:955 +msgid "Grouping elements" +msgstr "" + +#: howto/functional.rst:957 msgid "" "The last function I'll discuss, :func:`itertools.groupby(iter, " "key_func=None) `, is the most complicated. " @@ -1023,14 +1350,39 @@ msgid "" "key is simply each element itself." msgstr "" -#: howto/functional.rst:960 +#: howto/functional.rst:962 msgid "" ":func:`~itertools.groupby` collects all the consecutive elements from the " "underlying iterable that have the same key value, and returns a stream of 2-" "tuples containing a key value and an iterator for the elements with that key." msgstr "" -#: howto/functional.rst:988 +#: howto/functional.rst:968 +msgid "" +"city_list = [('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL'),\n" +" ('Anchorage', 'AK'), ('Nome', 'AK'),\n" +" ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ'),\n" +" ...\n" +" ]\n" +"\n" +"def get_state(city_state):\n" +" return city_state[1]\n" +"\n" +"itertools.groupby(city_list, get_state) =>\n" +" ('AL', iterator-1),\n" +" ('AK', iterator-2),\n" +" ('AZ', iterator-3), ...\n" +"\n" +"where\n" +"iterator-1 =>\n" +" ('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL')\n" +"iterator-2 =>\n" +" ('Anchorage', 'AK'), ('Nome', 'AK')\n" +"iterator-3 =>\n" +" ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ')" +msgstr "" + +#: howto/functional.rst:990 msgid "" ":func:`~itertools.groupby` assumes that the underlying iterable's contents " "will already be sorted based on the key. Note that the returned iterators " @@ -1038,19 +1390,19 @@ msgid "" "iterator-1 before requesting iterator-2 and its corresponding key." msgstr "" -#: howto/functional.rst:995 +#: howto/functional.rst:997 msgid "The functools module" msgstr "" -#: howto/functional.rst:997 +#: howto/functional.rst:999 msgid "" "The :mod:`functools` module contains some higher-order functions. A **higher-" "order function** takes one or more functions as input and returns a new " -"function. The most useful tool in this module is the :func:`functools." -"partial` function." +"function. The most useful tool in this module is " +"the :func:`functools.partial` function." msgstr "" -#: howto/functional.rst:1002 +#: howto/functional.rst:1004 msgid "" "For programs written in a functional style, you'll sometimes want to " "construct variants of existing functions that have some of the parameters " @@ -1060,7 +1412,7 @@ msgid "" "\"partial function application\"." msgstr "" -#: howto/functional.rst:1008 +#: howto/functional.rst:1010 msgid "" "The constructor for :func:`~functools.partial` takes the arguments " "``(function, arg1, arg2, ..., kwarg1=value1, kwarg2=value2)``. The " @@ -1068,51 +1420,101 @@ msgid "" "with the filled-in arguments." msgstr "" -#: howto/functional.rst:1013 +#: howto/functional.rst:1015 msgid "Here's a small but realistic example::" msgstr "" -#: howto/functional.rst:1025 +#: howto/functional.rst:1017 +msgid "" +"import functools\n" +"\n" +"def log(message, subsystem):\n" +" \"\"\"Write the contents of 'message' to the specified subsystem.\"\"\"\n" +" print('%s: %s' % (subsystem, message))\n" +" ...\n" +"\n" +"server_log = functools.partial(log, subsystem='server')\n" +"server_log('Unable to open socket')" +msgstr "" + +#: howto/functional.rst:1027 msgid "" ":func:`functools.reduce(func, iter, [initial_value]) ` " "cumulatively performs an operation on all the iterable's elements and, " "therefore, can't be applied to infinite iterables. *func* must be a function " -"that takes two elements and returns a single value. :func:`functools." -"reduce` takes the first two elements A and B returned by the iterator and " -"calculates ``func(A, B)``. It then requests the third element, C, " -"calculates ``func(func(A, B), C)``, combines this result with the fourth " -"element returned, and continues until the iterable is exhausted. If the " -"iterable returns no values at all, a :exc:`TypeError` exception is raised. " -"If the initial value is supplied, it's used as a starting point and " -"``func(initial_value, A)`` is the first calculation. ::" +"that takes two elements and returns a single " +"value. :func:`functools.reduce` takes the first two elements A and B " +"returned by the iterator and calculates ``func(A, B)``. It then requests " +"the third element, C, calculates ``func(func(A, B), C)``, combines this " +"result with the fourth element returned, and continues until the iterable is " +"exhausted. If the iterable returns no values at all, a :exc:`TypeError` " +"exception is raised. If the initial value is supplied, it's used as a " +"starting point and ``func(initial_value, A)`` is the first calculation. ::" msgstr "" -#: howto/functional.rst:1049 +#: howto/functional.rst:1039 +msgid "" +">>> import operator, functools\n" +">>> functools.reduce(operator.concat, ['A', 'BB', 'C'])\n" +"'ABBC'\n" +">>> functools.reduce(operator.concat, [])\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: reduce() of empty sequence with no initial value\n" +">>> functools.reduce(operator.mul, [1, 2, 3], 1)\n" +"6\n" +">>> functools.reduce(operator.mul, [], 1)\n" +"1" +msgstr "" + +#: howto/functional.rst:1051 msgid "" "If you use :func:`operator.add` with :func:`functools.reduce`, you'll add up " "all the elements of the iterable. This case is so common that there's a " "special built-in called :func:`sum` to compute it:" msgstr "" -#: howto/functional.rst:1061 +#: howto/functional.rst:1063 msgid "" "For many uses of :func:`functools.reduce`, though, it can be clearer to just " "write the obvious :keyword:`for` loop::" msgstr "" -#: howto/functional.rst:1073 +#: howto/functional.rst:1066 msgid "" -"A related function is :func:`itertools.accumulate(iterable, func=operator." -"add) `. It performs the same calculation, but instead " -"of returning only the final result, :func:`~itertools.accumulate` returns an " -"iterator that also yields each partial result::" +"import functools\n" +"# Instead of:\n" +"product = functools.reduce(operator.mul, [1, 2, 3], 1)\n" +"\n" +"# You can write:\n" +"product = 1\n" +"for i in [1, 2, 3]:\n" +" product *= i" msgstr "" -#: howto/functional.rst:1086 -msgid "The operator module" +#: howto/functional.rst:1075 +msgid "" +"A related function is :func:`itertools.accumulate(iterable, " +"func=operator.add) `. It performs the same " +"calculation, but instead of returning only the final " +"result, :func:`~itertools.accumulate` returns an iterator that also yields " +"each partial result::" +msgstr "" + +#: howto/functional.rst:1080 +msgid "" +"itertools.accumulate([1, 2, 3, 4, 5]) =>\n" +" 1, 3, 6, 10, 15\n" +"\n" +"itertools.accumulate([1, 2, 3, 4, 5], operator.mul) =>\n" +" 1, 2, 6, 24, 120" msgstr "" #: howto/functional.rst:1088 +msgid "The operator module" +msgstr "" + +#: howto/functional.rst:1090 msgid "" "The :mod:`operator` module was mentioned earlier. It contains a set of " "functions corresponding to Python's operators. These functions are often " @@ -1120,54 +1522,60 @@ msgid "" "functions that perform a single operation." msgstr "" -#: howto/functional.rst:1093 +#: howto/functional.rst:1095 msgid "Some of the functions in this module are:" msgstr "" -#: howto/functional.rst:1095 +#: howto/functional.rst:1097 msgid "" "Math operations: ``add()``, ``sub()``, ``mul()``, ``floordiv()``, " "``abs()``, ..." msgstr "" -#: howto/functional.rst:1096 +#: howto/functional.rst:1098 msgid "Logical operations: ``not_()``, ``truth()``." msgstr "" -#: howto/functional.rst:1097 +#: howto/functional.rst:1099 msgid "Bitwise operations: ``and_()``, ``or_()``, ``invert()``." msgstr "" -#: howto/functional.rst:1098 +#: howto/functional.rst:1100 msgid "" "Comparisons: ``eq()``, ``ne()``, ``lt()``, ``le()``, ``gt()``, and ``ge()``." msgstr "" -#: howto/functional.rst:1099 +#: howto/functional.rst:1101 msgid "Object identity: ``is_()``, ``is_not()``." msgstr "" -#: howto/functional.rst:1101 +#: howto/functional.rst:1103 msgid "Consult the operator module's documentation for a complete list." msgstr "" -#: howto/functional.rst:1105 +#: howto/functional.rst:1107 msgid "Small functions and the lambda expression" msgstr "" -#: howto/functional.rst:1107 +#: howto/functional.rst:1109 msgid "" "When writing functional-style programs, you'll often need little functions " "that act as predicates or that combine elements in some way." msgstr "" -#: howto/functional.rst:1110 +#: howto/functional.rst:1112 msgid "" "If there's a Python built-in or a module function that's suitable, you don't " "need to define a new function at all::" msgstr "" -#: howto/functional.rst:1116 +#: howto/functional.rst:1115 +msgid "" +"stripped_lines = [line.strip() for line in lines]\n" +"existing_files = filter(os.path.exists, file_list)" +msgstr "" + +#: howto/functional.rst:1118 msgid "" "If the function you need doesn't exist, you need to write it. One way to " "write small functions is to use the :keyword:`lambda` expression. " @@ -1176,19 +1584,35 @@ msgid "" "expression::" msgstr "" -#: howto/functional.rst:1125 +#: howto/functional.rst:1123 +msgid "" +"adder = lambda x, y: x+y\n" +"\n" +"print_assign = lambda name, value: name + '=' + str(value)" +msgstr "" + +#: howto/functional.rst:1127 msgid "" "An alternative is to just use the ``def`` statement and define a function in " "the usual way::" msgstr "" -#: howto/functional.rst:1134 +#: howto/functional.rst:1130 +msgid "" +"def adder(x, y):\n" +" return x + y\n" +"\n" +"def print_assign(name, value):\n" +" return name + '=' + str(value)" +msgstr "" + +#: howto/functional.rst:1136 msgid "" "Which alternative is preferable? That's a style question; my usual course " "is to avoid using ``lambda``." msgstr "" -#: howto/functional.rst:1137 +#: howto/functional.rst:1139 msgid "" "One reason for my preference is that ``lambda`` is quite limited in the " "functions it can define. The result has to be computable as a single " @@ -1198,66 +1622,92 @@ msgid "" "that's hard to read. Quick, what's the following code doing? ::" msgstr "" -#: howto/functional.rst:1147 +#: howto/functional.rst:1146 +msgid "" +"import functools\n" +"total = functools.reduce(lambda a, b: (0, a[1] + b[1]), items)[1]" +msgstr "" + +#: howto/functional.rst:1149 msgid "" "You can figure it out, but it takes time to disentangle the expression to " "figure out what's going on. Using a short nested ``def`` statements makes " "things a little bit better::" msgstr "" -#: howto/functional.rst:1157 +#: howto/functional.rst:1153 +msgid "" +"import functools\n" +"def combine(a, b):\n" +" return 0, a[1] + b[1]\n" +"\n" +"total = functools.reduce(combine, items)[1]" +msgstr "" + +#: howto/functional.rst:1159 msgid "But it would be best of all if I had simply used a ``for`` loop::" msgstr "" -#: howto/functional.rst:1163 +#: howto/functional.rst:1161 +msgid "" +"total = 0\n" +"for a, b in items:\n" +" total += b" +msgstr "" + +#: howto/functional.rst:1165 msgid "Or the :func:`sum` built-in and a generator expression::" msgstr "" #: howto/functional.rst:1167 +msgid "total = sum(b for a, b in items)" +msgstr "" + +#: howto/functional.rst:1169 msgid "" "Many uses of :func:`functools.reduce` are clearer when written as ``for`` " "loops." msgstr "" -#: howto/functional.rst:1169 +#: howto/functional.rst:1171 msgid "" "Fredrik Lundh once suggested the following set of rules for refactoring uses " "of ``lambda``:" msgstr "" -#: howto/functional.rst:1172 +#: howto/functional.rst:1174 msgid "Write a lambda function." msgstr "" -#: howto/functional.rst:1173 +#: howto/functional.rst:1175 msgid "Write a comment explaining what the heck that lambda does." msgstr "" -#: howto/functional.rst:1174 +#: howto/functional.rst:1176 msgid "" "Study the comment for a while, and think of a name that captures the essence " "of the comment." msgstr "" -#: howto/functional.rst:1176 +#: howto/functional.rst:1178 msgid "Convert the lambda to a def statement, using that name." msgstr "" -#: howto/functional.rst:1177 +#: howto/functional.rst:1179 msgid "Remove the comment." msgstr "" -#: howto/functional.rst:1179 +#: howto/functional.rst:1181 msgid "" "I really like these rules, but you're free to disagree about whether this " "lambda-free style is better." msgstr "" -#: howto/functional.rst:1184 +#: howto/functional.rst:1186 msgid "Revision History and Acknowledgements" msgstr "" -#: howto/functional.rst:1186 +#: howto/functional.rst:1188 msgid "" "The author would like to thank the following people for offering " "suggestions, corrections and assistance with various drafts of this article: " @@ -1265,40 +1715,40 @@ msgid "" "Krell, Leandro Lameiro, Jussi Salmela, Collin Winter, Blake Winton." msgstr "" -#: howto/functional.rst:1191 +#: howto/functional.rst:1193 msgid "Version 0.1: posted June 30 2006." msgstr "" -#: howto/functional.rst:1193 +#: howto/functional.rst:1195 msgid "Version 0.11: posted July 1 2006. Typo fixes." msgstr "" -#: howto/functional.rst:1195 +#: howto/functional.rst:1197 msgid "" "Version 0.2: posted July 10 2006. Merged genexp and listcomp sections into " "one. Typo fixes." msgstr "" -#: howto/functional.rst:1198 +#: howto/functional.rst:1200 msgid "" "Version 0.21: Added more references suggested on the tutor mailing list." msgstr "" -#: howto/functional.rst:1200 +#: howto/functional.rst:1202 msgid "" "Version 0.30: Adds a section on the ``functional`` module written by Collin " "Winter; adds short section on the operator module; a few other edits." msgstr "" -#: howto/functional.rst:1205 +#: howto/functional.rst:1207 msgid "References" msgstr "" -#: howto/functional.rst:1208 +#: howto/functional.rst:1210 msgid "General" msgstr "" -#: howto/functional.rst:1210 +#: howto/functional.rst:1212 msgid "" "**Structure and Interpretation of Computer Programs**, by Harold Abelson and " "Gerald Jay Sussman with Julie Sussman. The book can be found at https://" @@ -1309,39 +1759,39 @@ msgid "" "functional-style Python code." msgstr "" -#: howto/functional.rst:1218 +#: howto/functional.rst:1220 msgid "" "https://www.defmacro.org/ramblings/fp.html: A general introduction to " "functional programming that uses Java examples and has a lengthy historical " "introduction." msgstr "" -#: howto/functional.rst:1221 +#: howto/functional.rst:1223 msgid "" "https://en.wikipedia.org/wiki/Functional_programming: General Wikipedia " "entry describing functional programming." msgstr "" -#: howto/functional.rst:1224 +#: howto/functional.rst:1226 msgid "https://en.wikipedia.org/wiki/Coroutine: Entry for coroutines." msgstr "" -#: howto/functional.rst:1226 +#: howto/functional.rst:1228 msgid "" "https://en.wikipedia.org/wiki/Partial_application: Entry for the concept of " "partial function application." msgstr "" -#: howto/functional.rst:1228 +#: howto/functional.rst:1230 msgid "" "https://en.wikipedia.org/wiki/Currying: Entry for the concept of currying." msgstr "" -#: howto/functional.rst:1231 +#: howto/functional.rst:1233 msgid "Python-specific" msgstr "" -#: howto/functional.rst:1233 +#: howto/functional.rst:1235 msgid "" "https://gnosis.cx/TPiP/: The first chapter of David Mertz's book :title-" "reference:`Text Processing in Python` discusses functional programming for " @@ -1349,7 +1799,7 @@ msgid "" "Text Processing\"." msgstr "" -#: howto/functional.rst:1238 +#: howto/functional.rst:1240 msgid "" "Mertz also wrote a 3-part series of articles on functional programming for " "IBM's DeveloperWorks site; see `part 1 `__," msgstr "" -#: howto/functional.rst:1246 +#: howto/functional.rst:1248 msgid "Python documentation" msgstr "" -#: howto/functional.rst:1248 +#: howto/functional.rst:1250 msgid "Documentation for the :mod:`itertools` module." msgstr "" -#: howto/functional.rst:1250 +#: howto/functional.rst:1252 msgid "Documentation for the :mod:`functools` module." msgstr "" -#: howto/functional.rst:1252 +#: howto/functional.rst:1254 msgid "Documentation for the :mod:`operator` module." msgstr "" -#: howto/functional.rst:1254 +#: howto/functional.rst:1256 msgid ":pep:`289`: \"Generator Expressions\"" msgstr "" -#: howto/functional.rst:1256 +#: howto/functional.rst:1258 msgid "" ":pep:`342`: \"Coroutines via Enhanced Generators\" describes the new " "generator features in Python 2.5." diff --git a/howto/gdb_helpers.po b/howto/gdb_helpers.po index 221f61d2..c1bbbcc3 100644 --- a/howto/gdb_helpers.po +++ b/howto/gdb_helpers.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -53,8 +54,8 @@ msgstr "" #: howto/gdb_helpers.rst:29 msgid "" "This document assumes that you are familiar with the basics of GDB and the " -"CPython C API. It consolidates guidance from the `devguide `_ and the `Python wiki `_ and the `Python wiki `_." msgstr "" @@ -113,6 +114,10 @@ msgid "" "configuration file (``~/.gdbinit`` or ``~/.config/gdb/gdbinit``)::" msgstr "" +#: howto/gdb_helpers.rst:68 +msgid "add-auto-load-safe-path /path/to/cpython" +msgstr "" + #: howto/gdb_helpers.rst:70 msgid "You can also add multiple paths, separated by ``:``." msgstr "" @@ -131,10 +136,20 @@ msgstr "" msgid "Fedora:" msgstr "" +#: howto/gdb_helpers.rst:82 +msgid "" +"sudo dnf install gdb\n" +"sudo dnf debuginfo-install python3" +msgstr "" + #: howto/gdb_helpers.rst:87 msgid "Ubuntu:" msgstr "" +#: howto/gdb_helpers.rst:89 +msgid "sudo apt install gdb python3-dbg" +msgstr "" + #: howto/gdb_helpers.rst:93 msgid "" "On several recent Linux systems, GDB can download debugging symbols " @@ -189,6 +204,37 @@ msgid "" "enabled::" msgstr "" +#: howto/gdb_helpers.rst:126 +msgid "" +"#0 0x000000000041a6b1 in PyObject_Malloc (nbytes=Cannot access memory at " +"address 0x7fffff7fefe8\n" +") at Objects/obmalloc.c:748\n" +"#1 0x000000000041b7c0 in _PyObject_DebugMallocApi (id=111 'o', nbytes=24) " +"at Objects/obmalloc.c:1445\n" +"#2 0x000000000041b717 in _PyObject_DebugMalloc (nbytes=24) at Objects/" +"obmalloc.c:1412\n" +"#3 0x000000000044060a in _PyUnicode_New (length=11) at Objects/" +"unicodeobject.c:346\n" +"#4 0x00000000004466aa in PyUnicodeUCS2_DecodeUTF8Stateful (s=0x5c2b8d " +"\"__lltrace__\", size=11, errors=0x0, consumed=\n" +" 0x0) at Objects/unicodeobject.c:2531\n" +"#5 0x0000000000446647 in PyUnicodeUCS2_DecodeUTF8 (s=0x5c2b8d " +"\"__lltrace__\", size=11, errors=0x0)\n" +" at Objects/unicodeobject.c:2495\n" +"#6 0x0000000000440d1b in PyUnicodeUCS2_FromStringAndSize (u=0x5c2b8d " +"\"__lltrace__\", size=11)\n" +" at Objects/unicodeobject.c:551\n" +"#7 0x0000000000440d94 in PyUnicodeUCS2_FromString (u=0x5c2b8d " +"\"__lltrace__\") at Objects/unicodeobject.c:569\n" +"#8 0x0000000000584abd in PyDict_GetItemString (v=\n" +" {'Yuck': , '__builtins__': , '__file__': 'Lib/test/crashers/nasty_eq_vs_dict.py', " +"'__package__': None, 'y': , 'dict': {0: 0, 1: " +"1, 2: 2, 3: 3}, '__cached__': None, '__name__': '__main__', 'z': , '__doc__': None}, key=\n" +" 0x5c2b8d \"__lltrace__\") at Objects/dictobject.c:2171" +msgstr "" + #: howto/gdb_helpers.rst:142 msgid "" "Notice how the dictionary argument to ``PyDict_GetItemString`` is displayed " @@ -203,6 +249,28 @@ msgid "" "example::" msgstr "" +#: howto/gdb_helpers.rst:149 +msgid "" +"(gdb) p globals\n" +"$1 = {'__builtins__': , '__name__':\n" +"'__main__', 'ctypes': , '__doc__': None,\n" +"'__package__': None}\n" +"\n" +"(gdb) p *(PyDictObject*)globals\n" +"$2 = {ob_refcnt = 3, ob_type = 0x3dbdf85820, ma_fill = 5, ma_used = 5,\n" +"ma_mask = 7, ma_table = 0x63d0f8, ma_lookup = 0x3dbdc7ea70\n" +", ma_smalltable = {{me_hash = 7065186196740147912,\n" +"me_key = '__builtins__', me_value = },\n" +"{me_hash = -368181376027291943, me_key = '__name__',\n" +"me_value ='__main__'}, {me_hash = 0, me_key = 0x0, me_value = 0x0},\n" +"{me_hash = 0, me_key = 0x0, me_value = 0x0},\n" +"{me_hash = -9177857982131165996, me_key = 'ctypes',\n" +"me_value = },\n" +"{me_hash = -8518757509529533123, me_key = '__doc__', me_value = None},\n" +"{me_hash = 0, me_key = 0x0, me_value = 0x0}, {\n" +" me_hash = 6614918939584953775, me_key = '__package__', me_value = None}}}" +msgstr "" + #: howto/gdb_helpers.rst:168 msgid "" "Note that the pretty-printers do not actually call ``repr()``. For basic " @@ -218,16 +286,27 @@ msgid "" "level integer::" msgstr "" +#: howto/gdb_helpers.rst:177 +msgid "" +"(gdb) p some_machine_integer\n" +"$3 = 42\n" +"\n" +"(gdb) p some_python_integer\n" +"$4 = 42" +msgstr "" + #: howto/gdb_helpers.rst:183 msgid "" "The internal structure can be revealed with a cast to :c:expr:`PyLongObject " -"*`:" +"*`::" msgstr "" #: howto/gdb_helpers.rst:185 msgid "" -"(gdb) p *(PyLongObject*)some_python_integer $5 = {ob_base = {ob_base = " -"{ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size = 1}, ob_digit = {42}}" +"(gdb) p *(PyLongObject*)some_python_integer\n" +"$5 = {ob_base = {ob_base = {ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size " +"= 1},\n" +"ob_digit = {42}}" msgstr "" #: howto/gdb_helpers.rst:189 @@ -236,6 +315,12 @@ msgid "" "a lot like gdb's built-in printer for ``char *``::" msgstr "" +#: howto/gdb_helpers.rst:192 +msgid "" +"(gdb) p ptr_to_python_str\n" +"$6 = '__builtins__'" +msgstr "" + #: howto/gdb_helpers.rst:195 msgid "" "The pretty-printer for ``str`` instances defaults to using single-quotes (as " @@ -243,10 +328,23 @@ msgid "" "*`` values uses double-quotes and contains a hexadecimal address::" msgstr "" +#: howto/gdb_helpers.rst:199 +msgid "" +"(gdb) p ptr_to_char_star\n" +"$7 = 0x6d72c0 \"hello world\"" +msgstr "" + #: howto/gdb_helpers.rst:202 msgid "" -"Again, the implementation details can be revealed with a cast to :c:expr:" -"`PyUnicodeObject *`::" +"Again, the implementation details can be revealed with a cast " +"to :c:expr:`PyUnicodeObject *`::" +msgstr "" + +#: howto/gdb_helpers.rst:205 +msgid "" +"(gdb) p *(PyUnicodeObject*)$6\n" +"$8 = {ob_base = {ob_refcnt = 33, ob_type = 0x3dad3a95a0}, length = 12,\n" +"str = 0x7ffff2128500, hash = 7065186196740147912, state = 1, defenc = 0x0}" msgstr "" #: howto/gdb_helpers.rst:210 @@ -260,6 +358,22 @@ msgid "" "marked with a \">\"::" msgstr "" +#: howto/gdb_helpers.rst:216 +msgid "" +"(gdb) py-list\n" +" 901 if options.profile:\n" +" 902 options.profile = False\n" +" 903 profile_me()\n" +" 904 return\n" +" 905\n" +">906 u = UI()\n" +" 907 if not u.quit:\n" +" 908 try:\n" +" 909 gtk.main()\n" +" 910 except KeyboardInterrupt:\n" +" 911 # properly quit on a keyboard interrupt..." +msgstr "" + #: howto/gdb_helpers.rst:229 msgid "" "Use ``py-list START`` to list at a different line number within the Python " @@ -295,6 +409,21 @@ msgstr "" msgid "For example::" msgstr "" +#: howto/gdb_helpers.rst:250 +msgid "" +"(gdb) py-up\n" +"#37 Frame 0x9420b04, for file /usr/lib/python2.6/site-packages/\n" +"gnome_sudoku/main.py, line 906, in start_game ()\n" +" u = UI()\n" +"(gdb) py-up\n" +"#40 Frame 0x948e82c, for file /usr/lib/python2.6/site-packages/\n" +"gnome_sudoku/gnome_sudoku.py, line 22, in start_game(main=)\n" +" main.start_game()\n" +"(gdb) py-up\n" +"Unable to find an older python frame" +msgstr "" + #: howto/gdb_helpers.rst:261 msgid "so we're at the top of the Python stack." msgstr "" @@ -310,6 +439,47 @@ msgstr "" msgid "Going back down::" msgstr "" +#: howto/gdb_helpers.rst:269 +msgid "" +"(gdb) py-down\n" +"#37 Frame 0x9420b04, for file /usr/lib/python2.6/site-packages/gnome_sudoku/" +"main.py, line 906, in start_game ()\n" +" u = UI()\n" +"(gdb) py-down\n" +"#34 (unable to read python frame information)\n" +"(gdb) py-down\n" +"#23 (unable to read python frame information)\n" +"(gdb) py-down\n" +"#19 (unable to read python frame information)\n" +"(gdb) py-down\n" +"#14 Frame 0x99262ac, for file /usr/lib/python2.6/site-packages/gnome_sudoku/" +"game_selector.py, line 201, in run_swallowed_dialog " +"(self=, puzzle=None, saved_games=[{'gsd.auto_fills': 0, 'tracking': {}, " +"'trackers': {}, 'notes': [], 'saved_at': 1270084485, 'game': '7 8 0 0 0 0 0 " +"5 6 0 0 9 0 8 0 1 0 0 0 4 6 0 0 0 0 7 0 6 5 0 0 0 4 7 9 2 0 0 0 9 0 1 0 0 0 " +"3 9 7 6 0 0 0 1 8 0 6 0 0 0 0 2 8 0 0 0 5 0 4 0 6 0 0 2 1 0 0 0 0 0 4 5\\n7 " +"8 0 0 0 0 0 5 6 0 0 9 0 8 0 1 0 0 0 4 6 0 0 0 0 7 0 6 5 1 8 3 4 7 9 2 0 0 0 " +"9 0 1 0 0 0 3 9 7 6 0 0 0 1 8 0 6 0 0 0 0 2 8 0 0 0 5 0 4 0 6 0 0 2 1 0 0 0 " +"0 0 4 5', 'gsd.impossible_hints': 0, 'timer.__absolute_start_time__': , 'gsd.hints': 0, 'timer.active_time': , 'timer.total_time': }], " +"dialog=, saved_game_model=, sudoku_maker=, main_page=0) " +"at remote 0x98fa6e4>, d=)\n" +" gtk.main()\n" +"(gdb) py-down\n" +"#8 (unable to read python frame information)\n" +"(gdb) py-down\n" +"Unable to find a newer python frame" +msgstr "" + #: howto/gdb_helpers.rst:289 msgid "and we're at the bottom of the Python stack." msgstr "" @@ -321,6 +491,33 @@ msgid "" "move multiple Python frames at once. For example::" msgstr "" +#: howto/gdb_helpers.rst:295 +msgid "" +"(gdb) py-up\n" +"#6 Frame 0x7ffff7fb62b0, for file /tmp/rec.py, line 5, in recursive_function " +"(n=0)\n" +" time.sleep(5)\n" +"#6 Frame 0x7ffff7fb6240, for file /tmp/rec.py, line 7, in recursive_function " +"(n=1)\n" +" recursive_function(n-1)\n" +"#6 Frame 0x7ffff7fb61d0, for file /tmp/rec.py, line 7, in recursive_function " +"(n=2)\n" +" recursive_function(n-1)\n" +"#6 Frame 0x7ffff7fb6160, for file /tmp/rec.py, line 7, in recursive_function " +"(n=3)\n" +" recursive_function(n-1)\n" +"#6 Frame 0x7ffff7fb60f0, for file /tmp/rec.py, line 7, in recursive_function " +"(n=4)\n" +" recursive_function(n-1)\n" +"#6 Frame 0x7ffff7fb6080, for file /tmp/rec.py, line 7, in recursive_function " +"(n=5)\n" +" recursive_function(n-1)\n" +"#6 Frame 0x7ffff7fb6020, for file /tmp/rec.py, line 9, in ()\n" +" recursive_function(5)\n" +"(gdb) py-up\n" +"Unable to find an older python frame" +msgstr "" + #: howto/gdb_helpers.rst:315 msgid "``py-bt``" msgstr "" @@ -331,6 +528,43 @@ msgid "" "current thread." msgstr "" +#: howto/gdb_helpers.rst:322 +msgid "" +"(gdb) py-bt\n" +"#8 (unable to read python frame information)\n" +"#11 Frame 0x9aead74, for file /usr/lib/python2.6/site-packages/gnome_sudoku/" +"dialog_swallower.py, line 48, in run_dialog " +"(self=, main_page=0) " +"at remote 0x98fa6e4>, d=)\n" +" gtk.main()\n" +"#14 Frame 0x99262ac, for file /usr/lib/python2.6/site-packages/gnome_sudoku/" +"game_selector.py, line 201, in run_swallowed_dialog " +"(self=, puzzle=None, saved_games=[{'gsd.auto_fills': 0, 'tracking': {}, " +"'trackers': {}, 'notes': [], 'saved_at': 1270084485, 'game': '7 8 0 0 0 0 0 " +"5 6 0 0 9 0 8 0 1 0 0 0 4 6 0 0 0 0 7 0 6 5 0 0 0 4 7 9 2 0 0 0 9 0 1 0 0 0 " +"3 9 7 6 0 0 0 1 8 0 6 0 0 0 0 2 8 0 0 0 5 0 4 0 6 0 0 2 1 0 0 0 0 0 4 5\\n7 " +"8 0 0 0 0 0 5 6 0 0 9 0 8 0 1 0 0 0 4 6 0 0 0 0 7 0 6 5 1 8 3 4 7 9 2 0 0 0 " +"9 0 1 0 0 0 3 9 7 6 0 0 0 1 8 0 6 0 0 0 0 2 8 0 0 0 5 0 4 0 6 0 0 2 1 0 0 0 " +"0 0 4 5', 'gsd.impossible_hints': 0, 'timer.__absolute_start_time__': , 'gsd.hints': 0, 'timer.active_time': , 'timer.total_time': }], " +"dialog=, saved_game_model=, sudoku_maker=)\n" +" main.start_game()" +msgstr "" + #: howto/gdb_helpers.rst:336 msgid "" "The frame numbers correspond to those displayed by GDB's standard " @@ -348,6 +582,19 @@ msgid "" "builtins::" msgstr "" +#: howto/gdb_helpers.rst:346 +msgid "" +"(gdb) py-print self\n" +"local 'self' = ,\n" +"main_page=0) at remote 0x98fa6e4>\n" +"(gdb) py-print __name__\n" +"global '__name__' = 'gnome_sudoku.dialog_swallower'\n" +"(gdb) py-print len\n" +"builtin 'len' = \n" +"(gdb) py-print scarlet_pimpernel\n" +"'scarlet_pimpernel' not found" +msgstr "" + #: howto/gdb_helpers.rst:356 msgid "" "If the current C frame corresponds to multiple Python frames, ``py-print`` " @@ -364,12 +611,38 @@ msgid "" "Python frame in the selected thread, and prints their representations::" msgstr "" +#: howto/gdb_helpers.rst:365 +msgid "" +"(gdb) py-locals\n" +"self = ,\n" +"main_page=0) at remote 0x98fa6e4>\n" +"d = " +msgstr "" + #: howto/gdb_helpers.rst:370 msgid "" "If the current C frame corresponds to multiple Python frames, locals from " "all of them will be shown::" msgstr "" +#: howto/gdb_helpers.rst:373 +msgid "" +"(gdb) py-locals\n" +"Locals for recursive_function\n" +"n = 0\n" +"Locals for recursive_function\n" +"n = 1\n" +"Locals for recursive_function\n" +"n = 2\n" +"Locals for recursive_function\n" +"n = 3\n" +"Locals for recursive_function\n" +"n = 4\n" +"Locals for recursive_function\n" +"n = 5\n" +"Locals for " +msgstr "" + #: howto/gdb_helpers.rst:390 msgid "Use with GDB commands" msgstr "" @@ -381,15 +654,131 @@ msgid "" "a specific frame within the selected thread, like this::" msgstr "" +#: howto/gdb_helpers.rst:396 +msgid "" +"(gdb) py-bt\n" +"(output snipped)\n" +"#68 Frame 0xaa4560, for file Lib/test/regrtest.py, line 1548, in " +"()\n" +" main()\n" +"(gdb) frame 68\n" +"#68 0x00000000004cd1e6 in PyEval_EvalFrameEx (f=Frame 0xaa4560, for file Lib/" +"test/regrtest.py, line 1548, in (), throwflag=0) at Python/" +"ceval.c:2665\n" +"2665 x = call_function(&sp, oparg);\n" +"(gdb) py-list\n" +"1543 # Run the tests in a context manager that temporary changes the " +"CWD to a\n" +"1544 # temporary and writable directory. If it's not possible to " +"create or\n" +"1545 # change the CWD, the original CWD will be used. The original " +"CWD is\n" +"1546 # available from test_support.SAVEDCWD.\n" +"1547 with test_support.temp_cwd(TESTCWD, quiet=True):\n" +">1548 main()" +msgstr "" + #: howto/gdb_helpers.rst:411 msgid "" "The ``info threads`` command will give you a list of the threads within the " "process, and you can use the ``thread`` command to select a different one::" msgstr "" +#: howto/gdb_helpers.rst:414 +msgid "" +"(gdb) info threads\n" +" 105 Thread 0x7fffefa18710 (LWP 10260) sem_wait () at ../nptl/sysdeps/unix/" +"sysv/linux/x86_64/sem_wait.S:86\n" +" 104 Thread 0x7fffdf5fe710 (LWP 10259) sem_wait () at ../nptl/sysdeps/unix/" +"sysv/linux/x86_64/sem_wait.S:86\n" +"* 1 Thread 0x7ffff7fe2700 (LWP 10145) 0x00000038e46d73e3 in select () at ../" +"sysdeps/unix/syscall-template.S:82" +msgstr "" + #: howto/gdb_helpers.rst:419 msgid "" "You can use ``thread apply all COMMAND`` or (``t a a COMMAND`` for short) to " "run a command on all threads. With ``py-bt``, this lets you see what every " "thread is doing at the Python level::" msgstr "" + +#: howto/gdb_helpers.rst:423 +msgid "" +"(gdb) t a a py-bt\n" +"\n" +"Thread 105 (Thread 0x7fffefa18710 (LWP 10260)):\n" +"#5 Frame 0x7fffd00019d0, for file /home/david/coding/python-svn/Lib/" +"threading.py, line 155, in _acquire_restore " +"(self=<_RLock(_Verbose__verbose=False, _RLock__owner=140737354016512, " +"_RLock__block=, _RLock__count=1) at remote " +"0xd7ff40>, count_owner=(1, 140737213728528), count=1, " +"owner=140737213728528)\n" +" self.__block.acquire()\n" +"#8 Frame 0x7fffac001640, for file /home/david/coding/python-svn/Lib/" +"threading.py, line 269, in wait " +"(self=<_Condition(_Condition__lock=<_RLock(_Verbose__verbose=False, " +"_RLock__owner=140737354016512, _RLock__block=, _RLock__count=1) at remote 0xd7ff40>, acquire=, _is_owned=, " +"_release_save=, release=, _acquire_restore=, " +"_Verbose__verbose=False, _Condition__waiters=[]) at remote 0xd7fd10>, " +"timeout=None, waiter=, saved_state=(1, " +"140737213728528))\n" +" self._acquire_restore(saved_state)\n" +"#12 Frame 0x7fffb8001a10, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 348, in f ()\n" +" cond.wait()\n" +"#16 Frame 0x7fffb8001c40, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 37, in task (tid=140737213728528)\n" +" f()\n" +"\n" +"Thread 104 (Thread 0x7fffdf5fe710 (LWP 10259)):\n" +"#5 Frame 0x7fffe4001580, for file /home/david/coding/python-svn/Lib/" +"threading.py, line 155, in _acquire_restore " +"(self=<_RLock(_Verbose__verbose=False, _RLock__owner=140737354016512, " +"_RLock__block=, _RLock__count=1) at remote " +"0xd7ff40>, count_owner=(1, 140736940992272), count=1, " +"owner=140736940992272)\n" +" self.__block.acquire()\n" +"#8 Frame 0x7fffc8002090, for file /home/david/coding/python-svn/Lib/" +"threading.py, line 269, in wait " +"(self=<_Condition(_Condition__lock=<_RLock(_Verbose__verbose=False, " +"_RLock__owner=140737354016512, _RLock__block=, _RLock__count=1) at remote 0xd7ff40>, acquire=, _is_owned=, " +"_release_save=, release=, _acquire_restore=, " +"_Verbose__verbose=False, _Condition__waiters=[]) at remote 0xd7fd10>, " +"timeout=None, waiter=, saved_state=(1, " +"140736940992272))\n" +" self._acquire_restore(saved_state)\n" +"#12 Frame 0x7fffac001c90, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 348, in f ()\n" +" cond.wait()\n" +"#16 Frame 0x7fffac0011c0, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 37, in task (tid=140736940992272)\n" +" f()\n" +"\n" +"Thread 1 (Thread 0x7ffff7fe2700 (LWP 10145)):\n" +"#5 Frame 0xcb5380, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 16, in _wait ()\n" +" time.sleep(0.01)\n" +"#8 Frame 0x7fffd00024a0, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 378, in _check_notify " +"(self=, skipped=[], _mirrorOutput=False, testsRun=39, " +"buffer=False, _original_stderr=, " +"_stdout_buffer=, " +"_stderr_buffer=, " +"_moduleSetUpFailed=False, expectedFailures=[], errors=[], " +"_previousTestClass=, unexpectedSuccesses=[], " +"failures=[], shouldStop=False, failfast=False) at remote 0xc185a0>, " +"_threads=(0,), _cleanups=[], _type_equality_funcs={: , : " +", : " +", : " +", \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -22,12 +23,100 @@ msgstr "" #: howto/index.rst:5 msgid "" -"Python HOWTOs are documents that cover a single, specific topic, and attempt " -"to cover it fairly completely. Modelled on the Linux Documentation Project's " -"HOWTO collection, this collection is an effort to foster documentation " -"that's more detailed than the Python Library Reference." +"Python HOWTOs are documents that cover a specific topic in-depth. Modeled on " +"the Linux Documentation Project's HOWTO collection, this collection is an " +"effort to foster documentation that's more detailed than the Python Library " +"Reference." msgstr "" -#: howto/index.rst:11 -msgid "Currently, the HOWTOs are:" +#: howto/index.rst:35 +msgid "General:" +msgstr "" + +#: howto/index.rst:37 +msgid ":ref:`annotations-howto`" +msgstr "" + +#: howto/index.rst:38 +msgid ":ref:`argparse-tutorial`" +msgstr "" + +#: howto/index.rst:39 +msgid ":ref:`descriptorhowto`" +msgstr "" + +#: howto/index.rst:40 +msgid ":ref:`enum-howto`" +msgstr "" + +#: howto/index.rst:41 +msgid ":ref:`functional-howto`" +msgstr "" + +#: howto/index.rst:42 +msgid ":ref:`ipaddress-howto`" +msgstr "" + +#: howto/index.rst:43 +msgid ":ref:`logging-howto`" +msgstr "" + +#: howto/index.rst:44 +msgid ":ref:`logging-cookbook`" +msgstr "" + +#: howto/index.rst:45 +msgid ":ref:`regex-howto`" +msgstr "" + +#: howto/index.rst:46 +msgid ":ref:`sortinghowto`" +msgstr "" + +#: howto/index.rst:47 +msgid ":ref:`unicode-howto`" +msgstr "" + +#: howto/index.rst:48 +msgid ":ref:`urllib-howto`" +msgstr "" + +#: howto/index.rst:50 +msgid "Advanced development:" +msgstr "" + +#: howto/index.rst:52 +msgid ":ref:`curses-howto`" +msgstr "" + +#: howto/index.rst:53 +msgid ":ref:`isolating-extensions-howto`" +msgstr "" + +#: howto/index.rst:54 +msgid ":ref:`python_2.3_mro`" +msgstr "" + +#: howto/index.rst:55 +msgid ":ref:`socket-howto`" +msgstr "" + +#: howto/index.rst:56 +msgid ":ref:`cporting-howto`" +msgstr "" + +#: howto/index.rst:58 +msgid "Debugging and profiling:" +msgstr "" + +#: howto/index.rst:60 +msgid ":ref:`gdb`" +msgstr "" + +#: howto/index.rst:61 +msgid ":ref:`instrumentation`" +msgstr "" + +#: howto/index.rst:62 +msgid ":ref:`perf_profiling`" msgstr "" diff --git a/howto/instrumentation.po b/howto/instrumentation.po index e5f14078..5acc69ef 100644 --- a/howto/instrumentation.po +++ b/howto/instrumentation.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -81,16 +82,28 @@ msgstr "" msgid "On a Linux machine, this can be done via::" msgstr "" +#: howto/instrumentation.rst:42 +msgid "$ yum install systemtap-sdt-devel" +msgstr "" + #: howto/instrumentation.rst:44 msgid "or::" msgstr "" +#: howto/instrumentation.rst:46 +msgid "$ sudo apt-get install systemtap-sdt-dev" +msgstr "" + #: howto/instrumentation.rst:49 msgid "" "CPython must then be :option:`configured with the --with-dtrace option <--" "with-dtrace>`:" msgstr "" +#: howto/instrumentation.rst:52 +msgid "checking for --with-dtrace... yes" +msgstr "" + #: howto/instrumentation.rst:56 msgid "" "On macOS, you can list available DTrace probes by running a Python process " @@ -98,12 +111,40 @@ msgid "" "provider::" msgstr "" +#: howto/instrumentation.rst:60 +msgid "" +"$ python3.6 -q &\n" +"$ sudo dtrace -l -P python$! # or: dtrace -l -m python3.6\n" +"\n" +" ID PROVIDER MODULE FUNCTION NAME\n" +"29564 python18035 python3.6 _PyEval_EvalFrameDefault " +"function-entry\n" +"29565 python18035 python3.6 dtrace_function_entry " +"function-entry\n" +"29566 python18035 python3.6 _PyEval_EvalFrameDefault " +"function-return\n" +"29567 python18035 python3.6 dtrace_function_return " +"function-return\n" +"29568 python18035 python3.6 collect gc-" +"done\n" +"29569 python18035 python3.6 collect gc-" +"start\n" +"29570 python18035 python3.6 _PyEval_EvalFrameDefault line\n" +"29571 python18035 python3.6 maybe_dtrace_line line" +msgstr "" + #: howto/instrumentation.rst:73 msgid "" "On Linux, you can verify if the SystemTap static markers are present in the " "built binary by seeing if it contains a \".note.stapsdt\" section." msgstr "" +#: howto/instrumentation.rst:78 +msgid "" +"$ readelf -S ./python | grep .note.stapsdt\n" +"[30] .note.stapsdt NOTE 0000000000000000 00308d78" +msgstr "" + #: howto/instrumentation.rst:81 msgid "" "If you've built Python as a shared library (with the :option:`--enable-" @@ -111,10 +152,64 @@ msgid "" "library. For example::" msgstr "" +#: howto/instrumentation.rst:85 +msgid "" +"$ readelf -S libpython3.3dm.so.1.0 | grep .note.stapsdt\n" +"[29] .note.stapsdt NOTE 0000000000000000 00365b68" +msgstr "" + #: howto/instrumentation.rst:88 msgid "Sufficiently modern readelf can print the metadata::" msgstr "" +#: howto/instrumentation.rst:90 +msgid "" +"$ readelf -n ./python\n" +"\n" +"Displaying notes found at file offset 0x00000254 with length 0x00000020:\n" +" Owner Data size Description\n" +" GNU 0x00000010 NT_GNU_ABI_TAG (ABI version " +"tag)\n" +" OS: Linux, ABI: 2.6.32\n" +"\n" +"Displaying notes found at file offset 0x00000274 with length 0x00000024:\n" +" Owner Data size Description\n" +" GNU 0x00000014 NT_GNU_BUILD_ID (unique build " +"ID bitstring)\n" +" Build ID: df924a2b08a7e89f6e11251d4602022977af2670\n" +"\n" +"Displaying notes found at file offset 0x002d6c30 with length 0x00000144:\n" +" Owner Data size Description\n" +" stapsdt 0x00000031 NT_STAPSDT (SystemTap probe " +"descriptors)\n" +" Provider: python\n" +" Name: gc__start\n" +" Location: 0x00000000004371c3, Base: 0x0000000000630ce2, Semaphore: " +"0x00000000008d6bf6\n" +" Arguments: -4@%ebx\n" +" stapsdt 0x00000030 NT_STAPSDT (SystemTap probe " +"descriptors)\n" +" Provider: python\n" +" Name: gc__done\n" +" Location: 0x00000000004374e1, Base: 0x0000000000630ce2, Semaphore: " +"0x00000000008d6bf8\n" +" Arguments: -8@%rax\n" +" stapsdt 0x00000045 NT_STAPSDT (SystemTap probe " +"descriptors)\n" +" Provider: python\n" +" Name: function__entry\n" +" Location: 0x000000000053db6c, Base: 0x0000000000630ce2, Semaphore: " +"0x00000000008d6be8\n" +" Arguments: 8@%rbp 8@%r12 -4@%eax\n" +" stapsdt 0x00000046 NT_STAPSDT (SystemTap probe " +"descriptors)\n" +" Provider: python\n" +" Name: function__return\n" +" Location: 0x000000000053dba8, Base: 0x0000000000630ce2, Semaphore: " +"0x00000000008d6bea\n" +" Arguments: 8@%rbp 8@%r12 -4@%eax" +msgstr "" + #: howto/instrumentation.rst:125 msgid "" "The above metadata contains information for SystemTap describing how it can " @@ -134,14 +229,77 @@ msgid "" "are not going to be listed:" msgstr "" +#: howto/instrumentation.rst:138 +msgid "" +"self int indent;\n" +"\n" +"python$target:::function-entry\n" +"/copyinstr(arg1) == \"start\"/\n" +"{\n" +" self->trace = 1;\n" +"}\n" +"\n" +"python$target:::function-entry\n" +"/self->trace/\n" +"{\n" +" printf(\"%d\\t%*s:\", timestamp, 15, probename);\n" +" printf(\"%*s\", self->indent, \"\");\n" +" printf(\"%s:%s:%d\\n\", basename(copyinstr(arg0)), copyinstr(arg1), " +"arg2);\n" +" self->indent++;\n" +"}\n" +"\n" +"python$target:::function-return\n" +"/self->trace/\n" +"{\n" +" self->indent--;\n" +" printf(\"%d\\t%*s:\", timestamp, 15, probename);\n" +" printf(\"%*s\", self->indent, \"\");\n" +" printf(\"%s:%s:%d\\n\", basename(copyinstr(arg0)), copyinstr(arg1), " +"arg2);\n" +"}\n" +"\n" +"python$target:::function-return\n" +"/copyinstr(arg1) == \"start\"/\n" +"{\n" +" self->trace = 0;\n" +"}" +msgstr "" + #: howto/instrumentation.rst:230 msgid "It can be invoked like this::" msgstr "" +#: howto/instrumentation.rst:174 +msgid "$ sudo dtrace -q -s call_stack.d -c \"python3.6 script.py\"" +msgstr "" + #: howto/instrumentation.rst:236 msgid "The output looks like this:" msgstr "" +#: howto/instrumentation.rst:178 +msgid "" +"156641360502280 function-entry:call_stack.py:start:23\n" +"156641360518804 function-entry: call_stack.py:function_1:1\n" +"156641360532797 function-entry: call_stack.py:function_3:9\n" +"156641360546807 function-return: call_stack.py:function_3:10\n" +"156641360563367 function-return: call_stack.py:function_1:2\n" +"156641360578365 function-entry: call_stack.py:function_2:5\n" +"156641360591757 function-entry: call_stack.py:function_1:1\n" +"156641360605556 function-entry: call_stack.py:function_3:9\n" +"156641360617482 function-return: call_stack.py:function_3:10\n" +"156641360629814 function-return: call_stack.py:function_1:2\n" +"156641360642285 function-return: call_stack.py:function_2:6\n" +"156641360656770 function-entry: call_stack.py:function_3:9\n" +"156641360669707 function-return: call_stack.py:function_3:10\n" +"156641360687853 function-entry: call_stack.py:function_4:13\n" +"156641360700719 function-return: call_stack.py:function_4:14\n" +"156641360719640 function-entry: call_stack.py:function_5:18\n" +"156641360732567 function-return: call_stack.py:function_5:21\n" +"156641360747370 function-return:call_stack.py:start:28" +msgstr "" + #: howto/instrumentation.rst:201 msgid "Static SystemTap markers" msgstr "" @@ -159,6 +317,44 @@ msgid "" "hierarchy of a Python script:" msgstr "" +#: howto/instrumentation.rst:210 +msgid "" +"probe process(\"python\").mark(\"function__entry\") {\n" +" filename = user_string($arg1);\n" +" funcname = user_string($arg2);\n" +" lineno = $arg3;\n" +"\n" +" printf(\"%s => %s in %s:%d\\\\n\",\n" +" thread_indent(1), funcname, filename, lineno);\n" +"}\n" +"\n" +"probe process(\"python\").mark(\"function__return\") {\n" +" filename = user_string($arg1);\n" +" funcname = user_string($arg2);\n" +" lineno = $arg3;\n" +"\n" +" printf(\"%s <= %s in %s:%d\\\\n\",\n" +" thread_indent(-1), funcname, filename, lineno);\n" +"}" +msgstr "" + +#: howto/instrumentation.rst:232 +msgid "" +"$ stap \\\n" +" show-call-hierarchy.stp \\\n" +" -c \"./python test.py\"" +msgstr "" + +#: howto/instrumentation.rst:238 +msgid "" +"11408 python(8274): => __contains__ in Lib/_abcoll.py:362\n" +"11414 python(8274): => __getitem__ in Lib/os.py:425\n" +"11418 python(8274): => encode in Lib/os.py:490\n" +"11424 python(8274): <= encode in Lib/os.py:493\n" +"11428 python(8274): <= __getitem__ in Lib/os.py:426\n" +"11433 python(8274): <= __contains__ in Lib/_abcoll.py:366" +msgstr "" + #: howto/instrumentation.rst:247 msgid "where the columns are:" msgstr "" @@ -187,10 +383,21 @@ msgid "" "reflect this. For example, this line from the above example:" msgstr "" +#: howto/instrumentation.rst:259 +msgid "probe process(\"python\").mark(\"function__entry\") {" +msgstr "" + #: howto/instrumentation.rst:263 msgid "should instead read:" msgstr "" +#: howto/instrumentation.rst:265 +msgid "" +"probe " +"process(\"python\").library(\"libpython3.6dm.so.1.0\").mark(\"function__entry\") " +"{" +msgstr "" + #: howto/instrumentation.rst:269 msgid "(assuming a :ref:`debug build ` of CPython 3.6)" msgstr "" @@ -253,7 +460,7 @@ msgstr "" #: howto/instrumentation.rst:309 msgid "" "Fires when the Python interpreter starts a garbage collection cycle. " -"``arg0`` is the generation to scan, like :func:`gc.collect()`." +"``arg0`` is the generation to scan, like :func:`gc.collect`." msgstr "" #: howto/instrumentation.rst:314 @@ -296,6 +503,29 @@ msgstr "" msgid "Here is a tapset file, based on a non-shared build of CPython:" msgstr "" +#: howto/instrumentation.rst:351 +msgid "" +"/*\n" +" Provide a higher-level wrapping around the function__entry and\n" +" function__return markers:\n" +" \\*/\n" +"probe python.function.entry = process(\"python\").mark(\"function__entry\")\n" +"{\n" +" filename = user_string($arg1);\n" +" funcname = user_string($arg2);\n" +" lineno = $arg3;\n" +" frameptr = $arg4\n" +"}\n" +"probe python.function.return = " +"process(\"python\").mark(\"function__return\")\n" +"{\n" +" filename = user_string($arg1);\n" +" funcname = user_string($arg2);\n" +" lineno = $arg3;\n" +" frameptr = $arg4\n" +"}" +msgstr "" + #: howto/instrumentation.rst:372 msgid "" "If this file is installed in SystemTap's tapset directory (e.g. ``/usr/share/" @@ -327,9 +557,46 @@ msgid "" "needing to directly name the static markers:" msgstr "" +#: howto/instrumentation.rst:395 +msgid "" +"probe python.function.entry\n" +"{\n" +" printf(\"%s => %s in %s:%d\\n\",\n" +" thread_indent(1), funcname, filename, lineno);\n" +"}\n" +"\n" +"probe python.function.return\n" +"{\n" +" printf(\"%s <= %s in %s:%d\\n\",\n" +" thread_indent(-1), funcname, filename, lineno);\n" +"}" +msgstr "" + #: howto/instrumentation.rst:410 msgid "" "The following script uses the tapset above to provide a top-like view of all " "running CPython code, showing the top 20 most frequently entered bytecode " "frames, each second, across the whole system:" msgstr "" + +#: howto/instrumentation.rst:414 +msgid "" +"global fn_calls;\n" +"\n" +"probe python.function.entry\n" +"{\n" +" fn_calls[pid(), filename, funcname, lineno] += 1;\n" +"}\n" +"\n" +"probe timer.ms(1000) {\n" +" printf(\"\\033[2J\\033[1;1H\") /* clear screen \\*/\n" +" printf(\"%6s %80s %6s %30s %6s\\n\",\n" +" \"PID\", \"FILENAME\", \"LINE\", \"FUNCTION\", \"CALLS\")\n" +" foreach ([pid, filename, funcname, lineno] in fn_calls- limit 20) {\n" +" printf(\"%6d %80s %6d %30s %6d\\n\",\n" +" pid, filename, lineno, funcname,\n" +" fn_calls[pid, filename, funcname, lineno]);\n" +" }\n" +" delete fn_calls;\n" +"}" +msgstr "" diff --git a/howto/ipaddress.po b/howto/ipaddress.po index f8f36b9a..ad0e8c8b 100644 --- a/howto/ipaddress.po +++ b/howto/ipaddress.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -98,6 +99,14 @@ msgid "" "within 32 bits are assumed to be IPv4 addresses::" msgstr "" +#: howto/ipaddress.rst:64 +msgid "" +">>> ipaddress.ip_address(3221225985)\n" +"IPv4Address('192.0.2.1')\n" +">>> ipaddress.ip_address(42540766411282592856903984951653826561)\n" +"IPv6Address('2001:db8::1')" +msgstr "" + #: howto/ipaddress.rst:69 msgid "" "To force the use of IPv4 or IPv6 addresses, the relevant classes can be " @@ -105,14 +114,24 @@ msgid "" "addresses for small integers::" msgstr "" +#: howto/ipaddress.rst:73 +msgid "" +">>> ipaddress.ip_address(1)\n" +"IPv4Address('0.0.0.1')\n" +">>> ipaddress.IPv4Address(1)\n" +"IPv4Address('0.0.0.1')\n" +">>> ipaddress.IPv6Address(1)\n" +"IPv6Address('::1')" +msgstr "" + #: howto/ipaddress.rst:82 msgid "Defining Networks" msgstr "" #: howto/ipaddress.rst:84 msgid "" -"Host addresses are usually grouped together into IP networks, so :mod:" -"`ipaddress` provides a way to create, inspect and manipulate network " +"Host addresses are usually grouped together into IP networks, " +"so :mod:`ipaddress` provides a way to create, inspect and manipulate network " "definitions. IP network objects are constructed from strings that define the " "range of host addresses that are part of that network. The simplest form for " "that information is a \"network address/network prefix\" pair, where the " @@ -127,6 +146,14 @@ msgid "" "IP version automatically::" msgstr "" +#: howto/ipaddress.rst:96 +msgid "" +">>> ipaddress.ip_network('192.0.2.0/24')\n" +"IPv4Network('192.0.2.0/24')\n" +">>> ipaddress.ip_network('2001:db8::0/96')\n" +"IPv6Network('2001:db8::/96')" +msgstr "" + #: howto/ipaddress.rst:101 msgid "" "Network objects cannot have any host bits set. The practical effect of this " @@ -144,6 +171,16 @@ msgid "" "the constructor::" msgstr "" +#: howto/ipaddress.rst:112 +msgid "" +">>> ipaddress.ip_network('192.0.2.1/24')\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: 192.0.2.1/24 has host bits set\n" +">>> ipaddress.ip_network('192.0.2.1/24', strict=False)\n" +"IPv4Network('192.0.2.0/24')" +msgstr "" + #: howto/ipaddress.rst:119 msgid "" "While the string form offers significantly more flexibility, networks can " @@ -152,6 +189,14 @@ msgid "" "integer, so the network prefix includes the entire network address::" msgstr "" +#: howto/ipaddress.rst:124 +msgid "" +">>> ipaddress.ip_network(3221225984)\n" +"IPv4Network('192.0.2.0/32')\n" +">>> ipaddress.ip_network(42540766411282592856903984951653826560)\n" +"IPv6Network('2001:db8::/128')" +msgstr "" + #: howto/ipaddress.rst:129 msgid "" "As with addresses, creation of a particular kind of network can be forced by " @@ -168,11 +213,11 @@ msgid "" "network, neither the address nor the network classes are sufficient. " "Notation like ``192.0.2.1/24`` is commonly used by network engineers and the " "people who write tools for firewalls and routers as shorthand for \"the host " -"``192.0.2.1`` on the network ``192.0.2.0/24``\", Accordingly, :mod:" -"`ipaddress` provides a set of hybrid classes that associate an address with " -"a particular network. The interface for creation is identical to that for " -"defining network objects, except that the address portion isn't constrained " -"to being a network address." +"``192.0.2.1`` on the network ``192.0.2.0/24``\", " +"Accordingly, :mod:`ipaddress` provides a set of hybrid classes that " +"associate an address with a particular network. The interface for creation " +"is identical to that for defining network objects, except that the address " +"portion isn't constrained to being a network address." msgstr "" #: howto/ipaddress.rst:152 @@ -188,26 +233,71 @@ msgstr "" #: howto/ipaddress.rst:159 msgid "" "You've gone to the trouble of creating an IPv(4|6)(Address|Network|" -"Interface) object, so you probably want to get information about it. :mod:" -"`ipaddress` tries to make doing this easy and intuitive." +"Interface) object, so you probably want to get information about " +"it. :mod:`ipaddress` tries to make doing this easy and intuitive." msgstr "" #: howto/ipaddress.rst:163 msgid "Extracting the IP version::" msgstr "" +#: howto/ipaddress.rst:165 +msgid "" +">>> addr4 = ipaddress.ip_address('192.0.2.1')\n" +">>> addr6 = ipaddress.ip_address('2001:db8::1')\n" +">>> addr6.version\n" +"6\n" +">>> addr4.version\n" +"4" +msgstr "" + #: howto/ipaddress.rst:172 msgid "Obtaining the network from an interface::" msgstr "" +#: howto/ipaddress.rst:174 +msgid "" +">>> host4 = ipaddress.ip_interface('192.0.2.1/24')\n" +">>> host4.network\n" +"IPv4Network('192.0.2.0/24')\n" +">>> host6 = ipaddress.ip_interface('2001:db8::1/96')\n" +">>> host6.network\n" +"IPv6Network('2001:db8::/96')" +msgstr "" + #: howto/ipaddress.rst:181 msgid "Finding out how many individual addresses are in a network::" msgstr "" +#: howto/ipaddress.rst:183 +msgid "" +">>> net4 = ipaddress.ip_network('192.0.2.0/24')\n" +">>> net4.num_addresses\n" +"256\n" +">>> net6 = ipaddress.ip_network('2001:db8::0/96')\n" +">>> net6.num_addresses\n" +"4294967296" +msgstr "" + #: howto/ipaddress.rst:190 msgid "Iterating through the \"usable\" addresses on a network::" msgstr "" +#: howto/ipaddress.rst:192 +msgid "" +">>> net4 = ipaddress.ip_network('192.0.2.0/24')\n" +">>> for x in net4.hosts():\n" +"... print(x) \n" +"192.0.2.1\n" +"192.0.2.2\n" +"192.0.2.3\n" +"192.0.2.4\n" +"...\n" +"192.0.2.252\n" +"192.0.2.253\n" +"192.0.2.254" +msgstr "" + #: howto/ipaddress.rst:205 msgid "" "Obtaining the netmask (i.e. set bits corresponding to the network prefix) or " @@ -218,6 +308,18 @@ msgstr "" msgid "Exploding or compressing the address::" msgstr "" +#: howto/ipaddress.rst:222 +msgid "" +">>> addr6.exploded\n" +"'2001:0db8:0000:0000:0000:0000:0000:0001'\n" +">>> addr6.compressed\n" +"'2001:db8::1'\n" +">>> net6.exploded\n" +"'2001:0db8:0000:0000:0000:0000:0000:0000/96'\n" +">>> net6.compressed\n" +"'2001:db8::/96'" +msgstr "" + #: howto/ipaddress.rst:231 msgid "" "While IPv4 doesn't support explosion or compression, the associated objects " @@ -236,16 +338,43 @@ msgid "" "to index them like this::" msgstr "" +#: howto/ipaddress.rst:243 +msgid "" +">>> net4[1]\n" +"IPv4Address('192.0.2.1')\n" +">>> net4[-1]\n" +"IPv4Address('192.0.2.255')\n" +">>> net6[1]\n" +"IPv6Address('2001:db8::1')\n" +">>> net6[-1]\n" +"IPv6Address('2001:db8::ffff:ffff')" +msgstr "" + #: howto/ipaddress.rst:253 msgid "" "It also means that network objects lend themselves to using the list " "membership test syntax like this::" msgstr "" +#: howto/ipaddress.rst:256 +msgid "" +"if address in network:\n" +" # do something" +msgstr "" + #: howto/ipaddress.rst:259 msgid "Containment testing is done efficiently based on the network prefix::" msgstr "" +#: howto/ipaddress.rst:261 +msgid "" +">>> addr4 = ipaddress.ip_address('192.0.2.1')\n" +">>> addr4 in ipaddress.ip_network('192.0.2.0/24')\n" +"True\n" +">>> addr4 in ipaddress.ip_network('192.0.3.0/24')\n" +"False" +msgstr "" + #: howto/ipaddress.rst:269 msgid "Comparisons" msgstr "" @@ -256,6 +385,12 @@ msgid "" "objects, where it makes sense::" msgstr "" +#: howto/ipaddress.rst:274 +msgid "" +">>> ipaddress.ip_address('192.0.2.1') < ipaddress.ip_address('192.0.2.2')\n" +"True" +msgstr "" + #: howto/ipaddress.rst:277 msgid "" "A :exc:`TypeError` exception is raised if you try to compare objects of " @@ -273,6 +408,15 @@ msgid "" "an integer or string that the other module will accept::" msgstr "" +#: howto/ipaddress.rst:288 +msgid "" +">>> addr4 = ipaddress.ip_address('192.0.2.1')\n" +">>> str(addr4)\n" +"'192.0.2.1'\n" +">>> int(addr4)\n" +"3221225985" +msgstr "" + #: howto/ipaddress.rst:296 msgid "Getting more detail when instance creation fails" msgstr "" @@ -290,9 +434,9 @@ msgstr "" #: howto/ipaddress.rst:305 msgid "" "To support use cases where it is useful to have access to this additional " -"detail, the individual class constructors actually raise the :exc:" -"`ValueError` subclasses :exc:`ipaddress.AddressValueError` and :exc:" -"`ipaddress.NetmaskValueError` to indicate exactly which part of the " +"detail, the individual class constructors actually raise " +"the :exc:`ValueError` subclasses :exc:`ipaddress.AddressValueError` " +"and :exc:`ipaddress.NetmaskValueError` to indicate exactly which part of the " "definition failed to parse correctly." msgstr "" @@ -302,9 +446,39 @@ msgid "" "constructors directly. For example::" msgstr "" +#: howto/ipaddress.rst:314 +msgid "" +">>> ipaddress.ip_address(\"192.168.0.256\")\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: '192.168.0.256' does not appear to be an IPv4 or IPv6 address\n" +">>> ipaddress.IPv4Address(\"192.168.0.256\")\n" +"Traceback (most recent call last):\n" +" ...\n" +"ipaddress.AddressValueError: Octet 256 (> 255) not permitted in " +"'192.168.0.256'\n" +"\n" +">>> ipaddress.ip_network(\"192.168.0.1/64\")\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: '192.168.0.1/64' does not appear to be an IPv4 or IPv6 network\n" +">>> ipaddress.IPv4Network(\"192.168.0.1/64\")\n" +"Traceback (most recent call last):\n" +" ...\n" +"ipaddress.NetmaskValueError: '64' is not a valid netmask" +msgstr "" + #: howto/ipaddress.rst:332 msgid "" "However, both of the module specific exceptions have :exc:`ValueError` as " "their parent class, so if you're not concerned with the particular type of " "error, you can still write code like the following::" msgstr "" + +#: howto/ipaddress.rst:336 +msgid "" +"try:\n" +" network = ipaddress.IPv4Network(address)\n" +"except ValueError:\n" +" print('address/netmask is invalid for IPv4:', address)" +msgstr "" diff --git a/howto/isolating-extensions.po b/howto/isolating-extensions.po index 1e28247e..9a757219 100644 --- a/howto/isolating-extensions.po +++ b/howto/isolating-extensions.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -75,8 +76,8 @@ msgstr "" #: howto/isolating-extensions.rst:42 msgid "" -"in parallel, managing \"sub-interpreters\" using :c:func:" -"`Py_NewInterpreter`/:c:func:`Py_EndInterpreter`." +"in parallel, managing \"sub-interpreters\" " +"using :c:func:`Py_NewInterpreter`/:c:func:`Py_EndInterpreter`." msgstr "" #: howto/isolating-extensions.rst:45 @@ -148,6 +149,17 @@ msgid "" "example:" msgstr "" +#: howto/isolating-extensions.rst:93 +msgid "" +">>> import sys\n" +">>> import binascii\n" +">>> old_binascii = binascii\n" +">>> del sys.modules['binascii']\n" +">>> import binascii # create a new module object\n" +">>> old_binascii == binascii\n" +"False" +msgstr "" + #: howto/isolating-extensions.rst:103 msgid "" "As a rule of thumb, the two modules should be completely independent. All " @@ -179,6 +191,20 @@ msgid "" "exception is *not* caught:" msgstr "" +#: howto/isolating-extensions.rst:126 +msgid "" +">>> old_binascii.Error == binascii.Error\n" +"False\n" +">>> try:\n" +"... old_binascii.unhexlify(b'qwertyuiop')\n" +"... except binascii.Error:\n" +"... print('boo')\n" +"...\n" +"Traceback (most recent call last):\n" +" File \"\", line 2, in \n" +"binascii.Error: Non-hexadecimal digit found" +msgstr "" + #: howto/isolating-extensions.rst:139 msgid "" "This is expected. Notice that pure-Python modules behave the same way: it is " @@ -281,8 +307,9 @@ msgstr "" #: howto/isolating-extensions.rst:205 msgid "" "An example of a module with per-module state is currently available as " -"`xxlimited `__; example module initialization shown at the bottom of the file." +"`xxlimited `__; example module initialization shown at the bottom of the " +"file." msgstr "" #: howto/isolating-extensions.rst:211 @@ -297,6 +324,23 @@ msgid "" "For example::" msgstr "" +#: howto/isolating-extensions.rst:218 +msgid "" +"static int loaded = 0;\n" +"\n" +"static int\n" +"exec_module(PyObject* module)\n" +"{\n" +" if (loaded) {\n" +" PyErr_SetString(PyExc_ImportError,\n" +" \"cannot load module more than once per process\");\n" +" return -1;\n" +" }\n" +" loaded = 1;\n" +" // ... rest of initialization\n" +"}" +msgstr "" + #: howto/isolating-extensions.rst:234 msgid "Module State Access from Functions" msgstr "" @@ -308,6 +352,19 @@ msgid "" "state, you can use ``PyModule_GetState``::" msgstr "" +#: howto/isolating-extensions.rst:240 +msgid "" +"static PyObject *\n" +"func(PyObject *module, PyObject *args)\n" +"{\n" +" my_struct *state = (my_struct*)PyModule_GetState(module);\n" +" if (state == NULL) {\n" +" return NULL;\n" +" }\n" +" // ... rest of logic\n" +"}" +msgstr "" + #: howto/isolating-extensions.rst:251 msgid "" "``PyModule_GetState`` may return ``NULL`` without setting an exception if " @@ -379,8 +436,8 @@ msgstr "" #: howto/isolating-extensions.rst:302 msgid "" -"Unlike static types, heap type objects are mutable by default. Use the :c:" -"macro:`Py_TPFLAGS_IMMUTABLETYPE` flag to prevent mutability." +"Unlike static types, heap type objects are mutable by default. Use " +"the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag to prevent mutability." msgstr "" #: howto/isolating-extensions.rst:304 @@ -397,8 +454,8 @@ msgstr "" #: howto/isolating-extensions.rst:312 msgid "" "Heap types can be created by filling a :c:struct:`PyType_Spec` structure, a " -"description or \"blueprint\" of a class, and calling :c:func:" -"`PyType_FromModuleAndSpec` to construct a new class object." +"description or \"blueprint\" of a class, and " +"calling :c:func:`PyType_FromModuleAndSpec` to construct a new class object." msgstr "" #: howto/isolating-extensions.rst:317 @@ -443,8 +500,8 @@ msgstr "" #: howto/isolating-extensions.rst:342 msgid "" -"Please refer to the the documentation of :c:macro:`Py_TPFLAGS_HAVE_GC` and :" -"c:member:`~PyTypeObject.tp_traverse` for additional considerations." +"Please refer to the documentation of :c:macro:`Py_TPFLAGS_HAVE_GC` " +"and :c:member:`~PyTypeObject.tp_traverse` for additional considerations." msgstr "" #: howto/isolating-extensions.rst:346 @@ -465,6 +522,17 @@ msgid "" "visit the type, so it must be more complicated::" msgstr "" +#: howto/isolating-extensions.rst:358 +msgid "" +"static int my_traverse(PyObject *self, visitproc visit, void *arg)\n" +"{\n" +" if (Py_Version >= 0x03090000) {\n" +" Py_VISIT(Py_TYPE(self));\n" +" }\n" +" return 0;\n" +"}" +msgstr "" + #: howto/isolating-extensions.rst:366 msgid "" "Unfortunately, :c:data:`Py_Version` was only added in Python 3.11. As a " @@ -477,8 +545,8 @@ msgstr "" #: howto/isolating-extensions.rst:370 msgid "" -":py:data:`sys.version_info` (via :c:func:`PySys_GetObject` and :c:func:" -"`PyArg_ParseTuple`)." +":py:data:`sys.version_info` (via :c:func:`PySys_GetObject` " +"and :c:func:`PyArg_ParseTuple`)." msgstr "" #: howto/isolating-extensions.rst:375 @@ -487,24 +555,39 @@ msgstr "" #: howto/isolating-extensions.rst:377 msgid "" -"If your traverse function delegates to the :c:member:`~PyTypeObject." -"tp_traverse` of its base class (or another type), ensure that " -"``Py_TYPE(self)`` is visited only once. Note that only heap type are " -"expected to visit the type in ``tp_traverse``." +"If your traverse function delegates to " +"the :c:member:`~PyTypeObject.tp_traverse` of its base class (or another " +"type), ensure that ``Py_TYPE(self)`` is visited only once. Note that only " +"heap type are expected to visit the type in ``tp_traverse``." msgstr "" #: howto/isolating-extensions.rst:382 msgid "For example, if your traverse function includes::" msgstr "" +#: howto/isolating-extensions.rst:384 +msgid "base->tp_traverse(self, visit, arg)" +msgstr "" + #: howto/isolating-extensions.rst:386 msgid "...and ``base`` may be a static type, then it should also include::" msgstr "" +#: howto/isolating-extensions.rst:388 +msgid "" +"if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) {\n" +" // a heap type's tp_traverse already visited Py_TYPE(self)\n" +"} else {\n" +" if (Py_Version >= 0x03090000) {\n" +" Py_VISIT(Py_TYPE(self));\n" +" }\n" +"}" +msgstr "" + #: howto/isolating-extensions.rst:396 msgid "" -"It is not necessary to handle the type's reference count in :c:member:" -"`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_clear`." +"It is not necessary to handle the type's reference count " +"in :c:member:`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_clear`." msgstr "" #: howto/isolating-extensions.rst:401 @@ -532,6 +615,18 @@ msgid "" "needs to be decremented *after* the instance is deallocated. For example::" msgstr "" +#: howto/isolating-extensions.rst:412 +msgid "" +"static void my_dealloc(PyObject *self)\n" +"{\n" +" PyObject_GC_UnTrack(self);\n" +" ...\n" +" PyTypeObject *type = Py_TYPE(self);\n" +" type->tp_free(self);\n" +" Py_DECREF(type);\n" +"}" +msgstr "" + #: howto/isolating-extensions.rst:421 msgid "" "The default ``tp_dealloc`` function does this, so if your type does *not* " @@ -544,8 +639,8 @@ msgstr "" #: howto/isolating-extensions.rst:429 msgid "" -"The :c:member:`~PyTypeObject.tp_free` slot of a heap type must be set to :c:" -"func:`PyObject_GC_Del`. This is the default; do not override it." +"The :c:member:`~PyTypeObject.tp_free` slot of a heap type must be set " +"to :c:func:`PyObject_GC_Del`. This is the default; do not override it." msgstr "" #: howto/isolating-extensions.rst:435 @@ -566,6 +661,10 @@ msgid "" "That is, replace ``TYPE *o = PyObject_New(TYPE, typeobj)`` with::" msgstr "" +#: howto/isolating-extensions.rst:444 +msgid "TYPE *o = typeobj->tp_alloc(typeobj, 0);" +msgstr "" + #: howto/isolating-extensions.rst:446 msgid "" "Replace ``o = PyObject_NewVar(TYPE, typeobj, size)`` with the same, but use " @@ -574,8 +673,15 @@ msgstr "" #: howto/isolating-extensions.rst:449 msgid "" -"If the above is not possible (e.g. inside a custom ``tp_alloc``), call :c:" -"func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`::" +"If the above is not possible (e.g. inside a custom ``tp_alloc``), " +"call :c:func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`::" +msgstr "" + +#: howto/isolating-extensions.rst:452 +msgid "" +"TYPE *o = PyObject_GC_New(TYPE, typeobj);\n" +"\n" +"TYPE *o = PyObject_GC_NewVar(TYPE, typeobj, size);" msgstr "" #: howto/isolating-extensions.rst:458 @@ -595,6 +701,14 @@ msgid "" "these two steps with :c:func:`PyType_GetModuleState`, resulting in::" msgstr "" +#: howto/isolating-extensions.rst:467 +msgid "" +"my_struct *state = (my_struct*)PyType_GetModuleState(type);\n" +"if (state == NULL) {\n" +" return NULL;\n" +"}" +msgstr "" + #: howto/isolating-extensions.rst:474 msgid "Module State Access from Regular Methods" msgstr "" @@ -623,16 +737,39 @@ msgstr "" #: howto/isolating-extensions.rst:490 msgid "" -"The following Python code can illustrate the concept. ``Base." -"get_defining_class`` returns ``Base`` even if ``type(self) == Sub``:" +"The following Python code can illustrate the concept. " +"``Base.get_defining_class`` returns ``Base`` even if ``type(self) == Sub``:" +msgstr "" + +#: howto/isolating-extensions.rst:494 +msgid "" +"class Base:\n" +" def get_type_of_self(self):\n" +" return type(self)\n" +"\n" +" def get_defining_class(self):\n" +" return __class__\n" +"\n" +"class Sub(Base):\n" +" pass" msgstr "" #: howto/isolating-extensions.rst:506 msgid "" -"For a method to get its \"defining class\", it must use the :ref:" -"`METH_METHOD | METH_FASTCALL | METH_KEYWORDS ` :c:type:`calling convention ` and the " -"corresponding :c:type:`PyCMethod` signature::" +"For a method to get its \"defining class\", it must use " +"the :ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS ` :c:type:`calling convention ` and " +"the corresponding :c:type:`PyCMethod` signature::" +msgstr "" + +#: howto/isolating-extensions.rst:511 +msgid "" +"PyObject *PyCMethod(\n" +" PyObject *self, // object the method was called on\n" +" PyTypeObject *defining_class, // defining class\n" +" PyObject *const *args, // C array of arguments\n" +" Py_ssize_t nargs, // length of \"args\"\n" +" PyObject *kwnames) // NULL, or dict of keyword arguments" msgstr "" #: howto/isolating-extensions.rst:518 @@ -645,6 +782,33 @@ msgstr "" msgid "For example::" msgstr "" +#: howto/isolating-extensions.rst:523 +msgid "" +"static PyObject *\n" +"example_method(PyObject *self,\n" +" PyTypeObject *defining_class,\n" +" PyObject *const *args,\n" +" Py_ssize_t nargs,\n" +" PyObject *kwnames)\n" +"{\n" +" my_struct *state = (my_struct*)PyType_GetModuleState(defining_class);\n" +" if (state == NULL) {\n" +" return NULL;\n" +" }\n" +" ... // rest of logic\n" +"}\n" +"\n" +"PyDoc_STRVAR(example_method_doc, \"...\");\n" +"\n" +"static PyMethodDef my_methods[] = {\n" +" {\"example_method\",\n" +" (PyCFunction)(void(*)(void))example_method,\n" +" METH_METHOD|METH_FASTCALL|METH_KEYWORDS,\n" +" example_method_doc}\n" +" {NULL},\n" +"}" +msgstr "" + #: howto/isolating-extensions.rst:549 msgid "Module State Access from Slot Methods, Getters and Setters" msgstr "" @@ -655,19 +819,29 @@ msgstr "" #: howto/isolating-extensions.rst:561 msgid "" -"Slot methods—the fast C equivalents for special methods, such as :c:member:" -"`~PyNumberMethods.nb_add` for :py:attr:`~object.__add__` or :c:member:" -"`~PyTypeObject.tp_new` for initialization—have a very simple API that " -"doesn't allow passing in the defining class, unlike with :c:type:" -"`PyCMethod`. The same goes for getters and setters defined with :c:type:" -"`PyGetSetDef`." +"Slot methods—the fast C equivalents for special methods, such " +"as :c:member:`~PyNumberMethods.nb_add` for :py:attr:`~object.__add__` " +"or :c:member:`~PyTypeObject.tp_new` for initialization—have a very simple " +"API that doesn't allow passing in the defining class, unlike " +"with :c:type:`PyCMethod`. The same goes for getters and setters defined " +"with :c:type:`PyGetSetDef`." msgstr "" #: howto/isolating-extensions.rst:568 msgid "" -"To access the module state in these cases, use the :c:func:" -"`PyType_GetModuleByDef` function, and pass in the module definition. Once " -"you have the module, call :c:func:`PyModule_GetState` to get the state::" +"To access the module state in these cases, use " +"the :c:func:`PyType_GetModuleByDef` function, and pass in the module " +"definition. Once you have the module, call :c:func:`PyModule_GetState` to " +"get the state::" +msgstr "" + +#: howto/isolating-extensions.rst:573 +msgid "" +"PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &module_def);\n" +"my_struct *state = (my_struct*)PyModule_GetState(module);\n" +"if (state == NULL) {\n" +" return NULL;\n" +"}" msgstr "" #: howto/isolating-extensions.rst:579 @@ -698,11 +872,11 @@ msgstr "" #: howto/isolating-extensions.rst:599 msgid "" -"Usually this is not an issue, because types created with :c:func:" -"`PyType_FromModuleAndSpec`, and their instances, hold a reference to the " -"module. However, you must be careful in reference counting when you " -"reference module state from other places, such as callbacks for external " -"libraries." +"Usually this is not an issue, because types created " +"with :c:func:`PyType_FromModuleAndSpec`, and their instances, hold a " +"reference to the module. However, you must be careful in reference counting " +"when you reference module state from other places, such as callbacks for " +"external libraries." msgstr "" #: howto/isolating-extensions.rst:608 diff --git a/howto/logging-cookbook.po b/howto/logging-cookbook.po index d9040d83..a269ae36 100644 --- a/howto/logging-cookbook.po +++ b/howto/logging-cookbook.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -51,14 +52,94 @@ msgid "" "module::" msgstr "" +#: howto/logging-cookbook.rst:26 +msgid "" +"import logging\n" +"import auxiliary_module\n" +"\n" +"# create logger with 'spam_application'\n" +"logger = logging.getLogger('spam_application')\n" +"logger.setLevel(logging.DEBUG)\n" +"# create file handler which logs even debug messages\n" +"fh = logging.FileHandler('spam.log')\n" +"fh.setLevel(logging.DEBUG)\n" +"# create console handler with a higher log level\n" +"ch = logging.StreamHandler()\n" +"ch.setLevel(logging.ERROR)\n" +"# create formatter and add it to the handlers\n" +"formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %" +"(message)s')\n" +"fh.setFormatter(formatter)\n" +"ch.setFormatter(formatter)\n" +"# add the handlers to the logger\n" +"logger.addHandler(fh)\n" +"logger.addHandler(ch)\n" +"\n" +"logger.info('creating an instance of auxiliary_module.Auxiliary')\n" +"a = auxiliary_module.Auxiliary()\n" +"logger.info('created an instance of auxiliary_module.Auxiliary')\n" +"logger.info('calling auxiliary_module.Auxiliary.do_something')\n" +"a.do_something()\n" +"logger.info('finished auxiliary_module.Auxiliary.do_something')\n" +"logger.info('calling auxiliary_module.some_function()')\n" +"auxiliary_module.some_function()\n" +"logger.info('done with auxiliary_module.some_function()')" +msgstr "" + #: howto/logging-cookbook.rst:56 msgid "Here is the auxiliary module::" msgstr "" +#: howto/logging-cookbook.rst:58 +msgid "" +"import logging\n" +"\n" +"# create logger\n" +"module_logger = logging.getLogger('spam_application.auxiliary')\n" +"\n" +"class Auxiliary:\n" +" def __init__(self):\n" +" self.logger = " +"logging.getLogger('spam_application.auxiliary.Auxiliary')\n" +" self.logger.info('creating an instance of Auxiliary')\n" +"\n" +" def do_something(self):\n" +" self.logger.info('doing something')\n" +" a = 1 + 1\n" +" self.logger.info('done doing something')\n" +"\n" +"def some_function():\n" +" module_logger.info('received a call to \"some_function\"')" +msgstr "" + #: howto/logging-cookbook.rst:76 msgid "The output looks like this:" msgstr "" +#: howto/logging-cookbook.rst:78 +msgid "" +"2005-03-23 23:47:11,663 - spam_application - INFO -\n" +" creating an instance of auxiliary_module.Auxiliary\n" +"2005-03-23 23:47:11,665 - spam_application.auxiliary.Auxiliary - INFO -\n" +" creating an instance of Auxiliary\n" +"2005-03-23 23:47:11,665 - spam_application - INFO -\n" +" created an instance of auxiliary_module.Auxiliary\n" +"2005-03-23 23:47:11,668 - spam_application - INFO -\n" +" calling auxiliary_module.Auxiliary.do_something\n" +"2005-03-23 23:47:11,668 - spam_application.auxiliary.Auxiliary - INFO -\n" +" doing something\n" +"2005-03-23 23:47:11,669 - spam_application.auxiliary.Auxiliary - INFO -\n" +" done doing something\n" +"2005-03-23 23:47:11,670 - spam_application - INFO -\n" +" finished auxiliary_module.Auxiliary.do_something\n" +"2005-03-23 23:47:11,671 - spam_application - INFO -\n" +" calling auxiliary_module.some_function()\n" +"2005-03-23 23:47:11,672 - spam_application.auxiliary - INFO -\n" +" received a call to 'some_function'\n" +"2005-03-23 23:47:11,673 - spam_application - INFO -\n" +" done with auxiliary_module.some_function()" +msgstr "" + #: howto/logging-cookbook.rst:102 msgid "Logging from multiple threads" msgstr "" @@ -69,10 +150,61 @@ msgid "" "example shows logging from the main (initial) thread and another thread::" msgstr "" +#: howto/logging-cookbook.rst:107 +msgid "" +"import logging\n" +"import threading\n" +"import time\n" +"\n" +"def worker(arg):\n" +" while not arg['stop']:\n" +" logging.debug('Hi from myfunc')\n" +" time.sleep(0.5)\n" +"\n" +"def main():\n" +" logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d %" +"(threadName)s %(message)s')\n" +" info = {'stop': False}\n" +" thread = threading.Thread(target=worker, args=(info,))\n" +" thread.start()\n" +" while True:\n" +" try:\n" +" logging.debug('Hello from main')\n" +" time.sleep(0.75)\n" +" except KeyboardInterrupt:\n" +" info['stop'] = True\n" +" break\n" +" thread.join()\n" +"\n" +"if __name__ == '__main__':\n" +" main()" +msgstr "" + #: howto/logging-cookbook.rst:133 msgid "When run, the script should print something like the following:" msgstr "" +#: howto/logging-cookbook.rst:135 +msgid "" +" 0 Thread-1 Hi from myfunc\n" +" 3 MainThread Hello from main\n" +" 505 Thread-1 Hi from myfunc\n" +" 755 MainThread Hello from main\n" +"1007 Thread-1 Hi from myfunc\n" +"1507 MainThread Hello from main\n" +"1508 Thread-1 Hi from myfunc\n" +"2010 Thread-1 Hi from myfunc\n" +"2258 MainThread Hello from main\n" +"2512 Thread-1 Hi from myfunc\n" +"3009 MainThread Hello from main\n" +"3013 Thread-1 Hi from myfunc\n" +"3515 Thread-1 Hi from myfunc\n" +"3761 MainThread Hello from main\n" +"4017 Thread-1 Hi from myfunc\n" +"4513 MainThread Hello from main\n" +"4518 Thread-1 Hi from myfunc" +msgstr "" + #: howto/logging-cookbook.rst:155 msgid "" "This shows the logging output interspersed as one might expect. This " @@ -95,6 +227,35 @@ msgid "" "example::" msgstr "" +#: howto/logging-cookbook.rst:169 +msgid "" +"import logging\n" +"\n" +"logger = logging.getLogger('simple_example')\n" +"logger.setLevel(logging.DEBUG)\n" +"# create file handler which logs even debug messages\n" +"fh = logging.FileHandler('spam.log')\n" +"fh.setLevel(logging.DEBUG)\n" +"# create console handler with a higher log level\n" +"ch = logging.StreamHandler()\n" +"ch.setLevel(logging.ERROR)\n" +"# create formatter and add it to the handlers\n" +"formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %" +"(message)s')\n" +"ch.setFormatter(formatter)\n" +"fh.setFormatter(formatter)\n" +"# add the handlers to logger\n" +"logger.addHandler(ch)\n" +"logger.addHandler(fh)\n" +"\n" +"# 'application' code\n" +"logger.debug('debug message')\n" +"logger.info('info message')\n" +"logger.warning('warn message')\n" +"logger.error('error message')\n" +"logger.critical('critical message')" +msgstr "" + #: howto/logging-cookbook.rst:194 msgid "" "Notice that the 'application' code does not care about multiple handlers. " @@ -127,14 +288,69 @@ msgid "" "console messages should not. Here's how you can achieve this::" msgstr "" +#: howto/logging-cookbook.rst:216 +msgid "" +"import logging\n" +"\n" +"# set up logging to file - see previous section for more details\n" +"logging.basicConfig(level=logging.DEBUG,\n" +" format='%(asctime)s %(name)-12s %(levelname)-8s %" +"(message)s',\n" +" datefmt='%m-%d %H:%M',\n" +" filename='/tmp/myapp.log',\n" +" filemode='w')\n" +"# define a Handler which writes INFO messages or higher to the sys.stderr\n" +"console = logging.StreamHandler()\n" +"console.setLevel(logging.INFO)\n" +"# set a format which is simpler for console use\n" +"formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')\n" +"# tell the handler to use this format\n" +"console.setFormatter(formatter)\n" +"# add the handler to the root logger\n" +"logging.getLogger('').addHandler(console)\n" +"\n" +"# Now, we can log to the root logger, or any other logger. First the " +"root...\n" +"logging.info('Jackdaws love my big sphinx of quartz.')\n" +"\n" +"# Now, define a couple of other loggers which might represent areas in your\n" +"# application:\n" +"\n" +"logger1 = logging.getLogger('myapp.area1')\n" +"logger2 = logging.getLogger('myapp.area2')\n" +"\n" +"logger1.debug('Quick zephyrs blow, vexing daft Jim.')\n" +"logger1.info('How quickly daft jumping zebras vex.')\n" +"logger2.warning('Jail zesty vixen who grabbed pay from quack.')\n" +"logger2.error('The five boxing wizards jump quickly.')" +msgstr "" + #: howto/logging-cookbook.rst:248 msgid "When you run this, on the console you will see" msgstr "" +#: howto/logging-cookbook.rst:250 +msgid "" +"root : INFO Jackdaws love my big sphinx of quartz.\n" +"myapp.area1 : INFO How quickly daft jumping zebras vex.\n" +"myapp.area2 : WARNING Jail zesty vixen who grabbed pay from quack.\n" +"myapp.area2 : ERROR The five boxing wizards jump quickly." +msgstr "" + #: howto/logging-cookbook.rst:257 msgid "and in the file you will see something like" msgstr "" +#: howto/logging-cookbook.rst:259 +msgid "" +"10-22 22:19 root INFO Jackdaws love my big sphinx of quartz.\n" +"10-22 22:19 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim.\n" +"10-22 22:19 myapp.area1 INFO How quickly daft jumping zebras vex.\n" +"10-22 22:19 myapp.area2 WARNING Jail zesty vixen who grabbed pay from " +"quack.\n" +"10-22 22:19 myapp.area2 ERROR The five boxing wizards jump quickly." +msgstr "" + #: howto/logging-cookbook.rst:267 msgid "" "As you can see, the DEBUG message only shows up in the file. The other " @@ -184,6 +400,47 @@ msgstr "" msgid "Suppose you configure logging with the following JSON:" msgstr "" +#: howto/logging-cookbook.rst:295 +msgid "" +"{\n" +" \"version\": 1,\n" +" \"disable_existing_loggers\": false,\n" +" \"formatters\": {\n" +" \"simple\": {\n" +" \"format\": \"%(levelname)-8s - %(message)s\"\n" +" }\n" +" },\n" +" \"handlers\": {\n" +" \"stdout\": {\n" +" \"class\": \"logging.StreamHandler\",\n" +" \"level\": \"INFO\",\n" +" \"formatter\": \"simple\",\n" +" \"stream\": \"ext://sys.stdout\"\n" +" },\n" +" \"stderr\": {\n" +" \"class\": \"logging.StreamHandler\",\n" +" \"level\": \"ERROR\",\n" +" \"formatter\": \"simple\",\n" +" \"stream\": \"ext://sys.stderr\"\n" +" },\n" +" \"file\": {\n" +" \"class\": \"logging.FileHandler\",\n" +" \"formatter\": \"simple\",\n" +" \"filename\": \"app.log\",\n" +" \"mode\": \"w\"\n" +" }\n" +" },\n" +" \"root\": {\n" +" \"level\": \"DEBUG\",\n" +" \"handlers\": [\n" +" \"stderr\",\n" +" \"stdout\",\n" +" \"file\"\n" +" ]\n" +" }\n" +"}" +msgstr "" + #: howto/logging-cookbook.rst:335 msgid "" "This configuration does *almost* what we want, except that ``sys.stdout`` " @@ -193,39 +450,171 @@ msgid "" "adding a ``filters`` section parallel to ``formatters`` and ``handlers``:" msgstr "" +#: howto/logging-cookbook.rst:341 +msgid "" +"{\n" +" \"filters\": {\n" +" \"warnings_and_below\": {\n" +" \"()\" : \"__main__.filter_maker\",\n" +" \"level\": \"WARNING\"\n" +" }\n" +" }\n" +"}" +msgstr "" + #: howto/logging-cookbook.rst:352 msgid "and changing the section on the ``stdout`` handler to add it:" msgstr "" +#: howto/logging-cookbook.rst:354 +msgid "" +"{\n" +" \"stdout\": {\n" +" \"class\": \"logging.StreamHandler\",\n" +" \"level\": \"INFO\",\n" +" \"formatter\": \"simple\",\n" +" \"stream\": \"ext://sys.stdout\",\n" +" \"filters\": [\"warnings_and_below\"]\n" +" }\n" +"}" +msgstr "" + #: howto/logging-cookbook.rst:366 msgid "" "A filter is just a function, so we can define the ``filter_maker`` (a " "factory function) as follows:" msgstr "" +#: howto/logging-cookbook.rst:369 +msgid "" +"def filter_maker(level):\n" +" level = getattr(logging, level)\n" +"\n" +" def filter(record):\n" +" return record.levelno <= level\n" +"\n" +" return filter" +msgstr "" + #: howto/logging-cookbook.rst:379 msgid "" "This converts the string argument passed in to a numeric level, and returns " "a function which only returns ``True`` if the level of the passed in record " "is at or below the specified level. Note that in this example I have defined " "the ``filter_maker`` in a test script ``main.py`` that I run from the " -"command line, so its module will be ``__main__`` - hence the ``__main__." -"filter_maker`` in the filter configuration. You will need to change that if " -"you define it in a different module." +"command line, so its module will be ``__main__`` - hence the " +"``__main__.filter_maker`` in the filter configuration. You will need to " +"change that if you define it in a different module." msgstr "" #: howto/logging-cookbook.rst:387 msgid "With the filter added, we can run ``main.py``, which in full is:" msgstr "" +#: howto/logging-cookbook.rst:389 +msgid "" +"import json\n" +"import logging\n" +"import logging.config\n" +"\n" +"CONFIG = '''\n" +"{\n" +" \"version\": 1,\n" +" \"disable_existing_loggers\": false,\n" +" \"formatters\": {\n" +" \"simple\": {\n" +" \"format\": \"%(levelname)-8s - %(message)s\"\n" +" }\n" +" },\n" +" \"filters\": {\n" +" \"warnings_and_below\": {\n" +" \"()\" : \"__main__.filter_maker\",\n" +" \"level\": \"WARNING\"\n" +" }\n" +" },\n" +" \"handlers\": {\n" +" \"stdout\": {\n" +" \"class\": \"logging.StreamHandler\",\n" +" \"level\": \"INFO\",\n" +" \"formatter\": \"simple\",\n" +" \"stream\": \"ext://sys.stdout\",\n" +" \"filters\": [\"warnings_and_below\"]\n" +" },\n" +" \"stderr\": {\n" +" \"class\": \"logging.StreamHandler\",\n" +" \"level\": \"ERROR\",\n" +" \"formatter\": \"simple\",\n" +" \"stream\": \"ext://sys.stderr\"\n" +" },\n" +" \"file\": {\n" +" \"class\": \"logging.FileHandler\",\n" +" \"formatter\": \"simple\",\n" +" \"filename\": \"app.log\",\n" +" \"mode\": \"w\"\n" +" }\n" +" },\n" +" \"root\": {\n" +" \"level\": \"DEBUG\",\n" +" \"handlers\": [\n" +" \"stderr\",\n" +" \"stdout\",\n" +" \"file\"\n" +" ]\n" +" }\n" +"}\n" +"'''\n" +"\n" +"def filter_maker(level):\n" +" level = getattr(logging, level)\n" +"\n" +" def filter(record):\n" +" return record.levelno <= level\n" +"\n" +" return filter\n" +"\n" +"logging.config.dictConfig(json.loads(CONFIG))\n" +"logging.debug('A DEBUG message')\n" +"logging.info('An INFO message')\n" +"logging.warning('A WARNING message')\n" +"logging.error('An ERROR message')\n" +"logging.critical('A CRITICAL message')" +msgstr "" + #: howto/logging-cookbook.rst:457 msgid "And after running it like this:" msgstr "" +#: howto/logging-cookbook.rst:459 +msgid "python main.py 2>stderr.log >stdout.log" +msgstr "" + #: howto/logging-cookbook.rst:463 msgid "We can see the results are as expected:" msgstr "" +#: howto/logging-cookbook.rst:465 +msgid "" +"$ more *.log\n" +"::::::::::::::\n" +"app.log\n" +"::::::::::::::\n" +"DEBUG - A DEBUG message\n" +"INFO - An INFO message\n" +"WARNING - A WARNING message\n" +"ERROR - An ERROR message\n" +"CRITICAL - A CRITICAL message\n" +"::::::::::::::\n" +"stderr.log\n" +"::::::::::::::\n" +"ERROR - An ERROR message\n" +"CRITICAL - A CRITICAL message\n" +"::::::::::::::\n" +"stdout.log\n" +"::::::::::::::\n" +"INFO - An INFO message\n" +"WARNING - A WARNING message" +msgstr "" + #: howto/logging-cookbook.rst:489 msgid "Configuration server example" msgstr "" @@ -234,6 +623,38 @@ msgstr "" msgid "Here is an example of a module using the logging configuration server::" msgstr "" +#: howto/logging-cookbook.rst:493 +msgid "" +"import logging\n" +"import logging.config\n" +"import time\n" +"import os\n" +"\n" +"# read initial config file\n" +"logging.config.fileConfig('logging.conf')\n" +"\n" +"# create and start listener on port 9999\n" +"t = logging.config.listen(9999)\n" +"t.start()\n" +"\n" +"logger = logging.getLogger('simpleExample')\n" +"\n" +"try:\n" +" # loop through logging calls to see the difference\n" +" # new configurations make, until Ctrl+C is pressed\n" +" while True:\n" +" logger.debug('debug message')\n" +" logger.info('info message')\n" +" logger.warning('warn message')\n" +" logger.error('error message')\n" +" logger.critical('critical message')\n" +" time.sleep(5)\n" +"except KeyboardInterrupt:\n" +" # cleanup\n" +" logging.config.stopListening()\n" +" t.join()" +msgstr "" + #: howto/logging-cookbook.rst:522 msgid "" "And here is a script that takes a filename and sends that file to the " @@ -241,6 +662,26 @@ msgid "" "configuration::" msgstr "" +#: howto/logging-cookbook.rst:526 +msgid "" +"#!/usr/bin/env python\n" +"import socket, sys, struct\n" +"\n" +"with open(sys.argv[1], 'rb') as f:\n" +" data_to_send = f.read()\n" +"\n" +"HOST = 'localhost'\n" +"PORT = 9999\n" +"s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" +"print('connecting...')\n" +"s.connect((HOST, PORT))\n" +"print('sending config...')\n" +"s.send(struct.pack('>L', len(data_to_send)))\n" +"s.send(data_to_send)\n" +"s.close()\n" +"print('complete')" +msgstr "" + #: howto/logging-cookbook.rst:547 msgid "Dealing with handlers that block" msgstr "" @@ -254,13 +695,13 @@ msgstr "" #: howto/logging-cookbook.rst:555 msgid "" -"A common culprit which demonstrates sluggish behaviour is the :class:" -"`SMTPHandler`: sending emails can take a long time, for a number of reasons " -"outside the developer's control (for example, a poorly performing mail or " -"network infrastructure). But almost any network-based handler can block: " -"Even a :class:`SocketHandler` operation may do a DNS query under the hood " -"which is too slow (and this query can be deep in the socket library code, " -"below the Python layer, and outside your control)." +"A common culprit which demonstrates sluggish behaviour is " +"the :class:`SMTPHandler`: sending emails can take a long time, for a number " +"of reasons outside the developer's control (for example, a poorly performing " +"mail or network infrastructure). But almost any network-based handler can " +"block: Even a :class:`SocketHandler` operation may do a DNS query under the " +"hood which is too slow (and this query can be deep in the socket library " +"code, below the Python layer, and outside your control)." msgstr "" #: howto/logging-cookbook.rst:563 @@ -280,12 +721,12 @@ msgstr "" #: howto/logging-cookbook.rst:574 msgid "" "The second part of the solution is :class:`QueueListener`, which has been " -"designed as the counterpart to :class:`QueueHandler`. A :class:" -"`QueueListener` is very simple: it's passed a queue and some handlers, and " -"it fires up an internal thread which listens to its queue for LogRecords " -"sent from ``QueueHandlers`` (or any other source of ``LogRecords``, for that " -"matter). The ``LogRecords`` are removed from the queue and passed to the " -"handlers for processing." +"designed as the counterpart to :class:`QueueHandler`. " +"A :class:`QueueListener` is very simple: it's passed a queue and some " +"handlers, and it fires up an internal thread which listens to its queue for " +"LogRecords sent from ``QueueHandlers`` (or any other source of " +"``LogRecords``, for that matter). The ``LogRecords`` are removed from the " +"queue and passed to the handlers for processing." msgstr "" #: howto/logging-cookbook.rst:582 @@ -301,19 +742,42 @@ msgstr "" msgid "An example of using these two classes follows (imports omitted)::" msgstr "" +#: howto/logging-cookbook.rst:589 +msgid "" +"que = queue.Queue(-1) # no limit on size\n" +"queue_handler = QueueHandler(que)\n" +"handler = logging.StreamHandler()\n" +"listener = QueueListener(que, handler)\n" +"root = logging.getLogger()\n" +"root.addHandler(queue_handler)\n" +"formatter = logging.Formatter('%(threadName)s: %(message)s')\n" +"handler.setFormatter(formatter)\n" +"listener.start()\n" +"# The log output will display the thread which generated\n" +"# the event (the main thread) rather than the internal\n" +"# thread which monitors the internal queue. This is what\n" +"# you want to happen.\n" +"root.warning('Look out!')\n" +"listener.stop()" +msgstr "" + #: howto/logging-cookbook.rst:605 msgid "which, when run, will produce:" msgstr "" +#: howto/logging-cookbook.rst:607 +msgid "MainThread: Look out!" +msgstr "" + #: howto/logging-cookbook.rst:611 msgid "" "Although the earlier discussion wasn't specifically talking about async " "code, but rather about slow logging handlers, it should be noted that when " "logging from async code, network and even file handlers could lead to " -"problems (blocking the event loop) because some logging is done from :mod:" -"`asyncio` internals. It might be best, if any async code is used in an " -"application, to use the above approach for logging, so that any blocking " -"code runs only in the ``QueueListener`` thread." +"problems (blocking the event loop) because some logging is done " +"from :mod:`asyncio` internals. It might be best, if any async code is used " +"in an application, to use the above approach for logging, so that any " +"blocking code runs only in the ``QueueListener`` thread." msgstr "" #: howto/logging-cookbook.rst:619 @@ -335,14 +799,133 @@ msgstr "" #: howto/logging-cookbook.rst:634 msgid "" "Let's say you want to send logging events across a network, and handle them " -"at the receiving end. A simple way of doing this is attaching a :class:" -"`SocketHandler` instance to the root logger at the sending end::" +"at the receiving end. A simple way of doing this is attaching " +"a :class:`SocketHandler` instance to the root logger at the sending end::" +msgstr "" + +#: howto/logging-cookbook.rst:638 +msgid "" +"import logging, logging.handlers\n" +"\n" +"rootLogger = logging.getLogger('')\n" +"rootLogger.setLevel(logging.DEBUG)\n" +"socketHandler = logging.handlers.SocketHandler('localhost',\n" +" logging.handlers.DEFAULT_TCP_LOGGING_PORT)\n" +"# don't bother with a formatter, since a socket handler sends the event as\n" +"# an unformatted pickle\n" +"rootLogger.addHandler(socketHandler)\n" +"\n" +"# Now, we can log to the root logger, or any other logger. First the " +"root...\n" +"logging.info('Jackdaws love my big sphinx of quartz.')\n" +"\n" +"# Now, define a couple of other loggers which might represent areas in your\n" +"# application:\n" +"\n" +"logger1 = logging.getLogger('myapp.area1')\n" +"logger2 = logging.getLogger('myapp.area2')\n" +"\n" +"logger1.debug('Quick zephyrs blow, vexing daft Jim.')\n" +"logger1.info('How quickly daft jumping zebras vex.')\n" +"logger2.warning('Jail zesty vixen who grabbed pay from quack.')\n" +"logger2.error('The five boxing wizards jump quickly.')" msgstr "" #: howto/logging-cookbook.rst:662 msgid "" -"At the receiving end, you can set up a receiver using the :mod:" -"`socketserver` module. Here is a basic working example::" +"At the receiving end, you can set up a receiver using " +"the :mod:`socketserver` module. Here is a basic working example::" +msgstr "" + +#: howto/logging-cookbook.rst:665 +msgid "" +"import pickle\n" +"import logging\n" +"import logging.handlers\n" +"import socketserver\n" +"import struct\n" +"\n" +"\n" +"class LogRecordStreamHandler(socketserver.StreamRequestHandler):\n" +" \"\"\"Handler for a streaming logging request.\n" +"\n" +" This basically logs the record using whatever logging policy is\n" +" configured locally.\n" +" \"\"\"\n" +"\n" +" def handle(self):\n" +" \"\"\"\n" +" Handle multiple requests - each expected to be a 4-byte length,\n" +" followed by the LogRecord in pickle format. Logs the record\n" +" according to whatever policy is configured locally.\n" +" \"\"\"\n" +" while True:\n" +" chunk = self.connection.recv(4)\n" +" if len(chunk) < 4:\n" +" break\n" +" slen = struct.unpack('>L', chunk)[0]\n" +" chunk = self.connection.recv(slen)\n" +" while len(chunk) < slen:\n" +" chunk = chunk + self.connection.recv(slen - len(chunk))\n" +" obj = self.unPickle(chunk)\n" +" record = logging.makeLogRecord(obj)\n" +" self.handleLogRecord(record)\n" +"\n" +" def unPickle(self, data):\n" +" return pickle.loads(data)\n" +"\n" +" def handleLogRecord(self, record):\n" +" # if a name is specified, we use the named logger rather than the " +"one\n" +" # implied by the record.\n" +" if self.server.logname is not None:\n" +" name = self.server.logname\n" +" else:\n" +" name = record.name\n" +" logger = logging.getLogger(name)\n" +" # N.B. EVERY record gets logged. This is because Logger.handle\n" +" # is normally called AFTER logger-level filtering. If you want\n" +" # to do filtering, do it at the client end to save wasting\n" +" # cycles and network bandwidth!\n" +" logger.handle(record)\n" +"\n" +"class LogRecordSocketReceiver(socketserver.ThreadingTCPServer):\n" +" \"\"\"\n" +" Simple TCP socket-based logging receiver suitable for testing.\n" +" \"\"\"\n" +"\n" +" allow_reuse_address = True\n" +"\n" +" def __init__(self, host='localhost',\n" +" port=logging.handlers.DEFAULT_TCP_LOGGING_PORT,\n" +" handler=LogRecordStreamHandler):\n" +" socketserver.ThreadingTCPServer.__init__(self, (host, port), " +"handler)\n" +" self.abort = 0\n" +" self.timeout = 1\n" +" self.logname = None\n" +"\n" +" def serve_until_stopped(self):\n" +" import select\n" +" abort = 0\n" +" while not abort:\n" +" rd, wr, ex = select.select([self.socket.fileno()],\n" +" [], [],\n" +" self.timeout)\n" +" if rd:\n" +" self.handle_request()\n" +" abort = self.abort\n" +"\n" +"def main():\n" +" logging.basicConfig(\n" +" format='%(relativeCreated)5d %(name)-15s %(levelname)-8s %" +"(message)s')\n" +" tcpserver = LogRecordSocketReceiver()\n" +" print('About to start TCP server...')\n" +" tcpserver.serve_until_stopped()\n" +"\n" +"if __name__ == '__main__':\n" +" main()" msgstr "" #: howto/logging-cookbook.rst:750 @@ -351,6 +934,16 @@ msgid "" "printed on the console; on the server side, you should see something like:" msgstr "" +#: howto/logging-cookbook.rst:753 +msgid "" +"About to start TCP server...\n" +" 59 root INFO Jackdaws love my big sphinx of quartz.\n" +" 59 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim.\n" +" 69 myapp.area1 INFO How quickly daft jumping zebras vex.\n" +" 69 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack.\n" +" 69 myapp.area2 ERROR The five boxing wizards jump quickly." +msgstr "" + #: howto/logging-cookbook.rst:762 msgid "" "Note that there are some security issues with pickle in some scenarios. If " @@ -459,8 +1052,8 @@ msgstr "" #: howto/logging-cookbook.rst:811 msgid "" -"Download `the Gist `__ as a ZIP archive using the :" -"guilabel:`Download ZIP` button." +"Download `the Gist `__ as a ZIP archive using " +"the :guilabel:`Download ZIP` button." msgstr "" #: howto/logging-cookbook.rst:814 @@ -523,8 +1116,8 @@ msgid "" "is not a good idea because these instances are not garbage collected. While " "this is not a problem in practice, when the number of :class:`Logger` " "instances is dependent on the level of granularity you want to use in " -"logging an application, it could be hard to manage if the number of :class:" -"`Logger` instances becomes effectively unbounded." +"logging an application, it could be hard to manage if the number " +"of :class:`Logger` instances becomes effectively unbounded." msgstr "" #: howto/logging-cookbook.rst:860 @@ -535,22 +1128,33 @@ msgstr "" msgid "" "An easy way in which you can pass contextual information to be output along " "with logging event information is to use the :class:`LoggerAdapter` class. " -"This class is designed to look like a :class:`Logger`, so that you can call :" -"meth:`debug`, :meth:`info`, :meth:`warning`, :meth:`error`, :meth:" -"`exception`, :meth:`critical` and :meth:`log`. These methods have the same " -"signatures as their counterparts in :class:`Logger`, so you can use the two " -"types of instances interchangeably." +"This class is designed to look like a :class:`Logger`, so that you can " +"call :meth:`debug`, :meth:`info`, :meth:`warning`, :meth:`error`, :meth:`exception`, :meth:`critical` " +"and :meth:`log`. These methods have the same signatures as their " +"counterparts in :class:`Logger`, so you can use the two types of instances " +"interchangeably." msgstr "" #: howto/logging-cookbook.rst:870 msgid "" -"When you create an instance of :class:`LoggerAdapter`, you pass it a :class:" -"`Logger` instance and a dict-like object which contains your contextual " -"information. When you call one of the logging methods on an instance of :" -"class:`LoggerAdapter`, it delegates the call to the underlying instance of :" -"class:`Logger` passed to its constructor, and arranges to pass the " -"contextual information in the delegated call. Here's a snippet from the code " -"of :class:`LoggerAdapter`::" +"When you create an instance of :class:`LoggerAdapter`, you pass it " +"a :class:`Logger` instance and a dict-like object which contains your " +"contextual information. When you call one of the logging methods on an " +"instance of :class:`LoggerAdapter`, it delegates the call to the underlying " +"instance of :class:`Logger` passed to its constructor, and arranges to pass " +"the contextual information in the delegated call. Here's a snippet from the " +"code of :class:`LoggerAdapter`::" +msgstr "" + +#: howto/logging-cookbook.rst:878 +msgid "" +"def debug(self, msg, /, *args, **kwargs):\n" +" \"\"\"\n" +" Delegate a debug call to the underlying logger, after adding\n" +" contextual information from this adapter instance.\n" +" \"\"\"\n" +" msg, kwargs = self.process(msg, kwargs)\n" +" self.logger.debug(msg, *args, **kwargs)" msgstr "" #: howto/logging-cookbook.rst:886 @@ -573,14 +1177,32 @@ msgid "" "use customized strings with your :class:`Formatter` instances which know " "about the keys of the dict-like object. If you need a different method, e.g. " "if you want to prepend or append the contextual information to the message " -"string, you just need to subclass :class:`LoggerAdapter` and override :meth:" -"`~LoggerAdapter.process` to do what you need. Here is a simple example::" +"string, you just need to subclass :class:`LoggerAdapter` and " +"override :meth:`~LoggerAdapter.process` to do what you need. Here is a " +"simple example::" +msgstr "" + +#: howto/logging-cookbook.rst:903 +msgid "" +"class CustomAdapter(logging.LoggerAdapter):\n" +" \"\"\"\n" +" This example adapter expects the passed in dict-like object to have a\n" +" 'connid' key, whose value in brackets is prepended to the log message.\n" +" \"\"\"\n" +" def process(self, msg, kwargs):\n" +" return '[%s] %s' % (self.extra['connid'], msg), kwargs" msgstr "" #: howto/logging-cookbook.rst:911 msgid "which you can use like this::" msgstr "" +#: howto/logging-cookbook.rst:913 +msgid "" +"logger = logging.getLogger(__name__)\n" +"adapter = CustomAdapter(logger, {'connid': some_conn_id})" +msgstr "" + #: howto/logging-cookbook.rst:916 msgid "" "Then any events that you log to the adapter will have the value of " @@ -606,29 +1228,100 @@ msgstr "" #: howto/logging-cookbook.rst:933 msgid "" -"You can also add contextual information to log output using a user-defined :" -"class:`Filter`. ``Filter`` instances are allowed to modify the " +"You can also add contextual information to log output using a user-" +"defined :class:`Filter`. ``Filter`` instances are allowed to modify the " "``LogRecords`` passed to them, including adding additional attributes which " -"can then be output using a suitable format string, or if needed a custom :" -"class:`Formatter`." +"can then be output using a suitable format string, or if needed a " +"custom :class:`Formatter`." msgstr "" #: howto/logging-cookbook.rst:938 msgid "" "For example in a web application, the request being processed (or at least, " -"the interesting parts of it) can be stored in a threadlocal (:class:" -"`threading.local`) variable, and then accessed from a ``Filter`` to add, " -"say, information from the request - say, the remote IP address and remote " -"user's username - to the ``LogRecord``, using the attribute names 'ip' and " -"'user' as in the ``LoggerAdapter`` example above. In that case, the same " -"format string can be used to get similar output to that shown above. Here's " -"an example script::" +"the interesting parts of it) can be stored in a threadlocal " +"(:class:`threading.local`) variable, and then accessed from a ``Filter`` to " +"add, say, information from the request - say, the remote IP address and " +"remote user's username - to the ``LogRecord``, using the attribute names " +"'ip' and 'user' as in the ``LoggerAdapter`` example above. In that case, the " +"same format string can be used to get similar output to that shown above. " +"Here's an example script::" +msgstr "" + +#: howto/logging-cookbook.rst:947 +msgid "" +"import logging\n" +"from random import choice\n" +"\n" +"class ContextFilter(logging.Filter):\n" +" \"\"\"\n" +" This is a filter which injects contextual information into the log.\n" +"\n" +" Rather than use actual contextual information, we just use random\n" +" data in this demo.\n" +" \"\"\"\n" +"\n" +" USERS = ['jim', 'fred', 'sheila']\n" +" IPS = ['123.231.231.123', '127.0.0.1', '192.168.0.1']\n" +"\n" +" def filter(self, record):\n" +"\n" +" record.ip = choice(ContextFilter.IPS)\n" +" record.user = choice(ContextFilter.USERS)\n" +" return True\n" +"\n" +"if __name__ == '__main__':\n" +" levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, " +"logging.CRITICAL)\n" +" logging.basicConfig(level=logging.DEBUG,\n" +" format='%(asctime)-15s %(name)-5s %(levelname)-8s " +"IP: %(ip)-15s User: %(user)-8s %(message)s')\n" +" a1 = logging.getLogger('a.b.c')\n" +" a2 = logging.getLogger('d.e.f')\n" +"\n" +" f = ContextFilter()\n" +" a1.addFilter(f)\n" +" a2.addFilter(f)\n" +" a1.debug('A debug message')\n" +" a1.info('An info message with %s', 'some parameters')\n" +" for x in range(10):\n" +" lvl = choice(levels)\n" +" lvlname = logging.getLevelName(lvl)\n" +" a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, " +"'parameters')" msgstr "" #: howto/logging-cookbook.rst:984 msgid "which, when run, produces something like:" msgstr "" +#: howto/logging-cookbook.rst:986 +msgid "" +"2010-09-06 22:38:15,292 a.b.c DEBUG IP: 123.231.231.123 User: fred A " +"debug message\n" +"2010-09-06 22:38:15,300 a.b.c INFO IP: 192.168.0.1 User: sheila An " +"info message with some parameters\n" +"2010-09-06 22:38:15,300 d.e.f CRITICAL IP: 127.0.0.1 User: sheila A " +"message at CRITICAL level with 2 parameters\n" +"2010-09-06 22:38:15,300 d.e.f ERROR IP: 127.0.0.1 User: jim A " +"message at ERROR level with 2 parameters\n" +"2010-09-06 22:38:15,300 d.e.f DEBUG IP: 127.0.0.1 User: sheila A " +"message at DEBUG level with 2 parameters\n" +"2010-09-06 22:38:15,300 d.e.f ERROR IP: 123.231.231.123 User: fred A " +"message at ERROR level with 2 parameters\n" +"2010-09-06 22:38:15,300 d.e.f CRITICAL IP: 192.168.0.1 User: jim A " +"message at CRITICAL level with 2 parameters\n" +"2010-09-06 22:38:15,300 d.e.f CRITICAL IP: 127.0.0.1 User: sheila A " +"message at CRITICAL level with 2 parameters\n" +"2010-09-06 22:38:15,300 d.e.f DEBUG IP: 192.168.0.1 User: jim A " +"message at DEBUG level with 2 parameters\n" +"2010-09-06 22:38:15,301 d.e.f ERROR IP: 127.0.0.1 User: sheila A " +"message at ERROR level with 2 parameters\n" +"2010-09-06 22:38:15,301 d.e.f DEBUG IP: 123.231.231.123 User: fred A " +"message at DEBUG level with 2 parameters\n" +"2010-09-06 22:38:15,301 d.e.f INFO IP: 123.231.231.123 User: fred A " +"message at INFO level with 2 parameters" +msgstr "" + #: howto/logging-cookbook.rst:1002 msgid "Use of ``contextvars``" msgstr "" @@ -658,6 +1351,21 @@ msgstr "" msgid "Let's assume that the library can be simulated by the following code:" msgstr "" +#: howto/logging-cookbook.rst:1019 +msgid "" +"# webapplib.py\n" +"import logging\n" +"import time\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"def useful():\n" +" # Just a representative event logged from the library\n" +" logger.debug('Hello from webapplib!')\n" +" # Just sleep for a bit so other threads get to run\n" +" time.sleep(0.01)" +msgstr "" + #: howto/logging-cookbook.rst:1033 msgid "" "We can simulate the multiple web applications by means of two simple " @@ -665,6 +1373,161 @@ msgid "" "applications work - each request is handled by a thread:" msgstr "" +#: howto/logging-cookbook.rst:1037 +msgid "" +"# main.py\n" +"import argparse\n" +"from contextvars import ContextVar\n" +"import logging\n" +"import os\n" +"from random import choice\n" +"import threading\n" +"import webapplib\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"root = logging.getLogger()\n" +"root.setLevel(logging.DEBUG)\n" +"\n" +"class Request:\n" +" \"\"\"\n" +" A simple dummy request class which just holds dummy HTTP request " +"method,\n" +" client IP address and client username\n" +" \"\"\"\n" +" def __init__(self, method, ip, user):\n" +" self.method = method\n" +" self.ip = ip\n" +" self.user = user\n" +"\n" +"# A dummy set of requests which will be used in the simulation - we'll just " +"pick\n" +"# from this list randomly. Note that all GET requests are from " +"192.168.2.XXX\n" +"# addresses, whereas POST requests are from 192.16.3.XXX addresses. Three " +"users\n" +"# are represented in the sample requests.\n" +"\n" +"REQUESTS = [\n" +" Request('GET', '192.168.2.20', 'jim'),\n" +" Request('POST', '192.168.3.20', 'fred'),\n" +" Request('GET', '192.168.2.21', 'sheila'),\n" +" Request('POST', '192.168.3.21', 'jim'),\n" +" Request('GET', '192.168.2.22', 'fred'),\n" +" Request('POST', '192.168.3.22', 'sheila'),\n" +"]\n" +"\n" +"# Note that the format string includes references to request context " +"information\n" +"# such as HTTP method, client IP and username\n" +"\n" +"formatter = logging.Formatter('%(threadName)-11s %(appName)s %(name)-9s %" +"(user)-6s %(ip)s %(method)-4s %(message)s')\n" +"\n" +"# Create our context variables. These will be filled at the start of " +"request\n" +"# processing, and used in the logging that happens during that processing\n" +"\n" +"ctx_request = ContextVar('request')\n" +"ctx_appname = ContextVar('appname')\n" +"\n" +"class InjectingFilter(logging.Filter):\n" +" \"\"\"\n" +" A filter which injects context-specific information into logs and " +"ensures\n" +" that only information for a specific webapp is included in its log\n" +" \"\"\"\n" +" def __init__(self, app):\n" +" self.app = app\n" +"\n" +" def filter(self, record):\n" +" request = ctx_request.get()\n" +" record.method = request.method\n" +" record.ip = request.ip\n" +" record.user = request.user\n" +" record.appName = appName = ctx_appname.get()\n" +" return appName == self.app.name\n" +"\n" +"class WebApp:\n" +" \"\"\"\n" +" A dummy web application class which has its own handler and filter for " +"a\n" +" webapp-specific log.\n" +" \"\"\"\n" +" def __init__(self, name):\n" +" self.name = name\n" +" handler = logging.FileHandler(name + '.log', 'w')\n" +" f = InjectingFilter(self)\n" +" handler.setFormatter(formatter)\n" +" handler.addFilter(f)\n" +" root.addHandler(handler)\n" +" self.num_requests = 0\n" +"\n" +" def process_request(self, request):\n" +" \"\"\"\n" +" This is the dummy method for processing a request. It's called on a\n" +" different thread for every request. We store the context information " +"into\n" +" the context vars before doing anything else.\n" +" \"\"\"\n" +" ctx_request.set(request)\n" +" ctx_appname.set(self.name)\n" +" self.num_requests += 1\n" +" logger.debug('Request processing started')\n" +" webapplib.useful()\n" +" logger.debug('Request processing finished')\n" +"\n" +"def main():\n" +" fn = os.path.splitext(os.path.basename(__file__))[0]\n" +" adhf = argparse.ArgumentDefaultsHelpFormatter\n" +" ap = argparse.ArgumentParser(formatter_class=adhf, prog=fn,\n" +" description='Simulate a couple of web '\n" +" 'applications handling some '\n" +" 'requests, showing how request " +"'\n" +" 'context can be used to '\n" +" 'populate logs')\n" +" aa = ap.add_argument\n" +" aa('--count', '-c', type=int, default=100, help='How many requests to " +"simulate')\n" +" options = ap.parse_args()\n" +"\n" +" # Create the dummy webapps and put them in a list which we can use to " +"select\n" +" # from randomly\n" +" app1 = WebApp('app1')\n" +" app2 = WebApp('app2')\n" +" apps = [app1, app2]\n" +" threads = []\n" +" # Add a common handler which will capture all events\n" +" handler = logging.FileHandler('app.log', 'w')\n" +" handler.setFormatter(formatter)\n" +" root.addHandler(handler)\n" +"\n" +" # Generate calls to process requests\n" +" for i in range(options.count):\n" +" try:\n" +" # Pick an app at random and a request for it to process\n" +" app = choice(apps)\n" +" request = choice(REQUESTS)\n" +" # Process the request in its own thread\n" +" t = threading.Thread(target=app.process_request, " +"args=(request,))\n" +" threads.append(t)\n" +" t.start()\n" +" except KeyboardInterrupt:\n" +" break\n" +"\n" +" # Wait for the threads to terminate\n" +" for t in threads:\n" +" t.join()\n" +"\n" +" for app in apps:\n" +" print('%s processed %s requests' % (app.name, app.num_requests))\n" +"\n" +"if __name__ == '__main__':\n" +" main()" +msgstr "" + #: howto/logging-cookbook.rst:1177 msgid "" "If you run the above, you should find that roughly half the requests go " @@ -676,6 +1539,61 @@ msgid "" "illustrated by the following shell output:" msgstr "" +#: howto/logging-cookbook.rst:1184 +msgid "" +"~/logging-contextual-webapp$ python main.py\n" +"app1 processed 51 requests\n" +"app2 processed 49 requests\n" +"~/logging-contextual-webapp$ wc -l *.log\n" +" 153 app1.log\n" +" 147 app2.log\n" +" 300 app.log\n" +" 600 total\n" +"~/logging-contextual-webapp$ head -3 app1.log\n" +"Thread-3 (process_request) app1 __main__ jim 192.168.3.21 POST Request " +"processing started\n" +"Thread-3 (process_request) app1 webapplib jim 192.168.3.21 POST Hello " +"from webapplib!\n" +"Thread-5 (process_request) app1 __main__ jim 192.168.3.21 POST Request " +"processing started\n" +"~/logging-contextual-webapp$ head -3 app2.log\n" +"Thread-1 (process_request) app2 __main__ sheila 192.168.2.21 GET Request " +"processing started\n" +"Thread-1 (process_request) app2 webapplib sheila 192.168.2.21 GET Hello " +"from webapplib!\n" +"Thread-2 (process_request) app2 __main__ jim 192.168.2.20 GET Request " +"processing started\n" +"~/logging-contextual-webapp$ head app.log\n" +"Thread-1 (process_request) app2 __main__ sheila 192.168.2.21 GET Request " +"processing started\n" +"Thread-1 (process_request) app2 webapplib sheila 192.168.2.21 GET Hello " +"from webapplib!\n" +"Thread-2 (process_request) app2 __main__ jim 192.168.2.20 GET Request " +"processing started\n" +"Thread-3 (process_request) app1 __main__ jim 192.168.3.21 POST Request " +"processing started\n" +"Thread-2 (process_request) app2 webapplib jim 192.168.2.20 GET Hello " +"from webapplib!\n" +"Thread-3 (process_request) app1 webapplib jim 192.168.3.21 POST Hello " +"from webapplib!\n" +"Thread-4 (process_request) app2 __main__ fred 192.168.2.22 GET Request " +"processing started\n" +"Thread-5 (process_request) app1 __main__ jim 192.168.3.21 POST Request " +"processing started\n" +"Thread-4 (process_request) app2 webapplib fred 192.168.2.22 GET Hello " +"from webapplib!\n" +"Thread-6 (process_request) app1 __main__ jim 192.168.3.21 POST Request " +"processing started\n" +"~/logging-contextual-webapp$ grep app1 app1.log | wc -l\n" +"153\n" +"~/logging-contextual-webapp$ grep app2 app2.log | wc -l\n" +"147\n" +"~/logging-contextual-webapp$ grep app1 app.log | wc -l\n" +"153\n" +"~/logging-contextual-webapp$ grep app2 app.log | wc -l\n" +"147" +msgstr "" + #: howto/logging-cookbook.rst:1224 msgid "Imparting contextual information in handlers" msgstr "" @@ -688,6 +1606,28 @@ msgid "" "instead of modifying it in-place, as shown in the following script::" msgstr "" +#: howto/logging-cookbook.rst:1231 +msgid "" +"import copy\n" +"import logging\n" +"\n" +"def filter(record: logging.LogRecord):\n" +" record = copy.copy(record)\n" +" record.user = 'jim'\n" +" return record\n" +"\n" +"if __name__ == '__main__':\n" +" logger = logging.getLogger()\n" +" logger.setLevel(logging.INFO)\n" +" handler = logging.StreamHandler()\n" +" formatter = logging.Formatter('%(message)s from %(user)-8s')\n" +" handler.setFormatter(formatter)\n" +" handler.addFilter(filter)\n" +" logger.addHandler(handler)\n" +"\n" +" logger.info('A log message')" +msgstr "" + #: howto/logging-cookbook.rst:1253 msgid "Logging to a single file from multiple processes" msgstr "" @@ -702,21 +1642,22 @@ msgid "" "this is to have all the processes log to a :class:`~handlers.SocketHandler`, " "and have a separate process which implements a socket server which reads " "from the socket and logs to file. (If you prefer, you can dedicate one " -"thread in one of the existing processes to perform this function.) :ref:" -"`This section ` documents this approach in more detail and " -"includes a working socket receiver which can be used as a starting point for " -"you to adapt in your own applications." +"thread in one of the existing processes to perform this " +"function.) :ref:`This section ` documents this approach in " +"more detail and includes a working socket receiver which can be used as a " +"starting point for you to adapt in your own applications." msgstr "" #: howto/logging-cookbook.rst:1268 msgid "" -"You could also write your own handler which uses the :class:" -"`~multiprocessing.Lock` class from the :mod:`multiprocessing` module to " -"serialize access to the file from your processes. The existing :class:" -"`FileHandler` and subclasses do not make use of :mod:`multiprocessing` at " -"present, though they may do so in the future. Note that at present, the :mod:" -"`multiprocessing` module does not provide working lock functionality on all " -"platforms (see https://bugs.python.org/issue3770)." +"You could also write your own handler which uses " +"the :class:`~multiprocessing.Lock` class from the :mod:`multiprocessing` " +"module to serialize access to the file from your processes. The " +"existing :class:`FileHandler` and subclasses do not make use " +"of :mod:`multiprocessing` at present, though they may do so in the future. " +"Note that at present, the :mod:`multiprocessing` module does not provide " +"working lock functionality on all platforms (see https://bugs.python.org/" +"issue3770)." msgstr "" #: howto/logging-cookbook.rst:1278 @@ -734,12 +1675,229 @@ msgid "" "requirements::" msgstr "" +#: howto/logging-cookbook.rst:1289 +msgid "" +"# You'll need these imports in your own code\n" +"import logging\n" +"import logging.handlers\n" +"import multiprocessing\n" +"\n" +"# Next two import lines for this demo only\n" +"from random import choice, random\n" +"import time\n" +"\n" +"#\n" +"# Because you'll want to define the logging configurations for listener and " +"workers, the\n" +"# listener and worker process functions take a configurer parameter which is " +"a callable\n" +"# for configuring logging for that process. These functions are also passed " +"the queue,\n" +"# which they use for communication.\n" +"#\n" +"# In practice, you can configure the listener however you want, but note " +"that in this\n" +"# simple example, the listener does not apply level or filter logic to " +"received records.\n" +"# In practice, you would probably want to do this logic in the worker " +"processes, to avoid\n" +"# sending events which would be filtered out between processes.\n" +"#\n" +"# The size of the rotated files is made small so you can see the results " +"easily.\n" +"def listener_configurer():\n" +" root = logging.getLogger()\n" +" h = logging.handlers.RotatingFileHandler('mptest.log', 'a', 300, 10)\n" +" f = logging.Formatter('%(asctime)s %(processName)-10s %(name)s %" +"(levelname)-8s %(message)s')\n" +" h.setFormatter(f)\n" +" root.addHandler(h)\n" +"\n" +"# This is the listener process top-level loop: wait for logging events\n" +"# (LogRecords)on the queue and handle them, quit when you get a None for a\n" +"# LogRecord.\n" +"def listener_process(queue, configurer):\n" +" configurer()\n" +" while True:\n" +" try:\n" +" record = queue.get()\n" +" if record is None: # We send this as a sentinel to tell the " +"listener to quit.\n" +" break\n" +" logger = logging.getLogger(record.name)\n" +" logger.handle(record) # No level or filter logic applied - just " +"do it!\n" +" except Exception:\n" +" import sys, traceback\n" +" print('Whoops! Problem:', file=sys.stderr)\n" +" traceback.print_exc(file=sys.stderr)\n" +"\n" +"# Arrays used for random selections in this demo\n" +"\n" +"LEVELS = [logging.DEBUG, logging.INFO, logging.WARNING,\n" +" logging.ERROR, logging.CRITICAL]\n" +"\n" +"LOGGERS = ['a.b.c', 'd.e.f']\n" +"\n" +"MESSAGES = [\n" +" 'Random message #1',\n" +" 'Random message #2',\n" +" 'Random message #3',\n" +"]\n" +"\n" +"# The worker configuration is done at the start of the worker process run.\n" +"# Note that on Windows you can't rely on fork semantics, so each process\n" +"# will run the logging configuration code when it starts.\n" +"def worker_configurer(queue):\n" +" h = logging.handlers.QueueHandler(queue) # Just the one handler needed\n" +" root = logging.getLogger()\n" +" root.addHandler(h)\n" +" # send all messages, for demo; no other level or filter logic applied.\n" +" root.setLevel(logging.DEBUG)\n" +"\n" +"# This is the worker process top-level loop, which just logs ten events " +"with\n" +"# random intervening delays before terminating.\n" +"# The print messages are just so you know it's doing something!\n" +"def worker_process(queue, configurer):\n" +" configurer(queue)\n" +" name = multiprocessing.current_process().name\n" +" print('Worker started: %s' % name)\n" +" for i in range(10):\n" +" time.sleep(random())\n" +" logger = logging.getLogger(choice(LOGGERS))\n" +" level = choice(LEVELS)\n" +" message = choice(MESSAGES)\n" +" logger.log(level, message)\n" +" print('Worker finished: %s' % name)\n" +"\n" +"# Here's where the demo gets orchestrated. Create the queue, create and " +"start\n" +"# the listener, create ten workers and start them, wait for them to finish,\n" +"# then send a None to the queue to tell the listener to finish.\n" +"def main():\n" +" queue = multiprocessing.Queue(-1)\n" +" listener = multiprocessing.Process(target=listener_process,\n" +" args=(queue, listener_configurer))\n" +" listener.start()\n" +" workers = []\n" +" for i in range(10):\n" +" worker = multiprocessing.Process(target=worker_process,\n" +" args=(queue, worker_configurer))\n" +" workers.append(worker)\n" +" worker.start()\n" +" for w in workers:\n" +" w.join()\n" +" queue.put_nowait(None)\n" +" listener.join()\n" +"\n" +"if __name__ == '__main__':\n" +" main()" +msgstr "" + #: howto/logging-cookbook.rst:1394 msgid "" "A variant of the above script keeps the logging in the main process, in a " "separate thread::" msgstr "" +#: howto/logging-cookbook.rst:1397 +msgid "" +"import logging\n" +"import logging.config\n" +"import logging.handlers\n" +"from multiprocessing import Process, Queue\n" +"import random\n" +"import threading\n" +"import time\n" +"\n" +"def logger_thread(q):\n" +" while True:\n" +" record = q.get()\n" +" if record is None:\n" +" break\n" +" logger = logging.getLogger(record.name)\n" +" logger.handle(record)\n" +"\n" +"\n" +"def worker_process(q):\n" +" qh = logging.handlers.QueueHandler(q)\n" +" root = logging.getLogger()\n" +" root.setLevel(logging.DEBUG)\n" +" root.addHandler(qh)\n" +" levels = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,\n" +" logging.CRITICAL]\n" +" loggers = ['foo', 'foo.bar', 'foo.bar.baz',\n" +" 'spam', 'spam.ham', 'spam.ham.eggs']\n" +" for i in range(100):\n" +" lvl = random.choice(levels)\n" +" logger = logging.getLogger(random.choice(loggers))\n" +" logger.log(lvl, 'Message no. %d', i)\n" +"\n" +"if __name__ == '__main__':\n" +" q = Queue()\n" +" d = {\n" +" 'version': 1,\n" +" 'formatters': {\n" +" 'detailed': {\n" +" 'class': 'logging.Formatter',\n" +" 'format': '%(asctime)s %(name)-15s %(levelname)-8s %" +"(processName)-10s %(message)s'\n" +" }\n" +" },\n" +" 'handlers': {\n" +" 'console': {\n" +" 'class': 'logging.StreamHandler',\n" +" 'level': 'INFO',\n" +" },\n" +" 'file': {\n" +" 'class': 'logging.FileHandler',\n" +" 'filename': 'mplog.log',\n" +" 'mode': 'w',\n" +" 'formatter': 'detailed',\n" +" },\n" +" 'foofile': {\n" +" 'class': 'logging.FileHandler',\n" +" 'filename': 'mplog-foo.log',\n" +" 'mode': 'w',\n" +" 'formatter': 'detailed',\n" +" },\n" +" 'errors': {\n" +" 'class': 'logging.FileHandler',\n" +" 'filename': 'mplog-errors.log',\n" +" 'mode': 'w',\n" +" 'level': 'ERROR',\n" +" 'formatter': 'detailed',\n" +" },\n" +" },\n" +" 'loggers': {\n" +" 'foo': {\n" +" 'handlers': ['foofile']\n" +" }\n" +" },\n" +" 'root': {\n" +" 'level': 'DEBUG',\n" +" 'handlers': ['console', 'file', 'errors']\n" +" },\n" +" }\n" +" workers = []\n" +" for i in range(5):\n" +" wp = Process(target=worker_process, name='worker %d' % (i + 1), " +"args=(q,))\n" +" workers.append(wp)\n" +" wp.start()\n" +" logging.config.dictConfig(d)\n" +" lp = threading.Thread(target=logger_thread, args=(q,))\n" +" lp.start()\n" +" # At this point, the main process could do some useful work of its own\n" +" # Once it's done that, it can wait for the workers to terminate...\n" +" for wp in workers:\n" +" wp.join()\n" +" # And now tell the logging thread to finish up, too\n" +" q.put(None)\n" +" lp.join()" +msgstr "" + #: howto/logging-cookbook.rst:1489 msgid "" "This variant shows how you can e.g. apply configuration for particular " @@ -761,18 +1919,47 @@ msgid "" "Instead of" msgstr "" +#: howto/logging-cookbook.rst:1502 +msgid "queue = multiprocessing.Queue(-1)" +msgstr "" + #: howto/logging-cookbook.rst:1506 msgid "you should use" msgstr "" +#: howto/logging-cookbook.rst:1508 +msgid "" +"queue = multiprocessing.Manager().Queue(-1) # also works with the examples " +"above" +msgstr "" + #: howto/logging-cookbook.rst:1512 msgid "and you can then replace the worker creation from this::" msgstr "" +#: howto/logging-cookbook.rst:1514 +msgid "" +"workers = []\n" +"for i in range(10):\n" +" worker = multiprocessing.Process(target=worker_process,\n" +" args=(queue, worker_configurer))\n" +" workers.append(worker)\n" +" worker.start()\n" +"for w in workers:\n" +" w.join()" +msgstr "" + #: howto/logging-cookbook.rst:1523 msgid "to this (remembering to first import :mod:`concurrent.futures`)::" msgstr "" +#: howto/logging-cookbook.rst:1525 +msgid "" +"with concurrent.futures.ProcessPoolExecutor(max_workers=10) as executor:\n" +" for i in range(10):\n" +" executor.submit(worker_process, queue, worker_configurer)" +msgstr "" + #: howto/logging-cookbook.rst:1530 msgid "Deploying Web applications using Gunicorn and uWSGI" msgstr "" @@ -802,12 +1989,51 @@ msgid "" "usage pattern, the logging package provides a :class:`RotatingFileHandler`::" msgstr "" +#: howto/logging-cookbook.rst:1553 +msgid "" +"import glob\n" +"import logging\n" +"import logging.handlers\n" +"\n" +"LOG_FILENAME = 'logging_rotatingfile_example.out'\n" +"\n" +"# Set up a specific logger with our desired output level\n" +"my_logger = logging.getLogger('MyLogger')\n" +"my_logger.setLevel(logging.DEBUG)\n" +"\n" +"# Add the log message handler to the logger\n" +"handler = logging.handlers.RotatingFileHandler(\n" +" LOG_FILENAME, maxBytes=20, backupCount=5)\n" +"\n" +"my_logger.addHandler(handler)\n" +"\n" +"# Log some messages\n" +"for i in range(20):\n" +" my_logger.debug('i = %d' % i)\n" +"\n" +"# See what files are created\n" +"logfiles = glob.glob('%s*' % LOG_FILENAME)\n" +"\n" +"for filename in logfiles:\n" +" print(filename)" +msgstr "" + #: howto/logging-cookbook.rst:1579 msgid "" "The result should be 6 separate files, each with part of the log history for " "the application:" msgstr "" +#: howto/logging-cookbook.rst:1582 +msgid "" +"logging_rotatingfile_example.out\n" +"logging_rotatingfile_example.out.1\n" +"logging_rotatingfile_example.out.2\n" +"logging_rotatingfile_example.out.3\n" +"logging_rotatingfile_example.out.4\n" +"logging_rotatingfile_example.out.5" +msgstr "" + #: howto/logging-cookbook.rst:1591 msgid "" "The most current file is always :file:`logging_rotatingfile_example.out`, " @@ -830,9 +2056,9 @@ msgstr "" msgid "" "When logging was added to the Python standard library, the only way of " "formatting messages with variable content was to use the %-formatting " -"method. Since then, Python has gained two new formatting approaches: :class:" -"`string.Template` (added in Python 2.4) and :meth:`str.format` (added in " -"Python 2.6)." +"method. Since then, Python has gained two new formatting " +"approaches: :class:`string.Template` (added in Python 2.4) " +"and :meth:`str.format` (added in Python 2.6)." msgstr "" #: howto/logging-cookbook.rst:1612 @@ -843,9 +2069,34 @@ msgid "" "``'%'``, but other possible values are ``'{'`` and ``'$'``, which correspond " "to the other two formatting styles. Backwards compatibility is maintained by " "default (as you would expect), but by explicitly specifying a style " -"parameter, you get the ability to specify format strings which work with :" -"meth:`str.format` or :class:`string.Template`. Here's an example console " -"session to show the possibilities:" +"parameter, you get the ability to specify format strings which work " +"with :meth:`str.format` or :class:`string.Template`. Here's an example " +"console session to show the possibilities:" +msgstr "" + +#: howto/logging-cookbook.rst:1622 +msgid "" +">>> import logging\n" +">>> root = logging.getLogger()\n" +">>> root.setLevel(logging.DEBUG)\n" +">>> handler = logging.StreamHandler()\n" +">>> bf = logging.Formatter('{asctime} {name} {levelname:8s} {message}',\n" +"... style='{')\n" +">>> handler.setFormatter(bf)\n" +">>> root.addHandler(handler)\n" +">>> logger = logging.getLogger('foo.bar')\n" +">>> logger.debug('This is a DEBUG message')\n" +"2010-10-28 15:11:55,341 foo.bar DEBUG This is a DEBUG message\n" +">>> logger.critical('This is a CRITICAL message')\n" +"2010-10-28 15:12:11,526 foo.bar CRITICAL This is a CRITICAL message\n" +">>> df = logging.Formatter('$asctime $name ${levelname} $message',\n" +"... style='$')\n" +">>> handler.setFormatter(df)\n" +">>> logger.debug('This is a DEBUG message')\n" +"2010-10-28 15:13:06,924 foo.bar DEBUG This is a DEBUG message\n" +">>> logger.critical('This is a CRITICAL message')\n" +"2010-10-28 15:13:11,494 foo.bar CRITICAL This is a CRITICAL message\n" +">>>" msgstr "" #: howto/logging-cookbook.rst:1646 @@ -855,6 +2106,13 @@ msgid "" "That can still use %-formatting, as shown here::" msgstr "" +#: howto/logging-cookbook.rst:1650 +msgid "" +">>> logger.error('This is an%s %s %s', 'other,', 'ERROR,', 'message')\n" +"2010-10-28 15:19:29,833 foo.bar ERROR This is another, ERROR, message\n" +">>>" +msgstr "" + #: howto/logging-cookbook.rst:1654 msgid "" "Logging calls (``logger.debug()``, ``logger.info()`` etc.) only take " @@ -863,12 +2121,12 @@ msgid "" "logging call (e.g. the ``exc_info`` keyword parameter to indicate that " "traceback information should be logged, or the ``extra`` keyword parameter " "to indicate additional contextual information to be added to the log). So " -"you cannot directly make logging calls using :meth:`str.format` or :class:" -"`string.Template` syntax, because internally the logging package uses %-" -"formatting to merge the format string and the variable arguments. There " -"would be no changing this while preserving backward compatibility, since all " -"logging calls which are out there in existing code will be using %-format " -"strings." +"you cannot directly make logging calls using :meth:`str.format` " +"or :class:`string.Template` syntax, because internally the logging package " +"uses %-formatting to merge the format string and the variable arguments. " +"There would be no changing this while preserving backward compatibility, " +"since all logging calls which are out there in existing code will be using %-" +"format strings." msgstr "" #: howto/logging-cookbook.rst:1667 @@ -880,6 +2138,27 @@ msgid "" "the following two classes::" msgstr "" +#: howto/logging-cookbook.rst:1673 howto/logging-cookbook.rst:2761 +msgid "" +"class BraceMessage:\n" +" def __init__(self, fmt, /, *args, **kwargs):\n" +" self.fmt = fmt\n" +" self.args = args\n" +" self.kwargs = kwargs\n" +"\n" +" def __str__(self):\n" +" return self.fmt.format(*self.args, **self.kwargs)\n" +"\n" +"class DollarMessage:\n" +" def __init__(self, fmt, /, **kwargs):\n" +" self.fmt = fmt\n" +" self.kwargs = kwargs\n" +"\n" +" def __str__(self):\n" +" from string import Template\n" +" return Template(self.fmt).substitute(**self.kwargs)" +msgstr "" + #: howto/logging-cookbook.rst:1691 msgid "" "Either of these can be used in place of a format string, to allow {}- or $-" @@ -898,6 +2177,25 @@ msgid "" "that they're declared in a module called ``wherever``):" msgstr "" +#: howto/logging-cookbook.rst:1703 +msgid "" +">>> from wherever import BraceMessage as __\n" +">>> print(__('Message with {0} {name}', 2, name='placeholders'))\n" +"Message with 2 placeholders\n" +">>> class Point: pass\n" +"...\n" +">>> p = Point()\n" +">>> p.x = 0.5\n" +">>> p.y = 0.5\n" +">>> print(__('Message with coordinates: ({point.x:.2f}, {point.y:.2f})',\n" +"... point=p))\n" +"Message with coordinates: (0.50, 0.50)\n" +">>> from wherever import DollarMessage as __\n" +">>> print(__('Message with $num $what', num=2, what='placeholders'))\n" +"Message with 2 placeholders\n" +">>>" +msgstr "" + #: howto/logging-cookbook.rst:1721 msgid "" "While the above examples use ``print()`` to show how the formatting works, " @@ -922,6 +2220,35 @@ msgid "" "effect to the above, as in the following example::" msgstr "" +#: howto/logging-cookbook.rst:1736 +msgid "" +"import logging\n" +"\n" +"class Message:\n" +" def __init__(self, fmt, args):\n" +" self.fmt = fmt\n" +" self.args = args\n" +"\n" +" def __str__(self):\n" +" return self.fmt.format(*self.args)\n" +"\n" +"class StyleAdapter(logging.LoggerAdapter):\n" +" def log(self, level, msg, /, *args, stacklevel=1, **kwargs):\n" +" if self.isEnabledFor(level):\n" +" msg, kwargs = self.process(msg, kwargs)\n" +" self.logger.log(level, Message(msg, args), **kwargs,\n" +" stacklevel=stacklevel+1)\n" +"\n" +"logger = StyleAdapter(logging.getLogger(__name__))\n" +"\n" +"def main():\n" +" logger.debug('Hello, {}', 'world!')\n" +"\n" +"if __name__ == '__main__':\n" +" logging.basicConfig(level=logging.DEBUG)\n" +" main()" +msgstr "" + #: howto/logging-cookbook.rst:1762 msgid "" "The above script should log the message ``Hello, world!`` when run with " @@ -935,10 +2262,10 @@ msgstr "" #: howto/logging-cookbook.rst:1773 msgid "" "Every logging event is represented by a :class:`LogRecord` instance. When an " -"event is logged and not filtered out by a logger's level, a :class:" -"`LogRecord` is created, populated with information about the event and then " -"passed to the handlers for that logger (and its ancestors, up to and " -"including the logger where further propagation up the hierarchy is " +"event is logged and not filtered out by a logger's level, " +"a :class:`LogRecord` is created, populated with information about the event " +"and then passed to the handlers for that logger (and its ancestors, up to " +"and including the logger where further propagation up the hierarchy is " "disabled). Before Python 3.2, there were only two places where this creation " "was done:" msgstr "" @@ -954,21 +2281,22 @@ msgid "" ":func:`makeLogRecord`, which is called with a dictionary containing " "attributes to be added to the LogRecord. This is typically invoked when a " "suitable dictionary has been received over the network (e.g. in pickle form " -"via a :class:`~handlers.SocketHandler`, or in JSON form via an :class:" -"`~handlers.HTTPHandler`)." +"via a :class:`~handlers.SocketHandler`, or in JSON form via " +"an :class:`~handlers.HTTPHandler`)." msgstr "" #: howto/logging-cookbook.rst:1789 msgid "" -"This has usually meant that if you need to do anything special with a :class:" -"`LogRecord`, you've had to do one of the following." +"This has usually meant that if you need to do anything special with " +"a :class:`LogRecord`, you've had to do one of the following." msgstr "" #: howto/logging-cookbook.rst:1792 msgid "" -"Create your own :class:`Logger` subclass, which overrides :meth:`Logger." -"makeRecord`, and set it using :func:`~logging.setLoggerClass` before any " -"loggers that you care about are instantiated." +"Create your own :class:`Logger` subclass, which " +"overrides :meth:`Logger.makeRecord`, and set it " +"using :func:`~logging.setLoggerClass` before any loggers that you care about " +"are instantiated." msgstr "" #: howto/logging-cookbook.rst:1795 @@ -995,6 +2323,10 @@ msgid "" "would do simply by adding new packages or modules and doing ::" msgstr "" +#: howto/logging-cookbook.rst:1810 +msgid "logger = logging.getLogger(__name__)" +msgstr "" + #: howto/logging-cookbook.rst:1812 msgid "" "at module level). It's probably one too many things to think about. " @@ -1009,10 +2341,10 @@ msgstr "" msgid "" "In Python 3.2 and later, :class:`~logging.LogRecord` creation is done " "through a factory, which you can specify. The factory is just a callable you " -"can set with :func:`~logging.setLogRecordFactory`, and interrogate with :" -"func:`~logging.getLogRecordFactory`. The factory is invoked with the same " -"signature as the :class:`~logging.LogRecord` constructor, as :class:" -"`LogRecord` is the default setting for the factory." +"can set with :func:`~logging.setLogRecordFactory`, and interrogate " +"with :func:`~logging.getLogRecordFactory`. The factory is invoked with the " +"same signature as the :class:`~logging.LogRecord` constructor, " +"as :class:`LogRecord` is the default setting for the factory." msgstr "" #: howto/logging-cookbook.rst:1825 @@ -1023,6 +2355,18 @@ msgid "" "this::" msgstr "" +#: howto/logging-cookbook.rst:1829 +msgid "" +"old_factory = logging.getLogRecordFactory()\n" +"\n" +"def record_factory(*args, **kwargs):\n" +" record = old_factory(*args, **kwargs)\n" +" record.custom_attribute = 0xdecafbad\n" +" return record\n" +"\n" +"logging.setLogRecordFactory(record_factory)" +msgstr "" + #: howto/logging-cookbook.rst:1838 msgid "" "This pattern allows different libraries to chain factories together, and as " @@ -1034,103 +2378,416 @@ msgid "" msgstr "" #: howto/logging-cookbook.rst:1850 -msgid "Subclassing QueueHandler - a ZeroMQ example" +msgid "Subclassing QueueHandler and QueueListener- a ZeroMQ example" msgstr "" -#: howto/logging-cookbook.rst:1852 +#: howto/logging-cookbook.rst:1853 howto/logging-cookbook.rst:1986 +msgid "Subclass ``QueueHandler``" +msgstr "" + +#: howto/logging-cookbook.rst:1855 msgid "" "You can use a :class:`QueueHandler` subclass to send messages to other kinds " "of queues, for example a ZeroMQ 'publish' socket. In the example below,the " "socket is created separately and passed to the handler (as its 'queue')::" msgstr "" -#: howto/logging-cookbook.rst:1871 +#: howto/logging-cookbook.rst:1859 +msgid "" +"import zmq # using pyzmq, the Python binding for ZeroMQ\n" +"import json # for serializing records portably\n" +"\n" +"ctx = zmq.Context()\n" +"sock = zmq.Socket(ctx, zmq.PUB) # or zmq.PUSH, or other suitable value\n" +"sock.bind('tcp://*:5556') # or wherever\n" +"\n" +"class ZeroMQSocketHandler(QueueHandler):\n" +" def enqueue(self, record):\n" +" self.queue.send_json(record.__dict__)\n" +"\n" +"\n" +"handler = ZeroMQSocketHandler(sock)" +msgstr "" + +#: howto/logging-cookbook.rst:1874 msgid "" "Of course there are other ways of organizing this, for example passing in " "the data needed by the handler to create the socket::" msgstr "" -#: howto/logging-cookbook.rst:1889 -msgid "Subclassing QueueListener - a ZeroMQ example" +#: howto/logging-cookbook.rst:1877 +msgid "" +"class ZeroMQSocketHandler(QueueHandler):\n" +" def __init__(self, uri, socktype=zmq.PUB, ctx=None):\n" +" self.ctx = ctx or zmq.Context()\n" +" socket = zmq.Socket(self.ctx, socktype)\n" +" socket.bind(uri)\n" +" super().__init__(socket)\n" +"\n" +" def enqueue(self, record):\n" +" self.queue.send_json(record.__dict__)\n" +"\n" +" def close(self):\n" +" self.queue.close()" +msgstr "" + +#: howto/logging-cookbook.rst:1892 howto/logging-cookbook.rst:1922 +msgid "Subclass ``QueueListener``" msgstr "" -#: howto/logging-cookbook.rst:1891 +#: howto/logging-cookbook.rst:1894 msgid "" "You can also subclass :class:`QueueListener` to get messages from other " "kinds of queues, for example a ZeroMQ 'subscribe' socket. Here's an example::" msgstr "" -#: howto/logging-cookbook.rst:1910 howto/logging-cookbook.rst:3973 -msgid "Module :mod:`logging`" +#: howto/logging-cookbook.rst:1897 +msgid "" +"class ZeroMQSocketListener(QueueListener):\n" +" def __init__(self, uri, /, *handlers, **kwargs):\n" +" self.ctx = kwargs.get('ctx') or zmq.Context()\n" +" socket = zmq.Socket(self.ctx, zmq.SUB)\n" +" socket.setsockopt_string(zmq.SUBSCRIBE, '') # subscribe to " +"everything\n" +" socket.connect(uri)\n" +" super().__init__(socket, *handlers, **kwargs)\n" +"\n" +" def dequeue(self):\n" +" msg = self.queue.recv_json()\n" +" return logging.makeLogRecord(msg)" +msgstr "" + +#: howto/logging-cookbook.rst:1912 +msgid "Subclassing QueueHandler and QueueListener- a ``pynng`` example" +msgstr "" + +#: howto/logging-cookbook.rst:1914 +msgid "" +"In a similar way to the above section, we can implement a listener and " +"handler using :pypi:`pynng`, which is a Python binding to `NNG `_, billed as a spiritual successor to ZeroMQ. The " +"following snippets illustrate -- you can test them in an environment which " +"has ``pynng`` installed. Just for variety, we present the listener first." +msgstr "" + +#: howto/logging-cookbook.rst:1924 +msgid "" +"# listener.py\n" +"import json\n" +"import logging\n" +"import logging.handlers\n" +"\n" +"import pynng\n" +"\n" +"DEFAULT_ADDR = \"tcp://localhost:13232\"\n" +"\n" +"interrupted = False\n" +"\n" +"class NNGSocketListener(logging.handlers.QueueListener):\n" +"\n" +" def __init__(self, uri, /, *handlers, **kwargs):\n" +" # Have a timeout for interruptability, and open a\n" +" # subscriber socket\n" +" socket = pynng.Sub0(listen=uri, recv_timeout=500)\n" +" # The b'' subscription matches all topics\n" +" topics = kwargs.pop('topics', None) or b''\n" +" socket.subscribe(topics)\n" +" # We treat the socket as a queue\n" +" super().__init__(socket, *handlers, **kwargs)\n" +"\n" +" def dequeue(self, block):\n" +" data = None\n" +" # Keep looping while not interrupted and no data received over the\n" +" # socket\n" +" while not interrupted:\n" +" try:\n" +" data = self.queue.recv(block=block)\n" +" break\n" +" except pynng.Timeout:\n" +" pass\n" +" except pynng.Closed: # sometimes happens when you hit Ctrl-C\n" +" break\n" +" if data is None:\n" +" return None\n" +" # Get the logging event sent from a publisher\n" +" event = json.loads(data.decode('utf-8'))\n" +" return logging.makeLogRecord(event)\n" +"\n" +" def enqueue_sentinel(self):\n" +" # Not used in this implementation, as the socket isn't really a\n" +" # queue\n" +" pass\n" +"\n" +"logging.getLogger('pynng').propagate = False\n" +"listener = NNGSocketListener(DEFAULT_ADDR, logging.StreamHandler(), " +"topics=b'')\n" +"listener.start()\n" +"print('Press Ctrl-C to stop.')\n" +"try:\n" +" while True:\n" +" pass\n" +"except KeyboardInterrupt:\n" +" interrupted = True\n" +"finally:\n" +" listener.stop()" msgstr "" -#: howto/logging-cookbook.rst:1910 howto/logging-cookbook.rst:3973 -msgid "API reference for the logging module." +#: howto/logging-cookbook.rst:1990 +msgid "" +"# sender.py\n" +"import json\n" +"import logging\n" +"import logging.handlers\n" +"import time\n" +"import random\n" +"\n" +"import pynng\n" +"\n" +"DEFAULT_ADDR = \"tcp://localhost:13232\"\n" +"\n" +"class NNGSocketHandler(logging.handlers.QueueHandler):\n" +"\n" +" def __init__(self, uri):\n" +" socket = pynng.Pub0(dial=uri, send_timeout=500)\n" +" super().__init__(socket)\n" +"\n" +" def enqueue(self, record):\n" +" # Send the record as UTF-8 encoded JSON\n" +" d = dict(record.__dict__)\n" +" data = json.dumps(d)\n" +" self.queue.send(data.encode('utf-8'))\n" +"\n" +" def close(self):\n" +" self.queue.close()\n" +"\n" +"logging.getLogger('pynng').propagate = False\n" +"handler = NNGSocketHandler(DEFAULT_ADDR)\n" +"# Make sure the process ID is in the output\n" +"logging.basicConfig(level=logging.DEBUG,\n" +" handlers=[logging.StreamHandler(), handler],\n" +" format='%(levelname)-8s %(name)10s %(process)6s %" +"(message)s')\n" +"levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,\n" +" logging.CRITICAL)\n" +"logger_names = ('myapp', 'myapp.lib1', 'myapp.lib2')\n" +"msgno = 1\n" +"while True:\n" +" # Just randomly select some loggers and levels and log away\n" +" level = random.choice(levels)\n" +" logger = logging.getLogger(random.choice(logger_names))\n" +" logger.log(level, 'Message no. %5d' % msgno)\n" +" msgno += 1\n" +" delay = random.random() * 2 + 0.5\n" +" time.sleep(delay)" +msgstr "" + +#: howto/logging-cookbook.rst:2037 +msgid "" +"You can run the above two snippets in separate command shells. If we run the " +"listener in one shell and run the sender in two separate shells, we should " +"see something like the following. In the first sender shell:" msgstr "" -#: howto/logging-cookbook.rst:1913 howto/logging-cookbook.rst:3976 -msgid "Module :mod:`logging.config`" +#: howto/logging-cookbook.rst:2041 +msgid "" +"$ python sender.py\n" +"DEBUG myapp 613 Message no. 1\n" +"WARNING myapp.lib2 613 Message no. 2\n" +"CRITICAL myapp.lib2 613 Message no. 3\n" +"WARNING myapp.lib2 613 Message no. 4\n" +"CRITICAL myapp.lib1 613 Message no. 5\n" +"DEBUG myapp 613 Message no. 6\n" +"CRITICAL myapp.lib1 613 Message no. 7\n" +"INFO myapp.lib1 613 Message no. 8\n" +"(and so on)" msgstr "" -#: howto/logging-cookbook.rst:1913 howto/logging-cookbook.rst:3976 -msgid "Configuration API for the logging module." +#: howto/logging-cookbook.rst:2054 +msgid "In the second sender shell:" msgstr "" -#: howto/logging-cookbook.rst:1916 howto/logging-cookbook.rst:3979 -msgid "Module :mod:`logging.handlers`" +#: howto/logging-cookbook.rst:2056 +msgid "" +"$ python sender.py\n" +"INFO myapp.lib2 657 Message no. 1\n" +"CRITICAL myapp.lib2 657 Message no. 2\n" +"CRITICAL myapp 657 Message no. 3\n" +"CRITICAL myapp.lib1 657 Message no. 4\n" +"INFO myapp.lib1 657 Message no. 5\n" +"WARNING myapp.lib2 657 Message no. 6\n" +"CRITICAL myapp 657 Message no. 7\n" +"DEBUG myapp.lib1 657 Message no. 8\n" +"(and so on)" msgstr "" -#: howto/logging-cookbook.rst:1916 howto/logging-cookbook.rst:3979 -msgid "Useful handlers included with the logging module." +#: howto/logging-cookbook.rst:2069 +msgid "In the listener shell:" msgstr "" -#: howto/logging-cookbook.rst:1918 -msgid ":ref:`A basic logging tutorial `" +#: howto/logging-cookbook.rst:2071 +msgid "" +"$ python listener.py\n" +"Press Ctrl-C to stop.\n" +"DEBUG myapp 613 Message no. 1\n" +"WARNING myapp.lib2 613 Message no. 2\n" +"INFO myapp.lib2 657 Message no. 1\n" +"CRITICAL myapp.lib2 613 Message no. 3\n" +"CRITICAL myapp.lib2 657 Message no. 2\n" +"CRITICAL myapp 657 Message no. 3\n" +"WARNING myapp.lib2 613 Message no. 4\n" +"CRITICAL myapp.lib1 613 Message no. 5\n" +"CRITICAL myapp.lib1 657 Message no. 4\n" +"INFO myapp.lib1 657 Message no. 5\n" +"DEBUG myapp 613 Message no. 6\n" +"WARNING myapp.lib2 657 Message no. 6\n" +"CRITICAL myapp 657 Message no. 7\n" +"CRITICAL myapp.lib1 613 Message no. 7\n" +"INFO myapp.lib1 613 Message no. 8\n" +"DEBUG myapp.lib1 657 Message no. 8\n" +"(and so on)" msgstr "" -#: howto/logging-cookbook.rst:1920 -msgid ":ref:`A more advanced logging tutorial `" +#: howto/logging-cookbook.rst:2093 +msgid "" +"As you can see, the logging from the two sender processes is interleaved in " +"the listener's output." msgstr "" -#: howto/logging-cookbook.rst:1926 +#: howto/logging-cookbook.rst:2098 msgid "An example dictionary-based configuration" msgstr "" -#: howto/logging-cookbook.rst:1928 +#: howto/logging-cookbook.rst:2100 msgid "" "Below is an example of a logging configuration dictionary - it's taken from " "the `documentation on the Django project `_. This dictionary is passed to :" -"func:`~config.dictConfig` to put the configuration into effect::" -msgstr "" - -#: howto/logging-cookbook.rst:1981 +"stable/topics/logging/#configuring-logging>`_. This dictionary is passed " +"to :func:`~config.dictConfig` to put the configuration into effect::" +msgstr "" + +#: howto/logging-cookbook.rst:2104 +msgid "" +"LOGGING = {\n" +" 'version': 1,\n" +" 'disable_existing_loggers': False,\n" +" 'formatters': {\n" +" 'verbose': {\n" +" 'format': '{levelname} {asctime} {module} {process:d} {thread:d} " +"{message}',\n" +" 'style': '{',\n" +" },\n" +" 'simple': {\n" +" 'format': '{levelname} {message}',\n" +" 'style': '{',\n" +" },\n" +" },\n" +" 'filters': {\n" +" 'special': {\n" +" '()': 'project.logging.SpecialFilter',\n" +" 'foo': 'bar',\n" +" },\n" +" },\n" +" 'handlers': {\n" +" 'console': {\n" +" 'level': 'INFO',\n" +" 'class': 'logging.StreamHandler',\n" +" 'formatter': 'simple',\n" +" },\n" +" 'mail_admins': {\n" +" 'level': 'ERROR',\n" +" 'class': 'django.utils.log.AdminEmailHandler',\n" +" 'filters': ['special']\n" +" }\n" +" },\n" +" 'loggers': {\n" +" 'django': {\n" +" 'handlers': ['console'],\n" +" 'propagate': True,\n" +" },\n" +" 'django.request': {\n" +" 'handlers': ['mail_admins'],\n" +" 'level': 'ERROR',\n" +" 'propagate': False,\n" +" },\n" +" 'myproject.custom': {\n" +" 'handlers': ['console', 'mail_admins'],\n" +" 'level': 'INFO',\n" +" 'filters': ['special']\n" +" }\n" +" }\n" +"}" +msgstr "" + +#: howto/logging-cookbook.rst:2153 msgid "" "For more information about this configuration, you can see the `relevant " "section `_ of the Django documentation." msgstr "" -#: howto/logging-cookbook.rst:1988 +#: howto/logging-cookbook.rst:2160 msgid "Using a rotator and namer to customize log rotation processing" msgstr "" -#: howto/logging-cookbook.rst:1990 +#: howto/logging-cookbook.rst:2162 msgid "" "An example of how you can define a namer and rotator is given in the " "following runnable script, which shows gzip compression of the log file::" msgstr "" -#: howto/logging-cookbook.rst:2021 +#: howto/logging-cookbook.rst:2165 +msgid "" +"import gzip\n" +"import logging\n" +"import logging.handlers\n" +"import os\n" +"import shutil\n" +"\n" +"def namer(name):\n" +" return name + \".gz\"\n" +"\n" +"def rotator(source, dest):\n" +" with open(source, 'rb') as f_in:\n" +" with gzip.open(dest, 'wb') as f_out:\n" +" shutil.copyfileobj(f_in, f_out)\n" +" os.remove(source)\n" +"\n" +"\n" +"rh = logging.handlers.RotatingFileHandler('rotated.log', maxBytes=128, " +"backupCount=5)\n" +"rh.rotator = rotator\n" +"rh.namer = namer\n" +"\n" +"root = logging.getLogger()\n" +"root.setLevel(logging.INFO)\n" +"root.addHandler(rh)\n" +"f = logging.Formatter('%(asctime)s %(message)s')\n" +"rh.setFormatter(f)\n" +"for i in range(1000):\n" +" root.info(f'Message no. {i + 1}')" +msgstr "" + +#: howto/logging-cookbook.rst:2193 msgid "" "After running this, you will see six new files, five of which are compressed:" msgstr "" -#: howto/logging-cookbook.rst:2034 +#: howto/logging-cookbook.rst:2195 +msgid "" +"$ ls rotated.log*\n" +"rotated.log rotated.log.2.gz rotated.log.4.gz\n" +"rotated.log.1.gz rotated.log.3.gz rotated.log.5.gz\n" +"$ zcat rotated.log.1.gz\n" +"2023-01-20 02:28:17,767 Message no. 996\n" +"2023-01-20 02:28:17,767 Message no. 997\n" +"2023-01-20 02:28:17,767 Message no. 998" +msgstr "" + +#: howto/logging-cookbook.rst:2206 msgid "A more elaborate multiprocessing example" msgstr "" -#: howto/logging-cookbook.rst:2036 +#: howto/logging-cookbook.rst:2208 msgid "" "The following working example shows how logging can be used with " "multiprocessing using configuration files. The configurations are fairly " @@ -1138,7 +2795,7 @@ msgid "" "in a real multiprocessing scenario." msgstr "" -#: howto/logging-cookbook.rst:2041 +#: howto/logging-cookbook.rst:2213 msgid "" "In the example, the main process spawns a listener process and some worker " "processes. Each of the main process, the listener and the workers have three " @@ -1151,17 +2808,240 @@ msgid "" "own scenario." msgstr "" -#: howto/logging-cookbook.rst:2051 +#: howto/logging-cookbook.rst:2223 msgid "" "Here's the script - the docstrings and the comments hopefully explain how it " "works::" msgstr "" -#: howto/logging-cookbook.rst:2263 +#: howto/logging-cookbook.rst:2226 +msgid "" +"import logging\n" +"import logging.config\n" +"import logging.handlers\n" +"from multiprocessing import Process, Queue, Event, current_process\n" +"import os\n" +"import random\n" +"import time\n" +"\n" +"class MyHandler:\n" +" \"\"\"\n" +" A simple handler for logging events. It runs in the listener process " +"and\n" +" dispatches events to loggers based on the name in the received record,\n" +" which then get dispatched, by the logging system, to the handlers\n" +" configured for those loggers.\n" +" \"\"\"\n" +"\n" +" def handle(self, record):\n" +" if record.name == \"root\":\n" +" logger = logging.getLogger()\n" +" else:\n" +" logger = logging.getLogger(record.name)\n" +"\n" +" if logger.isEnabledFor(record.levelno):\n" +" # The process name is transformed just to show that it's the " +"listener\n" +" # doing the logging to files and console\n" +" record.processName = '%s (for %s)' % (current_process().name, " +"record.processName)\n" +" logger.handle(record)\n" +"\n" +"def listener_process(q, stop_event, config):\n" +" \"\"\"\n" +" This could be done in the main process, but is just done in a separate\n" +" process for illustrative purposes.\n" +"\n" +" This initialises logging according to the specified configuration,\n" +" starts the listener and waits for the main process to signal completion\n" +" via the event. The listener is then stopped, and the process exits.\n" +" \"\"\"\n" +" logging.config.dictConfig(config)\n" +" listener = logging.handlers.QueueListener(q, MyHandler())\n" +" listener.start()\n" +" if os.name == 'posix':\n" +" # On POSIX, the setup logger will have been configured in the\n" +" # parent process, but should have been disabled following the\n" +" # dictConfig call.\n" +" # On Windows, since fork isn't used, the setup logger won't\n" +" # exist in the child, so it would be created and the message\n" +" # would appear - hence the \"if posix\" clause.\n" +" logger = logging.getLogger('setup')\n" +" logger.critical('Should not appear, because of disabled " +"logger ...')\n" +" stop_event.wait()\n" +" listener.stop()\n" +"\n" +"def worker_process(config):\n" +" \"\"\"\n" +" A number of these are spawned for the purpose of illustration. In\n" +" practice, they could be a heterogeneous bunch of processes rather than\n" +" ones which are identical to each other.\n" +"\n" +" This initialises logging according to the specified configuration,\n" +" and logs a hundred messages with random levels to randomly selected\n" +" loggers.\n" +"\n" +" A small sleep is added to allow other processes a chance to run. This\n" +" is not strictly needed, but it mixes the output from the different\n" +" processes a bit more than if it's left out.\n" +" \"\"\"\n" +" logging.config.dictConfig(config)\n" +" levels = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,\n" +" logging.CRITICAL]\n" +" loggers = ['foo', 'foo.bar', 'foo.bar.baz',\n" +" 'spam', 'spam.ham', 'spam.ham.eggs']\n" +" if os.name == 'posix':\n" +" # On POSIX, the setup logger will have been configured in the\n" +" # parent process, but should have been disabled following the\n" +" # dictConfig call.\n" +" # On Windows, since fork isn't used, the setup logger won't\n" +" # exist in the child, so it would be created and the message\n" +" # would appear - hence the \"if posix\" clause.\n" +" logger = logging.getLogger('setup')\n" +" logger.critical('Should not appear, because of disabled " +"logger ...')\n" +" for i in range(100):\n" +" lvl = random.choice(levels)\n" +" logger = logging.getLogger(random.choice(loggers))\n" +" logger.log(lvl, 'Message no. %d', i)\n" +" time.sleep(0.01)\n" +"\n" +"def main():\n" +" q = Queue()\n" +" # The main process gets a simple configuration which prints to the " +"console.\n" +" config_initial = {\n" +" 'version': 1,\n" +" 'handlers': {\n" +" 'console': {\n" +" 'class': 'logging.StreamHandler',\n" +" 'level': 'INFO'\n" +" }\n" +" },\n" +" 'root': {\n" +" 'handlers': ['console'],\n" +" 'level': 'DEBUG'\n" +" }\n" +" }\n" +" # The worker process configuration is just a QueueHandler attached to " +"the\n" +" # root logger, which allows all messages to be sent to the queue.\n" +" # We disable existing loggers to disable the \"setup\" logger used in " +"the\n" +" # parent process. This is needed on POSIX because the logger will\n" +" # be there in the child following a fork().\n" +" config_worker = {\n" +" 'version': 1,\n" +" 'disable_existing_loggers': True,\n" +" 'handlers': {\n" +" 'queue': {\n" +" 'class': 'logging.handlers.QueueHandler',\n" +" 'queue': q\n" +" }\n" +" },\n" +" 'root': {\n" +" 'handlers': ['queue'],\n" +" 'level': 'DEBUG'\n" +" }\n" +" }\n" +" # The listener process configuration shows that the full flexibility of\n" +" # logging configuration is available to dispatch events to handlers " +"however\n" +" # you want.\n" +" # We disable existing loggers to disable the \"setup\" logger used in " +"the\n" +" # parent process. This is needed on POSIX because the logger will\n" +" # be there in the child following a fork().\n" +" config_listener = {\n" +" 'version': 1,\n" +" 'disable_existing_loggers': True,\n" +" 'formatters': {\n" +" 'detailed': {\n" +" 'class': 'logging.Formatter',\n" +" 'format': '%(asctime)s %(name)-15s %(levelname)-8s %" +"(processName)-10s %(message)s'\n" +" },\n" +" 'simple': {\n" +" 'class': 'logging.Formatter',\n" +" 'format': '%(name)-15s %(levelname)-8s %(processName)-10s %" +"(message)s'\n" +" }\n" +" },\n" +" 'handlers': {\n" +" 'console': {\n" +" 'class': 'logging.StreamHandler',\n" +" 'formatter': 'simple',\n" +" 'level': 'INFO'\n" +" },\n" +" 'file': {\n" +" 'class': 'logging.FileHandler',\n" +" 'filename': 'mplog.log',\n" +" 'mode': 'w',\n" +" 'formatter': 'detailed'\n" +" },\n" +" 'foofile': {\n" +" 'class': 'logging.FileHandler',\n" +" 'filename': 'mplog-foo.log',\n" +" 'mode': 'w',\n" +" 'formatter': 'detailed'\n" +" },\n" +" 'errors': {\n" +" 'class': 'logging.FileHandler',\n" +" 'filename': 'mplog-errors.log',\n" +" 'mode': 'w',\n" +" 'formatter': 'detailed',\n" +" 'level': 'ERROR'\n" +" }\n" +" },\n" +" 'loggers': {\n" +" 'foo': {\n" +" 'handlers': ['foofile']\n" +" }\n" +" },\n" +" 'root': {\n" +" 'handlers': ['console', 'file', 'errors'],\n" +" 'level': 'DEBUG'\n" +" }\n" +" }\n" +" # Log some initial events, just to show that logging in the parent " +"works\n" +" # normally.\n" +" logging.config.dictConfig(config_initial)\n" +" logger = logging.getLogger('setup')\n" +" logger.info('About to create workers ...')\n" +" workers = []\n" +" for i in range(5):\n" +" wp = Process(target=worker_process, name='worker %d' % (i + 1),\n" +" args=(config_worker,))\n" +" workers.append(wp)\n" +" wp.start()\n" +" logger.info('Started worker: %s', wp.name)\n" +" logger.info('About to create listener ...')\n" +" stop_event = Event()\n" +" lp = Process(target=listener_process, name='listener',\n" +" args=(q, stop_event, config_listener))\n" +" lp.start()\n" +" logger.info('Started listener')\n" +" # We now hang around for the workers to finish their work.\n" +" for wp in workers:\n" +" wp.join()\n" +" # Workers all done, listening can now stop.\n" +" # Logging in the parent still works normally.\n" +" logger.info('Telling listener to stop ...')\n" +" stop_event.set()\n" +" lp.join()\n" +" logger.info('All done.')\n" +"\n" +"if __name__ == '__main__':\n" +" main()" +msgstr "" + +#: howto/logging-cookbook.rst:2435 msgid "Inserting a BOM into messages sent to a SysLogHandler" msgstr "" -#: howto/logging-cookbook.rst:2265 +#: howto/logging-cookbook.rst:2437 msgid "" ":rfc:`5424` requires that a Unicode message be sent to a syslog daemon as a " "set of bytes which have the following structure: an optional pure-ASCII " @@ -1170,7 +3050,7 @@ msgid "" "<5424#section-6>`.)" msgstr "" -#: howto/logging-cookbook.rst:2271 +#: howto/logging-cookbook.rst:2443 msgid "" "In Python 3.1, code was added to :class:`~logging.handlers.SysLogHandler` to " "insert a BOM into the message, but unfortunately, it was implemented " @@ -1178,7 +3058,7 @@ msgid "" "hence not allowing any pure-ASCII component to appear before it." msgstr "" -#: howto/logging-cookbook.rst:2277 +#: howto/logging-cookbook.rst:2449 msgid "" "As this behaviour is broken, the incorrect BOM insertion code is being " "removed from Python 3.2.4 and later. However, it is not being replaced, and " @@ -1187,33 +3067,38 @@ msgid "" "encoded using UTF-8, then you need to do the following:" msgstr "" -#: howto/logging-cookbook.rst:2283 +#: howto/logging-cookbook.rst:2455 msgid "" -"Attach a :class:`~logging.Formatter` instance to your :class:`~logging." -"handlers.SysLogHandler` instance, with a format string such as::" +"Attach a :class:`~logging.Formatter` instance to " +"your :class:`~logging.handlers.SysLogHandler` instance, with a format string " +"such as::" msgstr "" -#: howto/logging-cookbook.rst:2289 +#: howto/logging-cookbook.rst:2459 +msgid "'ASCII section\\ufeffUnicode section'" +msgstr "" + +#: howto/logging-cookbook.rst:2461 msgid "" "The Unicode code point U+FEFF, when encoded using UTF-8, will be encoded as " "a UTF-8 BOM -- the byte-string ``b'\\xef\\xbb\\xbf'``." msgstr "" -#: howto/logging-cookbook.rst:2292 +#: howto/logging-cookbook.rst:2464 msgid "" "Replace the ASCII section with whatever placeholders you like, but make sure " "that the data that appears in there after substitution is always ASCII (that " "way, it will remain unchanged after UTF-8 encoding)." msgstr "" -#: howto/logging-cookbook.rst:2296 +#: howto/logging-cookbook.rst:2468 msgid "" "Replace the Unicode section with whatever placeholders you like; if the data " "which appears there after substitution contains characters outside the ASCII " "range, that's fine -- it will be encoded using UTF-8." msgstr "" -#: howto/logging-cookbook.rst:2300 +#: howto/logging-cookbook.rst:2472 msgid "" "The formatted message *will* be encoded using UTF-8 encoding by " "``SysLogHandler``. If you follow the above rules, you should be able to " @@ -1222,11 +3107,11 @@ msgid "" "daemon may complain." msgstr "" -#: howto/logging-cookbook.rst:2307 +#: howto/logging-cookbook.rst:2479 msgid "Implementing structured logging" msgstr "" -#: howto/logging-cookbook.rst:2309 +#: howto/logging-cookbook.rst:2481 msgid "" "Although most logging messages are intended for reading by humans, and thus " "not readily machine-parseable, there might be circumstances where you want " @@ -1238,31 +3123,93 @@ msgid "" "machine-parseable manner::" msgstr "" -#: howto/logging-cookbook.rst:2333 +#: howto/logging-cookbook.rst:2489 +msgid "" +"import json\n" +"import logging\n" +"\n" +"class StructuredMessage:\n" +" def __init__(self, message, /, **kwargs):\n" +" self.message = message\n" +" self.kwargs = kwargs\n" +"\n" +" def __str__(self):\n" +" return '%s >>> %s' % (self.message, json.dumps(self.kwargs))\n" +"\n" +"_ = StructuredMessage # optional, to improve readability\n" +"\n" +"logging.basicConfig(level=logging.INFO, format='%(message)s')\n" +"logging.info(_('message 1', foo='bar', bar='baz', num=123, fnum=123.456))" +msgstr "" + +#: howto/logging-cookbook.rst:2505 msgid "If the above script is run, it prints:" msgstr "" -#: howto/logging-cookbook.rst:2339 howto/logging-cookbook.rst:2381 +#: howto/logging-cookbook.rst:2507 +msgid "" +"message 1 >>> {\"fnum\": 123.456, \"num\": 123, \"bar\": \"baz\", \"foo\": " +"\"bar\"}" +msgstr "" + +#: howto/logging-cookbook.rst:2511 howto/logging-cookbook.rst:2553 msgid "" "Note that the order of items might be different according to the version of " "Python used." msgstr "" -#: howto/logging-cookbook.rst:2342 +#: howto/logging-cookbook.rst:2514 msgid "" "If you need more specialised processing, you can use a custom JSON encoder, " "as in the following complete example::" msgstr "" -#: howto/logging-cookbook.rst:2375 +#: howto/logging-cookbook.rst:2517 +msgid "" +"import json\n" +"import logging\n" +"\n" +"\n" +"class Encoder(json.JSONEncoder):\n" +" def default(self, o):\n" +" if isinstance(o, set):\n" +" return tuple(o)\n" +" elif isinstance(o, str):\n" +" return o.encode('unicode_escape').decode('ascii')\n" +" return super().default(o)\n" +"\n" +"class StructuredMessage:\n" +" def __init__(self, message, /, **kwargs):\n" +" self.message = message\n" +" self.kwargs = kwargs\n" +"\n" +" def __str__(self):\n" +" s = Encoder().encode(self.kwargs)\n" +" return '%s >>> %s' % (self.message, s)\n" +"\n" +"_ = StructuredMessage # optional, to improve readability\n" +"\n" +"def main():\n" +" logging.basicConfig(level=logging.INFO, format='%(message)s')\n" +" logging.info(_('message 1', set_value={1, 2, 3}, snowman='\\u2603'))\n" +"\n" +"if __name__ == '__main__':\n" +" main()" +msgstr "" + +#: howto/logging-cookbook.rst:2547 msgid "When the above script is run, it prints:" msgstr "" -#: howto/logging-cookbook.rst:2390 +#: howto/logging-cookbook.rst:2549 +msgid "message 1 >>> {\"snowman\": \"\\u2603\", \"set_value\": [1, 2, 3]}" +msgstr "" + +#: howto/logging-cookbook.rst:2562 msgid "Customizing handlers with :func:`dictConfig`" msgstr "" -#: howto/logging-cookbook.rst:2392 +#: howto/logging-cookbook.rst:2564 msgid "" "There are times when you want to customize logging handlers in particular " "ways, and if you use :func:`dictConfig` you may be able to do this without " @@ -1272,43 +3219,150 @@ msgid "" "customize handler creation using a plain function such as::" msgstr "" -#: howto/logging-cookbook.rst:2406 -msgid "" -"You can then specify, in a logging configuration passed to :func:" -"`dictConfig`, that a logging handler be created by calling this function::" -msgstr "" - -#: howto/logging-cookbook.rst:2439 +#: howto/logging-cookbook.rst:2571 +msgid "" +"def owned_file_handler(filename, mode='a', encoding=None, owner=None):\n" +" if owner:\n" +" if not os.path.exists(filename):\n" +" open(filename, 'a').close()\n" +" shutil.chown(filename, *owner)\n" +" return logging.FileHandler(filename, mode, encoding)" +msgstr "" + +#: howto/logging-cookbook.rst:2578 +msgid "" +"You can then specify, in a logging configuration passed " +"to :func:`dictConfig`, that a logging handler be created by calling this " +"function::" +msgstr "" + +#: howto/logging-cookbook.rst:2581 +msgid "" +"LOGGING = {\n" +" 'version': 1,\n" +" 'disable_existing_loggers': False,\n" +" 'formatters': {\n" +" 'default': {\n" +" 'format': '%(asctime)s %(levelname)s %(name)s %(message)s'\n" +" },\n" +" },\n" +" 'handlers': {\n" +" 'file':{\n" +" # The values below are popped from this dictionary and\n" +" # used to create the handler, set the handler's level and\n" +" # its formatter.\n" +" '()': owned_file_handler,\n" +" 'level':'DEBUG',\n" +" 'formatter': 'default',\n" +" # The values below are passed to the handler creator callable\n" +" # as keyword arguments.\n" +" 'owner': ['pulse', 'pulse'],\n" +" 'filename': 'chowntest.log',\n" +" 'mode': 'w',\n" +" 'encoding': 'utf-8',\n" +" },\n" +" },\n" +" 'root': {\n" +" 'handlers': ['file'],\n" +" 'level': 'DEBUG',\n" +" },\n" +"}" +msgstr "" + +#: howto/logging-cookbook.rst:2611 msgid "" "In this example I am setting the ownership using the ``pulse`` user and " "group, just for the purposes of illustration. Putting it together into a " "working script, ``chowntest.py``::" msgstr "" -#: howto/logging-cookbook.rst:2486 +#: howto/logging-cookbook.rst:2615 +msgid "" +"import logging, logging.config, os, shutil\n" +"\n" +"def owned_file_handler(filename, mode='a', encoding=None, owner=None):\n" +" if owner:\n" +" if not os.path.exists(filename):\n" +" open(filename, 'a').close()\n" +" shutil.chown(filename, *owner)\n" +" return logging.FileHandler(filename, mode, encoding)\n" +"\n" +"LOGGING = {\n" +" 'version': 1,\n" +" 'disable_existing_loggers': False,\n" +" 'formatters': {\n" +" 'default': {\n" +" 'format': '%(asctime)s %(levelname)s %(name)s %(message)s'\n" +" },\n" +" },\n" +" 'handlers': {\n" +" 'file':{\n" +" # The values below are popped from this dictionary and\n" +" # used to create the handler, set the handler's level and\n" +" # its formatter.\n" +" '()': owned_file_handler,\n" +" 'level':'DEBUG',\n" +" 'formatter': 'default',\n" +" # The values below are passed to the handler creator callable\n" +" # as keyword arguments.\n" +" 'owner': ['pulse', 'pulse'],\n" +" 'filename': 'chowntest.log',\n" +" 'mode': 'w',\n" +" 'encoding': 'utf-8',\n" +" },\n" +" },\n" +" 'root': {\n" +" 'handlers': ['file'],\n" +" 'level': 'DEBUG',\n" +" },\n" +"}\n" +"\n" +"logging.config.dictConfig(LOGGING)\n" +"logger = logging.getLogger('mylogger')\n" +"logger.debug('A debug message')" +msgstr "" + +#: howto/logging-cookbook.rst:2658 msgid "To run this, you will probably need to run as ``root``:" msgstr "" -#: howto/logging-cookbook.rst:2496 +#: howto/logging-cookbook.rst:2660 msgid "" -"Note that this example uses Python 3.3 because that's where :func:`shutil." -"chown` makes an appearance. This approach should work with any Python " -"version that supports :func:`dictConfig` - namely, Python 2.7, 3.2 or later. " -"With pre-3.3 versions, you would need to implement the actual ownership " -"change using e.g. :func:`os.chown`." +"$ sudo python3.3 chowntest.py\n" +"$ cat chowntest.log\n" +"2013-11-05 09:34:51,128 DEBUG mylogger A debug message\n" +"$ ls -l chowntest.log\n" +"-rw-r--r-- 1 pulse pulse 55 2013-11-05 09:34 chowntest.log" msgstr "" -#: howto/logging-cookbook.rst:2502 +#: howto/logging-cookbook.rst:2668 +msgid "" +"Note that this example uses Python 3.3 because that's " +"where :func:`shutil.chown` makes an appearance. This approach should work " +"with any Python version that supports :func:`dictConfig` - namely, Python " +"2.7, 3.2 or later. With pre-3.3 versions, you would need to implement the " +"actual ownership change using e.g. :func:`os.chown`." +msgstr "" + +#: howto/logging-cookbook.rst:2674 msgid "" "In practice, the handler-creating function may be in a utility module " "somewhere in your project. Instead of the line in the configuration::" msgstr "" -#: howto/logging-cookbook.rst:2507 +#: howto/logging-cookbook.rst:2677 +msgid "'()': owned_file_handler," +msgstr "" + +#: howto/logging-cookbook.rst:2679 msgid "you could use e.g.::" msgstr "" -#: howto/logging-cookbook.rst:2511 +#: howto/logging-cookbook.rst:2681 +msgid "'()': 'ext://project.util.owned_file_handler'," +msgstr "" + +#: howto/logging-cookbook.rst:2683 msgid "" "where ``project.util`` can be replaced with the actual name of the package " "where the function resides. In the above working script, using ``'ext://" @@ -1316,25 +3370,25 @@ msgid "" "resolved by :func:`dictConfig` from the ``ext://`` specification." msgstr "" -#: howto/logging-cookbook.rst:2516 +#: howto/logging-cookbook.rst:2688 msgid "" "This example hopefully also points the way to how you could implement other " "types of file change - e.g. setting specific POSIX permission bits - in the " "same way, using :func:`os.chmod`." msgstr "" -#: howto/logging-cookbook.rst:2520 +#: howto/logging-cookbook.rst:2692 msgid "" "Of course, the approach could also be extended to types of handler other " "than a :class:`~logging.FileHandler` - for example, one of the rotating file " "handlers, or a different type of handler altogether." msgstr "" -#: howto/logging-cookbook.rst:2530 +#: howto/logging-cookbook.rst:2702 msgid "Using particular formatting styles throughout your application" msgstr "" -#: howto/logging-cookbook.rst:2532 +#: howto/logging-cookbook.rst:2704 msgid "" "In Python 3.2, the :class:`~logging.Formatter` gained a ``style`` keyword " "parameter which, while defaulting to ``%`` for backward compatibility, " @@ -1345,7 +3399,7 @@ msgid "" "is constructed." msgstr "" -#: howto/logging-cookbook.rst:2539 +#: howto/logging-cookbook.rst:2711 msgid "" "Logging calls (:meth:`~Logger.debug`, :meth:`~Logger.info` etc.) only take " "positional parameters for the actual logging message itself, with keyword " @@ -1353,14 +3407,15 @@ msgid "" "call (e.g. the ``exc_info`` keyword parameter to indicate that traceback " "information should be logged, or the ``extra`` keyword parameter to indicate " "additional contextual information to be added to the log). So you cannot " -"directly make logging calls using :meth:`str.format` or :class:`string." -"Template` syntax, because internally the logging package uses %-formatting " -"to merge the format string and the variable arguments. There would be no " -"changing this while preserving backward compatibility, since all logging " -"calls which are out there in existing code will be using %-format strings." +"directly make logging calls using :meth:`str.format` " +"or :class:`string.Template` syntax, because internally the logging package " +"uses %-formatting to merge the format string and the variable arguments. " +"There would be no changing this while preserving backward compatibility, " +"since all logging calls which are out there in existing code will be using %-" +"format strings." msgstr "" -#: howto/logging-cookbook.rst:2551 +#: howto/logging-cookbook.rst:2723 msgid "" "There have been suggestions to associate format styles with specific " "loggers, but that approach also runs into backward compatibility problems " @@ -1368,7 +3423,7 @@ msgid "" "formatting." msgstr "" -#: howto/logging-cookbook.rst:2555 +#: howto/logging-cookbook.rst:2727 msgid "" "For logging to work interoperably between any third-party libraries and your " "code, decisions about formatting need to be made at the level of the " @@ -1376,11 +3431,11 @@ msgid "" "formatting styles can be accommodated." msgstr "" -#: howto/logging-cookbook.rst:2562 +#: howto/logging-cookbook.rst:2734 msgid "Using LogRecord factories" msgstr "" -#: howto/logging-cookbook.rst:2564 +#: howto/logging-cookbook.rst:2736 msgid "" "In Python 3.2, along with the :class:`~logging.Formatter` changes mentioned " "above, the logging package gained the ability to allow users to set their " @@ -1395,27 +3450,27 @@ msgid "" "implementation does." msgstr "" -#: howto/logging-cookbook.rst:2575 +#: howto/logging-cookbook.rst:2747 msgid "" -"Refer to the reference documentation on :func:`setLogRecordFactory` and :" -"class:`LogRecord` for more information." +"Refer to the reference documentation on :func:`setLogRecordFactory` " +"and :class:`LogRecord` for more information." msgstr "" -#: howto/logging-cookbook.rst:2580 +#: howto/logging-cookbook.rst:2752 msgid "Using custom message objects" msgstr "" -#: howto/logging-cookbook.rst:2582 +#: howto/logging-cookbook.rst:2754 msgid "" "There is another, perhaps simpler way that you can use {}- and $- formatting " -"to construct your individual log messages. You may recall (from :ref:" -"`arbitrary-object-messages`) that when logging you can use an arbitrary " -"object as a message format string, and that the logging package will call :" -"func:`str` on that object to get the actual format string. Consider the " -"following two classes::" +"to construct your individual log messages. You may recall " +"(from :ref:`arbitrary-object-messages`) that when logging you can use an " +"arbitrary object as a message format string, and that the logging package " +"will call :func:`str` on that object to get the actual format string. " +"Consider the following two classes::" msgstr "" -#: howto/logging-cookbook.rst:2607 +#: howto/logging-cookbook.rst:2779 msgid "" "Either of these can be used in place of a format string, to allow {}- or $-" "formatting to be used to build the actual \"message\" part which appears in " @@ -1426,17 +3481,40 @@ msgid "" "using ``_`` for localization)." msgstr "" -#: howto/logging-cookbook.rst:2615 +#: howto/logging-cookbook.rst:2787 +msgid "" +"Examples of this approach are given below. Firstly, formatting " +"with :meth:`str.format`::" +msgstr "" + +#: howto/logging-cookbook.rst:2790 msgid "" -"Examples of this approach are given below. Firstly, formatting with :meth:" -"`str.format`::" +">>> __ = BraceMessage\n" +">>> print(__('Message with {0} {1}', 2, 'placeholders'))\n" +"Message with 2 placeholders\n" +">>> class Point: pass\n" +"...\n" +">>> p = Point()\n" +">>> p.x = 0.5\n" +">>> p.y = 0.5\n" +">>> print(__('Message with coordinates: ({point.x:.2f}, {point.y:.2f})', " +"point=p))\n" +"Message with coordinates: (0.50, 0.50)" msgstr "" -#: howto/logging-cookbook.rst:2629 +#: howto/logging-cookbook.rst:2801 msgid "Secondly, formatting with :class:`string.Template`::" msgstr "" -#: howto/logging-cookbook.rst:2636 +#: howto/logging-cookbook.rst:2803 +msgid "" +">>> __ = DollarMessage\n" +">>> print(__('Message with $num $what', num=2, what='placeholders'))\n" +"Message with 2 placeholders\n" +">>>" +msgstr "" + +#: howto/logging-cookbook.rst:2808 msgid "" "One thing to note is that you pay no significant performance penalty with " "this approach: the actual formatting happens not when you make the logging " @@ -1448,41 +3526,90 @@ msgid "" "shown above." msgstr "" -#: howto/logging-cookbook.rst:2650 +#: howto/logging-cookbook.rst:2822 msgid "Configuring filters with :func:`dictConfig`" msgstr "" -#: howto/logging-cookbook.rst:2652 +#: howto/logging-cookbook.rst:2824 msgid "" "You *can* configure filters using :func:`~logging.config.dictConfig`, though " "it might not be obvious at first glance how to do it (hence this recipe). " "Since :class:`~logging.Filter` is the only filter class included in the " "standard library, and it is unlikely to cater to many requirements (it's " -"only there as a base class), you will typically need to define your own :" -"class:`~logging.Filter` subclass with an overridden :meth:`~logging.Filter." -"filter` method. To do this, specify the ``()`` key in the configuration " -"dictionary for the filter, specifying a callable which will be used to " -"create the filter (a class is the most obvious, but you can provide any " -"callable which returns a :class:`~logging.Filter` instance). Here is a " -"complete example::" +"only there as a base class), you will typically need to define your " +"own :class:`~logging.Filter` subclass with an " +"overridden :meth:`~logging.Filter.filter` method. To do this, specify the " +"``()`` key in the configuration dictionary for the filter, specifying a " +"callable which will be used to create the filter (a class is the most " +"obvious, but you can provide any callable which returns " +"a :class:`~logging.Filter` instance). Here is a complete example::" +msgstr "" + +#: howto/logging-cookbook.rst:2835 +msgid "" +"import logging\n" +"import logging.config\n" +"import sys\n" +"\n" +"class MyFilter(logging.Filter):\n" +" def __init__(self, param=None):\n" +" self.param = param\n" +"\n" +" def filter(self, record):\n" +" if self.param is None:\n" +" allow = True\n" +" else:\n" +" allow = self.param not in record.msg\n" +" if allow:\n" +" record.msg = 'changed: ' + record.msg\n" +" return allow\n" +"\n" +"LOGGING = {\n" +" 'version': 1,\n" +" 'filters': {\n" +" 'myfilter': {\n" +" '()': MyFilter,\n" +" 'param': 'noshow',\n" +" }\n" +" },\n" +" 'handlers': {\n" +" 'console': {\n" +" 'class': 'logging.StreamHandler',\n" +" 'filters': ['myfilter']\n" +" }\n" +" },\n" +" 'root': {\n" +" 'level': 'DEBUG',\n" +" 'handlers': ['console']\n" +" },\n" +"}\n" +"\n" +"if __name__ == '__main__':\n" +" logging.config.dictConfig(LOGGING)\n" +" logging.debug('hello')\n" +" logging.debug('hello - noshow')" msgstr "" -#: howto/logging-cookbook.rst:2705 +#: howto/logging-cookbook.rst:2877 msgid "" "This example shows how you can pass configuration data to the callable which " "constructs the instance, in the form of keyword parameters. When run, the " "above script will print:" msgstr "" -#: howto/logging-cookbook.rst:2713 +#: howto/logging-cookbook.rst:2881 +msgid "changed: hello" +msgstr "" + +#: howto/logging-cookbook.rst:2885 msgid "which shows that the filter is working as configured." msgstr "" -#: howto/logging-cookbook.rst:2715 +#: howto/logging-cookbook.rst:2887 msgid "A couple of extra points to note:" msgstr "" -#: howto/logging-cookbook.rst:2717 +#: howto/logging-cookbook.rst:2889 msgid "" "If you can't refer to the callable directly in the configuration (e.g. if it " "lives in a different module, and you can't import it directly where the " @@ -1492,7 +3619,7 @@ msgid "" "the above example." msgstr "" -#: howto/logging-cookbook.rst:2724 +#: howto/logging-cookbook.rst:2896 msgid "" "As well as for filters, this technique can also be used to configure custom " "handlers and formatters. See :ref:`logging-config-dict-userdef` for more " @@ -1501,11 +3628,11 @@ msgid "" "above." msgstr "" -#: howto/logging-cookbook.rst:2733 +#: howto/logging-cookbook.rst:2905 msgid "Customized exception formatting" msgstr "" -#: howto/logging-cookbook.rst:2735 +#: howto/logging-cookbook.rst:2907 msgid "" "There might be times when you want to do customized exception formatting - " "for argument's sake, let's say you want exactly one line per logged event, " @@ -1513,56 +3640,136 @@ msgid "" "formatter class, as shown in the following example::" msgstr "" -#: howto/logging-cookbook.rst:2776 +#: howto/logging-cookbook.rst:2912 +msgid "" +"import logging\n" +"\n" +"class OneLineExceptionFormatter(logging.Formatter):\n" +" def formatException(self, exc_info):\n" +" \"\"\"\n" +" Format an exception so that it prints on a single line.\n" +" \"\"\"\n" +" result = super().formatException(exc_info)\n" +" return repr(result) # or format into one line however you want to\n" +"\n" +" def format(self, record):\n" +" s = super().format(record)\n" +" if record.exc_text:\n" +" s = s.replace('\\n', '') + '|'\n" +" return s\n" +"\n" +"def configure_logging():\n" +" fh = logging.FileHandler('output.txt', 'w')\n" +" f = OneLineExceptionFormatter('%(asctime)s|%(levelname)s|%(message)s|',\n" +" '%d/%m/%Y %H:%M:%S')\n" +" fh.setFormatter(f)\n" +" root = logging.getLogger()\n" +" root.setLevel(logging.DEBUG)\n" +" root.addHandler(fh)\n" +"\n" +"def main():\n" +" configure_logging()\n" +" logging.info('Sample message')\n" +" try:\n" +" x = 1 / 0\n" +" except ZeroDivisionError as e:\n" +" logging.exception('ZeroDivisionError: %s', e)\n" +"\n" +"if __name__ == '__main__':\n" +" main()" +msgstr "" + +#: howto/logging-cookbook.rst:2948 msgid "When run, this produces a file with exactly two lines:" msgstr "" -#: howto/logging-cookbook.rst:2783 +#: howto/logging-cookbook.rst:2950 +msgid "" +"28/01/2015 07:21:23|INFO|Sample message|\n" +"28/01/2015 07:21:23|ERROR|ZeroDivisionError: integer division or modulo by " +"zero|'Traceback (most recent call last):\\n File \"logtest7.py\", line 30, " +"in main\\n x = 1 / 0\\nZeroDivisionError: integer division or modulo by " +"zero'|" +msgstr "" + +#: howto/logging-cookbook.rst:2955 msgid "" "While the above treatment is simplistic, it points the way to how exception " "information can be formatted to your liking. The :mod:`traceback` module may " "be helpful for more specialized needs." msgstr "" -#: howto/logging-cookbook.rst:2790 +#: howto/logging-cookbook.rst:2962 msgid "Speaking logging messages" msgstr "" -#: howto/logging-cookbook.rst:2792 +#: howto/logging-cookbook.rst:2964 msgid "" "There might be situations when it is desirable to have logging messages " "rendered in an audible rather than a visible format. This is easy to do if " "you have text-to-speech (TTS) functionality available in your system, even " "if it doesn't have a Python binding. Most TTS systems have a command line " -"program you can run, and this can be invoked from a handler using :mod:" -"`subprocess`. It's assumed here that TTS command line programs won't expect " -"to interact with users or take a long time to complete, and that the " -"frequency of logged messages will be not so high as to swamp the user with " -"messages, and that it's acceptable to have the messages spoken one at a time " -"rather than concurrently, The example implementation below waits for one " -"message to be spoken before the next is processed, and this might cause " -"other handlers to be kept waiting. Here is a short example showing the " +"program you can run, and this can be invoked from a handler " +"using :mod:`subprocess`. It's assumed here that TTS command line programs " +"won't expect to interact with users or take a long time to complete, and " +"that the frequency of logged messages will be not so high as to swamp the " +"user with messages, and that it's acceptable to have the messages spoken one " +"at a time rather than concurrently, The example implementation below waits " +"for one message to be spoken before the next is processed, and this might " +"cause other handlers to be kept waiting. Here is a short example showing the " "approach, which assumes that the ``espeak`` TTS package is available::" msgstr "" -#: howto/logging-cookbook.rst:2834 +#: howto/logging-cookbook.rst:2977 +msgid "" +"import logging\n" +"import subprocess\n" +"import sys\n" +"\n" +"class TTSHandler(logging.Handler):\n" +" def emit(self, record):\n" +" msg = self.format(record)\n" +" # Speak slowly in a female English voice\n" +" cmd = ['espeak', '-s150', '-ven+f3', msg]\n" +" p = subprocess.Popen(cmd, stdout=subprocess.PIPE,\n" +" stderr=subprocess.STDOUT)\n" +" # wait for the program to finish\n" +" p.communicate()\n" +"\n" +"def configure_logging():\n" +" h = TTSHandler()\n" +" root = logging.getLogger()\n" +" root.addHandler(h)\n" +" # the default formatter just returns the message\n" +" root.setLevel(logging.DEBUG)\n" +"\n" +"def main():\n" +" logging.info('Hello')\n" +" logging.debug('Goodbye')\n" +"\n" +"if __name__ == '__main__':\n" +" configure_logging()\n" +" sys.exit(main())" +msgstr "" + +#: howto/logging-cookbook.rst:3006 msgid "" "When run, this script should say \"Hello\" and then \"Goodbye\" in a female " "voice." msgstr "" -#: howto/logging-cookbook.rst:2836 +#: howto/logging-cookbook.rst:3008 msgid "" "The above approach can, of course, be adapted to other TTS systems and even " "other systems altogether which can process messages via external programs " "run from a command line." msgstr "" -#: howto/logging-cookbook.rst:2844 +#: howto/logging-cookbook.rst:3016 msgid "Buffering logging messages and outputting them conditionally" msgstr "" -#: howto/logging-cookbook.rst:2846 +#: howto/logging-cookbook.rst:3018 msgid "" "There might be situations where you want to log messages in a temporary area " "and only output them if a certain condition occurs. For example, you may " @@ -1572,7 +3779,7 @@ msgid "" "debug information to be output as well as the error." msgstr "" -#: howto/logging-cookbook.rst:2853 +#: howto/logging-cookbook.rst:3025 msgid "" "Here is an example which shows how you could do this using a decorator for " "your functions where you want logging to behave this way. It makes use of " @@ -1585,7 +3792,7 @@ msgid "" "subclass of ``MemoryHandler`` if you want custom flushing behavior." msgstr "" -#: howto/logging-cookbook.rst:2863 +#: howto/logging-cookbook.rst:3035 msgid "" "The example script has a simple function, ``foo``, which just cycles through " "all the logging levels, writing to ``sys.stderr`` to say what level it's " @@ -1594,53 +3801,224 @@ msgid "" "levels - otherwise, it only logs at DEBUG, INFO and WARNING levels." msgstr "" -#: howto/logging-cookbook.rst:2869 +#: howto/logging-cookbook.rst:3041 msgid "" "The script just arranges to decorate ``foo`` with a decorator which will do " "the conditional logging that's required. The decorator takes a logger as a " "parameter and attaches a memory handler for the duration of the call to the " "decorated function. The decorator can be additionally parameterised using a " "target handler, a level at which flushing should occur, and a capacity for " -"the buffer (number of records buffered). These default to a :class:`~logging." -"StreamHandler` which writes to ``sys.stderr``, ``logging.ERROR`` and ``100`` " -"respectively." +"the buffer (number of records buffered). These default to " +"a :class:`~logging.StreamHandler` which writes to ``sys.stderr``, " +"``logging.ERROR`` and ``100`` respectively." msgstr "" -#: howto/logging-cookbook.rst:2877 +#: howto/logging-cookbook.rst:3049 msgid "Here's the script::" msgstr "" -#: howto/logging-cookbook.rst:2940 +#: howto/logging-cookbook.rst:3051 +msgid "" +"import logging\n" +"from logging.handlers import MemoryHandler\n" +"import sys\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"logger.addHandler(logging.NullHandler())\n" +"\n" +"def log_if_errors(logger, target_handler=None, flush_level=None, " +"capacity=None):\n" +" if target_handler is None:\n" +" target_handler = logging.StreamHandler()\n" +" if flush_level is None:\n" +" flush_level = logging.ERROR\n" +" if capacity is None:\n" +" capacity = 100\n" +" handler = MemoryHandler(capacity, flushLevel=flush_level, " +"target=target_handler)\n" +"\n" +" def decorator(fn):\n" +" def wrapper(*args, **kwargs):\n" +" logger.addHandler(handler)\n" +" try:\n" +" return fn(*args, **kwargs)\n" +" except Exception:\n" +" logger.exception('call failed')\n" +" raise\n" +" finally:\n" +" super(MemoryHandler, handler).flush()\n" +" logger.removeHandler(handler)\n" +" return wrapper\n" +"\n" +" return decorator\n" +"\n" +"def write_line(s):\n" +" sys.stderr.write('%s\\n' % s)\n" +"\n" +"def foo(fail=False):\n" +" write_line('about to log at DEBUG ...')\n" +" logger.debug('Actually logged at DEBUG')\n" +" write_line('about to log at INFO ...')\n" +" logger.info('Actually logged at INFO')\n" +" write_line('about to log at WARNING ...')\n" +" logger.warning('Actually logged at WARNING')\n" +" if fail:\n" +" write_line('about to log at ERROR ...')\n" +" logger.error('Actually logged at ERROR')\n" +" write_line('about to log at CRITICAL ...')\n" +" logger.critical('Actually logged at CRITICAL')\n" +" return fail\n" +"\n" +"decorated_foo = log_if_errors(logger)(foo)\n" +"\n" +"if __name__ == '__main__':\n" +" logger.setLevel(logging.DEBUG)\n" +" write_line('Calling undecorated foo with False')\n" +" assert not foo(False)\n" +" write_line('Calling undecorated foo with True')\n" +" assert foo(True)\n" +" write_line('Calling decorated foo with False')\n" +" assert not decorated_foo(False)\n" +" write_line('Calling decorated foo with True')\n" +" assert decorated_foo(True)" +msgstr "" + +#: howto/logging-cookbook.rst:3112 msgid "When this script is run, the following output should be observed:" msgstr "" -#: howto/logging-cookbook.rst:2970 +#: howto/logging-cookbook.rst:3114 +msgid "" +"Calling undecorated foo with False\n" +"about to log at DEBUG ...\n" +"about to log at INFO ...\n" +"about to log at WARNING ...\n" +"Calling undecorated foo with True\n" +"about to log at DEBUG ...\n" +"about to log at INFO ...\n" +"about to log at WARNING ...\n" +"about to log at ERROR ...\n" +"about to log at CRITICAL ...\n" +"Calling decorated foo with False\n" +"about to log at DEBUG ...\n" +"about to log at INFO ...\n" +"about to log at WARNING ...\n" +"Calling decorated foo with True\n" +"about to log at DEBUG ...\n" +"about to log at INFO ...\n" +"about to log at WARNING ...\n" +"about to log at ERROR ...\n" +"Actually logged at DEBUG\n" +"Actually logged at INFO\n" +"Actually logged at WARNING\n" +"Actually logged at ERROR\n" +"about to log at CRITICAL ...\n" +"Actually logged at CRITICAL" +msgstr "" + +#: howto/logging-cookbook.rst:3142 msgid "" "As you can see, actual logging output only occurs when an event is logged " "whose severity is ERROR or greater, but in that case, any previous events at " "lower severities are also logged." msgstr "" -#: howto/logging-cookbook.rst:2974 +#: howto/logging-cookbook.rst:3146 msgid "You can of course use the conventional means of decoration::" msgstr "" -#: howto/logging-cookbook.rst:2984 +#: howto/logging-cookbook.rst:3148 +msgid "" +"@log_if_errors(logger)\n" +"def foo(fail=False):\n" +" ..." +msgstr "" + +#: howto/logging-cookbook.rst:3156 msgid "Sending logging messages to email, with buffering" msgstr "" -#: howto/logging-cookbook.rst:2986 +#: howto/logging-cookbook.rst:3158 msgid "" "To illustrate how you can send log messages via email, so that a set number " -"of messages are sent per email, you can subclass :class:`~logging.handlers." -"BufferingHandler`. In the following example, which you can adapt to suit " -"your specific needs, a simple test harness is provided which allows you to " -"run the script with command line arguments specifying what you typically " -"need to send things via SMTP. (Run the downloaded script with the ``-h`` " -"argument to see the required and optional arguments.)" -msgstr "" - -#: howto/logging-cookbook.rst:3058 +"of messages are sent per email, you can " +"subclass :class:`~logging.handlers.BufferingHandler`. In the following " +"example, which you can adapt to suit your specific needs, a simple test " +"harness is provided which allows you to run the script with command line " +"arguments specifying what you typically need to send things via SMTP. (Run " +"the downloaded script with the ``-h`` argument to see the required and " +"optional arguments.)" +msgstr "" + +#: howto/logging-cookbook.rst:3166 +msgid "" +"import logging\n" +"import logging.handlers\n" +"import smtplib\n" +"\n" +"class BufferingSMTPHandler(logging.handlers.BufferingHandler):\n" +" def __init__(self, mailhost, port, username, password, fromaddr, " +"toaddrs,\n" +" subject, capacity):\n" +" logging.handlers.BufferingHandler.__init__(self, capacity)\n" +" self.mailhost = mailhost\n" +" self.mailport = port\n" +" self.username = username\n" +" self.password = password\n" +" self.fromaddr = fromaddr\n" +" if isinstance(toaddrs, str):\n" +" toaddrs = [toaddrs]\n" +" self.toaddrs = toaddrs\n" +" self.subject = subject\n" +" self.setFormatter(logging.Formatter(\"%(asctime)s %(levelname)-5s %" +"(message)s\"))\n" +"\n" +" def flush(self):\n" +" if len(self.buffer) > 0:\n" +" try:\n" +" smtp = smtplib.SMTP(self.mailhost, self.mailport)\n" +" smtp.starttls()\n" +" smtp.login(self.username, self.password)\n" +" msg = \"From: %s\\r\\nTo: %s\\r\\nSubject: %s\\r\\n\\r\\n\" " +"% (self.fromaddr, ','.join(self.toaddrs), self.subject)\n" +" for record in self.buffer:\n" +" s = self.format(record)\n" +" msg = msg + s + \"\\r\\n\"\n" +" smtp.sendmail(self.fromaddr, self.toaddrs, msg)\n" +" smtp.quit()\n" +" except Exception:\n" +" if logging.raiseExceptions:\n" +" raise\n" +" self.buffer = []\n" +"\n" +"if __name__ == '__main__':\n" +" import argparse\n" +"\n" +" ap = argparse.ArgumentParser()\n" +" aa = ap.add_argument\n" +" aa('host', metavar='HOST', help='SMTP server')\n" +" aa('--port', '-p', type=int, default=587, help='SMTP port')\n" +" aa('user', metavar='USER', help='SMTP username')\n" +" aa('password', metavar='PASSWORD', help='SMTP password')\n" +" aa('to', metavar='TO', help='Addressee for emails')\n" +" aa('sender', metavar='SENDER', help='Sender email address')\n" +" aa('--subject', '-s',\n" +" default='Test Logging email from Python logging module (buffering)',\n" +" help='Subject of email')\n" +" options = ap.parse_args()\n" +" logger = logging.getLogger()\n" +" logger.setLevel(logging.DEBUG)\n" +" h = BufferingSMTPHandler(options.host, options.port, options.user,\n" +" options.password, options.sender,\n" +" options.to, options.subject, 10)\n" +" logger.addHandler(h)\n" +" for i in range(102):\n" +" logger.info(\"Info index = %d\", i)\n" +" h.flush()\n" +" h.close()" +msgstr "" + +#: howto/logging-cookbook.rst:3230 msgid "" "If you run this script and your SMTP server is correctly set up, you should " "find that it sends eleven emails to the addressee you specify. The first ten " @@ -1648,39 +4026,95 @@ msgid "" "messages. That makes up 102 messages as specified in the script." msgstr "" -#: howto/logging-cookbook.rst:3066 +#: howto/logging-cookbook.rst:3238 msgid "Formatting times using UTC (GMT) via configuration" msgstr "" -#: howto/logging-cookbook.rst:3068 +#: howto/logging-cookbook.rst:3240 msgid "" "Sometimes you want to format times using UTC, which can be done using a " "class such as ``UTCFormatter``, shown below::" msgstr "" -#: howto/logging-cookbook.rst:3077 +#: howto/logging-cookbook.rst:3243 msgid "" -"and you can then use the ``UTCFormatter`` in your code instead of :class:" -"`~logging.Formatter`. If you want to do that via configuration, you can use " -"the :func:`~logging.config.dictConfig` API with an approach illustrated by " -"the following complete example::" +"import logging\n" +"import time\n" +"\n" +"class UTCFormatter(logging.Formatter):\n" +" converter = time.gmtime" msgstr "" -#: howto/logging-cookbook.rst:3120 +#: howto/logging-cookbook.rst:3249 +msgid "" +"and you can then use the ``UTCFormatter`` in your code instead " +"of :class:`~logging.Formatter`. If you want to do that via configuration, " +"you can use the :func:`~logging.config.dictConfig` API with an approach " +"illustrated by the following complete example::" +msgstr "" + +#: howto/logging-cookbook.rst:3254 +msgid "" +"import logging\n" +"import logging.config\n" +"import time\n" +"\n" +"class UTCFormatter(logging.Formatter):\n" +" converter = time.gmtime\n" +"\n" +"LOGGING = {\n" +" 'version': 1,\n" +" 'disable_existing_loggers': False,\n" +" 'formatters': {\n" +" 'utc': {\n" +" '()': UTCFormatter,\n" +" 'format': '%(asctime)s %(message)s',\n" +" },\n" +" 'local': {\n" +" 'format': '%(asctime)s %(message)s',\n" +" }\n" +" },\n" +" 'handlers': {\n" +" 'console1': {\n" +" 'class': 'logging.StreamHandler',\n" +" 'formatter': 'utc',\n" +" },\n" +" 'console2': {\n" +" 'class': 'logging.StreamHandler',\n" +" 'formatter': 'local',\n" +" },\n" +" },\n" +" 'root': {\n" +" 'handlers': ['console1', 'console2'],\n" +" }\n" +"}\n" +"\n" +"if __name__ == '__main__':\n" +" logging.config.dictConfig(LOGGING)\n" +" logging.warning('The local time is %s', time.asctime())" +msgstr "" + +#: howto/logging-cookbook.rst:3292 msgid "When this script is run, it should print something like:" msgstr "" -#: howto/logging-cookbook.rst:3127 +#: howto/logging-cookbook.rst:3294 +msgid "" +"2015-10-17 12:53:29,501 The local time is Sat Oct 17 13:53:29 2015\n" +"2015-10-17 13:53:29,501 The local time is Sat Oct 17 13:53:29 2015" +msgstr "" + +#: howto/logging-cookbook.rst:3299 msgid "" "showing how the time is formatted both as local time and UTC, one for each " "handler." msgstr "" -#: howto/logging-cookbook.rst:3134 +#: howto/logging-cookbook.rst:3306 msgid "Using a context manager for selective logging" msgstr "" -#: howto/logging-cookbook.rst:3136 +#: howto/logging-cookbook.rst:3308 msgid "" "There are times when it would be useful to temporarily change the logging " "configuration and revert it back after doing something. For this, a context " @@ -1690,7 +4124,36 @@ msgid "" "scope of the context manager::" msgstr "" -#: howto/logging-cookbook.rst:3169 +#: howto/logging-cookbook.rst:3315 +msgid "" +"import logging\n" +"import sys\n" +"\n" +"class LoggingContext:\n" +" def __init__(self, logger, level=None, handler=None, close=True):\n" +" self.logger = logger\n" +" self.level = level\n" +" self.handler = handler\n" +" self.close = close\n" +"\n" +" def __enter__(self):\n" +" if self.level is not None:\n" +" self.old_level = self.logger.level\n" +" self.logger.setLevel(self.level)\n" +" if self.handler:\n" +" self.logger.addHandler(self.handler)\n" +"\n" +" def __exit__(self, et, ev, tb):\n" +" if self.level is not None:\n" +" self.logger.setLevel(self.old_level)\n" +" if self.handler:\n" +" self.logger.removeHandler(self.handler)\n" +" if self.handler and self.close:\n" +" self.handler.close()\n" +" # implicit return of None => don't swallow exceptions" +msgstr "" + +#: howto/logging-cookbook.rst:3341 msgid "" "If you specify a level value, the logger's level is set to that value in the " "scope of the with block covered by the context manager. If you specify a " @@ -1699,13 +4162,33 @@ msgid "" "block exit - you could do this if you don't need the handler any more." msgstr "" -#: howto/logging-cookbook.rst:3175 +#: howto/logging-cookbook.rst:3347 msgid "" "To illustrate how it works, we can add the following block of code to the " "above::" msgstr "" -#: howto/logging-cookbook.rst:3193 +#: howto/logging-cookbook.rst:3350 +msgid "" +"if __name__ == '__main__':\n" +" logger = logging.getLogger('foo')\n" +" logger.addHandler(logging.StreamHandler())\n" +" logger.setLevel(logging.INFO)\n" +" logger.info('1. This should appear just once on stderr.')\n" +" logger.debug('2. This should not appear.')\n" +" with LoggingContext(logger, level=logging.DEBUG):\n" +" logger.debug('3. This should appear once on stderr.')\n" +" logger.debug('4. This should not appear.')\n" +" h = logging.StreamHandler(sys.stdout)\n" +" with LoggingContext(logger, level=logging.DEBUG, handler=h, " +"close=True):\n" +" logger.debug('5. This should appear twice - once on stderr and once " +"on stdout.')\n" +" logger.info('6. This should appear just once on stderr.')\n" +" logger.debug('7. This should not appear.')" +msgstr "" + +#: howto/logging-cookbook.rst:3365 msgid "" "We initially set the logger's level to ``INFO``, so message #1 appears and " "message #2 doesn't. We then change the level to ``DEBUG`` temporarily in the " @@ -1718,121 +4201,284 @@ msgid "" "(like message #1) whereas message #7 doesn't (just like message #2)." msgstr "" -#: howto/logging-cookbook.rst:3203 +#: howto/logging-cookbook.rst:3375 msgid "If we run the resulting script, the result is as follows:" msgstr "" -#: howto/logging-cookbook.rst:3214 +#: howto/logging-cookbook.rst:3377 +msgid "" +"$ python logctx.py\n" +"1. This should appear just once on stderr.\n" +"3. This should appear once on stderr.\n" +"5. This should appear twice - once on stderr and once on stdout.\n" +"5. This should appear twice - once on stderr and once on stdout.\n" +"6. This should appear just once on stderr." +msgstr "" + +#: howto/logging-cookbook.rst:3386 msgid "" "If we run it again, but pipe ``stderr`` to ``/dev/null``, we see the " "following, which is the only message written to ``stdout``:" msgstr "" -#: howto/logging-cookbook.rst:3222 +#: howto/logging-cookbook.rst:3389 +msgid "" +"$ python logctx.py 2>/dev/null\n" +"5. This should appear twice - once on stderr and once on stdout." +msgstr "" + +#: howto/logging-cookbook.rst:3394 msgid "Once again, but piping ``stdout`` to ``/dev/null``, we get:" msgstr "" -#: howto/logging-cookbook.rst:3232 +#: howto/logging-cookbook.rst:3396 +msgid "" +"$ python logctx.py >/dev/null\n" +"1. This should appear just once on stderr.\n" +"3. This should appear once on stderr.\n" +"5. This should appear twice - once on stderr and once on stdout.\n" +"6. This should appear just once on stderr." +msgstr "" + +#: howto/logging-cookbook.rst:3404 msgid "" "In this case, the message #5 printed to ``stdout`` doesn't appear, as " "expected." msgstr "" -#: howto/logging-cookbook.rst:3234 +#: howto/logging-cookbook.rst:3406 msgid "" "Of course, the approach described here can be generalised, for example to " "attach logging filters temporarily. Note that the above code works in Python " "2 as well as Python 3." msgstr "" -#: howto/logging-cookbook.rst:3242 +#: howto/logging-cookbook.rst:3414 msgid "A CLI application starter template" msgstr "" -#: howto/logging-cookbook.rst:3244 +#: howto/logging-cookbook.rst:3416 msgid "Here's an example which shows how you can:" msgstr "" -#: howto/logging-cookbook.rst:3246 +#: howto/logging-cookbook.rst:3418 msgid "Use a logging level based on command-line arguments" msgstr "" -#: howto/logging-cookbook.rst:3247 +#: howto/logging-cookbook.rst:3419 msgid "" "Dispatch to multiple subcommands in separate files, all logging at the same " "level in a consistent way" msgstr "" -#: howto/logging-cookbook.rst:3249 +#: howto/logging-cookbook.rst:3421 msgid "Make use of simple, minimal configuration" msgstr "" -#: howto/logging-cookbook.rst:3251 +#: howto/logging-cookbook.rst:3423 msgid "" "Suppose we have a command-line application whose job is to stop, start or " "restart some services. This could be organised for the purposes of " "illustration as a file ``app.py`` that is the main script for the " -"application, with individual commands implemented in ``start.py``, ``stop." -"py`` and ``restart.py``. Suppose further that we want to control the " +"application, with individual commands implemented in ``start.py``, " +"``stop.py`` and ``restart.py``. Suppose further that we want to control the " "verbosity of the application via a command-line argument, defaulting to " "``logging.INFO``. Here's one way that ``app.py`` could be written::" msgstr "" -#: howto/logging-cookbook.rst:3300 +#: howto/logging-cookbook.rst:3431 +msgid "" +"import argparse\n" +"import importlib\n" +"import logging\n" +"import os\n" +"import sys\n" +"\n" +"def main(args=None):\n" +" scriptname = os.path.basename(__file__)\n" +" parser = argparse.ArgumentParser(scriptname)\n" +" levels = ('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL')\n" +" parser.add_argument('--log-level', default='INFO', choices=levels)\n" +" subparsers = parser.add_subparsers(dest='command',\n" +" help='Available commands:')\n" +" start_cmd = subparsers.add_parser('start', help='Start a service')\n" +" start_cmd.add_argument('name', metavar='NAME',\n" +" help='Name of service to start')\n" +" stop_cmd = subparsers.add_parser('stop',\n" +" help='Stop one or more services')\n" +" stop_cmd.add_argument('names', metavar='NAME', nargs='+',\n" +" help='Name of service to stop')\n" +" restart_cmd = subparsers.add_parser('restart',\n" +" help='Restart one or more " +"services')\n" +" restart_cmd.add_argument('names', metavar='NAME', nargs='+',\n" +" help='Name of service to restart')\n" +" options = parser.parse_args()\n" +" # the code to dispatch commands could all be in this file. For the " +"purposes\n" +" # of illustration only, we implement each command in a separate module.\n" +" try:\n" +" mod = importlib.import_module(options.command)\n" +" cmd = getattr(mod, 'command')\n" +" except (ImportError, AttributeError):\n" +" print('Unable to find the code for command \\'%s\\'' % " +"options.command)\n" +" return 1\n" +" # Could get fancy here and load configuration from file or dictionary\n" +" logging.basicConfig(level=options.log_level,\n" +" format='%(levelname)s %(name)s %(message)s')\n" +" cmd(options)\n" +"\n" +"if __name__ == '__main__':\n" +" sys.exit(main())" +msgstr "" + +#: howto/logging-cookbook.rst:3472 msgid "" "And the ``start``, ``stop`` and ``restart`` commands can be implemented in " "separate modules, like so for starting::" msgstr "" -#: howto/logging-cookbook.rst:3313 +#: howto/logging-cookbook.rst:3475 +msgid "" +"# start.py\n" +"import logging\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"def command(options):\n" +" logger.debug('About to start %s', options.name)\n" +" # actually do the command processing here ...\n" +" logger.info('Started the \\'%s\\' service.', options.name)" +msgstr "" + +#: howto/logging-cookbook.rst:3485 msgid "and thus for stopping::" msgstr "" -#: howto/logging-cookbook.rst:3334 +#: howto/logging-cookbook.rst:3487 +msgid "" +"# stop.py\n" +"import logging\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"def command(options):\n" +" n = len(options.names)\n" +" if n == 1:\n" +" plural = ''\n" +" services = '\\'%s\\'' % options.names[0]\n" +" else:\n" +" plural = 's'\n" +" services = ', '.join('\\'%s\\'' % name for name in options.names)\n" +" i = services.rfind(', ')\n" +" services = services[:i] + ' and ' + services[i + 2:]\n" +" logger.debug('About to stop %s', services)\n" +" # actually do the command processing here ...\n" +" logger.info('Stopped the %s service%s.', services, plural)" +msgstr "" + +#: howto/logging-cookbook.rst:3506 msgid "and similarly for restarting::" msgstr "" -#: howto/logging-cookbook.rst:3355 +#: howto/logging-cookbook.rst:3508 +msgid "" +"# restart.py\n" +"import logging\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"def command(options):\n" +" n = len(options.names)\n" +" if n == 1:\n" +" plural = ''\n" +" services = '\\'%s\\'' % options.names[0]\n" +" else:\n" +" plural = 's'\n" +" services = ', '.join('\\'%s\\'' % name for name in options.names)\n" +" i = services.rfind(', ')\n" +" services = services[:i] + ' and ' + services[i + 2:]\n" +" logger.debug('About to restart %s', services)\n" +" # actually do the command processing here ...\n" +" logger.info('Restarted the %s service%s.', services, plural)" +msgstr "" + +#: howto/logging-cookbook.rst:3527 msgid "" "If we run this application with the default log level, we get output like " "this:" msgstr "" -#: howto/logging-cookbook.rst:3368 +#: howto/logging-cookbook.rst:3529 +msgid "" +"$ python app.py start foo\n" +"INFO start Started the 'foo' service.\n" +"\n" +"$ python app.py stop foo bar\n" +"INFO stop Stopped the 'foo' and 'bar' services.\n" +"\n" +"$ python app.py restart foo bar baz\n" +"INFO restart Restarted the 'foo', 'bar' and 'baz' services." +msgstr "" + +#: howto/logging-cookbook.rst:3540 msgid "" "The first word is the logging level, and the second word is the module or " "package name of the place where the event was logged." msgstr "" -#: howto/logging-cookbook.rst:3371 +#: howto/logging-cookbook.rst:3543 msgid "" "If we change the logging level, then we can change the information sent to " "the log. For example, if we want more information:" msgstr "" -#: howto/logging-cookbook.rst:3388 +#: howto/logging-cookbook.rst:3546 +msgid "" +"$ python app.py --log-level DEBUG start foo\n" +"DEBUG start About to start foo\n" +"INFO start Started the 'foo' service.\n" +"\n" +"$ python app.py --log-level DEBUG stop foo bar\n" +"DEBUG stop About to stop 'foo' and 'bar'\n" +"INFO stop Stopped the 'foo' and 'bar' services.\n" +"\n" +"$ python app.py --log-level DEBUG restart foo bar baz\n" +"DEBUG restart About to restart 'foo', 'bar' and 'baz'\n" +"INFO restart Restarted the 'foo', 'bar' and 'baz' services." +msgstr "" + +#: howto/logging-cookbook.rst:3560 msgid "And if we want less:" msgstr "" -#: howto/logging-cookbook.rst:3396 +#: howto/logging-cookbook.rst:3562 +msgid "" +"$ python app.py --log-level WARNING start foo\n" +"$ python app.py --log-level WARNING stop foo bar\n" +"$ python app.py --log-level WARNING restart foo bar baz" +msgstr "" + +#: howto/logging-cookbook.rst:3568 msgid "" "In this case, the commands don't print anything to the console, since " "nothing at ``WARNING`` level or above is logged by them." msgstr "" -#: howto/logging-cookbook.rst:3402 +#: howto/logging-cookbook.rst:3574 msgid "A Qt GUI for logging" msgstr "" -#: howto/logging-cookbook.rst:3404 +#: howto/logging-cookbook.rst:3576 msgid "" "A question that comes up from time to time is about how to log to a GUI " "application. The `Qt `_ framework is a popular cross-" -"platform UI framework with Python bindings using `PySide2 `_ or `PyQt5 `_ libraries." +"platform UI framework with Python bindings using :pypi:`PySide2` " +"or :pypi:`PyQt5` libraries." msgstr "" -#: howto/logging-cookbook.rst:3410 +#: howto/logging-cookbook.rst:3581 msgid "" "The following example shows how to log to a Qt GUI. This introduces a simple " "``QtHandler`` class which takes a callable, which should be a slot in the " @@ -1842,43 +4488,365 @@ msgid "" "logging messages at random levels with random short delays in between)." msgstr "" -#: howto/logging-cookbook.rst:3417 +#: howto/logging-cookbook.rst:3588 msgid "" "The worker thread is implemented using Qt's ``QThread`` class rather than " "the :mod:`threading` module, as there are circumstances where one has to use " "``QThread``, which offers better integration with other ``Qt`` components." msgstr "" -#: howto/logging-cookbook.rst:3421 +#: howto/logging-cookbook.rst:3592 msgid "" -"The code should work with recent releases of either ``PySide6``, ``PyQt6``, " +"The code should work with recent releases of any of ``PySide6``, ``PyQt6``, " "``PySide2`` or ``PyQt5``. You should be able to adapt the approach to " "earlier versions of Qt. Please refer to the comments in the code snippet for " "more detailed information." msgstr "" -#: howto/logging-cookbook.rst:3658 +#: howto/logging-cookbook.rst:3597 +msgid "" +"import datetime\n" +"import logging\n" +"import random\n" +"import sys\n" +"import time\n" +"\n" +"# Deal with minor differences between different Qt packages\n" +"try:\n" +" from PySide6 import QtCore, QtGui, QtWidgets\n" +" Signal = QtCore.Signal\n" +" Slot = QtCore.Slot\n" +"except ImportError:\n" +" try:\n" +" from PyQt6 import QtCore, QtGui, QtWidgets\n" +" Signal = QtCore.pyqtSignal\n" +" Slot = QtCore.pyqtSlot\n" +" except ImportError:\n" +" try:\n" +" from PySide2 import QtCore, QtGui, QtWidgets\n" +" Signal = QtCore.Signal\n" +" Slot = QtCore.Slot\n" +" except ImportError:\n" +" from PyQt5 import QtCore, QtGui, QtWidgets\n" +" Signal = QtCore.pyqtSignal\n" +" Slot = QtCore.pyqtSlot\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"\n" +"#\n" +"# Signals need to be contained in a QObject or subclass in order to be " +"correctly\n" +"# initialized.\n" +"#\n" +"class Signaller(QtCore.QObject):\n" +" signal = Signal(str, logging.LogRecord)\n" +"\n" +"#\n" +"# Output to a Qt GUI is only supposed to happen on the main thread. So, " +"this\n" +"# handler is designed to take a slot function which is set up to run in the " +"main\n" +"# thread. In this example, the function takes a string argument which is a\n" +"# formatted log message, and the log record which generated it. The " +"formatted\n" +"# string is just a convenience - you could format a string for output any " +"way\n" +"# you like in the slot function itself.\n" +"#\n" +"# You specify the slot function to do whatever GUI updates you want. The " +"handler\n" +"# doesn't know or care about specific UI elements.\n" +"#\n" +"class QtHandler(logging.Handler):\n" +" def __init__(self, slotfunc, *args, **kwargs):\n" +" super().__init__(*args, **kwargs)\n" +" self.signaller = Signaller()\n" +" self.signaller.signal.connect(slotfunc)\n" +"\n" +" def emit(self, record):\n" +" s = self.format(record)\n" +" self.signaller.signal.emit(s, record)\n" +"\n" +"#\n" +"# This example uses QThreads, which means that the threads at the Python " +"level\n" +"# are named something like \"Dummy-1\". The function below gets the Qt name " +"of the\n" +"# current thread.\n" +"#\n" +"def ctname():\n" +" return QtCore.QThread.currentThread().objectName()\n" +"\n" +"\n" +"#\n" +"# Used to generate random levels for logging.\n" +"#\n" +"LEVELS = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,\n" +" logging.CRITICAL)\n" +"\n" +"#\n" +"# This worker class represents work that is done in a thread separate to " +"the\n" +"# main thread. The way the thread is kicked off to do work is via a button " +"press\n" +"# that connects to a slot in the worker.\n" +"#\n" +"# Because the default threadName value in the LogRecord isn't much use, we " +"add\n" +"# a qThreadName which contains the QThread name as computed above, and pass " +"that\n" +"# value in an \"extra\" dictionary which is used to update the LogRecord " +"with the\n" +"# QThread name.\n" +"#\n" +"# This example worker just outputs messages sequentially, interspersed with\n" +"# random delays of the order of a few seconds.\n" +"#\n" +"class Worker(QtCore.QObject):\n" +" @Slot()\n" +" def start(self):\n" +" extra = {'qThreadName': ctname() }\n" +" logger.debug('Started work', extra=extra)\n" +" i = 1\n" +" # Let the thread run until interrupted. This allows reasonably " +"clean\n" +" # thread termination.\n" +" while not QtCore.QThread.currentThread().isInterruptionRequested():\n" +" delay = 0.5 + random.random() * 2\n" +" time.sleep(delay)\n" +" try:\n" +" if random.random() < 0.1:\n" +" raise ValueError('Exception raised: %d' % i)\n" +" else:\n" +" level = random.choice(LEVELS)\n" +" logger.log(level, 'Message after delay of %3.1f: %d', " +"delay, i, extra=extra)\n" +" except ValueError as e:\n" +" logger.exception('Failed: %s', e, extra=extra)\n" +" i += 1\n" +"\n" +"#\n" +"# Implement a simple UI for this cookbook example. This contains:\n" +"#\n" +"# * A read-only text edit window which holds formatted log messages\n" +"# * A button to start work and log stuff in a separate thread\n" +"# * A button to log something from the main thread\n" +"# * A button to clear the log window\n" +"#\n" +"class Window(QtWidgets.QWidget):\n" +"\n" +" COLORS = {\n" +" logging.DEBUG: 'black',\n" +" logging.INFO: 'blue',\n" +" logging.WARNING: 'orange',\n" +" logging.ERROR: 'red',\n" +" logging.CRITICAL: 'purple',\n" +" }\n" +"\n" +" def __init__(self, app):\n" +" super().__init__()\n" +" self.app = app\n" +" self.textedit = te = QtWidgets.QPlainTextEdit(self)\n" +" # Set whatever the default monospace font is for the platform\n" +" f = QtGui.QFont('nosuchfont')\n" +" if hasattr(f, 'Monospace'):\n" +" f.setStyleHint(f.Monospace)\n" +" else:\n" +" f.setStyleHint(f.StyleHint.Monospace) # for Qt6\n" +" te.setFont(f)\n" +" te.setReadOnly(True)\n" +" PB = QtWidgets.QPushButton\n" +" self.work_button = PB('Start background work', self)\n" +" self.log_button = PB('Log a message at a random level', self)\n" +" self.clear_button = PB('Clear log window', self)\n" +" self.handler = h = QtHandler(self.update_status)\n" +" # Remember to use qThreadName rather than threadName in the format " +"string.\n" +" fs = '%(asctime)s %(qThreadName)-12s %(levelname)-8s %(message)s'\n" +" formatter = logging.Formatter(fs)\n" +" h.setFormatter(formatter)\n" +" logger.addHandler(h)\n" +" # Set up to terminate the QThread when we exit\n" +" app.aboutToQuit.connect(self.force_quit)\n" +"\n" +" # Lay out all the widgets\n" +" layout = QtWidgets.QVBoxLayout(self)\n" +" layout.addWidget(te)\n" +" layout.addWidget(self.work_button)\n" +" layout.addWidget(self.log_button)\n" +" layout.addWidget(self.clear_button)\n" +" self.setFixedSize(900, 400)\n" +"\n" +" # Connect the non-worker slots and signals\n" +" self.log_button.clicked.connect(self.manual_update)\n" +" self.clear_button.clicked.connect(self.clear_display)\n" +"\n" +" # Start a new worker thread and connect the slots for the worker\n" +" self.start_thread()\n" +" self.work_button.clicked.connect(self.worker.start)\n" +" # Once started, the button should be disabled\n" +" self.work_button.clicked.connect(lambda : " +"self.work_button.setEnabled(False))\n" +"\n" +" def start_thread(self):\n" +" self.worker = Worker()\n" +" self.worker_thread = QtCore.QThread()\n" +" self.worker.setObjectName('Worker')\n" +" self.worker_thread.setObjectName('WorkerThread') # for qThreadName\n" +" self.worker.moveToThread(self.worker_thread)\n" +" # This will start an event loop in the worker thread\n" +" self.worker_thread.start()\n" +"\n" +" def kill_thread(self):\n" +" # Just tell the worker to stop, then tell it to quit and wait for " +"that\n" +" # to happen\n" +" self.worker_thread.requestInterruption()\n" +" if self.worker_thread.isRunning():\n" +" self.worker_thread.quit()\n" +" self.worker_thread.wait()\n" +" else:\n" +" print('worker has already exited.')\n" +"\n" +" def force_quit(self):\n" +" # For use when the window is closed\n" +" if self.worker_thread.isRunning():\n" +" self.kill_thread()\n" +"\n" +" # The functions below update the UI and run in the main thread because\n" +" # that's where the slots are set up\n" +"\n" +" @Slot(str, logging.LogRecord)\n" +" def update_status(self, status, record):\n" +" color = self.COLORS.get(record.levelno, 'black')\n" +" s = '
%s
' % (color, status)\n" +" self.textedit.appendHtml(s)\n" +"\n" +" @Slot()\n" +" def manual_update(self):\n" +" # This function uses the formatted message passed in, but also uses\n" +" # information from the record to format the message in an " +"appropriate\n" +" # color according to its severity (level).\n" +" level = random.choice(LEVELS)\n" +" extra = {'qThreadName': ctname() }\n" +" logger.log(level, 'Manually logged!', extra=extra)\n" +"\n" +" @Slot()\n" +" def clear_display(self):\n" +" self.textedit.clear()\n" +"\n" +"\n" +"def main():\n" +" QtCore.QThread.currentThread().setObjectName('MainThread')\n" +" logging.getLogger().setLevel(logging.DEBUG)\n" +" app = QtWidgets.QApplication(sys.argv)\n" +" example = Window(app)\n" +" example.show()\n" +" if hasattr(app, 'exec'):\n" +" rc = app.exec()\n" +" else:\n" +" rc = app.exec_()\n" +" sys.exit(rc)\n" +"\n" +"if __name__=='__main__':\n" +" main()" +msgstr "" + +#: howto/logging-cookbook.rst:3829 msgid "Logging to syslog with RFC5424 support" msgstr "" -#: howto/logging-cookbook.rst:3660 +#: howto/logging-cookbook.rst:3831 msgid "" "Although :rfc:`5424` dates from 2009, most syslog servers are configured by " "default to use the older :rfc:`3164`, which hails from 2001. When " "``logging`` was added to Python in 2003, it supported the earlier (and only " "existing) protocol at the time. Since RFC5424 came out, as there has not " -"been widespread deployment of it in syslog servers, the :class:`~logging." -"handlers.SysLogHandler` functionality has not been updated." +"been widespread deployment of it in syslog servers, " +"the :class:`~logging.handlers.SysLogHandler` functionality has not been " +"updated." msgstr "" -#: howto/logging-cookbook.rst:3667 +#: howto/logging-cookbook.rst:3838 msgid "" "RFC 5424 contains some useful features such as support for structured data, " "and if you need to be able to log to a syslog server with support for it, " "you can do so with a subclassed handler which looks something like this::" msgstr "" -#: howto/logging-cookbook.rst:3733 +#: howto/logging-cookbook.rst:3842 +msgid "" +"import datetime\n" +"import logging.handlers\n" +"import re\n" +"import socket\n" +"import time\n" +"\n" +"class SysLogHandler5424(logging.handlers.SysLogHandler):\n" +"\n" +" tz_offset = re.compile(r'([+-]\\d{2})(\\d{2})$')\n" +" escaped = re.compile(r'([\\]\"\\\\])')\n" +"\n" +" def __init__(self, *args, **kwargs):\n" +" self.msgid = kwargs.pop('msgid', None)\n" +" self.appname = kwargs.pop('appname', None)\n" +" super().__init__(*args, **kwargs)\n" +"\n" +" def format(self, record):\n" +" version = 1\n" +" asctime = " +"datetime.datetime.fromtimestamp(record.created).isoformat()\n" +" m = self.tz_offset.match(time.strftime('%z'))\n" +" has_offset = False\n" +" if m and time.timezone:\n" +" hrs, mins = m.groups()\n" +" if int(hrs) or int(mins):\n" +" has_offset = True\n" +" if not has_offset:\n" +" asctime += 'Z'\n" +" else:\n" +" asctime += f'{hrs}:{mins}'\n" +" try:\n" +" hostname = socket.gethostname()\n" +" except Exception:\n" +" hostname = '-'\n" +" appname = self.appname or '-'\n" +" procid = record.process\n" +" msgid = '-'\n" +" msg = super().format(record)\n" +" sdata = '-'\n" +" if hasattr(record, 'structured_data'):\n" +" sd = record.structured_data\n" +" # This should be a dict where the keys are SD-ID and the value " +"is a\n" +" # dict mapping PARAM-NAME to PARAM-VALUE (refer to the RFC for " +"what these\n" +" # mean)\n" +" # There's no error checking here - it's purely for illustration, " +"and you\n" +" # can adapt this code for use in production environments\n" +" parts = []\n" +"\n" +" def replacer(m):\n" +" g = m.groups()\n" +" return '\\\\' + g[0]\n" +"\n" +" for sdid, dv in sd.items():\n" +" part = f'[{sdid}'\n" +" for k, v in dv.items():\n" +" s = str(v)\n" +" s = self.escaped.sub(replacer, s)\n" +" part += f' {k}=\"{s}\"'\n" +" part += ']'\n" +" parts.append(part)\n" +" sdata = ''.join(parts)\n" +" return f'{version} {asctime} {hostname} {appname} {procid} {msgid} " +"{sdata} {msg}'" +msgstr "" + +#: howto/logging-cookbook.rst:3904 msgid "" "You'll need to be familiar with RFC 5424 to fully understand the above code, " "and it may be that you have slightly different needs (e.g. for how you pass " @@ -1887,11 +4855,22 @@ msgid "" "using something like this::" msgstr "" -#: howto/logging-cookbook.rst:3747 +#: howto/logging-cookbook.rst:3909 +msgid "" +"sd = {\n" +" 'foo@12345': {'bar': 'baz', 'baz': 'bozz', 'fizz': r'buzz'},\n" +" 'foo@54321': {'rab': 'baz', 'zab': 'bozz', 'zzif': r'buzz'}\n" +"}\n" +"extra = {'structured_data': sd}\n" +"i = 1\n" +"logger.debug('Message %d', i, extra=extra)" +msgstr "" + +#: howto/logging-cookbook.rst:3918 msgid "How to treat a logger like an output stream" msgstr "" -#: howto/logging-cookbook.rst:3749 +#: howto/logging-cookbook.rst:3920 msgid "" "Sometimes, you need to interface to a third-party API which expects a file-" "like object to write to, but you want to direct the API's output to a " @@ -1899,63 +4878,181 @@ msgid "" "API. Here's a short script illustrating such a class:" msgstr "" -#: howto/logging-cookbook.rst:3789 +#: howto/logging-cookbook.rst:3925 +msgid "" +"import logging\n" +"\n" +"class LoggerWriter:\n" +" def __init__(self, logger, level):\n" +" self.logger = logger\n" +" self.level = level\n" +"\n" +" def write(self, message):\n" +" if message != '\\n': # avoid printing bare newlines, if you like\n" +" self.logger.log(self.level, message)\n" +"\n" +" def flush(self):\n" +" # doesn't actually do anything, but might be expected of a file-" +"like\n" +" # object - so optional depending on your situation\n" +" pass\n" +"\n" +" def close(self):\n" +" # doesn't actually do anything, but might be expected of a file-" +"like\n" +" # object - so optional depending on your situation. You might want\n" +" # to set a flag so that later calls to write raise an exception\n" +" pass\n" +"\n" +"def main():\n" +" logging.basicConfig(level=logging.DEBUG)\n" +" logger = logging.getLogger('demo')\n" +" info_fp = LoggerWriter(logger, logging.INFO)\n" +" debug_fp = LoggerWriter(logger, logging.DEBUG)\n" +" print('An INFO message', file=info_fp)\n" +" print('A DEBUG message', file=debug_fp)\n" +"\n" +"if __name__ == \"__main__\":\n" +" main()" +msgstr "" + +#: howto/logging-cookbook.rst:3960 msgid "When this script is run, it prints" msgstr "" -#: howto/logging-cookbook.rst:3796 +#: howto/logging-cookbook.rst:3962 msgid "" -"You could also use ``LoggerWriter`` to redirect ``sys.stdout`` and ``sys." -"stderr`` by doing something like this:" +"INFO:demo:An INFO message\n" +"DEBUG:demo:A DEBUG message" msgstr "" -#: howto/logging-cookbook.rst:3806 +#: howto/logging-cookbook.rst:3967 +msgid "" +"You could also use ``LoggerWriter`` to redirect ``sys.stdout`` and " +"``sys.stderr`` by doing something like this:" +msgstr "" + +#: howto/logging-cookbook.rst:3970 +msgid "" +"import sys\n" +"\n" +"sys.stdout = LoggerWriter(logger, logging.INFO)\n" +"sys.stderr = LoggerWriter(logger, logging.WARNING)" +msgstr "" + +#: howto/logging-cookbook.rst:3977 msgid "" "You should do this *after* configuring logging for your needs. In the above " -"example, the :func:`~logging.basicConfig` call does this (using the ``sys." -"stderr`` value *before* it is overwritten by a ``LoggerWriter`` instance). " -"Then, you'd get this kind of result:" +"example, the :func:`~logging.basicConfig` call does this (using the " +"``sys.stderr`` value *before* it is overwritten by a ``LoggerWriter`` " +"instance). Then, you'd get this kind of result:" msgstr "" -#: howto/logging-cookbook.rst:3819 +#: howto/logging-cookbook.rst:3982 msgid "" -"Of course, the examples above show output according to the format used by :" -"func:`~logging.basicConfig`, but you can use a different formatter when you " -"configure logging." +">>> print('Foo')\n" +"INFO:demo:Foo\n" +">>> print('Bar', file=sys.stderr)\n" +"WARNING:demo:Bar\n" +">>>" msgstr "" -#: howto/logging-cookbook.rst:3823 +#: howto/logging-cookbook.rst:3990 +msgid "" +"Of course, the examples above show output according to the format used " +"by :func:`~logging.basicConfig`, but you can use a different formatter when " +"you configure logging." +msgstr "" + +#: howto/logging-cookbook.rst:3994 msgid "" "Note that with the above scheme, you are somewhat at the mercy of buffering " "and the sequence of write calls which you are intercepting. For example, " "with the definition of ``LoggerWriter`` above, if you have the snippet" msgstr "" -#: howto/logging-cookbook.rst:3832 +#: howto/logging-cookbook.rst:3998 +msgid "" +"sys.stderr = LoggerWriter(logger, logging.WARNING)\n" +"1 / 0" +msgstr "" + +#: howto/logging-cookbook.rst:4003 msgid "then running the script results in" msgstr "" -#: howto/logging-cookbook.rst:3850 +#: howto/logging-cookbook.rst:4005 +msgid "" +"WARNING:demo:Traceback (most recent call last):\n" +"\n" +"WARNING:demo: File \"/home/runner/cookbook-loggerwriter/test.py\", line 53, " +"in \n" +"\n" +"WARNING:demo:\n" +"WARNING:demo:main()\n" +"WARNING:demo: File \"/home/runner/cookbook-loggerwriter/test.py\", line 49, " +"in main\n" +"\n" +"WARNING:demo:\n" +"WARNING:demo:1 / 0\n" +"WARNING:demo:ZeroDivisionError\n" +"WARNING:demo::\n" +"WARNING:demo:division by zero" +msgstr "" + +#: howto/logging-cookbook.rst:4021 msgid "" "As you can see, this output isn't ideal. That's because the underlying code " "which writes to ``sys.stderr`` makes multiple writes, each of which results " "in a separate logged line (for example, the last three lines above). To get " "around this problem, you need to buffer things and only output log lines " -"when newlines are seen. Let's use a slghtly better implementation of " +"when newlines are seen. Let's use a slightly better implementation of " "``LoggerWriter``:" msgstr "" -#: howto/logging-cookbook.rst:3875 +#: howto/logging-cookbook.rst:4027 +msgid "" +"class BufferingLoggerWriter(LoggerWriter):\n" +" def __init__(self, logger, level):\n" +" super().__init__(logger, level)\n" +" self.buffer = ''\n" +"\n" +" def write(self, message):\n" +" if '\\n' not in message:\n" +" self.buffer += message\n" +" else:\n" +" parts = message.split('\\n')\n" +" if self.buffer:\n" +" s = self.buffer + parts.pop(0)\n" +" self.logger.log(self.level, s)\n" +" self.buffer = parts.pop()\n" +" for part in parts:\n" +" self.logger.log(self.level, part)" +msgstr "" + +#: howto/logging-cookbook.rst:4046 msgid "" "This just buffers up stuff until a newline is seen, and then logs complete " "lines. With this approach, you get better output:" msgstr "" -#: howto/logging-cookbook.rst:3891 +#: howto/logging-cookbook.rst:4049 +msgid "" +"WARNING:demo:Traceback (most recent call last):\n" +"WARNING:demo: File \"/home/runner/cookbook-loggerwriter/main.py\", line 55, " +"in \n" +"WARNING:demo: main()\n" +"WARNING:demo: File \"/home/runner/cookbook-loggerwriter/main.py\", line 52, " +"in main\n" +"WARNING:demo: 1/0\n" +"WARNING:demo:ZeroDivisionError: division by zero" +msgstr "" + +#: howto/logging-cookbook.rst:4062 msgid "Patterns to avoid" msgstr "" -#: howto/logging-cookbook.rst:3893 +#: howto/logging-cookbook.rst:4064 msgid "" "Although the preceding sections have described ways of doing things you " "might need to do or deal with, it is worth mentioning some usage patterns " @@ -1963,11 +5060,11 @@ msgid "" "The following sections are in no particular order." msgstr "" -#: howto/logging-cookbook.rst:3899 +#: howto/logging-cookbook.rst:4070 msgid "Opening the same log file multiple times" msgstr "" -#: howto/logging-cookbook.rst:3901 +#: howto/logging-cookbook.rst:4072 msgid "" "On Windows, you will generally not be able to open the same file multiple " "times as this will lead to a \"file is in use by another process\" error. " @@ -1975,32 +5072,32 @@ msgid "" "file multiple times. This could be done accidentally, for example by:" msgstr "" -#: howto/logging-cookbook.rst:3906 +#: howto/logging-cookbook.rst:4077 msgid "" "Adding a file handler more than once which references the same file (e.g. by " "a copy/paste/forget-to-change error)." msgstr "" -#: howto/logging-cookbook.rst:3909 +#: howto/logging-cookbook.rst:4080 msgid "" "Opening two files that look different, as they have different names, but are " "the same because one is a symbolic link to the other." msgstr "" -#: howto/logging-cookbook.rst:3912 +#: howto/logging-cookbook.rst:4083 msgid "" "Forking a process, following which both parent and child have a reference to " "the same file. This might be through use of the :mod:`multiprocessing` " "module, for example." msgstr "" -#: howto/logging-cookbook.rst:3916 +#: howto/logging-cookbook.rst:4087 msgid "" "Opening a file multiple times might *appear* to work most of the time, but " "can lead to a number of problems in practice:" msgstr "" -#: howto/logging-cookbook.rst:3919 +#: howto/logging-cookbook.rst:4090 msgid "" "Logging output can be garbled because multiple threads or processes try to " "write to the same file. Although logging guards against concurrent use of " @@ -2009,7 +5106,7 @@ msgid "" "different handler instances which happen to point to the same file." msgstr "" -#: howto/logging-cookbook.rst:3925 +#: howto/logging-cookbook.rst:4096 msgid "" "An attempt to delete a file (e.g. during file rotation) silently fails, " "because there is another reference pointing to it. This can lead to " @@ -2019,17 +5116,17 @@ msgid "" "being supposedly in place." msgstr "" -#: howto/logging-cookbook.rst:3932 +#: howto/logging-cookbook.rst:4103 msgid "" "Use the techniques outlined in :ref:`multiple-processes` to circumvent such " "issues." msgstr "" -#: howto/logging-cookbook.rst:3936 +#: howto/logging-cookbook.rst:4107 msgid "Using loggers as attributes in a class or passing them as parameters" msgstr "" -#: howto/logging-cookbook.rst:3938 +#: howto/logging-cookbook.rst:4109 msgid "" "While there might be unusual cases where you'll need to do this, in general " "there is no point because loggers are singletons. Code can always access a " @@ -2040,13 +5137,13 @@ msgid "" "module (and not the class) is the unit of software decomposition." msgstr "" -#: howto/logging-cookbook.rst:3947 +#: howto/logging-cookbook.rst:4118 msgid "" "Adding handlers other than :class:`~logging.NullHandler` to a logger in a " "library" msgstr "" -#: howto/logging-cookbook.rst:3949 +#: howto/logging-cookbook.rst:4120 msgid "" "Configuring logging by adding handlers, formatters and filters is the " "responsibility of the application developer, not the library developer. If " @@ -2054,11 +5151,11 @@ msgid "" "your loggers other than a :class:`~logging.NullHandler` instance." msgstr "" -#: howto/logging-cookbook.rst:3955 +#: howto/logging-cookbook.rst:4126 msgid "Creating a lot of loggers" msgstr "" -#: howto/logging-cookbook.rst:3957 +#: howto/logging-cookbook.rst:4128 msgid "" "Loggers are singletons that are never freed during a script execution, and " "so creating lots of loggers will use up memory which can't then be freed. " @@ -2069,14 +5166,38 @@ msgid "" "occasionally slightly more fine-grained than that)." msgstr "" -#: howto/logging-cookbook.rst:3968 +#: howto/logging-cookbook.rst:4139 msgid "Other resources" msgstr "" -#: howto/logging-cookbook.rst:3981 +#: howto/logging-cookbook.rst:4143 +msgid "Module :mod:`logging`" +msgstr "" + +#: howto/logging-cookbook.rst:4144 +msgid "API reference for the logging module." +msgstr "" + +#: howto/logging-cookbook.rst:4146 +msgid "Module :mod:`logging.config`" +msgstr "" + +#: howto/logging-cookbook.rst:4147 +msgid "Configuration API for the logging module." +msgstr "" + +#: howto/logging-cookbook.rst:4149 +msgid "Module :mod:`logging.handlers`" +msgstr "" + +#: howto/logging-cookbook.rst:4150 +msgid "Useful handlers included with the logging module." +msgstr "" + +#: howto/logging-cookbook.rst:4152 msgid ":ref:`Basic Tutorial `" msgstr "" -#: howto/logging-cookbook.rst:3983 +#: howto/logging-cookbook.rst:4154 msgid ":ref:`Advanced Tutorial `" msgstr "" diff --git a/howto/logging.po b/howto/logging.po index d31ef58a..15bcdca9 100644 --- a/howto/logging.po +++ b/howto/logging.po @@ -8,15 +8,16 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: howto/logging.rst:3 +#: howto/logging.rst:5 msgid "Logging HOWTO" msgstr "" @@ -24,21 +25,21 @@ msgstr "" msgid "Author" msgstr "" -#: howto/logging.rst:5 +#: howto/logging.rst:7 msgid "Vinay Sajip " msgstr "" -#: howto/logging.rst:11 +#: howto/logging.rst:13 msgid "" "This page contains tutorial information. For links to reference information " "and a logging cookbook, please see :ref:`tutorial-ref-links`." msgstr "" -#: howto/logging.rst:15 +#: howto/logging.rst:17 msgid "Basic Logging Tutorial" msgstr "" -#: howto/logging.rst:17 +#: howto/logging.rst:19 msgid "" "Logging is a means of tracking events that happen when some software runs. " "The software's developer adds logging calls to their code to indicate that " @@ -49,185 +50,196 @@ msgid "" "the *level* or *severity*." msgstr "" -#: howto/logging.rst:26 +#: howto/logging.rst:28 msgid "When to use logging" msgstr "" -#: howto/logging.rst:28 +#: howto/logging.rst:30 msgid "" "You can access logging functionality by creating a logger via ``logger = " -"getLogger(__name__)``, and then calling the logger's :meth:`~Logger.debug`, :" -"meth:`~Logger.info`, :meth:`~Logger.warning`, :meth:`~Logger.error` and :" -"meth:`~Logger.critical` methods. To determine when to use logging, and to " -"see which logger methods to use when, see the table below. It states, for " +"getLogger(__name__)``, and then calling the " +"logger's :meth:`~Logger.debug`, :meth:`~Logger.info`, :meth:`~Logger.warning`, :meth:`~Logger.error` " +"and :meth:`~Logger.critical` methods. To determine when to use logging, and " +"to see which logger methods to use when, see the table below. It states, for " "each of a set of common tasks, the best tool to use for that task." msgstr "" -#: howto/logging.rst:36 +#: howto/logging.rst:38 msgid "Task you want to perform" msgstr "" -#: howto/logging.rst:36 +#: howto/logging.rst:38 msgid "The best tool for the task" msgstr "" -#: howto/logging.rst:38 +#: howto/logging.rst:40 msgid "" "Display console output for ordinary usage of a command line script or program" msgstr "" -#: howto/logging.rst:38 +#: howto/logging.rst:40 msgid ":func:`print`" msgstr "" -#: howto/logging.rst:42 +#: howto/logging.rst:44 msgid "" "Report events that occur during normal operation of a program (e.g. for " "status monitoring or fault investigation)" msgstr "" -#: howto/logging.rst:42 +#: howto/logging.rst:44 msgid "" "A logger's :meth:`~Logger.info` (or :meth:`~Logger.debug` method for very " "detailed output for diagnostic purposes)" msgstr "" -#: howto/logging.rst:47 +#: howto/logging.rst:49 msgid "Issue a warning regarding a particular runtime event" msgstr "" -#: howto/logging.rst:47 +#: howto/logging.rst:49 msgid "" ":func:`warnings.warn` in library code if the issue is avoidable and the " "client application should be modified to eliminate the warning" msgstr "" -#: howto/logging.rst:52 +#: howto/logging.rst:54 msgid "" "A logger's :meth:`~Logger.warning` method if there is nothing the client " "application can do about the situation, but the event should still be noted" msgstr "" -#: howto/logging.rst:58 +#: howto/logging.rst:60 msgid "Report an error regarding a particular runtime event" msgstr "" -#: howto/logging.rst:58 +#: howto/logging.rst:60 msgid "Raise an exception" msgstr "" -#: howto/logging.rst:61 +#: howto/logging.rst:63 msgid "" "Report suppression of an error without raising an exception (e.g. error " "handler in a long-running server process)" msgstr "" -#: howto/logging.rst:61 +#: howto/logging.rst:63 msgid "" -"A logger's :meth:`~Logger.error`, :meth:`~Logger.exception` or :meth:" -"`~Logger.critical` method as appropriate for the specific error and " +"A logger's :meth:`~Logger.error`, :meth:`~Logger.exception` " +"or :meth:`~Logger.critical` method as appropriate for the specific error and " "application domain" msgstr "" -#: howto/logging.rst:68 +#: howto/logging.rst:70 msgid "" "The logger methods are named after the level or severity of the events they " "are used to track. The standard levels and their applicability are described " "below (in increasing order of severity):" msgstr "" -#: howto/logging.rst:830 +#: howto/logging.rst:876 msgid "Level" msgstr "" -#: howto/logging.rst:75 +#: howto/logging.rst:77 msgid "When it's used" msgstr "" -#: howto/logging.rst:840 +#: howto/logging.rst:886 msgid "``DEBUG``" msgstr "" -#: howto/logging.rst:77 +#: howto/logging.rst:79 msgid "" "Detailed information, typically of interest only when diagnosing problems." msgstr "" -#: howto/logging.rst:838 +#: howto/logging.rst:884 msgid "``INFO``" msgstr "" -#: howto/logging.rst:80 +#: howto/logging.rst:82 msgid "Confirmation that things are working as expected." msgstr "" -#: howto/logging.rst:836 +#: howto/logging.rst:882 msgid "``WARNING``" msgstr "" -#: howto/logging.rst:83 +#: howto/logging.rst:85 msgid "" "An indication that something unexpected happened, or indicative of some " "problem in the near future (e.g. 'disk space low'). The software is still " "working as expected." msgstr "" -#: howto/logging.rst:834 +#: howto/logging.rst:880 msgid "``ERROR``" msgstr "" -#: howto/logging.rst:88 +#: howto/logging.rst:90 msgid "" "Due to a more serious problem, the software has not been able to perform " "some function." msgstr "" -#: howto/logging.rst:832 +#: howto/logging.rst:878 msgid "``CRITICAL``" msgstr "" -#: howto/logging.rst:91 +#: howto/logging.rst:93 msgid "" "A serious error, indicating that the program itself may be unable to " "continue running." msgstr "" -#: howto/logging.rst:95 +#: howto/logging.rst:97 msgid "" "The default level is ``WARNING``, which means that only events of this level " "and above will be tracked, unless the logging package is configured to do " "otherwise." msgstr "" -#: howto/logging.rst:99 +#: howto/logging.rst:101 msgid "" "Events that are tracked can be handled in different ways. The simplest way " "of handling tracked events is to print them to the console. Another common " "way is to write them to a disk file." msgstr "" -#: howto/logging.rst:107 +#: howto/logging.rst:109 msgid "A simple example" msgstr "" -#: howto/logging.rst:109 +#: howto/logging.rst:111 msgid "A very simple example is::" msgstr "" -#: howto/logging.rst:115 +#: howto/logging.rst:113 +msgid "" +"import logging\n" +"logging.warning('Watch out!') # will print a message to the console\n" +"logging.info('I told you so') # will not print anything" +msgstr "" + +#: howto/logging.rst:117 msgid "If you type these lines into a script and run it, you'll see:" msgstr "" -#: howto/logging.rst:121 +#: howto/logging.rst:119 +msgid "WARNING:root:Watch out!" +msgstr "" + +#: howto/logging.rst:123 msgid "" "printed out on the console. The ``INFO`` message doesn't appear because the " "default level is ``WARNING``. The printed message includes the indication of " -"the level and the description of the event provided in the logging call, i." -"e. 'Watch out!'. The actual output can be formatted quite flexibly if you " +"the level and the description of the event provided in the logging call, " +"i.e. 'Watch out!'. The actual output can be formatted quite flexibly if you " "need that; formatting options will also be explained later." msgstr "" -#: howto/logging.rst:127 +#: howto/logging.rst:129 msgid "" "Notice that in this example, we use functions directly on the ``logging`` " "module, like ``logging.debug``, rather than creating a logger and calling " @@ -239,11 +251,11 @@ msgid "" "methods." msgstr "" -#: howto/logging.rst:136 +#: howto/logging.rst:138 msgid "Logging to a file" msgstr "" -#: howto/logging.rst:138 +#: howto/logging.rst:140 msgid "" "A very common situation is that of recording logging events in a file, so " "let's look at that next. Be sure to try the following in a newly started " @@ -251,7 +263,19 @@ msgid "" "above::" msgstr "" -#: howto/logging.rst:150 +#: howto/logging.rst:144 +msgid "" +"import logging\n" +"logger = logging.getLogger(__name__)\n" +"logging.basicConfig(filename='example.log', encoding='utf-8', " +"level=logging.DEBUG)\n" +"logger.debug('This message should go to the log file')\n" +"logger.info('So should this')\n" +"logger.warning('And this, too')\n" +"logger.error('And non-ASCII stuff, too, like Øresund and Malmö')" +msgstr "" + +#: howto/logging.rst:152 msgid "" "The *encoding* argument was added. In earlier Python versions, or if not " "specified, the encoding used is the default value used by :func:`open`. " @@ -260,45 +284,72 @@ msgid "" "values and the default, see the documentation for :func:`open`." msgstr "" -#: howto/logging.rst:157 +#: howto/logging.rst:159 msgid "" "And now if we open the file and look at what we have, we should find the log " "messages:" msgstr "" -#: howto/logging.rst:167 +#: howto/logging.rst:162 +msgid "" +"DEBUG:__main__:This message should go to the log file\n" +"INFO:__main__:So should this\n" +"WARNING:__main__:And this, too\n" +"ERROR:__main__:And non-ASCII stuff, too, like Øresund and Malmö" +msgstr "" + +#: howto/logging.rst:169 msgid "" "This example also shows how you can set the logging level which acts as the " "threshold for tracking. In this case, because we set the threshold to " "``DEBUG``, all of the messages were printed." msgstr "" -#: howto/logging.rst:171 +#: howto/logging.rst:173 msgid "" "If you want to set the logging level from a command-line option such as:" msgstr "" -#: howto/logging.rst:177 +#: howto/logging.rst:175 +msgid "--log=INFO" +msgstr "" + +#: howto/logging.rst:179 msgid "" "and you have the value of the parameter passed for ``--log`` in some " "variable *loglevel*, you can use::" msgstr "" #: howto/logging.rst:182 +msgid "getattr(logging, loglevel.upper())" +msgstr "" + +#: howto/logging.rst:184 msgid "" "to get the value which you'll pass to :func:`basicConfig` via the *level* " "argument. You may want to error check any user input value, perhaps as in " "the following example::" msgstr "" -#: howto/logging.rst:194 +#: howto/logging.rst:188 +msgid "" +"# assuming loglevel is bound to the string value obtained from the\n" +"# command line argument. Convert to upper case to allow the user to\n" +"# specify --log=DEBUG or --log=debug\n" +"numeric_level = getattr(logging, loglevel.upper(), None)\n" +"if not isinstance(numeric_level, int):\n" +" raise ValueError('Invalid log level: %s' % loglevel)\n" +"logging.basicConfig(level=numeric_level, ...)" +msgstr "" + +#: howto/logging.rst:196 msgid "" "The call to :func:`basicConfig` should come *before* any calls to a logger's " "methods such as :meth:`~Logger.debug`, :meth:`~Logger.info`, etc. Otherwise, " "that logging event may not be handled in the desired manner." msgstr "" -#: howto/logging.rst:198 +#: howto/logging.rst:200 msgid "" "If you run the above script several times, the messages from successive runs " "are appended to the file *example.log*. If you want each run to start " @@ -308,25 +359,41 @@ msgstr "" #: howto/logging.rst:205 msgid "" +"logging.basicConfig(filename='example.log', filemode='w', " +"level=logging.DEBUG)" +msgstr "" + +#: howto/logging.rst:207 +msgid "" "The output will be the same as before, but the log file is no longer " "appended to, so the messages from earlier runs are lost." msgstr "" -#: howto/logging.rst:210 +#: howto/logging.rst:212 msgid "Logging variable data" msgstr "" -#: howto/logging.rst:212 +#: howto/logging.rst:214 msgid "" "To log variable data, use a format string for the event description message " "and append the variable data as arguments. For example::" msgstr "" -#: howto/logging.rst:218 +#: howto/logging.rst:217 +msgid "" +"import logging\n" +"logging.warning('%s before you %s', 'Look', 'leap!')" +msgstr "" + +#: howto/logging.rst:220 msgid "will display:" msgstr "" -#: howto/logging.rst:224 +#: howto/logging.rst:222 +msgid "WARNING:root:Look before you leap!" +msgstr "" + +#: howto/logging.rst:226 msgid "" "As you can see, merging of variable data into the event description message " "uses the old, %-style of string formatting. This is for backwards " @@ -336,21 +403,38 @@ msgid "" "tutorial: see :ref:`formatting-styles` for more information." msgstr "" -#: howto/logging.rst:233 +#: howto/logging.rst:235 msgid "Changing the format of displayed messages" msgstr "" -#: howto/logging.rst:235 +#: howto/logging.rst:237 msgid "" "To change the format which is used to display messages, you need to specify " "the format you want to use::" msgstr "" -#: howto/logging.rst:244 +#: howto/logging.rst:240 +msgid "" +"import logging\n" +"logging.basicConfig(format='%(levelname)s:%(message)s', " +"level=logging.DEBUG)\n" +"logging.debug('This message should appear on the console')\n" +"logging.info('So should this')\n" +"logging.warning('And this, too')" +msgstr "" + +#: howto/logging.rst:246 msgid "which would print:" msgstr "" -#: howto/logging.rst:252 +#: howto/logging.rst:248 +msgid "" +"DEBUG:This message should appear on the console\n" +"INFO:So should this\n" +"WARNING:And this, too" +msgstr "" + +#: howto/logging.rst:254 msgid "" "Notice that the 'root' which appeared in earlier examples has disappeared. " "For a full set of things that can appear in format strings, you can refer to " @@ -360,42 +444,65 @@ msgid "" "This is described in the next section." msgstr "" -#: howto/logging.rst:261 +#: howto/logging.rst:263 msgid "Displaying the date/time in messages" msgstr "" -#: howto/logging.rst:263 +#: howto/logging.rst:265 msgid "" "To display the date and time of an event, you would place '%(asctime)s' in " "your format string::" msgstr "" -#: howto/logging.rst:270 +#: howto/logging.rst:268 +msgid "" +"import logging\n" +"logging.basicConfig(format='%(asctime)s %(message)s')\n" +"logging.warning('is when this event was logged.')" +msgstr "" + +#: howto/logging.rst:272 msgid "which should print something like this:" msgstr "" -#: howto/logging.rst:276 +#: howto/logging.rst:274 +msgid "2010-12-12 11:41:42,612 is when this event was logged." +msgstr "" + +#: howto/logging.rst:278 msgid "" -"The default format for date/time display (shown above) is like ISO8601 or :" -"rfc:`3339`. If you need more control over the formatting of the date/time, " -"provide a *datefmt* argument to ``basicConfig``, as in this example::" +"The default format for date/time display (shown above) is like ISO8601 " +"or :rfc:`3339`. If you need more control over the formatting of the date/" +"time, provide a *datefmt* argument to ``basicConfig``, as in this example::" msgstr "" -#: howto/logging.rst:284 +#: howto/logging.rst:282 +msgid "" +"import logging\n" +"logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:" +"%M:%S %p')\n" +"logging.warning('is when this event was logged.')" +msgstr "" + +#: howto/logging.rst:286 msgid "which would display something like this:" msgstr "" -#: howto/logging.rst:290 +#: howto/logging.rst:288 +msgid "12/12/2010 11:46:36 AM is when this event was logged." +msgstr "" + +#: howto/logging.rst:292 msgid "" -"The format of the *datefmt* argument is the same as supported by :func:`time." -"strftime`." +"The format of the *datefmt* argument is the same as supported " +"by :func:`time.strftime`." msgstr "" -#: howto/logging.rst:295 +#: howto/logging.rst:297 msgid "Next Steps" msgstr "" -#: howto/logging.rst:297 +#: howto/logging.rst:299 msgid "" "That concludes the basic tutorial. It should be enough to get you up and " "running with logging. There's a lot more that the logging package offers, " @@ -404,7 +511,7 @@ msgid "" "of your favourite beverage and carry on." msgstr "" -#: howto/logging.rst:303 +#: howto/logging.rst:305 msgid "" "If your logging needs are simple, then use the above examples to incorporate " "logging into your own scripts, and if you run into problems or don't " @@ -413,50 +520,50 @@ msgid "" "should receive help before too long." msgstr "" -#: howto/logging.rst:309 +#: howto/logging.rst:311 msgid "" "Still here? You can carry on reading the next few sections, which provide a " "slightly more advanced/in-depth tutorial than the basic one above. After " "that, you can take a look at the :ref:`logging-cookbook`." msgstr "" -#: howto/logging.rst:317 +#: howto/logging.rst:319 msgid "Advanced Logging Tutorial" msgstr "" -#: howto/logging.rst:319 +#: howto/logging.rst:321 msgid "" "The logging library takes a modular approach and offers several categories " "of components: loggers, handlers, filters, and formatters." msgstr "" -#: howto/logging.rst:322 +#: howto/logging.rst:324 msgid "Loggers expose the interface that application code directly uses." msgstr "" -#: howto/logging.rst:323 +#: howto/logging.rst:325 msgid "" "Handlers send the log records (created by loggers) to the appropriate " "destination." msgstr "" -#: howto/logging.rst:325 +#: howto/logging.rst:327 msgid "" "Filters provide a finer grained facility for determining which log records " "to output." msgstr "" -#: howto/logging.rst:327 +#: howto/logging.rst:329 msgid "Formatters specify the layout of log records in the final output." msgstr "" -#: howto/logging.rst:329 +#: howto/logging.rst:331 msgid "" "Log event information is passed between loggers, handlers, filters and " "formatters in a :class:`LogRecord` instance." msgstr "" -#: howto/logging.rst:332 +#: howto/logging.rst:334 msgid "" "Logging is performed by calling methods on instances of the :class:`Logger` " "class (hereafter called :dfn:`loggers`). Each instance has a name, and they " @@ -467,28 +574,33 @@ msgid "" "originates." msgstr "" -#: howto/logging.rst:339 +#: howto/logging.rst:341 msgid "" "A good convention to use when naming loggers is to use a module-level " "logger, in each module which uses logging, named as follows::" msgstr "" #: howto/logging.rst:344 +msgid "logger = logging.getLogger(__name__)" +msgstr "" + +#: howto/logging.rst:346 msgid "" "This means that logger names track the package/module hierarchy, and it's " "intuitively obvious where events are logged just from the logger name." msgstr "" -#: howto/logging.rst:347 +#: howto/logging.rst:349 msgid "" "The root of the hierarchy of loggers is called the root logger. That's the " -"logger used by the functions :func:`debug`, :func:`info`, :func:`warning`, :" -"func:`error` and :func:`critical`, which just call the same-named method of " -"the root logger. The functions and the methods have the same signatures. The " -"root logger's name is printed as 'root' in the logged output." +"logger used by the " +"functions :func:`debug`, :func:`info`, :func:`warning`, :func:`error` " +"and :func:`critical`, which just call the same-named method of the root " +"logger. The functions and the methods have the same signatures. The root " +"logger's name is printed as 'root' in the logged output." msgstr "" -#: howto/logging.rst:353 +#: howto/logging.rst:355 msgid "" "It is, of course, possible to log messages to different destinations. " "Support is included in the package for writing log messages to files, HTTP " @@ -499,44 +611,48 @@ msgid "" "built-in handler classes." msgstr "" -#: howto/logging.rst:360 +#: howto/logging.rst:362 msgid "" "By default, no destination is set for any logging messages. You can specify " "a destination (such as console or file) by using :func:`basicConfig` as in " -"the tutorial examples. If you call the functions :func:`debug`, :func:" -"`info`, :func:`warning`, :func:`error` and :func:`critical`, they will check " -"to see if no destination is set; and if one is not set, they will set a " -"destination of the console (``sys.stderr``) and a default format for the " -"displayed message before delegating to the root logger to do the actual " -"message output." +"the tutorial examples. If you call the " +"functions :func:`debug`, :func:`info`, :func:`warning`, :func:`error` " +"and :func:`critical`, they will check to see if no destination is set; and " +"if one is not set, they will set a destination of the console " +"(``sys.stderr``) and a default format for the displayed message before " +"delegating to the root logger to do the actual message output." msgstr "" -#: howto/logging.rst:368 +#: howto/logging.rst:370 msgid "The default format set by :func:`basicConfig` for messages is:" msgstr "" -#: howto/logging.rst:374 +#: howto/logging.rst:372 +msgid "severity:logger name:message" +msgstr "" + +#: howto/logging.rst:376 msgid "" "You can change this by passing a format string to :func:`basicConfig` with " "the *format* keyword argument. For all options regarding how a format string " "is constructed, see :ref:`formatter-objects`." msgstr "" -#: howto/logging.rst:379 +#: howto/logging.rst:381 msgid "Logging Flow" msgstr "" -#: howto/logging.rst:381 +#: howto/logging.rst:383 msgid "" "The flow of log event information in loggers and handlers is illustrated in " "the following diagram." msgstr "" -#: howto/logging.rst:388 +#: howto/logging.rst:434 msgid "Loggers" msgstr "" -#: howto/logging.rst:390 +#: howto/logging.rst:436 msgid "" ":class:`Logger` objects have a threefold job. First, they expose several " "methods to application code so that applications can log messages at " @@ -546,17 +662,17 @@ msgid "" "handlers." msgstr "" -#: howto/logging.rst:396 +#: howto/logging.rst:442 msgid "" "The most widely used methods on logger objects fall into two categories: " "configuration and message sending." msgstr "" -#: howto/logging.rst:399 +#: howto/logging.rst:445 msgid "These are the most common configuration methods:" msgstr "" -#: howto/logging.rst:401 +#: howto/logging.rst:447 msgid "" ":meth:`Logger.setLevel` specifies the lowest-severity log message a logger " "will handle, where debug is the lowest built-in severity level and critical " @@ -565,52 +681,53 @@ msgid "" "messages and will ignore DEBUG messages." msgstr "" -#: howto/logging.rst:407 +#: howto/logging.rst:453 msgid "" ":meth:`Logger.addHandler` and :meth:`Logger.removeHandler` add and remove " "handler objects from the logger object. Handlers are covered in more detail " "in :ref:`handler-basic`." msgstr "" -#: howto/logging.rst:411 +#: howto/logging.rst:457 msgid "" ":meth:`Logger.addFilter` and :meth:`Logger.removeFilter` add and remove " "filter objects from the logger object. Filters are covered in more detail " "in :ref:`filter`." msgstr "" -#: howto/logging.rst:415 +#: howto/logging.rst:461 msgid "" "You don't need to always call these methods on every logger you create. See " "the last two paragraphs in this section." msgstr "" -#: howto/logging.rst:418 +#: howto/logging.rst:464 msgid "" "With the logger object configured, the following methods create log messages:" msgstr "" -#: howto/logging.rst:420 +#: howto/logging.rst:466 msgid "" -":meth:`Logger.debug`, :meth:`Logger.info`, :meth:`Logger.warning`, :meth:" -"`Logger.error`, and :meth:`Logger.critical` all create log records with a " -"message and a level that corresponds to their respective method names. The " -"message is actually a format string, which may contain the standard string " -"substitution syntax of ``%s``, ``%d``, ``%f``, and so on. The rest of their " -"arguments is a list of objects that correspond with the substitution fields " -"in the message. With regard to ``**kwargs``, the logging methods care only " -"about a keyword of ``exc_info`` and use it to determine whether to log " -"exception information." +":meth:`Logger.debug`, :meth:`Logger.info`, :meth:`Logger.warning`, :meth:`Logger.error`, " +"and :meth:`Logger.critical` all create log records with a message and a " +"level that corresponds to their respective method names. The message is " +"actually a format string, which may contain the standard string substitution " +"syntax of ``%s``, ``%d``, ``%f``, and so on. The rest of their arguments is " +"a list of objects that correspond with the substitution fields in the " +"message. With regard to ``**kwargs``, the logging methods care only about a " +"keyword of ``exc_info`` and use it to determine whether to log exception " +"information." msgstr "" -#: howto/logging.rst:430 +#: howto/logging.rst:476 msgid "" -":meth:`Logger.exception` creates a log message similar to :meth:`Logger." -"error`. The difference is that :meth:`Logger.exception` dumps a stack trace " -"along with it. Call this method only from an exception handler." +":meth:`Logger.exception` creates a log message similar " +"to :meth:`Logger.error`. The difference is that :meth:`Logger.exception` " +"dumps a stack trace along with it. Call this method only from an exception " +"handler." msgstr "" -#: howto/logging.rst:434 +#: howto/logging.rst:480 msgid "" ":meth:`Logger.log` takes a log level as an explicit argument. This is a " "little more verbose for logging messages than using the log level " @@ -618,7 +735,7 @@ msgid "" "levels." msgstr "" -#: howto/logging.rst:438 +#: howto/logging.rst:484 msgid "" ":func:`getLogger` returns a reference to a logger instance with the " "specified name if it is provided, or ``root`` if not. The names are period-" @@ -630,7 +747,7 @@ msgid "" "descendants of ``foo``." msgstr "" -#: howto/logging.rst:446 +#: howto/logging.rst:492 msgid "" "Loggers have a concept of *effective level*. If a level is not explicitly " "set on a logger, the level of its parent is used instead as its effective " @@ -642,7 +759,7 @@ msgid "" "handlers." msgstr "" -#: howto/logging.rst:454 +#: howto/logging.rst:500 msgid "" "Child loggers propagate messages up to the handlers associated with their " "ancestor loggers. Because of this, it is unnecessary to define and configure " @@ -652,11 +769,11 @@ msgid "" "attribute of a logger to ``False``.)" msgstr "" -#: howto/logging.rst:465 +#: howto/logging.rst:511 msgid "Handlers" msgstr "" -#: howto/logging.rst:467 +#: howto/logging.rst:513 msgid "" ":class:`~logging.Handler` objects are responsible for dispatching the " "appropriate log messages (based on the log messages' severity) to the " @@ -669,14 +786,14 @@ msgid "" "of a specific severity to a specific location." msgstr "" -#: howto/logging.rst:477 +#: howto/logging.rst:523 msgid "" "The standard library includes quite a few handler types (see :ref:`useful-" -"handlers`); the tutorials use mainly :class:`StreamHandler` and :class:" -"`FileHandler` in its examples." +"handlers`); the tutorials use mainly :class:`StreamHandler` " +"and :class:`FileHandler` in its examples." msgstr "" -#: howto/logging.rst:481 +#: howto/logging.rst:527 msgid "" "There are very few methods in a handler for application developers to " "concern themselves with. The only handler methods that seem relevant for " @@ -684,7 +801,7 @@ msgid "" "not creating custom handlers) are the following configuration methods:" msgstr "" -#: howto/logging.rst:486 +#: howto/logging.rst:532 msgid "" "The :meth:`~Handler.setLevel` method, just as in logger objects, specifies " "the lowest severity that will be dispatched to the appropriate destination. " @@ -694,31 +811,31 @@ msgid "" "send on." msgstr "" -#: howto/logging.rst:492 +#: howto/logging.rst:538 msgid "" ":meth:`~Handler.setFormatter` selects a Formatter object for this handler to " "use." msgstr "" -#: howto/logging.rst:495 +#: howto/logging.rst:541 msgid "" ":meth:`~Handler.addFilter` and :meth:`~Handler.removeFilter` respectively " "configure and deconfigure filter objects on handlers." msgstr "" -#: howto/logging.rst:498 +#: howto/logging.rst:544 msgid "" -"Application code should not directly instantiate and use instances of :class:" -"`Handler`. Instead, the :class:`Handler` class is a base class that defines " -"the interface that all handlers should have and establishes some default " -"behavior that child classes can use (or override)." +"Application code should not directly instantiate and use instances " +"of :class:`Handler`. Instead, the :class:`Handler` class is a base class " +"that defines the interface that all handlers should have and establishes " +"some default behavior that child classes can use (or override)." msgstr "" -#: howto/logging.rst:505 +#: howto/logging.rst:551 msgid "Formatters" msgstr "" -#: howto/logging.rst:507 +#: howto/logging.rst:553 msgid "" "Formatter objects configure the final order, structure, and contents of the " "log message. Unlike the base :class:`logging.Handler` class, application " @@ -728,41 +845,49 @@ msgid "" "string and a style indicator." msgstr "" -#: howto/logging.rst:516 +#: howto/logging.rst:562 msgid "" "If there is no message format string, the default is to use the raw " "message. If there is no date format string, the default date format is:" msgstr "" -#: howto/logging.rst:523 +#: howto/logging.rst:565 +msgid "%Y-%m-%d %H:%M:%S" +msgstr "" + +#: howto/logging.rst:569 msgid "" "with the milliseconds tacked on at the end. The ``style`` is one of ``'%'``, " "``'{'``, or ``'$'``. If one of these is not specified, then ``'%'`` will be " "used." msgstr "" -#: howto/logging.rst:526 +#: howto/logging.rst:572 msgid "" "If the ``style`` is ``'%'``, the message format string uses ``%()s`` styled string substitution; the possible keys are documented in :" -"ref:`logrecord-attributes`. If the style is ``'{'``, the message format " +"key>)s`` styled string substitution; the possible keys are documented " +"in :ref:`logrecord-attributes`. If the style is ``'{'``, the message format " "string is assumed to be compatible with :meth:`str.format` (using keyword " "arguments), while if the style is ``'$'`` then the message format string " "should conform to what is expected by :meth:`string.Template.substitute`." msgstr "" -#: howto/logging.rst:533 +#: howto/logging.rst:579 msgid "Added the ``style`` parameter." msgstr "" -#: howto/logging.rst:536 +#: howto/logging.rst:582 msgid "" "The following message format string will log the time in a human-readable " "format, the severity of the message, and the contents of the message, in " "that order::" msgstr "" -#: howto/logging.rst:542 +#: howto/logging.rst:586 +msgid "'%(asctime)s - %(levelname)s - %(message)s'" +msgstr "" + +#: howto/logging.rst:588 msgid "" "Formatters use a user-configurable function to convert the creation time of " "a record to a tuple. By default, :func:`time.localtime` is used; to change " @@ -773,68 +898,167 @@ msgid "" "in the Formatter class (to ``time.gmtime`` for GMT display)." msgstr "" -#: howto/logging.rst:552 +#: howto/logging.rst:598 msgid "Configuring Logging" msgstr "" -#: howto/logging.rst:556 +#: howto/logging.rst:602 msgid "Programmers can configure logging in three ways:" msgstr "" -#: howto/logging.rst:558 +#: howto/logging.rst:604 msgid "" "Creating loggers, handlers, and formatters explicitly using Python code that " "calls the configuration methods listed above." msgstr "" -#: howto/logging.rst:560 +#: howto/logging.rst:606 msgid "" "Creating a logging config file and reading it using the :func:`fileConfig` " "function." msgstr "" -#: howto/logging.rst:562 +#: howto/logging.rst:608 msgid "" -"Creating a dictionary of configuration information and passing it to the :" -"func:`dictConfig` function." +"Creating a dictionary of configuration information and passing it to " +"the :func:`dictConfig` function." msgstr "" -#: howto/logging.rst:565 +#: howto/logging.rst:611 msgid "" "For the reference documentation on the last two options, see :ref:`logging-" "config-api`. The following example configures a very simple logger, a " "console handler, and a simple formatter using Python code::" msgstr "" -#: howto/logging.rst:595 +#: howto/logging.rst:615 +msgid "" +"import logging\n" +"\n" +"# create logger\n" +"logger = logging.getLogger('simple_example')\n" +"logger.setLevel(logging.DEBUG)\n" +"\n" +"# create console handler and set level to debug\n" +"ch = logging.StreamHandler()\n" +"ch.setLevel(logging.DEBUG)\n" +"\n" +"# create formatter\n" +"formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %" +"(message)s')\n" +"\n" +"# add formatter to ch\n" +"ch.setFormatter(formatter)\n" +"\n" +"# add ch to logger\n" +"logger.addHandler(ch)\n" +"\n" +"# 'application' code\n" +"logger.debug('debug message')\n" +"logger.info('info message')\n" +"logger.warning('warn message')\n" +"logger.error('error message')\n" +"logger.critical('critical message')" +msgstr "" + +#: howto/logging.rst:641 msgid "" "Running this module from the command line produces the following output:" msgstr "" -#: howto/logging.rst:606 +#: howto/logging.rst:643 +msgid "" +"$ python simple_logging_module.py\n" +"2005-03-19 15:10:26,618 - simple_example - DEBUG - debug message\n" +"2005-03-19 15:10:26,620 - simple_example - INFO - info message\n" +"2005-03-19 15:10:26,695 - simple_example - WARNING - warn message\n" +"2005-03-19 15:10:26,697 - simple_example - ERROR - error message\n" +"2005-03-19 15:10:26,773 - simple_example - CRITICAL - critical message" +msgstr "" + +#: howto/logging.rst:652 msgid "" "The following Python module creates a logger, handler, and formatter nearly " "identical to those in the example listed above, with the only difference " "being the names of the objects::" msgstr "" -#: howto/logging.rst:625 +#: howto/logging.rst:656 +msgid "" +"import logging\n" +"import logging.config\n" +"\n" +"logging.config.fileConfig('logging.conf')\n" +"\n" +"# create logger\n" +"logger = logging.getLogger('simpleExample')\n" +"\n" +"# 'application' code\n" +"logger.debug('debug message')\n" +"logger.info('info message')\n" +"logger.warning('warn message')\n" +"logger.error('error message')\n" +"logger.critical('critical message')" +msgstr "" + +#: howto/logging.rst:671 msgid "Here is the logging.conf file:" msgstr "" -#: howto/logging.rst:657 +#: howto/logging.rst:673 +msgid "" +"[loggers]\n" +"keys=root,simpleExample\n" +"\n" +"[handlers]\n" +"keys=consoleHandler\n" +"\n" +"[formatters]\n" +"keys=simpleFormatter\n" +"\n" +"[logger_root]\n" +"level=DEBUG\n" +"handlers=consoleHandler\n" +"\n" +"[logger_simpleExample]\n" +"level=DEBUG\n" +"handlers=consoleHandler\n" +"qualname=simpleExample\n" +"propagate=0\n" +"\n" +"[handler_consoleHandler]\n" +"class=StreamHandler\n" +"level=DEBUG\n" +"formatter=simpleFormatter\n" +"args=(sys.stdout,)\n" +"\n" +"[formatter_simpleFormatter]\n" +"format=%(asctime)s - %(name)s - %(levelname)s - %(message)s" +msgstr "" + +#: howto/logging.rst:703 msgid "" "The output is nearly identical to that of the non-config-file-based example:" msgstr "" -#: howto/logging.rst:668 +#: howto/logging.rst:705 +msgid "" +"$ python simple_logging_config.py\n" +"2005-03-19 15:38:55,977 - simpleExample - DEBUG - debug message\n" +"2005-03-19 15:38:55,979 - simpleExample - INFO - info message\n" +"2005-03-19 15:38:56,054 - simpleExample - WARNING - warn message\n" +"2005-03-19 15:38:56,055 - simpleExample - ERROR - error message\n" +"2005-03-19 15:38:56,130 - simpleExample - CRITICAL - critical message" +msgstr "" + +#: howto/logging.rst:714 msgid "" "You can see that the config file approach has a few advantages over the " "Python code approach, mainly separation of configuration and code and the " "ability of noncoders to easily modify the logging properties." msgstr "" -#: howto/logging.rst:672 +#: howto/logging.rst:718 msgid "" "The :func:`fileConfig` function takes a default parameter, " "``disable_existing_loggers``, which defaults to ``True`` for reasons of " @@ -845,7 +1069,7 @@ msgid "" "information, and specify ``False`` for this parameter if you wish." msgstr "" -#: howto/logging.rst:680 +#: howto/logging.rst:726 msgid "" "The dictionary passed to :func:`dictConfig` can also specify a Boolean value " "with key ``disable_existing_loggers``, which if not specified explicitly in " @@ -854,18 +1078,18 @@ msgid "" "want - in which case, provide the key explicitly with a value of ``False``." msgstr "" -#: howto/logging.rst:690 +#: howto/logging.rst:736 msgid "" "Note that the class names referenced in config files need to be either " "relative to the logging module, or absolute values which can be resolved " -"using normal import mechanisms. Thus, you could use either :class:`~logging." -"handlers.WatchedFileHandler` (relative to the logging module) or ``mypackage." -"mymodule.MyHandler`` (for a class defined in package ``mypackage`` and " -"module ``mymodule``, where ``mypackage`` is available on the Python import " -"path)." +"using normal import mechanisms. Thus, you could use " +"either :class:`~logging.handlers.WatchedFileHandler` (relative to the " +"logging module) or ``mypackage.mymodule.MyHandler`` (for a class defined in " +"package ``mypackage`` and module ``mymodule``, where ``mypackage`` is " +"available on the Python import path)." msgstr "" -#: howto/logging.rst:698 +#: howto/logging.rst:744 msgid "" "In Python 3.2, a new means of configuring logging has been introduced, using " "dictionaries to hold configuration information. This provides a superset of " @@ -880,67 +1104,89 @@ msgid "" "a socket, or use whatever approach makes sense for your application." msgstr "" -#: howto/logging.rst:710 +#: howto/logging.rst:756 msgid "" "Here's an example of the same configuration as above, in YAML format for the " "new dictionary-based approach:" msgstr "" -#: howto/logging.rst:734 +#: howto/logging.rst:759 +msgid "" +"version: 1\n" +"formatters:\n" +" simple:\n" +" format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s'\n" +"handlers:\n" +" console:\n" +" class: logging.StreamHandler\n" +" level: DEBUG\n" +" formatter: simple\n" +" stream: ext://sys.stdout\n" +"loggers:\n" +" simpleExample:\n" +" level: DEBUG\n" +" handlers: [console]\n" +" propagate: no\n" +"root:\n" +" level: DEBUG\n" +" handlers: [console]" +msgstr "" + +#: howto/logging.rst:780 msgid "" "For more information about logging using a dictionary, see :ref:`logging-" "config-api`." msgstr "" -#: howto/logging.rst:738 +#: howto/logging.rst:784 msgid "What happens if no configuration is provided" msgstr "" -#: howto/logging.rst:740 +#: howto/logging.rst:786 msgid "" "If no logging configuration is provided, it is possible to have a situation " "where a logging event needs to be output, but no handlers can be found to " "output the event." msgstr "" -#: howto/logging.rst:744 +#: howto/logging.rst:790 msgid "" -"The event is output using a 'handler of last resort', stored in :data:" -"`lastResort`. This internal handler is not associated with any logger, and " -"acts like a :class:`~logging.StreamHandler` which writes the event " -"description message to the current value of ``sys.stderr`` (therefore " +"The event is output using a 'handler of last resort', stored " +"in :data:`lastResort`. This internal handler is not associated with any " +"logger, and acts like a :class:`~logging.StreamHandler` which writes the " +"event description message to the current value of ``sys.stderr`` (therefore " "respecting any redirections which may be in effect). No formatting is done " "on the message - just the bare event description message is printed. The " "handler's level is set to ``WARNING``, so all events at this and greater " "severities will be output." msgstr "" -#: howto/logging.rst:755 +#: howto/logging.rst:801 msgid "For versions of Python prior to 3.2, the behaviour is as follows:" msgstr "" -#: howto/logging.rst:757 +#: howto/logging.rst:803 msgid "" "If :data:`raiseExceptions` is ``False`` (production mode), the event is " "silently dropped." msgstr "" -#: howto/logging.rst:760 +#: howto/logging.rst:806 msgid "" "If :data:`raiseExceptions` is ``True`` (development mode), a message 'No " "handlers could be found for logger X.Y.Z' is printed once." msgstr "" -#: howto/logging.rst:763 +#: howto/logging.rst:809 msgid "" "To obtain the pre-3.2 behaviour, :data:`lastResort` can be set to ``None``." msgstr "" -#: howto/logging.rst:769 +#: howto/logging.rst:815 msgid "Configuring Logging for a Library" msgstr "" -#: howto/logging.rst:771 +#: howto/logging.rst:817 msgid "" "When developing a library which uses logging, you should take care to " "document how the library uses logging - for example, the names of loggers " @@ -951,7 +1197,7 @@ msgid "" "is regarded as the best default behaviour." msgstr "" -#: howto/logging.rst:779 +#: howto/logging.rst:825 msgid "" "If for some reason you *don't* want these messages printed in the absence of " "any logging configuration, you can attach a do-nothing handler to the top-" @@ -963,25 +1209,31 @@ msgid "" "to those handlers, as normal." msgstr "" -#: howto/logging.rst:788 +#: howto/logging.rst:834 msgid "" -"A do-nothing handler is included in the logging package: :class:`~logging." -"NullHandler` (since Python 3.1). An instance of this handler could be added " -"to the top-level logger of the logging namespace used by the library (*if* " -"you want to prevent your library's logged events being output to ``sys." -"stderr`` in the absence of logging configuration). If all logging by a " -"library *foo* is done using loggers with names matching 'foo.x', 'foo.x.y', " -"etc. then the code::" +"A do-nothing handler is included in the logging " +"package: :class:`~logging.NullHandler` (since Python 3.1). An instance of " +"this handler could be added to the top-level logger of the logging namespace " +"used by the library (*if* you want to prevent your library's logged events " +"being output to ``sys.stderr`` in the absence of logging configuration). If " +"all logging by a library *foo* is done using loggers with names matching " +"'foo.x', 'foo.x.y', etc. then the code::" msgstr "" -#: howto/logging.rst:799 +#: howto/logging.rst:842 +msgid "" +"import logging\n" +"logging.getLogger('foo').addHandler(logging.NullHandler())" +msgstr "" + +#: howto/logging.rst:845 msgid "" "should have the desired effect. If an organisation produces a number of " "libraries, then the logger name specified can be 'orgname.foo' rather than " "just 'foo'." msgstr "" -#: howto/logging.rst:803 +#: howto/logging.rst:849 msgid "" "It is strongly advised that you *do not log to the root logger* in your " "library. Instead, use a logger with a unique and easily identifiable name, " @@ -991,22 +1243,23 @@ msgid "" "library as they wish." msgstr "" -#: howto/logging.rst:810 +#: howto/logging.rst:856 msgid "" -"It is strongly advised that you *do not add any handlers other than* :class:" -"`~logging.NullHandler` *to your library's loggers*. This is because the " -"configuration of handlers is the prerogative of the application developer " -"who uses your library. The application developer knows their target audience " -"and what handlers are most appropriate for their application: if you add " -"handlers 'under the hood', you might well interfere with their ability to " -"carry out unit tests and deliver logs which suit their requirements." +"It is strongly advised that you *do not add any handlers other " +"than* :class:`~logging.NullHandler` *to your library's loggers*. This is " +"because the configuration of handlers is the prerogative of the application " +"developer who uses your library. The application developer knows their " +"target audience and what handlers are most appropriate for their " +"application: if you add handlers 'under the hood', you might well interfere " +"with their ability to carry out unit tests and deliver logs which suit their " +"requirements." msgstr "" -#: howto/logging.rst:821 +#: howto/logging.rst:867 msgid "Logging Levels" msgstr "" -#: howto/logging.rst:823 +#: howto/logging.rst:869 msgid "" "The numeric values of logging levels are given in the following table. These " "are primarily of interest if you want to define your own levels, and need " @@ -1015,39 +1268,39 @@ msgid "" "value; the predefined name is lost." msgstr "" -#: howto/logging.rst:830 +#: howto/logging.rst:876 msgid "Numeric value" msgstr "" -#: howto/logging.rst:832 +#: howto/logging.rst:878 msgid "50" msgstr "" -#: howto/logging.rst:834 +#: howto/logging.rst:880 msgid "40" msgstr "" -#: howto/logging.rst:836 +#: howto/logging.rst:882 msgid "30" msgstr "" -#: howto/logging.rst:838 +#: howto/logging.rst:884 msgid "20" msgstr "" -#: howto/logging.rst:840 +#: howto/logging.rst:886 msgid "10" msgstr "" -#: howto/logging.rst:842 +#: howto/logging.rst:888 msgid "``NOTSET``" msgstr "" -#: howto/logging.rst:842 +#: howto/logging.rst:888 msgid "0" msgstr "" -#: howto/logging.rst:845 +#: howto/logging.rst:891 msgid "" "Levels can also be associated with loggers, being set either by the " "developer or through loading a saved logging configuration. When a logging " @@ -1057,45 +1310,45 @@ msgid "" "basic mechanism controlling the verbosity of logging output." msgstr "" -#: howto/logging.rst:852 +#: howto/logging.rst:898 msgid "" "Logging messages are encoded as instances of the :class:`~logging.LogRecord` " -"class. When a logger decides to actually log an event, a :class:`~logging." -"LogRecord` instance is created from the logging message." +"class. When a logger decides to actually log an event, " +"a :class:`~logging.LogRecord` instance is created from the logging message." msgstr "" -#: howto/logging.rst:856 +#: howto/logging.rst:902 msgid "" -"Logging messages are subjected to a dispatch mechanism through the use of :" -"dfn:`handlers`, which are instances of subclasses of the :class:`Handler` " -"class. Handlers are responsible for ensuring that a logged message (in the " -"form of a :class:`LogRecord`) ends up in a particular location (or set of " -"locations) which is useful for the target audience for that message (such as " -"end users, support desk staff, system administrators, developers). Handlers " -"are passed :class:`LogRecord` instances intended for particular " -"destinations. Each logger can have zero, one or more handlers associated " -"with it (via the :meth:`~Logger.addHandler` method of :class:`Logger`). In " -"addition to any handlers directly associated with a logger, *all handlers " -"associated with all ancestors of the logger* are called to dispatch the " -"message (unless the *propagate* flag for a logger is set to a false value, " -"at which point the passing to ancestor handlers stops)." +"Logging messages are subjected to a dispatch mechanism through the use " +"of :dfn:`handlers`, which are instances of subclasses of " +"the :class:`Handler` class. Handlers are responsible for ensuring that a " +"logged message (in the form of a :class:`LogRecord`) ends up in a particular " +"location (or set of locations) which is useful for the target audience for " +"that message (such as end users, support desk staff, system administrators, " +"developers). Handlers are passed :class:`LogRecord` instances intended for " +"particular destinations. Each logger can have zero, one or more handlers " +"associated with it (via the :meth:`~Logger.addHandler` method " +"of :class:`Logger`). In addition to any handlers directly associated with a " +"logger, *all handlers associated with all ancestors of the logger* are " +"called to dispatch the message (unless the *propagate* flag for a logger is " +"set to a false value, at which point the passing to ancestor handlers stops)." msgstr "" -#: howto/logging.rst:870 +#: howto/logging.rst:916 msgid "" "Just as for loggers, handlers can have levels associated with them. A " "handler's level acts as a filter in the same way as a logger's level does. " -"If a handler decides to actually dispatch an event, the :meth:`~Handler." -"emit` method is used to send the message to its destination. Most user-" -"defined subclasses of :class:`Handler` will need to override this :meth:" -"`~Handler.emit`." +"If a handler decides to actually dispatch an event, " +"the :meth:`~Handler.emit` method is used to send the message to its " +"destination. Most user-defined subclasses of :class:`Handler` will need to " +"override this :meth:`~Handler.emit`." msgstr "" -#: howto/logging.rst:879 +#: howto/logging.rst:925 msgid "Custom Levels" msgstr "" -#: howto/logging.rst:881 +#: howto/logging.rst:927 msgid "" "Defining your own levels is possible, but should not be necessary, as the " "existing levels have been chosen on the basis of practical experience. " @@ -1108,89 +1361,89 @@ msgid "" "given numeric value might mean different things for different libraries." msgstr "" -#: howto/logging.rst:894 +#: howto/logging.rst:940 msgid "Useful Handlers" msgstr "" -#: howto/logging.rst:896 +#: howto/logging.rst:942 msgid "" "In addition to the base :class:`Handler` class, many useful subclasses are " "provided:" msgstr "" -#: howto/logging.rst:899 +#: howto/logging.rst:945 msgid "" ":class:`StreamHandler` instances send messages to streams (file-like " "objects)." msgstr "" -#: howto/logging.rst:902 +#: howto/logging.rst:948 msgid ":class:`FileHandler` instances send messages to disk files." msgstr "" -#: howto/logging.rst:904 +#: howto/logging.rst:950 msgid "" ":class:`~handlers.BaseRotatingHandler` is the base class for handlers that " "rotate log files at a certain point. It is not meant to be instantiated " -"directly. Instead, use :class:`~handlers.RotatingFileHandler` or :class:" -"`~handlers.TimedRotatingFileHandler`." +"directly. Instead, use :class:`~handlers.RotatingFileHandler` " +"or :class:`~handlers.TimedRotatingFileHandler`." msgstr "" -#: howto/logging.rst:909 +#: howto/logging.rst:955 msgid "" ":class:`~handlers.RotatingFileHandler` instances send messages to disk " "files, with support for maximum log file sizes and log file rotation." msgstr "" -#: howto/logging.rst:912 +#: howto/logging.rst:958 msgid "" ":class:`~handlers.TimedRotatingFileHandler` instances send messages to disk " "files, rotating the log file at certain timed intervals." msgstr "" -#: howto/logging.rst:915 +#: howto/logging.rst:961 msgid "" ":class:`~handlers.SocketHandler` instances send messages to TCP/IP sockets. " "Since 3.4, Unix domain sockets are also supported." msgstr "" -#: howto/logging.rst:918 +#: howto/logging.rst:964 msgid "" ":class:`~handlers.DatagramHandler` instances send messages to UDP sockets. " "Since 3.4, Unix domain sockets are also supported." msgstr "" -#: howto/logging.rst:921 +#: howto/logging.rst:967 msgid "" ":class:`~handlers.SMTPHandler` instances send messages to a designated email " "address." msgstr "" -#: howto/logging.rst:924 +#: howto/logging.rst:970 msgid "" ":class:`~handlers.SysLogHandler` instances send messages to a Unix syslog " "daemon, possibly on a remote machine." msgstr "" -#: howto/logging.rst:927 +#: howto/logging.rst:973 msgid "" -":class:`~handlers.NTEventLogHandler` instances send messages to a Windows " -"NT/2000/XP event log." +":class:`~handlers.NTEventLogHandler` instances send messages to a Windows NT/" +"2000/XP event log." msgstr "" -#: howto/logging.rst:930 +#: howto/logging.rst:976 msgid "" ":class:`~handlers.MemoryHandler` instances send messages to a buffer in " "memory, which is flushed whenever specific criteria are met." msgstr "" -#: howto/logging.rst:933 +#: howto/logging.rst:979 msgid "" ":class:`~handlers.HTTPHandler` instances send messages to an HTTP server " "using either ``GET`` or ``POST`` semantics." msgstr "" -#: howto/logging.rst:936 +#: howto/logging.rst:982 msgid "" ":class:`~handlers.WatchedFileHandler` instances watch the file they are " "logging to. If the file changes, it is closed and reopened using the file " @@ -1198,13 +1451,13 @@ msgid "" "support the underlying mechanism used." msgstr "" -#: howto/logging.rst:941 +#: howto/logging.rst:987 msgid "" ":class:`~handlers.QueueHandler` instances send messages to a queue, such as " "those implemented in the :mod:`queue` or :mod:`multiprocessing` modules." msgstr "" -#: howto/logging.rst:944 +#: howto/logging.rst:990 msgid "" ":class:`NullHandler` instances do nothing with error messages. They are used " "by library developers who want to use logging, but want to avoid the 'No " @@ -1213,15 +1466,15 @@ msgid "" "more information." msgstr "" -#: howto/logging.rst:950 +#: howto/logging.rst:996 msgid "The :class:`NullHandler` class." msgstr "" -#: howto/logging.rst:953 +#: howto/logging.rst:999 msgid "The :class:`~handlers.QueueHandler` class." msgstr "" -#: howto/logging.rst:956 +#: howto/logging.rst:1002 msgid "" "The :class:`NullHandler`, :class:`StreamHandler` and :class:`FileHandler` " "classes are defined in the core logging package. The other handlers are " @@ -1229,43 +1482,43 @@ msgid "" "module, :mod:`logging.config`, for configuration functionality.)" msgstr "" -#: howto/logging.rst:961 +#: howto/logging.rst:1007 msgid "" -"Logged messages are formatted for presentation through instances of the :" -"class:`Formatter` class. They are initialized with a format string suitable " -"for use with the % operator and a dictionary." +"Logged messages are formatted for presentation through instances of " +"the :class:`Formatter` class. They are initialized with a format string " +"suitable for use with the % operator and a dictionary." msgstr "" -#: howto/logging.rst:965 +#: howto/logging.rst:1011 msgid "" -"For formatting multiple messages in a batch, instances of :class:" -"`BufferingFormatter` can be used. In addition to the format string (which is " -"applied to each message in the batch), there is provision for header and " -"trailer format strings." +"For formatting multiple messages in a batch, instances " +"of :class:`BufferingFormatter` can be used. In addition to the format string " +"(which is applied to each message in the batch), there is provision for " +"header and trailer format strings." msgstr "" -#: howto/logging.rst:970 +#: howto/logging.rst:1016 msgid "" "When filtering based on logger level and/or handler level is not enough, " -"instances of :class:`Filter` can be added to both :class:`Logger` and :class:" -"`Handler` instances (through their :meth:`~Handler.addFilter` method). " -"Before deciding to process a message further, both loggers and handlers " -"consult all their filters for permission. If any filter returns a false " -"value, the message is not processed further." +"instances of :class:`Filter` can be added to both :class:`Logger` " +"and :class:`Handler` instances (through their :meth:`~Handler.addFilter` " +"method). Before deciding to process a message further, both loggers and " +"handlers consult all their filters for permission. If any filter returns a " +"false value, the message is not processed further." msgstr "" -#: howto/logging.rst:977 +#: howto/logging.rst:1023 msgid "" "The basic :class:`Filter` functionality allows filtering by specific logger " "name. If this feature is used, messages sent to the named logger and its " "children are allowed through the filter, and all others dropped." msgstr "" -#: howto/logging.rst:985 +#: howto/logging.rst:1031 msgid "Exceptions raised during logging" msgstr "" -#: howto/logging.rst:987 +#: howto/logging.rst:1033 msgid "" "The logging package is designed to swallow exceptions which occur while " "logging in production. This is so that errors which occur while handling " @@ -1273,23 +1526,23 @@ msgid "" "errors - do not cause the application using logging to terminate prematurely." msgstr "" -#: howto/logging.rst:992 +#: howto/logging.rst:1038 msgid "" ":class:`SystemExit` and :class:`KeyboardInterrupt` exceptions are never " "swallowed. Other exceptions which occur during the :meth:`~Handler.emit` " -"method of a :class:`Handler` subclass are passed to its :meth:`~Handler." -"handleError` method." +"method of a :class:`Handler` subclass are passed to " +"its :meth:`~Handler.handleError` method." msgstr "" -#: howto/logging.rst:997 +#: howto/logging.rst:1043 msgid "" -"The default implementation of :meth:`~Handler.handleError` in :class:" -"`Handler` checks to see if a module-level variable, :data:`raiseExceptions`, " -"is set. If set, a traceback is printed to :data:`sys.stderr`. If not set, " -"the exception is swallowed." +"The default implementation of :meth:`~Handler.handleError` " +"in :class:`Handler` checks to see if a module-level " +"variable, :data:`raiseExceptions`, is set. If set, a traceback is printed " +"to :data:`sys.stderr`. If not set, the exception is swallowed." msgstr "" -#: howto/logging.rst:1003 +#: howto/logging.rst:1049 msgid "" "The default value of :data:`raiseExceptions` is ``True``. This is because " "during development, you typically want to be notified of any exceptions that " @@ -1297,44 +1550,51 @@ msgid "" "production usage." msgstr "" -#: howto/logging.rst:1013 +#: howto/logging.rst:1059 msgid "Using arbitrary objects as messages" msgstr "" -#: howto/logging.rst:1015 +#: howto/logging.rst:1061 msgid "" "In the preceding sections and examples, it has been assumed that the message " "passed when logging the event is a string. However, this is not the only " -"possibility. You can pass an arbitrary object as a message, and its :meth:" -"`~object.__str__` method will be called when the logging system needs to " -"convert it to a string representation. In fact, if you want to, you can " -"avoid computing a string representation altogether - for example, the :class:" -"`~handlers.SocketHandler` emits an event by pickling it and sending it over " -"the wire." +"possibility. You can pass an arbitrary object as a message, and " +"its :meth:`~object.__str__` method will be called when the logging system " +"needs to convert it to a string representation. In fact, if you want to, you " +"can avoid computing a string representation altogether - for example, " +"the :class:`~handlers.SocketHandler` emits an event by pickling it and " +"sending it over the wire." msgstr "" -#: howto/logging.rst:1026 +#: howto/logging.rst:1072 msgid "Optimization" msgstr "" -#: howto/logging.rst:1028 +#: howto/logging.rst:1074 msgid "" "Formatting of message arguments is deferred until it cannot be avoided. " "However, computing the arguments passed to the logging method can also be " "expensive, and you may want to avoid doing it if the logger will just throw " -"away your event. To decide what to do, you can call the :meth:`~Logger." -"isEnabledFor` method which takes a level argument and returns true if the " -"event would be created by the Logger for that level of call. You can write " -"code like this::" +"away your event. To decide what to do, you can call " +"the :meth:`~Logger.isEnabledFor` method which takes a level argument and " +"returns true if the event would be created by the Logger for that level of " +"call. You can write code like this::" +msgstr "" + +#: howto/logging.rst:1082 +msgid "" +"if logger.isEnabledFor(logging.DEBUG):\n" +" logger.debug('Message with %s, %s', expensive_func1(),\n" +" expensive_func2())" msgstr "" -#: howto/logging.rst:1040 +#: howto/logging.rst:1086 msgid "" "so that if the logger's threshold is set above ``DEBUG``, the calls to " "``expensive_func1`` and ``expensive_func2`` are never made." msgstr "" -#: howto/logging.rst:1043 +#: howto/logging.rst:1089 msgid "" "In some cases, :meth:`~Logger.isEnabledFor` can itself be more expensive " "than you'd like (e.g. for deeply nested loggers where an explicit level is " @@ -1346,7 +1606,7 @@ msgid "" "while the application is running (which is not all that common)." msgstr "" -#: howto/logging.rst:1052 +#: howto/logging.rst:1098 msgid "" "There are other optimizations which can be made for specific applications " "which need more precise control over what logging information is collected. " @@ -1354,94 +1614,95 @@ msgid "" "you don't need:" msgstr "" -#: howto/logging.rst:1058 +#: howto/logging.rst:1104 msgid "What you don't want to collect" msgstr "" -#: howto/logging.rst:1058 +#: howto/logging.rst:1104 msgid "How to avoid collecting it" msgstr "" -#: howto/logging.rst:1060 +#: howto/logging.rst:1106 msgid "Information about where calls were made from." msgstr "" -#: howto/logging.rst:1060 +#: howto/logging.rst:1106 msgid "" -"Set ``logging._srcfile`` to ``None``. This avoids calling :func:`sys." -"_getframe`, which may help to speed up your code in environments like PyPy " -"(which can't speed up code that uses :func:`sys._getframe`)." +"Set ``logging._srcfile`` to ``None``. This avoids " +"calling :func:`sys._getframe`, which may help to speed up your code in " +"environments like PyPy (which can't speed up code that " +"uses :func:`sys._getframe`)." msgstr "" -#: howto/logging.rst:1066 +#: howto/logging.rst:1112 msgid "Threading information." msgstr "" -#: howto/logging.rst:1066 +#: howto/logging.rst:1112 msgid "Set ``logging.logThreads`` to ``False``." msgstr "" -#: howto/logging.rst:1068 +#: howto/logging.rst:1114 msgid "Current process ID (:func:`os.getpid`)" msgstr "" -#: howto/logging.rst:1068 +#: howto/logging.rst:1114 msgid "Set ``logging.logProcesses`` to ``False``." msgstr "" -#: howto/logging.rst:1070 +#: howto/logging.rst:1116 msgid "" "Current process name when using ``multiprocessing`` to manage multiple " "processes." msgstr "" -#: howto/logging.rst:1070 +#: howto/logging.rst:1116 msgid "Set ``logging.logMultiprocessing`` to ``False``." msgstr "" -#: howto/logging.rst:1073 +#: howto/logging.rst:1119 msgid "Current :class:`asyncio.Task` name when using ``asyncio``." msgstr "" -#: howto/logging.rst:1073 +#: howto/logging.rst:1119 msgid "Set ``logging.logAsyncioTasks`` to ``False``." msgstr "" -#: howto/logging.rst:1077 +#: howto/logging.rst:1123 msgid "" "Also note that the core logging module only includes the basic handlers. If " "you don't import :mod:`logging.handlers` and :mod:`logging.config`, they " "won't take up any memory." msgstr "" -#: howto/logging.rst:1084 +#: howto/logging.rst:1130 msgid "Other resources" msgstr "" -#: howto/logging.rst:1089 +#: howto/logging.rst:1134 msgid "Module :mod:`logging`" msgstr "" -#: howto/logging.rst:1089 +#: howto/logging.rst:1135 msgid "API reference for the logging module." msgstr "" -#: howto/logging.rst:1092 +#: howto/logging.rst:1137 msgid "Module :mod:`logging.config`" msgstr "" -#: howto/logging.rst:1092 +#: howto/logging.rst:1138 msgid "Configuration API for the logging module." msgstr "" -#: howto/logging.rst:1095 +#: howto/logging.rst:1140 msgid "Module :mod:`logging.handlers`" msgstr "" -#: howto/logging.rst:1095 +#: howto/logging.rst:1141 msgid "Useful handlers included with the logging module." msgstr "" -#: howto/logging.rst:1097 +#: howto/logging.rst:1143 msgid ":ref:`A logging cookbook `" msgstr "" diff --git a/howto/mro.po b/howto/mro.po new file mode 100644 index 00000000..0d0336a3 --- /dev/null +++ b/howto/mro.po @@ -0,0 +1,904 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: howto/mro.rst:4 +msgid "The Python 2.3 Method Resolution Order" +msgstr "" + +#: howto/mro.rst:8 +msgid "" +"This is a historical document, provided as an appendix to the official " +"documentation. The Method Resolution Order discussed here was *introduced* " +"in Python 2.3, but it is still used in later versions -- including Python 3." +msgstr "" + +#: howto/mro.rst:13 +msgid "By `Michele Simionato `__." +msgstr "" + +#: howto/mro.rst:0 +msgid "Abstract" +msgstr "" + +#: howto/mro.rst:17 +msgid "" +"*This document is intended for Python programmers who want to understand the " +"C3 Method Resolution Order used in Python 2.3. Although it is not intended " +"for newbies, it is quite pedagogical with many worked out examples. I am " +"not aware of other publicly available documents with the same scope, " +"therefore it should be useful.*" +msgstr "" + +#: howto/mro.rst:23 +msgid "Disclaimer:" +msgstr "" + +#: howto/mro.rst:25 +msgid "" +"*I donate this document to the Python Software Foundation, under the Python " +"2.3 license. As usual in these circumstances, I warn the reader that what " +"follows* should *be correct, but I don't give any warranty. Use it at your " +"own risk and peril!*" +msgstr "" + +#: howto/mro.rst:30 +msgid "Acknowledgments:" +msgstr "" + +#: howto/mro.rst:32 +msgid "" +"*All the people of the Python mailing list who sent me their support. Paul " +"Foley who pointed out various imprecisions and made me to add the part on " +"local precedence ordering. David Goodger for help with the formatting in " +"reStructuredText. David Mertz for help with the editing. Finally, Guido van " +"Rossum who enthusiastically added this document to the official Python 2.3 " +"home-page.*" +msgstr "" + +#: howto/mro.rst:40 +msgid "The beginning" +msgstr "" + +#: howto/mro.rst:42 +msgid "*Felix qui potuit rerum cognoscere causas* -- Virgilius" +msgstr "" + +#: howto/mro.rst:44 +msgid "" +"Everything started with a post by Samuele Pedroni to the Python development " +"mailing list [#]_. In his post, Samuele showed that the Python 2.2 method " +"resolution order is not monotonic and he proposed to replace it with the C3 " +"method resolution order. Guido agreed with his arguments and therefore now " +"Python 2.3 uses C3. The C3 method itself has nothing to do with Python, " +"since it was invented by people working on Dylan and it is described in a " +"paper intended for lispers [#]_. The present paper gives a (hopefully) " +"readable discussion of the C3 algorithm for Pythonistas who want to " +"understand the reasons for the change." +msgstr "" + +#: howto/mro.rst:55 +msgid "" +"First of all, let me point out that what I am going to say only applies to " +"the *new style classes* introduced in Python 2.2: *classic classes* " +"maintain their old method resolution order, depth first and then left to " +"right. Therefore, there is no breaking of old code for classic classes; and " +"even if in principle there could be breaking of code for Python 2.2 new " +"style classes, in practice the cases in which the C3 resolution order " +"differs from the Python 2.2 method resolution order are so rare that no real " +"breaking of code is expected. Therefore:" +msgstr "" + +#: howto/mro.rst:64 +msgid "*Don't be scared!*" +msgstr "" + +#: howto/mro.rst:66 +msgid "" +"Moreover, unless you make strong use of multiple inheritance and you have " +"non-trivial hierarchies, you don't need to understand the C3 algorithm, and " +"you can easily skip this paper. On the other hand, if you really want to " +"know how multiple inheritance works, then this paper is for you. The good " +"news is that things are not as complicated as you might expect." +msgstr "" + +#: howto/mro.rst:73 +msgid "Let me begin with some basic definitions." +msgstr "" + +#: howto/mro.rst:75 +msgid "" +"Given a class C in a complicated multiple inheritance hierarchy, it is a non-" +"trivial task to specify the order in which methods are overridden, i.e. to " +"specify the order of the ancestors of C." +msgstr "" + +#: howto/mro.rst:79 +msgid "" +"The list of the ancestors of a class C, including the class itself, ordered " +"from the nearest ancestor to the furthest, is called the class precedence " +"list or the *linearization* of C." +msgstr "" + +#: howto/mro.rst:83 +msgid "" +"The *Method Resolution Order* (MRO) is the set of rules that construct the " +"linearization. In the Python literature, the idiom \"the MRO of C\" is also " +"used as a synonymous for the linearization of the class C." +msgstr "" + +#: howto/mro.rst:88 +msgid "" +"For instance, in the case of single inheritance hierarchy, if C is a " +"subclass of C1, and C1 is a subclass of C2, then the linearization of C is " +"simply the list [C, C1 , C2]. However, with multiple inheritance " +"hierarchies, the construction of the linearization is more cumbersome, since " +"it is more difficult to construct a linearization that respects *local " +"precedence ordering* and *monotonicity*." +msgstr "" + +#: howto/mro.rst:96 +msgid "" +"I will discuss the local precedence ordering later, but I can give the " +"definition of monotonicity here. A MRO is monotonic when the following is " +"true: *if C1 precedes C2 in the linearization of C, then C1 precedes C2 in " +"the linearization of any subclass of C*. Otherwise, the innocuous operation " +"of deriving a new class could change the resolution order of methods, " +"potentially introducing very subtle bugs. Examples where this happens will " +"be shown later." +msgstr "" + +#: howto/mro.rst:104 +msgid "" +"Not all classes admit a linearization. There are cases, in complicated " +"hierarchies, where it is not possible to derive a class such that its " +"linearization respects all the desired properties." +msgstr "" + +#: howto/mro.rst:108 +msgid "Here I give an example of this situation. Consider the hierarchy" +msgstr "" + +#: howto/mro.rst:116 +msgid "" +"which can be represented with the following inheritance graph, where I have " +"denoted with O the ``object`` class, which is the beginning of any hierarchy " +"for new style classes:" +msgstr "" + +#: howto/mro.rst:120 +msgid "" +" -----------\n" +"| |\n" +"| O |\n" +"| / \\ |\n" +" - X Y /\n" +" | / | /\n" +" | / |/\n" +" A B\n" +" \\ /\n" +" ?" +msgstr "" + +#: howto/mro.rst:133 +msgid "" +"In this case, it is not possible to derive a new class C from A and B, since " +"X precedes Y in A, but Y precedes X in B, therefore the method resolution " +"order would be ambiguous in C." +msgstr "" + +#: howto/mro.rst:137 +msgid "" +"Python 2.3 raises an exception in this situation (TypeError: MRO conflict " +"among bases Y, X) forbidding the naive programmer from creating ambiguous " +"hierarchies. Python 2.2 instead does not raise an exception, but chooses an " +"*ad hoc* ordering (CABXYO in this case)." +msgstr "" + +#: howto/mro.rst:143 +msgid "The C3 Method Resolution Order" +msgstr "" + +#: howto/mro.rst:145 +msgid "" +"Let me introduce a few simple notations which will be useful for the " +"following discussion. I will use the shortcut notation::" +msgstr "" + +#: howto/mro.rst:148 +msgid "C1 C2 ... CN" +msgstr "" + +#: howto/mro.rst:150 +msgid "to indicate the list of classes [C1, C2, ... , CN]." +msgstr "" + +#: howto/mro.rst:152 +msgid "The *head* of the list is its first element::" +msgstr "" + +#: howto/mro.rst:154 +msgid "head = C1" +msgstr "" + +#: howto/mro.rst:156 +msgid "whereas the *tail* is the rest of the list::" +msgstr "" + +#: howto/mro.rst:158 +msgid "tail = C2 ... CN." +msgstr "" + +#: howto/mro.rst:160 +msgid "I shall also use the notation::" +msgstr "" + +#: howto/mro.rst:162 +msgid "C + (C1 C2 ... CN) = C C1 C2 ... CN" +msgstr "" + +#: howto/mro.rst:164 +msgid "to denote the sum of the lists [C] + [C1, C2, ... ,CN]." +msgstr "" + +#: howto/mro.rst:166 +msgid "Now I can explain how the MRO works in Python 2.3." +msgstr "" + +#: howto/mro.rst:168 +msgid "" +"Consider a class C in a multiple inheritance hierarchy, with C inheriting " +"from the base classes B1, B2, ... , BN. We want to compute the " +"linearization L[C] of the class C. The rule is the following:" +msgstr "" + +#: howto/mro.rst:173 +msgid "" +"*the linearization of C is the sum of C plus the merge of the linearizations " +"of the parents and the list of the parents.*" +msgstr "" + +#: howto/mro.rst:176 +msgid "In symbolic notation::" +msgstr "" + +#: howto/mro.rst:178 +msgid "L[C(B1 ... BN)] = C + merge(L[B1] ... L[BN], B1 ... BN)" +msgstr "" + +#: howto/mro.rst:180 +msgid "" +"In particular, if C is the ``object`` class, which has no parents, the " +"linearization is trivial::" +msgstr "" + +#: howto/mro.rst:183 +msgid "L[object] = object." +msgstr "" + +#: howto/mro.rst:185 +msgid "" +"However, in general one has to compute the merge according to the following " +"prescription:" +msgstr "" + +#: howto/mro.rst:188 +msgid "" +"*take the head of the first list, i.e L[B1][0]; if this head is not in the " +"tail of any of the other lists, then add it to the linearization of C and " +"remove it from the lists in the merge, otherwise look at the head of the " +"next list and take it, if it is a good head. Then repeat the operation " +"until all the class are removed or it is impossible to find good heads. In " +"this case, it is impossible to construct the merge, Python 2.3 will refuse " +"to create the class C and will raise an exception.*" +msgstr "" + +#: howto/mro.rst:197 +msgid "" +"This prescription ensures that the merge operation *preserves* the ordering, " +"if the ordering can be preserved. On the other hand, if the order cannot be " +"preserved (as in the example of serious order disagreement discussed above) " +"then the merge cannot be computed." +msgstr "" + +#: howto/mro.rst:202 +msgid "" +"The computation of the merge is trivial if C has only one parent (single " +"inheritance); in this case::" +msgstr "" + +#: howto/mro.rst:205 +msgid "L[C(B)] = C + merge(L[B],B) = C + L[B]" +msgstr "" + +#: howto/mro.rst:207 +msgid "" +"However, in the case of multiple inheritance things are more cumbersome and " +"I don't expect you can understand the rule without a couple of examples ;-)" +msgstr "" + +#: howto/mro.rst:212 +msgid "Examples" +msgstr "" + +#: howto/mro.rst:214 +msgid "First example. Consider the following hierarchy:" +msgstr "" + +#: howto/mro.rst:224 +msgid "In this case the inheritance graph can be drawn as:" +msgstr "" + +#: howto/mro.rst:226 +msgid "" +" 6\n" +" ---\n" +"Level 3 | O | (more general)\n" +" / --- \\\n" +" / | \\ |\n" +" / | \\ |\n" +" / | \\ |\n" +" --- --- --- |\n" +"Level 2 3 | D | 4| E | | F | 5 |\n" +" --- --- --- |\n" +" \\ \\ _ / | |\n" +" \\ / \\ _ | |\n" +" \\ / \\ | |\n" +" --- --- |\n" +"Level 1 1 | B | | C | 2 |\n" +" --- --- |\n" +" \\ / |\n" +" \\ / \\ /\n" +" ---\n" +"Level 0 0 | A | (more specialized)\n" +" ---" +msgstr "" + +#: howto/mro.rst:251 +msgid "The linearizations of O,D,E and F are trivial::" +msgstr "" + +#: howto/mro.rst:253 +msgid "" +"L[O] = O\n" +"L[D] = D O\n" +"L[E] = E O\n" +"L[F] = F O" +msgstr "" + +#: howto/mro.rst:258 +msgid "The linearization of B can be computed as::" +msgstr "" + +#: howto/mro.rst:260 +msgid "L[B] = B + merge(DO, EO, DE)" +msgstr "" + +#: howto/mro.rst:262 +msgid "" +"We see that D is a good head, therefore we take it and we are reduced to " +"compute ``merge(O,EO,E)``. Now O is not a good head, since it is in the " +"tail of the sequence EO. In this case the rule says that we have to skip to " +"the next sequence. Then we see that E is a good head; we take it and we are " +"reduced to compute ``merge(O,O)`` which gives O. Therefore::" +msgstr "" + +#: howto/mro.rst:268 +msgid "L[B] = B D E O" +msgstr "" + +#: howto/mro.rst:270 +msgid "Using the same procedure one finds::" +msgstr "" + +#: howto/mro.rst:272 +msgid "" +"L[C] = C + merge(DO,FO,DF)\n" +" = C + D + merge(O,FO,F)\n" +" = C + D + F + merge(O,O)\n" +" = C D F O" +msgstr "" + +#: howto/mro.rst:277 +msgid "Now we can compute::" +msgstr "" + +#: howto/mro.rst:279 +msgid "" +"L[A] = A + merge(BDEO,CDFO,BC)\n" +" = A + B + merge(DEO,CDFO,C)\n" +" = A + B + C + merge(DEO,DFO)\n" +" = A + B + C + D + merge(EO,FO)\n" +" = A + B + C + D + E + merge(O,FO)\n" +" = A + B + C + D + E + F + merge(O,O)\n" +" = A B C D E F O" +msgstr "" + +#: howto/mro.rst:287 +msgid "" +"In this example, the linearization is ordered in a pretty nice way according " +"to the inheritance level, in the sense that lower levels (i.e. more " +"specialized classes) have higher precedence (see the inheritance graph). " +"However, this is not the general case." +msgstr "" + +#: howto/mro.rst:292 +msgid "" +"I leave as an exercise for the reader to compute the linearization for my " +"second example:" +msgstr "" + +#: howto/mro.rst:303 +msgid "" +"The only difference with the previous example is the change B(D,E) --> " +"B(E,D); however even such a little modification completely changes the " +"ordering of the hierarchy:" +msgstr "" + +#: howto/mro.rst:307 +msgid "" +" 6\n" +" ---\n" +"Level 3 | O |\n" +" / --- \\\n" +" / | \\\n" +" / | \\\n" +" / | \\\n" +" --- --- ---\n" +"Level 2 2 | E | 4 | D | | F | 5\n" +" --- --- ---\n" +" \\ / \\ /\n" +" \\ / \\ /\n" +" \\ / \\ /\n" +" --- ---\n" +"Level 1 1 | B | | C | 3\n" +" --- ---\n" +" \\ /\n" +" \\ /\n" +" ---\n" +"Level 0 0 | A |\n" +" ---" +msgstr "" + +#: howto/mro.rst:332 +msgid "" +"Notice that the class E, which is in the second level of the hierarchy, " +"precedes the class C, which is in the first level of the hierarchy, i.e. E " +"is more specialized than C, even if it is in a higher level." +msgstr "" + +#: howto/mro.rst:336 +msgid "" +"A lazy programmer can obtain the MRO directly from Python 2.2, since in this " +"case it coincides with the Python 2.3 linearization. It is enough to invoke " +"the :meth:`~type.mro` method of class A:" +msgstr "" + +#: howto/mro.rst:345 +msgid "" +"Finally, let me consider the example discussed in the first section, " +"involving a serious order disagreement. In this case, it is straightforward " +"to compute the linearizations of O, X, Y, A and B:" +msgstr "" + +#: howto/mro.rst:349 +msgid "" +"L[O] = 0\n" +"L[X] = X O\n" +"L[Y] = Y O\n" +"L[A] = A X Y O\n" +"L[B] = B Y X O" +msgstr "" + +#: howto/mro.rst:357 +msgid "" +"However, it is impossible to compute the linearization for a class C that " +"inherits from A and B::" +msgstr "" + +#: howto/mro.rst:360 +msgid "" +"L[C] = C + merge(AXYO, BYXO, AB)\n" +" = C + A + merge(XYO, BYXO, B)\n" +" = C + A + B + merge(XYO, YXO)" +msgstr "" + +#: howto/mro.rst:364 +msgid "" +"At this point we cannot merge the lists XYO and YXO, since X is in the tail " +"of YXO whereas Y is in the tail of XYO: therefore there are no good heads " +"and the C3 algorithm stops. Python 2.3 raises an error and refuses to " +"create the class C." +msgstr "" + +#: howto/mro.rst:370 +msgid "Bad Method Resolution Orders" +msgstr "" + +#: howto/mro.rst:372 +msgid "" +"A MRO is *bad* when it breaks such fundamental properties as local " +"precedence ordering and monotonicity. In this section, I will show that " +"both the MRO for classic classes and the MRO for new style classes in Python " +"2.2 are bad." +msgstr "" + +#: howto/mro.rst:377 +msgid "" +"It is easier to start with the local precedence ordering. Consider the " +"following example:" +msgstr "" + +#: howto/mro.rst:384 +msgid "with inheritance diagram" +msgstr "" + +#: howto/mro.rst:386 +msgid "" +" O\n" +" |\n" +"(buy spam) F\n" +" | \\\n" +" | E (buy eggs)\n" +" | /\n" +" G\n" +"\n" +" (buy eggs or spam ?)" +msgstr "" + +#: howto/mro.rst:399 +msgid "" +"We see that class G inherits from F and E, with F *before* E: therefore we " +"would expect the attribute *G.remember2buy* to be inherited by " +"*F.remember2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives" +msgstr "" + +#: howto/mro.rst:407 +msgid "" +"This is a breaking of local precedence ordering since the order in the local " +"precedence list, i.e. the list of the parents of G, is not preserved in the " +"Python 2.2 linearization of G::" +msgstr "" + +#: howto/mro.rst:411 +msgid "L[G,P22]= G E F object # F *follows* E" +msgstr "" + +#: howto/mro.rst:413 +msgid "" +"One could argue that the reason why F follows E in the Python 2.2 " +"linearization is that F is less specialized than E, since F is the " +"superclass of E; nevertheless the breaking of local precedence ordering is " +"quite non-intuitive and error prone. This is particularly true since it is " +"a different from old style classes:" +msgstr "" + +#: howto/mro.rst:425 +msgid "" +"In this case the MRO is GFEF and the local precedence ordering is preserved." +msgstr "" + +#: howto/mro.rst:428 +msgid "" +"As a general rule, hierarchies such as the previous one should be avoided, " +"since it is unclear if F should override E or vice-versa. Python 2.3 solves " +"the ambiguity by raising an exception in the creation of class G, " +"effectively stopping the programmer from generating ambiguous hierarchies. " +"The reason for that is that the C3 algorithm fails when the merge::" +msgstr "" + +#: howto/mro.rst:435 +msgid "merge(FO,EFO,FE)" +msgstr "" + +#: howto/mro.rst:437 +msgid "" +"cannot be computed, because F is in the tail of EFO and E is in the tail of " +"FE." +msgstr "" + +#: howto/mro.rst:440 +msgid "" +"The real solution is to design a non-ambiguous hierarchy, i.e. to derive G " +"from E and F (the more specific first) and not from F and E; in this case " +"the MRO is GEF without any doubt." +msgstr "" + +#: howto/mro.rst:444 +msgid "" +" O\n" +" |\n" +" F (spam)\n" +" / |\n" +"(eggs) E |\n" +" \\ |\n" +" G\n" +" (eggs, no doubt)" +msgstr "" + +#: howto/mro.rst:456 +msgid "" +"Python 2.3 forces the programmer to write good hierarchies (or, at least, " +"less error-prone ones)." +msgstr "" + +#: howto/mro.rst:459 +msgid "" +"On a related note, let me point out that the Python 2.3 algorithm is smart " +"enough to recognize obvious mistakes, as the duplication of classes in the " +"list of parents:" +msgstr "" + +#: howto/mro.rst:469 +msgid "" +"Python 2.2 (both for classic classes and new style classes) in this " +"situation, would not raise any exception." +msgstr "" + +#: howto/mro.rst:472 +msgid "" +"Finally, I would like to point out two lessons we have learned from this " +"example:" +msgstr "" + +#: howto/mro.rst:475 +msgid "" +"despite the name, the MRO determines the resolution order of attributes, not " +"only of methods;" +msgstr "" + +#: howto/mro.rst:478 +msgid "" +"the default food for Pythonistas is spam ! (but you already knew that ;-)" +msgstr "" + +#: howto/mro.rst:481 +msgid "" +"Having discussed the issue of local precedence ordering, let me now consider " +"the issue of monotonicity. My goal is to show that neither the MRO for " +"classic classes nor that for Python 2.2 new style classes is monotonic." +msgstr "" + +#: howto/mro.rst:486 +msgid "" +"To prove that the MRO for classic classes is non-monotonic is rather " +"trivial, it is enough to look at the diamond diagram:" +msgstr "" + +#: howto/mro.rst:489 +msgid "" +" C\n" +" / \\\n" +" / \\\n" +"A B\n" +" \\ /\n" +" \\ /\n" +" D" +msgstr "" + +#: howto/mro.rst:500 +msgid "One easily discerns the inconsistency::" +msgstr "" + +#: howto/mro.rst:502 +msgid "" +"L[B,P21] = B C # B precedes C : B's methods win\n" +"L[D,P21] = D A C B C # B follows C : C's methods win!" +msgstr "" + +#: howto/mro.rst:505 +msgid "" +"On the other hand, there are no problems with the Python 2.2 and 2.3 MROs, " +"they give both::" +msgstr "" + +#: howto/mro.rst:508 +msgid "L[D] = D A B C" +msgstr "" + +#: howto/mro.rst:510 +msgid "" +"Guido points out in his essay [#]_ that the classic MRO is not so bad in " +"practice, since one can typically avoids diamonds for classic classes. But " +"all new style classes inherit from ``object``, therefore diamonds are " +"unavoidable and inconsistencies shows up in every multiple inheritance graph." +msgstr "" + +#: howto/mro.rst:516 +msgid "" +"The MRO of Python 2.2 makes breaking monotonicity difficult, but not " +"impossible. The following example, originally provided by Samuele Pedroni, " +"shows that the MRO of Python 2.2 is non-monotonic:" +msgstr "" + +#: howto/mro.rst:530 +msgid "" +"Here are the linearizations according to the C3 MRO (the reader should " +"verify these linearizations as an exercise and draw the inheritance " +"diagram ;-) ::" +msgstr "" + +#: howto/mro.rst:534 +msgid "" +"L[A] = A O\n" +"L[B] = B O\n" +"L[C] = C O\n" +"L[D] = D O\n" +"L[E] = E O\n" +"L[K1]= K1 A B C O\n" +"L[K2]= K2 D B E O\n" +"L[K3]= K3 D A O\n" +"L[Z] = Z K1 K2 K3 D A B C E O" +msgstr "" + +#: howto/mro.rst:544 +msgid "" +"Python 2.2 gives exactly the same linearizations for A, B, C, D, E, K1, K2 " +"and K3, but a different linearization for Z::" +msgstr "" + +#: howto/mro.rst:547 +msgid "L[Z,P22] = Z K1 K3 A K2 D B C E O" +msgstr "" + +#: howto/mro.rst:549 +msgid "" +"It is clear that this linearization is *wrong*, since A comes before D " +"whereas in the linearization of K3 A comes *after* D. In other words, in K3 " +"methods derived by D override methods derived by A, but in Z, which still is " +"a subclass of K3, methods derived by A override methods derived by D! This " +"is a violation of monotonicity. Moreover, the Python 2.2 linearization of Z " +"is also inconsistent with local precedence ordering, since the local " +"precedence list of the class Z is [K1, K2, K3] (K2 precedes K3), whereas in " +"the linearization of Z K2 *follows* K3. These problems explain why the 2.2 " +"rule has been dismissed in favor of the C3 rule." +msgstr "" + +#: howto/mro.rst:561 +msgid "The end" +msgstr "" + +#: howto/mro.rst:563 +msgid "" +"This section is for the impatient reader, who skipped all the previous " +"sections and jumped immediately to the end. This section is for the lazy " +"programmer too, who didn't want to exercise her/his brain. Finally, it is " +"for the programmer with some hubris, otherwise s/he would not be reading a " +"paper on the C3 method resolution order in multiple inheritance " +"hierarchies ;-) These three virtues taken all together (and *not* " +"separately) deserve a prize: the prize is a short Python 2.2 script that " +"allows you to compute the 2.3 MRO without risk to your brain. Simply change " +"the last line to play with the various examples I have discussed in this " +"paper.::" +msgstr "" + +#: howto/mro.rst:574 +msgid "" +"#\n" +"\n" +"\"\"\"C3 algorithm by Samuele Pedroni (with readability enhanced by me)." +"\"\"\"\n" +"\n" +"class __metaclass__(type):\n" +" \"All classes are metamagically modified to be nicely printed\"\n" +" __repr__ = lambda cls: cls.__name__\n" +"\n" +"class ex_2:\n" +" \"Serious order disagreement\" #From Guido\n" +" class O: pass\n" +" class X(O): pass\n" +" class Y(O): pass\n" +" class A(X,Y): pass\n" +" class B(Y,X): pass\n" +" try:\n" +" class Z(A,B): pass #creates Z(A,B) in Python 2.2\n" +" except TypeError:\n" +" pass # Z(A,B) cannot be created in Python 2.3\n" +"\n" +"class ex_5:\n" +" \"My first example\"\n" +" class O: pass\n" +" class F(O): pass\n" +" class E(O): pass\n" +" class D(O): pass\n" +" class C(D,F): pass\n" +" class B(D,E): pass\n" +" class A(B,C): pass\n" +"\n" +"class ex_6:\n" +" \"My second example\"\n" +" class O: pass\n" +" class F(O): pass\n" +" class E(O): pass\n" +" class D(O): pass\n" +" class C(D,F): pass\n" +" class B(E,D): pass\n" +" class A(B,C): pass\n" +"\n" +"class ex_9:\n" +" \"Difference between Python 2.2 MRO and C3\" #From Samuele\n" +" class O: pass\n" +" class A(O): pass\n" +" class B(O): pass\n" +" class C(O): pass\n" +" class D(O): pass\n" +" class E(O): pass\n" +" class K1(A,B,C): pass\n" +" class K2(D,B,E): pass\n" +" class K3(D,A): pass\n" +" class Z(K1,K2,K3): pass\n" +"\n" +"def merge(seqs):\n" +" print '\\n\\nCPL[%s]=%s' % (seqs[0][0],seqs),\n" +" res = []; i=0\n" +" while 1:\n" +" nonemptyseqs=[seq for seq in seqs if seq]\n" +" if not nonemptyseqs: return res\n" +" i+=1; print '\\n',i,'round: candidates...',\n" +" for seq in nonemptyseqs: # find merge candidates among seq heads\n" +" cand = seq[0]; print ' ',cand,\n" +" nothead=[s for s in nonemptyseqs if cand in s[1:]]\n" +" if nothead: cand=None #reject candidate\n" +" else: break\n" +" if not cand: raise \"Inconsistent hierarchy\"\n" +" res.append(cand)\n" +" for seq in nonemptyseqs: # remove cand\n" +" if seq[0] == cand: del seq[0]\n" +"\n" +"def mro(C):\n" +" \"Compute the class precedence list (mro) according to C3\"\n" +" return merge([[C]]+map(mro,C.__bases__)+[list(C.__bases__)])\n" +"\n" +"def print_mro(C):\n" +" print '\\nMRO[%s]=%s' % (C,mro(C))\n" +" print '\\nP22 MRO[%s]=%s' % (C,C.mro())\n" +"\n" +"print_mro(ex_9.Z)\n" +"\n" +"#" +msgstr "" + +#: howto/mro.rst:656 +msgid "That's all folks," +msgstr "" + +#: howto/mro.rst:658 +msgid "enjoy !" +msgstr "" + +#: howto/mro.rst:662 +msgid "Resources" +msgstr "" + +#: howto/mro.rst:664 +msgid "" +"The thread on python-dev started by Samuele Pedroni: https://mail.python.org/" +"pipermail/python-dev/2002-October/029035.html" +msgstr "" + +#: howto/mro.rst:667 +msgid "" +"The paper *A Monotonic Superclass Linearization for Dylan*: https://doi.org/" +"10.1145/236337.236343" +msgstr "" + +#: howto/mro.rst:670 +msgid "" +"Guido van Rossum's essay, *Unifying types and classes in Python 2.2*: " +"https://web.archive.org/web/20140210194412/http://www.python.org/download/" +"releases/2.2.2/descrintro" +msgstr "" diff --git a/howto/perf_profiling.po b/howto/perf_profiling.po index 278d4227..cd732ceb 100644 --- a/howto/perf_profiling.po +++ b/howto/perf_profiling.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -67,14 +68,92 @@ msgstr "" msgid "For example, consider the following script:" msgstr "" +#: howto/perf_profiling.rst:38 +msgid "" +"def foo(n):\n" +" result = 0\n" +" for _ in range(n):\n" +" result += 1\n" +" return result\n" +"\n" +"def bar(n):\n" +" foo(n)\n" +"\n" +"def baz(n):\n" +" bar(n)\n" +"\n" +"if __name__ == \"__main__\":\n" +" baz(1000000)" +msgstr "" + #: howto/perf_profiling.rst:55 msgid "We can run ``perf`` to sample CPU stack traces at 9999 hertz::" msgstr "" +#: howto/perf_profiling.rst:57 +msgid "$ perf record -F 9999 -g -o perf.data python my_script.py" +msgstr "" + #: howto/perf_profiling.rst:59 msgid "Then we can use ``perf report`` to analyze the data:" msgstr "" +#: howto/perf_profiling.rst:61 +msgid "" +"$ perf report --stdio -n -g\n" +"\n" +"# Children Self Samples Command Shared Object Symbol\n" +"# ........ ........ ............ .......... .................. ..........................................\n" +"#\n" +" 91.08% 0.00% 0 python.exe python.exe [.] " +"_start\n" +" |\n" +" ---_start\n" +" |\n" +" --90.71%--__libc_start_main\n" +" Py_BytesMain\n" +" |\n" +" |--56.88%--pymain_run_python.constprop.0\n" +" | |\n" +" | |--56.13%--_PyRun_AnyFileObject\n" +" | | _PyRun_SimpleFileObject\n" +" | | |\n" +" | | |--55.02%--run_mod\n" +" | | | |\n" +" | | | --54.65%--" +"PyEval_EvalCode\n" +" | | | " +"_PyEval_EvalFrameDefault\n" +" | | | " +"PyObject_Vectorcall\n" +" | | | " +"_PyEval_Vector\n" +" | | | " +"_PyEval_EvalFrameDefault\n" +" | | | " +"PyObject_Vectorcall\n" +" | | | " +"_PyEval_Vector\n" +" | | | " +"_PyEval_EvalFrameDefault\n" +" | | | " +"PyObject_Vectorcall\n" +" | | | " +"_PyEval_Vector\n" +" | | | |\n" +" | | | " +"|--51.67%--_PyEval_EvalFrameDefault\n" +" | | | " +"| |\n" +" | | | " +"| |--11.52%--_PyLong_Add\n" +" | | | " +"| | |\n" +" | | | " +"| | |--2.97%--_PyObject_Malloc\n" +"..." +msgstr "" + #: howto/perf_profiling.rst:100 msgid "" "As you can see, the Python functions are not shown in the output, only " @@ -89,6 +168,69 @@ msgid "" "Instead, if we run the same experiment with ``perf`` support enabled we get:" msgstr "" +#: howto/perf_profiling.rst:107 +msgid "" +"$ perf report --stdio -n -g\n" +"\n" +"# Children Self Samples Command Shared Object Symbol\n" +"# ........ ........ ............ .......... .................. .....................................................................\n" +"#\n" +" 90.58% 0.36% 1 python.exe python.exe [.] " +"_start\n" +" |\n" +" ---_start\n" +" |\n" +" --89.86%--__libc_start_main\n" +" Py_BytesMain\n" +" |\n" +" |--55.43%--pymain_run_python.constprop.0\n" +" | |\n" +" | |--54.71%--_PyRun_AnyFileObject\n" +" | | _PyRun_SimpleFileObject\n" +" | | |\n" +" | | |--53.62%--run_mod\n" +" | | | |\n" +" | | | --53.26%--" +"PyEval_EvalCode\n" +" | | | py::" +":/src/script.py\n" +" | | | " +"_PyEval_EvalFrameDefault\n" +" | | | " +"PyObject_Vectorcall\n" +" | | | " +"_PyEval_Vector\n" +" | | | py::baz:/" +"src/script.py\n" +" | | | " +"_PyEval_EvalFrameDefault\n" +" | | | " +"PyObject_Vectorcall\n" +" | | | " +"_PyEval_Vector\n" +" | | | py::bar:/" +"src/script.py\n" +" | | | " +"_PyEval_EvalFrameDefault\n" +" | | | " +"PyObject_Vectorcall\n" +" | | | " +"_PyEval_Vector\n" +" | | | py::foo:/" +"src/script.py\n" +" | | | |\n" +" | | | " +"|--51.81%--_PyEval_EvalFrameDefault\n" +" | | | " +"| |\n" +" | | | " +"| |--13.77%--_PyLong_Add\n" +" | | | " +"| | |\n" +" | | | " +"| | |--3.26%--_PyObject_Malloc" +msgstr "" + #: howto/perf_profiling.rst:152 msgid "How to enable ``perf`` profiling support" msgstr "" @@ -97,8 +239,8 @@ msgstr "" msgid "" "``perf`` profiling support can be enabled either from the start using the " "environment variable :envvar:`PYTHONPERFSUPPORT` or the :option:`-X perf <-" -"X>` option, or dynamically using :func:`sys.activate_stack_trampoline` and :" -"func:`sys.deactivate_stack_trampoline`." +"X>` option, or dynamically using :func:`sys.activate_stack_trampoline` " +"and :func:`sys.deactivate_stack_trampoline`." msgstr "" #: howto/perf_profiling.rst:160 @@ -111,18 +253,47 @@ msgstr "" msgid "Example, using the environment variable::" msgstr "" +#: howto/perf_profiling.rst:165 +msgid "" +"$ PYTHONPERFSUPPORT=1 python script.py\n" +"$ perf report -g -i perf.data" +msgstr "" + #: howto/perf_profiling.rst:168 msgid "Example, using the :option:`!-X` option::" msgstr "" +#: howto/perf_profiling.rst:170 +msgid "" +"$ python -X perf script.py\n" +"$ perf report -g -i perf.data" +msgstr "" + #: howto/perf_profiling.rst:173 msgid "Example, using the :mod:`sys` APIs in file :file:`example.py`:" msgstr "" +#: howto/perf_profiling.rst:175 +msgid "" +"import sys\n" +"\n" +"sys.activate_stack_trampoline(\"perf\")\n" +"do_profiled_stuff()\n" +"sys.deactivate_stack_trampoline()\n" +"\n" +"non_profiled_stuff()" +msgstr "" + #: howto/perf_profiling.rst:185 msgid "...then::" msgstr "" +#: howto/perf_profiling.rst:187 +msgid "" +"$ python ./example.py\n" +"$ perf report -g -i perf.data" +msgstr "" + #: howto/perf_profiling.rst:192 msgid "How to obtain the best results" msgstr "" @@ -142,6 +313,10 @@ msgid "" "You can check if your system has been compiled with this flag by running::" msgstr "" +#: howto/perf_profiling.rst:203 +msgid "$ python -m sysconfig | grep 'no-omit-frame-pointer'" +msgstr "" + #: howto/perf_profiling.rst:205 msgid "" "If you don't see any output it means that your interpreter has not been " diff --git a/howto/pyporting.po b/howto/pyporting.po index 7e783111..4fc7aeed 100644 --- a/howto/pyporting.po +++ b/howto/pyporting.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-12-06 13:40+0200\n" "Last-Translator: Marios Giannopoulos \n" "Language-Team: PyGreece \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -56,10 +57,11 @@ msgstr "" "χρήσιμες οδηγίες." #: howto/pyporting.rst:21 +#, fuzzy msgid "" -"Since Python 3.13 the original porting guide was discontinued. You can find " -"the old guide in the `archive `_." +"Since Python 3.11 the original porting guide was discontinued. You can find " +"the old guide in the `archive `_." msgstr "" "Από την Python 3.13 και μετά, ο αρχικός οδηγός μεταφοράς διακόπηκε. Μπορείτε " "να βρείτε τον παλιό οδηγό στο `αρχείο \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -110,12 +111,12 @@ msgstr "" #: howto/regex.rst:70 msgid "" -"There are exceptions to this rule; some characters are special :dfn:" -"`metacharacters`, and don't match themselves. Instead, they signal that " -"some out-of-the-ordinary thing should be matched, or they affect other " -"portions of the RE by repeating them or changing their meaning. Much of " -"this document is devoted to discussing various metacharacters and what they " -"do." +"There are exceptions to this rule; some characters are " +"special :dfn:`metacharacters`, and don't match themselves. Instead, they " +"signal that some out-of-the-ordinary thing should be matched, or they affect " +"other portions of the RE by repeating them or changing their meaning. Much " +"of this document is devoted to discussing various metacharacters and what " +"they do." msgstr "" #: howto/regex.rst:76 @@ -124,6 +125,10 @@ msgid "" "discussed in the rest of this HOWTO." msgstr "" +#: howto/regex.rst:79 +msgid ". ^ $ * + ? { } [ ] \\ | ( )" +msgstr "" + #: howto/regex.rst:83 msgid "" "The first metacharacters we'll look at are ``[`` and ``]``. They're used for " @@ -146,12 +151,12 @@ msgstr "" #: howto/regex.rst:97 msgid "" -"You can match the characters not listed within the class by :dfn:" -"`complementing` the set. This is indicated by including a ``'^'`` as the " -"first character of the class. For example, ``[^5]`` will match any character " -"except ``'5'``. If the caret appears elsewhere in a character class, it " -"does not have special meaning. For example: ``[5^]`` will match either a " -"``'5'`` or a ``'^'``." +"You can match the characters not listed within the class " +"by :dfn:`complementing` the set. This is indicated by including a ``'^'`` " +"as the first character of the class. For example, ``[^5]`` will match any " +"character except ``'5'``. If the caret appears elsewhere in a character " +"class, it does not have special meaning. For example: ``[5^]`` will match " +"either a ``'5'`` or a ``'^'``." msgstr "" #: howto/regex.rst:103 @@ -176,10 +181,10 @@ msgid "" "Let's take an example: ``\\w`` matches any alphanumeric character. If the " "regex pattern is expressed in bytes, this is equivalent to the class ``[a-zA-" "Z0-9_]``. If the regex pattern is a string, ``\\w`` will match all the " -"characters marked as letters in the Unicode database provided by the :mod:" -"`unicodedata` module. You can use the more restricted definition of ``\\w`` " -"in a string pattern by supplying the :const:`re.ASCII` flag when compiling " -"the regular expression." +"characters marked as letters in the Unicode database provided by " +"the :mod:`unicodedata` module. You can use the more restricted definition " +"of ``\\w`` in a string pattern by supplying the :const:`re.ASCII` flag when " +"compiling the regular expression." msgstr "" #: howto/regex.rst:123 @@ -191,7 +196,7 @@ msgid "" "character that's in the appropriate category in the Unicode database." msgstr "" -#: howto/regex.rst:131 +#: howto/regex.rst:130 msgid "``\\d``" msgstr "" @@ -199,7 +204,7 @@ msgstr "" msgid "Matches any decimal digit; this is equivalent to the class ``[0-9]``." msgstr "" -#: howto/regex.rst:134 +#: howto/regex.rst:133 msgid "``\\D``" msgstr "" @@ -208,7 +213,7 @@ msgid "" "Matches any non-digit character; this is equivalent to the class ``[^0-9]``." msgstr "" -#: howto/regex.rst:138 +#: howto/regex.rst:136 msgid "``\\s``" msgstr "" @@ -218,7 +223,7 @@ msgid "" "``[ \\t\\n\\r\\f\\v]``." msgstr "" -#: howto/regex.rst:142 +#: howto/regex.rst:140 msgid "``\\S``" msgstr "" @@ -228,7 +233,7 @@ msgid "" "\\t\\n\\r\\f\\v]``." msgstr "" -#: howto/regex.rst:146 +#: howto/regex.rst:144 msgid "``\\w``" msgstr "" @@ -238,7 +243,7 @@ msgid "" "Z0-9_]``." msgstr "" -#: howto/regex.rst:150 +#: howto/regex.rst:148 msgid "``\\W``" msgstr "" @@ -258,9 +263,9 @@ msgstr "" #: howto/regex.rst:156 msgid "" "The final metacharacter in this section is ``.``. It matches anything " -"except a newline character, and there's an alternate mode (:const:`re." -"DOTALL`) where it will match even a newline. ``.`` is often used where you " -"want to match \"any character\"." +"except a newline character, and there's an alternate mode " +"(:const:`re.DOTALL`) where it will match even a newline. ``.`` is often " +"used where you want to match \"any character\"." msgstr "" #: howto/regex.rst:163 @@ -480,6 +485,14 @@ msgid "" "string substitutions. ::" msgstr "" +#: howto/regex.rst:274 +msgid "" +">>> import re\n" +">>> p = re.compile('ab*')\n" +">>> p\n" +"re.compile('ab*')" +msgstr "" + #: howto/regex.rst:279 msgid "" ":func:`re.compile` also accepts an optional *flags* argument, used to enable " @@ -487,6 +500,10 @@ msgid "" "settings later, but for now a single example will do::" msgstr "" +#: howto/regex.rst:283 +msgid ">>> p = re.compile('ab*', re.IGNORECASE)" +msgstr "" + #: howto/regex.rst:285 msgid "" "The RE is passed to :func:`re.compile` as a string. REs are handled as " @@ -494,8 +511,8 @@ msgid "" "and no special syntax was created for expressing them. (There are " "applications that don't need REs at all, so there's no need to bloat the " "language specification by including them.) Instead, the :mod:`re` module is " -"simply a C extension module included with Python, just like the :mod:" -"`socket` or :mod:`zlib` modules." +"simply a C extension module included with Python, just like " +"the :mod:`socket` or :mod:`zlib` modules." msgstr "" #: howto/regex.rst:292 @@ -582,10 +599,10 @@ msgstr "" #: howto/regex.rst:336 msgid "" "In addition, special escape sequences that are valid in regular expressions, " -"but not valid as Python string literals, now result in a :exc:" -"`DeprecationWarning` and will eventually become a :exc:`SyntaxError`, which " -"means the sequences will be invalid if raw string notation or escaping the " -"backslashes isn't used." +"but not valid as Python string literals, now result in " +"a :exc:`DeprecationWarning` and will eventually become a :exc:`SyntaxError`, " +"which means the sequences will be invalid if raw string notation or escaping " +"the backslashes isn't used." msgstr "" #: howto/regex.rst:344 @@ -666,8 +683,8 @@ msgstr "" #: howto/regex.rst:374 msgid "" -"Find all substrings where the RE matches, and returns them as an :term:" -"`iterator`." +"Find all substrings where the RE matches, and returns them as " +"an :term:`iterator`." msgstr "" #: howto/regex.rst:378 @@ -690,6 +707,14 @@ msgid "" "the Python interpreter, import the :mod:`re` module, and compile a RE::" msgstr "" +#: howto/regex.rst:389 +msgid "" +">>> import re\n" +">>> p = re.compile('[a-z]+')\n" +">>> p\n" +"re.compile('[a-z]+')" +msgstr "" + #: howto/regex.rst:394 msgid "" "Now, you can try matching various strings against the RE ``[a-z]+``. An " @@ -699,6 +724,13 @@ msgid "" "print the result of :meth:`!match` to make this clear. ::" msgstr "" +#: howto/regex.rst:400 +msgid "" +">>> p.match(\"\")\n" +">>> print(p.match(\"\"))\n" +"None" +msgstr "" + #: howto/regex.rst:404 msgid "" "Now, let's try it on a string that it should match, such as ``tempo``. In " @@ -706,6 +738,13 @@ msgid "" "objects>`, so you should store the result in a variable for later use. ::" msgstr "" +#: howto/regex.rst:408 +msgid "" +">>> m = p.match('tempo')\n" +">>> m\n" +"" +msgstr "" + #: howto/regex.rst:412 msgid "" "Now you can query the :ref:`match object ` for information " @@ -749,18 +788,40 @@ msgstr "" msgid "Trying these methods will soon clarify their meaning::" msgstr "" +#: howto/regex.rst:431 +msgid "" +">>> m.group()\n" +"'tempo'\n" +">>> m.start(), m.end()\n" +"(0, 5)\n" +">>> m.span()\n" +"(0, 5)" +msgstr "" + #: howto/regex.rst:438 msgid "" -":meth:`~re.Match.group` returns the substring that was matched by the RE. :" -"meth:`~re.Match.start` and :meth:`~re.Match.end` return the starting and " -"ending index of the match. :meth:`~re.Match.span` returns both start and end " -"indexes in a single tuple. Since the :meth:`~re.Pattern.match` method only " -"checks if the RE matches at the start of a string, :meth:`!start` will " +":meth:`~re.Match.group` returns the substring that was matched by the " +"RE. :meth:`~re.Match.start` and :meth:`~re.Match.end` return the starting " +"and ending index of the match. :meth:`~re.Match.span` returns both start and " +"end indexes in a single tuple. Since the :meth:`~re.Pattern.match` method " +"only checks if the RE matches at the start of a string, :meth:`!start` will " "always be zero. However, the :meth:`~re.Pattern.search` method of patterns " "scans through the string, so the match may not start at zero in that " "case. ::" msgstr "" +#: howto/regex.rst:446 +msgid "" +">>> print(p.match('::: message'))\n" +"None\n" +">>> m = p.search('::: message'); print(m)\n" +"\n" +">>> m.group()\n" +"'message'\n" +">>> m.span()\n" +"(4, 11)" +msgstr "" + #: howto/regex.rst:455 msgid "" "In actual programs, the most common style is to store the :ref:`match object " @@ -768,10 +829,27 @@ msgid "" "usually looks like::" msgstr "" +#: howto/regex.rst:459 +msgid "" +"p = re.compile( ... )\n" +"m = p.match( 'string goes here' )\n" +"if m:\n" +" print('Match found: ', m.group())\n" +"else:\n" +" print('No match')" +msgstr "" + #: howto/regex.rst:466 msgid "" -"Two pattern methods return all of the matches for a pattern. :meth:`~re." -"Pattern.findall` returns a list of matching strings::" +"Two pattern methods return all of the matches for a " +"pattern. :meth:`~re.Pattern.findall` returns a list of matching strings::" +msgstr "" + +#: howto/regex.rst:469 +msgid "" +">>> p = re.compile(r'\\d+')\n" +">>> p.findall('12 drummers drumming, 11 pipers piping, 10 lords a-leaping')\n" +"['12', '11', '10']" msgstr "" #: howto/regex.rst:473 @@ -779,16 +857,29 @@ msgid "" "The ``r`` prefix, making the literal a raw string literal, is needed in this " "example because escape sequences in a normal \"cooked\" string literal that " "are not recognized by Python, as opposed to regular expressions, now result " -"in a :exc:`DeprecationWarning` and will eventually become a :exc:" -"`SyntaxError`. See :ref:`the-backslash-plague`." +"in a :exc:`DeprecationWarning` and will eventually become " +"a :exc:`SyntaxError`. See :ref:`the-backslash-plague`." msgstr "" #: howto/regex.rst:479 msgid "" ":meth:`~re.Pattern.findall` has to create the entire list before it can be " "returned as the result. The :meth:`~re.Pattern.finditer` method returns a " -"sequence of :ref:`match object ` instances as an :term:" -"`iterator`::" +"sequence of :ref:`match object ` instances as " +"an :term:`iterator`::" +msgstr "" + +#: howto/regex.rst:483 +msgid "" +">>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...')\n" +">>> iterator \n" +"\n" +">>> for match in iterator:\n" +"... print(match.span())\n" +"...\n" +"(0, 2)\n" +"(22, 24)\n" +"(29, 31)" msgstr "" #: howto/regex.rst:495 @@ -797,12 +888,20 @@ msgstr "" #: howto/regex.rst:497 msgid "" -"You don't have to create a pattern object and call its methods; the :mod:" -"`re` module also provides top-level functions called :func:`~re.match`, :" -"func:`~re.search`, :func:`~re.findall`, :func:`~re.sub`, and so forth. " -"These functions take the same arguments as the corresponding pattern method " -"with the RE string added as the first argument, and still return either " -"``None`` or a :ref:`match object ` instance. ::" +"You don't have to create a pattern object and call its methods; " +"the :mod:`re` module also provides top-level functions " +"called :func:`~re.match`, :func:`~re.search`, :func:`~re.findall`, :func:`~re.sub`, " +"and so forth. These functions take the same arguments as the corresponding " +"pattern method with the RE string added as the first argument, and still " +"return either ``None`` or a :ref:`match object ` instance. ::" +msgstr "" + +#: howto/regex.rst:504 +msgid "" +">>> print(re.match(r'From\\s+', 'Fromage amk'))\n" +"None\n" +">>> re.match(r'From\\s+', 'From amk Thu May 14 19:12:10 1998') \n" +"" msgstr "" #: howto/regex.rst:509 @@ -829,12 +928,12 @@ msgstr "" msgid "" "Compilation flags let you modify some aspects of how regular expressions " "work. Flags are available in the :mod:`re` module under two names, a long " -"name such as :const:`IGNORECASE` and a short, one-letter form such as :const:" -"`I`. (If you're familiar with Perl's pattern modifiers, the one-letter " -"forms use the same letters; the short form of :const:`re.VERBOSE` is :const:" -"`re.X`, for example.) Multiple flags can be specified by bitwise OR-ing " -"them; ``re.I | re.M`` sets both the :const:`I` and :const:`M` flags, for " -"example." +"name such as :const:`IGNORECASE` and a short, one-letter form such " +"as :const:`I`. (If you're familiar with Perl's pattern modifiers, the one-" +"letter forms use the same letters; the short form of :const:`re.VERBOSE` " +"is :const:`re.X`, for example.) Multiple flags can be specified by bitwise " +"OR-ing them; ``re.I | re.M`` sets both the :const:`I` and :const:`M` flags, " +"for example." msgstr "" #: howto/regex.rst:534 @@ -909,13 +1008,13 @@ msgid "" "letters, too. Full Unicode matching also works unless the :const:`ASCII` " "flag is used to disable non-ASCII matches. When the Unicode patterns ``[a-" "z]`` or ``[A-Z]`` are used in combination with the :const:`IGNORECASE` flag, " -"they will match the 52 ASCII letters and 4 additional non-ASCII letters: " -"'İ' (U+0130, Latin capital letter I with dot above), 'ı' (U+0131, Latin " -"small letter dotless i), 'ſ' (U+017F, Latin small letter long s) and " -"'K' (U+212A, Kelvin sign). ``Spam`` will match ``'Spam'``, ``'spam'``, " -"``'spAM'``, or ``'ſpam'`` (the latter is matched only in Unicode mode). This " -"lowercasing doesn't take the current locale into account; it will if you " -"also set the :const:`LOCALE` flag." +"they will match the 52 ASCII letters and 4 additional non-ASCII letters: 'İ' " +"(U+0130, Latin capital letter I with dot above), 'ı' (U+0131, Latin small " +"letter dotless i), 'ſ' (U+017F, Latin small letter long s) and 'K' (U+212A, " +"Kelvin sign). ``Spam`` will match ``'Spam'``, ``'spam'``, ``'spAM'``, or " +"``'ſpam'`` (the latter is matched only in Unicode mode). This lowercasing " +"doesn't take the current locale into account; it will if you also set " +"the :const:`LOCALE` flag." msgstr "" #: howto/regex.rst:581 @@ -991,10 +1090,30 @@ msgid "" "it is to read? ::" msgstr "" +#: howto/regex.rst:651 +msgid "" +"charref = re.compile(r\"\"\"\n" +" &[#] # Start of a numeric entity reference\n" +" (\n" +" 0[0-7]+ # Octal form\n" +" | [0-9]+ # Decimal form\n" +" | x[0-9a-fA-F]+ # Hexadecimal form\n" +" )\n" +" ; # Trailing semicolon\n" +"\"\"\", re.VERBOSE)" +msgstr "" + #: howto/regex.rst:661 msgid "Without the verbose setting, the RE would look like this::" msgstr "" +#: howto/regex.rst:663 +msgid "" +"charref = re.compile(\"&#(0[0-7]+\"\n" +" \"|[0-9]+\"\n" +" \"|x[0-9a-fA-F]+);\")" +msgstr "" + #: howto/regex.rst:667 msgid "" "In the above example, Python's automatic concatenation of string literals " @@ -1035,7 +1154,7 @@ msgid "" "of times." msgstr "" -#: howto/regex.rst:704 +#: howto/regex.rst:696 msgid "``|``" msgstr "" @@ -1055,16 +1174,16 @@ msgid "" "class, as in ``[|]``." msgstr "" -#: howto/regex.rst:719 +#: howto/regex.rst:706 msgid "``^``" msgstr "" #: howto/regex.rst:707 msgid "" "Matches at the beginning of lines. Unless the :const:`MULTILINE` flag has " -"been set, this will only match at the beginning of the string. In :const:" -"`MULTILINE` mode, this also matches immediately after each newline within " -"the string." +"been set, this will only match at the beginning of the string. " +"In :const:`MULTILINE` mode, this also matches immediately after each newline " +"within the string." msgstr "" #: howto/regex.rst:711 @@ -1073,11 +1192,19 @@ msgid "" "a line, the RE to use is ``^From``. ::" msgstr "" +#: howto/regex.rst:714 +msgid "" +">>> print(re.search('^From', 'From Here to Eternity')) \n" +"\n" +">>> print(re.search('^From', 'Reciting From Memory'))\n" +"None" +msgstr "" + #: howto/regex.rst:719 msgid "To match a literal ``'^'``, use ``\\^``." msgstr "" -#: howto/regex.rst:733 +#: howto/regex.rst:721 msgid "``$``" msgstr "" @@ -1087,13 +1214,23 @@ msgid "" "string, or any location followed by a newline character. ::" msgstr "" +#: howto/regex.rst:725 +msgid "" +">>> print(re.search('}$', '{block}')) \n" +"\n" +">>> print(re.search('}$', '{block} '))\n" +"None\n" +">>> print(re.search('}$', '{block}\\n')) \n" +"" +msgstr "" + #: howto/regex.rst:732 msgid "" "To match a literal ``'$'``, use ``\\$`` or enclose it inside a character " "class, as in ``[$]``." msgstr "" -#: howto/regex.rst:739 +#: howto/regex.rst:735 msgid "``\\A``" msgstr "" @@ -1106,7 +1243,7 @@ msgid "" "newline character." msgstr "" -#: howto/regex.rst:742 +#: howto/regex.rst:741 msgid "``\\Z``" msgstr "" @@ -1114,7 +1251,7 @@ msgstr "" msgid "Matches only at the end of the string." msgstr "" -#: howto/regex.rst:777 +#: howto/regex.rst:744 msgid "``\\b``" msgstr "" @@ -1132,6 +1269,17 @@ msgid "" "won't match when it's contained inside another word. ::" msgstr "" +#: howto/regex.rst:753 +msgid "" +">>> p = re.compile(r'\\bclass\\b')\n" +">>> print(p.search('no class at all'))\n" +"\n" +">>> print(p.search('the declassified algorithm'))\n" +"None\n" +">>> print(p.search('one subclass is'))\n" +"None" +msgstr "" + #: howto/regex.rst:761 msgid "" "There are two subtleties you should remember when using this special " @@ -1143,6 +1291,15 @@ msgid "" "previous RE, but omits the ``'r'`` in front of the RE string. ::" msgstr "" +#: howto/regex.rst:769 +msgid "" +">>> p = re.compile('\\bclass\\b')\n" +">>> print(p.search('no class at all'))\n" +"None\n" +">>> print(p.search('\\b' + 'class' + '\\b'))\n" +"" +msgstr "" + #: howto/regex.rst:775 msgid "" "Second, inside a character class, where there's no use for this assertion, " @@ -1150,7 +1307,7 @@ msgid "" "string literals." msgstr "" -#: howto/regex.rst:782 +#: howto/regex.rst:779 msgid "``\\B``" msgstr "" @@ -1173,6 +1330,14 @@ msgid "" "name and a value, separated by a ``':'``, like this:" msgstr "" +#: howto/regex.rst:793 +msgid "" +"From: author@example.com\n" +"User-Agent: Thunderbird 1.5.0.9 (X11/20061227)\n" +"MIME-Version: 1.0\n" +"To: editor@example.com" +msgstr "" + #: howto/regex.rst:800 msgid "" "This can be handled by writing a regular expression which matches an entire " @@ -1190,16 +1355,33 @@ msgid "" "repetitions of ``ab``. ::" msgstr "" +#: howto/regex.rst:811 +msgid "" +">>> p = re.compile('(ab)*')\n" +">>> print(p.match('ababababab').span())\n" +"(0, 10)" +msgstr "" + #: howto/regex.rst:815 msgid "" "Groups indicated with ``'('``, ``')'`` also capture the starting and ending " "index of the text that they match; this can be retrieved by passing an " -"argument to :meth:`~re.Match.group`, :meth:`~re.Match.start`, :meth:`~re." -"Match.end`, and :meth:`~re.Match.span`. Groups are numbered starting with " -"0. Group 0 is always present; it's the whole RE, so :ref:`match object " -"` methods all have group 0 as their default argument. Later " -"we'll see how to express groups that don't capture the span of text that " -"they match. ::" +"argument " +"to :meth:`~re.Match.group`, :meth:`~re.Match.start`, :meth:`~re.Match.end`, " +"and :meth:`~re.Match.span`. Groups are numbered starting with 0. Group 0 " +"is always present; it's the whole RE, so :ref:`match object ` " +"methods all have group 0 as their default argument. Later we'll see how to " +"express groups that don't capture the span of text that they match. ::" +msgstr "" + +#: howto/regex.rst:824 +msgid "" +">>> p = re.compile('(a)b')\n" +">>> m = p.match('ab')\n" +">>> m.group()\n" +"'ab'\n" +">>> m.group(0)\n" +"'ab'" msgstr "" #: howto/regex.rst:831 @@ -1209,6 +1391,18 @@ msgid "" "characters, going from left to right. ::" msgstr "" +#: howto/regex.rst:835 +msgid "" +">>> p = re.compile('(a(b)c)d')\n" +">>> m = p.match('abcd')\n" +">>> m.group(0)\n" +"'abcd'\n" +">>> m.group(1)\n" +"'abc'\n" +">>> m.group(2)\n" +"'b'" +msgstr "" + #: howto/regex.rst:844 msgid "" ":meth:`~re.Match.group` can be passed multiple group numbers at a time, in " @@ -1216,12 +1410,24 @@ msgid "" "those groups. ::" msgstr "" +#: howto/regex.rst:847 +msgid "" +">>> m.group(2,1,2)\n" +"('b', 'abc', 'b')" +msgstr "" + #: howto/regex.rst:850 msgid "" "The :meth:`~re.Match.groups` method returns a tuple containing the strings " "for all the subgroups, from 1 up to however many there are. ::" msgstr "" +#: howto/regex.rst:853 +msgid "" +">>> m.groups()\n" +"('abc', 'b')" +msgstr "" + #: howto/regex.rst:856 msgid "" "Backreferences in a pattern allow you to specify that the contents of an " @@ -1237,6 +1443,13 @@ msgstr "" msgid "For example, the following RE detects doubled words in a string. ::" msgstr "" +#: howto/regex.rst:866 +msgid "" +">>> p = re.compile(r'\\b(\\w+)\\s+\\1\\b')\n" +">>> p.search('Paris in the the spring').group()\n" +"'the the'" +msgstr "" + #: howto/regex.rst:870 msgid "" "Backreferences like this aren't often useful for just searching through a " @@ -1301,6 +1514,16 @@ msgid "" "where you can replace the ``...`` with any other regular expression. ::" msgstr "" +#: howto/regex.rst:912 +msgid "" +">>> m = re.match(\"([abc])+\", \"abc\")\n" +">>> m.groups()\n" +"('c',)\n" +">>> m = re.match(\"(?:[abc])+\", \"abc\")\n" +">>> m.groups()\n" +"()" +msgstr "" + #: howto/regex.rst:919 msgid "" "Except for the fact that you can't retrieve the contents of what the group " @@ -1332,17 +1555,44 @@ msgid "" "ways::" msgstr "" +#: howto/regex.rst:939 +msgid "" +">>> p = re.compile(r'(?P\\b\\w+\\b)')\n" +">>> m = p.search( '(((( Lots of punctuation )))' )\n" +">>> m.group('word')\n" +"'Lots'\n" +">>> m.group(1)\n" +"'Lots'" +msgstr "" + #: howto/regex.rst:946 msgid "" -"Additionally, you can retrieve named groups as a dictionary with :meth:`~re." -"Match.groupdict`::" +"Additionally, you can retrieve named groups as a dictionary " +"with :meth:`~re.Match.groupdict`::" +msgstr "" + +#: howto/regex.rst:949 +msgid "" +">>> m = re.match(r'(?P\\w+) (?P\\w+)', 'Jane Doe')\n" +">>> m.groupdict()\n" +"{'first': 'Jane', 'last': 'Doe'}" msgstr "" #: howto/regex.rst:953 msgid "" "Named groups are handy because they let you use easily remembered names, " -"instead of having to remember numbers. Here's an example RE from the :mod:" -"`imaplib` module::" +"instead of having to remember numbers. Here's an example RE from " +"the :mod:`imaplib` module::" +msgstr "" + +#: howto/regex.rst:957 +msgid "" +"InternalDate = re.compile(r'INTERNALDATE \"'\n" +" r'(?P[ 123][0-9])-(?P[A-Z][a-z][a-z])-'\n" +" r'(?P[0-9][0-9][0-9][0-9])'\n" +" r' (?P[0-9][0-9]):(?P[0-9][0-9]):(?P[0-9][0-9])'\n" +" r' (?P[-+])(?P[0-9][0-9])(?P[0-9][0-9])'\n" +" r'\"')" msgstr "" #: howto/regex.rst:964 @@ -1358,8 +1608,15 @@ msgid "" "name instead of the number. This is another Python extension: ``(?P=name)`` " "indicates that the contents of the group called *name* should again be " "matched at the current point. The regular expression for finding doubled " -"words, ``\\b(\\w+)\\s+\\1\\b`` can also be written as ``\\b(?" -"P\\w+)\\s+(?P=word)\\b``::" +"words, ``\\b(\\w+)\\s+\\1\\b`` can also be written as ``\\b(?P\\w+)\\s+" +"(?P=word)\\b``::" +msgstr "" + +#: howto/regex.rst:974 +msgid "" +">>> p = re.compile(r'\\b(?P\\w+)\\s+(?P=word)\\b')\n" +">>> p.search('Paris in the the spring').group()\n" +"'the the'" msgstr "" #: howto/regex.rst:980 @@ -1373,7 +1630,7 @@ msgid "" "this:" msgstr "" -#: howto/regex.rst:990 +#: howto/regex.rst:985 msgid "``(?=...)``" msgstr "" @@ -1386,7 +1643,7 @@ msgid "" "is tried right where the assertion started." msgstr "" -#: howto/regex.rst:995 +#: howto/regex.rst:992 msgid "``(?!...)``" msgstr "" @@ -1445,10 +1702,10 @@ msgid "" "The expression gets messier when you try to patch up the first solution by " "requiring one of the following cases to match: the first character of the " "extension isn't ``b``; the second character isn't ``a``; or the third " -"character isn't ``t``. This accepts ``foo.bar`` and rejects ``autoexec." -"bat``, but it requires a three-letter extension and won't accept a filename " -"with a two-letter extension such as ``sendmail.cf``. We'll complicate the " -"pattern again in an effort to fix it." +"character isn't ``t``. This accepts ``foo.bar`` and rejects " +"``autoexec.bat``, but it requires a three-letter extension and won't accept " +"a filename with a two-letter extension such as ``sendmail.cf``. We'll " +"complicate the pattern again in an effort to fix it." msgstr "" #: howto/regex.rst:1030 @@ -1565,6 +1822,15 @@ msgid "" "characters. ::" msgstr "" +#: howto/regex.rst:1104 +msgid "" +">>> p = re.compile(r'\\W+')\n" +">>> p.split('This is a test, short and sweet, of split().')\n" +"['This', 'is', 'a', 'test', 'short', 'and', 'sweet', 'of', 'split', '']\n" +">>> p.split('This is a test, short and sweet, of split().', 3)\n" +"['This', 'is', 'a', 'test, short and sweet, of split().']" +msgstr "" + #: howto/regex.rst:1110 msgid "" "Sometimes you're not only interested in what the text between delimiters is, " @@ -1573,12 +1839,32 @@ msgid "" "Compare the following calls::" msgstr "" +#: howto/regex.rst:1115 +msgid "" +">>> p = re.compile(r'\\W+')\n" +">>> p2 = re.compile(r'(\\W+)')\n" +">>> p.split('This... is a test.')\n" +"['This', 'is', 'a', 'test', '']\n" +">>> p2.split('This... is a test.')\n" +"['This', '... ', 'is', ' ', 'a', ' ', 'test', '.', '']" +msgstr "" + #: howto/regex.rst:1122 msgid "" "The module-level function :func:`re.split` adds the RE to be used as the " "first argument, but is otherwise the same. ::" msgstr "" +#: howto/regex.rst:1125 +msgid "" +">>> re.split(r'[\\W]+', 'Words, words, words.')\n" +"['Words', 'words', 'words', '']\n" +">>> re.split(r'([\\W]+)', 'Words, words, words.')\n" +"['Words', ', ', 'words', ', ', 'words', '.', '']\n" +">>> re.split(r'[\\W]+', 'Words, words, words.', 1)\n" +"['Words', 'words, words.']" +msgstr "" + #: howto/regex.rst:1134 msgid "Search and Replace" msgstr "" @@ -1611,6 +1897,15 @@ msgid "" "replaces colour names with the word ``colour``::" msgstr "" +#: howto/regex.rst:1154 +msgid "" +">>> p = re.compile('(blue|white|red)')\n" +">>> p.sub('colour', 'blue socks and red shoes')\n" +"'colour socks and colour shoes'\n" +">>> p.sub('colour', 'blue socks and red shoes', count=1)\n" +"'colour socks and red shoes'" +msgstr "" + #: howto/regex.rst:1160 msgid "" "The :meth:`~re.Pattern.subn` method does the same work, but returns a 2-" @@ -1618,12 +1913,28 @@ msgid "" "were performed::" msgstr "" +#: howto/regex.rst:1163 +msgid "" +">>> p = re.compile('(blue|white|red)')\n" +">>> p.subn('colour', 'blue socks and red shoes')\n" +"('colour socks and colour shoes', 2)\n" +">>> p.subn('colour', 'no colours at all')\n" +"('no colours at all', 0)" +msgstr "" + #: howto/regex.rst:1169 msgid "" "Empty matches are replaced only when they're not adjacent to a previous " "empty match. ::" msgstr "" +#: howto/regex.rst:1172 +msgid "" +">>> p = re.compile('x*')\n" +">>> p.sub('-', 'abxd')\n" +"'-a-b--d-'" +msgstr "" + #: howto/regex.rst:1176 msgid "" "If *replacement* is a string, any backslash escapes in it are processed. " @@ -1641,6 +1952,13 @@ msgid "" "``{``, ``}``, and changes ``section`` to ``subsection``::" msgstr "" +#: howto/regex.rst:1186 +msgid "" +">>> p = re.compile('section{ ( [^}]* ) }', re.VERBOSE)\n" +">>> p.sub(r'subsection{\\1}','section{First} section{second}')\n" +"'subsection{First} subsection{second}'" +msgstr "" + #: howto/regex.rst:1190 msgid "" "There's also a syntax for referring to named groups as defined by the ``(?" @@ -1653,6 +1971,17 @@ msgid "" "but use all three variations of the replacement string. ::" msgstr "" +#: howto/regex.rst:1199 +msgid "" +">>> p = re.compile('section{ (?P [^}]* ) }', re.VERBOSE)\n" +">>> p.sub(r'subsection{\\1}','section{First}')\n" +"'subsection{First}'\n" +">>> p.sub(r'subsection{\\g<1>}','section{First}')\n" +"'subsection{First}'\n" +">>> p.sub(r'subsection{\\g}','section{First}')\n" +"'subsection{First}'" +msgstr "" + #: howto/regex.rst:1207 msgid "" "*replacement* can also be a function, which gives you even more control. If " @@ -1668,6 +1997,18 @@ msgid "" "hexadecimal::" msgstr "" +#: howto/regex.rst:1216 +msgid "" +">>> def hexrepl(match):\n" +"... \"Return the hex string for a decimal number\"\n" +"... value = int(match.group())\n" +"... return hex(value)\n" +"...\n" +">>> p = re.compile(r'\\d+')\n" +">>> p.sub(hexrepl, 'Call 65490 for printing, 49152 for user code.')\n" +"'Call 0xffd2 for printing, 0xc000 for user code.'" +msgstr "" + #: howto/regex.rst:1225 msgid "" "When using the module-level :func:`re.sub` function, the pattern is passed " @@ -1697,13 +2038,13 @@ msgstr "" #: howto/regex.rst:1243 msgid "" "Sometimes using the :mod:`re` module is a mistake. If you're matching a " -"fixed string, or a single character class, and you're not using any :mod:" -"`re` features such as the :const:`~re.IGNORECASE` flag, then the full power " -"of regular expressions may not be required. Strings have several methods for " -"performing operations with fixed strings and they're usually much faster, " -"because the implementation is a single small C loop that's been optimized " -"for the purpose, instead of the large, more generalized regular expression " -"engine." +"fixed string, or a single character class, and you're not using " +"any :mod:`re` features such as the :const:`~re.IGNORECASE` flag, then the " +"full power of regular expressions may not be required. Strings have several " +"methods for performing operations with fixed strings and they're usually " +"much faster, because the implementation is a single small C loop that's been " +"optimized for the purpose, instead of the large, more generalized regular " +"expression engine." msgstr "" #: howto/regex.rst:1251 @@ -1715,8 +2056,8 @@ msgid "" "turning ``swordfish`` into ``sdeedfish``, but the naive RE ``word`` would " "have done that, too. (To avoid performing the substitution on parts of " "words, the pattern would have to be ``\\bword\\b``, in order to require that " -"``word`` have a word boundary on either side. This takes the job beyond :" -"meth:`!replace`'s abilities.)" +"``word`` have a word boundary on either side. This takes the job " +"beyond :meth:`!replace`'s abilities.)" msgstr "" #: howto/regex.rst:1260 @@ -1748,22 +2089,39 @@ msgid "" "report it. ::" msgstr "" +#: howto/regex.rst:1279 +msgid "" +">>> print(re.match('super', 'superstition').span())\n" +"(0, 5)\n" +">>> print(re.match('super', 'insuperable'))\n" +"None" +msgstr "" + #: howto/regex.rst:1284 msgid "" "On the other hand, :func:`~re.search` will scan forward through the string, " "reporting the first match it finds. ::" msgstr "" +#: howto/regex.rst:1287 +msgid "" +">>> print(re.search('super', 'superstition').span())\n" +"(0, 5)\n" +">>> print(re.search('super', 'insuperable').span())\n" +"(2, 7)" +msgstr "" + #: howto/regex.rst:1292 msgid "" -"Sometimes you'll be tempted to keep using :func:`re.match`, and just add ``." -"*`` to the front of your RE. Resist this temptation and use :func:`re." -"search` instead. The regular expression compiler does some analysis of REs " -"in order to speed up the process of looking for a match. One such analysis " -"figures out what the first character of a match must be; for example, a " -"pattern starting with ``Crow`` must match starting with a ``'C'``. The " -"analysis lets the engine quickly scan through the string looking for the " -"starting character, only trying the full match if a ``'C'`` is found." +"Sometimes you'll be tempted to keep using :func:`re.match`, and just add " +"``.*`` to the front of your RE. Resist this temptation and " +"use :func:`re.search` instead. The regular expression compiler does some " +"analysis of REs in order to speed up the process of looking for a match. " +"One such analysis figures out what the first character of a match must be; " +"for example, a pattern starting with ``Crow`` must match starting with a " +"``'C'``. The analysis lets the engine quickly scan through the string " +"looking for the starting character, only trying the full match if a ``'C'`` " +"is found." msgstr "" #: howto/regex.rst:1301 @@ -1786,6 +2144,17 @@ msgid "" "HTML tag doesn't work because of the greedy nature of ``.*``. ::" msgstr "" +#: howto/regex.rst:1315 +msgid "" +">>> s = 'Title'\n" +">>> len(s)\n" +"32\n" +">>> print(re.match('<.*>', s).span())\n" +"(0, 32)\n" +">>> print(re.match('<.*>', s).group())\n" +"Title" +msgstr "" + #: howto/regex.rst:1323 msgid "" "The RE matches the ``'<'`` in ``''``, and the ``.*`` consumes the rest " @@ -1805,6 +2174,12 @@ msgid "" "retrying the ``'>'`` at every step. This produces just the right result::" msgstr "" +#: howto/regex.rst:1336 +msgid "" +">>> print(re.match('<.*?>', s).group())\n" +"" +msgstr "" + #: howto/regex.rst:1339 msgid "" "(Note that parsing HTML or XML with regular expressions is painful. Quick-" @@ -1845,10 +2220,26 @@ msgid "" "quoted strings, this enables REs to be formatted more neatly::" msgstr "" +#: howto/regex.rst:1366 +msgid "" +"pat = re.compile(r\"\"\"\n" +" \\s* # Skip leading whitespace\n" +" (?P
[^:]+) # Header name\n" +" \\s* : # Whitespace, and a colon\n" +" (?P.*?) # The header's value -- *? used to\n" +" # lose the following trailing whitespace\n" +" \\s*$ # Trailing whitespace to end-of-line\n" +"\"\"\", re.VERBOSE)" +msgstr "" + #: howto/regex.rst:1375 msgid "This is far more readable than::" msgstr "" +#: howto/regex.rst:1377 +msgid "pat = re.compile(r\"\\s*(?P
[^:]+)\\s*:(?P.*?)\\s*$\")" +msgstr "" + #: howto/regex.rst:1381 msgid "Feedback" msgstr "" diff --git a/howto/sockets.po b/howto/sockets.po index 953c106c..03af24bb 100644 --- a/howto/sockets.po +++ b/howto/sockets.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -99,6 +100,14 @@ msgid "" "page, your browser did something like the following::" msgstr "" +#: howto/sockets.rst:59 +msgid "" +"# create an INET, STREAMing socket\n" +"s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" +"# now connect to the web server on port 80 - the normal http port\n" +"s.connect((\"www.python.org\", 80))" +msgstr "" + #: howto/sockets.rst:64 msgid "" "When the ``connect`` completes, the socket ``s`` can be used to send in a " @@ -113,14 +122,24 @@ msgid "" "creates a \"server socket\"::" msgstr "" +#: howto/sockets.rst:73 +msgid "" +"# create an INET, STREAMing socket\n" +"serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" +"# bind the socket to a public host, and a well-known port\n" +"serversocket.bind((socket.gethostname(), 80))\n" +"# become a server socket\n" +"serversocket.listen(5)" +msgstr "" + #: howto/sockets.rst:80 msgid "" "A couple things to notice: we used ``socket.gethostname()`` so that the " -"socket would be visible to the outside world. If we had used ``s." -"bind(('localhost', 80))`` or ``s.bind(('127.0.0.1', 80))`` we would still " -"have a \"server\" socket, but one that was only visible within the same " -"machine. ``s.bind(('', 80))`` specifies that the socket is reachable by any " -"address the machine happens to have." +"socket would be visible to the outside world. If we had used " +"``s.bind(('localhost', 80))`` or ``s.bind(('127.0.0.1', 80))`` we would " +"still have a \"server\" socket, but one that was only visible within the " +"same machine. ``s.bind(('', 80))`` specifies that the socket is reachable " +"by any address the machine happens to have." msgstr "" #: howto/sockets.rst:87 @@ -144,6 +163,17 @@ msgid "" "mainloop of the web server::" msgstr "" +#: howto/sockets.rst:98 +msgid "" +"while True:\n" +" # accept connections from outside\n" +" (clientsocket, address) = serversocket.accept()\n" +" # now do something with the clientsocket\n" +" # in this case, we'll pretend this is a threaded server\n" +" ct = client_thread(clientsocket)\n" +" ct.run()" +msgstr "" + #: howto/sockets.rst:106 msgid "" "There's actually 3 general ways in which this loop could work - dispatching " @@ -252,6 +282,43 @@ msgid "" "fixed length message::" msgstr "" +#: howto/sockets.rst:183 +msgid "" +"class MySocket:\n" +" \"\"\"demonstration class only\n" +" - coded for clarity, not efficiency\n" +" \"\"\"\n" +"\n" +" def __init__(self, sock=None):\n" +" if sock is None:\n" +" self.sock = socket.socket(\n" +" socket.AF_INET, socket.SOCK_STREAM)\n" +" else:\n" +" self.sock = sock\n" +"\n" +" def connect(self, host, port):\n" +" self.sock.connect((host, port))\n" +"\n" +" def mysend(self, msg):\n" +" totalsent = 0\n" +" while totalsent < MSGLEN:\n" +" sent = self.sock.send(msg[totalsent:])\n" +" if sent == 0:\n" +" raise RuntimeError(\"socket connection broken\")\n" +" totalsent = totalsent + sent\n" +"\n" +" def myreceive(self):\n" +" chunks = []\n" +" bytes_recd = 0\n" +" while bytes_recd < MSGLEN:\n" +" chunk = self.sock.recv(min(MSGLEN - bytes_recd, 2048))\n" +" if chunk == b'':\n" +" raise RuntimeError(\"socket connection broken\")\n" +" chunks.append(chunk)\n" +" bytes_recd = bytes_recd + len(chunk)\n" +" return b''.join(chunks)" +msgstr "" + #: howto/sockets.rst:217 msgid "" "The sending code here is usable for almost any messaging scheme - in Python " @@ -433,6 +500,16 @@ msgid "" "Python, you'll have little trouble with it in C::" msgstr "" +#: howto/sockets.rst:345 +msgid "" +"ready_to_read, ready_to_write, in_error = \\\n" +" select.select(\n" +" potential_readers,\n" +" potential_writers,\n" +" potential_errs,\n" +" timeout)" +msgstr "" + #: howto/sockets.rst:352 msgid "" "You pass ``select`` three lists: the first contains all sockets that you " diff --git a/howto/sorting.po b/howto/sorting.po index 1c7ca146..d09d8437 100644 --- a/howto/sorting.po +++ b/howto/sorting.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -51,6 +52,12 @@ msgid "" "It returns a new sorted list:" msgstr "" +#: howto/sorting.rst:22 +msgid "" +">>> sorted([5, 2, 3, 1, 4])\n" +"[1, 2, 3, 4, 5]" +msgstr "" + #: howto/sorting.rst:27 msgid "" "You can also use the :meth:`list.sort` method. It modifies the list in-place " @@ -59,12 +66,26 @@ msgid "" "more efficient." msgstr "" +#: howto/sorting.rst:32 +msgid "" +">>> a = [5, 2, 3, 1, 4]\n" +">>> a.sort()\n" +">>> a\n" +"[1, 2, 3, 4, 5]" +msgstr "" + #: howto/sorting.rst:39 msgid "" "Another difference is that the :meth:`list.sort` method is only defined for " "lists. In contrast, the :func:`sorted` function accepts any iterable." msgstr "" +#: howto/sorting.rst:42 +msgid "" +">>> sorted({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'})\n" +"[1, 2, 3, 4, 5]" +msgstr "" + #: howto/sorting.rst:48 msgid "Key Functions" msgstr "" @@ -80,6 +101,12 @@ msgstr "" msgid "For example, here's a case-insensitive string comparison:" msgstr "" +#: howto/sorting.rst:56 +msgid "" +">>> sorted(\"This is a test string from Andrew\".split(), key=str.casefold)\n" +"['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']" +msgstr "" + #: howto/sorting.rst:61 msgid "" "The value of the *key* parameter should be a function (or other callable) " @@ -94,16 +121,47 @@ msgid "" "indices as keys. For example:" msgstr "" +#: howto/sorting.rst:69 +msgid "" +">>> student_tuples = [\n" +"... ('john', 'A', 15),\n" +"... ('jane', 'B', 12),\n" +"... ('dave', 'B', 10),\n" +"... ]\n" +">>> sorted(student_tuples, key=lambda student: student[2]) # sort by age\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" +msgstr "" + #: howto/sorting.rst:79 msgid "" "The same technique works for objects with named attributes. For example:" msgstr "" +#: howto/sorting.rst:81 +msgid "" +">>> class Student:\n" +"... def __init__(self, name, grade, age):\n" +"... self.name = name\n" +"... self.grade = grade\n" +"... self.age = age\n" +"... def __repr__(self):\n" +"... return repr((self.name, self.grade, self.age))\n" +"\n" +">>> student_objects = [\n" +"... Student('john', 'A', 15),\n" +"... Student('jane', 'B', 12),\n" +"... Student('dave', 'B', 10),\n" +"... ]\n" +">>> sorted(student_objects, key=lambda student: student.age) # sort by " +"age\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" +msgstr "" + #: howto/sorting.rst:99 msgid "" "Objects with named attributes can be made by a regular class as shown above, " -"or they can be instances of :class:`~dataclasses.dataclass` or a :term:" -"`named tuple`." +"or they can be instances of :class:`~dataclasses.dataclass` or " +"a :term:`named tuple`." msgstr "" #: howto/sorting.rst:104 @@ -114,20 +172,41 @@ msgstr "" msgid "" "The :term:`key function` patterns shown above are very common, so Python " "provides convenience functions to make accessor functions easier and faster. " -"The :mod:`operator` module has :func:`~operator.itemgetter`, :func:" -"`~operator.attrgetter`, and a :func:`~operator.methodcaller` function." +"The :mod:`operator` module " +"has :func:`~operator.itemgetter`, :func:`~operator.attrgetter`, and " +"a :func:`~operator.methodcaller` function." msgstr "" #: howto/sorting.rst:111 msgid "Using those functions, the above examples become simpler and faster:" msgstr "" +#: howto/sorting.rst:113 +msgid "" +">>> from operator import itemgetter, attrgetter\n" +"\n" +">>> sorted(student_tuples, key=itemgetter(2))\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]\n" +"\n" +">>> sorted(student_objects, key=attrgetter('age'))\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" +msgstr "" + #: howto/sorting.rst:123 msgid "" "The operator module functions allow multiple levels of sorting. For example, " "to sort by *grade* then by *age*:" msgstr "" +#: howto/sorting.rst:126 +msgid "" +">>> sorted(student_tuples, key=itemgetter(1,2))\n" +"[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]\n" +"\n" +">>> sorted(student_objects, key=attrgetter('grade', 'age'))\n" +"[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]" +msgstr "" + #: howto/sorting.rst:134 msgid "" "The :mod:`functools` module provides another helpful tool for making key-" @@ -136,6 +215,20 @@ msgid "" "it suitable for use as a key-function." msgstr "" +#: howto/sorting.rst:139 +msgid "" +">>> from functools import partial\n" +">>> from unicodedata import normalize\n" +"\n" +">>> names = 'Zoë Åbjørn Núñez Élana Zeke Abe Nubia Eloise'.split()\n" +"\n" +">>> sorted(names, key=partial(normalize, 'NFD'))\n" +"['Abe', 'Åbjørn', 'Eloise', 'Élana', 'Nubia', 'Núñez', 'Zeke', 'Zoë']\n" +"\n" +">>> sorted(names, key=partial(normalize, 'NFC'))\n" +"['Abe', 'Eloise', 'Nubia', 'Núñez', 'Zeke', 'Zoë', 'Åbjørn', 'Élana']" +msgstr "" + #: howto/sorting.rst:153 msgid "Ascending and Descending" msgstr "" @@ -147,6 +240,15 @@ msgid "" "the student data in reverse *age* order:" msgstr "" +#: howto/sorting.rst:159 +msgid "" +">>> sorted(student_tuples, key=itemgetter(2), reverse=True)\n" +"[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]\n" +"\n" +">>> sorted(student_objects, key=attrgetter('age'), reverse=True)\n" +"[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]" +msgstr "" + #: howto/sorting.rst:168 msgid "Sort Stability and Complex Sorts" msgstr "" @@ -158,6 +260,13 @@ msgid "" "the same key, their original order is preserved." msgstr "" +#: howto/sorting.rst:174 +msgid "" +">>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]\n" +">>> sorted(data, key=itemgetter(0))\n" +"[('blue', 1), ('blue', 2), ('red', 1), ('red', 2)]" +msgstr "" + #: howto/sorting.rst:180 msgid "" "Notice how the two records for *blue* retain their original order so that " @@ -171,12 +280,32 @@ msgid "" "ascending *age*, do the *age* sort first and then sort again using *grade*:" msgstr "" +#: howto/sorting.rst:187 +msgid "" +">>> s = sorted(student_objects, key=attrgetter('age')) # sort on " +"secondary key\n" +">>> sorted(s, key=attrgetter('grade'), reverse=True) # now sort on " +"primary key, descending\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" +msgstr "" + #: howto/sorting.rst:193 msgid "" "This can be abstracted out into a wrapper function that can take a list and " "tuples of field and order to sort them on multiple passes." msgstr "" +#: howto/sorting.rst:196 +msgid "" +">>> def multisort(xs, specs):\n" +"... for key, reverse in reversed(specs):\n" +"... xs.sort(key=attrgetter(key), reverse=reverse)\n" +"... return xs\n" +"\n" +">>> multisort(list(student_objects), (('grade', True), ('age', False)))\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" +msgstr "" + #: howto/sorting.rst:206 msgid "" "The `Timsort `_ algorithm used in " @@ -213,6 +342,15 @@ msgid "" "For example, to sort the student data by *grade* using the DSU approach:" msgstr "" +#: howto/sorting.rst:224 +msgid "" +">>> decorated = [(student.grade, i, student) for i, student in " +"enumerate(student_objects)]\n" +">>> decorated.sort()\n" +">>> [student for grade, i, student in decorated] # undecorate\n" +"[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]" +msgstr "" + #: howto/sorting.rst:231 msgid "" "This idiom works because tuples are compared lexicographically; the first " @@ -242,9 +380,9 @@ msgstr "" #: howto/sorting.rst:246 msgid "" -"Another name for this idiom is `Schwartzian transform `_\\, after Randal L. Schwartz, who " -"popularized it among Perl programmers." +"Another name for this idiom is `Schwartzian transform `_\\, after Randal L. Schwartz, " +"who popularized it among Perl programmers." msgstr "" #: howto/sorting.rst:250 @@ -282,9 +420,13 @@ msgstr "" #: howto/sorting.rst:269 msgid "" -"To accommodate those situations, Python provides :class:`functools." -"cmp_to_key` to wrap the comparison function to make it usable as a key " -"function::" +"To accommodate those situations, Python " +"provides :class:`functools.cmp_to_key` to wrap the comparison function to " +"make it usable as a key function::" +msgstr "" + +#: howto/sorting.rst:273 +msgid "sorted(words, key=cmp_to_key(strcoll)) # locale-aware sort order" msgstr "" #: howto/sorting.rst:276 @@ -293,9 +435,9 @@ msgstr "" #: howto/sorting.rst:278 msgid "" -"For locale aware sorting, use :func:`locale.strxfrm` for a key function or :" -"func:`locale.strcoll` for a comparison function. This is necessary because " -"\"alphabetical\" sort orderings can vary across cultures even if the " +"For locale aware sorting, use :func:`locale.strxfrm` for a key function " +"or :func:`locale.strcoll` for a comparison function. This is necessary " +"because \"alphabetical\" sort orderings can vary across cultures even if the " "underlying alphabet is the same." msgstr "" @@ -307,17 +449,35 @@ msgid "" "function twice:" msgstr "" +#: howto/sorting.rst:288 +msgid "" +">>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]\n" +">>> standard_way = sorted(data, key=itemgetter(0), reverse=True)\n" +">>> double_reversed = list(reversed(sorted(reversed(data), " +"key=itemgetter(0))))\n" +">>> assert standard_way == double_reversed\n" +">>> standard_way\n" +"[('red', 1), ('red', 2), ('blue', 1), ('blue', 2)]" +msgstr "" + #: howto/sorting.rst:297 msgid "" "The sort routines use ``<`` when making comparisons between two objects. So, " -"it is easy to add a standard sort order to a class by defining an :meth:" -"`~object.__lt__` method:" +"it is easy to add a standard sort order to a class by defining " +"an :meth:`~object.__lt__` method:" +msgstr "" + +#: howto/sorting.rst:301 +msgid "" +">>> Student.__lt__ = lambda self, other: self.age < other.age\n" +">>> sorted(student_objects)\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" msgstr "" #: howto/sorting.rst:307 msgid "" -"However, note that ``<`` can fall back to using :meth:`~object.__gt__` if :" -"meth:`~object.__lt__` is not implemented (see :func:`object.__lt__` for " +"However, note that ``<`` can fall back to using :meth:`~object.__gt__` " +"if :meth:`~object.__lt__` is not implemented (see :func:`object.__lt__` for " "details on the mechanics). To avoid surprises, :pep:`8` recommends that all " "six comparison methods be implemented. The :func:`~functools.total_ordering` " "decorator is provided to make that task easier." @@ -331,6 +491,14 @@ msgid "" "of student names:" msgstr "" +#: howto/sorting.rst:319 +msgid "" +">>> students = ['dave', 'john', 'jane']\n" +">>> newgrades = {'john': 'F', 'jane':'A', 'dave': 'C'}\n" +">>> sorted(students, key=newgrades.__getitem__)\n" +"['jane', 'dave', 'john']" +msgstr "" + #: howto/sorting.rst:327 msgid "Partial Sorts" msgstr "" diff --git a/howto/unicode.po b/howto/unicode.po index 721f19d0..0049f67c 100644 --- a/howto/unicode.po +++ b/howto/unicode.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -77,10 +78,10 @@ msgstr "" msgid "" "The Unicode standard describes how characters are represented by **code " "points**. A code point value is an integer in the range 0 to 0x10FFFF " -"(about 1.1 million values, the `actual number assigned `_ is less than that). In the standard and in " -"this document, a code point is written using the notation ``U+265E`` to mean " -"the character with value ``0x265e`` (9,822 in decimal)." +"(about 1.1 million values, the `actual number assigned `_ is less than that). In the " +"standard and in this document, a code point is written using the notation " +"``U+265E`` to mean the character with value ``0x265e`` (9,822 in decimal)." msgstr "" #: howto/unicode.rst:50 @@ -89,6 +90,25 @@ msgid "" "corresponding code points:" msgstr "" +#: howto/unicode.rst:53 +msgid "" +"0061 'a'; LATIN SMALL LETTER A\n" +"0062 'b'; LATIN SMALL LETTER B\n" +"0063 'c'; LATIN SMALL LETTER C\n" +"...\n" +"007B '{'; LEFT CURLY BRACKET\n" +"...\n" +"2167 'Ⅷ'; ROMAN NUMERAL EIGHT\n" +"2168 'Ⅸ'; ROMAN NUMERAL NINE\n" +"...\n" +"265E '♞'; BLACK CHESS KNIGHT\n" +"265F '♟'; BLACK CHESS PAWN\n" +"...\n" +"1F600 '😀'; GRINNING FACE\n" +"1F609 '😉'; WINKING FACE\n" +"..." +msgstr "" + #: howto/unicode.rst:71 msgid "" "Strictly, these definitions imply that it's meaningless to say 'this is " @@ -129,6 +149,13 @@ msgid "" "representation, the string \"Python\" might look like this:" msgstr "" +#: howto/unicode.rst:101 +msgid "" +" P y t h o n\n" +"0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00\n" +" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23" +msgstr "" + #: howto/unicode.rst:107 msgid "" "This representation is straightforward but using it presents a number of " @@ -254,8 +281,8 @@ msgstr "" #: howto/unicode.rst:173 msgid "" -"Another `good introductory article `_ was " "written by Joel Spolsky. If this introduction didn't make things clear to " "you, you should try reading this alternate article before continuing." @@ -296,11 +323,28 @@ msgid "" "include a Unicode character in a string literal::" msgstr "" +#: howto/unicode.rst:199 +msgid "" +"try:\n" +" with open('/tmp/input.txt', 'r') as f:\n" +" ...\n" +"except OSError:\n" +" # 'File not found' error message.\n" +" print(\"Fichier non trouvé\")" +msgstr "" + #: howto/unicode.rst:206 msgid "" "Side note: Python 3 also supports using Unicode characters in identifiers::" msgstr "" +#: howto/unicode.rst:208 +msgid "" +"répertoire = \"/tmp/records.log\"\n" +"with open(répertoire, \"w\") as f:\n" +" f.write(\"test\\n\")" +msgstr "" + #: howto/unicode.rst:212 msgid "" "If you can't enter a particular character in your editor or want to keep the " @@ -309,6 +353,16 @@ msgid "" "delta glyph instead of a \\u escape.) ::" msgstr "" +#: howto/unicode.rst:217 +msgid "" +">>> \"\\N{GREEK CAPITAL LETTER DELTA}\" # Using the character name\n" +"'\\u0394'\n" +">>> \"\\u0394\" # Using a 16-bit hex value\n" +"'\\u0394'\n" +">>> \"\\U00000394\" # Using a 32-bit hex value\n" +"'\\u0394'" +msgstr "" + #: howto/unicode.rst:224 msgid "" "In addition, one can create a string using the :func:`~bytes.decode` method " @@ -327,6 +381,21 @@ msgid "" "examples show the differences::" msgstr "" +#: howto/unicode.rst:236 +msgid "" +">>> b'\\x80abc'.decode(\"utf-8\", \"strict\") \n" +"Traceback (most recent call last):\n" +" ...\n" +"UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0:\n" +" invalid start byte\n" +">>> b'\\x80abc'.decode(\"utf-8\", \"replace\")\n" +"'\\ufffdabc'\n" +">>> b'\\x80abc'.decode(\"utf-8\", \"backslashreplace\")\n" +"'\\\\x80abc'\n" +">>> b'\\x80abc'.decode(\"utf-8\", \"ignore\")\n" +"'abc'" +msgstr "" + #: howto/unicode.rst:248 msgid "" "Encodings are specified as strings containing the encoding's name. Python " @@ -345,6 +414,14 @@ msgid "" "returns the code point value::" msgstr "" +#: howto/unicode.rst:260 +msgid "" +">>> chr(57344)\n" +"'\\ue000'\n" +">>> ord('\\ue000')\n" +"57344" +msgstr "" + #: howto/unicode.rst:266 msgid "Converting to Bytes" msgstr "" @@ -358,10 +435,10 @@ msgstr "" #: howto/unicode.rst:272 msgid "" -"The *errors* parameter is the same as the parameter of the :meth:`~bytes." -"decode` method but supports a few more possible handlers. As well as " -"``'strict'``, ``'ignore'``, and ``'replace'`` (which in this case inserts a " -"question mark instead of the unencodable character), there is also " +"The *errors* parameter is the same as the parameter of " +"the :meth:`~bytes.decode` method but supports a few more possible handlers. " +"As well as ``'strict'``, ``'ignore'``, and ``'replace'`` (which in this case " +"inserts a question mark instead of the unencodable character), there is also " "``'xmlcharrefreplace'`` (inserts an XML character reference), " "``backslashreplace`` (inserts a ``\\uNNNN`` escape sequence) and " "``namereplace`` (inserts a ``\\N{...}`` escape sequence)." @@ -371,6 +448,28 @@ msgstr "" msgid "The following example shows the different results::" msgstr "" +#: howto/unicode.rst:282 +msgid "" +">>> u = chr(40960) + 'abcd' + chr(1972)\n" +">>> u.encode('utf-8')\n" +"b'\\xea\\x80\\x80abcd\\xde\\xb4'\n" +">>> u.encode('ascii') \n" +"Traceback (most recent call last):\n" +" ...\n" +"UnicodeEncodeError: 'ascii' codec can't encode character '\\ua000' in\n" +" position 0: ordinal not in range(128)\n" +">>> u.encode('ascii', 'ignore')\n" +"b'abcd'\n" +">>> u.encode('ascii', 'replace')\n" +"b'?abcd?'\n" +">>> u.encode('ascii', 'xmlcharrefreplace')\n" +"b'ꀀabcd޴'\n" +">>> u.encode('ascii', 'backslashreplace')\n" +"b'\\\\ua000abcd\\\\u07b4'\n" +">>> u.encode('ascii', 'namereplace')\n" +"b'\\\\N{YI SYLLABLE IT}abcd\\\\u07b4'" +msgstr "" + #: howto/unicode.rst:301 msgid "" "The low-level routines for registering and accessing the available encodings " @@ -393,6 +492,16 @@ msgid "" "digits, not four::" msgstr "" +#: howto/unicode.rst:317 +msgid "" +">>> s = \"a\\xac\\u1234\\u20ac\\U00008000\"\n" +"... # ^^^^ two-digit hex escape\n" +"... # ^^^^^^ four-digit Unicode escape\n" +"... # ^^^^^^^^^^ eight-digit Unicode escape\n" +">>> [ord(c) for c in s]\n" +"[97, 172, 4660, 8364, 32768]" +msgstr "" + #: howto/unicode.rst:324 msgid "" "Using escape sequences for code points greater than 127 is fine in small " @@ -418,6 +527,15 @@ msgid "" "file::" msgstr "" +#: howto/unicode.rst:339 +msgid "" +"#!/usr/bin/env python\n" +"# -*- coding: latin-1 -*-\n" +"\n" +"u = 'abcdé'\n" +"print(ord(u[-1]))" +msgstr "" + #: howto/unicode.rst:345 msgid "" "The syntax is inspired by Emacs's notation for specifying variables local to " @@ -453,10 +571,34 @@ msgid "" "and prints the numeric value of one particular character::" msgstr "" +#: howto/unicode.rst:369 +msgid "" +"import unicodedata\n" +"\n" +"u = chr(233) + chr(0x0bf2) + chr(3972) + chr(6000) + chr(13231)\n" +"\n" +"for i, c in enumerate(u):\n" +" print(i, '%04x' % ord(c), unicodedata.category(c), end=\" \")\n" +" print(unicodedata.name(c))\n" +"\n" +"# Get numeric value of second character\n" +"print(unicodedata.numeric(u[1]))" +msgstr "" + #: howto/unicode.rst:380 msgid "When run, this prints:" msgstr "" +#: howto/unicode.rst:382 +msgid "" +"0 00e9 Ll LATIN SMALL LETTER E WITH ACUTE\n" +"1 0bf2 No TAMIL NUMBER ONE THOUSAND\n" +"2 0f84 Mn TIBETAN MARK HALANTA\n" +"3 1770 Lo TAGBANWA LETTER SA\n" +"4 33af So SQUARE RAD OVER S SQUARED\n" +"1000.0" +msgstr "" + #: howto/unicode.rst:391 msgid "" "The category codes are abbreviations describing the nature of the character. " @@ -465,9 +607,9 @@ msgid "" "subcategories. To take the codes from the above output, ``'Ll'`` means " "'Letter, lowercase', ``'No'`` means \"Number, other\", ``'Mn'`` is \"Mark, " "nonspacing\", and ``'So'`` is \"Symbol, other\". See `the General Category " -"Values section of the Unicode Character Database documentation `_ for a list of category " -"codes." +"Values section of the Unicode Character Database documentation `_ for a list of " +"category codes." msgstr "" #: howto/unicode.rst:402 @@ -493,20 +635,53 @@ msgid "" "which becomes the pair of lowercase letters 'ss'." msgstr "" +#: howto/unicode.rst:421 +msgid "" +">>> street = 'Gürzenichstraße'\n" +">>> street.casefold()\n" +"'gürzenichstrasse'" +msgstr "" + #: howto/unicode.rst:425 msgid "" -"A second tool is the :mod:`unicodedata` module's :func:`~unicodedata." -"normalize` function that converts strings to one of several normal forms, " -"where letters followed by a combining character are replaced with single " -"characters. :func:`~unicodedata.normalize` can be used to perform string " -"comparisons that won't falsely report inequality if two strings use " -"combining characters differently:" +"A second tool is the :mod:`unicodedata` " +"module's :func:`~unicodedata.normalize` function that converts strings to " +"one of several normal forms, where letters followed by a combining character " +"are replaced with single characters. :func:`~unicodedata.normalize` can be " +"used to perform string comparisons that won't falsely report inequality if " +"two strings use combining characters differently:" +msgstr "" + +#: howto/unicode.rst:434 +msgid "" +"import unicodedata\n" +"\n" +"def compare_strs(s1, s2):\n" +" def NFD(s):\n" +" return unicodedata.normalize('NFD', s)\n" +"\n" +" return NFD(s1) == NFD(s2)\n" +"\n" +"single_char = 'ê'\n" +"multiple_chars = '\\N{LATIN SMALL LETTER E}\\N{COMBINING CIRCUMFLEX " +"ACCENT}'\n" +"print('length of first string=', len(single_char))\n" +"print('length of second string=', len(multiple_chars))\n" +"print(compare_strs(single_char, multiple_chars))" msgstr "" #: howto/unicode.rst:448 msgid "When run, this outputs:" msgstr "" +#: howto/unicode.rst:450 +msgid "" +"$ python compare-strs.py\n" +"length of first string= 1\n" +"length of second string= 2\n" +"True" +msgstr "" + #: howto/unicode.rst:457 msgid "" "The first argument to the :func:`~unicodedata.normalize` function is a " @@ -518,6 +693,24 @@ msgstr "" msgid "The Unicode Standard also specifies how to do caseless comparisons::" msgstr "" +#: howto/unicode.rst:463 +msgid "" +"import unicodedata\n" +"\n" +"def compare_caseless(s1, s2):\n" +" def NFD(s):\n" +" return unicodedata.normalize('NFD', s)\n" +"\n" +" return NFD(NFD(s1).casefold()) == NFD(NFD(s2).casefold())\n" +"\n" +"# Example usage\n" +"single_char = 'ê'\n" +"multiple_chars = '\\N{LATIN CAPITAL LETTER E}\\N{COMBINING CIRCUMFLEX " +"ACCENT}'\n" +"\n" +"print(compare_caseless(single_char, multiple_chars))" +msgstr "" + #: howto/unicode.rst:477 msgid "" "This will print ``True``. (Why is :func:`!NFD` invoked twice? Because " @@ -546,6 +739,16 @@ msgid "" "numerals::" msgstr "" +#: howto/unicode.rst:496 +msgid "" +"import re\n" +"p = re.compile(r'\\d+')\n" +"\n" +"s = \"Over \\u0e55\\u0e57 57 flavours\"\n" +"m = p.search(s)\n" +"print(repr(m.group()))" +msgstr "" + #: howto/unicode.rst:503 msgid "" "When executed, ``\\d+`` will match the Thai numerals and print them out. If " @@ -566,8 +769,9 @@ msgstr "" #: howto/unicode.rst:520 msgid "" -"`Processing Text Files in Python 3 `_, by Nick Coghlan." +"`Processing Text Files in Python 3 `_, " +"by Nick Coghlan." msgstr "" #: howto/unicode.rst:521 @@ -578,8 +782,8 @@ msgstr "" #: howto/unicode.rst:523 msgid "" -"The :class:`str` type is described in the Python library reference at :ref:" -"`textseq`." +"The :class:`str` type is described in the Python library reference " +"at :ref:`textseq`." msgstr "" #: howto/unicode.rst:526 @@ -650,20 +854,35 @@ msgid "" "object that assumes the file's contents are in a specified encoding and " "accepts Unicode parameters for methods such as :meth:`~io.TextIOBase.read` " "and :meth:`~io.TextIOBase.write`. This works through :func:`open`\\'s " -"*encoding* and *errors* parameters which are interpreted just like those in :" -"meth:`str.encode` and :meth:`bytes.decode`." +"*encoding* and *errors* parameters which are interpreted just like those " +"in :meth:`str.encode` and :meth:`bytes.decode`." msgstr "" #: howto/unicode.rst:574 msgid "Reading Unicode from a file is therefore simple::" msgstr "" +#: howto/unicode.rst:576 +msgid "" +"with open('unicode.txt', encoding='utf-8') as f:\n" +" for line in f:\n" +" print(repr(line))" +msgstr "" + #: howto/unicode.rst:580 msgid "" "It's also possible to open files in update mode, allowing both reading and " "writing::" msgstr "" +#: howto/unicode.rst:583 +msgid "" +"with open('test', encoding='utf-8', mode='w+') as f:\n" +" f.write('\\u4500 blah blah blah\\n')\n" +" f.seek(0)\n" +" print(repr(f.readline()[:1]))" +msgstr "" + #: howto/unicode.rst:588 msgid "" "The Unicode character ``U+FEFF`` is used as a byte-order mark (BOM), and is " @@ -712,6 +931,13 @@ msgid "" "and it will be automatically converted to the right encoding for you::" msgstr "" +#: howto/unicode.rst:622 +msgid "" +"filename = 'filename\\u4500abc'\n" +"with open(filename, 'w') as f:\n" +" f.write('blah\\n')" +msgstr "" + #: howto/unicode.rst:626 msgid "" "Functions in the :mod:`os` module such as :func:`os.stat` will also accept " @@ -731,10 +957,28 @@ msgid "" "error handler>` is UTF-8, running the following program::" msgstr "" +#: howto/unicode.rst:639 +msgid "" +"fn = 'filename\\u4500abc'\n" +"f = open(fn, 'w')\n" +"f.close()\n" +"\n" +"import os\n" +"print(os.listdir(b'.'))\n" +"print(os.listdir('.'))" +msgstr "" + #: howto/unicode.rst:647 msgid "will produce the following output:" msgstr "" +#: howto/unicode.rst:649 +msgid "" +"$ python listdir-test.py\n" +"[b'filename\\xe4\\x94\\x80abc', ...]\n" +"['filename\\u4500abc', ...]" +msgstr "" + #: howto/unicode.rst:655 msgid "" "The first list contains UTF-8-encoded filenames, and the second list " @@ -807,6 +1051,17 @@ msgid "" "it with a :class:`~codecs.StreamRecoder` to return bytes encoded in UTF-8::" msgstr "" +#: howto/unicode.rst:701 +msgid "" +"new_f = codecs.StreamRecoder(f,\n" +" # en/decoder: used by read() to encode its results and\n" +" # by write() to decode its input.\n" +" codecs.getencoder('utf-8'), codecs.getdecoder('utf-8'),\n" +"\n" +" # reader/writer: used to read and write to the stream.\n" +" codecs.getreader('latin-1'), codecs.getwriter('latin-1') )" +msgstr "" + #: howto/unicode.rst:711 msgid "Files in an Unknown Encoding" msgstr "" @@ -819,6 +1074,18 @@ msgid "" "``surrogateescape`` error handler::" msgstr "" +#: howto/unicode.rst:718 +msgid "" +"with open(fname, 'r', encoding=\"ascii\", errors=\"surrogateescape\") as f:\n" +" data = f.read()\n" +"\n" +"# make changes to the string 'data'\n" +"\n" +"with open(fname + '.new', 'w',\n" +" encoding=\"ascii\", errors=\"surrogateescape\") as f:\n" +" f.write(data)" +msgstr "" + #: howto/unicode.rst:727 msgid "" "The ``surrogateescape`` error handler will decode any non-ASCII bytes as " @@ -829,8 +1096,8 @@ msgstr "" #: howto/unicode.rst:737 msgid "" -"One section of `Mastering Python 3 Input/Output `_, a PyCon 2010 talk by David " +"One section of `Mastering Python 3 Input/Output `_, a PyCon 2010 talk by David " "Beazley, discusses text processing and binary data handling." msgstr "" diff --git a/howto/urllib2.po b/howto/urllib2.po index 924e07b6..4e8af62c 100644 --- a/howto/urllib2.po +++ b/howto/urllib2.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -40,8 +41,8 @@ msgstr "" #: howto/urllib2.rst:18 msgid "" -"`Basic Authentication `_" +"`Basic Authentication `_" msgstr "" #: howto/urllib2.rst:20 @@ -87,11 +88,32 @@ msgstr "" msgid "The simplest way to use urllib.request is as follows::" msgstr "" +#: howto/urllib2.rst:48 +msgid "" +"import urllib.request\n" +"with urllib.request.urlopen('http://python.org/') as response:\n" +" html = response.read()" +msgstr "" + #: howto/urllib2.rst:52 msgid "" "If you wish to retrieve a resource via URL and store it in a temporary " -"location, you can do so via the :func:`shutil.copyfileobj` and :func:" -"`tempfile.NamedTemporaryFile` functions::" +"location, you can do so via the :func:`shutil.copyfileobj` " +"and :func:`tempfile.NamedTemporaryFile` functions::" +msgstr "" + +#: howto/urllib2.rst:56 +msgid "" +"import shutil\n" +"import tempfile\n" +"import urllib.request\n" +"\n" +"with urllib.request.urlopen('http://python.org/') as response:\n" +" with tempfile.NamedTemporaryFile(delete=False) as tmp_file:\n" +" shutil.copyfileobj(response, tmp_file)\n" +"\n" +"with open(tmp_file.name) as html:\n" +" pass" msgstr "" #: howto/urllib2.rst:67 @@ -113,12 +135,25 @@ msgid "" "for example call ``.read()`` on the response::" msgstr "" +#: howto/urllib2.rst:80 +msgid "" +"import urllib.request\n" +"\n" +"req = urllib.request.Request('http://python.org/')\n" +"with urllib.request.urlopen(req) as response:\n" +" the_page = response.read()" +msgstr "" + #: howto/urllib2.rst:86 msgid "" "Note that urllib.request makes use of the same Request interface to handle " "all URL schemes. For example, you can make an FTP request like so::" msgstr "" +#: howto/urllib2.rst:89 +msgid "req = urllib.request.Request('ftp://example.com/')" +msgstr "" + #: howto/urllib2.rst:91 msgid "" "In the case of HTTP, there are two extra things that Request objects allow " @@ -145,6 +180,23 @@ msgid "" "function from the :mod:`urllib.parse` library. ::" msgstr "" +#: howto/urllib2.rst:110 +msgid "" +"import urllib.parse\n" +"import urllib.request\n" +"\n" +"url = 'http://www.someserver.com/cgi-bin/register.cgi'\n" +"values = {'name' : 'Michael Foord',\n" +" 'location' : 'Northampton',\n" +" 'language' : 'Python' }\n" +"\n" +"data = urllib.parse.urlencode(values)\n" +"data = data.encode('ascii') # data should be bytes\n" +"req = urllib.request.Request(url, data)\n" +"with urllib.request.urlopen(req) as response:\n" +" the_page = response.read()" +msgstr "" + #: howto/urllib2.rst:124 msgid "" "Note that other encodings are sometimes required (e.g. for file upload from " @@ -169,6 +221,22 @@ msgstr "" msgid "This is done as follows::" msgstr "" +#: howto/urllib2.rst:141 +msgid "" +">>> import urllib.request\n" +">>> import urllib.parse\n" +">>> data = {}\n" +">>> data['name'] = 'Somebody Here'\n" +">>> data['location'] = 'Northampton'\n" +">>> data['language'] = 'Python'\n" +">>> url_values = urllib.parse.urlencode(data)\n" +">>> print(url_values) # The order may differ from below. \n" +"name=Somebody+Here&language=Python&location=Northampton\n" +">>> url = 'http://www.example.com/example.cgi'\n" +">>> full_url = url + '?' + url_values\n" +">>> data = urllib.request.urlopen(full_url)" +msgstr "" + #: howto/urllib2.rst:154 msgid "" "Notice that the full URL is created by adding a ``?`` to the URL, followed " @@ -198,6 +266,25 @@ msgid "" "Explorer [#]_. ::" msgstr "" +#: howto/urllib2.rst:174 +msgid "" +"import urllib.parse\n" +"import urllib.request\n" +"\n" +"url = 'http://www.someserver.com/cgi-bin/register.cgi'\n" +"user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'\n" +"values = {'name': 'Michael Foord',\n" +" 'location': 'Northampton',\n" +" 'language': 'Python' }\n" +"headers = {'User-Agent': user_agent}\n" +"\n" +"data = urllib.parse.urlencode(values)\n" +"data = data.encode('ascii')\n" +"req = urllib.request.Request(url, data, headers)\n" +"with urllib.request.urlopen(req) as response:\n" +" the_page = response.read()" +msgstr "" + #: howto/urllib2.rst:190 msgid "" "The response also has two useful methods. See the section on `info and " @@ -212,14 +299,14 @@ msgstr "" #: howto/urllib2.rst:197 msgid "" "*urlopen* raises :exc:`~urllib.error.URLError` when it cannot handle a " -"response (though as usual with Python APIs, built-in exceptions such as :exc:" -"`ValueError`, :exc:`TypeError` etc. may also be raised)." +"response (though as usual with Python APIs, built-in exceptions such " +"as :exc:`ValueError`, :exc:`TypeError` etc. may also be raised)." msgstr "" #: howto/urllib2.rst:201 msgid "" -":exc:`~urllib.error.HTTPError` is the subclass of :exc:`~urllib.error." -"URLError` raised in the specific case of HTTP URLs." +":exc:`~urllib.error.HTTPError` is the subclass " +"of :exc:`~urllib.error.URLError` raised in the specific case of HTTP URLs." msgstr "" #: howto/urllib2.rst:204 @@ -242,6 +329,16 @@ msgstr "" msgid "e.g. ::" msgstr "" +#: howto/urllib2.rst:216 +msgid "" +">>> req = urllib.request.Request('http://www.pretend_server.org')\n" +">>> try: urllib.request.urlopen(req)\n" +"... except urllib.error.URLError as e:\n" +"... print(e.reason) \n" +"...\n" +"(4, 'getaddrinfo failed')" +msgstr "" + #: howto/urllib2.rst:225 msgid "HTTPError" msgstr "" @@ -253,9 +350,9 @@ msgid "" "request. The default handlers will handle some of these responses for you " "(for example, if the response is a \"redirection\" that requests the client " "fetch the document from a different URL, urllib will handle that for you). " -"For those it can't handle, urlopen will raise an :exc:`~urllib.error." -"HTTPError`. Typical errors include '404' (page not found), '403' (request " -"forbidden), and '401' (authentication required)." +"For those it can't handle, urlopen will raise " +"an :exc:`~urllib.error.HTTPError`. Typical errors include '404' (page not " +"found), '403' (request forbidden), and '401' (authentication required)." msgstr "" #: howto/urllib2.rst:235 @@ -287,6 +384,77 @@ msgid "" "The dictionary is reproduced here for convenience ::" msgstr "" +#: howto/urllib2.rst:251 +msgid "" +"# Table mapping response codes to messages; entries have the\n" +"# form {code: (shortmessage, longmessage)}.\n" +"responses = {\n" +" 100: ('Continue', 'Request received, please continue'),\n" +" 101: ('Switching Protocols',\n" +" 'Switching to new protocol; obey Upgrade header'),\n" +"\n" +" 200: ('OK', 'Request fulfilled, document follows'),\n" +" 201: ('Created', 'Document created, URL follows'),\n" +" 202: ('Accepted',\n" +" 'Request accepted, processing continues off-line'),\n" +" 203: ('Non-Authoritative Information', 'Request fulfilled from cache'),\n" +" 204: ('No Content', 'Request fulfilled, nothing follows'),\n" +" 205: ('Reset Content', 'Clear input form for further input.'),\n" +" 206: ('Partial Content', 'Partial content follows.'),\n" +"\n" +" 300: ('Multiple Choices',\n" +" 'Object has several resources -- see URI list'),\n" +" 301: ('Moved Permanently', 'Object moved permanently -- see URI list'),\n" +" 302: ('Found', 'Object moved temporarily -- see URI list'),\n" +" 303: ('See Other', 'Object moved -- see Method and URL list'),\n" +" 304: ('Not Modified',\n" +" 'Document has not changed since given time'),\n" +" 305: ('Use Proxy',\n" +" 'You must use proxy specified in Location to access this '\n" +" 'resource.'),\n" +" 307: ('Temporary Redirect',\n" +" 'Object moved temporarily -- see URI list'),\n" +"\n" +" 400: ('Bad Request',\n" +" 'Bad request syntax or unsupported method'),\n" +" 401: ('Unauthorized',\n" +" 'No permission -- see authorization schemes'),\n" +" 402: ('Payment Required',\n" +" 'No payment -- see charging schemes'),\n" +" 403: ('Forbidden',\n" +" 'Request forbidden -- authorization will not help'),\n" +" 404: ('Not Found', 'Nothing matches the given URI'),\n" +" 405: ('Method Not Allowed',\n" +" 'Specified method is invalid for this server.'),\n" +" 406: ('Not Acceptable', 'URI not available in preferred format.'),\n" +" 407: ('Proxy Authentication Required', 'You must authenticate with '\n" +" 'this proxy before proceeding.'),\n" +" 408: ('Request Timeout', 'Request timed out; try again later.'),\n" +" 409: ('Conflict', 'Request conflict.'),\n" +" 410: ('Gone',\n" +" 'URI no longer exists and has been permanently removed.'),\n" +" 411: ('Length Required', 'Client must specify Content-Length.'),\n" +" 412: ('Precondition Failed', 'Precondition in headers is false.'),\n" +" 413: ('Request Entity Too Large', 'Entity is too large.'),\n" +" 414: ('Request-URI Too Long', 'URI is too long.'),\n" +" 415: ('Unsupported Media Type', 'Entity body in unsupported format.'),\n" +" 416: ('Requested Range Not Satisfiable',\n" +" 'Cannot satisfy request range.'),\n" +" 417: ('Expectation Failed',\n" +" 'Expect condition could not be satisfied.'),\n" +"\n" +" 500: ('Internal Server Error', 'Server got itself in trouble'),\n" +" 501: ('Not Implemented',\n" +" 'Server does not support this operation'),\n" +" 502: ('Bad Gateway', 'Invalid responses from another server/proxy.'),\n" +" 503: ('Service Unavailable',\n" +" 'The server cannot process the request due to a high load'),\n" +" 504: ('Gateway Timeout',\n" +" 'The gateway server did not receive a timely response'),\n" +" 505: ('HTTP Version Not Supported', 'Cannot fulfill request.'),\n" +" }" +msgstr "" + #: howto/urllib2.rst:319 msgid "" "When an error is raised the server responds by returning an HTTP error code " @@ -296,21 +464,56 @@ msgid "" "``urllib.response`` module::" msgstr "" +#: howto/urllib2.rst:324 +msgid "" +">>> req = urllib.request.Request('http://www.python.org/fish.html')\n" +">>> try:\n" +"... urllib.request.urlopen(req)\n" +"... except urllib.error.HTTPError as e:\n" +"... print(e.code)\n" +"... print(e.read()) \n" +"...\n" +"404\n" +"b'\\n\\n\\nPage Not Found\\n\n" +" ..." +msgstr "" + #: howto/urllib2.rst:339 msgid "Wrapping it Up" msgstr "" #: howto/urllib2.rst:341 msgid "" -"So if you want to be prepared for :exc:`~urllib.error.HTTPError` *or* :exc:" -"`~urllib.error.URLError` there are two basic approaches. I prefer the second " -"approach." +"So if you want to be prepared for :exc:`~urllib.error.HTTPError` " +"*or* :exc:`~urllib.error.URLError` there are two basic approaches. I prefer " +"the second approach." msgstr "" #: howto/urllib2.rst:345 msgid "Number 1" msgstr "" +#: howto/urllib2.rst:350 +msgid "" +"from urllib.request import Request, urlopen\n" +"from urllib.error import URLError, HTTPError\n" +"req = Request(someurl)\n" +"try:\n" +" response = urlopen(req)\n" +"except HTTPError as e:\n" +" print('The server couldn\\'t fulfill the request.')\n" +" print('Error code: ', e.code)\n" +"except URLError as e:\n" +" print('We failed to reach a server.')\n" +" print('Reason: ', e.reason)\n" +"else:\n" +" # everything is fine" +msgstr "" + #: howto/urllib2.rst:367 msgid "" "The ``except HTTPError`` *must* come first, otherwise ``except URLError`` " @@ -321,6 +524,24 @@ msgstr "" msgid "Number 2" msgstr "" +#: howto/urllib2.rst:375 +msgid "" +"from urllib.request import Request, urlopen\n" +"from urllib.error import URLError\n" +"req = Request(someurl)\n" +"try:\n" +" response = urlopen(req)\n" +"except URLError as e:\n" +" if hasattr(e, 'reason'):\n" +" print('We failed to reach a server.')\n" +" print('Reason: ', e.reason)\n" +" elif hasattr(e, 'code'):\n" +" print('The server couldn\\'t fulfill the request.')\n" +" print('Error code: ', e.code)\n" +"else:\n" +" # everything is fine" +msgstr "" + #: howto/urllib2.rst:392 msgid "info and geturl" msgstr "" @@ -343,8 +564,8 @@ msgstr "" #: howto/urllib2.rst:402 msgid "" "**info** - this returns a dictionary-like object that describes the page " -"fetched, particularly the headers sent by the server. It is currently an :" -"class:`http.client.HTTPMessage` instance." +"fetched, particularly the headers sent by the server. It is currently " +"an :class:`http.client.HTTPMessage` instance." msgstr "" #: howto/urllib2.rst:406 @@ -379,8 +600,8 @@ msgstr "" #: howto/urllib2.rst:427 msgid "" -"To create an opener, instantiate an ``OpenerDirector``, and then call ``." -"add_handler(some_handler_instance)`` repeatedly." +"To create an opener, instantiate an ``OpenerDirector``, and then call " +"``.add_handler(some_handler_instance)`` repeatedly." msgstr "" #: howto/urllib2.rst:430 @@ -436,6 +657,10 @@ msgstr "" msgid "e.g." msgstr "" +#: howto/urllib2.rst:463 +msgid "WWW-Authenticate: Basic realm=\"cPanel Users\"" +msgstr "" + #: howto/urllib2.rst:468 msgid "" "The client should then retry the request with the appropriate name and " @@ -463,6 +688,29 @@ msgid "" "\"deeper\" than the URL you pass to .add_password() will also match. ::" msgstr "" +#: howto/urllib2.rst:486 +msgid "" +"# create a password manager\n" +"password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()\n" +"\n" +"# Add the username and password.\n" +"# If we knew the realm, we could use it instead of None.\n" +"top_level_url = \"http://example.com/foo/\"\n" +"password_mgr.add_password(None, top_level_url, username, password)\n" +"\n" +"handler = urllib.request.HTTPBasicAuthHandler(password_mgr)\n" +"\n" +"# create \"opener\" (OpenerDirector instance)\n" +"opener = urllib.request.build_opener(handler)\n" +"\n" +"# use the opener to fetch a URL\n" +"opener.open(a_url)\n" +"\n" +"# Install the opener.\n" +"# Now all calls to urllib.request.urlopen use our opener.\n" +"urllib.request.install_opener(opener)" +msgstr "" + #: howto/urllib2.rst:508 msgid "" "In the above example we only supplied our ``HTTPBasicAuthHandler`` to " @@ -498,11 +746,18 @@ msgid "" "similar steps to setting up a `Basic Authentication`_ handler: ::" msgstr "" +#: howto/urllib2.rst:534 +msgid "" +">>> proxy_support = urllib.request.ProxyHandler({})\n" +">>> opener = urllib.request.build_opener(proxy_support)\n" +">>> urllib.request.install_opener(opener)" +msgstr "" + #: howto/urllib2.rst:540 msgid "" "Currently ``urllib.request`` *does not* support fetching of ``https`` " -"locations through a proxy. However, this can be enabled by extending urllib." -"request as shown in the recipe [#]_." +"locations through a proxy. However, this can be enabled by extending " +"urllib.request as shown in the recipe [#]_." msgstr "" #: howto/urllib2.rst:546 @@ -526,9 +781,24 @@ msgid "" "As of Python 2.3 you can specify how long a socket should wait for a " "response before timing out. This can be useful in applications which have to " "fetch web pages. By default the socket module has *no timeout* and can hang. " -"Currently, the socket timeout is not exposed at the http.client or urllib." -"request levels. However, you can set the default timeout globally for all " -"sockets using ::" +"Currently, the socket timeout is not exposed at the http.client or " +"urllib.request levels. However, you can set the default timeout globally for " +"all sockets using ::" +msgstr "" + +#: howto/urllib2.rst:562 +msgid "" +"import socket\n" +"import urllib.request\n" +"\n" +"# timeout in seconds\n" +"timeout = 10\n" +"socket.setdefaulttimeout(timeout)\n" +"\n" +"# this call to urllib.request.urlopen now uses the default timeout\n" +"# we have set in the socket module\n" +"req = urllib.request.Request('http://www.voidspace.org.uk')\n" +"response = urllib.request.urlopen(req)" msgstr "" #: howto/urllib2.rst:579 @@ -573,5 +843,6 @@ msgstr "" #: howto/urllib2.rst:596 msgid "" "urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe `_." +"code.activestate.com/recipes/456195-urrlib2-opener-for-ssl-proxy-connect-" +"method/>`_." msgstr "" diff --git a/installing/index.po b/installing/index.po index 86992cd2..06edec06 100644 --- a/installing/index.po +++ b/installing/index.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -142,6 +143,10 @@ msgid "" "dependencies from the Python Package Index::" msgstr "" +#: installing/index.rst:84 +msgid "python -m pip install SomePackage" +msgstr "" + #: installing/index.rst:88 msgid "" "For POSIX users (including macOS and Linux users), the examples in this " @@ -163,6 +168,12 @@ msgid "" "the version should be enclosed within double quotes::" msgstr "" +#: installing/index.rst:100 +msgid "" +"python -m pip install SomePackage==1.0.4 # specific version\n" +"python -m pip install \"SomePackage>=1.0.4\" # minimum version" +msgstr "" + #: installing/index.rst:103 msgid "" "Normally, if a suitable module is already installed, attempting to install " @@ -170,6 +181,10 @@ msgid "" "explicitly::" msgstr "" +#: installing/index.rst:107 +msgid "python -m pip install --upgrade SomePackage" +msgstr "" + #: installing/index.rst:109 msgid "" "More information and resources regarding ``pip`` and its capabilities can be " @@ -254,6 +269,14 @@ msgid "" "``pip``::" msgstr "" +#: installing/index.rst:171 +msgid "" +"python2 -m pip install SomePackage # default Python 2\n" +"python2.7 -m pip install SomePackage # specifically Python 2.7\n" +"python3 -m pip install SomePackage # default Python 3\n" +"python3.4 -m pip install SomePackage # specifically Python 3.4" +msgstr "" + #: installing/index.rst:176 msgid "Appropriately versioned ``pip`` commands may also be available." msgstr "" @@ -264,6 +287,14 @@ msgid "" "switch::" msgstr "" +#: installing/index.rst:181 +msgid "" +"py -2 -m pip install SomePackage # default Python 2\n" +"py -2.7 -m pip install SomePackage # specifically Python 2.7\n" +"py -3 -m pip install SomePackage # default Python 3\n" +"py -3.4 -m pip install SomePackage # specifically Python 3.4" +msgstr "" + #: installing/index.rst:195 msgid "Common installation issues" msgstr "" @@ -297,11 +328,15 @@ msgid "" "fix is::" msgstr "" +#: installing/index.rst:215 +msgid "python -m ensurepip --default-pip" +msgstr "" + #: installing/index.rst:217 msgid "" -"There are also additional resources for `installing pip. `__" +"There are also additional resources for `installing pip. `__" msgstr "" #: installing/index.rst:222 @@ -326,14 +361,14 @@ msgstr "" #: installing/index.rst:234 msgid "" -"Some of the solutions for installing `scientific software `__ that are not yet available as pre-built ``wheel`` " -"files may also help with obtaining other binary extensions without needing " -"to build them locally." +"Some of the solutions for installing `scientific software `__ that are not yet available as pre-built " +"``wheel`` files may also help with obtaining other binary extensions without " +"needing to build them locally." msgstr "" #: installing/index.rst:241 msgid "" -"`Python Packaging User Guide: Binary Extensions `__" +"`Python Packaging User Guide: Binary Extensions `__" msgstr "" diff --git a/library/2to3.po b/library/2to3.po index fae5a9e6..1df7c85f 100644 --- a/library/2to3.po +++ b/library/2to3.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -29,7 +30,7 @@ msgid "" "library, so it is possible to write your own fixers for 2to3." msgstr "" -#: library/2to3.rst:19 +#: library/2to3.rst:14 msgid "" "The ``lib2to3`` module was marked pending for deprecation in Python 3.9 " "(raising :exc:`PendingDeprecationWarning` on import) and fully deprecated in " @@ -57,10 +58,23 @@ msgstr "" msgid "Here is a sample Python 2.x source file, :file:`example.py`::" msgstr "" +#: library/2to3.rst:33 +msgid "" +"def greet(name):\n" +" print \"Hello, {0}!\".format(name)\n" +"print \"What's your name?\"\n" +"name = raw_input()\n" +"greet(name)" +msgstr "" + #: library/2to3.rst:39 msgid "It can be converted to Python 3.x code via 2to3 on the command line:" msgstr "" +#: library/2to3.rst:41 +msgid "$ 2to3 example.py" +msgstr "" + #: library/2to3.rst:45 msgid "" "A diff against the original source file is printed. 2to3 can also write the " @@ -69,10 +83,23 @@ msgid "" "changes back is enabled with the :option:`!-w` flag:" msgstr "" +#: library/2to3.rst:50 +msgid "$ 2to3 -w example.py" +msgstr "" + #: library/2to3.rst:54 msgid "After transformation, :file:`example.py` looks like this::" msgstr "" +#: library/2to3.rst:56 +msgid "" +"def greet(name):\n" +" print(\"Hello, {0}!\".format(name))\n" +"print(\"What's your name?\")\n" +"name = input()\n" +"greet(name)" +msgstr "" + #: library/2to3.rst:62 msgid "" "Comments and exact indentation are preserved throughout the translation " @@ -81,17 +108,25 @@ msgstr "" #: library/2to3.rst:64 msgid "" -"By default, 2to3 runs a set of :ref:`predefined fixers <2to3-fixers>`. The :" -"option:`!-l` flag lists all available fixers. An explicit set of fixers to " -"run can be given with :option:`!-f`. Likewise the :option:`!-x` explicitly " -"disables a fixer. The following example runs only the ``imports`` and " -"``has_key`` fixers:" +"By default, 2to3 runs a set of :ref:`predefined fixers <2to3-fixers>`. " +"The :option:`!-l` flag lists all available fixers. An explicit set of " +"fixers to run can be given with :option:`!-f`. Likewise the :option:`!-x` " +"explicitly disables a fixer. The following example runs only the " +"``imports`` and ``has_key`` fixers:" +msgstr "" + +#: library/2to3.rst:69 +msgid "$ 2to3 -f imports -f has_key example.py" msgstr "" #: library/2to3.rst:73 msgid "This command runs every fixer except the ``apply`` fixer:" msgstr "" +#: library/2to3.rst:75 +msgid "$ 2to3 -x apply example.py" +msgstr "" + #: library/2to3.rst:79 msgid "" "Some fixers are *explicit*, meaning they aren't run by default and must be " @@ -99,6 +134,10 @@ msgid "" "fixers, the ``idioms`` fixer is run:" msgstr "" +#: library/2to3.rst:83 +msgid "$ 2to3 -f all -f idioms example.py" +msgstr "" + #: library/2to3.rst:87 msgid "Notice how passing ``all`` enables all default fixers." msgstr "" @@ -130,19 +169,19 @@ msgid "" "Since some print statements can be parsed as function calls or statements, " "2to3 cannot always read files containing the print function. When 2to3 " "detects the presence of the ``from __future__ import print_function`` " -"compiler directive, it modifies its internal grammar to interpret :func:" -"`print` as a function. This change can also be enabled manually with the :" -"option:`!-p` flag. Use :option:`!-p` to run fixers on code that already has " -"had its print statements converted. Also :option:`!-e` can be used to make :" -"func:`exec` a function." +"compiler directive, it modifies its internal grammar to " +"interpret :func:`print` as a function. This change can also be enabled " +"manually with the :option:`!-p` flag. Use :option:`!-p` to run fixers on " +"code that already has had its print statements converted. Also :option:`!-e` " +"can be used to make :func:`exec` a function." msgstr "" #: library/2to3.rst:110 msgid "" "The :option:`!-o` or :option:`!--output-dir` option allows specification of " -"an alternate directory for processed output files to be written to. The :" -"option:`!-n` flag is required when using this as backup files do not make " -"sense when not overwriting the input files." +"an alternate directory for processed output files to be written to. " +"The :option:`!-n` flag is required when using this as backup files do not " +"make sense when not overwriting the input files." msgstr "" #: library/2to3.rst:115 @@ -169,6 +208,10 @@ msgid "" "as backups are not necessary when writing to different filenames. Example:" msgstr "" +#: library/2to3.rst:131 +msgid "$ 2to3 -n -W --add-suffix=3 example.py" +msgstr "" + #: library/2to3.rst:135 msgid "Will cause a converted file named ``example.py3`` to be written." msgstr "" @@ -181,6 +224,10 @@ msgstr "" msgid "To translate an entire project from one directory tree to another use:" msgstr "" +#: library/2to3.rst:142 +msgid "$ 2to3 --output-dir=python3-version/mycode -W -n python2-version/mycode" +msgstr "" + #: library/2to3.rst:150 msgid "Fixers" msgstr "" @@ -300,13 +347,14 @@ msgstr "" #: library/2to3.rst:207 msgid "" -"Fixes dictionary iteration methods. :meth:`dict.iteritems` is converted to :" -"meth:`dict.items`, :meth:`dict.iterkeys` to :meth:`dict.keys`, and :meth:" -"`dict.itervalues` to :meth:`dict.values`. Similarly, :meth:`dict." -"viewitems`, :meth:`dict.viewkeys` and :meth:`dict.viewvalues` are converted " -"respectively to :meth:`dict.items`, :meth:`dict.keys` and :meth:`dict." -"values`. It also wraps existing usages of :meth:`dict.items`, :meth:`dict." -"keys`, and :meth:`dict.values` in a call to :class:`list`." +"Fixes dictionary iteration methods. :meth:`dict.iteritems` is converted " +"to :meth:`dict.items`, :meth:`dict.iterkeys` to :meth:`dict.keys`, " +"and :meth:`dict.itervalues` to :meth:`dict.values`. " +"Similarly, :meth:`dict.viewitems`, :meth:`dict.viewkeys` " +"and :meth:`dict.viewvalues` are converted respectively " +"to :meth:`dict.items`, :meth:`dict.keys` and :meth:`dict.values`. It also " +"wraps existing usages of :meth:`dict.items`, :meth:`dict.keys`, " +"and :meth:`dict.values` in a call to :class:`list`." msgstr "" #: library/2to3.rst:217 @@ -356,14 +404,24 @@ msgid "" "This optional fixer performs several transformations that make Python code " "more idiomatic. Type comparisons like ``type(x) is SomeClass`` and " "``type(x) == SomeClass`` are converted to ``isinstance(x, SomeClass)``. " -"``while 1`` becomes ``while True``. This fixer also tries to make use of :" -"func:`sorted` in appropriate places. For example, this block ::" +"``while 1`` becomes ``while True``. This fixer also tries to make use " +"of :func:`sorted` in appropriate places. For example, this block ::" +msgstr "" + +#: library/2to3.rst:262 +msgid "" +"L = list(some_iterable)\n" +"L.sort()" msgstr "" #: library/2to3.rst:265 msgid "is changed to ::" msgstr "" +#: library/2to3.rst:267 +msgid "L = sorted(some_iterable)" +msgstr "" + #: library/2to3.rst:271 msgid "Detects sibling imports and converts them to relative imports." msgstr "" @@ -396,16 +454,17 @@ msgstr "" #: library/2to3.rst:299 msgid "" -"Removes imports of :func:`itertools.ifilter`, :func:`itertools.izip`, and :" -"func:`itertools.imap`. Imports of :func:`itertools.ifilterfalse` are also " -"changed to :func:`itertools.filterfalse`." +"Removes imports of :func:`itertools.ifilter`, :func:`itertools.izip`, " +"and :func:`itertools.imap`. Imports of :func:`itertools.ifilterfalse` are " +"also changed to :func:`itertools.filterfalse`." msgstr "" #: library/2to3.rst:305 msgid "" -"Changes usage of :func:`itertools.ifilter`, :func:`itertools.izip`, and :" -"func:`itertools.imap` to their built-in equivalents. :func:`itertools." -"ifilterfalse` is changed to :func:`itertools.filterfalse`." +"Changes usage of :func:`itertools.ifilter`, :func:`itertools.izip`, " +"and :func:`itertools.imap` to their built-in " +"equivalents. :func:`itertools.ifilterfalse` is changed " +"to :func:`itertools.filterfalse`." msgstr "" #: library/2to3.rst:311 @@ -437,15 +496,15 @@ msgstr "" #: library/2to3.rst:335 msgid "" -"Converts the use of iterator's :meth:`~iterator.next` methods to the :func:" -"`next` function. It also renames :meth:`next` methods to :meth:`~iterator." -"__next__`." +"Converts the use of iterator's :meth:`~iterator.next` methods to " +"the :func:`next` function. It also renames :meth:`next` methods " +"to :meth:`~iterator.__next__`." msgstr "" #: library/2to3.rst:341 msgid "" -"Renames definitions of methods called :meth:`__nonzero__` to :meth:`~object." -"__bool__`." +"Renames definitions of methods called :meth:`__nonzero__` " +"to :meth:`~object.__bool__`." msgstr "" #: library/2to3.rst:346 @@ -565,8 +624,9 @@ msgstr "" #: library/2to3.rst:413 msgid "" -"Changes the deprecated :data:`sys.exc_value`, :data:`sys.exc_type`, :data:" -"`sys.exc_traceback` to use :func:`sys.exc_info`." +"Changes the " +"deprecated :data:`sys.exc_value`, :data:`sys.exc_type`, :data:`sys.exc_traceback` " +"to use :func:`sys.exc_info`." msgstr "" #: library/2to3.rst:418 @@ -625,16 +685,16 @@ msgstr "" msgid "**Source code:** :source:`Lib/lib2to3/`" msgstr "" -#: library/2to3.rst:482 +#: library/2to3.rst:473 msgid "" "Python 3.9 switched to a PEG parser (see :pep:`617`) while lib2to3 is using " "a less flexible LL(1) parser. Python 3.10 includes new language syntax that " "is not parsable by lib2to3's LL(1) parser (see :pep:`634`). The ``lib2to3`` " -"module was marked pending for deprecation in Python 3.9 (raising :exc:" -"`PendingDeprecationWarning` on import) and fully deprecated in Python 3.11 " -"(raising :exc:`DeprecationWarning`). It will be removed from the standard " -"library in Python 3.13. Consider third-party alternatives such as `LibCST`_ " -"or `parso`_." +"module was marked pending for deprecation in Python 3.9 " +"(raising :exc:`PendingDeprecationWarning` on import) and fully deprecated in " +"Python 3.11 (raising :exc:`DeprecationWarning`). It will be removed from the " +"standard library in Python 3.13. Consider third-party alternatives such as " +"`LibCST`_ or `parso`_." msgstr "" #: library/2to3.rst:485 diff --git a/library/__future__.po b/library/__future__.po index f483ba8f..c6572ac6 100644 --- a/library/__future__.po +++ b/library/__future__.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/__future__.rst:2 -msgid ":mod:`__future__` --- Future statement definitions" +msgid ":mod:`!__future__` --- Future statement definitions" msgstr "" #: library/__future__.rst:7 @@ -26,10 +27,11 @@ msgstr "" #: library/__future__.rst:11 msgid "" -"Imports of the form ``from __future__ import feature`` are called :ref:" -"`future statements `. These are special-cased by the Python compiler " -"to allow the use of new Python features in modules containing the future " -"statement before the release in which the feature becomes standard." +"Imports of the form ``from __future__ import feature`` are " +"called :ref:`future statements `. These are special-cased by the " +"Python compiler to allow the use of new Python features in modules " +"containing the future statement before the release in which the feature " +"becomes standard." msgstr "" #: library/__future__.rst:16 @@ -57,9 +59,9 @@ msgstr "" #: library/__future__.rst:29 msgid "" "To ensure that :ref:`future statements ` run under releases prior to " -"Python 2.1 at least yield runtime exceptions (the import of :mod:" -"`__future__` will fail, because there was no module of that name prior to " -"2.1)." +"Python 2.1 at least yield runtime exceptions (the import " +"of :mod:`__future__` will fail, because there was no module of that name " +"prior to 2.1)." msgstr "" #: library/__future__.rst:34 @@ -217,12 +219,29 @@ msgstr "" msgid "Each statement in :file:`__future__.py` is of the form::" msgstr "" +#: library/__future__.rst:79 +msgid "" +"FeatureName = _Feature(OptionalRelease, MandatoryRelease,\n" +" CompilerFlag)" +msgstr "" + #: library/__future__.rst:82 msgid "" "where, normally, *OptionalRelease* is less than *MandatoryRelease*, and both " "are 5-tuples of the same form as :data:`sys.version_info`::" msgstr "" +#: library/__future__.rst:85 +msgid "" +"(PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int\n" +" PY_MINOR_VERSION, # the 1; an int\n" +" PY_MICRO_VERSION, # the 0; an int\n" +" PY_RELEASE_LEVEL, # \"alpha\", \"beta\", \"candidate\" or \"final\"; " +"string\n" +" PY_RELEASE_SERIAL # the 3; an int\n" +")" +msgstr "" + #: library/__future__.rst:94 msgid "" "*OptionalRelease* records the first release in which the feature was " @@ -254,8 +273,8 @@ msgstr "" msgid "" "*CompilerFlag* is the (bitfield) flag that should be passed in the fourth " "argument to the built-in function :func:`compile` to enable the feature in " -"dynamically compiled code. This flag is stored in the :attr:`_Feature." -"compiler_flag` attribute on :class:`_Feature` instances." +"dynamically compiled code. This flag is stored in " +"the :attr:`_Feature.compiler_flag` attribute on :class:`_Feature` instances." msgstr "" #: library/__future__.rst:117 @@ -269,7 +288,7 @@ msgid "" "final decision has been made yet. See also :pep:`563` and :pep:`649`." msgstr "" -#: library/__future__.rst:128 +#: library/__future__.rst:127 msgid ":ref:`future`" msgstr "" diff --git a/library/__main__.po b/library/__main__.po index c067f68e..a1016e63 100644 --- a/library/__main__.po +++ b/library/__main__.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/__main__.rst:2 -msgid ":mod:`__main__` --- Top-level code environment" +msgid ":mod:`!__main__` --- Top-level code environment" msgstr "" #: library/__main__.rst:10 @@ -40,8 +41,8 @@ msgstr "" msgid "" "Both of these mechanisms are related to Python modules; how users interact " "with them and how they interact with each other. They are explained in " -"detail below. If you're new to Python modules, see the tutorial section :" -"ref:`tut-modules` for an introduction." +"detail below. If you're new to Python modules, see the tutorial " +"section :ref:`tut-modules` for an introduction." msgstr "" #: library/__main__.rst:25 @@ -55,12 +56,26 @@ msgid "" "the ``.py`` extension::" msgstr "" +#: library/__main__.rst:31 +msgid "" +">>> import configparser\n" +">>> configparser.__name__\n" +"'configparser'" +msgstr "" + #: library/__main__.rst:35 msgid "" "If the file is part of a package, ``__name__`` will also include the parent " "package's path::" msgstr "" +#: library/__main__.rst:38 +msgid "" +">>> from concurrent.futures import process\n" +">>> process.__name__\n" +"'concurrent.futures.process'" +msgstr "" + #: library/__main__.rst:42 msgid "" "However, if the module is executed in the top-level code environment, its " @@ -88,25 +103,63 @@ msgstr "" msgid "the scope of an interactive prompt::" msgstr "" +#: library/__main__.rst:57 +msgid "" +">>> __name__\n" +"'__main__'" +msgstr "" + #: library/__main__.rst:60 msgid "the Python module passed to the Python interpreter as a file argument:" msgstr "" +#: library/__main__.rst:62 +msgid "" +"$ python helloworld.py\n" +"Hello, world!" +msgstr "" + #: library/__main__.rst:67 msgid "" -"the Python module or package passed to the Python interpreter with the :" -"option:`-m` argument:" +"the Python module or package passed to the Python interpreter with " +"the :option:`-m` argument:" +msgstr "" + +#: library/__main__.rst:70 +msgid "" +"$ python -m tarfile\n" +"usage: tarfile.py [-h] [-v] (...)" msgstr "" #: library/__main__.rst:75 msgid "Python code read by the Python interpreter from standard input:" msgstr "" +#: library/__main__.rst:77 +msgid "" +"$ echo \"import this\" | python\n" +"The Zen of Python, by Tim Peters\n" +"\n" +"Beautiful is better than ugly.\n" +"Explicit is better than implicit.\n" +"..." +msgstr "" + #: library/__main__.rst:86 msgid "" "Python code passed to the Python interpreter with the :option:`-c` argument:" msgstr "" +#: library/__main__.rst:88 +msgid "" +"$ python -c \"import this\"\n" +"The Zen of Python, by Tim Peters\n" +"\n" +"Beautiful is better than ugly.\n" +"Explicit is better than implicit.\n" +"..." +msgstr "" + #: library/__main__.rst:97 msgid "" "In each of these situations, the top-level module's ``__name__`` is set to " @@ -121,6 +174,13 @@ msgid "" "from an import statement::" msgstr "" +#: library/__main__.rst:105 +msgid "" +"if __name__ == '__main__':\n" +" # Execute when the module is not initialized from an import statement.\n" +" ..." +msgstr "" + #: library/__main__.rst:111 msgid "" "For a more detailed look at how ``__name__`` is set in all situations, see " @@ -153,6 +213,29 @@ msgid "" "function named ``main`` encapsulates the program's primary behavior::" msgstr "" +#: library/__main__.rst:131 +msgid "" +"# echo.py\n" +"\n" +"import shlex\n" +"import sys\n" +"\n" +"def echo(phrase: str) -> None:\n" +" \"\"\"A dummy wrapper around print.\"\"\"\n" +" # for demonstration purposes, you can imagine that there is some\n" +" # valuable and reusable logic inside this function\n" +" print(phrase)\n" +"\n" +"def main() -> int:\n" +" \"\"\"Echo the input arguments to standard output\"\"\"\n" +" phrase = shlex.join(sys.argv)\n" +" echo(phrase)\n" +" return 0\n" +"\n" +"if __name__ == '__main__':\n" +" sys.exit(main()) # next section explains the use of sys.exit" +msgstr "" + #: library/__main__.rst:151 msgid "" "Note that if the module didn't encapsulate code inside the ``main`` function " @@ -183,12 +266,16 @@ msgid "" "return value of ``main`` is passed into :func:`sys.exit`. For example::" msgstr "" +#: library/__main__.rst:173 +msgid "sys.exit(main())" +msgstr "" + #: library/__main__.rst:175 msgid "" "Since the call to ``main`` is wrapped in :func:`sys.exit`, the expectation " -"is that your function will return some value acceptable as an input to :func:" -"`sys.exit`; typically, an integer or ``None`` (which is implicitly returned " -"if your function does not have a return statement)." +"is that your function will return some value acceptable as an input " +"to :func:`sys.exit`; typically, an integer or ``None`` (which is implicitly " +"returned if your function does not have a return statement)." msgstr "" #: library/__main__.rst:180 @@ -204,8 +291,8 @@ msgid "" "In particular, be careful about returning strings from your ``main`` " "function. :func:`sys.exit` will interpret a string argument as a failure " "message, so your program will have an exit code of ``1``, indicating " -"failure, and the string will be written to :data:`sys.stderr`. The ``echo." -"py`` example from earlier exemplifies using the ``sys.exit(main())`` " +"failure, and the string will be written to :data:`sys.stderr`. The " +"``echo.py`` example from earlier exemplifies using the ``sys.exit(main())`` " "convention." msgstr "" @@ -228,12 +315,24 @@ msgid "" "hypothetical package, \"bandclass\":" msgstr "" +#: library/__main__.rst:206 +msgid "" +"bandclass\n" +" ├── __init__.py\n" +" ├── __main__.py\n" +" └── student.py" +msgstr "" + #: library/__main__.rst:213 msgid "" "``__main__.py`` will be executed when the package itself is invoked directly " "from the command line using the :option:`-m` flag. For example:" msgstr "" +#: library/__main__.rst:216 +msgid "$ python -m bandclass" +msgstr "" + #: library/__main__.rst:220 msgid "" "This command will cause ``__main__.py`` to run. How you utilize this " @@ -242,6 +341,17 @@ msgid "" "for students::" msgstr "" +#: library/__main__.rst:225 +msgid "" +"# bandclass/__main__.py\n" +"\n" +"import sys\n" +"from .student import search_students\n" +"\n" +"student_name = sys.argv[1] if len(sys.argv) >= 2 else ''\n" +"print(f'Found student: {search_students(student_name)}')" +msgstr "" + #: library/__main__.rst:233 msgid "" "Note that ``from .student import search_students`` is an example of a " @@ -265,11 +375,18 @@ msgid "" "attribute will include the package's path if imported::" msgstr "" +#: library/__main__.rst:250 +msgid "" +">>> import asyncio.__main__\n" +">>> asyncio.__main__.__name__\n" +"'asyncio.__main__'" +msgstr "" + #: library/__main__.rst:254 msgid "" -"This won't work for ``__main__.py`` files in the root directory of a .zip " -"file though. Hence, for consistency, minimal ``__main__.py`` like the :mod:" -"`venv` one mentioned below are preferred." +"This won't work for ``__main__.py`` files in the root directory of a " +"``.zip`` file though. Hence, for consistency, a minimal ``__main__.py`` " +"without a ``__name__`` check is preferred." msgstr "" #: library/__main__.rst:260 @@ -309,14 +426,59 @@ msgstr "" msgid "Here is an example module that consumes the ``__main__`` namespace::" msgstr "" +#: library/__main__.rst:284 +msgid "" +"# namely.py\n" +"\n" +"import __main__\n" +"\n" +"def did_user_define_their_name():\n" +" return 'my_name' in dir(__main__)\n" +"\n" +"def print_user_name():\n" +" if not did_user_define_their_name():\n" +" raise ValueError('Define the variable `my_name`!')\n" +"\n" +" if '__file__' in dir(__main__):\n" +" print(__main__.my_name, \"found in file\", __main__.__file__)\n" +" else:\n" +" print(__main__.my_name)" +msgstr "" + #: library/__main__.rst:300 msgid "Example usage of this module could be as follows::" msgstr "" +#: library/__main__.rst:302 +msgid "" +"# start.py\n" +"\n" +"import sys\n" +"\n" +"from namely import print_user_name\n" +"\n" +"# my_name = \"Dinsdale\"\n" +"\n" +"def main():\n" +" try:\n" +" print_user_name()\n" +" except ValueError as ve:\n" +" return str(ve)\n" +"\n" +"if __name__ == \"__main__\":\n" +" sys.exit(main())" +msgstr "" + #: library/__main__.rst:319 msgid "Now, if we started our program, the result would look like this:" msgstr "" +#: library/__main__.rst:321 +msgid "" +"$ python start.py\n" +"Define the variable `my_name`!" +msgstr "" + #: library/__main__.rst:326 msgid "" "The exit code of the program would be 1, indicating an error. Uncommenting " @@ -324,6 +486,12 @@ msgid "" "with status code 0, indicating success:" msgstr "" +#: library/__main__.rst:330 +msgid "" +"$ python start.py\n" +"Dinsdale found in file /path/to/start.py" +msgstr "" + #: library/__main__.rst:335 msgid "" "Note that importing ``__main__`` doesn't cause any issues with " @@ -351,6 +519,22 @@ msgid "" "anything defined in the REPL becomes part of the ``__main__`` scope::" msgstr "" +#: library/__main__.rst:351 +msgid "" +">>> import namely\n" +">>> namely.did_user_define_their_name()\n" +"False\n" +">>> namely.print_user_name()\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: Define the variable `my_name`!\n" +">>> my_name = 'Jabberwocky'\n" +">>> namely.did_user_define_their_name()\n" +"True\n" +">>> namely.print_user_name()\n" +"Jabberwocky" +msgstr "" + #: library/__main__.rst:364 msgid "" "Note that in this case the ``__main__`` scope doesn't contain a ``__file__`` " @@ -359,6 +543,6 @@ msgstr "" #: library/__main__.rst:367 msgid "" -"The ``__main__`` scope is used in the implementation of :mod:`pdb` and :mod:" -"`rlcompleter`." +"The ``__main__`` scope is used in the implementation of :mod:`pdb` " +"and :mod:`rlcompleter`." msgstr "" diff --git a/library/_thread.po b/library/_thread.po index 8b7f30f7..2c6b0983 100644 --- a/library/_thread.po +++ b/library/_thread.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/_thread.rst:2 -msgid ":mod:`_thread` --- Low-level threading API" +msgid ":mod:`!_thread` --- Low-level threading API" msgstr "" #: library/_thread.rst:15 @@ -63,10 +64,11 @@ msgstr "" #: library/_thread.rst:52 msgid "" -"When the function terminates with an unhandled exception, :func:`sys." -"unraisablehook` is called to handle the exception. The *object* attribute of " -"the hook argument is *function*. By default, a stack trace is printed and " -"then the thread exits (but other threads continue to run)." +"When the function terminates with an unhandled " +"exception, :func:`sys.unraisablehook` is called to handle the exception. The " +"*object* attribute of the hook argument is *function*. By default, a stack " +"trace is printed and then the thread exits (but other threads continue to " +"run)." msgstr "" #: library/_thread.rst:57 @@ -100,8 +102,9 @@ msgstr "" #: library/_thread.rst:75 msgid "" -"If the given signal isn't handled by Python (it was set to :const:`signal." -"SIG_DFL` or :const:`signal.SIG_IGN`), this function does nothing." +"If the given signal isn't handled by Python (it was set " +"to :const:`signal.SIG_DFL` or :const:`signal.SIG_IGN`), this function does " +"nothing." msgstr "" #: library/_thread.rst:79 @@ -144,10 +147,8 @@ msgid "" "after which the value may be recycled by the OS)." msgstr "" -#: library/_thread.rst:123 -msgid "" -":ref:`Availability `: Windows, FreeBSD, Linux, macOS, OpenBSD, " -"NetBSD, AIX, DragonFlyBSD." +#: library/_thread.rst:145 +msgid "Availability" msgstr "" #: library/_thread.rst:130 @@ -156,9 +157,9 @@ msgid "" "*size* argument specifies the stack size to be used for subsequently created " "threads, and must be 0 (use platform or configured default) or a positive " "integer value of at least 32,768 (32 KiB). If *size* is not specified, 0 is " -"used. If changing the thread stack size is unsupported, a :exc:" -"`RuntimeError` is raised. If the specified stack size is invalid, a :exc:" -"`ValueError` is raised and the stack size is unmodified. 32 KiB is " +"used. If changing the thread stack size is unsupported, " +"a :exc:`RuntimeError` is raised. If the specified stack size is invalid, " +"a :exc:`ValueError` is raised and the stack size is unmodified. 32 KiB is " "currently the minimum supported stack size value to guarantee sufficient " "stack space for the interpreter itself. Note that some platforms may have " "particular restrictions on values for the stack size, such as requiring a " @@ -169,10 +170,6 @@ msgid "" "information)." msgstr "" -#: library/_thread.rst:145 -msgid ":ref:`Availability `: Windows, pthreads." -msgstr "" - #: library/_thread.rst:147 msgid "Unix platforms with POSIX threads support." msgstr "" @@ -199,8 +196,8 @@ msgstr "" #: library/_thread.rst:168 msgid "" "If the *blocking* argument is present, the action depends on its value: if " -"it is False, the lock is only acquired if it can be acquired immediately " -"without waiting, while if it is True, the lock is acquired unconditionally " +"it is false, the lock is only acquired if it can be acquired immediately " +"without waiting, while if it is true, the lock is acquired unconditionally " "as above." msgstr "" @@ -209,7 +206,7 @@ msgid "" "If the floating-point *timeout* argument is present and positive, it " "specifies the maximum wait time in seconds before returning. A negative " "*timeout* argument specifies an unbounded wait. You cannot specify a " -"*timeout* if *blocking* is False." +"*timeout* if *blocking* is false." msgstr "" #: library/_thread.rst:178 @@ -240,8 +237,18 @@ msgstr "" #: library/_thread.rst:199 msgid "" -"In addition to these methods, lock objects can also be used via the :keyword:" -"`with` statement, e.g.::" +"In addition to these methods, lock objects can also be used via " +"the :keyword:`with` statement, e.g.::" +msgstr "" + +#: library/_thread.rst:202 +msgid "" +"import _thread\n" +"\n" +"a_lock = _thread.allocate_lock()\n" +"\n" +"with a_lock:\n" +" print(\"a_lock is locked while this executes\")" msgstr "" #: library/_thread.rst:209 @@ -250,36 +257,31 @@ msgstr "" #: library/_thread.rst:213 msgid "" -"Threads interact strangely with interrupts: the :exc:`KeyboardInterrupt` " -"exception will be received by an arbitrary thread. (When the :mod:`signal` " -"module is available, interrupts always go to the main thread.)" +"Interrupts always go to the main thread (the :exc:`KeyboardInterrupt` " +"exception will be received by that thread.)" msgstr "" -#: library/_thread.rst:217 +#: library/_thread.rst:216 msgid "" "Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is " "equivalent to calling :func:`_thread.exit`." msgstr "" -#: library/_thread.rst:220 +#: library/_thread.rst:219 msgid "" -"It is not possible to interrupt the :meth:`~threading.Lock.acquire` method " -"on a lock --- the :exc:`KeyboardInterrupt` exception will happen after the " -"lock has been acquired." +"It is platform-dependent whether the :meth:`~threading.Lock.acquire` method " +"on a lock can be interrupted (so that the :exc:`KeyboardInterrupt` exception " +"will happen immediately, rather than only after the lock has been acquired " +"or the operation has timed out). It can be interrupted on POSIX, but not on " +"Windows." msgstr "" -#: library/_thread.rst:224 +#: library/_thread.rst:225 msgid "" "When the main thread exits, it is system defined whether the other threads " -"survive. On most systems, they are killed without executing :keyword:" -"`try` ... :keyword:`finally` clauses or executing object destructors." -msgstr "" - -#: library/_thread.rst:229 -msgid "" -"When the main thread exits, it does not do any of its usual cleanup (except " -"that :keyword:`try` ... :keyword:`finally` clauses are honored), and the " -"standard I/O files are not flushed." +"survive. On most systems, they are killed without " +"executing :keyword:`try` ... :keyword:`finally` clauses or executing object " +"destructors." msgstr "" #: library/_thread.rst:7 diff --git a/library/abc.po b/library/abc.po index 476d681c..178ff30e 100644 --- a/library/abc.po +++ b/library/abc.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/abc.rst:2 -msgid ":mod:`abc` --- Abstract Base Classes" +msgid ":mod:`!abc` --- Abstract Base Classes" msgstr "" #: library/abc.rst:11 @@ -28,17 +29,18 @@ msgstr "" msgid "" "This module provides the infrastructure for defining :term:`abstract base " "classes ` (ABCs) in Python, as outlined in :pep:`3119`; " -"see the PEP for why this was added to Python. (See also :pep:`3141` and the :" -"mod:`numbers` module regarding a type hierarchy for numbers based on ABCs.)" +"see the PEP for why this was added to Python. (See also :pep:`3141` and " +"the :mod:`numbers` module regarding a type hierarchy for numbers based on " +"ABCs.)" msgstr "" #: library/abc.rst:20 msgid "" "The :mod:`collections` module has some concrete classes that derive from " -"ABCs; these can, of course, be further derived. In addition, the :mod:" -"`collections.abc` submodule has some ABCs that can be used to test whether a " -"class or instance provides a particular interface, for example, if it is :" -"term:`hashable` or if it is a :term:`mapping`." +"ABCs; these can, of course, be further derived. In addition, " +"the :mod:`collections.abc` submodule has some ABCs that can be used to test " +"whether a class or instance provides a particular interface, for example, if " +"it is :term:`hashable` or if it is a :term:`mapping`." msgstr "" #: library/abc.rst:27 @@ -54,6 +56,14 @@ msgid "" "avoiding sometimes confusing metaclass usage, for example::" msgstr "" +#: library/abc.rst:36 +msgid "" +"from abc import ABC\n" +"\n" +"class MyABC(ABC):\n" +" pass" +msgstr "" + #: library/abc.rst:41 msgid "" "Note that the type of :class:`!ABC` is still :class:`ABCMeta`, therefore " @@ -63,6 +73,14 @@ msgid "" "and using :class:`!ABCMeta` directly, for example::" msgstr "" +#: library/abc.rst:47 +msgid "" +"from abc import ABCMeta\n" +"\n" +"class MyABC(metaclass=ABCMeta):\n" +" pass" +msgstr "" + #: library/abc.rst:57 msgid "Metaclass for defining Abstract Base Classes (ABCs)." msgstr "" @@ -90,14 +108,27 @@ msgid "" "Register *subclass* as a \"virtual subclass\" of this ABC. For example::" msgstr "" +#: library/abc.rst:75 +msgid "" +"from abc import ABC\n" +"\n" +"class MyABC(ABC):\n" +" pass\n" +"\n" +"MyABC.register(tuple)\n" +"\n" +"assert issubclass(tuple, MyABC)\n" +"assert isinstance((), MyABC)" +msgstr "" + #: library/abc.rst:85 msgid "Returns the registered subclass, to allow usage as a class decorator." msgstr "" #: library/abc.rst:88 msgid "" -"To detect calls to :meth:`!register`, you can use the :func:" -"`get_cache_token` function." +"To detect calls to :meth:`!register`, you can use " +"the :func:`get_cache_token` function." msgstr "" #: library/abc.rst:92 @@ -113,8 +144,8 @@ msgid "" "Check whether *subclass* is considered a subclass of this ABC. This means " "that you can customize the behavior of :func:`issubclass` further without " "the need to call :meth:`register` on every class you want to consider a " -"subclass of the ABC. (This class method is called from the :meth:`~class." -"__subclasscheck__` method of the ABC.)" +"subclass of the ABC. (This class method is called from " +"the :meth:`~type.__subclasscheck__` method of the ABC.)" msgstr "" #: library/abc.rst:104 @@ -131,21 +162,52 @@ msgid "" "For a demonstration of these concepts, look at this example ABC definition::" msgstr "" +#: library/abc.rst:116 +msgid "" +"class Foo:\n" +" def __getitem__(self, index):\n" +" ...\n" +" def __len__(self):\n" +" ...\n" +" def get_iterator(self):\n" +" return iter(self)\n" +"\n" +"class MyIterable(ABC):\n" +"\n" +" @abstractmethod\n" +" def __iter__(self):\n" +" while False:\n" +" yield None\n" +"\n" +" def get_iterator(self):\n" +" return self.__iter__()\n" +"\n" +" @classmethod\n" +" def __subclasshook__(cls, C):\n" +" if cls is MyIterable:\n" +" if any(\"__iter__\" in B.__dict__ for B in C.__mro__):\n" +" return True\n" +" return NotImplemented\n" +"\n" +"MyIterable.register(Foo)" +msgstr "" + #: library/abc.rst:143 msgid "" -"The ABC ``MyIterable`` defines the standard iterable method, :meth:" -"`~iterator.__iter__`, as an abstract method. The implementation given here " -"can still be called from subclasses. The :meth:`!get_iterator` method is " -"also part of the ``MyIterable`` abstract base class, but it does not have to " -"be overridden in non-abstract derived classes." +"The ABC ``MyIterable`` defines the standard iterable " +"method, :meth:`~iterator.__iter__`, as an abstract method. The " +"implementation given here can still be called from subclasses. The :meth:`!" +"get_iterator` method is also part of the ``MyIterable`` abstract base class, " +"but it does not have to be overridden in non-abstract derived classes." msgstr "" #: library/abc.rst:149 msgid "" "The :meth:`__subclasshook__` class method defined here says that any class " -"that has an :meth:`~iterator.__iter__` method in its :attr:`~object." -"__dict__` (or in that of one of its base classes, accessed via the :attr:" -"`~class.__mro__` list) is considered a ``MyIterable`` too." +"that has an :meth:`~iterator.__iter__` method in " +"its :attr:`~object.__dict__` (or in that of one of its base classes, " +"accessed via the :attr:`~type.__mro__` list) is considered a ``MyIterable`` " +"too." msgstr "" #: library/abc.rst:154 @@ -193,6 +255,39 @@ msgid "" "the following usage examples::" msgstr "" +#: library/abc.rst:187 +msgid "" +"class C(ABC):\n" +" @abstractmethod\n" +" def my_abstract_method(self, arg1):\n" +" ...\n" +" @classmethod\n" +" @abstractmethod\n" +" def my_abstract_classmethod(cls, arg2):\n" +" ...\n" +" @staticmethod\n" +" @abstractmethod\n" +" def my_abstract_staticmethod(arg3):\n" +" ...\n" +"\n" +" @property\n" +" @abstractmethod\n" +" def my_abstract_property(self):\n" +" ...\n" +" @my_abstract_property.setter\n" +" @abstractmethod\n" +" def my_abstract_property(self, val):\n" +" ...\n" +"\n" +" @abstractmethod\n" +" def _get_x(self):\n" +" ...\n" +" @abstractmethod\n" +" def _set_x(self, val):\n" +" ...\n" +" x = property(_get_x, _set_x)" +msgstr "" + #: library/abc.rst:217 msgid "" "In order to correctly interoperate with the abstract base class machinery, " @@ -202,6 +297,16 @@ msgid "" "Python's built-in :class:`property` does the equivalent of::" msgstr "" +#: library/abc.rst:223 +msgid "" +"class Descriptor:\n" +" ...\n" +" @property\n" +" def __isabstractmethod__(self):\n" +" return any(getattr(f, '__isabstractmethod__', False) for\n" +" f in (self._fget, self._fset, self._fdel))" +msgstr "" + #: library/abc.rst:232 msgid "" "Unlike Java abstract methods, these abstract methods may have an " @@ -233,6 +338,15 @@ msgid "" "correctly identified as abstract when applied to an abstract method::" msgstr "" +#: library/abc.rst:255 +msgid "" +"class C(ABC):\n" +" @classmethod\n" +" @abstractmethod\n" +" def my_abstract_classmethod(cls, arg):\n" +" ..." +msgstr "" + #: library/abc.rst:265 msgid "" "It is now possible to use :class:`staticmethod` with :func:`abstractmethod`, " @@ -251,11 +365,21 @@ msgid "" "now correctly identified as abstract when applied to an abstract method::" msgstr "" +#: library/abc.rst:276 +msgid "" +"class C(ABC):\n" +" @staticmethod\n" +" @abstractmethod\n" +" def my_abstract_staticmethod(arg):\n" +" ..." +msgstr "" + #: library/abc.rst:285 msgid "" -"It is now possible to use :class:`property`, :meth:`property.getter`, :meth:" -"`property.setter` and :meth:`property.deleter` with :func:`abstractmethod`, " -"making this decorator redundant." +"It is now possible to " +"use :class:`property`, :meth:`property.getter`, :meth:`property.setter` " +"and :meth:`property.deleter` with :func:`abstractmethod`, making this " +"decorator redundant." msgstr "" #: library/abc.rst:290 @@ -269,6 +393,15 @@ msgid "" "correctly identified as abstract when applied to an abstract method::" msgstr "" +#: library/abc.rst:297 +msgid "" +"class C(ABC):\n" +" @property\n" +" @abstractmethod\n" +" def my_abstract_property(self):\n" +" ..." +msgstr "" + #: library/abc.rst:303 msgid "" "The above example defines a read-only property; you can also define a read-" @@ -276,12 +409,33 @@ msgid "" "underlying methods as abstract::" msgstr "" +#: library/abc.rst:307 +msgid "" +"class C(ABC):\n" +" @property\n" +" def x(self):\n" +" ...\n" +"\n" +" @x.setter\n" +" @abstractmethod\n" +" def x(self, val):\n" +" ..." +msgstr "" + #: library/abc.rst:317 msgid "" "If only some components are abstract, only those components need to be " "updated to create a concrete property in a subclass::" msgstr "" +#: library/abc.rst:320 +msgid "" +"class D(C):\n" +" @C.x.setter\n" +" def x(self, val):\n" +" ..." +msgstr "" + #: library/abc.rst:326 msgid "The :mod:`!abc` module also provides the following functions:" msgstr "" diff --git a/library/aifc.po b/library/aifc.po index 198ac452..7fc66a9f 100644 --- a/library/aifc.po +++ b/library/aifc.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-12-23 14:33+0200\n" "Last-Translator: Marios Giannopoulos \n" "Language-Team: PyGreece \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,7 +25,7 @@ msgstr ":mod:`aifc` --- Ανάγνωση και εγγραφή AIFF και AIFC msgid "**Source code:** :source:`Lib/aifc.py`" msgstr "**Πηγαίος κώδικας:** :source:`Lib/aifc.py`" -#: library/aifc.rst:19 +#: library/aifc.rst:16 msgid "" "The :mod:`aifc` module is deprecated (see :pep:`PEP 594 <594#aifc>` for " "details)." @@ -89,23 +90,24 @@ msgid "" "opened for writing. If omitted, ``file.mode`` is used if it exists, " "otherwise ``'rb'`` is used. When used for writing, the file object should " "be seekable, unless you know ahead of time how many samples you are going to " -"write in total and use :meth:`writeframesraw` and :meth:`setnframes`. The :" -"func:`.open` function may be used in a :keyword:`with` statement. When the :" -"keyword:`!with` block completes, the :meth:`~aifc.close` method is called." +"write in total and use :meth:`writeframesraw` and :meth:`setnframes`. " +"The :func:`.open` function may be used in a :keyword:`with` statement. When " +"the :keyword:`!with` block completes, the :meth:`~aifc.close` method is " +"called." msgstr "" "Ανοίγει ένα αρχείο AIFF ή AIFF-C και επιστρέφει ένα στιγμιότυπο αντικειμένου " "με μεθόδους που περιγράφονται παρακάτω. Η παράμετρος *file* είναι είτε μια " "συμβολοσειρά που καθορίζει το όνομα του αρχείου είτε ένα :term:`file " "object`. Η παράμετρος *mode* πρέπει να είναι ``'r'`` ή ``'rb'`` όταν το " "αρχείο πρέπει να ανοίξει για ανάγνωση, ή ``'w'`` ή ``'wb'`` όταν το αρχείο " -"πρέπει να ανοίξει για εγγραφή. Αν παραληφθεί, χρησιμοποιείται το ``file." -"mode`` αν υπάρχει, διαφορετικά χρησιμοποιείται το ``'rb'``. Όταν " +"πρέπει να ανοίξει για εγγραφή. Αν παραληφθεί, χρησιμοποιείται το " +"``file.mode`` αν υπάρχει, διαφορετικά χρησιμοποιείται το ``'rb'``. Όταν " "χρησιμοποιείται για εγγραφή, το αντικείμενο αρχείου θα πρέπει να είναι " "αναζητήσιμο, εκτός αν γνωρίζετε εκ των προτέρων πόσα δείγματα θα γράψετε " -"συνολικά και χρησιμοποιήσετε τις μεθόδους :meth:`writeframesraw` και :meth:" -"`setnframes`. Η συνάρτηση :func:`.open` μπορεί να χρησιμοποιηθεί σε μια " -"δήλωση :keyword:`with`. Όταν ολοκληρωθεί το μπλοκ :keyword:`!with`, καλείται " -"η μέθοδος :meth:`~aifc.close`." +"συνολικά και χρησιμοποιήσετε τις μεθόδους :meth:`writeframesraw` " +"και :meth:`setnframes`. Η συνάρτηση :func:`.open` μπορεί να χρησιμοποιηθεί " +"σε μια δήλωση :keyword:`with`. Όταν ολοκληρωθεί το μπλοκ :keyword:`!with`, " +"καλείται η μέθοδος :meth:`~aifc.close`." #: library/aifc.rst:56 msgid "Support for the :keyword:`with` statement was added." @@ -160,8 +162,8 @@ msgstr "" #: library/aifc.rst:99 msgid "" "Returns a :func:`~collections.namedtuple` ``(nchannels, sampwidth, " -"framerate, nframes, comptype, compname)``, equivalent to output of the :meth:" -"`get\\*` methods." +"framerate, nframes, comptype, compname)``, equivalent to output of " +"the :meth:`get\\*` methods." msgstr "" "Επιστρέφει μια πλειάδα :func:`~collections.namedtuple` ``(nchannels, " "sampwidth, framerate, nframes, comptype, compname)``, η οποία είναι " @@ -235,9 +237,9 @@ msgstr "" "αρχείο ανοίγεται για εγγραφή έχουν όλες τις παραπάνω μεθόδους, εκτός από τις " "μεθόδους :meth:`readframes` και :meth:`setpos`. Επίσης, υπάρχουν οι εξής " "μέθοδοι. Οι μέθοδοι :meth:`get\\*` μπορούν να κληθούν μόνο αφού έχουν κληθεί " -"οι αντίστοιχες μέθοδοι :meth:`set\\*`. Πριν την πρώτη κλήση των μεθόδων :" -"meth:`writeframes` ή :meth:`writeframesraw`, όλες οι παράμετροι εκτός από " -"τον αριθμό των καρέ πρέπει να είναι συμπληρωμένες." +"οι αντίστοιχες μέθοδοι :meth:`set\\*`. Πριν την πρώτη κλήση των " +"μεθόδων :meth:`writeframes` ή :meth:`writeframesraw`, όλες οι παράμετροι " +"εκτός από τον αριθμό των καρέ πρέπει να είναι συμπληρωμένες." #: library/aifc.rst:156 msgid "" @@ -305,8 +307,8 @@ msgid "" msgstr "" "Ορίζει όλες τις παραμέτρους παραπάνω ταυτόχρονα. Η παράμετρος είναι μια " "πλειάδα που αποτελείται από τις διάφορες παραμέτρους. Αυτό σημαίνει ότι " -"είναι δυνατό να χρησιμοποιηθεί το αποτέλεσμα μιας κλήσης μεθόδου :meth:" -"`getparams` ως παράμετρος στην μέθοδο :meth:`setparams`." +"είναι δυνατό να χρησιμοποιηθεί το αποτέλεσμα μιας κλήσης " +"μεθόδου :meth:`getparams` ως παράμετρος στην μέθοδο :meth:`setparams`." #: library/aifc.rst:212 msgid "" diff --git a/library/allos.po b/library/allos.po index 03258fc1..cacdfe45 100644 --- a/library/allos.po +++ b/library/allos.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/archiving.po b/library/archiving.po index f0cd772a..eaa838cf 100644 --- a/library/archiving.po +++ b/library/archiving.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,6 +25,6 @@ msgstr "" msgid "" "The modules described in this chapter support data compression with the " "zlib, gzip, bzip2 and lzma algorithms, and the creation of ZIP- and tar-" -"format archives. See also :ref:`archiving-operations` provided by the :mod:" -"`shutil` module." +"format archives. See also :ref:`archiving-operations` provided by " +"the :mod:`shutil` module." msgstr "" diff --git a/library/argparse.po b/library/argparse.po index 97951801..17bb4673 100644 --- a/library/argparse.po +++ b/library/argparse.po @@ -8,18 +8,19 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/argparse.rst:2 msgid "" -":mod:`argparse` --- Parser for command-line options, arguments and sub-" -"commands" +":mod:`!argparse` --- Parser for command-line options, arguments and " +"subcommands" msgstr "" #: library/argparse.rst:12 @@ -33,550 +34,532 @@ msgstr "" #: library/argparse.rst:18 msgid "" "This page contains the API reference information. For a more gentle " -"introduction to Python command-line parsing, have a look at the :ref:" -"`argparse tutorial `." +"introduction to Python command-line parsing, have a look at " +"the :ref:`argparse tutorial `." msgstr "" #: library/argparse.rst:22 msgid "" -"The :mod:`argparse` module makes it easy to write user-friendly command-line " -"interfaces. The program defines what arguments it requires, and :mod:" -"`argparse` will figure out how to parse those out of :data:`sys.argv`. The :" -"mod:`argparse` module also automatically generates help and usage messages. " -"The module will also issue errors when users give the program invalid " -"arguments." +"The :mod:`!argparse` module makes it easy to write user-friendly command-" +"line interfaces. The program defines what arguments it requires, and :mod:`!" +"argparse` will figure out how to parse those out of :data:`sys.argv`. " +"The :mod:`!argparse` module also automatically generates help and usage " +"messages. The module will also issue errors when users give the program " +"invalid arguments." msgstr "" -#: library/argparse.rst:30 -msgid "Core Functionality" -msgstr "" - -#: library/argparse.rst:32 +#: library/argparse.rst:28 msgid "" -"The :mod:`argparse` module's support for command-line interfaces is built " +"The :mod:`!argparse` module's support for command-line interfaces is built " "around an instance of :class:`argparse.ArgumentParser`. It is a container " "for argument specifications and has options that apply to the parser as " "whole::" msgstr "" -#: library/argparse.rst:41 -msgid "" -"The :meth:`ArgumentParser.add_argument` method attaches individual argument " -"specifications to the parser. It supports positional arguments, options " -"that accept values, and on/off flags::" -msgstr "" - -#: library/argparse.rst:50 -msgid "" -"The :meth:`ArgumentParser.parse_args` method runs the parser and places the " -"extracted data in a :class:`argparse.Namespace` object::" -msgstr "" - -#: library/argparse.rst:58 -msgid "Quick Links for add_argument()" -msgstr "" - -#: library/argparse.rst:61 -msgid "Name" -msgstr "" - -#: library/argparse.rst:61 -msgid "Description" -msgstr "" - -#: library/argparse.rst:61 -msgid "Values" -msgstr "" - -#: library/argparse.rst:63 -msgid "action_" -msgstr "" - -#: library/argparse.rst:63 -msgid "Specify how an argument should be handled" -msgstr "" - -#: library/argparse.rst:63 -msgid "" -"``'store'``, ``'store_const'``, ``'store_true'``, ``'append'``, " -"``'append_const'``, ``'count'``, ``'help'``, ``'version'``" -msgstr "" - -#: library/argparse.rst:64 -msgid "choices_" -msgstr "" - -#: library/argparse.rst:64 -msgid "Limit values to a specific set of choices" -msgstr "" - -#: library/argparse.rst:64 -msgid "" -"``['foo', 'bar']``, ``range(1, 10)``, or :class:`~collections.abc.Container` " -"instance" -msgstr "" - -#: library/argparse.rst:65 -msgid "const_" -msgstr "" - -#: library/argparse.rst:65 -msgid "Store a constant value" -msgstr "" - -#: library/argparse.rst:66 -msgid "default_" -msgstr "" - -#: library/argparse.rst:66 -msgid "Default value used when an argument is not provided" -msgstr "" - -#: library/argparse.rst:66 -msgid "Defaults to ``None``" -msgstr "" - -#: library/argparse.rst:67 -msgid "dest_" -msgstr "" - -#: library/argparse.rst:67 -msgid "Specify the attribute name used in the result namespace" -msgstr "" - -#: library/argparse.rst:68 -msgid "help_" -msgstr "" - -#: library/argparse.rst:68 -msgid "Help message for an argument" -msgstr "" - -#: library/argparse.rst:69 -msgid "metavar_" -msgstr "" - -#: library/argparse.rst:69 -msgid "Alternate display name for the argument as shown in help" -msgstr "" - -#: library/argparse.rst:70 -msgid "nargs_" -msgstr "" - -#: library/argparse.rst:70 -msgid "Number of times the argument can be used" -msgstr "" - -#: library/argparse.rst:70 -msgid ":class:`int`, ``'?'``, ``'*'``, or ``'+'``" -msgstr "" - -#: library/argparse.rst:71 -msgid "required_" -msgstr "" - -#: library/argparse.rst:71 -msgid "Indicate whether an argument is required or optional" -msgstr "" - -#: library/argparse.rst:71 -msgid "``True`` or ``False``" -msgstr "" - -#: library/argparse.rst:72 -msgid ":ref:`type `" -msgstr "" - -#: library/argparse.rst:72 -msgid "Automatically convert an argument to the given type" -msgstr "" - -#: library/argparse.rst:72 -msgid "" -":class:`int`, :class:`float`, ``argparse.FileType('w')``, or callable " -"function" -msgstr "" - -#: library/argparse.rst:77 -msgid "Example" -msgstr "" - -#: library/argparse.rst:79 -msgid "" -"The following code is a Python program that takes a list of integers and " -"produces either the sum or the max::" -msgstr "" - -#: library/argparse.rst:94 -msgid "" -"Assuming the above Python code is saved into a file called ``prog.py``, it " -"can be run at the command line and it provides useful help messages:" -msgstr "" - -#: library/argparse.rst:111 +#: library/argparse.rst:32 msgid "" -"When run with the appropriate arguments, it prints either the sum or the max " -"of the command-line integers:" -msgstr "" - -#: library/argparse.rst:122 -msgid "If invalid arguments are passed in, an error will be displayed:" -msgstr "" - -#: library/argparse.rst:130 -msgid "The following sections walk you through this example." -msgstr "" - -#: library/argparse.rst:134 -msgid "Creating a parser" +"parser = argparse.ArgumentParser(\n" +" prog='ProgramName',\n" +" description='What the program does',\n" +" epilog='Text at the bottom of help')" msgstr "" -#: library/argparse.rst:136 +#: library/argparse.rst:37 msgid "" -"The first step in using the :mod:`argparse` is creating an :class:" -"`ArgumentParser` object::" +"The :meth:`ArgumentParser.add_argument` method attaches individual argument " +"specifications to the parser. It supports positional arguments, options " +"that accept values, and on/off flags::" msgstr "" -#: library/argparse.rst:141 +#: library/argparse.rst:41 msgid "" -"The :class:`ArgumentParser` object will hold all the information necessary " -"to parse the command line into Python data types." +"parser.add_argument('filename') # positional argument\n" +"parser.add_argument('-c', '--count') # option that takes a value\n" +"parser.add_argument('-v', '--verbose',\n" +" action='store_true') # on/off flag" msgstr "" -#: library/argparse.rst:146 -msgid "Adding arguments" -msgstr "" - -#: library/argparse.rst:148 +#: library/argparse.rst:46 msgid "" -"Filling an :class:`ArgumentParser` with information about program arguments " -"is done by making calls to the :meth:`~ArgumentParser.add_argument` method. " -"Generally, these calls tell the :class:`ArgumentParser` how to take the " -"strings on the command line and turn them into objects. This information is " -"stored and used when :meth:`~ArgumentParser.parse_args` is called. For " -"example::" +"The :meth:`ArgumentParser.parse_args` method runs the parser and places the " +"extracted data in a :class:`argparse.Namespace` object::" msgstr "" -#: library/argparse.rst:160 +#: library/argparse.rst:49 msgid "" -"Later, calling :meth:`~ArgumentParser.parse_args` will return an object with " -"two attributes, ``integers`` and ``accumulate``. The ``integers`` attribute " -"will be a list of one or more integers, and the ``accumulate`` attribute " -"will be either the :func:`sum` function, if ``--sum`` was specified at the " -"command line, or the :func:`max` function if it was not." -msgstr "" - -#: library/argparse.rst:168 -msgid "Parsing arguments" +"args = parser.parse_args()\n" +"print(args.filename, args.count, args.verbose)" msgstr "" -#: library/argparse.rst:170 +#: library/argparse.rst:53 msgid "" -":class:`ArgumentParser` parses arguments through the :meth:`~ArgumentParser." -"parse_args` method. This will inspect the command line, convert each " -"argument to the appropriate type and then invoke the appropriate action. In " -"most cases, this means a simple :class:`Namespace` object will be built up " -"from attributes parsed out of the command line::" +"If you're looking for a guide about how to upgrade :mod:`optparse` code " +"to :mod:`!argparse`, see :ref:`Upgrading Optparse Code `." msgstr "" -#: library/argparse.rst:179 -msgid "" -"In a script, :meth:`~ArgumentParser.parse_args` will typically be called " -"with no arguments, and the :class:`ArgumentParser` will automatically " -"determine the command-line arguments from :data:`sys.argv`." -msgstr "" - -#: library/argparse.rst:185 +#: library/argparse.rst:57 msgid "ArgumentParser objects" msgstr "" -#: library/argparse.rst:194 +#: library/argparse.rst:66 msgid "" "Create a new :class:`ArgumentParser` object. All parameters should be passed " "as keyword arguments. Each parameter has its own more detailed description " "below, but in short they are:" msgstr "" -#: library/argparse.rst:198 +#: library/argparse.rst:70 msgid "" "prog_ - The name of the program (default: ``os.path.basename(sys.argv[0])``)" msgstr "" -#: library/argparse.rst:201 +#: library/argparse.rst:73 msgid "" "usage_ - The string describing the program usage (default: generated from " "arguments added to parser)" msgstr "" -#: library/argparse.rst:204 +#: library/argparse.rst:76 msgid "" "description_ - Text to display before the argument help (by default, no text)" msgstr "" -#: library/argparse.rst:207 +#: library/argparse.rst:79 msgid "epilog_ - Text to display after the argument help (by default, no text)" msgstr "" -#: library/argparse.rst:209 +#: library/argparse.rst:81 msgid "" "parents_ - A list of :class:`ArgumentParser` objects whose arguments should " "also be included" msgstr "" -#: library/argparse.rst:212 +#: library/argparse.rst:84 msgid "formatter_class_ - A class for customizing the help output" msgstr "" -#: library/argparse.rst:214 +#: library/argparse.rst:86 msgid "" "prefix_chars_ - The set of characters that prefix optional arguments " "(default: '-')" msgstr "" -#: library/argparse.rst:217 +#: library/argparse.rst:89 msgid "" "fromfile_prefix_chars_ - The set of characters that prefix files from which " "additional arguments should be read (default: ``None``)" msgstr "" -#: library/argparse.rst:220 +#: library/argparse.rst:92 msgid "" "argument_default_ - The global default value for arguments (default: " "``None``)" msgstr "" -#: library/argparse.rst:223 +#: library/argparse.rst:95 msgid "" "conflict_handler_ - The strategy for resolving conflicting optionals " "(usually unnecessary)" msgstr "" -#: library/argparse.rst:226 +#: library/argparse.rst:98 msgid "" "add_help_ - Add a ``-h/--help`` option to the parser (default: ``True``)" msgstr "" -#: library/argparse.rst:228 +#: library/argparse.rst:100 msgid "" "allow_abbrev_ - Allows long options to be abbreviated if the abbreviation is " "unambiguous. (default: ``True``)" msgstr "" -#: library/argparse.rst:231 +#: library/argparse.rst:103 msgid "" -"exit_on_error_ - Determines whether or not ArgumentParser exits with error " -"info when an error occurs. (default: ``True``)" +"exit_on_error_ - Determines whether or not :class:`!ArgumentParser` exits " +"with error info when an error occurs. (default: ``True``)" msgstr "" -#: library/argparse.rst:234 +#: library/argparse.rst:106 msgid "*allow_abbrev* parameter was added." msgstr "" -#: library/argparse.rst:237 +#: library/argparse.rst:109 msgid "" "In previous versions, *allow_abbrev* also disabled grouping of short flags " "such as ``-vv`` to mean ``-v -v``." msgstr "" -#: library/argparse.rst:241 +#: library/argparse.rst:113 msgid "*exit_on_error* parameter was added." msgstr "" -#: library/argparse.rst:780 +#: library/argparse.rst:596 msgid "The following sections describe how each of these are used." msgstr "" -#: library/argparse.rst:250 +#: library/argparse.rst:122 msgid "prog" msgstr "" -#: library/argparse.rst:252 +#: library/argparse.rst:125 msgid "" -"By default, :class:`ArgumentParser` objects use ``sys.argv[0]`` to determine " -"how to display the name of the program in help messages. This default is " -"almost always desirable because it will make the help messages match how the " -"program was invoked on the command line. For example, consider a file named " -"``myprogram.py`` with the following code::" +"By default, :class:`ArgumentParser` calculates the name of the program to " +"display in help messages depending on the way the Python interpreter was run:" msgstr "" -#: library/argparse.rst:263 +#: library/argparse.rst:128 msgid "" -"The help for this program will display ``myprogram.py`` as the program name " -"(regardless of where the program was invoked from):" +"The :func:`base name ` of ``sys.argv[0]`` if a file was " +"passed as argument." msgstr "" -#: library/argparse.rst:282 +#: library/argparse.rst:130 msgid "" -"To change this default behavior, another value can be supplied using the " -"``prog=`` argument to :class:`ArgumentParser`::" +"The Python interpreter name followed by ``sys.argv[0]`` if a directory or a " +"zipfile was passed as argument." msgstr "" -#: library/argparse.rst:292 +#: library/argparse.rst:132 +msgid "" +"The Python interpreter name followed by ``-m`` followed by the module or " +"package name if the :option:`-m` option was used." +msgstr "" + +#: library/argparse.rst:135 +msgid "" +"This default is almost always desirable because it will make the help " +"messages match the string that was used to invoke the program on the command " +"line. However, to change this default behavior, another value can be " +"supplied using the ``prog=`` argument to :class:`ArgumentParser`::" +msgstr "" + +#: library/argparse.rst:140 +msgid "" +">>> parser = argparse.ArgumentParser(prog='myprogram')\n" +">>> parser.print_help()\n" +"usage: myprogram [-h]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit" +msgstr "" + +#: library/argparse.rst:147 msgid "" "Note that the program name, whether determined from ``sys.argv[0]`` or from " "the ``prog=`` argument, is available to help messages using the ``%(prog)s`` " "format specifier." msgstr "" -#: library/argparse.rst:309 +#: library/argparse.rst:153 +msgid "" +">>> parser = argparse.ArgumentParser(prog='myprogram')\n" +">>> parser.add_argument('--foo', help='foo of the %(prog)s program')\n" +">>> parser.print_help()\n" +"usage: myprogram [-h] [--foo FOO]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo FOO foo of the myprogram program" +msgstr "" + +#: library/argparse.rst:164 msgid "usage" msgstr "" -#: library/argparse.rst:311 +#: library/argparse.rst:166 msgid "" "By default, :class:`ArgumentParser` calculates the usage message from the " -"arguments it contains::" +"arguments it contains. The default message can be overridden with the " +"``usage=`` keyword argument::" msgstr "" -#: library/argparse.rst:327 +#: library/argparse.rst:170 msgid "" -"The default message can be overridden with the ``usage=`` keyword argument::" +">>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s " +"[options]')\n" +">>> parser.add_argument('--foo', nargs='?', help='foo help')\n" +">>> parser.add_argument('bar', nargs='+', help='bar help')\n" +">>> parser.print_help()\n" +"usage: PROG [options]\n" +"\n" +"positional arguments:\n" +" bar bar help\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo [FOO] foo help" msgstr "" -#: library/argparse.rst:342 +#: library/argparse.rst:183 msgid "" "The ``%(prog)s`` format specifier is available to fill in the program name " "in your usage messages." msgstr "" -#: library/argparse.rst:349 +#: library/argparse.rst:190 msgid "description" msgstr "" -#: library/argparse.rst:351 +#: library/argparse.rst:192 msgid "" "Most calls to the :class:`ArgumentParser` constructor will use the " "``description=`` keyword argument. This argument gives a brief description " "of what the program does and how it works. In help messages, the " "description is displayed between the command-line usage string and the help " -"messages for the various arguments::" +"messages for the various arguments." msgstr "" -#: library/argparse.rst:366 +#: library/argparse.rst:198 msgid "" "By default, the description will be line-wrapped so that it fits within the " "given space. To change this behavior, see the formatter_class_ argument." msgstr "" -#: library/argparse.rst:371 +#: library/argparse.rst:203 msgid "epilog" msgstr "" -#: library/argparse.rst:373 +#: library/argparse.rst:205 msgid "" "Some programs like to display additional description of the program after " "the description of the arguments. Such text can be specified using the " "``epilog=`` argument to :class:`ArgumentParser`::" msgstr "" -#: library/argparse.rst:390 +#: library/argparse.rst:209 +msgid "" +">>> parser = argparse.ArgumentParser(\n" +"... description='A foo that bars',\n" +"... epilog=\"And that's how you'd foo a bar\")\n" +">>> parser.print_help()\n" +"usage: argparse.py [-h]\n" +"\n" +"A foo that bars\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"\n" +"And that's how you'd foo a bar" +msgstr "" + +#: library/argparse.rst:222 msgid "" "As with the description_ argument, the ``epilog=`` text is by default line-" "wrapped, but this behavior can be adjusted with the formatter_class_ " "argument to :class:`ArgumentParser`." msgstr "" -#: library/argparse.rst:396 +#: library/argparse.rst:228 msgid "parents" msgstr "" -#: library/argparse.rst:398 +#: library/argparse.rst:230 msgid "" "Sometimes, several parsers share a common set of arguments. Rather than " "repeating the definitions of these arguments, a single parser with all the " -"shared arguments and passed to ``parents=`` argument to :class:" -"`ArgumentParser` can be used. The ``parents=`` argument takes a list of :" -"class:`ArgumentParser` objects, collects all the positional and optional " -"actions from them, and adds these actions to the :class:`ArgumentParser` " -"object being constructed::" +"shared arguments and passed to ``parents=`` argument " +"to :class:`ArgumentParser` can be used. The ``parents=`` argument takes a " +"list of :class:`ArgumentParser` objects, collects all the positional and " +"optional actions from them, and adds these actions to " +"the :class:`ArgumentParser` object being constructed::" msgstr "" -#: library/argparse.rst:418 +#: library/argparse.rst:237 +msgid "" +">>> parent_parser = argparse.ArgumentParser(add_help=False)\n" +">>> parent_parser.add_argument('--parent', type=int)\n" +"\n" +">>> foo_parser = argparse.ArgumentParser(parents=[parent_parser])\n" +">>> foo_parser.add_argument('foo')\n" +">>> foo_parser.parse_args(['--parent', '2', 'XXX'])\n" +"Namespace(foo='XXX', parent=2)\n" +"\n" +">>> bar_parser = argparse.ArgumentParser(parents=[parent_parser])\n" +">>> bar_parser.add_argument('--bar')\n" +">>> bar_parser.parse_args(['--bar', 'YYY'])\n" +"Namespace(bar='YYY', parent=None)" +msgstr "" + +#: library/argparse.rst:250 msgid "" "Note that most parent parsers will specify ``add_help=False``. Otherwise, " "the :class:`ArgumentParser` will see two ``-h/--help`` options (one in the " "parent and one in the child) and raise an error." msgstr "" -#: library/argparse.rst:423 +#: library/argparse.rst:255 msgid "" "You must fully initialize the parsers before passing them via ``parents=``. " "If you change the parent parsers after the child parser, those changes will " "not be reflected in the child." msgstr "" -#: library/argparse.rst:431 +#: library/argparse.rst:263 msgid "formatter_class" msgstr "" -#: library/argparse.rst:433 +#: library/argparse.rst:265 msgid "" ":class:`ArgumentParser` objects allow the help formatting to be customized " "by specifying an alternate formatting class. Currently, there are four such " "classes:" msgstr "" -#: library/argparse.rst:442 +#: library/argparse.rst:274 msgid "" ":class:`RawDescriptionHelpFormatter` and :class:`RawTextHelpFormatter` give " -"more control over how textual descriptions are displayed. By default, :class:" -"`ArgumentParser` objects line-wrap the description_ and epilog_ texts in " -"command-line help messages::" -msgstr "" - -#: library/argparse.rst:467 +"more control over how textual descriptions are displayed. By " +"default, :class:`ArgumentParser` objects line-wrap the description_ and " +"epilog_ texts in command-line help messages::" +msgstr "" + +#: library/argparse.rst:279 +msgid "" +">>> parser = argparse.ArgumentParser(\n" +"... prog='PROG',\n" +"... description='''this description\n" +"... was indented weird\n" +"... but that is okay''',\n" +"... epilog='''\n" +"... likewise for this epilog whose whitespace will\n" +"... be cleaned up and whose words will be wrapped\n" +"... across a couple lines''')\n" +">>> parser.print_help()\n" +"usage: PROG [-h]\n" +"\n" +"this description was indented weird but that is okay\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"\n" +"likewise for this epilog whose whitespace will be cleaned up and whose " +"words\n" +"will be wrapped across a couple lines" +msgstr "" + +#: library/argparse.rst:299 msgid "" "Passing :class:`RawDescriptionHelpFormatter` as ``formatter_class=`` " "indicates that description_ and epilog_ are already correctly formatted and " "should not be line-wrapped::" msgstr "" -#: library/argparse.rst:493 +#: library/argparse.rst:303 +msgid "" +">>> parser = argparse.ArgumentParser(\n" +"... prog='PROG',\n" +"... formatter_class=argparse.RawDescriptionHelpFormatter,\n" +"... description=textwrap.dedent('''\\\n" +"... Please do not mess up this text!\n" +"... --------------------------------\n" +"... I have indented it\n" +"... exactly the way\n" +"... I want it\n" +"... '''))\n" +">>> parser.print_help()\n" +"usage: PROG [-h]\n" +"\n" +"Please do not mess up this text!\n" +"--------------------------------\n" +" I have indented it\n" +" exactly the way\n" +" I want it\n" +"\n" +"options:\n" +" -h, --help show this help message and exit" +msgstr "" + +#: library/argparse.rst:325 msgid "" ":class:`RawTextHelpFormatter` maintains whitespace for all sorts of help " -"text, including argument descriptions. However, multiple new lines are " +"text, including argument descriptions. However, multiple newlines are " "replaced with one. If you wish to preserve multiple blank lines, add spaces " "between the newlines." msgstr "" -#: library/argparse.rst:498 +#: library/argparse.rst:330 msgid "" ":class:`ArgumentDefaultsHelpFormatter` automatically adds information about " "default values to each of the argument help messages::" msgstr "" -#: library/argparse.rst:516 +#: library/argparse.rst:333 +msgid "" +">>> parser = argparse.ArgumentParser(\n" +"... prog='PROG',\n" +"... formatter_class=argparse.ArgumentDefaultsHelpFormatter)\n" +">>> parser.add_argument('--foo', type=int, default=42, help='FOO!')\n" +">>> parser.add_argument('bar', nargs='*', default=[1, 2, 3], help='BAR!')\n" +">>> parser.print_help()\n" +"usage: PROG [-h] [--foo FOO] [bar ...]\n" +"\n" +"positional arguments:\n" +" bar BAR! (default: [1, 2, 3])\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo FOO FOO! (default: 42)" +msgstr "" + +#: library/argparse.rst:348 msgid "" ":class:`MetavarTypeHelpFormatter` uses the name of the type_ argument for " "each argument as the display name for its values (rather than using the " "dest_ as the regular formatter does)::" msgstr "" -#: library/argparse.rst:537 +#: library/argparse.rst:352 +msgid "" +">>> parser = argparse.ArgumentParser(\n" +"... prog='PROG',\n" +"... formatter_class=argparse.MetavarTypeHelpFormatter)\n" +">>> parser.add_argument('--foo', type=int)\n" +">>> parser.add_argument('bar', type=float)\n" +">>> parser.print_help()\n" +"usage: PROG [-h] [--foo int] float\n" +"\n" +"positional arguments:\n" +" float\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo int" +msgstr "" + +#: library/argparse.rst:369 msgid "prefix_chars" msgstr "" -#: library/argparse.rst:539 +#: library/argparse.rst:371 msgid "" "Most command-line options will use ``-`` as the prefix, e.g. ``-f/--foo``. " "Parsers that need to support different or additional prefix characters, e.g. " "for options like ``+f`` or ``/foo``, may specify them using the " -"``prefix_chars=`` argument to the ArgumentParser constructor::" +"``prefix_chars=`` argument to the :class:`ArgumentParser` constructor::" msgstr "" -#: library/argparse.rst:551 +#: library/argparse.rst:377 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='-+')\n" +">>> parser.add_argument('+f')\n" +">>> parser.add_argument('++bar')\n" +">>> parser.parse_args('+f X ++bar Y'.split())\n" +"Namespace(bar='Y', f='X')" +msgstr "" + +#: library/argparse.rst:383 msgid "" "The ``prefix_chars=`` argument defaults to ``'-'``. Supplying a set of " "characters that does not include ``-`` will cause ``-f/--foo`` options to be " "disallowed." msgstr "" -#: library/argparse.rst:557 +#: library/argparse.rst:389 msgid "fromfile_prefix_chars" msgstr "" -#: library/argparse.rst:559 +#: library/argparse.rst:391 msgid "" "Sometimes, when dealing with a particularly long argument list, it may make " "sense to keep the list of arguments in a file rather than typing it out at " @@ -586,73 +569,106 @@ msgid "" "by the arguments they contain. For example::" msgstr "" -#: library/argparse.rst:574 +#: library/argparse.rst:398 msgid "" -"Arguments read from a file must by default be one per line (but see also :" -"meth:`~ArgumentParser.convert_arg_line_to_args`) and are treated as if they " -"were in the same place as the original file referencing argument on the " +">>> with open('args.txt', 'w', encoding=sys.getfilesystemencoding()) as fp:\n" +"... fp.write('-f\\nbar')\n" +"...\n" +">>> parser = argparse.ArgumentParser(fromfile_prefix_chars='@')\n" +">>> parser.add_argument('-f')\n" +">>> parser.parse_args(['-f', 'foo', '@args.txt'])\n" +"Namespace(f='bar')" +msgstr "" + +#: library/argparse.rst:406 +msgid "" +"Arguments read from a file must by default be one per line (but see " +"also :meth:`~ArgumentParser.convert_arg_line_to_args`) and are treated as if " +"they were in the same place as the original file referencing argument on the " "command line. So in the example above, the expression ``['-f', 'foo', " "'@args.txt']`` is considered equivalent to the expression ``['-f', 'foo', '-" "f', 'bar']``." msgstr "" -#: library/argparse.rst:580 +#: library/argparse.rst:412 msgid "" ":class:`ArgumentParser` uses :term:`filesystem encoding and error handler` " "to read the file containing arguments." msgstr "" -#: library/argparse.rst:583 +#: library/argparse.rst:415 msgid "" "The ``fromfile_prefix_chars=`` argument defaults to ``None``, meaning that " "arguments will never be treated as file references." msgstr "" -#: library/argparse.rst:586 +#: library/argparse.rst:418 msgid "" ":class:`ArgumentParser` changed encoding and errors to read arguments files " -"from default (e.g. :func:`locale.getpreferredencoding(False) ` and ``\"strict\"``) to :term:`filesystem encoding and " -"error handler`. Arguments file should be encoded in UTF-8 instead of ANSI " -"Codepage on Windows." +"from default (e.g. :func:`locale.getpreferredencoding(False) " +"` and ``\"strict\"``) to the :term:`filesystem " +"encoding and error handler`. Arguments file should be encoded in UTF-8 " +"instead of ANSI Codepage on Windows." msgstr "" -#: library/argparse.rst:594 +#: library/argparse.rst:426 msgid "argument_default" msgstr "" -#: library/argparse.rst:596 +#: library/argparse.rst:428 msgid "" -"Generally, argument defaults are specified either by passing a default to :" -"meth:`~ArgumentParser.add_argument` or by calling the :meth:`~ArgumentParser." -"set_defaults` methods with a specific set of name-value pairs. Sometimes " -"however, it may be useful to specify a single parser-wide default for " -"arguments. This can be accomplished by passing the ``argument_default=`` " -"keyword argument to :class:`ArgumentParser`. For example, to globally " -"suppress attribute creation on :meth:`~ArgumentParser.parse_args` calls, we " -"supply ``argument_default=SUPPRESS``::" +"Generally, argument defaults are specified either by passing a default " +"to :meth:`~ArgumentParser.add_argument` or by calling " +"the :meth:`~ArgumentParser.set_defaults` methods with a specific set of name-" +"value pairs. Sometimes however, it may be useful to specify a single parser-" +"wide default for arguments. This can be accomplished by passing the " +"``argument_default=`` keyword argument to :class:`ArgumentParser`. For " +"example, to globally suppress attribute creation " +"on :meth:`~ArgumentParser.parse_args` calls, we supply " +"``argument_default=SUPPRESS``::" msgstr "" -#: library/argparse.rst:616 +#: library/argparse.rst:437 +msgid "" +">>> parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)\n" +">>> parser.add_argument('--foo')\n" +">>> parser.add_argument('bar', nargs='?')\n" +">>> parser.parse_args(['--foo', '1', 'BAR'])\n" +"Namespace(bar='BAR', foo='1')\n" +">>> parser.parse_args([])\n" +"Namespace()" +msgstr "" + +#: library/argparse.rst:448 msgid "allow_abbrev" msgstr "" -#: library/argparse.rst:618 +#: library/argparse.rst:450 msgid "" -"Normally, when you pass an argument list to the :meth:`~ArgumentParser." -"parse_args` method of an :class:`ArgumentParser`, it :ref:`recognizes " -"abbreviations ` of long options." +"Normally, when you pass an argument list to " +"the :meth:`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`, " +"it :ref:`recognizes abbreviations ` of long options." msgstr "" -#: library/argparse.rst:622 +#: library/argparse.rst:454 msgid "This feature can be disabled by setting ``allow_abbrev`` to ``False``::" msgstr "" -#: library/argparse.rst:635 +#: library/argparse.rst:456 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG', allow_abbrev=False)\n" +">>> parser.add_argument('--foobar', action='store_true')\n" +">>> parser.add_argument('--foonley', action='store_false')\n" +">>> parser.parse_args(['--foon'])\n" +"usage: PROG [-h] [--foobar] [--foonley]\n" +"PROG: error: unrecognized arguments: --foon" +msgstr "" + +#: library/argparse.rst:467 msgid "conflict_handler" msgstr "" -#: library/argparse.rst:637 +#: library/argparse.rst:469 msgid "" ":class:`ArgumentParser` objects do not allow two actions with the same " "option string. By default, :class:`ArgumentParser` objects raise an " @@ -660,7 +676,17 @@ msgid "" "that is already in use::" msgstr "" -#: library/argparse.rst:649 +#: library/argparse.rst:474 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-f', '--foo', help='old foo help')\n" +">>> parser.add_argument('--foo', help='new foo help')\n" +"Traceback (most recent call last):\n" +" ..\n" +"ArgumentError: argument --foo: conflicting option string(s): --foo" +msgstr "" + +#: library/argparse.rst:481 msgid "" "Sometimes (e.g. when using parents_) it may be useful to simply override any " "older arguments with the same option string. To get this behavior, the " @@ -668,7 +694,22 @@ msgid "" "of :class:`ArgumentParser`::" msgstr "" -#: library/argparse.rst:665 +#: library/argparse.rst:486 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG', " +"conflict_handler='resolve')\n" +">>> parser.add_argument('-f', '--foo', help='old foo help')\n" +">>> parser.add_argument('--foo', help='new foo help')\n" +">>> parser.print_help()\n" +"usage: PROG [-h] [-f FOO] [--foo FOO]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -f FOO old foo help\n" +" --foo FOO new foo help" +msgstr "" + +#: library/argparse.rst:497 msgid "" "Note that :class:`ArgumentParser` objects only remove an action if all of " "its option strings are overridden. So, in the example above, the old ``-f/--" @@ -676,31 +717,36 @@ msgid "" "option string was overridden." msgstr "" -#: library/argparse.rst:672 +#: library/argparse.rst:504 msgid "add_help" msgstr "" -#: library/argparse.rst:674 +#: library/argparse.rst:506 msgid "" -"By default, ArgumentParser objects add an option which simply displays the " -"parser's help message. For example, consider a file named ``myprogram.py`` " -"containing the following code::" +"By default, :class:`ArgumentParser` objects add an option which simply " +"displays the parser's help message. If ``-h`` or ``--help`` is supplied at " +"the command line, the :class:`!ArgumentParser` help will be printed." msgstr "" -#: library/argparse.rst:683 +#: library/argparse.rst:510 msgid "" -"If ``-h`` or ``--help`` is supplied at the command line, the ArgumentParser " -"help will be printed:" +"Occasionally, it may be useful to disable the addition of this help option. " +"This can be achieved by passing ``False`` as the ``add_help=`` argument " +"to :class:`ArgumentParser`::" msgstr "" -#: library/argparse.rst:695 +#: library/argparse.rst:514 msgid "" -"Occasionally, it may be useful to disable the addition of this help option. " -"This can be achieved by passing ``False`` as the ``add_help=`` argument to :" -"class:`ArgumentParser`::" +">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" +">>> parser.add_argument('--foo', help='foo help')\n" +">>> parser.print_help()\n" +"usage: PROG [--foo FOO]\n" +"\n" +"options:\n" +" --foo FOO foo help" msgstr "" -#: library/argparse.rst:707 +#: library/argparse.rst:522 msgid "" "The help option is typically ``-h/--help``. The exception to this is if the " "``prefix_chars=`` is specified and does not include ``-``, in which case ``-" @@ -708,122 +754,170 @@ msgid "" "in ``prefix_chars`` is used to prefix the help options::" msgstr "" -#: library/argparse.rst:722 +#: library/argparse.rst:528 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='+/')\n" +">>> parser.print_help()\n" +"usage: PROG [+h]\n" +"\n" +"options:\n" +" +h, ++help show this help message and exit" +msgstr "" + +#: library/argparse.rst:537 msgid "exit_on_error" msgstr "" -#: library/argparse.rst:724 +#: library/argparse.rst:539 msgid "" -"Normally, when you pass an invalid argument list to the :meth:" -"`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`, it will " -"exit with error info." +"Normally, when you pass an invalid argument list to " +"the :meth:`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`, " +"it will print a *message* to :data:`sys.stderr` and exit with a status code " +"of 2." msgstr "" -#: library/argparse.rst:727 +#: library/argparse.rst:543 msgid "" "If the user would like to catch errors manually, the feature can be enabled " "by setting ``exit_on_error`` to ``False``::" msgstr "" -#: library/argparse.rst:744 +#: library/argparse.rst:546 +msgid "" +">>> parser = argparse.ArgumentParser(exit_on_error=False)\n" +">>> parser.add_argument('--integers', type=int)\n" +"_StoreAction(option_strings=['--integers'], dest='integers', nargs=None, " +"const=None, default=None, type=, choices=None, help=None, " +"metavar=None)\n" +">>> try:\n" +"... parser.parse_args('--integers a'.split())\n" +"... except argparse.ArgumentError:\n" +"... print('Catching an argumentError')\n" +"...\n" +"Catching an argumentError" +msgstr "" + +#: library/argparse.rst:560 msgid "The add_argument() method" msgstr "" -#: library/argparse.rst:750 +#: library/argparse.rst:566 msgid "" "Define how a single command-line argument should be parsed. Each parameter " "has its own more detailed description below, but in short they are:" msgstr "" -#: library/argparse.rst:753 +#: library/argparse.rst:569 msgid "" -"`name or flags`_ - Either a name or a list of option strings, e.g. ``foo`` " -"or ``-f, --foo``." +"`name or flags`_ - Either a name or a list of option strings, e.g. ``'foo'`` " +"or ``'-f', '--foo'``." msgstr "" -#: library/argparse.rst:756 +#: library/argparse.rst:572 msgid "" "action_ - The basic type of action to be taken when this argument is " "encountered at the command line." msgstr "" -#: library/argparse.rst:759 +#: library/argparse.rst:575 msgid "nargs_ - The number of command-line arguments that should be consumed." msgstr "" -#: library/argparse.rst:761 +#: library/argparse.rst:577 msgid "" "const_ - A constant value required by some action_ and nargs_ selections." msgstr "" -#: library/argparse.rst:763 +#: library/argparse.rst:579 msgid "" "default_ - The value produced if the argument is absent from the command " "line and if it is absent from the namespace object." msgstr "" -#: library/argparse.rst:766 +#: library/argparse.rst:582 msgid "" "type_ - The type to which the command-line argument should be converted." msgstr "" -#: library/argparse.rst:768 +#: library/argparse.rst:584 msgid "choices_ - A sequence of the allowable values for the argument." msgstr "" -#: library/argparse.rst:770 +#: library/argparse.rst:586 msgid "" "required_ - Whether or not the command-line option may be omitted (optionals " "only)." msgstr "" -#: library/argparse.rst:773 +#: library/argparse.rst:589 msgid "help_ - A brief description of what the argument does." msgstr "" -#: library/argparse.rst:775 +#: library/argparse.rst:591 msgid "metavar_ - A name for the argument in usage messages." msgstr "" -#: library/argparse.rst:777 +#: library/argparse.rst:593 msgid "" -"dest_ - The name of the attribute to be added to the object returned by :" -"meth:`parse_args`." +"dest_ - The name of the attribute to be added to the object returned " +"by :meth:`parse_args`." msgstr "" -#: library/argparse.rst:786 +#: library/argparse.rst:602 msgid "name or flags" msgstr "" -#: library/argparse.rst:788 +#: library/argparse.rst:604 msgid "" "The :meth:`~ArgumentParser.add_argument` method must know whether an " "optional argument, like ``-f`` or ``--foo``, or a positional argument, like " -"a list of filenames, is expected. The first arguments passed to :meth:" -"`~ArgumentParser.add_argument` must therefore be either a series of flags, " -"or a simple argument name." +"a list of filenames, is expected. The first arguments passed " +"to :meth:`~ArgumentParser.add_argument` must therefore be either a series of " +"flags, or a simple argument name." msgstr "" -#: library/argparse.rst:794 +#: library/argparse.rst:610 msgid "For example, an optional argument could be created like::" msgstr "" -#: library/argparse.rst:798 +#: library/argparse.rst:612 +msgid ">>> parser.add_argument('-f', '--foo')" +msgstr "" + +#: library/argparse.rst:614 msgid "while a positional argument could be created like::" msgstr "" -#: library/argparse.rst:802 +#: library/argparse.rst:616 +msgid ">>> parser.add_argument('bar')" +msgstr "" + +#: library/argparse.rst:618 msgid "" "When :meth:`~ArgumentParser.parse_args` is called, optional arguments will " "be identified by the ``-`` prefix, and the remaining arguments will be " "assumed to be positional::" msgstr "" -#: library/argparse.rst:821 +#: library/argparse.rst:622 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-f', '--foo')\n" +">>> parser.add_argument('bar')\n" +">>> parser.parse_args(['BAR'])\n" +"Namespace(bar='BAR', foo=None)\n" +">>> parser.parse_args(['BAR', '--foo', 'FOO'])\n" +"Namespace(bar='BAR', foo='FOO')\n" +">>> parser.parse_args(['--foo', 'FOO'])\n" +"usage: PROG [-h] [-f FOO] bar\n" +"PROG: error: the following arguments are required: bar" +msgstr "" + +#: library/argparse.rst:637 msgid "action" msgstr "" -#: library/argparse.rst:823 +#: library/argparse.rst:639 msgid "" ":class:`ArgumentParser` objects associate command-line arguments with " "actions. These actions can do just about anything with the command-line " @@ -833,13 +927,13 @@ msgid "" "be handled. The supplied actions are:" msgstr "" -#: library/argparse.rst:829 +#: library/argparse.rst:645 msgid "" "``'store'`` - This just stores the argument's value. This is the default " -"action. For example::" +"action." msgstr "" -#: library/argparse.rst:837 +#: library/argparse.rst:648 msgid "" "``'store_const'`` - This stores the value specified by the const_ keyword " "argument; note that the const_ keyword argument defaults to ``None``. The " @@ -847,15 +941,33 @@ msgid "" "specify some sort of flag. For example::" msgstr "" -#: library/argparse.rst:847 +#: library/argparse.rst:653 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action='store_const', const=42)\n" +">>> parser.parse_args(['--foo'])\n" +"Namespace(foo=42)" +msgstr "" + +#: library/argparse.rst:658 msgid "" "``'store_true'`` and ``'store_false'`` - These are special cases of " "``'store_const'`` used for storing the values ``True`` and ``False`` " "respectively. In addition, they create default values of ``False`` and " -"``True`` respectively. For example::" +"``True`` respectively::" msgstr "" -#: library/argparse.rst:859 +#: library/argparse.rst:663 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action='store_true')\n" +">>> parser.add_argument('--bar', action='store_false')\n" +">>> parser.add_argument('--baz', action='store_false')\n" +">>> parser.parse_args('--foo --bar'.split())\n" +"Namespace(foo=True, bar=False, baz=True)" +msgstr "" + +#: library/argparse.rst:670 msgid "" "``'append'`` - This stores a list, and appends each argument value to the " "list. It is useful to allow an option to be specified multiple times. If the " @@ -864,7 +976,15 @@ msgid "" "after those default values. Example usage::" msgstr "" -#: library/argparse.rst:870 +#: library/argparse.rst:676 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action='append')\n" +">>> parser.parse_args('--foo 1 --foo 2'.split())\n" +"Namespace(foo=['1', '2'])" +msgstr "" + +#: library/argparse.rst:681 msgid "" "``'append_const'`` - This stores a list, and appends the value specified by " "the const_ keyword argument to the list; note that the const_ keyword " @@ -873,17 +993,55 @@ msgid "" "example::" msgstr "" -#: library/argparse.rst:882 +#: library/argparse.rst:687 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--str', dest='types', action='append_const', " +"const=str)\n" +">>> parser.add_argument('--int', dest='types', action='append_const', " +"const=int)\n" +">>> parser.parse_args('--str --int'.split())\n" +"Namespace(types=[, ])" +msgstr "" + +#: library/argparse.rst:693 +msgid "" +"``'extend'`` - This stores a list and appends each item from the multi-value " +"argument list to it. The ``'extend'`` action is typically used with the " +"nargs_ keyword argument value ``'+'`` or ``'*'``. Note that when nargs_ is " +"``None`` (the default) or ``'?'``, each character of the argument string " +"will be appended to the list. Example usage::" +msgstr "" + +#: library/argparse.rst:701 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " +"type=str)\n" +">>> parser.parse_args([\"--foo\", \"f1\", \"--foo\", \"f2\", \"f3\", " +"\"f4\"])\n" +"Namespace(foo=['f1', 'f2', 'f3', 'f4'])" +msgstr "" + +#: library/argparse.rst:708 msgid "" "``'count'`` - This counts the number of times a keyword argument occurs. For " "example, this is useful for increasing verbosity levels::" msgstr "" -#: library/argparse.rst:890 +#: library/argparse.rst:711 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--verbose', '-v', action='count', default=0)\n" +">>> parser.parse_args(['-vvv'])\n" +"Namespace(verbose=3)" +msgstr "" + +#: library/argparse.rst:716 msgid "Note, the *default* will be ``None`` unless explicitly set to *0*." msgstr "" -#: library/argparse.rst:892 +#: library/argparse.rst:718 msgid "" "``'help'`` - This prints a complete help message for all the options in the " "current parser and then exits. By default a help action is automatically " @@ -891,67 +1049,119 @@ msgid "" "output is created." msgstr "" -#: library/argparse.rst:897 +#: library/argparse.rst:723 msgid "" -"``'version'`` - This expects a ``version=`` keyword argument in the :meth:" -"`~ArgumentParser.add_argument` call, and prints version information and " -"exits when invoked::" +"``'version'`` - This expects a ``version=`` keyword argument in " +"the :meth:`~ArgumentParser.add_argument` call, and prints version " +"information and exits when invoked::" msgstr "" -#: library/argparse.rst:907 +#: library/argparse.rst:727 msgid "" -"``'extend'`` - This stores a list, and extends each argument value to the " -"list. Example usage::" +">>> import argparse\n" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('--version', action='version', version='%(prog)s " +"2.0')\n" +">>> parser.parse_args(['--version'])\n" +"PROG 2.0" msgstr "" -#: library/argparse.rst:918 +#: library/argparse.rst:733 msgid "" -"You may also specify an arbitrary action by passing an Action subclass or " -"other object that implements the same interface. The " -"``BooleanOptionalAction`` is available in ``argparse`` and adds support for " +"Only actions that consume command-line arguments (e.g. ``'store'``, " +"``'append'`` or ``'extend'``) can be used with positional arguments." +msgstr "" + +#: library/argparse.rst:738 +msgid "" +"You may also specify an arbitrary action by passing an :class:`Action` " +"subclass or other object that implements the same interface. The :class:`!" +"BooleanOptionalAction` is available in :mod:`!argparse` and adds support for " "boolean actions such as ``--foo`` and ``--no-foo``::" msgstr "" -#: library/argparse.rst:931 +#: library/argparse.rst:743 +msgid "" +">>> import argparse\n" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action=argparse.BooleanOptionalAction)\n" +">>> parser.parse_args(['--no-foo'])\n" +"Namespace(foo=False)" +msgstr "" + +#: library/argparse.rst:751 msgid "" "The recommended way to create a custom action is to extend :class:`Action`, " -"overriding the ``__call__`` method and optionally the ``__init__`` and " -"``format_usage`` methods." +"overriding the :meth:`!__call__` method and optionally the :meth:`!__init__` " +"and :meth:`!format_usage` methods. You can also register custom actions " +"using the :meth:`~ArgumentParser.register` method and reference them by " +"their registered name." msgstr "" -#: library/argparse.rst:935 +#: library/argparse.rst:756 msgid "An example of a custom action::" msgstr "" -#: library/argparse.rst:955 +#: library/argparse.rst:758 +msgid "" +">>> class FooAction(argparse.Action):\n" +"... def __init__(self, option_strings, dest, nargs=None, **kwargs):\n" +"... if nargs is not None:\n" +"... raise ValueError(\"nargs not allowed\")\n" +"... super().__init__(option_strings, dest, **kwargs)\n" +"... def __call__(self, parser, namespace, values, option_string=None):\n" +"... print('%r %r %r' % (namespace, values, option_string))\n" +"... setattr(namespace, self.dest, values)\n" +"...\n" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action=FooAction)\n" +">>> parser.add_argument('bar', action=FooAction)\n" +">>> args = parser.parse_args('1 --foo 2'.split())\n" +"Namespace(bar=None, foo=None) '1' None\n" +"Namespace(bar='1', foo=None) '2' '--foo'\n" +">>> args\n" +"Namespace(bar='1', foo='2')" +msgstr "" + +#: library/argparse.rst:776 msgid "For more details, see :class:`Action`." msgstr "" -#: library/argparse.rst:961 +#: library/argparse.rst:782 msgid "nargs" msgstr "" -#: library/argparse.rst:963 +#: library/argparse.rst:784 msgid "" -"ArgumentParser objects usually associate a single command-line argument with " -"a single action to be taken. The ``nargs`` keyword argument associates a " -"different number of command-line arguments with a single action. See also :" -"ref:`specifying-ambiguous-arguments`. The supported values are:" +":class:`ArgumentParser` objects usually associate a single command-line " +"argument with a single action to be taken. The ``nargs`` keyword argument " +"associates a different number of command-line arguments with a single " +"action. See also :ref:`specifying-ambiguous-arguments`. The supported values " +"are:" msgstr "" -#: library/argparse.rst:968 +#: library/argparse.rst:789 msgid "" "``N`` (an integer). ``N`` arguments from the command line will be gathered " "together into a list. For example::" msgstr "" -#: library/argparse.rst:977 +#: library/argparse.rst:792 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', nargs=2)\n" +">>> parser.add_argument('bar', nargs=1)\n" +">>> parser.parse_args('c --foo a b'.split())\n" +"Namespace(bar=['c'], foo=['a', 'b'])" +msgstr "" + +#: library/argparse.rst:798 msgid "" "Note that ``nargs=1`` produces a list of one item. This is different from " "the default, in which the item is produced by itself." msgstr "" -#: library/argparse.rst:982 +#: library/argparse.rst:803 msgid "" "``'?'``. One argument will be consumed from the command line if possible, " "and produced as a single item. If no command-line argument is present, the " @@ -961,13 +1171,41 @@ msgid "" "produced. Some examples to illustrate this::" msgstr "" -#: library/argparse.rst:999 +#: library/argparse.rst:810 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', nargs='?', const='c', default='d')\n" +">>> parser.add_argument('bar', nargs='?', default='d')\n" +">>> parser.parse_args(['XX', '--foo', 'YY'])\n" +"Namespace(bar='XX', foo='YY')\n" +">>> parser.parse_args(['XX', '--foo'])\n" +"Namespace(bar='XX', foo='c')\n" +">>> parser.parse_args([])\n" +"Namespace(bar='d', foo='d')" +msgstr "" + +#: library/argparse.rst:820 msgid "" "One of the more common uses of ``nargs='?'`` is to allow optional input and " "output files::" msgstr "" -#: library/argparse.rst:1016 +#: library/argparse.rst:823 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('infile', nargs='?', type=argparse.FileType('r'),\n" +"... default=sys.stdin)\n" +">>> parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'),\n" +"... default=sys.stdout)\n" +">>> parser.parse_args(['input.txt', 'output.txt'])\n" +"Namespace(infile=<_io.TextIOWrapper name='input.txt' encoding='UTF-8'>,\n" +" outfile=<_io.TextIOWrapper name='output.txt' encoding='UTF-8'>)\n" +">>> parser.parse_args([])\n" +"Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>,\n" +" outfile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" +msgstr "" + +#: library/argparse.rst:837 msgid "" "``'*'``. All command-line arguments present are gathered into a list. Note " "that it generally doesn't make much sense to have more than one positional " @@ -975,26 +1213,48 @@ msgid "" "``nargs='*'`` is possible. For example::" msgstr "" -#: library/argparse.rst:1030 +#: library/argparse.rst:842 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', nargs='*')\n" +">>> parser.add_argument('--bar', nargs='*')\n" +">>> parser.add_argument('baz', nargs='*')\n" +">>> parser.parse_args('a b --foo x y --bar 1 2'.split())\n" +"Namespace(bar=['1', '2'], baz=['a', 'b'], foo=['x', 'y'])" +msgstr "" + +#: library/argparse.rst:851 msgid "" "``'+'``. Just like ``'*'``, all command-line args present are gathered into " "a list. Additionally, an error message will be generated if there wasn't at " "least one command-line argument present. For example::" msgstr "" -#: library/argparse.rst:1042 +#: library/argparse.rst:855 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('foo', nargs='+')\n" +">>> parser.parse_args(['a', 'b'])\n" +"Namespace(foo=['a', 'b'])\n" +">>> parser.parse_args([])\n" +"usage: PROG [-h] foo [foo ...]\n" +"PROG: error: the following arguments are required: foo" +msgstr "" + +#: library/argparse.rst:863 msgid "" "If the ``nargs`` keyword argument is not provided, the number of arguments " "consumed is determined by the action_. Generally this means a single " "command-line argument will be consumed and a single item (not a list) will " -"be produced." +"be produced. Actions that do not consume command-line arguments (e.g. " +"``'store_const'``) set ``nargs=0``." msgstr "" -#: library/argparse.rst:1050 +#: library/argparse.rst:873 msgid "const" msgstr "" -#: library/argparse.rst:1052 +#: library/argparse.rst:875 msgid "" "The ``const`` argument of :meth:`~ArgumentParser.add_argument` is used to " "hold constant values that are not read from the command line but are " @@ -1002,17 +1262,18 @@ msgid "" "common uses of it are:" msgstr "" -#: library/argparse.rst:1056 +#: library/argparse.rst:879 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with " "``action='store_const'`` or ``action='append_const'``. These actions add " -"the ``const`` value to one of the attributes of the object returned by :meth:" -"`~ArgumentParser.parse_args`. See the action_ description for examples. If " -"``const`` is not provided to :meth:`~ArgumentParser.add_argument`, it will " -"receive a default value of ``None``." +"the ``const`` value to one of the attributes of the object returned " +"by :meth:`~ArgumentParser.parse_args`. See the action_ description for " +"examples. If ``const`` is not provided " +"to :meth:`~ArgumentParser.add_argument`, it will receive a default value of " +"``None``." msgstr "" -#: library/argparse.rst:1064 +#: library/argparse.rst:887 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with option strings " "(like ``-f`` or ``--foo``) and ``nargs='?'``. This creates an optional " @@ -1022,57 +1283,112 @@ msgid "" "to be ``None`` instead. See the nargs_ description for examples." msgstr "" -#: library/argparse.rst:1071 +#: library/argparse.rst:894 msgid "" "``const=None`` by default, including when ``action='append_const'`` or " "``action='store_const'``." msgstr "" -#: library/argparse.rst:1078 +#: library/argparse.rst:901 msgid "default" msgstr "" -#: library/argparse.rst:1080 +#: library/argparse.rst:903 msgid "" "All optional arguments and some positional arguments may be omitted at the " -"command line. The ``default`` keyword argument of :meth:`~ArgumentParser." -"add_argument`, whose value defaults to ``None``, specifies what value should " -"be used if the command-line argument is not present. For optional arguments, " -"the ``default`` value is used when the option string was not present at the " -"command line::" +"command line. The ``default`` keyword argument " +"of :meth:`~ArgumentParser.add_argument`, whose value defaults to ``None``, " +"specifies what value should be used if the command-line argument is not " +"present. For optional arguments, the ``default`` value is used when the " +"option string was not present at the command line::" msgstr "" -#: library/argparse.rst:1094 +#: library/argparse.rst:910 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', default=42)\n" +">>> parser.parse_args(['--foo', '2'])\n" +"Namespace(foo='2')\n" +">>> parser.parse_args([])\n" +"Namespace(foo=42)" +msgstr "" + +#: library/argparse.rst:917 msgid "" "If the target namespace already has an attribute set, the action *default* " -"will not over write it::" +"will not overwrite it::" msgstr "" -#: library/argparse.rst:1102 +#: library/argparse.rst:920 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', default=42)\n" +">>> parser.parse_args([], namespace=argparse.Namespace(foo=101))\n" +"Namespace(foo=101)" +msgstr "" + +#: library/argparse.rst:925 msgid "" "If the ``default`` value is a string, the parser parses the value as if it " "were a command-line argument. In particular, the parser applies any type_ " -"conversion argument, if provided, before setting the attribute on the :class:" -"`Namespace` return value. Otherwise, the parser uses the value as is::" +"conversion argument, if provided, before setting the attribute on " +"the :class:`Namespace` return value. Otherwise, the parser uses the value " +"as is::" msgstr "" -#: library/argparse.rst:1113 +#: library/argparse.rst:930 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--length', default='10', type=int)\n" +">>> parser.add_argument('--width', default=10.5, type=int)\n" +">>> parser.parse_args()\n" +"Namespace(length=10, width=10.5)" +msgstr "" + +#: library/argparse.rst:936 msgid "" "For positional arguments with nargs_ equal to ``?`` or ``*``, the " "``default`` value is used when no command-line argument was present::" msgstr "" -#: library/argparse.rst:1124 +#: library/argparse.rst:939 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('foo', nargs='?', default=42)\n" +">>> parser.parse_args(['a'])\n" +"Namespace(foo='a')\n" +">>> parser.parse_args([])\n" +"Namespace(foo=42)" +msgstr "" + +#: library/argparse.rst:946 +msgid "" +"For required_ arguments, the ``default`` value is ignored. For example, this " +"applies to positional arguments with nargs_ values other than ``?`` or " +"``*``, or optional arguments marked as ``required=True``." +msgstr "" + +#: library/argparse.rst:950 msgid "" "Providing ``default=argparse.SUPPRESS`` causes no attribute to be added if " "the command-line argument was not present::" msgstr "" -#: library/argparse.rst:1138 +#: library/argparse.rst:953 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', default=argparse.SUPPRESS)\n" +">>> parser.parse_args([])\n" +"Namespace()\n" +">>> parser.parse_args(['--foo', '1'])\n" +"Namespace(foo='1')" +msgstr "" + +#: library/argparse.rst:964 msgid "type" msgstr "" -#: library/argparse.rst:1140 +#: library/argparse.rst:966 msgid "" "By default, the parser reads command-line arguments in as simple strings. " "However, quite often the command-line string should instead be interpreted " @@ -1081,36 +1397,63 @@ msgid "" "checking and type conversions to be performed." msgstr "" -#: library/argparse.rst:1146 +#: library/argparse.rst:972 msgid "" "If the type_ keyword is used with the default_ keyword, the type converter " "is only applied if the default is a string." msgstr "" -#: library/argparse.rst:1149 +#: library/argparse.rst:975 msgid "" -"The argument to ``type`` can be any callable that accepts a single string. " -"If the function raises :exc:`ArgumentTypeError`, :exc:`TypeError`, or :exc:" -"`ValueError`, the exception is caught and a nicely formatted error message " -"is displayed. No other exception types are handled." +"The argument to ``type`` can be a callable that accepts a single string or " +"the name of a registered type (see :meth:`~ArgumentParser.register`) If the " +"function raises :exc:`ArgumentTypeError`, :exc:`TypeError`, " +"or :exc:`ValueError`, the exception is caught and a nicely formatted error " +"message is displayed. Other exception types are not handled." msgstr "" -#: library/argparse.rst:1154 +#: library/argparse.rst:981 msgid "Common built-in types and functions can be used as type converters:" msgstr "" -#: library/argparse.rst:1170 +#: library/argparse.rst:983 +msgid "" +"import argparse\n" +"import pathlib\n" +"\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument('count', type=int)\n" +"parser.add_argument('distance', type=float)\n" +"parser.add_argument('street', type=ascii)\n" +"parser.add_argument('code_point', type=ord)\n" +"parser.add_argument('dest_file', type=argparse.FileType('w', " +"encoding='latin-1'))\n" +"parser.add_argument('datapath', type=pathlib.Path)" +msgstr "" + +#: library/argparse.rst:996 msgid "User defined functions can be used as well:" msgstr "" -#: library/argparse.rst:1182 +#: library/argparse.rst:998 +msgid "" +">>> def hyphenated(string):\n" +"... return '-'.join([word[:4] for word in string.casefold().split()])\n" +"...\n" +">>> parser = argparse.ArgumentParser()\n" +">>> _ = parser.add_argument('short_title', type=hyphenated)\n" +">>> parser.parse_args(['\"The Tale of Two Cities\"'])\n" +"Namespace(short_title='\"the-tale-of-two-citi')" +msgstr "" + +#: library/argparse.rst:1008 msgid "" "The :func:`bool` function is not recommended as a type converter. All it " "does is convert empty strings to ``False`` and non-empty strings to " "``True``. This is usually not what is desired." msgstr "" -#: library/argparse.rst:1186 +#: library/argparse.rst:1012 msgid "" "In general, the ``type`` keyword is a convenience that should only be used " "for simple conversions that can only raise one of the three supported " @@ -1118,34 +1461,35 @@ msgid "" "management should be done downstream after the arguments are parsed." msgstr "" -#: library/argparse.rst:1191 +#: library/argparse.rst:1017 msgid "" "For example, JSON or YAML conversions have complex error cases that require " -"better reporting than can be given by the ``type`` keyword. A :exc:`~json." -"JSONDecodeError` would not be well formatted and a :exc:`FileNotFoundError` " -"exception would not be handled at all." +"better reporting than can be given by the ``type`` keyword. " +"A :exc:`~json.JSONDecodeError` would not be well formatted and " +"a :exc:`FileNotFoundError` exception would not be handled at all." msgstr "" -#: library/argparse.rst:1196 +#: library/argparse.rst:1022 msgid "" "Even :class:`~argparse.FileType` has its limitations for use with the " -"``type`` keyword. If one argument uses *FileType* and then a subsequent " -"argument fails, an error is reported but the file is not automatically " -"closed. In this case, it would be better to wait until after the parser has " -"run and then use the :keyword:`with`-statement to manage the files." +"``type`` keyword. If one argument uses :class:`~argparse.FileType` and then " +"a subsequent argument fails, an error is reported but the file is not " +"automatically closed. In this case, it would be better to wait until after " +"the parser has run and then use the :keyword:`with`-statement to manage the " +"files." msgstr "" -#: library/argparse.rst:1202 +#: library/argparse.rst:1029 msgid "" "For type checkers that simply check against a fixed set of values, consider " "using the choices_ keyword instead." msgstr "" -#: library/argparse.rst:1209 +#: library/argparse.rst:1036 msgid "choices" msgstr "" -#: library/argparse.rst:1211 +#: library/argparse.rst:1038 msgid "" "Some command-line arguments should be selected from a restricted set of " "values. These can be handled by passing a sequence object as the *choices* " @@ -1154,26 +1498,38 @@ msgid "" "be displayed if the argument was not one of the acceptable values::" msgstr "" -#: library/argparse.rst:1226 +#: library/argparse.rst:1044 +msgid "" +">>> parser = argparse.ArgumentParser(prog='game.py')\n" +">>> parser.add_argument('move', choices=['rock', 'paper', 'scissors'])\n" +">>> parser.parse_args(['rock'])\n" +"Namespace(move='rock')\n" +">>> parser.parse_args(['fire'])\n" +"usage: game.py [-h] {rock,paper,scissors}\n" +"game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',\n" +"'paper', 'scissors')" +msgstr "" + +#: library/argparse.rst:1053 msgid "" "Note that inclusion in the *choices* sequence is checked after any type_ " "conversions have been performed, so the type of the objects in the *choices* " -"sequence should match the type_ specified::" +"sequence should match the type_ specified." msgstr "" -#: library/argparse.rst:1238 +#: library/argparse.rst:1057 msgid "" "Any sequence can be passed as the *choices* value, so :class:`list` " "objects, :class:`tuple` objects, and custom sequences are all supported." msgstr "" -#: library/argparse.rst:1241 +#: library/argparse.rst:1060 msgid "" "Use of :class:`enum.Enum` is not recommended because it is difficult to " "control its appearance in usage, help, and error messages." msgstr "" -#: library/argparse.rst:1244 +#: library/argparse.rst:1063 msgid "" "Formatted choices override the default *metavar* which is normally derived " "from *dest*. This is usually what you want because the user never sees the " @@ -1181,113 +1537,208 @@ msgid "" "are many choices), just specify an explicit metavar_." msgstr "" -#: library/argparse.rst:1253 +#: library/argparse.rst:1072 msgid "required" msgstr "" -#: library/argparse.rst:1255 +#: library/argparse.rst:1074 msgid "" -"In general, the :mod:`argparse` module assumes that flags like ``-f`` and " +"In general, the :mod:`!argparse` module assumes that flags like ``-f`` and " "``--bar`` indicate *optional* arguments, which can always be omitted at the " "command line. To make an option *required*, ``True`` can be specified for " "the ``required=`` keyword argument to :meth:`~ArgumentParser.add_argument`::" msgstr "" -#: library/argparse.rst:1268 +#: library/argparse.rst:1079 msgid "" -"As the example shows, if an option is marked as ``required``, :meth:" -"`~ArgumentParser.parse_args` will report an error if that option is not " -"present at the command line." +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', required=True)\n" +">>> parser.parse_args(['--foo', 'BAR'])\n" +"Namespace(foo='BAR')\n" +">>> parser.parse_args([])\n" +"usage: [-h] --foo FOO\n" +": error: the following arguments are required: --foo" msgstr "" -#: library/argparse.rst:1274 +#: library/argparse.rst:1087 +msgid "" +"As the example shows, if an option is marked as " +"``required``, :meth:`~ArgumentParser.parse_args` will report an error if " +"that option is not present at the command line." +msgstr "" + +#: library/argparse.rst:1093 msgid "" "Required options are generally considered bad form because users expect " "*options* to be *optional*, and thus they should be avoided when possible." msgstr "" -#: library/argparse.rst:1281 +#: library/argparse.rst:1100 msgid "help" msgstr "" -#: library/argparse.rst:1283 +#: library/argparse.rst:1102 msgid "" "The ``help`` value is a string containing a brief description of the " "argument. When a user requests help (usually by using ``-h`` or ``--help`` " "at the command line), these ``help`` descriptions will be displayed with " -"each argument::" +"each argument." msgstr "" -#: library/argparse.rst:1303 +#: library/argparse.rst:1107 msgid "" "The ``help`` strings can include various format specifiers to avoid " "repetition of things like the program name or the argument default_. The " "available specifiers include the program name, ``%(prog)s`` and most keyword " -"arguments to :meth:`~ArgumentParser.add_argument`, e.g. ``%(default)s``, " -"``%(type)s``, etc.::" +"arguments to :meth:`~ArgumentParser.add_argument`, e.g. ``%(default)s``, ``%" +"(type)s``, etc.::" msgstr "" -#: library/argparse.rst:1320 +#: library/argparse.rst:1112 +msgid "" +">>> parser = argparse.ArgumentParser(prog='frobble')\n" +">>> parser.add_argument('bar', nargs='?', type=int, default=42,\n" +"... help='the bar to %(prog)s (default: %(default)s)')\n" +">>> parser.print_help()\n" +"usage: frobble [-h] [bar]\n" +"\n" +"positional arguments:\n" +" bar the bar to frobble (default: 42)\n" +"\n" +"options:\n" +" -h, --help show this help message and exit" +msgstr "" + +#: library/argparse.rst:1124 msgid "" "As the help string supports %-formatting, if you want a literal ``%`` to " "appear in the help string, you must escape it as ``%%``." msgstr "" -#: library/argparse.rst:1323 +#: library/argparse.rst:1127 msgid "" -":mod:`argparse` supports silencing the help entry for certain options, by " +":mod:`!argparse` supports silencing the help entry for certain options, by " "setting the ``help`` value to ``argparse.SUPPRESS``::" msgstr "" -#: library/argparse.rst:1338 +#: library/argparse.rst:1130 +msgid "" +">>> parser = argparse.ArgumentParser(prog='frobble')\n" +">>> parser.add_argument('--foo', help=argparse.SUPPRESS)\n" +">>> parser.print_help()\n" +"usage: frobble [-h]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit" +msgstr "" + +#: library/argparse.rst:1142 msgid "metavar" msgstr "" -#: library/argparse.rst:1340 +#: library/argparse.rst:1144 msgid "" "When :class:`ArgumentParser` generates help messages, it needs some way to " -"refer to each expected argument. By default, ArgumentParser objects use the " -"dest_ value as the \"name\" of each object. By default, for positional " -"argument actions, the dest_ value is used directly, and for optional " -"argument actions, the dest_ value is uppercased. So, a single positional " -"argument with ``dest='bar'`` will be referred to as ``bar``. A single " -"optional argument ``--foo`` that should be followed by a single command-line " -"argument will be referred to as ``FOO``. An example::" +"refer to each expected argument. By default, :class:`!ArgumentParser` " +"objects use the dest_ value as the \"name\" of each object. By default, for " +"positional argument actions, the dest_ value is used directly, and for " +"optional argument actions, the dest_ value is uppercased. So, a single " +"positional argument with ``dest='bar'`` will be referred to as ``bar``. A " +"single optional argument ``--foo`` that should be followed by a single " +"command-line argument will be referred to as ``FOO``. An example::" +msgstr "" + +#: library/argparse.rst:1153 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo')\n" +">>> parser.add_argument('bar')\n" +">>> parser.parse_args('X --foo Y'.split())\n" +"Namespace(bar='X', foo='Y')\n" +">>> parser.print_help()\n" +"usage: [-h] [--foo FOO] bar\n" +"\n" +"positional arguments:\n" +" bar\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo FOO" +msgstr "" + +#: library/argparse.rst:1168 +msgid "An alternative name can be specified with ``metavar``::" msgstr "" -#: library/argparse.rst:1364 -msgid "An alternative name can be specified with ``metavar``::" +#: library/argparse.rst:1170 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', metavar='YYY')\n" +">>> parser.add_argument('bar', metavar='XXX')\n" +">>> parser.parse_args('X --foo Y'.split())\n" +"Namespace(bar='X', foo='Y')\n" +">>> parser.print_help()\n" +"usage: [-h] [--foo YYY] XXX\n" +"\n" +"positional arguments:\n" +" XXX\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo YYY" msgstr "" -#: library/argparse.rst:1381 +#: library/argparse.rst:1185 msgid "" "Note that ``metavar`` only changes the *displayed* name - the name of the " "attribute on the :meth:`~ArgumentParser.parse_args` object is still " "determined by the dest_ value." msgstr "" -#: library/argparse.rst:1385 +#: library/argparse.rst:1189 msgid "" "Different values of ``nargs`` may cause the metavar to be used multiple " "times. Providing a tuple to ``metavar`` specifies a different display for " "each of the arguments::" msgstr "" -#: library/argparse.rst:1404 +#: library/argparse.rst:1193 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-x', nargs=2)\n" +">>> parser.add_argument('--foo', nargs=2, metavar=('bar', 'baz'))\n" +">>> parser.print_help()\n" +"usage: PROG [-h] [-x X X] [--foo bar baz]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -x X X\n" +" --foo bar baz" +msgstr "" + +#: library/argparse.rst:1208 msgid "dest" msgstr "" -#: library/argparse.rst:1406 +#: library/argparse.rst:1210 msgid "" "Most :class:`ArgumentParser` actions add some value as an attribute of the " "object returned by :meth:`~ArgumentParser.parse_args`. The name of this " -"attribute is determined by the ``dest`` keyword argument of :meth:" -"`~ArgumentParser.add_argument`. For positional argument actions, ``dest`` " -"is normally supplied as the first argument to :meth:`~ArgumentParser." -"add_argument`::" +"attribute is determined by the ``dest`` keyword argument " +"of :meth:`~ArgumentParser.add_argument`. For positional argument actions, " +"``dest`` is normally supplied as the first argument " +"to :meth:`~ArgumentParser.add_argument`::" +msgstr "" + +#: library/argparse.rst:1217 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('bar')\n" +">>> parser.parse_args(['XXX'])\n" +"Namespace(bar='XXX')" msgstr "" -#: library/argparse.rst:1418 +#: library/argparse.rst:1222 msgid "" "For optional argument actions, the value of ``dest`` is normally inferred " "from the option strings. :class:`ArgumentParser` generates the value of " @@ -1299,147 +1750,203 @@ msgid "" "below illustrate this behavior::" msgstr "" -#: library/argparse.rst:1435 +#: library/argparse.rst:1231 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('-f', '--foo-bar', '--foo')\n" +">>> parser.add_argument('-x', '-y')\n" +">>> parser.parse_args('-f 1 -x 2'.split())\n" +"Namespace(foo_bar='1', x='2')\n" +">>> parser.parse_args('--foo 1 -y 2'.split())\n" +"Namespace(foo_bar='1', x='2')" +msgstr "" + +#: library/argparse.rst:1239 msgid "``dest`` allows a custom attribute name to be provided::" msgstr "" -#: library/argparse.rst:1443 +#: library/argparse.rst:1241 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', dest='bar')\n" +">>> parser.parse_args('--foo XXX'.split())\n" +"Namespace(bar='XXX')" +msgstr "" + +#: library/argparse.rst:1247 msgid "Action classes" msgstr "" -#: library/argparse.rst:1445 +#: library/argparse.rst:1249 msgid "" -"Action classes implement the Action API, a callable which returns a callable " -"which processes arguments from the command-line. Any object which follows " -"this API may be passed as the ``action`` parameter to :meth:`~ArgumentParser." -"add_argument`." +":class:`!Action` classes implement the Action API, a callable which returns " +"a callable which processes arguments from the command-line. Any object which " +"follows this API may be passed as the ``action`` parameter " +"to :meth:`~ArgumentParser.add_argument`." msgstr "" -#: library/argparse.rst:1454 +#: library/argparse.rst:1258 msgid "" -"Action objects are used by an ArgumentParser to represent the information " -"needed to parse a single argument from one or more strings from the command " -"line. The Action class must accept the two positional arguments plus any " -"keyword arguments passed to :meth:`ArgumentParser.add_argument` except for " -"the ``action`` itself." +":class:`!Action` objects are used by an :class:`ArgumentParser` to represent " +"the information needed to parse a single argument from one or more strings " +"from the command line. The :class:`!Action` class must accept the two " +"positional arguments plus any keyword arguments passed " +"to :meth:`ArgumentParser.add_argument` except for the ``action`` itself." msgstr "" -#: library/argparse.rst:1460 +#: library/argparse.rst:1264 msgid "" -"Instances of Action (or return value of any callable to the ``action`` " -"parameter) should have attributes \"dest\", \"option_strings\", \"default\", " -"\"type\", \"required\", \"help\", etc. defined. The easiest way to ensure " -"these attributes are defined is to call ``Action.__init__``." +"Instances of :class:`!Action` (or return value of any callable to the " +"``action`` parameter) should have attributes :attr:`!dest`, :attr:`!" +"option_strings`, :attr:`!default`, :attr:`!type`, :attr:`!required`, :attr:`!" +"help`, etc. defined. The easiest way to ensure these attributes are defined " +"is to call :meth:`!Action.__init__`." msgstr "" -#: library/argparse.rst:1465 +#: library/argparse.rst:1272 msgid "" -"Action instances should be callable, so subclasses must override the " -"``__call__`` method, which should accept four parameters:" +":class:`!Action` instances should be callable, so subclasses must override " +"the :meth:`!__call__` method, which should accept four parameters:" msgstr "" -#: library/argparse.rst:1468 -msgid "``parser`` - The ArgumentParser object which contains this action." +#: library/argparse.rst:1275 +msgid "" +"*parser* - The :class:`ArgumentParser` object which contains this action." msgstr "" -#: library/argparse.rst:1470 +#: library/argparse.rst:1277 msgid "" -"``namespace`` - The :class:`Namespace` object that will be returned by :meth:" -"`~ArgumentParser.parse_args`. Most actions add an attribute to this object " -"using :func:`setattr`." +"*namespace* - The :class:`Namespace` object that will be returned " +"by :meth:`~ArgumentParser.parse_args`. Most actions add an attribute to " +"this object using :func:`setattr`." msgstr "" -#: library/argparse.rst:1474 +#: library/argparse.rst:1281 msgid "" -"``values`` - The associated command-line arguments, with any type " -"conversions applied. Type conversions are specified with the type_ keyword " -"argument to :meth:`~ArgumentParser.add_argument`." +"*values* - The associated command-line arguments, with any type conversions " +"applied. Type conversions are specified with the type_ keyword argument " +"to :meth:`~ArgumentParser.add_argument`." msgstr "" -#: library/argparse.rst:1478 +#: library/argparse.rst:1285 msgid "" -"``option_string`` - The option string that was used to invoke this action. " -"The ``option_string`` argument is optional, and will be absent if the action " -"is associated with a positional argument." +"*option_string* - The option string that was used to invoke this action. The " +"``option_string`` argument is optional, and will be absent if the action is " +"associated with a positional argument." msgstr "" -#: library/argparse.rst:1482 +#: library/argparse.rst:1289 msgid "" -"The ``__call__`` method may perform arbitrary actions, but will typically " -"set attributes on the ``namespace`` based on ``dest`` and ``values``." +"The :meth:`!__call__` method may perform arbitrary actions, but will " +"typically set attributes on the ``namespace`` based on ``dest`` and " +"``values``." msgstr "" -#: library/argparse.rst:1485 +#: library/argparse.rst:1294 msgid "" -"Action subclasses can define a ``format_usage`` method that takes no " -"argument and return a string which will be used when printing the usage of " -"the program. If such method is not provided, a sensible default will be used." +":class:`!Action` subclasses can define a :meth:`!format_usage` method that " +"takes no argument and return a string which will be used when printing the " +"usage of the program. If such method is not provided, a sensible default " +"will be used." msgstr "" -#: library/argparse.rst:1490 +#: library/argparse.rst:1300 msgid "The parse_args() method" msgstr "" -#: library/argparse.rst:1494 +#: library/argparse.rst:1304 msgid "" "Convert argument strings to objects and assign them as attributes of the " "namespace. Return the populated namespace." msgstr "" -#: library/argparse.rst:1497 +#: library/argparse.rst:1307 msgid "" "Previous calls to :meth:`add_argument` determine exactly what objects are " -"created and how they are assigned. See the documentation for :meth:" -"`add_argument` for details." +"created and how they are assigned. See the documentation for :meth:`!" +"add_argument` for details." msgstr "" -#: library/argparse.rst:1501 +#: library/argparse.rst:1311 msgid "" -"args_ - List of strings to parse. The default is taken from :data:`sys." -"argv`." +"args_ - List of strings to parse. The default is taken " +"from :data:`sys.argv`." msgstr "" -#: library/argparse.rst:1504 +#: library/argparse.rst:1314 msgid "" -"namespace_ - An object to take the attributes. The default is a new empty :" -"class:`Namespace` object." +"namespace_ - An object to take the attributes. The default is a new " +"empty :class:`Namespace` object." msgstr "" -#: library/argparse.rst:1509 +#: library/argparse.rst:1319 msgid "Option value syntax" msgstr "" -#: library/argparse.rst:1511 +#: library/argparse.rst:1321 msgid "" "The :meth:`~ArgumentParser.parse_args` method supports several ways of " "specifying the value of an option (if it takes one). In the simplest case, " "the option and its value are passed as two separate arguments::" msgstr "" -#: library/argparse.rst:1523 +#: library/argparse.rst:1325 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-x')\n" +">>> parser.add_argument('--foo')\n" +">>> parser.parse_args(['-x', 'X'])\n" +"Namespace(foo=None, x='X')\n" +">>> parser.parse_args(['--foo', 'FOO'])\n" +"Namespace(foo='FOO', x=None)" +msgstr "" + +#: library/argparse.rst:1333 msgid "" "For long options (options with names longer than a single character), the " "option and value can also be passed as a single command-line argument, using " "``=`` to separate them::" msgstr "" -#: library/argparse.rst:1530 +#: library/argparse.rst:1337 +msgid "" +">>> parser.parse_args(['--foo=FOO'])\n" +"Namespace(foo='FOO', x=None)" +msgstr "" + +#: library/argparse.rst:1340 msgid "" "For short options (options only one character long), the option and its " "value can be concatenated::" msgstr "" -#: library/argparse.rst:1536 +#: library/argparse.rst:1343 +msgid "" +">>> parser.parse_args(['-xX'])\n" +"Namespace(foo=None, x='X')" +msgstr "" + +#: library/argparse.rst:1346 msgid "" "Several short options can be joined together, using only a single ``-`` " "prefix, as long as only the last option (or none of them) requires a value::" msgstr "" -#: library/argparse.rst:1548 +#: library/argparse.rst:1349 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-x', action='store_true')\n" +">>> parser.add_argument('-y', action='store_true')\n" +">>> parser.add_argument('-z')\n" +">>> parser.parse_args(['-xyzZ'])\n" +"Namespace(x=True, y=True, z='Z')" +msgstr "" + +#: library/argparse.rst:1358 msgid "Invalid arguments" msgstr "" -#: library/argparse.rst:1550 +#: library/argparse.rst:1360 msgid "" "While parsing the command line, :meth:`~ArgumentParser.parse_args` checks " "for a variety of errors, including ambiguous options, invalid types, invalid " @@ -1447,11 +1954,33 @@ msgid "" "an error, it exits and prints the error along with a usage message::" msgstr "" -#: library/argparse.rst:1576 +#: library/argparse.rst:1365 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('--foo', type=int)\n" +">>> parser.add_argument('bar', nargs='?')\n" +"\n" +">>> # invalid type\n" +">>> parser.parse_args(['--foo', 'spam'])\n" +"usage: PROG [-h] [--foo FOO] [bar]\n" +"PROG: error: argument --foo: invalid int value: 'spam'\n" +"\n" +">>> # invalid option\n" +">>> parser.parse_args(['--bar'])\n" +"usage: PROG [-h] [--foo FOO] [bar]\n" +"PROG: error: no such option: --bar\n" +"\n" +">>> # wrong number of arguments\n" +">>> parser.parse_args(['spam', 'badger'])\n" +"usage: PROG [-h] [--foo FOO] [bar]\n" +"PROG: error: extra arguments found: badger" +msgstr "" + +#: library/argparse.rst:1386 msgid "Arguments containing ``-``" msgstr "" -#: library/argparse.rst:1578 +#: library/argparse.rst:1388 msgid "" "The :meth:`~ArgumentParser.parse_args` method attempts to give errors " "whenever the user has clearly made a mistake, but some situations are " @@ -1463,7 +1992,40 @@ msgid "" "negative numbers::" msgstr "" -#: library/argparse.rst:1616 +#: library/argparse.rst:1396 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-x')\n" +">>> parser.add_argument('foo', nargs='?')\n" +"\n" +">>> # no negative number options, so -1 is a positional argument\n" +">>> parser.parse_args(['-x', '-1'])\n" +"Namespace(foo=None, x='-1')\n" +"\n" +">>> # no negative number options, so -1 and -5 are positional arguments\n" +">>> parser.parse_args(['-x', '-1', '-5'])\n" +"Namespace(foo='-5', x='-1')\n" +"\n" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-1', dest='one')\n" +">>> parser.add_argument('foo', nargs='?')\n" +"\n" +">>> # negative number options present, so -1 is an option\n" +">>> parser.parse_args(['-1', 'X'])\n" +"Namespace(foo=None, one='X')\n" +"\n" +">>> # negative number options present, so -2 is an option\n" +">>> parser.parse_args(['-2'])\n" +"usage: PROG [-h] [-1 ONE] [foo]\n" +"PROG: error: no such option: -2\n" +"\n" +">>> # negative number options present, so both -1s are options\n" +">>> parser.parse_args(['-1', '-1'])\n" +"usage: PROG [-h] [-1 ONE] [foo]\n" +"PROG: error: argument -1: expected one argument" +msgstr "" + +#: library/argparse.rst:1426 msgid "" "If you have positional arguments that must begin with ``-`` and don't look " "like negative numbers, you can insert the pseudo-argument ``'--'`` which " @@ -1471,152 +2033,232 @@ msgid "" "positional argument::" msgstr "" -#: library/argparse.rst:1624 +#: library/argparse.rst:1431 +msgid "" +">>> parser.parse_args(['--', '-f'])\n" +"Namespace(foo='-f', one=None)" +msgstr "" + +#: library/argparse.rst:1434 msgid "" "See also :ref:`the argparse howto on ambiguous arguments ` for more details." msgstr "" -#: library/argparse.rst:1630 +#: library/argparse.rst:1440 msgid "Argument abbreviations (prefix matching)" msgstr "" -#: library/argparse.rst:1632 +#: library/argparse.rst:1442 msgid "" "The :meth:`~ArgumentParser.parse_args` method :ref:`by default " "` allows long options to be abbreviated to a prefix, if the " "abbreviation is unambiguous (the prefix matches a unique option)::" msgstr "" -#: library/argparse.rst:1647 +#: library/argparse.rst:1446 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-bacon')\n" +">>> parser.add_argument('-badger')\n" +">>> parser.parse_args('-bac MMM'.split())\n" +"Namespace(bacon='MMM', badger=None)\n" +">>> parser.parse_args('-bad WOOD'.split())\n" +"Namespace(bacon=None, badger='WOOD')\n" +">>> parser.parse_args('-ba BA'.split())\n" +"usage: PROG [-h] [-bacon BACON] [-badger BADGER]\n" +"PROG: error: ambiguous option: -ba could match -badger, -bacon" +msgstr "" + +#: library/argparse.rst:1457 msgid "" "An error is produced for arguments that could produce more than one options. " "This feature can be disabled by setting :ref:`allow_abbrev` to ``False``." msgstr "" -#: library/argparse.rst:1653 +#: library/argparse.rst:1463 msgid "Beyond ``sys.argv``" msgstr "" -#: library/argparse.rst:1655 +#: library/argparse.rst:1465 msgid "" -"Sometimes it may be useful to have an ArgumentParser parse arguments other " -"than those of :data:`sys.argv`. This can be accomplished by passing a list " -"of strings to :meth:`~ArgumentParser.parse_args`. This is useful for " -"testing at the interactive prompt::" +"Sometimes it may be useful to have an :class:`ArgumentParser` parse " +"arguments other than those of :data:`sys.argv`. This can be accomplished by " +"passing a list of strings to :meth:`~ArgumentParser.parse_args`. This is " +"useful for testing at the interactive prompt::" msgstr "" -#: library/argparse.rst:1675 +#: library/argparse.rst:1470 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument(\n" +"... 'integers', metavar='int', type=int, choices=range(10),\n" +"... nargs='+', help='an integer in the range 0..9')\n" +">>> parser.add_argument(\n" +"... '--sum', dest='accumulate', action='store_const', const=sum,\n" +"... default=max, help='sum the integers (default: find the max)')\n" +">>> parser.parse_args(['1', '2', '3', '4'])\n" +"Namespace(accumulate=, integers=[1, 2, 3, 4])\n" +">>> parser.parse_args(['1', '2', '3', '4', '--sum'])\n" +"Namespace(accumulate=, integers=[1, 2, 3, 4])" +msgstr "" + +#: library/argparse.rst:1485 msgid "The Namespace object" msgstr "" -#: library/argparse.rst:1679 +#: library/argparse.rst:1489 msgid "" "Simple class used by default by :meth:`~ArgumentParser.parse_args` to create " "an object holding attributes and return it." msgstr "" -#: library/argparse.rst:1682 +#: library/argparse.rst:1492 msgid "" "This class is deliberately simple, just an :class:`object` subclass with a " "readable string representation. If you prefer to have dict-like view of the " "attributes, you can use the standard Python idiom, :func:`vars`::" msgstr "" -#: library/argparse.rst:1692 +#: library/argparse.rst:1496 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo')\n" +">>> args = parser.parse_args(['--foo', 'BAR'])\n" +">>> vars(args)\n" +"{'foo': 'BAR'}" +msgstr "" + +#: library/argparse.rst:1502 msgid "" "It may also be useful to have an :class:`ArgumentParser` assign attributes " "to an already existing object, rather than a new :class:`Namespace` object. " "This can be achieved by specifying the ``namespace=`` keyword argument::" msgstr "" -#: library/argparse.rst:1708 +#: library/argparse.rst:1506 +msgid "" +">>> class C:\n" +"... pass\n" +"...\n" +">>> c = C()\n" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo')\n" +">>> parser.parse_args(args=['--foo', 'BAR'], namespace=c)\n" +">>> c.foo\n" +"'BAR'" +msgstr "" + +#: library/argparse.rst:1518 msgid "Other utilities" msgstr "" -#: library/argparse.rst:1711 +#: library/argparse.rst:1521 msgid "Sub-commands" msgstr "" -#: library/argparse.rst:1718 +#: library/argparse.rst:1528 msgid "" -"Many programs split up their functionality into a number of sub-commands, " -"for example, the ``svn`` program can invoke sub-commands like ``svn " -"checkout``, ``svn update``, and ``svn commit``. Splitting up functionality " -"this way can be a particularly good idea when a program performs several " -"different functions which require different kinds of command-line " -"arguments. :class:`ArgumentParser` supports the creation of such sub-" -"commands with the :meth:`add_subparsers` method. The :meth:`add_subparsers` " -"method is normally called with no arguments and returns a special action " -"object. This object has a single method, :meth:`~_SubParsersAction." -"add_parser`, which takes a command name and any :class:`ArgumentParser` " -"constructor arguments, and returns an :class:`ArgumentParser` object that " -"can be modified as usual." +"Many programs split up their functionality into a number of subcommands, for " +"example, the ``svn`` program can invoke subcommands like ``svn checkout``, " +"``svn update``, and ``svn commit``. Splitting up functionality this way can " +"be a particularly good idea when a program performs several different " +"functions which require different kinds of command-line " +"arguments. :class:`ArgumentParser` supports the creation of such subcommands " +"with the :meth:`!add_subparsers` method. The :meth:`!add_subparsers` method " +"is normally called with no arguments and returns a special action object. " +"This object has a single method, :meth:`~_SubParsersAction.add_parser`, " +"which takes a command name and any :class:`!ArgumentParser` constructor " +"arguments, and returns an :class:`!ArgumentParser` object that can be " +"modified as usual." msgstr "" -#: library/argparse.rst:1730 +#: library/argparse.rst:1540 msgid "Description of parameters:" msgstr "" -#: library/argparse.rst:1732 +#: library/argparse.rst:1542 msgid "" -"title - title for the sub-parser group in help output; by default " +"*title* - title for the sub-parser group in help output; by default " "\"subcommands\" if description is provided, otherwise uses title for " "positional arguments" msgstr "" -#: library/argparse.rst:1736 +#: library/argparse.rst:1546 msgid "" -"description - description for the sub-parser group in help output, by " +"*description* - description for the sub-parser group in help output, by " "default ``None``" msgstr "" -#: library/argparse.rst:1739 +#: library/argparse.rst:1549 msgid "" -"prog - usage information that will be displayed with sub-command help, by " +"*prog* - usage information that will be displayed with sub-command help, by " "default the name of the program and any positional arguments before the " "subparser argument" msgstr "" -#: library/argparse.rst:1743 +#: library/argparse.rst:1553 msgid "" -"parser_class - class which will be used to create sub-parser instances, by " -"default the class of the current parser (e.g. ArgumentParser)" +"*parser_class* - class which will be used to create sub-parser instances, by " +"default the class of the current parser (e.g. :class:`ArgumentParser`)" msgstr "" -#: library/argparse.rst:1746 +#: library/argparse.rst:1556 msgid "" "action_ - the basic type of action to be taken when this argument is " "encountered at the command line" msgstr "" -#: library/argparse.rst:1749 +#: library/argparse.rst:1559 msgid "" "dest_ - name of the attribute under which sub-command name will be stored; " "by default ``None`` and no value is stored" msgstr "" -#: library/argparse.rst:1752 +#: library/argparse.rst:1562 msgid "" "required_ - Whether or not a subcommand must be provided, by default " "``False`` (added in 3.7)" msgstr "" -#: library/argparse.rst:1755 +#: library/argparse.rst:1565 msgid "help_ - help for sub-parser group in help output, by default ``None``" msgstr "" -#: library/argparse.rst:1757 +#: library/argparse.rst:1567 msgid "" -"metavar_ - string presenting available sub-commands in help; by default it " -"is ``None`` and presents sub-commands in form {cmd1, cmd2, ..}" +"metavar_ - string presenting available subcommands in help; by default it is " +"``None`` and presents subcommands in form {cmd1, cmd2, ..}" msgstr "" -#: library/argparse.rst:1760 +#: library/argparse.rst:1570 msgid "Some example usage::" msgstr "" -#: library/argparse.rst:1781 +#: library/argparse.rst:1572 +msgid "" +">>> # create the top-level parser\n" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('--foo', action='store_true', help='foo help')\n" +">>> subparsers = parser.add_subparsers(help='subcommand help')\n" +">>>\n" +">>> # create the parser for the \"a\" command\n" +">>> parser_a = subparsers.add_parser('a', help='a help')\n" +">>> parser_a.add_argument('bar', type=int, help='bar help')\n" +">>>\n" +">>> # create the parser for the \"b\" command\n" +">>> parser_b = subparsers.add_parser('b', help='b help')\n" +">>> parser_b.add_argument('--baz', choices=('X', 'Y', 'Z'), help='baz " +"help')\n" +">>>\n" +">>> # parse some argument lists\n" +">>> parser.parse_args(['a', '12'])\n" +"Namespace(bar=12, foo=False)\n" +">>> parser.parse_args(['--foo', 'b', '--baz', 'Z'])\n" +"Namespace(baz='Z', foo=True)" +msgstr "" + +#: library/argparse.rst:1591 msgid "" "Note that the object returned by :meth:`parse_args` will only contain " "attributes for the main parser and the subparser that was selected by the " @@ -1626,7 +2268,7 @@ msgid "" "``baz`` attributes are present." msgstr "" -#: library/argparse.rst:1788 +#: library/argparse.rst:1598 msgid "" "Similarly, when a help message is requested from a subparser, only the help " "for that particular parser will be printed. The help message will not " @@ -1635,21 +2277,82 @@ msgid "" "to :meth:`~_SubParsersAction.add_parser` as above.)" msgstr "" -#: library/argparse.rst:1824 +#: library/argparse.rst:1606 +msgid "" +">>> parser.parse_args(['--help'])\n" +"usage: PROG [-h] [--foo] {a,b} ...\n" +"\n" +"positional arguments:\n" +" {a,b} subcommand help\n" +" a a help\n" +" b b help\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo foo help\n" +"\n" +">>> parser.parse_args(['a', '--help'])\n" +"usage: PROG a [-h] bar\n" +"\n" +"positional arguments:\n" +" bar bar help\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"\n" +">>> parser.parse_args(['b', '--help'])\n" +"usage: PROG b [-h] [--baz {X,Y,Z}]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --baz {X,Y,Z} baz help" +msgstr "" + +#: library/argparse.rst:1634 msgid "" "The :meth:`add_subparsers` method also supports ``title`` and " "``description`` keyword arguments. When either is present, the subparser's " "commands will appear in their own group in the help output. For example::" msgstr "" -#: library/argparse.rst:1845 +#: library/argparse.rst:1638 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> subparsers = parser.add_subparsers(title='subcommands',\n" +"... description='valid subcommands',\n" +"... help='additional help')\n" +">>> subparsers.add_parser('foo')\n" +">>> subparsers.add_parser('bar')\n" +">>> parser.parse_args(['-h'])\n" +"usage: [-h] {foo,bar} ...\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"\n" +"subcommands:\n" +" valid subcommands\n" +"\n" +" {foo,bar} additional help" +msgstr "" + +#: library/argparse.rst:1655 msgid "" "Furthermore, ``add_parser`` supports an additional ``aliases`` argument, " "which allows multiple strings to refer to the same subparser. This example, " "like ``svn``, aliases ``co`` as a shorthand for ``checkout``::" msgstr "" -#: library/argparse.rst:1856 +#: library/argparse.rst:1659 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> subparsers = parser.add_subparsers()\n" +">>> checkout = subparsers.add_parser('checkout', aliases=['co'])\n" +">>> checkout.add_argument('foo')\n" +">>> parser.parse_args(['co', 'bar'])\n" +"Namespace(foo='bar')" +msgstr "" + +#: library/argparse.rst:1666 msgid "" "One particularly effective way of handling sub-commands is to combine the " "use of the :meth:`add_subparsers` method with calls to :meth:`set_defaults` " @@ -1657,7 +2360,42 @@ msgid "" "example::" msgstr "" -#: library/argparse.rst:1893 +#: library/argparse.rst:1671 +msgid "" +">>> # subcommand functions\n" +">>> def foo(args):\n" +"... print(args.x * args.y)\n" +"...\n" +">>> def bar(args):\n" +"... print('((%s))' % args.z)\n" +"...\n" +">>> # create the top-level parser\n" +">>> parser = argparse.ArgumentParser()\n" +">>> subparsers = parser.add_subparsers(required=True)\n" +">>>\n" +">>> # create the parser for the \"foo\" command\n" +">>> parser_foo = subparsers.add_parser('foo')\n" +">>> parser_foo.add_argument('-x', type=int, default=1)\n" +">>> parser_foo.add_argument('y', type=float)\n" +">>> parser_foo.set_defaults(func=foo)\n" +">>>\n" +">>> # create the parser for the \"bar\" command\n" +">>> parser_bar = subparsers.add_parser('bar')\n" +">>> parser_bar.add_argument('z')\n" +">>> parser_bar.set_defaults(func=bar)\n" +">>>\n" +">>> # parse the args and call whatever function was selected\n" +">>> args = parser.parse_args('foo 1 -x 2'.split())\n" +">>> args.func(args)\n" +"2.0\n" +">>>\n" +">>> # parse the args and call whatever function was selected\n" +">>> args = parser.parse_args('bar XYZYX'.split())\n" +">>> args.func(args)\n" +"((XYZYX))" +msgstr "" + +#: library/argparse.rst:1703 msgid "" "This way, you can let :meth:`parse_args` do the job of calling the " "appropriate function after argument parsing is complete. Associating " @@ -1667,65 +2405,140 @@ msgid "" "argument to the :meth:`add_subparsers` call will work::" msgstr "" -#: library/argparse.rst:1909 -msgid "New *required* keyword argument." +#: library/argparse.rst:1710 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> subparsers = parser.add_subparsers(dest='subparser_name')\n" +">>> subparser1 = subparsers.add_parser('1')\n" +">>> subparser1.add_argument('-x')\n" +">>> subparser2 = subparsers.add_parser('2')\n" +">>> subparser2.add_argument('y')\n" +">>> parser.parse_args(['2', 'frobble'])\n" +"Namespace(subparser_name='2', y='frobble')" msgstr "" -#: library/argparse.rst:1914 +#: library/argparse.rst:1719 +msgid "New *required* keyword-only parameter." +msgstr "" + +#: library/argparse.rst:1724 msgid "FileType objects" msgstr "" -#: library/argparse.rst:1918 +#: library/argparse.rst:1728 msgid "" "The :class:`FileType` factory creates objects that can be passed to the type " -"argument of :meth:`ArgumentParser.add_argument`. Arguments that have :class:" -"`FileType` objects as their type will open command-line arguments as files " -"with the requested modes, buffer sizes, encodings and error handling (see " -"the :func:`open` function for more details)::" +"argument of :meth:`ArgumentParser.add_argument`. Arguments that " +"have :class:`FileType` objects as their type will open command-line " +"arguments as files with the requested modes, buffer sizes, encodings and " +"error handling (see the :func:`open` function for more details)::" msgstr "" -#: library/argparse.rst:1930 +#: library/argparse.rst:1734 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--raw', type=argparse.FileType('wb', 0))\n" +">>> parser.add_argument('out', type=argparse.FileType('w', " +"encoding='UTF-8'))\n" +">>> parser.parse_args(['--raw', 'raw.dat', 'file.txt'])\n" +"Namespace(out=<_io.TextIOWrapper name='file.txt' mode='w' encoding='UTF-8'>, " +"raw=<_io.FileIO name='raw.dat' mode='wb'>)" +msgstr "" + +#: library/argparse.rst:1740 msgid "" "FileType objects understand the pseudo-argument ``'-'`` and automatically " "convert this into :data:`sys.stdin` for readable :class:`FileType` objects " "and :data:`sys.stdout` for writable :class:`FileType` objects::" msgstr "" -#: library/argparse.rst:1939 +#: library/argparse.rst:1744 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('infile', type=argparse.FileType('r'))\n" +">>> parser.parse_args(['-'])\n" +"Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" +msgstr "" + +#: library/argparse.rst:1749 msgid "Added the *encodings* and *errors* parameters." msgstr "" -#: library/argparse.rst:1944 +#: library/argparse.rst:1754 msgid "Argument groups" msgstr "" -#: library/argparse.rst:1948 +#: library/argparse.rst:1759 msgid "" "By default, :class:`ArgumentParser` groups command-line arguments into " "\"positional arguments\" and \"options\" when displaying help messages. When " "there is a better conceptual grouping of arguments than this default one, " -"appropriate groups can be created using the :meth:`add_argument_group` " +"appropriate groups can be created using the :meth:`!add_argument_group` " "method::" msgstr "" -#: library/argparse.rst:1965 +#: library/argparse.rst:1765 msgid "" -"The :meth:`add_argument_group` method returns an argument group object which " -"has an :meth:`~ArgumentParser.add_argument` method just like a regular :" -"class:`ArgumentParser`. When an argument is added to the group, the parser " -"treats it just like a normal argument, but displays the argument in a " -"separate group for help messages. The :meth:`add_argument_group` method " -"accepts *title* and *description* arguments which can be used to customize " -"this display::" +">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" +">>> group = parser.add_argument_group('group')\n" +">>> group.add_argument('--foo', help='foo help')\n" +">>> group.add_argument('bar', help='bar help')\n" +">>> parser.print_help()\n" +"usage: PROG [--foo FOO] bar\n" +"\n" +"group:\n" +" bar bar help\n" +" --foo FOO foo help" msgstr "" -#: library/argparse.rst:1991 +#: library/argparse.rst:1776 +msgid "" +"The :meth:`add_argument_group` method returns an argument group object which " +"has an :meth:`~ArgumentParser.add_argument` method just like a " +"regular :class:`ArgumentParser`. When an argument is added to the group, " +"the parser treats it just like a normal argument, but displays the argument " +"in a separate group for help messages. The :meth:`!add_argument_group` " +"method accepts *title* and *description* arguments which can be used to " +"customize this display::" +msgstr "" + +#: library/argparse.rst:1784 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" +">>> group1 = parser.add_argument_group('group1', 'group1 description')\n" +">>> group1.add_argument('foo', help='foo help')\n" +">>> group2 = parser.add_argument_group('group2', 'group2 description')\n" +">>> group2.add_argument('--bar', help='bar help')\n" +">>> parser.print_help()\n" +"usage: PROG [--bar BAR] foo\n" +"\n" +"group1:\n" +" group1 description\n" +"\n" +" foo foo help\n" +"\n" +"group2:\n" +" group2 description\n" +"\n" +" --bar BAR bar help" +msgstr "" + +#: library/argparse.rst:1802 +msgid "" +"The optional, keyword-only parameters argument_default_ and " +"conflict_handler_ allow for finer-grained control of the behavior of the " +"argument group. These parameters have the same meaning as in " +"the :class:`ArgumentParser` constructor, but apply specifically to the " +"argument group rather than the entire parser." +msgstr "" + +#: library/argparse.rst:1807 msgid "" "Note that any arguments not in your user-defined groups will end up back in " "the usual \"positional arguments\" and \"optional arguments\" sections." msgstr "" -#: library/argparse.rst:1994 +#: library/argparse.rst:1810 msgid "" "Calling :meth:`add_argument_group` on an argument group is deprecated. This " "feature was never supported and does not always work correctly. The function " @@ -1733,33 +2546,80 @@ msgid "" "future." msgstr "" -#: library/argparse.rst:2002 +#: library/argparse.rst:1818 msgid "Mutual exclusion" msgstr "" -#: library/argparse.rst:2006 +#: library/argparse.rst:1822 msgid "" -"Create a mutually exclusive group. :mod:`argparse` will make sure that only " +"Create a mutually exclusive group. :mod:`!argparse` will make sure that only " "one of the arguments in the mutually exclusive group was present on the " "command line::" msgstr "" -#: library/argparse.rst:2022 +#: library/argparse.rst:1826 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> group = parser.add_mutually_exclusive_group()\n" +">>> group.add_argument('--foo', action='store_true')\n" +">>> group.add_argument('--bar', action='store_false')\n" +">>> parser.parse_args(['--foo'])\n" +"Namespace(bar=True, foo=True)\n" +">>> parser.parse_args(['--bar'])\n" +"Namespace(bar=False, foo=False)\n" +">>> parser.parse_args(['--foo', '--bar'])\n" +"usage: PROG [-h] [--foo | --bar]\n" +"PROG: error: argument --bar: not allowed with argument --foo" +msgstr "" + +#: library/argparse.rst:1838 msgid "" "The :meth:`add_mutually_exclusive_group` method also accepts a *required* " "argument, to indicate that at least one of the mutually exclusive arguments " "is required::" msgstr "" -#: library/argparse.rst:2034 +#: library/argparse.rst:1842 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> group = parser.add_mutually_exclusive_group(required=True)\n" +">>> group.add_argument('--foo', action='store_true')\n" +">>> group.add_argument('--bar', action='store_false')\n" +">>> parser.parse_args([])\n" +"usage: PROG [-h] (--foo | --bar)\n" +"PROG: error: one of the arguments --foo --bar is required" +msgstr "" + +#: library/argparse.rst:1850 msgid "" "Note that currently mutually exclusive argument groups do not support the " -"*title* and *description* arguments of :meth:`~ArgumentParser." -"add_argument_group`. However, a mutually exclusive group can be added to an " -"argument group that has a title and description. For example::" +"*title* and *description* arguments " +"of :meth:`~ArgumentParser.add_argument_group`. However, a mutually exclusive " +"group can be added to an argument group that has a title and description. " +"For example::" msgstr "" -#: library/argparse.rst:2057 +#: library/argparse.rst:1856 +msgid "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> group = parser.add_argument_group('Group title', 'Group description')\n" +">>> exclusive_group = group.add_mutually_exclusive_group(required=True)\n" +">>> exclusive_group.add_argument('--foo', help='foo help')\n" +">>> exclusive_group.add_argument('--bar', help='bar help')\n" +">>> parser.print_help()\n" +"usage: PROG [-h] (--foo FOO | --bar BAR)\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"\n" +"Group title:\n" +" Group description\n" +"\n" +" --foo FOO foo help\n" +" --bar BAR bar help" +msgstr "" + +#: library/argparse.rst:1873 msgid "" "Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` " "on a mutually exclusive group is deprecated. These features were never " @@ -1767,85 +2627,112 @@ msgid "" "by accident through inheritance and will be removed in the future." msgstr "" -#: library/argparse.rst:2065 +#: library/argparse.rst:1881 msgid "Parser defaults" msgstr "" -#: library/argparse.rst:2069 +#: library/argparse.rst:1885 msgid "" -"Most of the time, the attributes of the object returned by :meth:" -"`parse_args` will be fully determined by inspecting the command-line " -"arguments and the argument actions. :meth:`set_defaults` allows some " +"Most of the time, the attributes of the object returned " +"by :meth:`parse_args` will be fully determined by inspecting the command-" +"line arguments and the argument actions. :meth:`set_defaults` allows some " "additional attributes that are determined without any inspection of the " "command line to be added::" msgstr "" -#: library/argparse.rst:2081 +#: library/argparse.rst:1891 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('foo', type=int)\n" +">>> parser.set_defaults(bar=42, baz='badger')\n" +">>> parser.parse_args(['736'])\n" +"Namespace(bar=42, baz='badger', foo=736)" +msgstr "" + +#: library/argparse.rst:1897 msgid "" "Note that parser-level defaults always override argument-level defaults::" msgstr "" -#: library/argparse.rst:2089 +#: library/argparse.rst:1899 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', default='bar')\n" +">>> parser.set_defaults(foo='spam')\n" +">>> parser.parse_args([])\n" +"Namespace(foo='spam')" +msgstr "" + +#: library/argparse.rst:1905 msgid "" "Parser-level defaults can be particularly useful when working with multiple " "parsers. See the :meth:`~ArgumentParser.add_subparsers` method for an " "example of this type." msgstr "" -#: library/argparse.rst:2095 +#: library/argparse.rst:1911 msgid "" -"Get the default value for a namespace attribute, as set by either :meth:" -"`~ArgumentParser.add_argument` or by :meth:`~ArgumentParser.set_defaults`::" +"Get the default value for a namespace attribute, as set by " +"either :meth:`~ArgumentParser.add_argument` or " +"by :meth:`~ArgumentParser.set_defaults`::" msgstr "" -#: library/argparse.rst:2106 +#: library/argparse.rst:1915 +msgid "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', default='badger')\n" +">>> parser.get_default('foo')\n" +"'badger'" +msgstr "" + +#: library/argparse.rst:1922 msgid "Printing help" msgstr "" -#: library/argparse.rst:2108 +#: library/argparse.rst:1924 msgid "" "In most typical applications, :meth:`~ArgumentParser.parse_args` will take " "care of formatting and printing any usage or error messages. However, " "several formatting methods are available:" msgstr "" -#: library/argparse.rst:2114 +#: library/argparse.rst:1930 msgid "" "Print a brief description of how the :class:`ArgumentParser` should be " "invoked on the command line. If *file* is ``None``, :data:`sys.stdout` is " "assumed." msgstr "" -#: library/argparse.rst:2120 +#: library/argparse.rst:1936 msgid "" "Print a help message, including the program usage and information about the " "arguments registered with the :class:`ArgumentParser`. If *file* is " "``None``, :data:`sys.stdout` is assumed." msgstr "" -#: library/argparse.rst:2124 +#: library/argparse.rst:1940 msgid "" "There are also variants of these methods that simply return a string instead " "of printing it:" msgstr "" -#: library/argparse.rst:2129 +#: library/argparse.rst:1945 msgid "" -"Return a string containing a brief description of how the :class:" -"`ArgumentParser` should be invoked on the command line." +"Return a string containing a brief description of how " +"the :class:`ArgumentParser` should be invoked on the command line." msgstr "" -#: library/argparse.rst:2134 +#: library/argparse.rst:1950 msgid "" "Return a string containing a help message, including the program usage and " "information about the arguments registered with the :class:`ArgumentParser`." msgstr "" -#: library/argparse.rst:2139 +#: library/argparse.rst:1955 msgid "Partial parsing" msgstr "" -#: library/argparse.rst:2143 +#: library/argparse.rst:1959 msgid "" "Sometimes a script may only parse a few of the command-line arguments, " "passing the remaining arguments on to another script or program. In these " @@ -1856,19 +2743,28 @@ msgid "" "remaining argument strings." msgstr "" -#: library/argparse.rst:2159 +#: library/argparse.rst:1968 msgid "" -":ref:`Prefix matching ` rules apply to :meth:" -"`~ArgumentParser.parse_known_args`. The parser may consume an option even if " -"it's just a prefix of one of its known options, instead of leaving it in the " -"remaining arguments list." +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action='store_true')\n" +">>> parser.add_argument('bar')\n" +">>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])\n" +"(Namespace(bar='BAR', foo=True), ['--badger', 'spam'])" msgstr "" -#: library/argparse.rst:2166 +#: library/argparse.rst:1975 +msgid "" +":ref:`Prefix matching ` rules apply " +"to :meth:`~ArgumentParser.parse_known_args`. The parser may consume an " +"option even if it's just a prefix of one of its known options, instead of " +"leaving it in the remaining arguments list." +msgstr "" + +#: library/argparse.rst:1982 msgid "Customizing file parsing" msgstr "" -#: library/argparse.rst:2170 +#: library/argparse.rst:1986 msgid "" "Arguments that are read from a file (see the *fromfile_prefix_chars* keyword " "argument to the :class:`ArgumentParser` constructor) are read one argument " @@ -1876,41 +2772,57 @@ msgid "" "reading." msgstr "" -#: library/argparse.rst:2175 +#: library/argparse.rst:1991 msgid "" "This method takes a single argument *arg_line* which is a string read from " "the argument file. It returns a list of arguments parsed from this string. " "The method is called once per line read from the argument file, in order." msgstr "" -#: library/argparse.rst:2179 +#: library/argparse.rst:1995 msgid "" "A useful override of this method is one that treats each space-separated " "word as an argument. The following example demonstrates how to do this::" msgstr "" -#: library/argparse.rst:2188 +#: library/argparse.rst:1998 +msgid "" +"class MyArgumentParser(argparse.ArgumentParser):\n" +" def convert_arg_line_to_args(self, arg_line):\n" +" return arg_line.split()" +msgstr "" + +#: library/argparse.rst:2004 msgid "Exiting methods" msgstr "" -#: library/argparse.rst:2192 +#: library/argparse.rst:2008 msgid "" "This method terminates the program, exiting with the specified *status* and, " -"if given, it prints a *message* before that. The user can override this " -"method to handle these steps differently::" +"if given, it prints a *message* to :data:`sys.stderr` before that. The user " +"can override this method to handle these steps differently::" msgstr "" -#: library/argparse.rst:2204 +#: library/argparse.rst:2012 msgid "" -"This method prints a usage message including the *message* to the standard " -"error and terminates the program with a status code of 2." +"class ErrorCatchingArgumentParser(argparse.ArgumentParser):\n" +" def exit(self, status=0, message=None):\n" +" if status:\n" +" raise Exception(f'Exiting because of an error: {message}')\n" +" exit(status)" msgstr "" -#: library/argparse.rst:2209 +#: library/argparse.rst:2020 +msgid "" +"This method prints a usage message, including the *message*, " +"to :data:`sys.stderr` and terminates the program with a status code of 2." +msgstr "" + +#: library/argparse.rst:2025 msgid "Intermixed parsing" msgstr "" -#: library/argparse.rst:2214 +#: library/argparse.rst:2030 msgid "" "A number of Unix commands allow the user to intermix optional arguments with " "positional arguments. The :meth:`~ArgumentParser.parse_intermixed_args` " @@ -1918,23 +2830,36 @@ msgid "" "parsing style." msgstr "" -#: library/argparse.rst:2219 +#: library/argparse.rst:2035 +msgid "" +"These parsers do not support all the :mod:`!argparse` features, and will " +"raise exceptions if unsupported features are used. In particular, " +"subparsers, and mutually exclusive groups that include both optionals and " +"positionals are not supported." +msgstr "" + +#: library/argparse.rst:2040 msgid "" -"These parsers do not support all the argparse features, and will raise " -"exceptions if unsupported features are used. In particular, subparsers, and " -"mutually exclusive groups that include both optionals and positionals are " -"not supported." +"The following example shows the difference " +"between :meth:`~ArgumentParser.parse_known_args` " +"and :meth:`~ArgumentParser.parse_intermixed_args`: the former returns " +"``['2', '3']`` as unparsed arguments, while the latter collects all the " +"positionals into ``rest``. ::" msgstr "" -#: library/argparse.rst:2224 +#: library/argparse.rst:2046 msgid "" -"The following example shows the difference between :meth:`~ArgumentParser." -"parse_known_args` and :meth:`~ArgumentParser.parse_intermixed_args`: the " -"former returns ``['2', '3']`` as unparsed arguments, while the latter " -"collects all the positionals into ``rest``. ::" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo')\n" +">>> parser.add_argument('cmd')\n" +">>> parser.add_argument('rest', nargs='*', type=int)\n" +">>> parser.parse_known_args('doit 1 --foo bar 2 3'.split())\n" +"(Namespace(cmd='doit', foo='bar', rest=[1]), ['2', '3'])\n" +">>> parser.parse_intermixed_args('doit 1 --foo bar 2 3'.split())\n" +"Namespace(cmd='doit', foo='bar', rest=[1, 2, 3])" msgstr "" -#: library/argparse.rst:2239 +#: library/argparse.rst:2055 msgid "" ":meth:`~ArgumentParser.parse_known_intermixed_args` returns a two item tuple " "containing the populated namespace and the list of remaining argument " @@ -1942,139 +2867,82 @@ msgid "" "there are any remaining unparsed argument strings." msgstr "" -#: library/argparse.rst:2249 -msgid "Upgrading optparse code" +#: library/argparse.rst:2064 +msgid "Registering custom types or actions" msgstr "" -#: library/argparse.rst:2251 +#: library/argparse.rst:2068 msgid "" -"Originally, the :mod:`argparse` module had attempted to maintain " -"compatibility with :mod:`optparse`. However, :mod:`optparse` was difficult " -"to extend transparently, particularly with the changes required to support " -"the new ``nargs=`` specifiers and better usage messages. When most " -"everything in :mod:`optparse` had either been copy-pasted over or monkey-" -"patched, it no longer seemed practical to try to maintain the backwards " -"compatibility." +"Sometimes it's desirable to use a custom string in error messages to provide " +"more user-friendly output. In these cases, :meth:`!register` can be used to " +"register custom actions or types with a parser and allow you to reference " +"the type by their registered name instead of their callable name." msgstr "" -#: library/argparse.rst:2258 +#: library/argparse.rst:2073 msgid "" -"The :mod:`argparse` module improves on the standard library :mod:`optparse` " -"module in a number of ways including:" -msgstr "" - -#: library/argparse.rst:2261 -msgid "Handling positional arguments." -msgstr "" - -#: library/argparse.rst:2262 -msgid "Supporting sub-commands." -msgstr "" - -#: library/argparse.rst:2263 -msgid "Allowing alternative option prefixes like ``+`` and ``/``." +"The :meth:`!register` method accepts three arguments - a *registry_name*, " +"specifying the internal registry where the object will be stored (e.g., " +"``action``, ``type``), *value*, which is the key under which the object will " +"be registered, and object, the callable to be registered." msgstr "" -#: library/argparse.rst:2264 -msgid "Handling zero-or-more and one-or-more style arguments." -msgstr "" - -#: library/argparse.rst:2265 -msgid "Producing more informative usage messages." -msgstr "" - -#: library/argparse.rst:2266 -msgid "Providing a much simpler interface for custom ``type`` and ``action``." -msgstr "" - -#: library/argparse.rst:2268 -msgid "A partial upgrade path from :mod:`optparse` to :mod:`argparse`:" -msgstr "" - -#: library/argparse.rst:2270 -msgid "" -"Replace all :meth:`optparse.OptionParser.add_option` calls with :meth:" -"`ArgumentParser.add_argument` calls." -msgstr "" - -#: library/argparse.rst:2273 -msgid "" -"Replace ``(options, args) = parser.parse_args()`` with ``args = parser." -"parse_args()`` and add additional :meth:`ArgumentParser.add_argument` calls " -"for the positional arguments. Keep in mind that what was previously called " -"``options``, now in the :mod:`argparse` context is called ``args``." -msgstr "" - -#: library/argparse.rst:2278 +#: library/argparse.rst:2078 msgid "" -"Replace :meth:`optparse.OptionParser.disable_interspersed_args` by using :" -"meth:`~ArgumentParser.parse_intermixed_args` instead of :meth:" -"`~ArgumentParser.parse_args`." +"The following example shows how to register a custom type with a parser::" msgstr "" -#: library/argparse.rst:2282 +#: library/argparse.rst:2080 msgid "" -"Replace callback actions and the ``callback_*`` keyword arguments with " -"``type`` or ``action`` arguments." +">>> import argparse\n" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.register('type', 'hexadecimal integer', lambda s: int(s, 16))\n" +">>> parser.add_argument('--foo', type='hexadecimal integer')\n" +"_StoreAction(option_strings=['--foo'], dest='foo', nargs=None, const=None, " +"default=None, type='hexadecimal integer', choices=None, required=False, " +"help=None, metavar=None, deprecated=False)\n" +">>> parser.parse_args(['--foo', '0xFA'])\n" +"Namespace(foo=250)\n" +">>> parser.parse_args(['--foo', '1.2'])\n" +"usage: PROG [-h] [--foo FOO]\n" +"PROG: error: argument --foo: invalid 'hexadecimal integer' value: '1.2'" msgstr "" -#: library/argparse.rst:2285 -msgid "" -"Replace string names for ``type`` keyword arguments with the corresponding " -"type objects (e.g. int, float, complex, etc)." -msgstr "" - -#: library/argparse.rst:2288 -msgid "" -"Replace :class:`optparse.Values` with :class:`Namespace` and :exc:`optparse." -"OptionError` and :exc:`optparse.OptionValueError` with :exc:`ArgumentError`." -msgstr "" - -#: library/argparse.rst:2292 -msgid "" -"Replace strings with implicit arguments such as ``%default`` or ``%prog`` " -"with the standard Python syntax to use dictionaries to format strings, that " -"is, ``%(default)s`` and ``%(prog)s``." -msgstr "" - -#: library/argparse.rst:2296 -msgid "" -"Replace the OptionParser constructor ``version`` argument with a call to " -"``parser.add_argument('--version', action='version', version='')``." -msgstr "" - -#: library/argparse.rst:2300 +#: library/argparse.rst:2092 msgid "Exceptions" msgstr "" -#: library/argparse.rst:2304 +#: library/argparse.rst:2096 msgid "An error from creating or using an argument (optional or positional)." msgstr "" -#: library/argparse.rst:2306 +#: library/argparse.rst:2098 msgid "" "The string value of this exception is the message, augmented with " "information about the argument that caused it." msgstr "" -#: library/argparse.rst:2311 +#: library/argparse.rst:2103 msgid "" "Raised when something goes wrong converting a command line string to a type." msgstr "" -#: library/argparse.rst:980 +#: library/argparse.rst:2107 +msgid "Guides and Tutorials" +msgstr "" + +#: library/argparse.rst:801 msgid "? (question mark)" msgstr "" -#: library/argparse.rst:1014 library/argparse.rst:1028 +#: library/argparse.rst:835 library/argparse.rst:849 msgid "in argparse module" msgstr "" -#: library/argparse.rst:1014 +#: library/argparse.rst:835 msgid "* (asterisk)" msgstr "" -#: library/argparse.rst:1028 +#: library/argparse.rst:849 msgid "+ (plus)" msgstr "" diff --git a/library/array.po b/library/array.po index c0389520..af5293ef 100644 --- a/library/array.po +++ b/library/array.po @@ -8,22 +8,23 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/array.rst:2 -msgid ":mod:`array` --- Efficient arrays of numeric values" +msgid ":mod:`!array` --- Efficient arrays of numeric values" msgstr "" #: library/array.rst:11 msgid "" "This module defines an object type which can compactly represent an array of " -"basic values: characters, integers, floating point numbers. Arrays are " +"basic values: characters, integers, floating-point numbers. Arrays are " "sequence types and behave very much like lists, except that the type of " "objects stored in them is constrained. The type is specified at object " "creation time by using a :dfn:`type code`, which is a single character. The " @@ -220,9 +221,9 @@ msgstr "" #: library/array.rst:78 msgid "" "A new array whose items are restricted by *typecode*, and initialized from " -"the optional *initializer* value, which must be a :class:`bytes` or :class:" -"`bytearray` object, a Unicode string, or iterable over elements of the " -"appropriate type." +"the optional *initializer* value, which must be a :class:`bytes` " +"or :class:`bytearray` object, a Unicode string, or iterable over elements of " +"the appropriate type." msgstr "" #: library/array.rst:83 @@ -286,9 +287,9 @@ msgstr "" #: library/array.rst:135 msgid "" "\"Byteswap\" all items of the array. This is only supported for values " -"which are 1, 2, 4, or 8 bytes in size; for other types of values, :exc:" -"`RuntimeError` is raised. It is useful when reading data from a file " -"written on a machine with a different byte order." +"which are 1, 2, 4, or 8 bytes in size; for other types of " +"values, :exc:`RuntimeError` is raised. It is useful when reading data from " +"a file written on a machine with a different byte order." msgstr "" #: library/array.rst:143 @@ -298,16 +299,17 @@ msgstr "" #: library/array.rst:148 msgid "" "Append items from *iterable* to the end of the array. If *iterable* is " -"another array, it must have *exactly* the same type code; if not, :exc:" -"`TypeError` will be raised. If *iterable* is not an array, it must be " -"iterable and its elements must be the right type to be appended to the array." +"another array, it must have *exactly* the same type code; if " +"not, :exc:`TypeError` will be raised. If *iterable* is not an array, it " +"must be iterable and its elements must be the right type to be appended to " +"the array." msgstr "" #: library/array.rst:156 msgid "" "Appends items from the :term:`bytes-like object`, interpreting its content " -"as an array of machine values (as if it had been read from a file using the :" -"meth:`fromfile` method)." +"as an array of machine values (as if it had been read from a file using " +"the :meth:`fromfile` method)." msgstr "" #: library/array.rst:160 @@ -317,31 +319,31 @@ msgstr "" #: library/array.rst:166 msgid "" "Read *n* items (as machine values) from the :term:`file object` *f* and " -"append them to the end of the array. If less than *n* items are available, :" -"exc:`EOFError` is raised, but the items that were available are still " -"inserted into the array." +"append them to the end of the array. If less than *n* items are " +"available, :exc:`EOFError` is raised, but the items that were available are " +"still inserted into the array." msgstr "" #: library/array.rst:174 msgid "" -"Append items from the list. This is equivalent to ``for x in list: a." -"append(x)`` except that if there is a type error, the array is unchanged." +"Append items from the list. This is equivalent to ``for x in list: " +"a.append(x)`` except that if there is a type error, the array is unchanged." msgstr "" #: library/array.rst:180 msgid "" "Extends this array with data from the given Unicode string. The array must " -"have type code ``'u'``; otherwise a :exc:`ValueError` is raised. Use ``array." -"frombytes(unicodestring.encode(enc))`` to append Unicode data to an array of " -"some other type." +"have type code ``'u'``; otherwise a :exc:`ValueError` is raised. Use " +"``array.frombytes(unicodestring.encode(enc))`` to append Unicode data to an " +"array of some other type." msgstr "" #: library/array.rst:188 msgid "" "Return the smallest *i* such that *i* is the index of the first occurrence " "of *x* in the array. The optional arguments *start* and *stop* can be " -"specified to search for *x* within a subsection of the array. Raise :exc:" -"`ValueError` if *x* is not found." +"specified to search for *x* within a subsection of the array. " +"Raise :exc:`ValueError` if *x* is not found." msgstr "" #: library/array.rst:193 @@ -401,13 +403,22 @@ msgid "" "initializer)``. The *initializer* is omitted if the array is empty, " "otherwise it is a Unicode string if the *typecode* is ``'u'``, otherwise it " "is a list of numbers. The string representation is guaranteed to be able to " -"be converted back to an array with the same type and value using :func:" -"`eval`, so long as the :class:`~array.array` class has been imported using " -"``from array import array``. Variables ``inf`` and ``nan`` must also be " -"defined if it contains corresponding floating point values. Examples::" +"be converted back to an array with the same type and value " +"using :func:`eval`, so long as the :class:`~array.array` class has been " +"imported using ``from array import array``. Variables ``inf`` and ``nan`` " +"must also be defined if it contains corresponding floating-point values. " +"Examples::" msgstr "" -#: library/array.rst:268 +#: library/array.rst:259 +msgid "" +"array('l')\n" +"array('u', 'hello \\u2641')\n" +"array('l', [1, 2, 3, 4, 5])\n" +"array('d', [1.0, 2.0, 3.14, -inf, nan])" +msgstr "" + +#: library/array.rst:267 msgid "Module :mod:`struct`" msgstr "" @@ -415,7 +426,7 @@ msgstr "" msgid "Packing and unpacking of heterogeneous binary data." msgstr "" -#: library/array.rst:272 +#: library/array.rst:270 msgid "Module :mod:`xdrlib`" msgstr "" diff --git a/library/ast.po b/library/ast.po index d1d13730..3b5ab213 100644 --- a/library/ast.po +++ b/library/ast.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/ast.rst:2 -msgid ":mod:`ast` --- Abstract Syntax Trees" +msgid ":mod:`!ast` --- Abstract Syntax Trees" msgstr "" #: library/ast.rst:14 @@ -34,12 +35,12 @@ msgstr "" #: library/ast.rst:23 msgid "" -"An abstract syntax tree can be generated by passing :data:`ast." -"PyCF_ONLY_AST` as a flag to the :func:`compile` built-in function, or using " -"the :func:`parse` helper provided in this module. The result will be a tree " -"of objects whose classes all inherit from :class:`ast.AST`. An abstract " -"syntax tree can be compiled into a Python code object using the built-in :" -"func:`compile` function." +"An abstract syntax tree can be generated by " +"passing :data:`ast.PyCF_ONLY_AST` as a flag to the :func:`compile` built-in " +"function, or using the :func:`parse` helper provided in this module. The " +"result will be a tree of objects whose classes all inherit " +"from :class:`ast.AST`. An abstract syntax tree can be compiled into a " +"Python code object using the built-in :func:`compile` function." msgstr "" #: library/ast.rst:33 @@ -50,6 +51,180 @@ msgstr "" msgid "The abstract grammar is currently defined as follows:" msgstr "" +#: library/ast.rst:37 +msgid "" +"-- ASDL's 4 builtin types are:\n" +"-- identifier, int, string, constant\n" +"\n" +"module Python\n" +"{\n" +" mod = Module(stmt* body, type_ignore* type_ignores)\n" +" | Interactive(stmt* body)\n" +" | Expression(expr body)\n" +" | FunctionType(expr* argtypes, expr returns)\n" +"\n" +" stmt = FunctionDef(identifier name, arguments args,\n" +" stmt* body, expr* decorator_list, expr? returns,\n" +" string? type_comment, type_param* type_params)\n" +" | AsyncFunctionDef(identifier name, arguments args,\n" +" stmt* body, expr* decorator_list, expr? " +"returns,\n" +" string? type_comment, type_param* type_params)\n" +"\n" +" | ClassDef(identifier name,\n" +" expr* bases,\n" +" keyword* keywords,\n" +" stmt* body,\n" +" expr* decorator_list,\n" +" type_param* type_params)\n" +" | Return(expr? value)\n" +"\n" +" | Delete(expr* targets)\n" +" | Assign(expr* targets, expr value, string? type_comment)\n" +" | TypeAlias(expr name, type_param* type_params, expr value)\n" +" | AugAssign(expr target, operator op, expr value)\n" +" -- 'simple' indicates that we annotate simple name without parens\n" +" | AnnAssign(expr target, expr annotation, expr? value, int " +"simple)\n" +"\n" +" -- use 'orelse' because else is a keyword in target languages\n" +" | For(expr target, expr iter, stmt* body, stmt* orelse, string? " +"type_comment)\n" +" | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, " +"string? type_comment)\n" +" | While(expr test, stmt* body, stmt* orelse)\n" +" | If(expr test, stmt* body, stmt* orelse)\n" +" | With(withitem* items, stmt* body, string? type_comment)\n" +" | AsyncWith(withitem* items, stmt* body, string? type_comment)\n" +"\n" +" | Match(expr subject, match_case* cases)\n" +"\n" +" | Raise(expr? exc, expr? cause)\n" +" | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* " +"finalbody)\n" +" | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* " +"finalbody)\n" +" | Assert(expr test, expr? msg)\n" +"\n" +" | Import(alias* names)\n" +" | ImportFrom(identifier? module, alias* names, int? level)\n" +"\n" +" | Global(identifier* names)\n" +" | Nonlocal(identifier* names)\n" +" | Expr(expr value)\n" +" | Pass | Break | Continue\n" +"\n" +" -- col_offset is the byte offset in the utf8 string the parser " +"uses\n" +" attributes (int lineno, int col_offset, int? end_lineno, int? " +"end_col_offset)\n" +"\n" +" -- BoolOp() can use left & right?\n" +" expr = BoolOp(boolop op, expr* values)\n" +" | NamedExpr(expr target, expr value)\n" +" | BinOp(expr left, operator op, expr right)\n" +" | UnaryOp(unaryop op, expr operand)\n" +" | Lambda(arguments args, expr body)\n" +" | IfExp(expr test, expr body, expr orelse)\n" +" | Dict(expr* keys, expr* values)\n" +" | Set(expr* elts)\n" +" | ListComp(expr elt, comprehension* generators)\n" +" | SetComp(expr elt, comprehension* generators)\n" +" | DictComp(expr key, expr value, comprehension* generators)\n" +" | GeneratorExp(expr elt, comprehension* generators)\n" +" -- the grammar constrains where yield expressions can occur\n" +" | Await(expr value)\n" +" | Yield(expr? value)\n" +" | YieldFrom(expr value)\n" +" -- need sequences for compare to distinguish between\n" +" -- x < 4 < 3 and (x < 4) < 3\n" +" | Compare(expr left, cmpop* ops, expr* comparators)\n" +" | Call(expr func, expr* args, keyword* keywords)\n" +" | FormattedValue(expr value, int conversion, expr? format_spec)\n" +" | JoinedStr(expr* values)\n" +" | Constant(constant value, string? kind)\n" +"\n" +" -- the following expression can appear in assignment context\n" +" | Attribute(expr value, identifier attr, expr_context ctx)\n" +" | Subscript(expr value, expr slice, expr_context ctx)\n" +" | Starred(expr value, expr_context ctx)\n" +" | Name(identifier id, expr_context ctx)\n" +" | List(expr* elts, expr_context ctx)\n" +" | Tuple(expr* elts, expr_context ctx)\n" +"\n" +" -- can appear only in Subscript\n" +" | Slice(expr? lower, expr? upper, expr? step)\n" +"\n" +" -- col_offset is the byte offset in the utf8 string the parser " +"uses\n" +" attributes (int lineno, int col_offset, int? end_lineno, int? " +"end_col_offset)\n" +"\n" +" expr_context = Load | Store | Del\n" +"\n" +" boolop = And | Or\n" +"\n" +" operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift\n" +" | RShift | BitOr | BitXor | BitAnd | FloorDiv\n" +"\n" +" unaryop = Invert | Not | UAdd | USub\n" +"\n" +" cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn\n" +"\n" +" comprehension = (expr target, expr iter, expr* ifs, int is_async)\n" +"\n" +" excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)\n" +" attributes (int lineno, int col_offset, int? end_lineno, " +"int? end_col_offset)\n" +"\n" +" arguments = (arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs,\n" +" expr* kw_defaults, arg? kwarg, expr* defaults)\n" +"\n" +" arg = (identifier arg, expr? annotation, string? type_comment)\n" +" attributes (int lineno, int col_offset, int? end_lineno, int? " +"end_col_offset)\n" +"\n" +" -- keyword arguments supplied to call (NULL identifier for **kwargs)\n" +" keyword = (identifier? arg, expr value)\n" +" attributes (int lineno, int col_offset, int? end_lineno, int? " +"end_col_offset)\n" +"\n" +" -- import name with optional 'as' alias.\n" +" alias = (identifier name, identifier? asname)\n" +" attributes (int lineno, int col_offset, int? end_lineno, int? " +"end_col_offset)\n" +"\n" +" withitem = (expr context_expr, expr? optional_vars)\n" +"\n" +" match_case = (pattern pattern, expr? guard, stmt* body)\n" +"\n" +" pattern = MatchValue(expr value)\n" +" | MatchSingleton(constant value)\n" +" | MatchSequence(pattern* patterns)\n" +" | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n" +" | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, " +"pattern* kwd_patterns)\n" +"\n" +" | MatchStar(identifier? name)\n" +" -- The optional \"rest\" MatchMapping parameter handles " +"capturing extra mapping keys\n" +"\n" +" | MatchAs(pattern? pattern, identifier? name)\n" +" | MatchOr(pattern* patterns)\n" +"\n" +" attributes (int lineno, int col_offset, int end_lineno, int " +"end_col_offset)\n" +"\n" +" type_ignore = TypeIgnore(int lineno, string tag)\n" +"\n" +" type_param = TypeVar(identifier name, expr? bound)\n" +" | ParamSpec(identifier name)\n" +" | TypeVarTuple(identifier name)\n" +" attributes (int lineno, int col_offset, int end_lineno, int " +"end_col_offset)\n" +"}\n" +msgstr "" + #: library/ast.rst:42 msgid "Node classes" msgstr "" @@ -57,9 +232,9 @@ msgstr "" #: library/ast.rst:46 msgid "" "This is the base of all AST node classes. The actual node classes are " -"derived from the :file:`Parser/Python.asdl` file, which is reproduced :ref:" -"`above `. They are defined in the :mod:`!_ast` C module " -"and re-exported in :mod:`ast`." +"derived from the :file:`Parser/Python.asdl` file, which is " +"reproduced :ref:`above `. They are defined in the :mod:`!" +"_ast` C module and re-exported in :mod:`ast`." msgstr "" #: library/ast.rst:51 @@ -97,14 +272,14 @@ msgstr "" #: library/ast.rst:82 msgid "" -"Instances of :class:`ast.expr` and :class:`ast.stmt` subclasses have :attr:" -"`lineno`, :attr:`col_offset`, :attr:`end_lineno`, and :attr:`end_col_offset` " -"attributes. The :attr:`lineno` and :attr:`end_lineno` are the first and " -"last line numbers of source text span (1-indexed so the first line is line " -"1) and the :attr:`col_offset` and :attr:`end_col_offset` are the " -"corresponding UTF-8 byte offsets of the first and last tokens that generated " -"the node. The UTF-8 offset is recorded because the parser uses UTF-8 " -"internally." +"Instances of :class:`ast.expr` and :class:`ast.stmt` subclasses " +"have :attr:`lineno`, :attr:`col_offset`, :attr:`end_lineno`, " +"and :attr:`end_col_offset` attributes. The :attr:`lineno` " +"and :attr:`end_lineno` are the first and last line numbers of source text " +"span (1-indexed so the first line is line 1) and the :attr:`col_offset` " +"and :attr:`end_col_offset` are the corresponding UTF-8 byte offsets of the " +"first and last tokens that generated the node. The UTF-8 offset is recorded " +"because the parser uses UTF-8 internally." msgstr "" #: library/ast.rst:91 @@ -138,10 +313,28 @@ msgid "" "use ::" msgstr "" +#: library/ast.rst:106 +msgid "" +"node = ast.UnaryOp()\n" +"node.op = ast.USub()\n" +"node.operand = ast.Constant()\n" +"node.operand.value = 5\n" +"node.operand.lineno = 0\n" +"node.operand.col_offset = 0\n" +"node.lineno = 0\n" +"node.col_offset = 0" +msgstr "" + #: library/ast.rst:115 msgid "or the more compact ::" msgstr "" +#: library/ast.rst:117 +msgid "" +"node = ast.UnaryOp(ast.USub(), ast.Constant(5, lineno=0, col_offset=0),\n" +" lineno=0, col_offset=0)" +msgstr "" + #: library/ast.rst:122 msgid "Class :class:`ast.Constant` is now used for all constants." msgstr "" @@ -154,10 +347,10 @@ msgstr "" #: library/ast.rst:131 msgid "" -"Old classes :class:`!ast.Num`, :class:`!ast.Str`, :class:`!ast.Bytes`, :" -"class:`!ast.NameConstant` and :class:`!ast.Ellipsis` are still available, " -"but they will be removed in future Python releases. In the meantime, " -"instantiating them will return an instance of a different class." +"Old classes :class:`!ast.Num`, :class:`!ast.Str`, :class:`!" +"ast.Bytes`, :class:`!ast.NameConstant` and :class:`!ast.Ellipsis` are still " +"available, but they will be removed in future Python releases. In the " +"meantime, instantiating them will return an instance of a different class." msgstr "" #: library/ast.rst:138 @@ -170,8 +363,9 @@ msgstr "" #: library/ast.rst:144 msgid "" "The descriptions of the specific node classes displayed here were initially " -"adapted from the fantastic `Green Tree Snakes `__ project and all its contributors." +"adapted from the fantastic `Green Tree Snakes `__ project and all its " +"contributors." msgstr "" #: library/ast.rst:153 @@ -185,13 +379,25 @@ msgid "" msgstr "" #: library/ast.rst:160 -msgid "*body* is a :class:`list` of the module's :ref:`ast-statements`." +msgid "``body`` is a :class:`list` of the module's :ref:`ast-statements`." msgstr "" #: library/ast.rst:162 msgid "" -"*type_ignores* is a :class:`list` of the module's type ignore comments; see :" -"func:`ast.parse` for more details." +"``type_ignores`` is a :class:`list` of the module's type ignore comments; " +"see :func:`ast.parse` for more details." +msgstr "" + +#: library/ast.rst:165 +msgid "" +">>> print(ast.dump(ast.parse('x = 1'), indent=4))\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Name(id='x', ctx=Store())],\n" +" value=Constant(value=1))],\n" +" type_ignores=[])" msgstr "" #: library/ast.rst:179 @@ -202,10 +408,17 @@ msgstr "" #: library/ast.rst:182 msgid "" -"*body* is a single node, one of the :ref:`expression types `." msgstr "" +#: library/ast.rst:255 +msgid "" +">>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Constant(value=123))" +msgstr "" + #: library/ast.rst:194 msgid "" "A single :ref:`interactive input `, like in :ref:`tut-interac`. " @@ -213,7 +426,22 @@ msgid "" msgstr "" #: library/ast.rst:197 -msgid "*body* is a :class:`list` of :ref:`statement nodes `." +msgid "``body`` is a :class:`list` of :ref:`statement nodes `." +msgstr "" + +#: library/ast.rst:199 +msgid "" +">>> print(ast.dump(ast.parse('x = 1; y = 2', mode='single'), indent=4))\n" +"Interactive(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Name(id='x', ctx=Store())],\n" +" value=Constant(value=1)),\n" +" Assign(\n" +" targets=[\n" +" Name(id='y', ctx=Store())],\n" +" value=Constant(value=2))])" msgstr "" #: library/ast.rst:216 @@ -227,13 +455,34 @@ msgstr "" msgid "Such type comments would look like this::" msgstr "" +#: library/ast.rst:222 +msgid "" +"def sum_two_number(a, b):\n" +" # type: (int, int) -> int\n" +" return a + b" +msgstr "" + #: library/ast.rst:226 msgid "" -"*argtypes* is a :class:`list` of :ref:`expression nodes `." +"``argtypes`` is a :class:`list` of :ref:`expression nodes `." msgstr "" #: library/ast.rst:228 -msgid "*returns* is a single :ref:`expression node `." +msgid "``returns`` is a single :ref:`expression node `." +msgstr "" + +#: library/ast.rst:230 +msgid "" +">>> print(ast.dump(ast.parse('(int, str) -> List[int]', mode='func_type'), " +"indent=4))\n" +"FunctionType(\n" +" argtypes=[\n" +" Name(id='int', ctx=Load()),\n" +" Name(id='str', ctx=Load())],\n" +" returns=Subscript(\n" +" value=Name(id='List', ctx=Load()),\n" +" slice=Name(id='int', ctx=Load()),\n" +" ctx=Load()))" msgstr "" #: library/ast.rst:246 @@ -291,8 +540,32 @@ msgstr "" #: library/ast.rst:284 msgid "" -"An f-string, comprising a series of :class:`FormattedValue` and :class:" -"`Constant` nodes." +"An f-string, comprising a series of :class:`FormattedValue` " +"and :class:`Constant` nodes." +msgstr "" + +#: library/ast.rst:287 +msgid "" +">>> print(ast.dump(ast.parse('f\"sin({a}) is {sin(a):.3}\"', mode='eval'), " +"indent=4))\n" +"Expression(\n" +" body=JoinedStr(\n" +" values=[\n" +" Constant(value='sin('),\n" +" FormattedValue(\n" +" value=Name(id='a', ctx=Load()),\n" +" conversion=-1),\n" +" Constant(value=') is '),\n" +" FormattedValue(\n" +" value=Call(\n" +" func=Name(id='sin', ctx=Load()),\n" +" args=[\n" +" Name(id='a', ctx=Load())],\n" +" keywords=[]),\n" +" conversion=-1,\n" +" format_spec=JoinedStr(\n" +" values=[\n" +" Constant(value='.3')]))]))" msgstr "" #: library/ast.rst:313 @@ -302,10 +575,41 @@ msgid "" "``(x,y)=something``), and :class:`Load` otherwise." msgstr "" +#: library/ast.rst:317 +msgid "" +">>> print(ast.dump(ast.parse('[1, 2, 3]', mode='eval'), indent=4))\n" +"Expression(\n" +" body=List(\n" +" elts=[\n" +" Constant(value=1),\n" +" Constant(value=2),\n" +" Constant(value=3)],\n" +" ctx=Load()))\n" +">>> print(ast.dump(ast.parse('(1, 2, 3)', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Tuple(\n" +" elts=[\n" +" Constant(value=1),\n" +" Constant(value=2),\n" +" Constant(value=3)],\n" +" ctx=Load()))" +msgstr "" + #: library/ast.rst:339 msgid "A set. ``elts`` holds a list of nodes representing the set's elements." msgstr "" +#: library/ast.rst:341 +msgid "" +">>> print(ast.dump(ast.parse('{1, 2, 3}', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Set(\n" +" elts=[\n" +" Constant(value=1),\n" +" Constant(value=2),\n" +" Constant(value=3)]))" +msgstr "" + #: library/ast.rst:354 msgid "" "A dictionary. ``keys`` and ``values`` hold lists of nodes representing the " @@ -320,6 +624,19 @@ msgid "" "corresponding position in ``keys``." msgstr "" +#: library/ast.rst:362 +msgid "" +">>> print(ast.dump(ast.parse('{\"a\":1, **d}', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Dict(\n" +" keys=[\n" +" Constant(value='a'),\n" +" None],\n" +" values=[\n" +" Constant(value=1),\n" +" Name(id='d', ctx=Load())]))" +msgstr "" + #: library/ast.rst:376 msgid "Variables" msgstr "" @@ -337,11 +654,56 @@ msgid "" "distinguish these cases." msgstr "" +#: library/ast.rst:392 +msgid "" +">>> print(ast.dump(ast.parse('a'), indent=4))\n" +"Module(\n" +" body=[\n" +" Expr(\n" +" value=Name(id='a', ctx=Load()))],\n" +" type_ignores=[])\n" +"\n" +">>> print(ast.dump(ast.parse('a = 1'), indent=4))\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Name(id='a', ctx=Store())],\n" +" value=Constant(value=1))],\n" +" type_ignores=[])\n" +"\n" +">>> print(ast.dump(ast.parse('del a'), indent=4))\n" +"Module(\n" +" body=[\n" +" Delete(\n" +" targets=[\n" +" Name(id='a', ctx=Del())])],\n" +" type_ignores=[])" +msgstr "" + #: library/ast.rst:421 msgid "" -"A ``*var`` variable reference. ``value`` holds the variable, typically a :" -"class:`Name` node. This type must be used when building a :class:`Call` node " -"with ``*args``." +"A ``*var`` variable reference. ``value`` holds the variable, typically " +"a :class:`Name` node. This type must be used when building a :class:`Call` " +"node with ``*args``." +msgstr "" + +#: library/ast.rst:425 +msgid "" +">>> print(ast.dump(ast.parse('a, *b = it'), indent=4))\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Tuple(\n" +" elts=[\n" +" Name(id='a', ctx=Store()),\n" +" Starred(\n" +" value=Name(id='b', ctx=Store()),\n" +" ctx=Store())],\n" +" ctx=Store())],\n" +" value=Name(id='it', ctx=Load()))],\n" +" type_ignores=[])" msgstr "" #: library/ast.rst:446 @@ -352,9 +714,21 @@ msgstr "" msgid "" "When an expression, such as a function call, appears as a statement by " "itself with its return value not used or stored, it is wrapped in this " -"container. ``value`` holds one of the other nodes in this section, a :class:" -"`Constant`, a :class:`Name`, a :class:`Lambda`, a :class:`Yield` or :class:" -"`YieldFrom` node." +"container. ``value`` holds one of the other nodes in this section, " +"a :class:`Constant`, a :class:`Name`, a :class:`Lambda`, a :class:`Yield` " +"or :class:`YieldFrom` node." +msgstr "" + +#: library/ast.rst:455 +msgid "" +">>> print(ast.dump(ast.parse('-a'), indent=4))\n" +"Module(\n" +" body=[\n" +" Expr(\n" +" value=UnaryOp(\n" +" op=USub(),\n" +" operand=Name(id='a', ctx=Load())))],\n" +" type_ignores=[])" msgstr "" #: library/ast.rst:469 @@ -369,12 +743,31 @@ msgid "" "is the ``~`` operator." msgstr "" +#: library/ast.rst:481 +msgid "" +">>> print(ast.dump(ast.parse('not x', mode='eval'), indent=4))\n" +"Expression(\n" +" body=UnaryOp(\n" +" op=Not(),\n" +" operand=Name(id='x', ctx=Load())))" +msgstr "" + #: library/ast.rst:492 msgid "" "A binary operation (like addition or division). ``op`` is the operator, and " "``left`` and ``right`` are any expression nodes." msgstr "" +#: library/ast.rst:495 +msgid "" +">>> print(ast.dump(ast.parse('x + y', mode='eval'), indent=4))\n" +"Expression(\n" +" body=BinOp(\n" +" left=Name(id='x', ctx=Load()),\n" +" op=Add(),\n" +" right=Name(id='y', ctx=Load())))" +msgstr "" + #: library/ast.rst:519 msgid "Binary operator tokens." msgstr "" @@ -391,6 +784,17 @@ msgstr "" msgid "This doesn't include ``not``, which is a :class:`UnaryOp`." msgstr "" +#: library/ast.rst:531 +msgid "" +">>> print(ast.dump(ast.parse('x or y', mode='eval'), indent=4))\n" +"Expression(\n" +" body=BoolOp(\n" +" op=Or(),\n" +" values=[\n" +" Name(id='x', ctx=Load()),\n" +" Name(id='y', ctx=Load())]))" +msgstr "" + #: library/ast.rst:545 msgid "Boolean operator tokens." msgstr "" @@ -402,14 +806,28 @@ msgid "" "values after the first element in the comparison." msgstr "" +#: library/ast.rst:554 +msgid "" +">>> print(ast.dump(ast.parse('1 <= a < 10', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Compare(\n" +" left=Constant(value=1),\n" +" ops=[\n" +" LtE(),\n" +" Lt()],\n" +" comparators=[\n" +" Name(id='a', ctx=Load()),\n" +" Constant(value=10)]))" +msgstr "" + #: library/ast.rst:579 msgid "Comparison operator tokens." msgstr "" #: library/ast.rst:584 msgid "" -"A function call. ``func`` is the function, which will often be a :class:" -"`Name` or :class:`Attribute` object. Of the arguments:" +"A function call. ``func`` is the function, which will often be " +"a :class:`Name` or :class:`Attribute` object. Of the arguments:" msgstr "" #: library/ast.rst:587 @@ -428,6 +846,26 @@ msgid "" "they can be empty lists." msgstr "" +#: library/ast.rst:594 +msgid "" +">>> print(ast.dump(ast.parse('func(a, b=c, *d, **e)', mode='eval'), " +"indent=4))\n" +"Expression(\n" +" body=Call(\n" +" func=Name(id='func', ctx=Load()),\n" +" args=[\n" +" Name(id='a', ctx=Load()),\n" +" Starred(\n" +" value=Name(id='d', ctx=Load()),\n" +" ctx=Load())],\n" +" keywords=[\n" +" keyword(\n" +" arg='b',\n" +" value=Name(id='c', ctx=Load())),\n" +" keyword(\n" +" value=Name(id='e', ctx=Load()))]))" +msgstr "" + #: library/ast.rst:615 msgid "" "A keyword argument to a function call or class definition. ``arg`` is a raw " @@ -440,20 +878,49 @@ msgid "" "in the following example, all three are :class:`Name` nodes." msgstr "" +#: library/ast.rst:624 +msgid "" +">>> print(ast.dump(ast.parse('a if b else c', mode='eval'), indent=4))\n" +"Expression(\n" +" body=IfExp(\n" +" test=Name(id='b', ctx=Load()),\n" +" body=Name(id='a', ctx=Load()),\n" +" orelse=Name(id='c', ctx=Load())))" +msgstr "" + #: library/ast.rst:636 msgid "" -"Attribute access, e.g. ``d.keys``. ``value`` is a node, typically a :class:" -"`Name`. ``attr`` is a bare string giving the name of the attribute, and " -"``ctx`` is :class:`Load`, :class:`Store` or :class:`Del` according to how " -"the attribute is acted on." +"Attribute access, e.g. ``d.keys``. ``value`` is a node, typically " +"a :class:`Name`. ``attr`` is a bare string giving the name of the attribute, " +"and ``ctx`` is :class:`Load`, :class:`Store` or :class:`Del` according to " +"how the attribute is acted on." +msgstr "" + +#: library/ast.rst:641 +msgid "" +">>> print(ast.dump(ast.parse('snake.colour', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Attribute(\n" +" value=Name(id='snake', ctx=Load()),\n" +" attr='colour',\n" +" ctx=Load()))" msgstr "" #: library/ast.rst:653 msgid "" "A named expression. This AST node is produced by the assignment expressions " -"operator (also known as the walrus operator). As opposed to the :class:" -"`Assign` node in which the first argument can be multiple nodes, in this " -"case both ``target`` and ``value`` must be single nodes." +"operator (also known as the walrus operator). As opposed to " +"the :class:`Assign` node in which the first argument can be multiple nodes, " +"in this case both ``target`` and ``value`` must be single nodes." +msgstr "" + +#: library/ast.rst:658 +msgid "" +">>> print(ast.dump(ast.parse('(x := 4)', mode='eval'), indent=4))\n" +"Expression(\n" +" body=NamedExpr(\n" +" target=Name(id='x', ctx=Store()),\n" +" value=Constant(value=4)))" msgstr "" #: library/ast.rst:669 @@ -463,9 +930,26 @@ msgstr "" #: library/ast.rst:673 msgid "" "A subscript, such as ``l[1]``. ``value`` is the subscripted object (usually " -"sequence or mapping). ``slice`` is an index, slice or key. It can be a :" -"class:`Tuple` and contain a :class:`Slice`. ``ctx`` is :class:`Load`, :class:" -"`Store` or :class:`Del` according to the action performed with the subscript." +"sequence or mapping). ``slice`` is an index, slice or key. It can be " +"a :class:`Tuple` and contain a :class:`Slice`. ``ctx`` " +"is :class:`Load`, :class:`Store` or :class:`Del` according to the action " +"performed with the subscript." +msgstr "" + +#: library/ast.rst:679 +msgid "" +">>> print(ast.dump(ast.parse('l[1:2, 3]', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Subscript(\n" +" value=Name(id='l', ctx=Load()),\n" +" slice=Tuple(\n" +" elts=[\n" +" Slice(\n" +" lower=Constant(value=1),\n" +" upper=Constant(value=2)),\n" +" Constant(value=3)],\n" +" ctx=Load()),\n" +" ctx=Load()))" msgstr "" #: library/ast.rst:697 @@ -475,6 +959,18 @@ msgid "" "or as an element of :class:`Tuple`." msgstr "" +#: library/ast.rst:701 +msgid "" +">>> print(ast.dump(ast.parse('l[1:2]', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Subscript(\n" +" value=Name(id='l', ctx=Load()),\n" +" slice=Slice(\n" +" lower=Constant(value=1),\n" +" upper=Constant(value=2)),\n" +" ctx=Load()))" +msgstr "" + #: library/ast.rst:714 msgid "Comprehensions" msgstr "" @@ -490,6 +986,47 @@ msgstr "" msgid "``generators`` is a list of :class:`comprehension` nodes." msgstr "" +#: library/ast.rst:727 +msgid "" +">>> print(ast.dump(ast.parse('[x for x in numbers]', mode='eval'), " +"indent=4))\n" +"Expression(\n" +" body=ListComp(\n" +" elt=Name(id='x', ctx=Load()),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='x', ctx=Store()),\n" +" iter=Name(id='numbers', ctx=Load()),\n" +" ifs=[],\n" +" is_async=0)]))\n" +">>> print(ast.dump(ast.parse('{x: x**2 for x in numbers}', mode='eval'), " +"indent=4))\n" +"Expression(\n" +" body=DictComp(\n" +" key=Name(id='x', ctx=Load()),\n" +" value=BinOp(\n" +" left=Name(id='x', ctx=Load()),\n" +" op=Pow(),\n" +" right=Constant(value=2)),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='x', ctx=Store()),\n" +" iter=Name(id='numbers', ctx=Load()),\n" +" ifs=[],\n" +" is_async=0)]))\n" +">>> print(ast.dump(ast.parse('{x for x in numbers}', mode='eval'), " +"indent=4))\n" +"Expression(\n" +" body=SetComp(\n" +" elt=Name(id='x', ctx=Load()),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='x', ctx=Store()),\n" +" iter=Name(id='numbers', ctx=Load()),\n" +" ifs=[],\n" +" is_async=0)]))" +msgstr "" + #: library/ast.rst:767 msgid "" "One ``for`` clause in a comprehension. ``target`` is the reference to use " @@ -504,6 +1041,71 @@ msgid "" "for`` instead of ``for``). The value is an integer (0 or 1)." msgstr "" +#: library/ast.rst:775 +msgid "" +">>> print(ast.dump(ast.parse('[ord(c) for line in file for c in line]', " +"mode='eval'),\n" +"... indent=4)) # Multiple comprehensions in one.\n" +"Expression(\n" +" body=ListComp(\n" +" elt=Call(\n" +" func=Name(id='ord', ctx=Load()),\n" +" args=[\n" +" Name(id='c', ctx=Load())],\n" +" keywords=[]),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='line', ctx=Store()),\n" +" iter=Name(id='file', ctx=Load()),\n" +" ifs=[],\n" +" is_async=0),\n" +" comprehension(\n" +" target=Name(id='c', ctx=Store()),\n" +" iter=Name(id='line', ctx=Load()),\n" +" ifs=[],\n" +" is_async=0)]))\n" +"\n" +">>> print(ast.dump(ast.parse('(n**2 for n in it if n>5 if n<10)', " +"mode='eval'),\n" +"... indent=4)) # generator comprehension\n" +"Expression(\n" +" body=GeneratorExp(\n" +" elt=BinOp(\n" +" left=Name(id='n', ctx=Load()),\n" +" op=Pow(),\n" +" right=Constant(value=2)),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='n', ctx=Store()),\n" +" iter=Name(id='it', ctx=Load()),\n" +" ifs=[\n" +" Compare(\n" +" left=Name(id='n', ctx=Load()),\n" +" ops=[\n" +" Gt()],\n" +" comparators=[\n" +" Constant(value=5)]),\n" +" Compare(\n" +" left=Name(id='n', ctx=Load()),\n" +" ops=[\n" +" Lt()],\n" +" comparators=[\n" +" Constant(value=10)])],\n" +" is_async=0)]))\n" +"\n" +">>> print(ast.dump(ast.parse('[i async for i in soc]', mode='eval'),\n" +"... indent=4)) # Async comprehension\n" +"Expression(\n" +" body=ListComp(\n" +" elt=Name(id='i', ctx=Load()),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='i', ctx=Store()),\n" +" iter=Name(id='soc', ctx=Load()),\n" +" ifs=[],\n" +" is_async=1)]))" +msgstr "" + #: library/ast.rst:841 msgid "Statements" msgstr "" @@ -521,22 +1123,103 @@ msgid "" "``targets``." msgstr "" -#: library/ast.rst:1161 library/ast.rst:1891 +#: library/ast.rst:1165 library/ast.rst:1895 msgid "" "``type_comment`` is an optional string with the type annotation as a comment." msgstr "" +#: library/ast.rst:855 +msgid "" +">>> print(ast.dump(ast.parse('a = b = 1'), indent=4)) # Multiple assignment\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Name(id='a', ctx=Store()),\n" +" Name(id='b', ctx=Store())],\n" +" value=Constant(value=1))],\n" +" type_ignores=[])\n" +"\n" +">>> print(ast.dump(ast.parse('a,b = c'), indent=4)) # Unpacking\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Tuple(\n" +" elts=[\n" +" Name(id='a', ctx=Store()),\n" +" Name(id='b', ctx=Store())],\n" +" ctx=Store())],\n" +" value=Name(id='c', ctx=Load()))],\n" +" type_ignores=[])" +msgstr "" + #: library/ast.rst:883 msgid "" "An assignment with a type annotation. ``target`` is a single node and can be " -"a :class:`Name`, a :class:`Attribute` or a :class:`Subscript`. " -"``annotation`` is the annotation, such as a :class:`Constant` or :class:" -"`Name` node. ``value`` is a single optional node. ``simple`` is a boolean " -"integer set to True for a :class:`Name` node in ``target`` that do not " -"appear in between parenthesis and are hence pure names and not expressions." -msgstr "" - -#: library/ast.rst:938 +"a :class:`Name`, an :class:`Attribute` or a :class:`Subscript`. " +"``annotation`` is the annotation, such as a :class:`Constant` " +"or :class:`Name` node. ``value`` is a single optional node." +msgstr "" + +#: library/ast.rst:888 +msgid "" +"``simple`` is always either 0 (indicating a \"complex\" target) or 1 " +"(indicating a \"simple\" target). A \"simple\" target consists solely of " +"a :class:`Name` node that does not appear between parentheses; all other " +"targets are considered complex. Only simple targets appear in " +"the :attr:`~object.__annotations__` dictionary of modules and classes." +msgstr "" + +#: library/ast.rst:894 +msgid "" +">>> print(ast.dump(ast.parse('c: int'), indent=4))\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Name(id='c', ctx=Store()),\n" +" annotation=Name(id='int', ctx=Load()),\n" +" simple=1)],\n" +" type_ignores=[])\n" +"\n" +">>> print(ast.dump(ast.parse('(a): int = 1'), indent=4)) # Annotation with " +"parenthesis\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Name(id='a', ctx=Store()),\n" +" annotation=Name(id='int', ctx=Load()),\n" +" value=Constant(value=1),\n" +" simple=0)],\n" +" type_ignores=[])\n" +"\n" +">>> print(ast.dump(ast.parse('a.b: int'), indent=4)) # Attribute annotation\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Attribute(\n" +" value=Name(id='a', ctx=Load()),\n" +" attr='b',\n" +" ctx=Store()),\n" +" annotation=Name(id='int', ctx=Load()),\n" +" simple=0)],\n" +" type_ignores=[])\n" +"\n" +">>> print(ast.dump(ast.parse('a[1]: int'), indent=4)) # Subscript " +"annotation\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Subscript(\n" +" value=Name(id='a', ctx=Load()),\n" +" slice=Constant(value=1),\n" +" ctx=Store()),\n" +" annotation=Name(id='int', ctx=Load()),\n" +" simple=0)],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:942 msgid "" "Augmented assignment, such as ``a += 1``. In the following example, " "``target`` is a :class:`Name` node for ``x`` (with the :class:`Store` " @@ -544,58 +1227,139 @@ msgid "" "value for 1." msgstr "" -#: library/ast.rst:943 +#: library/ast.rst:947 msgid "" "The ``target`` attribute cannot be of class :class:`Tuple` or :class:`List`, " "unlike the targets of :class:`Assign`." msgstr "" -#: library/ast.rst:960 +#: library/ast.rst:950 +msgid "" +">>> print(ast.dump(ast.parse('x += 2'), indent=4))\n" +"Module(\n" +" body=[\n" +" AugAssign(\n" +" target=Name(id='x', ctx=Store()),\n" +" op=Add(),\n" +" value=Constant(value=2))],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:964 msgid "" "A ``raise`` statement. ``exc`` is the exception object to be raised, " "normally a :class:`Call` or :class:`Name`, or ``None`` for a standalone " "``raise``. ``cause`` is the optional part for ``y`` in ``raise x from y``." msgstr "" -#: library/ast.rst:977 +#: library/ast.rst:968 +msgid "" +">>> print(ast.dump(ast.parse('raise x from y'), indent=4))\n" +"Module(\n" +" body=[\n" +" Raise(\n" +" exc=Name(id='x', ctx=Load()),\n" +" cause=Name(id='y', ctx=Load()))],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:981 msgid "" "An assertion. ``test`` holds the condition, such as a :class:`Compare` node. " "``msg`` holds the failure message." msgstr "" -#: library/ast.rst:993 +#: library/ast.rst:984 +msgid "" +">>> print(ast.dump(ast.parse('assert x,y'), indent=4))\n" +"Module(\n" +" body=[\n" +" Assert(\n" +" test=Name(id='x', ctx=Load()),\n" +" msg=Name(id='y', ctx=Load()))],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:997 +msgid "" +"Represents a ``del`` statement. ``targets`` is a list of nodes, such " +"as :class:`Name`, :class:`Attribute` or :class:`Subscript` nodes." +msgstr "" + +#: library/ast.rst:1000 msgid "" -"Represents a ``del`` statement. ``targets`` is a list of nodes, such as :" -"class:`Name`, :class:`Attribute` or :class:`Subscript` nodes." +">>> print(ast.dump(ast.parse('del x,y,z'), indent=4))\n" +"Module(\n" +" body=[\n" +" Delete(\n" +" targets=[\n" +" Name(id='x', ctx=Del()),\n" +" Name(id='y', ctx=Del()),\n" +" Name(id='z', ctx=Del())])],\n" +" type_ignores=[])" msgstr "" -#: library/ast.rst:1011 +#: library/ast.rst:1015 msgid "A ``pass`` statement." msgstr "" -#: library/ast.rst:1024 +#: library/ast.rst:1017 +msgid "" +">>> print(ast.dump(ast.parse('pass'), indent=4))\n" +"Module(\n" +" body=[\n" +" Pass()],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1028 msgid "" "A :ref:`type alias ` created through the :keyword:`type` " -"statement. ``name`` is the name of the alias, ``type_params`` is a list of :" -"ref:`type parameters `, and ``value`` is the value of the " -"type alias." +"statement. ``name`` is the name of the alias, ``type_params`` is a list " +"of :ref:`type parameters `, and ``value`` is the value of " +"the type alias." +msgstr "" + +#: library/ast.rst:1033 +msgid "" +">>> print(ast.dump(ast.parse('type Alias = int'), indent=4))\n" +"Module(\n" +" body=[\n" +" TypeAlias(\n" +" name=Name(id='Alias', ctx=Store()),\n" +" type_params=[],\n" +" value=Name(id='int', ctx=Load()))],\n" +" type_ignores=[])" msgstr "" -#: library/ast.rst:1042 +#: library/ast.rst:1046 msgid "" "Other statements which are only applicable inside functions or loops are " "described in other sections." msgstr "" -#: library/ast.rst:1046 +#: library/ast.rst:1050 msgid "Imports" msgstr "" -#: library/ast.rst:1050 +#: library/ast.rst:1054 msgid "An import statement. ``names`` is a list of :class:`alias` nodes." msgstr "" -#: library/ast.rst:1067 +#: library/ast.rst:1056 +msgid "" +">>> print(ast.dump(ast.parse('import x,y,z'), indent=4))\n" +"Module(\n" +" body=[\n" +" Import(\n" +" names=[\n" +" alias(name='x'),\n" +" alias(name='y'),\n" +" alias(name='z')])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1071 msgid "" "Represents ``from x import y``. ``module`` is a raw string of the 'from' " "name, without any leading dots, or ``None`` for statements such as ``from . " @@ -603,69 +1367,267 @@ msgid "" "import (0 means absolute import)." msgstr "" -#: library/ast.rst:1089 +#: library/ast.rst:1076 +msgid "" +">>> print(ast.dump(ast.parse('from y import x,y,z'), indent=4))\n" +"Module(\n" +" body=[\n" +" ImportFrom(\n" +" module='y',\n" +" names=[\n" +" alias(name='x'),\n" +" alias(name='y'),\n" +" alias(name='z')],\n" +" level=0)],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1093 msgid "" "Both parameters are raw strings of the names. ``asname`` can be ``None`` if " "the regular name is to be used." msgstr "" -#: library/ast.rst:1106 +#: library/ast.rst:1096 +msgid "" +">>> print(ast.dump(ast.parse('from ..foo.bar import a as b, c'), indent=4))\n" +"Module(\n" +" body=[\n" +" ImportFrom(\n" +" module='foo.bar',\n" +" names=[\n" +" alias(name='a', asname='b'),\n" +" alias(name='c')],\n" +" level=2)],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1110 msgid "Control flow" msgstr "" -#: library/ast.rst:1109 +#: library/ast.rst:1113 msgid "" "Optional clauses such as ``else`` are stored as an empty list if they're not " "present." msgstr "" -#: library/ast.rst:1114 +#: library/ast.rst:1118 msgid "" -"An ``if`` statement. ``test`` holds a single node, such as a :class:" -"`Compare` node. ``body`` and ``orelse`` each hold a list of nodes." +"An ``if`` statement. ``test`` holds a single node, such as " +"a :class:`Compare` node. ``body`` and ``orelse`` each hold a list of nodes." msgstr "" -#: library/ast.rst:1117 +#: library/ast.rst:1121 msgid "" "``elif`` clauses don't have a special representation in the AST, but rather " "appear as extra :class:`If` nodes within the ``orelse`` section of the " "previous one." msgstr "" -#: library/ast.rst:1152 +#: library/ast.rst:1125 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... if x:\n" +"... ...\n" +"... elif y:\n" +"... ...\n" +"... else:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" If(\n" +" test=Name(id='x', ctx=Load()),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" orelse=[\n" +" If(\n" +" test=Name(id='y', ctx=Load()),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" orelse=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1156 msgid "" "A ``for`` loop. ``target`` holds the variable(s) the loop assigns to, as a " -"single :class:`Name`, :class:`Tuple`, :class:`List`, :class:`Attribute` or :" -"class:`Subscript` node. ``iter`` holds the item to be looped over, again as " -"a single node. ``body`` and ``orelse`` contain lists of nodes to execute. " +"single :class:`Name`, :class:`Tuple`, :class:`List`, :class:`Attribute` " +"or :class:`Subscript` node. ``iter`` holds the item to be looped over, again " +"as a single node. ``body`` and ``orelse`` contain lists of nodes to execute. " "Those in ``orelse`` are executed if the loop finishes normally, rather than " "via a ``break`` statement." msgstr "" -#: library/ast.rst:1187 +#: library/ast.rst:1167 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... for x in y:\n" +"... ...\n" +"... else:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" For(\n" +" target=Name(id='x', ctx=Store()),\n" +" iter=Name(id='y', ctx=Load()),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" orelse=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1191 msgid "" "A ``while`` loop. ``test`` holds the condition, such as a :class:`Compare` " "node." msgstr "" -#: library/ast.rst:1214 +#: library/ast.rst:1194 +msgid "" +">> print(ast.dump(ast.parse(\"\"\"\n" +"... while x:\n" +"... ...\n" +"... else:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" While(\n" +" test=Name(id='x', ctx=Load()),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" orelse=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1218 msgid "The ``break`` and ``continue`` statements." msgstr "" -#: library/ast.rst:1249 +#: library/ast.rst:1220 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... for a in b:\n" +"... if a > 5:\n" +"... break\n" +"... else:\n" +"... continue\n" +"...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" For(\n" +" target=Name(id='a', ctx=Store()),\n" +" iter=Name(id='b', ctx=Load()),\n" +" body=[\n" +" If(\n" +" test=Compare(\n" +" left=Name(id='a', ctx=Load()),\n" +" ops=[\n" +" Gt()],\n" +" comparators=[\n" +" Constant(value=5)]),\n" +" body=[\n" +" Break()],\n" +" orelse=[\n" +" Continue()])],\n" +" orelse=[])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1253 msgid "" "``try`` blocks. All attributes are list of nodes to execute, except for " "``handlers``, which is a list of :class:`ExceptHandler` nodes." msgstr "" -#: library/ast.rst:1295 +#: library/ast.rst:1256 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... try:\n" +"... ...\n" +"... except Exception:\n" +"... ...\n" +"... except OtherException as e:\n" +"... ...\n" +"... else:\n" +"... ...\n" +"... finally:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Try(\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" handlers=[\n" +" ExceptHandler(\n" +" type=Name(id='Exception', ctx=Load()),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))]),\n" +" ExceptHandler(\n" +" type=Name(id='OtherException', ctx=Load()),\n" +" name='e',\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])],\n" +" orelse=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" finalbody=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1299 msgid "" "``try`` blocks which are followed by ``except*`` clauses. The attributes are " "the same as for :class:`Try` but the :class:`ExceptHandler` nodes in " "``handlers`` are interpreted as ``except*`` blocks rather then ``except``." msgstr "" -#: library/ast.rst:1327 +#: library/ast.rst:1303 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... try:\n" +"... ...\n" +"... except* Exception:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" TryStar(\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" handlers=[\n" +" ExceptHandler(\n" +" type=Name(id='Exception', ctx=Load()),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])],\n" +" orelse=[],\n" +" finalbody=[])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1331 msgid "" "A single ``except`` clause. ``type`` is the exception type it will match, " "typically a :class:`Name` node (or ``None`` for a catch-all ``except:`` " @@ -673,53 +1635,146 @@ msgid "" "``None`` if the clause doesn't have ``as foo``. ``body`` is a list of nodes." msgstr "" -#: library/ast.rst:1361 +#: library/ast.rst:1336 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... try:\n" +"... a + 1\n" +"... except TypeError:\n" +"... pass\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Try(\n" +" body=[\n" +" Expr(\n" +" value=BinOp(\n" +" left=Name(id='a', ctx=Load()),\n" +" op=Add(),\n" +" right=Constant(value=1)))],\n" +" handlers=[\n" +" ExceptHandler(\n" +" type=Name(id='TypeError', ctx=Load()),\n" +" body=[\n" +" Pass()])],\n" +" orelse=[],\n" +" finalbody=[])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1365 msgid "" "A ``with`` block. ``items`` is a list of :class:`withitem` nodes " "representing the context managers, and ``body`` is the indented block inside " "the context." msgstr "" -#: library/ast.rst:1371 +#: library/ast.rst:1375 msgid "" "A single context manager in a ``with`` block. ``context_expr`` is the " -"context manager, often a :class:`Call` node. ``optional_vars`` is a :class:" -"`Name`, :class:`Tuple` or :class:`List` for the ``as foo`` part, or ``None`` " -"if that isn't used." -msgstr "" - -#: library/ast.rst:1404 +"context manager, often a :class:`Call` node. ``optional_vars`` is " +"a :class:`Name`, :class:`Tuple` or :class:`List` for the ``as foo`` part, or " +"``None`` if that isn't used." +msgstr "" + +#: library/ast.rst:1380 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... with a as b, c as d:\n" +"... something(b, d)\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" With(\n" +" items=[\n" +" withitem(\n" +" context_expr=Name(id='a', ctx=Load()),\n" +" optional_vars=Name(id='b', ctx=Store())),\n" +" withitem(\n" +" context_expr=Name(id='c', ctx=Load()),\n" +" optional_vars=Name(id='d', ctx=Store()))],\n" +" body=[\n" +" Expr(\n" +" value=Call(\n" +" func=Name(id='something', ctx=Load()),\n" +" args=[\n" +" Name(id='b', ctx=Load()),\n" +" Name(id='d', ctx=Load())],\n" +" keywords=[]))])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1408 msgid "Pattern matching" msgstr "" -#: library/ast.rst:1409 +#: library/ast.rst:1413 msgid "" "A ``match`` statement. ``subject`` holds the subject of the match (the " "object that is being matched against the cases) and ``cases`` contains an " "iterable of :class:`match_case` nodes with the different cases." msgstr "" -#: library/ast.rst:1417 +#: library/ast.rst:1421 msgid "" "A single case pattern in a ``match`` statement. ``pattern`` contains the " -"match pattern that the subject will be matched against. Note that the :class:" -"`AST` nodes produced for patterns differ from those produced for " +"match pattern that the subject will be matched against. Note that " +"the :class:`AST` nodes produced for patterns differ from those produced for " "expressions, even when they share the same syntax." msgstr "" -#: library/ast.rst:1422 +#: library/ast.rst:1426 msgid "" "The ``guard`` attribute contains an expression that will be evaluated if the " "pattern matches the subject." msgstr "" -#: library/ast.rst:1425 +#: library/ast.rst:1429 msgid "" "``body`` contains a list of nodes to execute if the pattern matches and the " "result of evaluating the guard expression is true." msgstr "" -#: library/ast.rst:1470 +#: library/ast.rst:1432 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case [x] if x>0:\n" +"... ...\n" +"... case tuple():\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x', ctx=Load()),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchSequence(\n" +" patterns=[\n" +" MatchAs(name='x')]),\n" +" guard=Compare(\n" +" left=Name(id='x', ctx=Load()),\n" +" ops=[\n" +" Gt()],\n" +" comparators=[\n" +" Constant(value=0)]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))]),\n" +" match_case(\n" +" pattern=MatchClass(\n" +" cls=Name(id='tuple', ctx=Load()),\n" +" patterns=[],\n" +" kwd_attrs=[],\n" +" kwd_patterns=[]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1474 msgid "" "A match literal or value pattern that compares by equality. ``value`` is an " "expression node. Permitted value nodes are restricted as described in the " @@ -727,14 +1782,55 @@ msgid "" "equal to the evaluated value." msgstr "" -#: library/ast.rst:1499 +#: library/ast.rst:1479 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case \"Relevant\":\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x', ctx=Load()),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchValue(\n" +" value=Constant(value='Relevant')),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1503 msgid "" "A match literal pattern that compares by identity. ``value`` is the " "singleton to be compared against: ``None``, ``True``, or ``False``. This " "pattern succeeds if the match subject is the given constant." msgstr "" -#: library/ast.rst:1526 +#: library/ast.rst:1507 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case None:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x', ctx=Load()),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchSingleton(value=None),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1530 msgid "" "A match sequence pattern. ``patterns`` contains the patterns to be matched " "against the subject elements if the subject is a sequence. Matches a " @@ -742,7 +1838,32 @@ msgid "" "otherwise matches a fixed length sequence." msgstr "" -#: library/ast.rst:1559 +#: library/ast.rst:1535 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case [1, 2]:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x', ctx=Load()),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchSequence(\n" +" patterns=[\n" +" MatchValue(\n" +" value=Constant(value=1)),\n" +" MatchValue(\n" +" value=Constant(value=2))]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1563 msgid "" "Matches the rest of the sequence in a variable length match sequence " "pattern. If ``name`` is not ``None``, a list containing the remaining " @@ -750,7 +1871,42 @@ msgid "" "successful." msgstr "" -#: library/ast.rst:1601 +#: library/ast.rst:1567 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case [1, 2, *rest]:\n" +"... ...\n" +"... case [*_]:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x', ctx=Load()),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchSequence(\n" +" patterns=[\n" +" MatchValue(\n" +" value=Constant(value=1)),\n" +" MatchValue(\n" +" value=Constant(value=2)),\n" +" MatchStar(name='rest')]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))]),\n" +" match_case(\n" +" pattern=MatchSequence(\n" +" patterns=[\n" +" MatchStar()]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1605 msgid "" "A match mapping pattern. ``keys`` is a sequence of expression nodes. " "``patterns`` is a corresponding sequence of pattern nodes. ``rest`` is an " @@ -759,7 +1915,7 @@ msgid "" "statement documentation." msgstr "" -#: library/ast.rst:1607 +#: library/ast.rst:1611 msgid "" "This pattern succeeds if the subject is a mapping, all evaluated key " "expressions are present in the mapping, and the value corresponding to each " @@ -768,7 +1924,41 @@ msgid "" "overall mapping pattern is successful." msgstr "" -#: library/ast.rst:1649 +#: library/ast.rst:1617 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case {1: _, 2: _}:\n" +"... ...\n" +"... case {**rest}:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x', ctx=Load()),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchMapping(\n" +" keys=[\n" +" Constant(value=1),\n" +" Constant(value=2)],\n" +" patterns=[\n" +" MatchAs(),\n" +" MatchAs()]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))]),\n" +" match_case(\n" +" pattern=MatchMapping(keys=[], patterns=[], " +"rest='rest'),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1653 msgid "" "A match class pattern. ``cls`` is an expression giving the nominal class to " "be matched. ``patterns`` is a sequence of pattern nodes to be matched " @@ -779,21 +1969,69 @@ msgid "" "pattern)." msgstr "" -#: library/ast.rst:1656 +#: library/ast.rst:1660 msgid "" "This pattern succeeds if the subject is an instance of the nominated class, " "all positional patterns match the corresponding class-defined attributes, " "and any specified keyword attributes match their corresponding pattern." msgstr "" -#: library/ast.rst:1660 +#: library/ast.rst:1664 msgid "" "Note: classes may define a property that returns self in order to match a " "pattern node against the instance being matched. Several builtin types are " "also matched that way, as described in the match statement documentation." msgstr "" -#: library/ast.rst:1715 +#: library/ast.rst:1668 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case Point2D(0, 0):\n" +"... ...\n" +"... case Point3D(x=0, y=0, z=0):\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x', ctx=Load()),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchClass(\n" +" cls=Name(id='Point2D', ctx=Load()),\n" +" patterns=[\n" +" MatchValue(\n" +" value=Constant(value=0)),\n" +" MatchValue(\n" +" value=Constant(value=0))],\n" +" kwd_attrs=[],\n" +" kwd_patterns=[]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))]),\n" +" match_case(\n" +" pattern=MatchClass(\n" +" cls=Name(id='Point3D', ctx=Load()),\n" +" patterns=[],\n" +" kwd_attrs=[\n" +" 'x',\n" +" 'y',\n" +" 'z'],\n" +" kwd_patterns=[\n" +" MatchValue(\n" +" value=Constant(value=0)),\n" +" MatchValue(\n" +" value=Constant(value=0)),\n" +" MatchValue(\n" +" value=Constant(value=0))]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1719 msgid "" "A match \"as-pattern\", capture pattern or wildcard pattern. ``pattern`` " "contains the match pattern that the subject will be matched against. If the " @@ -801,14 +2039,45 @@ msgid "" "and will always succeed." msgstr "" -#: library/ast.rst:1720 +#: library/ast.rst:1724 msgid "" "The ``name`` attribute contains the name that will be bound if the pattern " "is successful. If ``name`` is ``None``, ``pattern`` must also be ``None`` " "and the node represents the wildcard pattern." msgstr "" -#: library/ast.rst:1758 +#: library/ast.rst:1728 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case [x] as y:\n" +"... ...\n" +"... case _:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x', ctx=Load()),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchAs(\n" +" pattern=MatchSequence(\n" +" patterns=[\n" +" MatchAs(name='x')]),\n" +" name='y'),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))]),\n" +" match_case(\n" +" pattern=MatchAs(),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1762 msgid "" "A match \"or-pattern\". An or-pattern matches each of its subpatterns in " "turn to the subject, until one succeeds. The or-pattern is then deemed to " @@ -817,217 +2086,472 @@ msgid "" "matched against the subject." msgstr "" -#: library/ast.rst:1793 +#: library/ast.rst:1768 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case [x] | (y):\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x', ctx=Load()),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchOr(\n" +" patterns=[\n" +" MatchSequence(\n" +" patterns=[\n" +" MatchAs(name='x')]),\n" +" MatchAs(name='y')]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1797 msgid "Type parameters" msgstr "" -#: library/ast.rst:1795 +#: library/ast.rst:1799 msgid "" ":ref:`Type parameters ` can exist on classes, functions, and " "type aliases." msgstr "" -#: library/ast.rst:1800 +#: library/ast.rst:1804 msgid "" "A :class:`typing.TypeVar`. ``name`` is the name of the type variable. " -"``bound`` is the bound or constraints, if any. If ``bound`` is a :class:" -"`Tuple`, it represents constraints; otherwise it represents the bound." +"``bound`` is the bound or constraints, if any. If ``bound`` is " +"a :class:`Tuple`, it represents constraints; otherwise it represents the " +"bound." +msgstr "" + +#: library/ast.rst:1808 +msgid "" +">>> print(ast.dump(ast.parse(\"type Alias[T: int] = list[T]\"), indent=4))\n" +"Module(\n" +" body=[\n" +" TypeAlias(\n" +" name=Name(id='Alias', ctx=Store()),\n" +" type_params=[\n" +" TypeVar(\n" +" name='T',\n" +" bound=Name(id='int', ctx=Load()))],\n" +" value=Subscript(\n" +" value=Name(id='list', ctx=Load()),\n" +" slice=Name(id='T', ctx=Load()),\n" +" ctx=Load()))],\n" +" type_ignores=[])" msgstr "" -#: library/ast.rst:1825 +#: library/ast.rst:1829 msgid "" "A :class:`typing.ParamSpec`. ``name`` is the name of the parameter " "specification." msgstr "" -#: library/ast.rst:1850 +#: library/ast.rst:1831 +msgid "" +">>> print(ast.dump(ast.parse(\"type Alias[**P] = Callable[P, int]\"), " +"indent=4))\n" +"Module(\n" +" body=[\n" +" TypeAlias(\n" +" name=Name(id='Alias', ctx=Store()),\n" +" type_params=[\n" +" ParamSpec(name='P')],\n" +" value=Subscript(\n" +" value=Name(id='Callable', ctx=Load()),\n" +" slice=Tuple(\n" +" elts=[\n" +" Name(id='P', ctx=Load()),\n" +" Name(id='int', ctx=Load())],\n" +" ctx=Load()),\n" +" ctx=Load()))],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1854 msgid "" "A :class:`typing.TypeVarTuple`. ``name`` is the name of the type variable " "tuple." msgstr "" -#: library/ast.rst:1875 -msgid "Function and class definitions" +#: library/ast.rst:1856 +msgid "" +">>> print(ast.dump(ast.parse(\"type Alias[*Ts] = tuple[*Ts]\"), indent=4))\n" +"Module(\n" +" body=[\n" +" TypeAlias(\n" +" name=Name(id='Alias', ctx=Store()),\n" +" type_params=[\n" +" TypeVarTuple(name='Ts')],\n" +" value=Subscript(\n" +" value=Name(id='tuple', ctx=Load()),\n" +" slice=Tuple(\n" +" elts=[\n" +" Starred(\n" +" value=Name(id='Ts', ctx=Load()),\n" +" ctx=Load())],\n" +" ctx=Load()),\n" +" ctx=Load()))],\n" +" type_ignores=[])" msgstr "" #: library/ast.rst:1879 +msgid "Function and class definitions" +msgstr "" + +#: library/ast.rst:1883 msgid "A function definition." msgstr "" -#: library/ast.rst:1881 +#: library/ast.rst:1885 msgid "``name`` is a raw string of the function name." msgstr "" -#: library/ast.rst:1882 +#: library/ast.rst:1886 msgid "``args`` is an :class:`arguments` node." msgstr "" -#: library/ast.rst:1883 +#: library/ast.rst:1887 msgid "``body`` is the list of nodes inside the function." msgstr "" -#: library/ast.rst:1884 +#: library/ast.rst:1888 msgid "" "``decorator_list`` is the list of decorators to be applied, stored outermost " "first (i.e. the first in the list will be applied last)." msgstr "" -#: library/ast.rst:1886 +#: library/ast.rst:1890 msgid "``returns`` is the return annotation." msgstr "" -#: library/ast.rst:2064 +#: library/ast.rst:2067 msgid "``type_params`` is a list of :ref:`type parameters `." msgstr "" -#: library/ast.rst:2093 library/ast.rst:2104 +#: library/ast.rst:2096 library/ast.rst:2107 msgid "Added ``type_params``." msgstr "" -#: library/ast.rst:1899 +#: library/ast.rst:1903 msgid "" "``lambda`` is a minimal function definition that can be used inside an " "expression. Unlike :class:`FunctionDef`, ``body`` holds a single node." msgstr "" -#: library/ast.rst:1923 +#: library/ast.rst:1906 +msgid "" +">>> print(ast.dump(ast.parse('lambda x,y: ...'), indent=4))\n" +"Module(\n" +" body=[\n" +" Expr(\n" +" value=Lambda(\n" +" args=arguments(\n" +" posonlyargs=[],\n" +" args=[\n" +" arg(arg='x'),\n" +" arg(arg='y')],\n" +" kwonlyargs=[],\n" +" kw_defaults=[],\n" +" defaults=[]),\n" +" body=Constant(value=Ellipsis)))],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1927 msgid "The arguments for a function." msgstr "" -#: library/ast.rst:1925 +#: library/ast.rst:1929 msgid "" "``posonlyargs``, ``args`` and ``kwonlyargs`` are lists of :class:`arg` nodes." msgstr "" -#: library/ast.rst:1926 +#: library/ast.rst:1930 msgid "" "``vararg`` and ``kwarg`` are single :class:`arg` nodes, referring to the " "``*args, **kwargs`` parameters." msgstr "" -#: library/ast.rst:1928 +#: library/ast.rst:1932 msgid "" "``kw_defaults`` is a list of default values for keyword-only arguments. If " "one is ``None``, the corresponding argument is required." msgstr "" -#: library/ast.rst:1930 +#: library/ast.rst:1934 msgid "" "``defaults`` is a list of default values for arguments that can be passed " "positionally. If there are fewer defaults, they correspond to the last n " "arguments." msgstr "" -#: library/ast.rst:1937 +#: library/ast.rst:1941 msgid "" "A single argument in a list. ``arg`` is a raw string of the argument name; " "``annotation`` is its annotation, such as a :class:`Name` node." msgstr "" -#: library/ast.rst:1942 +#: library/ast.rst:1946 msgid "" "``type_comment`` is an optional string with the type annotation as a comment" msgstr "" -#: library/ast.rst:1987 +#: library/ast.rst:1948 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... @decorator1\n" +"... @decorator2\n" +"... def f(a: 'annotation', b=1, c=2, *d, e, f=3, **g) -> 'return " +"annotation':\n" +"... pass\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" FunctionDef(\n" +" name='f',\n" +" args=arguments(\n" +" posonlyargs=[],\n" +" args=[\n" +" arg(\n" +" arg='a',\n" +" annotation=Constant(value='annotation')),\n" +" arg(arg='b'),\n" +" arg(arg='c')],\n" +" vararg=arg(arg='d'),\n" +" kwonlyargs=[\n" +" arg(arg='e'),\n" +" arg(arg='f')],\n" +" kw_defaults=[\n" +" None,\n" +" Constant(value=3)],\n" +" kwarg=arg(arg='g'),\n" +" defaults=[\n" +" Constant(value=1),\n" +" Constant(value=2)]),\n" +" body=[\n" +" Pass()],\n" +" decorator_list=[\n" +" Name(id='decorator1', ctx=Load()),\n" +" Name(id='decorator2', ctx=Load())],\n" +" returns=Constant(value='return annotation'),\n" +" type_params=[])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:1991 msgid "A ``return`` statement." msgstr "" -#: library/ast.rst:2002 +#: library/ast.rst:1993 +msgid "" +">>> print(ast.dump(ast.parse('return 4'), indent=4))\n" +"Module(\n" +" body=[\n" +" Return(\n" +" value=Constant(value=4))],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:2006 msgid "" "A ``yield`` or ``yield from`` expression. Because these are expressions, " -"they must be wrapped in a :class:`Expr` node if the value sent back is not " +"they must be wrapped in an :class:`Expr` node if the value sent back is not " "used." msgstr "" -#: library/ast.rst:2027 +#: library/ast.rst:2009 +msgid "" +">>> print(ast.dump(ast.parse('yield x'), indent=4))\n" +"Module(\n" +" body=[\n" +" Expr(\n" +" value=Yield(\n" +" value=Name(id='x', ctx=Load())))],\n" +" type_ignores=[])\n" +"\n" +">>> print(ast.dump(ast.parse('yield from x'), indent=4))\n" +"Module(\n" +" body=[\n" +" Expr(\n" +" value=YieldFrom(\n" +" value=Name(id='x', ctx=Load())))],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:2031 msgid "" "``global`` and ``nonlocal`` statements. ``names`` is a list of raw strings." msgstr "" -#: library/ast.rst:2054 +#: library/ast.rst:2033 +msgid "" +">>> print(ast.dump(ast.parse('global x,y,z'), indent=4))\n" +"Module(\n" +" body=[\n" +" Global(\n" +" names=[\n" +" 'x',\n" +" 'y',\n" +" 'z'])],\n" +" type_ignores=[])\n" +"\n" +">>> print(ast.dump(ast.parse('nonlocal x,y,z'), indent=4))\n" +"Module(\n" +" body=[\n" +" Nonlocal(\n" +" names=[\n" +" 'x',\n" +" 'y',\n" +" 'z'])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:2058 msgid "A class definition." msgstr "" -#: library/ast.rst:2056 +#: library/ast.rst:2060 msgid "``name`` is a raw string for the class name" msgstr "" -#: library/ast.rst:2057 +#: library/ast.rst:2061 msgid "``bases`` is a list of nodes for explicitly specified base classes." msgstr "" -#: library/ast.rst:2058 +#: library/ast.rst:2062 msgid "" "``keywords`` is a list of :class:`.keyword` nodes, principally for " -"'metaclass'. Other keywords will be passed to the metaclass, as per " -"`PEP-3115 `_." +"'metaclass'. Other keywords will be passed to the metaclass, as " +"per :pep:`3115`." msgstr "" -#: library/ast.rst:2061 +#: library/ast.rst:2064 msgid "" "``body`` is a list of nodes representing the code within the class " "definition." msgstr "" -#: library/ast.rst:2063 +#: library/ast.rst:2066 msgid "``decorator_list`` is a list of nodes, as in :class:`FunctionDef`." msgstr "" -#: library/ast.rst:2097 +#: library/ast.rst:2069 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... @decorator1\n" +"... @decorator2\n" +"... class Foo(base1, base2, metaclass=meta):\n" +"... pass\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" ClassDef(\n" +" name='Foo',\n" +" bases=[\n" +" Name(id='base1', ctx=Load()),\n" +" Name(id='base2', ctx=Load())],\n" +" keywords=[\n" +" keyword(\n" +" arg='metaclass',\n" +" value=Name(id='meta', ctx=Load()))],\n" +" body=[\n" +" Pass()],\n" +" decorator_list=[\n" +" Name(id='decorator1', ctx=Load()),\n" +" Name(id='decorator2', ctx=Load())],\n" +" type_params=[])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:2100 msgid "Async and await" msgstr "" -#: library/ast.rst:2101 +#: library/ast.rst:2104 msgid "" -"An ``async def`` function definition. Has the same fields as :class:" -"`FunctionDef`." +"An ``async def`` function definition. Has the same fields " +"as :class:`FunctionDef`." msgstr "" -#: library/ast.rst:2110 +#: library/ast.rst:2113 msgid "" "An ``await`` expression. ``value`` is what it waits for. Only valid in the " "body of an :class:`AsyncFunctionDef`." msgstr "" -#: library/ast.rst:2144 +#: library/ast.rst:2116 +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... async def f():\n" +"... await other_func()\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" AsyncFunctionDef(\n" +" name='f',\n" +" args=arguments(\n" +" posonlyargs=[],\n" +" args=[],\n" +" kwonlyargs=[],\n" +" kw_defaults=[],\n" +" defaults=[]),\n" +" body=[\n" +" Expr(\n" +" value=Await(\n" +" value=Call(\n" +" func=Name(id='other_func', ctx=Load()),\n" +" args=[],\n" +" keywords=[])))],\n" +" decorator_list=[],\n" +" type_params=[])],\n" +" type_ignores=[])" +msgstr "" + +#: library/ast.rst:2147 msgid "" "``async for`` loops and ``async with`` context managers. They have the same " "fields as :class:`For` and :class:`With`, respectively. Only valid in the " "body of an :class:`AsyncFunctionDef`." msgstr "" -#: library/ast.rst:2149 +#: library/ast.rst:2152 msgid "" -"When a string is parsed by :func:`ast.parse`, operator nodes (subclasses of :" -"class:`ast.operator`, :class:`ast.unaryop`, :class:`ast.cmpop`, :class:`ast." -"boolop` and :class:`ast.expr_context`) on the returned tree will be " -"singletons. Changes to one will be reflected in all other occurrences of the " -"same value (e.g. :class:`ast.Add`)." +"When a string is parsed by :func:`ast.parse`, operator nodes (subclasses " +"of :class:`ast.operator`, :class:`ast.unaryop`, :class:`ast.cmpop`, :class:`ast.boolop` " +"and :class:`ast.expr_context`) on the returned tree will be singletons. " +"Changes to one will be reflected in all other occurrences of the same value " +"(e.g. :class:`ast.Add`)." msgstr "" -#: library/ast.rst:2157 +#: library/ast.rst:2160 msgid ":mod:`ast` Helpers" msgstr "" -#: library/ast.rst:2159 +#: library/ast.rst:2162 msgid "" "Apart from the node classes, the :mod:`ast` module defines these utility " "functions and classes for traversing abstract syntax trees:" msgstr "" -#: library/ast.rst:2164 +#: library/ast.rst:2167 msgid "" "Parse the source into an AST node. Equivalent to ``compile(source, " "filename, mode, ast.PyCF_ONLY_AST)``." msgstr "" -#: library/ast.rst:2167 +#: library/ast.rst:2170 msgid "" "If ``type_comments=True`` is given, the parser is modified to check and " "return type comments as specified by :pep:`484` and :pep:`526`. This is " -"equivalent to adding :data:`ast.PyCF_TYPE_COMMENTS` to the flags passed to :" -"func:`compile()`. This will report syntax errors for misplaced type " +"equivalent to adding :data:`ast.PyCF_TYPE_COMMENTS` to the flags passed " +"to :func:`compile`. This will report syntax errors for misplaced type " "comments. Without this flag, type comments will be ignored, and the " "``type_comment`` field on selected AST nodes will always be ``None``. In " "addition, the locations of ``# type: ignore`` comments will be returned as " @@ -1035,14 +2559,14 @@ msgid "" "empty list)." msgstr "" -#: library/ast.rst:2177 +#: library/ast.rst:2180 msgid "" "In addition, if ``mode`` is ``'func_type'``, the input syntax is modified to " "correspond to :pep:`484` \"signature type comments\", e.g. ``(str, int) -> " "List[str]``." msgstr "" -#: library/ast.rst:2181 +#: library/ast.rst:2184 msgid "" "Setting ``feature_version`` to a tuple ``(major, minor)`` will result in a " "\"best-effort\" attempt to parse using that Python version's grammar. For " @@ -1055,12 +2579,12 @@ msgid "" "``feature_version``." msgstr "" -#: library/ast.rst:2191 +#: library/ast.rst:2194 msgid "" "If source contains a null character (``\\0``), :exc:`ValueError` is raised." msgstr "" -#: library/ast.rst:2194 +#: library/ast.rst:2197 msgid "" "Note that successfully parsing source code into an AST object doesn't " "guarantee that the source code provided is valid Python code that can be " @@ -1070,43 +2594,43 @@ msgid "" "inside a function node)." msgstr "" -#: library/ast.rst:2201 +#: library/ast.rst:2204 msgid "" "In particular, :func:`ast.parse` won't do any scoping checks, which the " "compilation step does." msgstr "" -#: library/ast.rst:2205 +#: library/ast.rst:2208 msgid "" "It is possible to crash the Python interpreter with a sufficiently large/" "complex string due to stack depth limitations in Python's AST compiler." msgstr "" -#: library/ast.rst:2209 +#: library/ast.rst:2212 msgid "Added ``type_comments``, ``mode='func_type'`` and ``feature_version``." msgstr "" -#: library/ast.rst:2215 +#: library/ast.rst:2218 msgid "" "Unparse an :class:`ast.AST` object and generate a string with code that " -"would produce an equivalent :class:`ast.AST` object if parsed back with :" -"func:`ast.parse`." +"would produce an equivalent :class:`ast.AST` object if parsed back " +"with :func:`ast.parse`." msgstr "" -#: library/ast.rst:2220 +#: library/ast.rst:2223 msgid "" "The produced code string will not necessarily be equal to the original code " "that generated the :class:`ast.AST` object (without any compiler " "optimizations, such as constant tuples/frozensets)." msgstr "" -#: library/ast.rst:2225 +#: library/ast.rst:2228 msgid "" -"Trying to unparse a highly complex expression would result with :exc:" -"`RecursionError`." +"Trying to unparse a highly complex expression would result " +"with :exc:`RecursionError`." msgstr "" -#: library/ast.rst:2233 +#: library/ast.rst:2236 msgid "" "Evaluate an expression node or a string containing only a Python literal or " "container display. The string or node provided may only consist of the " @@ -1114,14 +2638,14 @@ msgid "" "dicts, sets, booleans, ``None`` and ``Ellipsis``." msgstr "" -#: library/ast.rst:2238 +#: library/ast.rst:2241 msgid "" "This can be used for evaluating strings containing Python values without the " "need to parse the values oneself. It is not capable of evaluating " "arbitrarily complex expressions, for example involving operators or indexing." msgstr "" -#: library/ast.rst:2243 +#: library/ast.rst:2246 msgid "" "This function had been documented as \"safe\" in the past without defining " "what that meant. That was misleading. This is specifically designed not to " @@ -1133,155 +2657,157 @@ msgid "" "untrusted data is thus not recommended." msgstr "" -#: library/ast.rst:2253 +#: library/ast.rst:2256 msgid "" "It is possible to crash the Python interpreter due to stack depth " "limitations in Python's AST compiler." msgstr "" -#: library/ast.rst:2256 +#: library/ast.rst:2259 msgid "" -"It can raise :exc:`ValueError`, :exc:`TypeError`, :exc:`SyntaxError`, :exc:" -"`MemoryError` and :exc:`RecursionError` depending on the malformed input." +"It can " +"raise :exc:`ValueError`, :exc:`TypeError`, :exc:`SyntaxError`, :exc:`MemoryError` " +"and :exc:`RecursionError` depending on the malformed input." msgstr "" -#: library/ast.rst:2260 +#: library/ast.rst:2263 msgid "Now allows bytes and set literals." msgstr "" -#: library/ast.rst:2263 +#: library/ast.rst:2266 msgid "Now supports creating empty sets with ``'set()'``." msgstr "" -#: library/ast.rst:2266 +#: library/ast.rst:2269 msgid "For string inputs, leading spaces and tabs are now stripped." msgstr "" -#: library/ast.rst:2272 +#: library/ast.rst:2275 msgid "" -"Return the docstring of the given *node* (which must be a :class:" -"`FunctionDef`, :class:`AsyncFunctionDef`, :class:`ClassDef`, or :class:" -"`Module` node), or ``None`` if it has no docstring. If *clean* is true, " -"clean up the docstring's indentation with :func:`inspect.cleandoc`." +"Return the docstring of the given *node* (which must be " +"a :class:`FunctionDef`, :class:`AsyncFunctionDef`, :class:`ClassDef`, " +"or :class:`Module` node), or ``None`` if it has no docstring. If *clean* is " +"true, clean up the docstring's indentation with :func:`inspect.cleandoc`." msgstr "" -#: library/ast.rst:2278 +#: library/ast.rst:2281 msgid ":class:`AsyncFunctionDef` is now supported." msgstr "" -#: library/ast.rst:2284 +#: library/ast.rst:2287 msgid "" "Get source code segment of the *source* that generated *node*. If some " -"location information (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.end_lineno`, :" -"attr:`~ast.AST.col_offset`, or :attr:`~ast.AST.end_col_offset`) is missing, " -"return ``None``." +"location information " +"(:attr:`~ast.AST.lineno`, :attr:`~ast.AST.end_lineno`, :attr:`~ast.AST.col_offset`, " +"or :attr:`~ast.AST.end_col_offset`) is missing, return ``None``." msgstr "" -#: library/ast.rst:2288 +#: library/ast.rst:2291 msgid "" "If *padded* is ``True``, the first line of a multi-line statement will be " "padded with spaces to match its original position." msgstr "" -#: library/ast.rst:2296 +#: library/ast.rst:2299 msgid "" -"When you compile a node tree with :func:`compile`, the compiler expects :" -"attr:`~ast.AST.lineno` and :attr:`~ast.AST.col_offset` attributes for every " -"node that supports them. This is rather tedious to fill in for generated " -"nodes, so this helper adds these attributes recursively where not already " -"set, by setting them to the values of the parent node. It works recursively " -"starting at *node*." +"When you compile a node tree with :func:`compile`, the compiler " +"expects :attr:`~ast.AST.lineno` and :attr:`~ast.AST.col_offset` attributes " +"for every node that supports them. This is rather tedious to fill in for " +"generated nodes, so this helper adds these attributes recursively where not " +"already set, by setting them to the values of the parent node. It works " +"recursively starting at *node*." msgstr "" -#: library/ast.rst:2305 +#: library/ast.rst:2308 msgid "" "Increment the line number and end line number of each node in the tree " "starting at *node* by *n*. This is useful to \"move code\" to a different " "location in a file." msgstr "" -#: library/ast.rst:2312 +#: library/ast.rst:2315 msgid "" -"Copy source location (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.col_offset`, :" -"attr:`~ast.AST.end_lineno`, and :attr:`~ast.AST.end_col_offset`) from " -"*old_node* to *new_node* if possible, and return *new_node*." +"Copy source location " +"(:attr:`~ast.AST.lineno`, :attr:`~ast.AST.col_offset`, :attr:`~ast.AST.end_lineno`, " +"and :attr:`~ast.AST.end_col_offset`) from *old_node* to *new_node* if " +"possible, and return *new_node*." msgstr "" -#: library/ast.rst:2319 +#: library/ast.rst:2322 msgid "" "Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields`` " "that is present on *node*." msgstr "" -#: library/ast.rst:2325 +#: library/ast.rst:2328 msgid "" "Yield all direct child nodes of *node*, that is, all fields that are nodes " "and all items of fields that are lists of nodes." msgstr "" -#: library/ast.rst:2331 +#: library/ast.rst:2334 msgid "" "Recursively yield all descendant nodes in the tree starting at *node* " "(including *node* itself), in no specified order. This is useful if you " "only want to modify nodes in place and don't care about the context." msgstr "" -#: library/ast.rst:2338 +#: library/ast.rst:2341 msgid "" "A node visitor base class that walks the abstract syntax tree and calls a " "visitor function for every node found. This function may return a value " "which is forwarded by the :meth:`visit` method." msgstr "" -#: library/ast.rst:2342 +#: library/ast.rst:2345 msgid "" "This class is meant to be subclassed, with the subclass adding visitor " "methods." msgstr "" -#: library/ast.rst:2347 +#: library/ast.rst:2350 msgid "" -"Visit a node. The default implementation calls the method called :samp:" -"`self.visit_{classname}` where *classname* is the name of the node class, " -"or :meth:`generic_visit` if that method doesn't exist." +"Visit a node. The default implementation calls the method " +"called :samp:`self.visit_{classname}` where *classname* is the name of the " +"node class, or :meth:`generic_visit` if that method doesn't exist." msgstr "" -#: library/ast.rst:2353 +#: library/ast.rst:2356 msgid "This visitor calls :meth:`visit` on all children of the node." msgstr "" -#: library/ast.rst:2355 +#: library/ast.rst:2358 msgid "" "Note that child nodes of nodes that have a custom visitor method won't be " "visited unless the visitor calls :meth:`generic_visit` or visits them itself." msgstr "" -#: library/ast.rst:2361 +#: library/ast.rst:2364 msgid "Handles all constant nodes." msgstr "" -#: library/ast.rst:2363 +#: library/ast.rst:2366 msgid "" "Don't use the :class:`NodeVisitor` if you want to apply changes to nodes " -"during traversal. For this a special visitor exists (:class:" -"`NodeTransformer`) that allows modifications." +"during traversal. For this a special visitor exists " +"(:class:`NodeTransformer`) that allows modifications." msgstr "" -#: library/ast.rst:2369 +#: library/ast.rst:2372 msgid "" -"Methods :meth:`!visit_Num`, :meth:`!visit_Str`, :meth:`!visit_Bytes`, :meth:" -"`!visit_NameConstant` and :meth:`!visit_Ellipsis` are deprecated now and " -"will not be called in future Python versions. Add the :meth:" -"`visit_Constant` method to handle all constant nodes." +"Methods :meth:`!visit_Num`, :meth:`!visit_Str`, :meth:`!" +"visit_Bytes`, :meth:`!visit_NameConstant` and :meth:`!visit_Ellipsis` are " +"deprecated now and will not be called in future Python versions. Add " +"the :meth:`visit_Constant` method to handle all constant nodes." msgstr "" -#: library/ast.rst:2377 +#: library/ast.rst:2380 msgid "" "A :class:`NodeVisitor` subclass that walks the abstract syntax tree and " "allows modification of nodes." msgstr "" -#: library/ast.rst:2380 +#: library/ast.rst:2383 msgid "" "The :class:`NodeTransformer` will walk the AST and use the return value of " "the visitor methods to replace or remove the old node. If the return value " @@ -1290,39 +2816,61 @@ msgid "" "may be the original node in which case no replacement takes place." msgstr "" -#: library/ast.rst:2386 +#: library/ast.rst:2389 msgid "" "Here is an example transformer that rewrites all occurrences of name lookups " "(``foo``) to ``data['foo']``::" msgstr "" -#: library/ast.rst:2398 +#: library/ast.rst:2392 +msgid "" +"class RewriteName(NodeTransformer):\n" +"\n" +" def visit_Name(self, node):\n" +" return Subscript(\n" +" value=Name(id='data', ctx=Load()),\n" +" slice=Constant(value=node.id),\n" +" ctx=node.ctx\n" +" )" +msgstr "" + +#: library/ast.rst:2401 msgid "" "Keep in mind that if the node you're operating on has child nodes you must " -"either transform the child nodes yourself or call the :meth:`~ast." -"NodeVisitor.generic_visit` method for the node first." +"either transform the child nodes yourself or call " +"the :meth:`~ast.NodeVisitor.generic_visit` method for the node first." msgstr "" -#: library/ast.rst:2402 +#: library/ast.rst:2405 msgid "" "For nodes that were part of a collection of statements (that applies to all " "statement nodes), the visitor may also return a list of nodes rather than " "just a single node." msgstr "" -#: library/ast.rst:2406 +#: library/ast.rst:2409 msgid "" "If :class:`NodeTransformer` introduces new nodes (that weren't part of " -"original tree) without giving them location information (such as :attr:`~ast." -"AST.lineno`), :func:`fix_missing_locations` should be called with the new " -"sub-tree to recalculate the location information::" +"original tree) without giving them location information (such " +"as :attr:`~ast.AST.lineno`), :func:`fix_missing_locations` should be called " +"with the new sub-tree to recalculate the location information::" msgstr "" #: library/ast.rst:2414 +msgid "" +"tree = ast.parse('foo', mode='eval')\n" +"new_tree = fix_missing_locations(RewriteName().visit(tree))" +msgstr "" + +#: library/ast.rst:2417 msgid "Usually you use the transformer like this::" msgstr "" -#: library/ast.rst:2421 +#: library/ast.rst:2419 +msgid "node = YourTransformer().visit(node)" +msgstr "" + +#: library/ast.rst:2424 msgid "" "Return a formatted dump of the tree in *node*. This is mainly useful for " "debugging purposes. If *annotate_fields* is true (by default), the returned " @@ -1333,7 +2881,7 @@ msgid "" "true." msgstr "" -#: library/ast.rst:2429 +#: library/ast.rst:2432 msgid "" "If *indent* is a non-negative integer or string, then the tree will be " "pretty-printed with that indent level. An indent level of 0, negative, or " @@ -1343,87 +2891,91 @@ msgid "" "string is used to indent each level." msgstr "" -#: library/ast.rst:2436 +#: library/ast.rst:2439 msgid "Added the *indent* option." msgstr "" -#: library/ast.rst:2443 +#: library/ast.rst:2446 msgid "Compiler Flags" msgstr "" -#: library/ast.rst:2445 +#: library/ast.rst:2448 msgid "" "The following flags may be passed to :func:`compile` in order to change " "effects on the compilation of a program:" msgstr "" -#: library/ast.rst:2450 +#: library/ast.rst:2453 msgid "" "Enables support for top-level ``await``, ``async for``, ``async with`` and " "async comprehensions." msgstr "" -#: library/ast.rst:2457 +#: library/ast.rst:2460 msgid "" "Generates and returns an abstract syntax tree instead of returning a " "compiled code object." msgstr "" -#: library/ast.rst:2462 +#: library/ast.rst:2465 msgid "" "Enables support for :pep:`484` and :pep:`526` style type comments (``# type: " "``, ``# type: ignore ``)." msgstr "" -#: library/ast.rst:2471 +#: library/ast.rst:2474 msgid "Command-Line Usage" msgstr "" -#: library/ast.rst:2475 +#: library/ast.rst:2478 msgid "" "The :mod:`ast` module can be executed as a script from the command line. It " "is as simple as:" msgstr "" -#: library/ast.rst:2482 +#: library/ast.rst:2481 +msgid "python -m ast [-m ] [-a] [infile]" +msgstr "" + +#: library/ast.rst:2485 msgid "The following options are accepted:" msgstr "" -#: library/ast.rst:2488 +#: library/ast.rst:2491 msgid "Show the help message and exit." msgstr "" -#: library/ast.rst:2493 +#: library/ast.rst:2496 msgid "" -"Specify what kind of code must be compiled, like the *mode* argument in :" -"func:`parse`." +"Specify what kind of code must be compiled, like the *mode* argument " +"in :func:`parse`." msgstr "" -#: library/ast.rst:2498 +#: library/ast.rst:2501 msgid "Don't parse type comments." msgstr "" -#: library/ast.rst:2502 +#: library/ast.rst:2505 msgid "Include attributes such as line numbers and column offsets." msgstr "" -#: library/ast.rst:2507 +#: library/ast.rst:2510 msgid "Indentation of nodes in AST (number of spaces)." msgstr "" -#: library/ast.rst:2509 +#: library/ast.rst:2512 msgid "" "If :file:`infile` is specified its contents are parsed to AST and dumped to " "stdout. Otherwise, the content is read from stdin." msgstr "" -#: library/ast.rst:2515 +#: library/ast.rst:2518 msgid "" "`Green Tree Snakes `_, an external " "documentation resource, has good details on working with Python ASTs." msgstr "" -#: library/ast.rst:2518 +#: library/ast.rst:2521 msgid "" "`ASTTokens `_ " "annotates Python ASTs with the positions of tokens and text in the source " @@ -1431,26 +2983,26 @@ msgid "" "transformations." msgstr "" -#: library/ast.rst:2523 +#: library/ast.rst:2526 msgid "" -"`leoAst.py `_ unifies the " -"token-based and parse-tree-based views of python programs by inserting two-" -"way links between tokens and ast nodes." +"`leoAst.py `_ unifies the token-based and parse-tree-based views of python programs " +"by inserting two-way links between tokens and ast nodes." msgstr "" -#: library/ast.rst:2527 +#: library/ast.rst:2531 msgid "" "`LibCST `_ parses code as a Concrete Syntax " "Tree that looks like an ast tree and keeps all formatting details. It's " "useful for building automated refactoring (codemod) applications and linters." msgstr "" -#: library/ast.rst:2532 +#: library/ast.rst:2536 msgid "" "`Parso `_ is a Python parser that supports " "error recovery and round-trip parsing for different Python versions (in " "multiple Python versions). Parso is also able to list multiple syntax errors " -"in your python file." +"in your Python file." msgstr "" #: library/ast.rst:59 diff --git a/library/asynchat.po b/library/asynchat.po new file mode 100644 index 00000000..72afd691 --- /dev/null +++ b/library/asynchat.po @@ -0,0 +1,38 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: library/asynchat.rst:2 +msgid ":mod:`!asynchat` --- Asynchronous socket command/response handler" +msgstr "" + +#: library/asynchat.rst:10 +msgid "" +"This module is no longer part of the Python standard library. It " +"was :ref:`removed in Python 3.12 ` after being " +"deprecated in Python 3.6. The removal was decided in :pep:`594`." +msgstr "" + +#: library/asynchat.rst:14 +msgid "Applications should use the :mod:`asyncio` module instead." +msgstr "" + +#: library/asynchat.rst:16 +msgid "" +"The last version of Python that provided the :mod:`!asynchat` module was " +"`Python 3.11 `_." +msgstr "" diff --git a/library/asyncio-api-index.po b/library/asyncio-api-index.po index de3437e6..50d3fe80 100644 --- a/library/asyncio-api-index.po +++ b/library/asyncio-api-index.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/asyncio-dev.po b/library/asyncio-dev.po index 768135b1..84fa33a4 100644 --- a/library/asyncio-dev.po +++ b/library/asyncio-dev.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -67,9 +68,13 @@ msgstr "" #: library/asyncio-dev.rst:36 msgid "" -"setting the log level of the :ref:`asyncio logger ` to :py:" -"const:`logging.DEBUG`, for example the following snippet of code can be run " -"at startup of the application::" +"setting the log level of the :ref:`asyncio logger ` " +"to :py:const:`logging.DEBUG`, for example the following snippet of code can " +"be run at startup of the application::" +msgstr "" + +#: library/asyncio-dev.rst:40 +msgid "logging.basicConfig(level=logging.DEBUG)" msgstr "" #: library/asyncio-dev.rst:42 @@ -92,9 +97,9 @@ msgstr "" #: library/asyncio-dev.rst:53 msgid "" -"Many non-threadsafe asyncio APIs (such as :meth:`loop.call_soon` and :meth:" -"`loop.call_at` methods) raise an exception if they are called from a wrong " -"thread." +"Many non-threadsafe asyncio APIs (such as :meth:`loop.call_soon` " +"and :meth:`loop.call_at` methods) raise an exception if they are called from " +"a wrong thread." msgstr "" #: library/asyncio-dev.rst:57 @@ -105,9 +110,9 @@ msgstr "" #: library/asyncio-dev.rst:60 msgid "" -"Callbacks taking longer than 100 milliseconds are logged. The :attr:`loop." -"slow_callback_duration` attribute can be used to set the minimum execution " -"duration in seconds that is considered \"slow\"." +"Callbacks taking longer than 100 milliseconds are logged. " +"The :attr:`loop.slow_callback_duration` attribute can be used to set the " +"minimum execution duration in seconds that is considered \"slow\"." msgstr "" #: library/asyncio-dev.rst:68 @@ -125,8 +130,12 @@ msgstr "" #: library/asyncio-dev.rst:76 msgid "" -"To schedule a :term:`callback` from another OS thread, the :meth:`loop." -"call_soon_threadsafe` method should be used. Example::" +"To schedule a :term:`callback` from another OS thread, " +"the :meth:`loop.call_soon_threadsafe` method should be used. Example::" +msgstr "" + +#: library/asyncio-dev.rst:79 +msgid "loop.call_soon_threadsafe(callback, *args)" msgstr "" #: library/asyncio-dev.rst:81 @@ -137,11 +146,27 @@ msgid "" "API, the :meth:`loop.call_soon_threadsafe` method should be used, e.g.::" msgstr "" +#: library/asyncio-dev.rst:87 +msgid "loop.call_soon_threadsafe(fut.cancel)" +msgstr "" + #: library/asyncio-dev.rst:89 msgid "" -"To schedule a coroutine object from a different OS thread, the :func:" -"`run_coroutine_threadsafe` function should be used. It returns a :class:" -"`concurrent.futures.Future` to access the result::" +"To schedule a coroutine object from a different OS thread, " +"the :func:`run_coroutine_threadsafe` function should be used. It returns " +"a :class:`concurrent.futures.Future` to access the result::" +msgstr "" + +#: library/asyncio-dev.rst:93 +msgid "" +"async def coro_func():\n" +" return await asyncio.sleep(1, 42)\n" +"\n" +"# Later in another OS thread:\n" +"\n" +"future = asyncio.run_coroutine_threadsafe(coro_func(), loop)\n" +"# Wait for the result:\n" +"result = future.result()" msgstr "" #: library/asyncio-dev.rst:102 @@ -150,22 +175,22 @@ msgstr "" #: library/asyncio-dev.rst:105 msgid "" -"The :meth:`loop.run_in_executor` method can be used with a :class:" -"`concurrent.futures.ThreadPoolExecutor` to execute blocking code in a " -"different OS thread without blocking the OS thread that the event loop runs " -"in." +"The :meth:`loop.run_in_executor` method can be used with " +"a :class:`concurrent.futures.ThreadPoolExecutor` to execute blocking code in " +"a different OS thread without blocking the OS thread that the event loop " +"runs in." msgstr "" #: library/asyncio-dev.rst:110 msgid "" "There is currently no way to schedule coroutines or callbacks directly from " -"a different process (such as one started with :mod:`multiprocessing`). The :" -"ref:`asyncio-event-loop-methods` section lists APIs that can read from pipes " -"and watch file descriptors without blocking the event loop. In addition, " -"asyncio's :ref:`Subprocess ` APIs provide a way to start " -"a process and communicate with it from the event loop. Lastly, the " -"aforementioned :meth:`loop.run_in_executor` method can also be used with a :" -"class:`concurrent.futures.ProcessPoolExecutor` to execute code in a " +"a different process (such as one started with :mod:`multiprocessing`). " +"The :ref:`asyncio-event-loop-methods` section lists APIs that can read from " +"pipes and watch file descriptors without blocking the event loop. In " +"addition, asyncio's :ref:`Subprocess ` APIs provide a " +"way to start a process and communicate with it from the event loop. Lastly, " +"the aforementioned :meth:`loop.run_in_executor` method can also be used with " +"a :class:`concurrent.futures.ProcessPoolExecutor` to execute code in a " "different process." msgstr "" @@ -203,11 +228,15 @@ msgid "" "adjusted::" msgstr "" +#: library/asyncio-dev.rst:148 +msgid "logging.getLogger(\"asyncio\").setLevel(logging.WARNING)" +msgstr "" + #: library/asyncio-dev.rst:151 msgid "" "Network logging can block the event loop. It is recommended to use a " -"separate thread for handling logs or use non-blocking IO. For example, see :" -"ref:`blocking-handlers`." +"separate thread for handling logs or use non-blocking IO. For example, " +"see :ref:`blocking-handlers`." msgstr "" #: library/asyncio-dev.rst:159 @@ -217,22 +246,61 @@ msgstr "" #: library/asyncio-dev.rst:161 msgid "" "When a coroutine function is called, but not awaited (e.g. ``coro()`` " -"instead of ``await coro()``) or the coroutine is not scheduled with :meth:" -"`asyncio.create_task`, asyncio will emit a :exc:`RuntimeWarning`::" +"instead of ``await coro()``) or the coroutine is not scheduled " +"with :meth:`asyncio.create_task`, asyncio will emit a :exc:`RuntimeWarning`::" +msgstr "" + +#: library/asyncio-dev.rst:166 +msgid "" +"import asyncio\n" +"\n" +"async def test():\n" +" print(\"never scheduled\")\n" +"\n" +"async def main():\n" +" test()\n" +"\n" +"asyncio.run(main())" msgstr "" #: library/asyncio-dev.rst:221 msgid "Output::" msgstr "" +#: library/asyncio-dev.rst:178 +msgid "" +"test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" +" test()" +msgstr "" + #: library/asyncio-dev.rst:237 msgid "Output in debug mode::" msgstr "" +#: library/asyncio-dev.rst:183 +msgid "" +"test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" +"Coroutine created at (most recent call last)\n" +" File \"../t.py\", line 9, in \n" +" asyncio.run(main(), debug=True)\n" +"\n" +" < .. >\n" +"\n" +" File \"../t.py\", line 7, in main\n" +" test()\n" +" test()" +msgstr "" + #: library/asyncio-dev.rst:194 msgid "" -"The usual fix is to either await the coroutine or call the :meth:`asyncio." -"create_task` function::" +"The usual fix is to either await the coroutine or call " +"the :meth:`asyncio.create_task` function::" +msgstr "" + +#: library/asyncio-dev.rst:197 +msgid "" +"async def main():\n" +" await test()" msgstr "" #: library/asyncio-dev.rst:202 @@ -251,8 +319,55 @@ msgstr "" msgid "Example of an unhandled exception::" msgstr "" +#: library/asyncio-dev.rst:211 +msgid "" +"import asyncio\n" +"\n" +"async def bug():\n" +" raise Exception(\"not consumed\")\n" +"\n" +"async def main():\n" +" asyncio.create_task(bug())\n" +"\n" +"asyncio.run(main())" +msgstr "" + +#: library/asyncio-dev.rst:223 +msgid "" +"Task exception was never retrieved\n" +"future: \n" +" exception=Exception('not consumed')>\n" +"\n" +"Traceback (most recent call last):\n" +" File \"test.py\", line 4, in bug\n" +" raise Exception(\"not consumed\")\n" +"Exception: not consumed" +msgstr "" + #: library/asyncio-dev.rst:232 msgid "" ":ref:`Enable the debug mode ` to get the traceback where " "the task was created::" msgstr "" + +#: library/asyncio-dev.rst:235 +msgid "asyncio.run(main(), debug=True)" +msgstr "" + +#: library/asyncio-dev.rst:239 +msgid "" +"Task exception was never retrieved\n" +"future: \n" +" exception=Exception('not consumed') created at asyncio/tasks.py:321>\n" +"\n" +"source_traceback: Object created at (most recent call last):\n" +" File \"../t.py\", line 9, in \n" +" asyncio.run(main(), debug=True)\n" +"\n" +"< .. >\n" +"\n" +"Traceback (most recent call last):\n" +" File \"../t.py\", line 4, in bug\n" +" raise Exception(\"not consumed\")\n" +"Exception: not consumed" +msgstr "" diff --git a/library/asyncio-eventloop.po b/library/asyncio-eventloop.po index eaaa3707..8d5bcbaf 100644 --- a/library/asyncio-eventloop.po +++ b/library/asyncio-eventloop.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -135,9 +136,9 @@ msgstr "" #: library/asyncio-eventloop.rst:86 msgid "" -"The `Callback Handles`_ section documents the :class:`Handle` and :class:" -"`TimerHandle` instances which are returned from scheduling methods such as :" -"meth:`loop.call_soon` and :meth:`loop.call_later`;" +"The `Callback Handles`_ section documents the :class:`Handle` " +"and :class:`TimerHandle` instances which are returned from scheduling " +"methods such as :meth:`loop.call_soon` and :meth:`loop.call_later`;" msgstr "" #: library/asyncio-eventloop.rst:90 @@ -148,8 +149,8 @@ msgstr "" #: library/asyncio-eventloop.rst:93 msgid "" -"The `Event Loop Implementations`_ section documents the :class:" -"`SelectorEventLoop` and :class:`ProactorEventLoop` classes;" +"The `Event Loop Implementations`_ section documents " +"the :class:`SelectorEventLoop` and :class:`ProactorEventLoop` classes;" msgstr "" #: library/asyncio-eventloop.rst:96 @@ -189,7 +190,7 @@ msgstr "" #: library/asyncio-eventloop.rst:129 msgid "" -"If :meth:`stop` is called before :meth:`run_forever()` is called, the loop " +"If :meth:`stop` is called before :meth:`run_forever` is called, the loop " "will poll the I/O selector once with a timeout of zero, run all callbacks " "scheduled in response to I/O events (and those that were already scheduled), " "and then exit." @@ -241,7 +242,7 @@ msgstr "" #: library/asyncio-eventloop.rst:167 msgid "" "Schedule all currently open :term:`asynchronous generator` objects to close " -"with an :meth:`~agen.aclose()` call. After calling this method, the event " +"with an :meth:`~agen.aclose` call. After calling this method, the event " "loop will issue a warning if a new asynchronous generator is iterated. This " "should be used to reliably finalize all scheduled asynchronous generators." msgstr "" @@ -252,17 +253,26 @@ msgid "" "used." msgstr "" -#: library/asyncio-eventloop.rst:176 library/asyncio-eventloop.rst:1242 -#: library/asyncio-eventloop.rst:1660 +#: library/asyncio-eventloop.rst:176 library/asyncio-eventloop.rst:1262 +#: library/asyncio-eventloop.rst:1680 msgid "Example::" msgstr "" +#: library/asyncio-eventloop.rst:178 +msgid "" +"try:\n" +" loop.run_forever()\n" +"finally:\n" +" loop.run_until_complete(loop.shutdown_asyncgens())\n" +" loop.close()" +msgstr "" + #: library/asyncio-eventloop.rst:188 msgid "" "Schedule the closure of the default executor and wait for it to join all of " "the threads in the :class:`~concurrent.futures.ThreadPoolExecutor`. Once " -"this method has been called, using the default executor with :meth:`loop." -"run_in_executor` will raise a :exc:`RuntimeError`." +"this method has been called, using the default executor " +"with :meth:`loop.run_in_executor` will raise a :exc:`RuntimeError`." msgstr "" #: library/asyncio-eventloop.rst:194 @@ -313,9 +323,9 @@ msgstr "" #: library/asyncio-eventloop.rst:227 msgid "" -"The optional keyword-only *context* argument specifies a custom :class:" -"`contextvars.Context` for the *callback* to run in. Callbacks use the " -"current context when no *context* is provided." +"The optional keyword-only *context* argument specifies a " +"custom :class:`contextvars.Context` for the *callback* to run in. Callbacks " +"use the current context when no *context* is provided." msgstr "" #: library/asyncio-eventloop.rst:231 @@ -331,265 +341,279 @@ msgstr "" #: library/asyncio-eventloop.rst:239 msgid "" +"This function is safe to be called from a reentrant context or signal " +"handler, however, it is not safe or fruitful to use the returned handle in " +"such contexts." +msgstr "" + +#: library/asyncio-eventloop.rst:242 +msgid "" "Raises :exc:`RuntimeError` if called on a loop that's been closed. This can " "happen on a secondary thread when the main application is shutting down." msgstr "" -#: library/asyncio-eventloop.rst:243 +#: library/asyncio-eventloop.rst:246 msgid "" "See the :ref:`concurrency and multithreading ` " "section of the documentation." msgstr "" -#: library/asyncio-eventloop.rst:246 library/asyncio-eventloop.rst:296 -#: library/asyncio-eventloop.rst:316 +#: library/asyncio-eventloop.rst:249 library/asyncio-eventloop.rst:299 +#: library/asyncio-eventloop.rst:319 msgid "" "The *context* keyword-only parameter was added. See :pep:`567` for more " "details." msgstr "" -#: library/asyncio-eventloop.rst:254 +#: library/asyncio-eventloop.rst:257 msgid "" "Most :mod:`asyncio` scheduling functions don't allow passing keyword " "arguments. To do that, use :func:`functools.partial`::" msgstr "" -#: library/asyncio-eventloop.rst:261 +#: library/asyncio-eventloop.rst:260 +msgid "" +"# will schedule \"print(\"Hello\", flush=True)\"\n" +"loop.call_soon(\n" +" functools.partial(print, \"Hello\", flush=True))" +msgstr "" + +#: library/asyncio-eventloop.rst:264 msgid "" "Using partial objects is usually more convenient than using lambdas, as " "asyncio can render partial objects better in debug and error messages." msgstr "" -#: library/asyncio-eventloop.rst:269 +#: library/asyncio-eventloop.rst:272 msgid "Scheduling delayed callbacks" msgstr "" -#: library/asyncio-eventloop.rst:271 +#: library/asyncio-eventloop.rst:274 msgid "" "Event loop provides mechanisms to schedule callback functions to be called " "at some point in the future. Event loop uses monotonic clocks to track time." msgstr "" -#: library/asyncio-eventloop.rst:278 +#: library/asyncio-eventloop.rst:281 msgid "" "Schedule *callback* to be called after the given *delay* number of seconds " "(can be either an int or a float)." msgstr "" -#: library/asyncio-eventloop.rst:281 library/asyncio-eventloop.rst:313 +#: library/asyncio-eventloop.rst:284 library/asyncio-eventloop.rst:316 msgid "" "An instance of :class:`asyncio.TimerHandle` is returned which can be used to " "cancel the callback." msgstr "" -#: library/asyncio-eventloop.rst:284 +#: library/asyncio-eventloop.rst:287 msgid "" "*callback* will be called exactly once. If two callbacks are scheduled for " "exactly the same time, the order in which they are called is undefined." msgstr "" -#: library/asyncio-eventloop.rst:288 +#: library/asyncio-eventloop.rst:291 msgid "" "The optional positional *args* will be passed to the callback when it is " -"called. If you want the callback to be called with keyword arguments use :" -"func:`functools.partial`." +"called. If you want the callback to be called with keyword arguments " +"use :func:`functools.partial`." msgstr "" -#: library/asyncio-eventloop.rst:292 +#: library/asyncio-eventloop.rst:295 msgid "" -"An optional keyword-only *context* argument allows specifying a custom :" -"class:`contextvars.Context` for the *callback* to run in. The current " -"context is used when no *context* is provided." +"An optional keyword-only *context* argument allows specifying a " +"custom :class:`contextvars.Context` for the *callback* to run in. The " +"current context is used when no *context* is provided." msgstr "" -#: library/asyncio-eventloop.rst:300 +#: library/asyncio-eventloop.rst:303 msgid "" "In Python 3.7 and earlier with the default event loop implementation, the " "*delay* could not exceed one day. This has been fixed in Python 3.8." msgstr "" -#: library/asyncio-eventloop.rst:307 +#: library/asyncio-eventloop.rst:310 msgid "" "Schedule *callback* to be called at the given absolute timestamp *when* (an " "int or a float), using the same time reference as :meth:`loop.time`." msgstr "" -#: library/asyncio-eventloop.rst:311 +#: library/asyncio-eventloop.rst:314 msgid "This method's behavior is the same as :meth:`call_later`." msgstr "" -#: library/asyncio-eventloop.rst:320 +#: library/asyncio-eventloop.rst:323 msgid "" "In Python 3.7 and earlier with the default event loop implementation, the " "difference between *when* and the current time could not exceed one day. " "This has been fixed in Python 3.8." msgstr "" -#: library/asyncio-eventloop.rst:327 +#: library/asyncio-eventloop.rst:330 msgid "" "Return the current time, as a :class:`float` value, according to the event " "loop's internal monotonic clock." msgstr "" -#: library/asyncio-eventloop.rst:331 +#: library/asyncio-eventloop.rst:334 msgid "" "In Python 3.7 and earlier timeouts (relative *delay* or absolute *when*) " "should not exceed one day. This has been fixed in Python 3.8." msgstr "" -#: library/asyncio-eventloop.rst:337 +#: library/asyncio-eventloop.rst:340 msgid "The :func:`asyncio.sleep` function." msgstr "" -#: library/asyncio-eventloop.rst:341 +#: library/asyncio-eventloop.rst:344 msgid "Creating Futures and Tasks" msgstr "" -#: library/asyncio-eventloop.rst:345 +#: library/asyncio-eventloop.rst:348 msgid "Create an :class:`asyncio.Future` object attached to the event loop." msgstr "" -#: library/asyncio-eventloop.rst:347 +#: library/asyncio-eventloop.rst:350 msgid "" "This is the preferred way to create Futures in asyncio. This lets third-" "party event loops provide alternative implementations of the Future object " "(with better performance or instrumentation)." msgstr "" -#: library/asyncio-eventloop.rst:355 +#: library/asyncio-eventloop.rst:358 msgid "" -"Schedule the execution of :ref:`coroutine ` *coro*. Return a :" -"class:`Task` object." +"Schedule the execution of :ref:`coroutine ` *coro*. Return " +"a :class:`Task` object." msgstr "" -#: library/asyncio-eventloop.rst:358 +#: library/asyncio-eventloop.rst:361 msgid "" "Third-party event loops can use their own subclass of :class:`Task` for " -"interoperability. In this case, the result type is a subclass of :class:" -"`Task`." +"interoperability. In this case, the result type is a subclass " +"of :class:`Task`." msgstr "" -#: library/asyncio-eventloop.rst:362 +#: library/asyncio-eventloop.rst:365 msgid "" "If the *name* argument is provided and not ``None``, it is set as the name " "of the task using :meth:`Task.set_name`." msgstr "" -#: library/asyncio-eventloop.rst:365 +#: library/asyncio-eventloop.rst:368 msgid "" -"An optional keyword-only *context* argument allows specifying a custom :" -"class:`contextvars.Context` for the *coro* to run in. The current context " -"copy is created when no *context* is provided." +"An optional keyword-only *context* argument allows specifying a " +"custom :class:`contextvars.Context` for the *coro* to run in. The current " +"context copy is created when no *context* is provided." msgstr "" -#: library/asyncio-eventloop.rst:369 +#: library/asyncio-eventloop.rst:372 msgid "Added the *name* parameter." msgstr "" -#: library/asyncio-eventloop.rst:372 +#: library/asyncio-eventloop.rst:375 msgid "Added the *context* parameter." msgstr "" -#: library/asyncio-eventloop.rst:377 +#: library/asyncio-eventloop.rst:380 msgid "Set a task factory that will be used by :meth:`loop.create_task`." msgstr "" -#: library/asyncio-eventloop.rst:380 +#: library/asyncio-eventloop.rst:383 msgid "" "If *factory* is ``None`` the default task factory will be set. Otherwise, " "*factory* must be a *callable* with the signature matching ``(loop, coro, " "context=None)``, where *loop* is a reference to the active event loop, and " -"*coro* is a coroutine object. The callable must return a :class:`asyncio." -"Future`-compatible object." +"*coro* is a coroutine object. The callable must return " +"a :class:`asyncio.Future`-compatible object." msgstr "" -#: library/asyncio-eventloop.rst:388 +#: library/asyncio-eventloop.rst:391 msgid "Return a task factory or ``None`` if the default one is in use." msgstr "" -#: library/asyncio-eventloop.rst:392 +#: library/asyncio-eventloop.rst:395 msgid "Opening network connections" msgstr "" -#: library/asyncio-eventloop.rst:403 +#: library/asyncio-eventloop.rst:406 msgid "" "Open a streaming transport connection to a given address specified by *host* " "and *port*." msgstr "" -#: library/asyncio-eventloop.rst:406 +#: library/asyncio-eventloop.rst:409 msgid "" -"The socket family can be either :py:const:`~socket.AF_INET` or :py:const:" -"`~socket.AF_INET6` depending on *host* (or the *family* argument, if " -"provided)." +"The socket family can be either :py:const:`~socket.AF_INET` " +"or :py:const:`~socket.AF_INET6` depending on *host* (or the *family* " +"argument, if provided)." msgstr "" -#: library/asyncio-eventloop.rst:410 +#: library/asyncio-eventloop.rst:413 msgid "The socket type will be :py:const:`~socket.SOCK_STREAM`." msgstr "" -#: library/asyncio-eventloop.rst:412 library/asyncio-eventloop.rst:1156 -#: library/asyncio-eventloop.rst:1172 +#: library/asyncio-eventloop.rst:415 library/asyncio-eventloop.rst:1173 +#: library/asyncio-eventloop.rst:1189 msgid "" "*protocol_factory* must be a callable returning an :ref:`asyncio protocol " "` implementation." msgstr "" -#: library/asyncio-eventloop.rst:415 +#: library/asyncio-eventloop.rst:418 msgid "" "This method will try to establish the connection in the background. When " "successful, it returns a ``(transport, protocol)`` pair." msgstr "" -#: library/asyncio-eventloop.rst:418 +#: library/asyncio-eventloop.rst:421 msgid "The chronological synopsis of the underlying operation is as follows:" msgstr "" -#: library/asyncio-eventloop.rst:420 +#: library/asyncio-eventloop.rst:423 msgid "" "The connection is established and a :ref:`transport ` is " "created for it." msgstr "" -#: library/asyncio-eventloop.rst:423 +#: library/asyncio-eventloop.rst:426 msgid "" -"*protocol_factory* is called without arguments and is expected to return a :" -"ref:`protocol ` instance." +"*protocol_factory* is called without arguments and is expected to return " +"a :ref:`protocol ` instance." msgstr "" -#: library/asyncio-eventloop.rst:426 +#: library/asyncio-eventloop.rst:429 msgid "" -"The protocol instance is coupled with the transport by calling its :meth:" -"`~BaseProtocol.connection_made` method." +"The protocol instance is coupled with the transport by calling " +"its :meth:`~BaseProtocol.connection_made` method." msgstr "" -#: library/asyncio-eventloop.rst:429 +#: library/asyncio-eventloop.rst:432 msgid "A ``(transport, protocol)`` tuple is returned on success." msgstr "" -#: library/asyncio-eventloop.rst:431 +#: library/asyncio-eventloop.rst:434 msgid "" "The created transport is an implementation-dependent bidirectional stream." msgstr "" -#: library/asyncio-eventloop.rst:434 library/asyncio-eventloop.rst:566 +#: library/asyncio-eventloop.rst:437 library/asyncio-eventloop.rst:569 msgid "Other arguments:" msgstr "" -#: library/asyncio-eventloop.rst:436 +#: library/asyncio-eventloop.rst:439 msgid "" "*ssl*: if given and not false, a SSL/TLS transport is created (by default a " "plain TCP transport is created). If *ssl* is a :class:`ssl.SSLContext` " -"object, this context is used to create the transport; if *ssl* is :const:" -"`True`, a default context returned from :func:`ssl.create_default_context` " -"is used." +"object, this context is used to create the transport; if *ssl* " +"is :const:`True`, a default context returned " +"from :func:`ssl.create_default_context` is used." msgstr "" -#: library/asyncio-eventloop.rst:442 +#: library/asyncio-eventloop.rst:445 msgid ":ref:`SSL/TLS security considerations `" msgstr "" -#: library/asyncio-eventloop.rst:444 +#: library/asyncio-eventloop.rst:447 msgid "" "*server_hostname* sets or overrides the hostname that the target server's " "certificate will be matched against. Should only be passed if *ssl* is not " @@ -600,7 +624,7 @@ msgid "" "potential man-in-the-middle attacks)." msgstr "" -#: library/asyncio-eventloop.rst:452 +#: library/asyncio-eventloop.rst:455 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to getaddrinfo() for *host* resolution. If given, " @@ -608,7 +632,7 @@ msgid "" "constants." msgstr "" -#: library/asyncio-eventloop.rst:457 +#: library/asyncio-eventloop.rst:460 msgid "" "*happy_eyeballs_delay*, if given, enables Happy Eyeballs for this " "connection. It should be a floating-point number representing the amount of " @@ -618,7 +642,7 @@ msgid "" "the RFC is ``0.25`` (250 milliseconds)." msgstr "" -#: library/asyncio-eventloop.rst:465 +#: library/asyncio-eventloop.rst:468 msgid "" "*interleave* controls address reordering when a host name resolves to " "multiple IP addresses. If ``0`` or unspecified, no reordering is done, and " @@ -629,45 +653,45 @@ msgid "" "*happy_eyeballs_delay* is not specified, and ``1`` if it is." msgstr "" -#: library/asyncio-eventloop.rst:474 +#: library/asyncio-eventloop.rst:477 msgid "" -"*sock*, if given, should be an existing, already connected :class:`socket." -"socket` object to be used by the transport. If *sock* is given, none of " -"*host*, *port*, *family*, *proto*, *flags*, *happy_eyeballs_delay*, " -"*interleave* and *local_addr* should be specified." +"*sock*, if given, should be an existing, already " +"connected :class:`socket.socket` object to be used by the transport. If " +"*sock* is given, none of *host*, *port*, *family*, *proto*, *flags*, " +"*happy_eyeballs_delay*, *interleave* and *local_addr* should be specified." msgstr "" -#: library/asyncio-eventloop.rst:482 library/asyncio-eventloop.rst:597 -#: library/asyncio-eventloop.rst:825 +#: library/asyncio-eventloop.rst:485 library/asyncio-eventloop.rst:600 +#: library/asyncio-eventloop.rst:828 msgid "" "The *sock* argument transfers ownership of the socket to the transport " -"created. To close the socket, call the transport's :meth:`~asyncio." -"BaseTransport.close` method." +"created. To close the socket, call the " +"transport's :meth:`~asyncio.BaseTransport.close` method." msgstr "" -#: library/asyncio-eventloop.rst:486 +#: library/asyncio-eventloop.rst:489 msgid "" "*local_addr*, if given, is a ``(local_host, local_port)`` tuple used to bind " "the socket locally. The *local_host* and *local_port* are looked up using " "``getaddrinfo()``, similarly to *host* and *port*." msgstr "" -#: library/asyncio-eventloop.rst:490 library/asyncio-eventloop.rst:919 +#: library/asyncio-eventloop.rst:493 library/asyncio-eventloop.rst:922 msgid "" "*ssl_handshake_timeout* is (for a TLS connection) the time in seconds to " "wait for the TLS handshake to complete before aborting the connection. " "``60.0`` seconds if ``None`` (default)." msgstr "" -#: library/asyncio-eventloop.rst:494 library/asyncio-eventloop.rst:742 -#: library/asyncio-eventloop.rst:836 library/asyncio-eventloop.rst:923 +#: library/asyncio-eventloop.rst:497 library/asyncio-eventloop.rst:745 +#: library/asyncio-eventloop.rst:839 library/asyncio-eventloop.rst:926 msgid "" "*ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown " "to complete before aborting the connection. ``30.0`` seconds if ``None`` " "(default)." msgstr "" -#: library/asyncio-eventloop.rst:498 +#: library/asyncio-eventloop.rst:501 msgid "" "*all_errors* determines what exceptions are raised when a connection cannot " "be created. By default, only a single ``Exception`` is raised: the first " @@ -677,25 +701,25 @@ msgid "" "(even if there is only one)." msgstr "" -#: library/asyncio-eventloop.rst:508 library/asyncio-eventloop.rst:754 +#: library/asyncio-eventloop.rst:511 library/asyncio-eventloop.rst:757 msgid "Added support for SSL/TLS in :class:`ProactorEventLoop`." msgstr "" -#: library/asyncio-eventloop.rst:512 +#: library/asyncio-eventloop.rst:515 msgid "" "The socket option :ref:`socket.TCP_NODELAY ` is set " "by default for all TCP connections." msgstr "" -#: library/asyncio-eventloop.rst:517 library/asyncio-eventloop.rst:846 +#: library/asyncio-eventloop.rst:520 library/asyncio-eventloop.rst:849 msgid "Added the *ssl_handshake_timeout* parameter." msgstr "" -#: library/asyncio-eventloop.rst:521 +#: library/asyncio-eventloop.rst:524 msgid "Added the *happy_eyeballs_delay* and *interleave* parameters." msgstr "" -#: library/asyncio-eventloop.rst:523 +#: library/asyncio-eventloop.rst:526 msgid "" "Happy Eyeballs Algorithm: Success with Dual-Stack Hosts. When a server's " "IPv4 path and protocol are working, but the server's IPv6 path and protocol " @@ -706,68 +730,69 @@ msgid "" "visible delay and provides an algorithm." msgstr "" -#: library/asyncio-eventloop.rst:532 +#: library/asyncio-eventloop.rst:535 msgid "For more information: https://datatracker.ietf.org/doc/html/rfc6555" msgstr "" -#: library/asyncio-eventloop.rst:536 library/asyncio-eventloop.rst:660 -#: library/asyncio-eventloop.rst:768 library/asyncio-eventloop.rst:803 -#: library/asyncio-eventloop.rst:850 library/asyncio-eventloop.rst:931 +#: library/asyncio-eventloop.rst:539 library/asyncio-eventloop.rst:663 +#: library/asyncio-eventloop.rst:771 library/asyncio-eventloop.rst:806 +#: library/asyncio-eventloop.rst:853 library/asyncio-eventloop.rst:934 msgid "Added the *ssl_shutdown_timeout* parameter." msgstr "" -#: library/asyncio-eventloop.rst:538 +#: library/asyncio-eventloop.rst:541 msgid "*all_errors* was added." msgstr "" -#: library/asyncio-eventloop.rst:543 +#: library/asyncio-eventloop.rst:546 msgid "" "The :func:`open_connection` function is a high-level alternative API. It " "returns a pair of (:class:`StreamReader`, :class:`StreamWriter`) that can be " "used directly in async/await code." msgstr "" -#: library/asyncio-eventloop.rst:553 +#: library/asyncio-eventloop.rst:556 msgid "Create a datagram connection." msgstr "" -#: library/asyncio-eventloop.rst:555 +#: library/asyncio-eventloop.rst:558 msgid "" -"The socket family can be either :py:const:`~socket.AF_INET`, :py:const:" -"`~socket.AF_INET6`, or :py:const:`~socket.AF_UNIX`, depending on *host* (or " -"the *family* argument, if provided)." +"The socket family can be " +"either :py:const:`~socket.AF_INET`, :py:const:`~socket.AF_INET6`, " +"or :py:const:`~socket.AF_UNIX`, depending on *host* (or the *family* " +"argument, if provided)." msgstr "" -#: library/asyncio-eventloop.rst:559 +#: library/asyncio-eventloop.rst:562 msgid "The socket type will be :py:const:`~socket.SOCK_DGRAM`." msgstr "" -#: library/asyncio-eventloop.rst:561 library/asyncio-eventloop.rst:685 -#: library/asyncio-eventloop.rst:817 +#: library/asyncio-eventloop.rst:564 library/asyncio-eventloop.rst:688 +#: library/asyncio-eventloop.rst:820 msgid "" "*protocol_factory* must be a callable returning a :ref:`protocol ` implementation." msgstr "" -#: library/asyncio-eventloop.rst:564 library/asyncio-eventloop.rst:642 +#: library/asyncio-eventloop.rst:567 library/asyncio-eventloop.rst:645 msgid "A tuple of ``(transport, protocol)`` is returned on success." msgstr "" -#: library/asyncio-eventloop.rst:568 +#: library/asyncio-eventloop.rst:571 msgid "" "*local_addr*, if given, is a ``(local_host, local_port)`` tuple used to bind " -"the socket locally. The *local_host* and *local_port* are looked up using :" -"meth:`getaddrinfo`." +"the socket locally. The *local_host* and *local_port* are looked up " +"using :meth:`getaddrinfo`." msgstr "" -#: library/asyncio-eventloop.rst:572 +#: library/asyncio-eventloop.rst:575 msgid "" "*remote_addr*, if given, is a ``(remote_host, remote_port)`` tuple used to " "connect the socket to a remote address. The *remote_host* and *remote_port* " "are looked up using :meth:`getaddrinfo`." msgstr "" -#: library/asyncio-eventloop.rst:576 +#: library/asyncio-eventloop.rst:579 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to :meth:`getaddrinfo` for *host* resolution. If " @@ -775,7 +800,7 @@ msgid "" "module constants." msgstr "" -#: library/asyncio-eventloop.rst:581 +#: library/asyncio-eventloop.rst:584 msgid "" "*reuse_port* tells the kernel to allow this endpoint to be bound to the same " "port as other existing endpoints are bound to, so long as they all set this " @@ -784,51 +809,53 @@ msgid "" "is not defined then this capability is unsupported." msgstr "" -#: library/asyncio-eventloop.rst:587 +#: library/asyncio-eventloop.rst:590 msgid "" "*allow_broadcast* tells the kernel to allow this endpoint to send messages " "to the broadcast address." msgstr "" -#: library/asyncio-eventloop.rst:590 +#: library/asyncio-eventloop.rst:593 msgid "" "*sock* can optionally be specified in order to use a preexisting, already " "connected, :class:`socket.socket` object to be used by the transport. If " -"specified, *local_addr* and *remote_addr* should be omitted (must be :const:" -"`None`)." +"specified, *local_addr* and *remote_addr* should be omitted (must " +"be :const:`None`)." msgstr "" -#: library/asyncio-eventloop.rst:601 +#: library/asyncio-eventloop.rst:604 msgid "" -"See :ref:`UDP echo client protocol ` and :" -"ref:`UDP echo server protocol ` examples." +"See :ref:`UDP echo client protocol ` " +"and :ref:`UDP echo server protocol ` " +"examples." msgstr "" -#: library/asyncio-eventloop.rst:604 +#: library/asyncio-eventloop.rst:607 msgid "" "The *family*, *proto*, *flags*, *reuse_address*, *reuse_port*, " "*allow_broadcast*, and *sock* parameters were added." msgstr "" -#: library/asyncio-eventloop.rst:608 +#: library/asyncio-eventloop.rst:611 msgid "Added support for Windows." msgstr "" -#: library/asyncio-eventloop.rst:611 +#: library/asyncio-eventloop.rst:614 msgid "" -"The *reuse_address* parameter is no longer supported, as using :ref:`socket." -"SO_REUSEADDR ` poses a significant security concern " -"for UDP. Explicitly passing ``reuse_address=True`` will raise an exception." +"The *reuse_address* parameter is no longer supported, as " +"using :ref:`socket.SO_REUSEADDR ` poses a significant " +"security concern for UDP. Explicitly passing ``reuse_address=True`` will " +"raise an exception." msgstr "" -#: library/asyncio-eventloop.rst:617 +#: library/asyncio-eventloop.rst:620 msgid "" "When multiple processes with differing UIDs assign sockets to an identical " "UDP socket address with ``SO_REUSEADDR``, incoming packets can become " "randomly distributed among the sockets." msgstr "" -#: library/asyncio-eventloop.rst:621 +#: library/asyncio-eventloop.rst:624 msgid "" "For supported platforms, *reuse_port* can be used as a replacement for " "similar functionality. With *reuse_port*, :ref:`socket.SO_REUSEPORT `: Unix." +#: library/asyncio-eventloop.rst:655 library/asyncio-eventloop.rst:797 +#: library/asyncio-eventloop.rst:1242 library/asyncio-eventloop.rst:1750 +#: library/asyncio-eventloop.rst:1757 +msgid "Availability" msgstr "" -#: library/asyncio-eventloop.rst:654 +#: library/asyncio-eventloop.rst:657 msgid "" "Added the *ssl_handshake_timeout* parameter. The *path* parameter can now be " "a :term:`path-like object`." msgstr "" -#: library/asyncio-eventloop.rst:664 +#: library/asyncio-eventloop.rst:667 msgid "Creating network servers" msgstr "" -#: library/asyncio-eventloop.rst:678 +#: library/asyncio-eventloop.rst:681 msgid "" "Create a TCP server (socket type :const:`~socket.SOCK_STREAM`) listening on " "*port* of the *host* address." msgstr "" -#: library/asyncio-eventloop.rst:681 +#: library/asyncio-eventloop.rst:684 msgid "Returns a :class:`Server` object." msgstr "" -#: library/asyncio-eventloop.rst:683 +#: library/asyncio-eventloop.rst:686 msgid "Arguments:" msgstr "" -#: library/asyncio-eventloop.rst:688 +#: library/asyncio-eventloop.rst:691 msgid "" "The *host* parameter can be set to several types which determine where the " "server would be listening:" msgstr "" -#: library/asyncio-eventloop.rst:691 +#: library/asyncio-eventloop.rst:694 msgid "" "If *host* is a string, the TCP server is bound to a single network interface " "specified by *host*." msgstr "" -#: library/asyncio-eventloop.rst:694 +#: library/asyncio-eventloop.rst:697 msgid "" "If *host* is a sequence of strings, the TCP server is bound to all network " "interfaces specified by the sequence." msgstr "" -#: library/asyncio-eventloop.rst:697 +#: library/asyncio-eventloop.rst:700 msgid "" "If *host* is an empty string or ``None``, all interfaces are assumed and a " "list of multiple sockets will be returned (most likely one for IPv4 and " "another one for IPv6)." msgstr "" -#: library/asyncio-eventloop.rst:701 +#: library/asyncio-eventloop.rst:704 msgid "" "The *port* parameter can be set to specify which port the server should " "listen on. If ``0`` or ``None`` (the default), a random unused port will be " @@ -927,63 +956,64 @@ msgid "" "different random port will be selected for each interface)." msgstr "" -#: library/asyncio-eventloop.rst:706 +#: library/asyncio-eventloop.rst:709 msgid "" -"*family* can be set to either :const:`socket.AF_INET` or :const:`~socket." -"AF_INET6` to force the socket to use IPv4 or IPv6. If not set, the *family* " -"will be determined from host name (defaults to :const:`~socket.AF_UNSPEC`)." +"*family* can be set to either :const:`socket.AF_INET` " +"or :const:`~socket.AF_INET6` to force the socket to use IPv4 or IPv6. If not " +"set, the *family* will be determined from host name (defaults " +"to :const:`~socket.AF_UNSPEC`)." msgstr "" -#: library/asyncio-eventloop.rst:711 +#: library/asyncio-eventloop.rst:714 msgid "*flags* is a bitmask for :meth:`getaddrinfo`." msgstr "" -#: library/asyncio-eventloop.rst:713 +#: library/asyncio-eventloop.rst:716 msgid "" "*sock* can optionally be specified in order to use a preexisting socket " "object. If specified, *host* and *port* must not be specified." msgstr "" -#: library/asyncio-eventloop.rst:718 +#: library/asyncio-eventloop.rst:721 msgid "" "The *sock* argument transfers ownership of the socket to the server created. " "To close the socket, call the server's :meth:`~asyncio.Server.close` method." msgstr "" -#: library/asyncio-eventloop.rst:722 +#: library/asyncio-eventloop.rst:725 msgid "" -"*backlog* is the maximum number of queued connections passed to :meth:" -"`~socket.socket.listen` (defaults to 100)." +"*backlog* is the maximum number of queued connections passed " +"to :meth:`~socket.socket.listen` (defaults to 100)." msgstr "" -#: library/asyncio-eventloop.rst:725 +#: library/asyncio-eventloop.rst:728 msgid "" "*ssl* can be set to an :class:`~ssl.SSLContext` instance to enable TLS over " "the accepted connections." msgstr "" -#: library/asyncio-eventloop.rst:728 +#: library/asyncio-eventloop.rst:731 msgid "" "*reuse_address* tells the kernel to reuse a local socket in ``TIME_WAIT`` " "state, without waiting for its natural timeout to expire. If not specified " "will automatically be set to ``True`` on Unix." msgstr "" -#: library/asyncio-eventloop.rst:733 +#: library/asyncio-eventloop.rst:736 msgid "" "*reuse_port* tells the kernel to allow this endpoint to be bound to the same " "port as other existing endpoints are bound to, so long as they all set this " "flag when being created. This option is not supported on Windows." msgstr "" -#: library/asyncio-eventloop.rst:738 +#: library/asyncio-eventloop.rst:741 msgid "" "*ssl_handshake_timeout* is (for a TLS server) the time in seconds to wait " "for the TLS handshake to complete before aborting the connection. ``60.0`` " "seconds if ``None`` (default)." msgstr "" -#: library/asyncio-eventloop.rst:746 +#: library/asyncio-eventloop.rst:749 msgid "" "*start_serving* set to ``True`` (the default) causes the created server to " "start accepting connections immediately. When set to ``False``, the user " @@ -991,104 +1021,104 @@ msgid "" "to make the server to start accepting connections." msgstr "" -#: library/asyncio-eventloop.rst:758 +#: library/asyncio-eventloop.rst:761 msgid "The *host* parameter can be a sequence of strings." msgstr "" -#: library/asyncio-eventloop.rst:762 +#: library/asyncio-eventloop.rst:765 msgid "" "Added *ssl_handshake_timeout* and *start_serving* parameters. The socket " "option :ref:`socket.TCP_NODELAY ` is set by default " "for all TCP connections." msgstr "" -#: library/asyncio-eventloop.rst:772 +#: library/asyncio-eventloop.rst:775 msgid "" "The :func:`start_server` function is a higher-level alternative API that " "returns a pair of :class:`StreamReader` and :class:`StreamWriter` that can " "be used in an async/await code." msgstr "" -#: library/asyncio-eventloop.rst:783 +#: library/asyncio-eventloop.rst:786 msgid "" -"Similar to :meth:`loop.create_server` but works with the :py:const:`~socket." -"AF_UNIX` socket family." +"Similar to :meth:`loop.create_server` but works with " +"the :py:const:`~socket.AF_UNIX` socket family." msgstr "" -#: library/asyncio-eventloop.rst:786 +#: library/asyncio-eventloop.rst:789 msgid "" "*path* is the name of a Unix domain socket, and is required, unless a *sock* " "argument is provided. Abstract Unix sockets, :class:`str`, :class:`bytes`, " "and :class:`~pathlib.Path` paths are supported." msgstr "" -#: library/asyncio-eventloop.rst:791 +#: library/asyncio-eventloop.rst:794 msgid "" "See the documentation of the :meth:`loop.create_server` method for " "information about arguments to this method." msgstr "" -#: library/asyncio-eventloop.rst:798 +#: library/asyncio-eventloop.rst:801 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :class:`~pathlib.Path` object." msgstr "" -#: library/asyncio-eventloop.rst:810 +#: library/asyncio-eventloop.rst:813 msgid "Wrap an already accepted connection into a transport/protocol pair." msgstr "" -#: library/asyncio-eventloop.rst:812 +#: library/asyncio-eventloop.rst:815 msgid "" "This method can be used by servers that accept connections outside of " "asyncio but that use asyncio to handle them." msgstr "" -#: library/asyncio-eventloop.rst:815 library/asyncio-eventloop.rst:905 +#: library/asyncio-eventloop.rst:818 library/asyncio-eventloop.rst:908 msgid "Parameters:" msgstr "" -#: library/asyncio-eventloop.rst:820 +#: library/asyncio-eventloop.rst:823 msgid "" "*sock* is a preexisting socket object returned from :meth:`socket.accept " "`." msgstr "" -#: library/asyncio-eventloop.rst:829 +#: library/asyncio-eventloop.rst:832 msgid "" "*ssl* can be set to an :class:`~ssl.SSLContext` to enable SSL over the " "accepted connections." msgstr "" -#: library/asyncio-eventloop.rst:832 +#: library/asyncio-eventloop.rst:835 msgid "" "*ssl_handshake_timeout* is (for an SSL connection) the time in seconds to " "wait for the SSL handshake to complete before aborting the connection. " "``60.0`` seconds if ``None`` (default)." msgstr "" -#: library/asyncio-eventloop.rst:840 +#: library/asyncio-eventloop.rst:843 msgid "Returns a ``(transport, protocol)`` pair." msgstr "" -#: library/asyncio-eventloop.rst:854 +#: library/asyncio-eventloop.rst:857 msgid "Transferring files" msgstr "" -#: library/asyncio-eventloop.rst:859 +#: library/asyncio-eventloop.rst:862 msgid "" "Send a *file* over a *transport*. Return the total number of bytes sent." msgstr "" -#: library/asyncio-eventloop.rst:862 +#: library/asyncio-eventloop.rst:865 msgid "The method uses high-performance :meth:`os.sendfile` if available." msgstr "" -#: library/asyncio-eventloop.rst:864 +#: library/asyncio-eventloop.rst:867 msgid "*file* must be a regular file object opened in binary mode." msgstr "" -#: library/asyncio-eventloop.rst:866 library/asyncio-eventloop.rst:1111 +#: library/asyncio-eventloop.rst:869 library/asyncio-eventloop.rst:1120 msgid "" "*offset* tells from where to start reading the file. If specified, *count* " "is the total number of bytes to transmit as opposed to sending the file " @@ -1097,35 +1127,35 @@ msgid "" "obtain the actual number of bytes sent." msgstr "" -#: library/asyncio-eventloop.rst:873 +#: library/asyncio-eventloop.rst:876 msgid "" "*fallback* set to ``True`` makes asyncio to manually read and send the file " "when the platform does not support the sendfile system call (e.g. Windows or " "SSL socket on Unix)." msgstr "" -#: library/asyncio-eventloop.rst:877 +#: library/asyncio-eventloop.rst:880 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support the " "*sendfile* syscall and *fallback* is ``False``." msgstr "" -#: library/asyncio-eventloop.rst:884 +#: library/asyncio-eventloop.rst:887 msgid "TLS Upgrade" msgstr "" -#: library/asyncio-eventloop.rst:891 +#: library/asyncio-eventloop.rst:894 msgid "Upgrade an existing transport-based connection to TLS." msgstr "" -#: library/asyncio-eventloop.rst:893 +#: library/asyncio-eventloop.rst:896 msgid "" "Create a TLS coder/decoder instance and insert it between the *transport* " "and the *protocol*. The coder/decoder implements both *transport*-facing " "protocol and *protocol*-facing transport." msgstr "" -#: library/asyncio-eventloop.rst:897 +#: library/asyncio-eventloop.rst:900 msgid "" "Return the created two-interface instance. After *await*, the *protocol* " "must stop using the original *transport* and communicate with the returned " @@ -1133,149 +1163,155 @@ msgid "" "exchanges extra TLS session packets with *transport*." msgstr "" -#: library/asyncio-eventloop.rst:902 +#: library/asyncio-eventloop.rst:905 msgid "" "In some situations (e.g. when the passed transport is already closing) this " "may return ``None``." msgstr "" -#: library/asyncio-eventloop.rst:907 +#: library/asyncio-eventloop.rst:910 msgid "" -"*transport* and *protocol* instances that methods like :meth:`~loop." -"create_server` and :meth:`~loop.create_connection` return." +"*transport* and *protocol* instances that methods " +"like :meth:`~loop.create_server` and :meth:`~loop.create_connection` return." msgstr "" -#: library/asyncio-eventloop.rst:911 +#: library/asyncio-eventloop.rst:914 msgid "*sslcontext*: a configured instance of :class:`~ssl.SSLContext`." msgstr "" -#: library/asyncio-eventloop.rst:913 +#: library/asyncio-eventloop.rst:916 msgid "" "*server_side* pass ``True`` when a server-side connection is being upgraded " "(like the one created by :meth:`~loop.create_server`)." msgstr "" -#: library/asyncio-eventloop.rst:916 +#: library/asyncio-eventloop.rst:919 msgid "" "*server_hostname*: sets or overrides the host name that the target server's " "certificate will be matched against." msgstr "" -#: library/asyncio-eventloop.rst:936 +#: library/asyncio-eventloop.rst:939 msgid "Watching file descriptors" msgstr "" -#: library/asyncio-eventloop.rst:940 +#: library/asyncio-eventloop.rst:943 msgid "" "Start monitoring the *fd* file descriptor for read availability and invoke " "*callback* with the specified arguments once *fd* is available for reading." msgstr "" -#: library/asyncio-eventloop.rst:946 +#: library/asyncio-eventloop.rst:947 library/asyncio-eventloop.rst:961 +msgid "" +"Any preexisting callback registered for *fd* is cancelled and replaced by " +"*callback*." +msgstr "" + +#: library/asyncio-eventloop.rst:952 msgid "" "Stop monitoring the *fd* file descriptor for read availability. Returns " "``True`` if *fd* was previously being monitored for reads." msgstr "" -#: library/asyncio-eventloop.rst:951 +#: library/asyncio-eventloop.rst:957 msgid "" "Start monitoring the *fd* file descriptor for write availability and invoke " "*callback* with the specified arguments once *fd* is available for writing." msgstr "" -#: library/asyncio-eventloop.rst:955 library/asyncio-eventloop.rst:1212 +#: library/asyncio-eventloop.rst:964 library/asyncio-eventloop.rst:1229 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *callback*." msgstr "" -#: library/asyncio-eventloop.rst:960 +#: library/asyncio-eventloop.rst:969 msgid "" "Stop monitoring the *fd* file descriptor for write availability. Returns " "``True`` if *fd* was previously being monitored for writes." msgstr "" -#: library/asyncio-eventloop.rst:963 +#: library/asyncio-eventloop.rst:972 msgid "" "See also :ref:`Platform Support ` section for some " "limitations of these methods." msgstr "" -#: library/asyncio-eventloop.rst:968 +#: library/asyncio-eventloop.rst:977 msgid "Working with socket objects directly" msgstr "" -#: library/asyncio-eventloop.rst:970 +#: library/asyncio-eventloop.rst:979 msgid "" -"In general, protocol implementations that use transport-based APIs such as :" -"meth:`loop.create_connection` and :meth:`loop.create_server` are faster than " -"implementations that work with sockets directly. However, there are some use " -"cases when performance is not critical, and working with :class:`~socket." -"socket` objects directly is more convenient." +"In general, protocol implementations that use transport-based APIs such " +"as :meth:`loop.create_connection` and :meth:`loop.create_server` are faster " +"than implementations that work with sockets directly. However, there are " +"some use cases when performance is not critical, and working " +"with :class:`~socket.socket` objects directly is more convenient." msgstr "" -#: library/asyncio-eventloop.rst:979 +#: library/asyncio-eventloop.rst:988 msgid "" -"Receive up to *nbytes* from *sock*. Asynchronous version of :meth:`socket." -"recv() `." +"Receive up to *nbytes* from *sock*. Asynchronous version " +"of :meth:`socket.recv() `." msgstr "" -#: library/asyncio-eventloop.rst:982 +#: library/asyncio-eventloop.rst:991 msgid "Return the received data as a bytes object." msgstr "" -#: library/asyncio-eventloop.rst:984 library/asyncio-eventloop.rst:998 -#: library/asyncio-eventloop.rst:1009 library/asyncio-eventloop.rst:1021 -#: library/asyncio-eventloop.rst:1036 library/asyncio-eventloop.rst:1051 -#: library/asyncio-eventloop.rst:1061 library/asyncio-eventloop.rst:1087 -#: library/asyncio-eventloop.rst:1125 +#: library/asyncio-eventloop.rst:993 library/asyncio-eventloop.rst:1007 +#: library/asyncio-eventloop.rst:1018 library/asyncio-eventloop.rst:1030 +#: library/asyncio-eventloop.rst:1045 library/asyncio-eventloop.rst:1060 +#: library/asyncio-eventloop.rst:1070 library/asyncio-eventloop.rst:1096 +#: library/asyncio-eventloop.rst:1134 msgid "*sock* must be a non-blocking socket." msgstr "" -#: library/asyncio-eventloop.rst:986 +#: library/asyncio-eventloop.rst:995 msgid "" "Even though this method was always documented as a coroutine method, " "releases before Python 3.7 returned a :class:`Future`. Since Python 3.7 this " "is an ``async def`` method." msgstr "" -#: library/asyncio-eventloop.rst:993 +#: library/asyncio-eventloop.rst:1002 msgid "" -"Receive data from *sock* into the *buf* buffer. Modeled after the blocking :" -"meth:`socket.recv_into() ` method." +"Receive data from *sock* into the *buf* buffer. Modeled after the " +"blocking :meth:`socket.recv_into() ` method." msgstr "" -#: library/asyncio-eventloop.rst:996 +#: library/asyncio-eventloop.rst:1005 msgid "Return the number of bytes written to the buffer." msgstr "" -#: library/asyncio-eventloop.rst:1004 +#: library/asyncio-eventloop.rst:1013 msgid "" -"Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of :" -"meth:`socket.recvfrom() `." +"Receive a datagram of up to *bufsize* from *sock*. Asynchronous version " +"of :meth:`socket.recvfrom() `." msgstr "" -#: library/asyncio-eventloop.rst:1007 +#: library/asyncio-eventloop.rst:1016 msgid "Return a tuple of (received data, remote address)." msgstr "" -#: library/asyncio-eventloop.rst:1015 +#: library/asyncio-eventloop.rst:1024 msgid "" "Receive a datagram of up to *nbytes* from *sock* into *buf*. Asynchronous " "version of :meth:`socket.recvfrom_into() `." msgstr "" -#: library/asyncio-eventloop.rst:1019 +#: library/asyncio-eventloop.rst:1028 msgid "Return a tuple of (number of bytes received, remote address)." msgstr "" -#: library/asyncio-eventloop.rst:1027 +#: library/asyncio-eventloop.rst:1036 msgid "" -"Send *data* to the *sock* socket. Asynchronous version of :meth:`socket." -"sendall() `." +"Send *data* to the *sock* socket. Asynchronous version " +"of :meth:`socket.sendall() `." msgstr "" -#: library/asyncio-eventloop.rst:1030 +#: library/asyncio-eventloop.rst:1039 msgid "" "This method continues to send to the socket until either all data in *data* " "has been sent or an error occurs. ``None`` is returned on success. On " @@ -1284,53 +1320,53 @@ msgid "" "the connection." msgstr "" -#: library/asyncio-eventloop.rst:1038 library/asyncio-eventloop.rst:1089 +#: library/asyncio-eventloop.rst:1047 library/asyncio-eventloop.rst:1098 msgid "" "Even though the method was always documented as a coroutine method, before " "Python 3.7 it returned a :class:`Future`. Since Python 3.7, this is an " "``async def`` method." msgstr "" -#: library/asyncio-eventloop.rst:1045 +#: library/asyncio-eventloop.rst:1054 msgid "" -"Send a datagram from *sock* to *address*. Asynchronous version of :meth:" -"`socket.sendto() `." +"Send a datagram from *sock* to *address*. Asynchronous version " +"of :meth:`socket.sendto() `." msgstr "" -#: library/asyncio-eventloop.rst:1049 +#: library/asyncio-eventloop.rst:1058 msgid "Return the number of bytes sent." msgstr "" -#: library/asyncio-eventloop.rst:1057 +#: library/asyncio-eventloop.rst:1066 msgid "Connect *sock* to a remote socket at *address*." msgstr "" -#: library/asyncio-eventloop.rst:1059 +#: library/asyncio-eventloop.rst:1068 msgid "" "Asynchronous version of :meth:`socket.connect() `." msgstr "" -#: library/asyncio-eventloop.rst:1063 +#: library/asyncio-eventloop.rst:1072 msgid "" "``address`` no longer needs to be resolved. ``sock_connect`` will try to " -"check if the *address* is already resolved by calling :func:`socket." -"inet_pton`. If not, :meth:`loop.getaddrinfo` will be used to resolve the " -"*address*." +"check if the *address* is already resolved by " +"calling :func:`socket.inet_pton`. If not, :meth:`loop.getaddrinfo` will be " +"used to resolve the *address*." msgstr "" -#: library/asyncio-eventloop.rst:1072 +#: library/asyncio-eventloop.rst:1081 msgid "" ":meth:`loop.create_connection` and :func:`asyncio.open_connection() " "`." msgstr "" -#: library/asyncio-eventloop.rst:1078 +#: library/asyncio-eventloop.rst:1087 msgid "" "Accept a connection. Modeled after the blocking :meth:`socket.accept() " "` method." msgstr "" -#: library/asyncio-eventloop.rst:1081 +#: library/asyncio-eventloop.rst:1090 msgid "" "The socket must be bound to an address and listening for connections. The " "return value is a pair ``(conn, address)`` where *conn* is a *new* socket " @@ -1338,124 +1374,134 @@ msgid "" "the address bound to the socket on the other end of the connection." msgstr "" -#: library/asyncio-eventloop.rst:1096 +#: library/asyncio-eventloop.rst:1105 msgid ":meth:`loop.create_server` and :func:`start_server`." msgstr "" -#: library/asyncio-eventloop.rst:1101 +#: library/asyncio-eventloop.rst:1110 msgid "" "Send a file using high-performance :mod:`os.sendfile` if possible. Return " "the total number of bytes sent." msgstr "" -#: library/asyncio-eventloop.rst:1104 +#: library/asyncio-eventloop.rst:1113 msgid "" "Asynchronous version of :meth:`socket.sendfile() `." msgstr "" -#: library/asyncio-eventloop.rst:1106 +#: library/asyncio-eventloop.rst:1115 msgid "" -"*sock* must be a non-blocking :const:`socket.SOCK_STREAM` :class:`~socket." -"socket`." +"*sock* must be a non-" +"blocking :const:`socket.SOCK_STREAM` :class:`~socket.socket`." msgstr "" -#: library/asyncio-eventloop.rst:1109 +#: library/asyncio-eventloop.rst:1118 msgid "*file* must be a regular file object open in binary mode." msgstr "" -#: library/asyncio-eventloop.rst:1118 +#: library/asyncio-eventloop.rst:1127 msgid "" "*fallback*, when set to ``True``, makes asyncio manually read and send the " "file when the platform does not support the sendfile syscall (e.g. Windows " "or SSL socket on Unix)." msgstr "" -#: library/asyncio-eventloop.rst:1122 +#: library/asyncio-eventloop.rst:1131 msgid "" "Raise :exc:`SendfileNotAvailableError` if the system does not support " "*sendfile* syscall and *fallback* is ``False``." msgstr "" -#: library/asyncio-eventloop.rst:1131 +#: library/asyncio-eventloop.rst:1140 msgid "DNS" msgstr "" -#: library/asyncio-eventloop.rst:1136 +#: library/asyncio-eventloop.rst:1145 msgid "Asynchronous version of :meth:`socket.getaddrinfo`." msgstr "" -#: library/asyncio-eventloop.rst:1140 +#: library/asyncio-eventloop.rst:1149 msgid "Asynchronous version of :meth:`socket.getnameinfo`." msgstr "" -#: library/asyncio-eventloop.rst:1142 +#: library/asyncio-eventloop.rst:1152 +msgid "" +"Both *getaddrinfo* and *getnameinfo* internally utilize their synchronous " +"versions through the loop's default thread pool executor. When this executor " +"is saturated, these methods may experience delays, which higher-level " +"networking libraries may report as increased timeouts. To mitigate this, " +"consider using a custom executor for other user tasks, or setting a default " +"executor with a larger number of workers." +msgstr "" + +#: library/asyncio-eventloop.rst:1159 msgid "" "Both *getaddrinfo* and *getnameinfo* methods were always documented to " -"return a coroutine, but prior to Python 3.7 they were, in fact, returning :" -"class:`asyncio.Future` objects. Starting with Python 3.7 both methods are " -"coroutines." +"return a coroutine, but prior to Python 3.7 they were, in fact, " +"returning :class:`asyncio.Future` objects. Starting with Python 3.7 both " +"methods are coroutines." msgstr "" -#: library/asyncio-eventloop.rst:1150 +#: library/asyncio-eventloop.rst:1167 msgid "Working with pipes" msgstr "" -#: library/asyncio-eventloop.rst:1154 +#: library/asyncio-eventloop.rst:1171 msgid "Register the read end of *pipe* in the event loop." msgstr "" -#: library/asyncio-eventloop.rst:1159 +#: library/asyncio-eventloop.rst:1176 msgid "*pipe* is a :term:`file-like object `." msgstr "" -#: library/asyncio-eventloop.rst:1161 +#: library/asyncio-eventloop.rst:1178 msgid "" -"Return pair ``(transport, protocol)``, where *transport* supports the :class:" -"`ReadTransport` interface and *protocol* is an object instantiated by the " -"*protocol_factory*." +"Return pair ``(transport, protocol)``, where *transport* supports " +"the :class:`ReadTransport` interface and *protocol* is an object " +"instantiated by the *protocol_factory*." msgstr "" -#: library/asyncio-eventloop.rst:1165 library/asyncio-eventloop.rst:1181 +#: library/asyncio-eventloop.rst:1182 library/asyncio-eventloop.rst:1198 msgid "" "With :class:`SelectorEventLoop` event loop, the *pipe* is set to non-" "blocking mode." msgstr "" -#: library/asyncio-eventloop.rst:1170 +#: library/asyncio-eventloop.rst:1187 msgid "Register the write end of *pipe* in the event loop." msgstr "" -#: library/asyncio-eventloop.rst:1175 +#: library/asyncio-eventloop.rst:1192 msgid "*pipe* is :term:`file-like object `." msgstr "" -#: library/asyncio-eventloop.rst:1177 +#: library/asyncio-eventloop.rst:1194 msgid "" -"Return pair ``(transport, protocol)``, where *transport* supports :class:" -"`WriteTransport` interface and *protocol* is an object instantiated by the " -"*protocol_factory*." +"Return pair ``(transport, protocol)``, where *transport* " +"supports :class:`WriteTransport` interface and *protocol* is an object " +"instantiated by the *protocol_factory*." msgstr "" -#: library/asyncio-eventloop.rst:1186 +#: library/asyncio-eventloop.rst:1203 msgid "" ":class:`SelectorEventLoop` does not support the above methods on Windows. " "Use :class:`ProactorEventLoop` instead for Windows." msgstr "" -#: library/asyncio-eventloop.rst:1191 +#: library/asyncio-eventloop.rst:1208 msgid "" "The :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell` methods." msgstr "" -#: library/asyncio-eventloop.rst:1196 +#: library/asyncio-eventloop.rst:1213 msgid "Unix signals" msgstr "" -#: library/asyncio-eventloop.rst:1202 +#: library/asyncio-eventloop.rst:1219 msgid "Set *callback* as the handler for the *signum* signal." msgstr "" -#: library/asyncio-eventloop.rst:1204 +#: library/asyncio-eventloop.rst:1221 msgid "" "The callback will be invoked by *loop*, along with other queued callbacks " "and runnable coroutines of that event loop. Unlike signal handlers " @@ -1463,46 +1509,92 @@ msgid "" "function is allowed to interact with the event loop." msgstr "" -#: library/asyncio-eventloop.rst:1209 +#: library/asyncio-eventloop.rst:1226 msgid "" "Raise :exc:`ValueError` if the signal number is invalid or uncatchable. " "Raise :exc:`RuntimeError` if there is a problem setting up the handler." msgstr "" -#: library/asyncio-eventloop.rst:1215 +#: library/asyncio-eventloop.rst:1232 msgid "" "Like :func:`signal.signal`, this function must be invoked in the main thread." msgstr "" -#: library/asyncio-eventloop.rst:1220 +#: library/asyncio-eventloop.rst:1237 msgid "Remove the handler for the *sig* signal." msgstr "" -#: library/asyncio-eventloop.rst:1222 +#: library/asyncio-eventloop.rst:1239 msgid "" "Return ``True`` if the signal handler was removed, or ``False`` if no " "handler was set for the given signal." msgstr "" -#: library/asyncio-eventloop.rst:1229 +#: library/asyncio-eventloop.rst:1246 msgid "The :mod:`signal` module." msgstr "" -#: library/asyncio-eventloop.rst:1233 +#: library/asyncio-eventloop.rst:1250 msgid "Executing code in thread or process pools" msgstr "" -#: library/asyncio-eventloop.rst:1237 +#: library/asyncio-eventloop.rst:1254 msgid "Arrange for *func* to be called in the specified executor." msgstr "" -#: library/asyncio-eventloop.rst:1239 +#: library/asyncio-eventloop.rst:1256 msgid "" "The *executor* argument should be an :class:`concurrent.futures.Executor` " -"instance. The default executor is used if *executor* is ``None``." -msgstr "" - -#: library/asyncio-eventloop.rst:1284 +"instance. The default executor is used if *executor* is ``None``. The " +"default executor can be set by :meth:`loop.set_default_executor`, otherwise, " +"a :class:`concurrent.futures.ThreadPoolExecutor` will be lazy-initialized " +"and used by :func:`run_in_executor` if needed." +msgstr "" + +#: library/asyncio-eventloop.rst:1264 +msgid "" +"import asyncio\n" +"import concurrent.futures\n" +"\n" +"def blocking_io():\n" +" # File operations (such as logging) can block the\n" +" # event loop: run them in a thread pool.\n" +" with open('/dev/urandom', 'rb') as f:\n" +" return f.read(100)\n" +"\n" +"def cpu_bound():\n" +" # CPU-bound operations will block the event loop:\n" +" # in general it is preferable to run them in a\n" +" # process pool.\n" +" return sum(i * i for i in range(10 ** 7))\n" +"\n" +"async def main():\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" ## Options:\n" +"\n" +" # 1. Run in the default loop's executor:\n" +" result = await loop.run_in_executor(\n" +" None, blocking_io)\n" +" print('default thread pool', result)\n" +"\n" +" # 2. Run in a custom thread pool:\n" +" with concurrent.futures.ThreadPoolExecutor() as pool:\n" +" result = await loop.run_in_executor(\n" +" pool, blocking_io)\n" +" print('custom thread pool', result)\n" +"\n" +" # 3. Run in a custom process pool:\n" +" with concurrent.futures.ProcessPoolExecutor() as pool:\n" +" result = await loop.run_in_executor(\n" +" pool, cpu_bound)\n" +" print('custom process pool', result)\n" +"\n" +"if __name__ == '__main__':\n" +" asyncio.run(main())" +msgstr "" + +#: library/asyncio-eventloop.rst:1304 msgid "" "Note that the entry point guard (``if __name__ == '__main__'``) is required " "for option 3 due to the peculiarities of :mod:`multiprocessing`, which is " @@ -1510,17 +1602,17 @@ msgid "" "importing of main module `." msgstr "" -#: library/asyncio-eventloop.rst:1289 +#: library/asyncio-eventloop.rst:1309 msgid "This method returns a :class:`asyncio.Future` object." msgstr "" -#: library/asyncio-eventloop.rst:1291 +#: library/asyncio-eventloop.rst:1311 msgid "" "Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *func*." msgstr "" -#: library/asyncio-eventloop.rst:1294 +#: library/asyncio-eventloop.rst:1314 msgid "" ":meth:`loop.run_in_executor` no longer configures the ``max_workers`` of the " "thread pool executor it creates, instead leaving it up to the thread pool " @@ -1528,32 +1620,32 @@ msgid "" "default." msgstr "" -#: library/asyncio-eventloop.rst:1303 +#: library/asyncio-eventloop.rst:1323 msgid "" "Set *executor* as the default executor used by :meth:`run_in_executor`. " -"*executor* must be an instance of :class:`~concurrent.futures." -"ThreadPoolExecutor`." +"*executor* must be an instance " +"of :class:`~concurrent.futures.ThreadPoolExecutor`." msgstr "" -#: library/asyncio-eventloop.rst:1307 +#: library/asyncio-eventloop.rst:1327 msgid "" -"*executor* must be an instance of :class:`~concurrent.futures." -"ThreadPoolExecutor`." +"*executor* must be an instance " +"of :class:`~concurrent.futures.ThreadPoolExecutor`." msgstr "" -#: library/asyncio-eventloop.rst:1313 +#: library/asyncio-eventloop.rst:1333 msgid "Error Handling API" msgstr "" -#: library/asyncio-eventloop.rst:1315 +#: library/asyncio-eventloop.rst:1335 msgid "Allows customizing how exceptions are handled in the event loop." msgstr "" -#: library/asyncio-eventloop.rst:1319 +#: library/asyncio-eventloop.rst:1339 msgid "Set *handler* as the new event loop exception handler." msgstr "" -#: library/asyncio-eventloop.rst:1321 +#: library/asyncio-eventloop.rst:1341 msgid "" "If *handler* is ``None``, the default exception handler will be set. " "Otherwise, *handler* must be a callable with the signature matching ``(loop, " @@ -1562,182 +1654,184 @@ msgid "" "(see :meth:`call_exception_handler` documentation for details about context)." msgstr "" -#: library/asyncio-eventloop.rst:1329 +#: library/asyncio-eventloop.rst:1349 msgid "" -"If the handler is called on behalf of a :class:`~asyncio.Task` or :class:" -"`~asyncio.Handle`, it is run in the :class:`contextvars.Context` of that " -"task or callback handle." +"If the handler is called on behalf of a :class:`~asyncio.Task` " +"or :class:`~asyncio.Handle`, it is run in the :class:`contextvars.Context` " +"of that task or callback handle." msgstr "" -#: library/asyncio-eventloop.rst:1335 +#: library/asyncio-eventloop.rst:1355 msgid "" "The handler may be called in the :class:`~contextvars.Context` of the task " "or handle where the exception originated." msgstr "" -#: library/asyncio-eventloop.rst:1340 +#: library/asyncio-eventloop.rst:1360 msgid "" "Return the current exception handler, or ``None`` if no custom exception " "handler was set." msgstr "" -#: library/asyncio-eventloop.rst:1347 +#: library/asyncio-eventloop.rst:1367 msgid "Default exception handler." msgstr "" -#: library/asyncio-eventloop.rst:1349 +#: library/asyncio-eventloop.rst:1369 msgid "" "This is called when an exception occurs and no exception handler is set. " "This can be called by a custom exception handler that wants to defer to the " "default handler behavior." msgstr "" -#: library/asyncio-eventloop.rst:1353 +#: library/asyncio-eventloop.rst:1373 msgid "" -"*context* parameter has the same meaning as in :meth:" -"`call_exception_handler`." +"*context* parameter has the same meaning as " +"in :meth:`call_exception_handler`." msgstr "" -#: library/asyncio-eventloop.rst:1358 +#: library/asyncio-eventloop.rst:1378 msgid "Call the current event loop exception handler." msgstr "" -#: library/asyncio-eventloop.rst:1360 +#: library/asyncio-eventloop.rst:1380 msgid "" "*context* is a ``dict`` object containing the following keys (new keys may " "be introduced in future Python versions):" msgstr "" -#: library/asyncio-eventloop.rst:1363 +#: library/asyncio-eventloop.rst:1383 msgid "'message': Error message;" msgstr "" -#: library/asyncio-eventloop.rst:1364 +#: library/asyncio-eventloop.rst:1384 msgid "'exception' (optional): Exception object;" msgstr "" -#: library/asyncio-eventloop.rst:1365 +#: library/asyncio-eventloop.rst:1385 msgid "'future' (optional): :class:`asyncio.Future` instance;" msgstr "" -#: library/asyncio-eventloop.rst:1366 +#: library/asyncio-eventloop.rst:1386 msgid "'task' (optional): :class:`asyncio.Task` instance;" msgstr "" -#: library/asyncio-eventloop.rst:1367 +#: library/asyncio-eventloop.rst:1387 msgid "'handle' (optional): :class:`asyncio.Handle` instance;" msgstr "" -#: library/asyncio-eventloop.rst:1368 +#: library/asyncio-eventloop.rst:1388 msgid "'protocol' (optional): :ref:`Protocol ` instance;" msgstr "" -#: library/asyncio-eventloop.rst:1369 +#: library/asyncio-eventloop.rst:1389 msgid "'transport' (optional): :ref:`Transport ` instance;" msgstr "" -#: library/asyncio-eventloop.rst:1370 +#: library/asyncio-eventloop.rst:1390 msgid "'socket' (optional): :class:`socket.socket` instance;" msgstr "" -#: library/asyncio-eventloop.rst:1372 +#: library/asyncio-eventloop.rst:1391 msgid "'asyncgen' (optional): Asynchronous generator that caused" msgstr "" -#: library/asyncio-eventloop.rst:1372 +#: library/asyncio-eventloop.rst:1392 msgid "the exception." msgstr "" -#: library/asyncio-eventloop.rst:1376 +#: library/asyncio-eventloop.rst:1396 msgid "" "This method should not be overloaded in subclassed event loops. For custom " -"exception handling, use the :meth:`set_exception_handler()` method." +"exception handling, use the :meth:`set_exception_handler` method." msgstr "" -#: library/asyncio-eventloop.rst:1381 +#: library/asyncio-eventloop.rst:1401 msgid "Enabling debug mode" msgstr "" -#: library/asyncio-eventloop.rst:1385 +#: library/asyncio-eventloop.rst:1405 msgid "Get the debug mode (:class:`bool`) of the event loop." msgstr "" -#: library/asyncio-eventloop.rst:1387 +#: library/asyncio-eventloop.rst:1407 msgid "" -"The default value is ``True`` if the environment variable :envvar:" -"`PYTHONASYNCIODEBUG` is set to a non-empty string, ``False`` otherwise." +"The default value is ``True`` if the environment " +"variable :envvar:`PYTHONASYNCIODEBUG` is set to a non-empty string, " +"``False`` otherwise." msgstr "" -#: library/asyncio-eventloop.rst:1393 +#: library/asyncio-eventloop.rst:1413 msgid "Set the debug mode of the event loop." msgstr "" -#: library/asyncio-eventloop.rst:1397 +#: library/asyncio-eventloop.rst:1417 msgid "" "The new :ref:`Python Development Mode ` can now also be used to " "enable the debug mode." msgstr "" -#: library/asyncio-eventloop.rst:1402 +#: library/asyncio-eventloop.rst:1422 msgid "" "This attribute can be used to set the minimum execution duration in seconds " "that is considered \"slow\". When debug mode is enabled, \"slow\" callbacks " "are logged." msgstr "" -#: library/asyncio-eventloop.rst:1406 +#: library/asyncio-eventloop.rst:1426 msgid "Default value is 100 milliseconds." msgstr "" -#: library/asyncio-eventloop.rst:1410 +#: library/asyncio-eventloop.rst:1430 msgid "The :ref:`debug mode of asyncio `." msgstr "" -#: library/asyncio-eventloop.rst:1414 +#: library/asyncio-eventloop.rst:1434 msgid "Running Subprocesses" msgstr "" -#: library/asyncio-eventloop.rst:1416 +#: library/asyncio-eventloop.rst:1436 msgid "" "Methods described in this subsections are low-level. In regular async/await " "code consider using the high-level :func:`asyncio.create_subprocess_shell` " "and :func:`asyncio.create_subprocess_exec` convenience functions instead." msgstr "" -#: library/asyncio-eventloop.rst:1423 +#: library/asyncio-eventloop.rst:1443 msgid "" "On Windows, the default event loop :class:`ProactorEventLoop` supports " -"subprocesses, whereas :class:`SelectorEventLoop` does not. See :ref:" -"`Subprocess Support on Windows ` for details." +"subprocesses, whereas :class:`SelectorEventLoop` does not. " +"See :ref:`Subprocess Support on Windows ` for " +"details." msgstr "" -#: library/asyncio-eventloop.rst:1434 +#: library/asyncio-eventloop.rst:1454 msgid "" "Create a subprocess from one or more string arguments specified by *args*." msgstr "" -#: library/asyncio-eventloop.rst:1437 +#: library/asyncio-eventloop.rst:1457 msgid "*args* must be a list of strings represented by:" msgstr "" -#: library/asyncio-eventloop.rst:1439 +#: library/asyncio-eventloop.rst:1459 msgid ":class:`str`;" msgstr "" -#: library/asyncio-eventloop.rst:1440 +#: library/asyncio-eventloop.rst:1460 msgid "" "or :class:`bytes`, encoded to the :ref:`filesystem encoding `." msgstr "" -#: library/asyncio-eventloop.rst:1443 +#: library/asyncio-eventloop.rst:1463 msgid "" "The first string specifies the program executable, and the remaining strings " "specify the arguments. Together, string arguments form the ``argv`` of the " "program." msgstr "" -#: library/asyncio-eventloop.rst:1447 +#: library/asyncio-eventloop.rst:1467 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=False`` and the list of strings passed as the first " @@ -1745,134 +1839,134 @@ msgid "" "which is list of strings, *subprocess_exec* takes multiple string arguments." msgstr "" -#: library/asyncio-eventloop.rst:1453 +#: library/asyncio-eventloop.rst:1473 msgid "" -"The *protocol_factory* must be a callable returning a subclass of the :class:" -"`asyncio.SubprocessProtocol` class." +"The *protocol_factory* must be a callable returning a subclass of " +"the :class:`asyncio.SubprocessProtocol` class." msgstr "" -#: library/asyncio-eventloop.rst:1456 +#: library/asyncio-eventloop.rst:1476 msgid "Other parameters:" msgstr "" -#: library/asyncio-eventloop.rst:1458 +#: library/asyncio-eventloop.rst:1478 msgid "*stdin* can be any of these:" msgstr "" -#: library/asyncio-eventloop.rst:1460 library/asyncio-eventloop.rst:1471 -#: library/asyncio-eventloop.rst:1481 +#: library/asyncio-eventloop.rst:1480 library/asyncio-eventloop.rst:1491 +#: library/asyncio-eventloop.rst:1501 msgid "a file-like object" msgstr "" -#: library/asyncio-eventloop.rst:1461 +#: library/asyncio-eventloop.rst:1481 msgid "" "an existing file descriptor (a positive integer), for example those created " -"with :meth:`os.pipe()`" +"with :meth:`os.pipe`" msgstr "" -#: library/asyncio-eventloop.rst:1462 library/asyncio-eventloop.rst:1472 -#: library/asyncio-eventloop.rst:1482 +#: library/asyncio-eventloop.rst:1482 library/asyncio-eventloop.rst:1492 +#: library/asyncio-eventloop.rst:1502 msgid "" "the :const:`subprocess.PIPE` constant (default) which will create a new pipe " "and connect it," msgstr "" -#: library/asyncio-eventloop.rst:1464 library/asyncio-eventloop.rst:1474 -#: library/asyncio-eventloop.rst:1484 +#: library/asyncio-eventloop.rst:1484 library/asyncio-eventloop.rst:1494 +#: library/asyncio-eventloop.rst:1504 msgid "" "the value ``None`` which will make the subprocess inherit the file " "descriptor from this process" msgstr "" -#: library/asyncio-eventloop.rst:1466 library/asyncio-eventloop.rst:1476 -#: library/asyncio-eventloop.rst:1486 +#: library/asyncio-eventloop.rst:1486 library/asyncio-eventloop.rst:1496 +#: library/asyncio-eventloop.rst:1506 msgid "" -"the :const:`subprocess.DEVNULL` constant which indicates that the special :" -"data:`os.devnull` file will be used" +"the :const:`subprocess.DEVNULL` constant which indicates that the " +"special :data:`os.devnull` file will be used" msgstr "" -#: library/asyncio-eventloop.rst:1469 +#: library/asyncio-eventloop.rst:1489 msgid "*stdout* can be any of these:" msgstr "" -#: library/asyncio-eventloop.rst:1479 +#: library/asyncio-eventloop.rst:1499 msgid "*stderr* can be any of these:" msgstr "" -#: library/asyncio-eventloop.rst:1488 +#: library/asyncio-eventloop.rst:1508 msgid "" "the :const:`subprocess.STDOUT` constant which will connect the standard " "error stream to the process' standard output stream" msgstr "" -#: library/asyncio-eventloop.rst:1491 +#: library/asyncio-eventloop.rst:1511 msgid "" "All other keyword arguments are passed to :class:`subprocess.Popen` without " "interpretation, except for *bufsize*, *universal_newlines*, *shell*, *text*, " "*encoding* and *errors*, which should not be specified at all." msgstr "" -#: library/asyncio-eventloop.rst:1496 +#: library/asyncio-eventloop.rst:1516 msgid "" "The ``asyncio`` subprocess API does not support decoding the streams as " "text. :func:`bytes.decode` can be used to convert the bytes returned from " "the stream to text." msgstr "" -#: library/asyncio-eventloop.rst:1500 +#: library/asyncio-eventloop.rst:1520 msgid "" "If a file-like object passed as *stdin*, *stdout* or *stderr* represents a " -"pipe, then the other side of this pipe should be registered with :meth:" -"`~loop.connect_write_pipe` or :meth:`~loop.connect_read_pipe` for use with " -"the event loop." +"pipe, then the other side of this pipe should be registered " +"with :meth:`~loop.connect_write_pipe` or :meth:`~loop.connect_read_pipe` for " +"use with the event loop." msgstr "" -#: library/asyncio-eventloop.rst:1505 +#: library/asyncio-eventloop.rst:1525 msgid "" "See the constructor of the :class:`subprocess.Popen` class for documentation " "on other arguments." msgstr "" -#: library/asyncio-eventloop.rst:1508 +#: library/asyncio-eventloop.rst:1528 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`asyncio.SubprocessTransport` base class and *protocol* is an " "object instantiated by the *protocol_factory*." msgstr "" -#: library/asyncio-eventloop.rst:1516 +#: library/asyncio-eventloop.rst:1536 msgid "" -"Create a subprocess from *cmd*, which can be a :class:`str` or a :class:" -"`bytes` string encoded to the :ref:`filesystem encoding `, using the platform's \"shell\" syntax." msgstr "" -#: library/asyncio-eventloop.rst:1521 +#: library/asyncio-eventloop.rst:1541 msgid "" "This is similar to the standard library :class:`subprocess.Popen` class " "called with ``shell=True``." msgstr "" -#: library/asyncio-eventloop.rst:1524 +#: library/asyncio-eventloop.rst:1544 msgid "" -"The *protocol_factory* must be a callable returning a subclass of the :class:" -"`SubprocessProtocol` class." +"The *protocol_factory* must be a callable returning a subclass of " +"the :class:`SubprocessProtocol` class." msgstr "" -#: library/asyncio-eventloop.rst:1527 +#: library/asyncio-eventloop.rst:1547 msgid "" "See :meth:`~loop.subprocess_exec` for more details about the remaining " "arguments." msgstr "" -#: library/asyncio-eventloop.rst:1530 +#: library/asyncio-eventloop.rst:1550 msgid "" "Returns a pair of ``(transport, protocol)``, where *transport* conforms to " "the :class:`SubprocessTransport` base class and *protocol* is an object " "instantiated by the *protocol_factory*." msgstr "" -#: library/asyncio-eventloop.rst:1535 +#: library/asyncio-eventloop.rst:1555 msgid "" "It is the application's responsibility to ensure that all whitespace and " "special characters are quoted appropriately to avoid `shell injection " @@ -1882,116 +1976,126 @@ msgid "" "used to construct shell commands." msgstr "" -#: library/asyncio-eventloop.rst:1544 +#: library/asyncio-eventloop.rst:1564 msgid "Callback Handles" msgstr "" -#: library/asyncio-eventloop.rst:1548 +#: library/asyncio-eventloop.rst:1568 msgid "" -"A callback wrapper object returned by :meth:`loop.call_soon`, :meth:`loop." -"call_soon_threadsafe`." +"A callback wrapper object returned " +"by :meth:`loop.call_soon`, :meth:`loop.call_soon_threadsafe`." msgstr "" -#: library/asyncio-eventloop.rst:1553 +#: library/asyncio-eventloop.rst:1573 msgid "" "Return the :class:`contextvars.Context` object associated with the handle." msgstr "" -#: library/asyncio-eventloop.rst:1560 +#: library/asyncio-eventloop.rst:1580 msgid "" "Cancel the callback. If the callback has already been canceled or executed, " "this method has no effect." msgstr "" -#: library/asyncio-eventloop.rst:1565 +#: library/asyncio-eventloop.rst:1585 msgid "Return ``True`` if the callback was cancelled." msgstr "" -#: library/asyncio-eventloop.rst:1571 +#: library/asyncio-eventloop.rst:1591 msgid "" -"A callback wrapper object returned by :meth:`loop.call_later`, and :meth:" -"`loop.call_at`." +"A callback wrapper object returned by :meth:`loop.call_later`, " +"and :meth:`loop.call_at`." msgstr "" -#: library/asyncio-eventloop.rst:1574 +#: library/asyncio-eventloop.rst:1594 msgid "This class is a subclass of :class:`Handle`." msgstr "" -#: library/asyncio-eventloop.rst:1578 +#: library/asyncio-eventloop.rst:1598 msgid "Return a scheduled callback time as :class:`float` seconds." msgstr "" -#: library/asyncio-eventloop.rst:1580 +#: library/asyncio-eventloop.rst:1600 msgid "" -"The time is an absolute timestamp, using the same time reference as :meth:" -"`loop.time`." +"The time is an absolute timestamp, using the same time reference " +"as :meth:`loop.time`." msgstr "" -#: library/asyncio-eventloop.rst:1587 +#: library/asyncio-eventloop.rst:1607 msgid "Server Objects" msgstr "" -#: library/asyncio-eventloop.rst:1589 +#: library/asyncio-eventloop.rst:1609 msgid "" -"Server objects are created by :meth:`loop.create_server`, :meth:`loop." -"create_unix_server`, :func:`start_server`, and :func:`start_unix_server` " -"functions." +"Server objects are created " +"by :meth:`loop.create_server`, :meth:`loop.create_unix_server`, :func:`start_server`, " +"and :func:`start_unix_server` functions." msgstr "" -#: library/asyncio-eventloop.rst:1593 +#: library/asyncio-eventloop.rst:1613 msgid "Do not instantiate the :class:`Server` class directly." msgstr "" -#: library/asyncio-eventloop.rst:1597 +#: library/asyncio-eventloop.rst:1617 msgid "" "*Server* objects are asynchronous context managers. When used in an ``async " "with`` statement, it's guaranteed that the Server object is closed and not " "accepting new connections when the ``async with`` statement is completed::" msgstr "" -#: library/asyncio-eventloop.rst:1610 +#: library/asyncio-eventloop.rst:1622 +msgid "" +"srv = await loop.create_server(...)\n" +"\n" +"async with srv:\n" +" # some code\n" +"\n" +"# At this point, srv is closed and no longer accepts new connections." +msgstr "" + +#: library/asyncio-eventloop.rst:1630 msgid "Server object is an asynchronous context manager since Python 3.7." msgstr "" -#: library/asyncio-eventloop.rst:1613 +#: library/asyncio-eventloop.rst:1633 msgid "" "This class was exposed publicly as ``asyncio.Server`` in Python 3.9.11, " "3.10.3 and 3.11." msgstr "" -#: library/asyncio-eventloop.rst:1618 +#: library/asyncio-eventloop.rst:1638 msgid "" "Stop serving: close listening sockets and set the :attr:`sockets` attribute " "to ``None``." msgstr "" -#: library/asyncio-eventloop.rst:1621 +#: library/asyncio-eventloop.rst:1641 msgid "" "The sockets that represent existing incoming client connections are left " "open." msgstr "" -#: library/asyncio-eventloop.rst:1624 +#: library/asyncio-eventloop.rst:1644 msgid "" "The server is closed asynchronously; use the :meth:`wait_closed` coroutine " "to wait until the server is closed (and no more connections are active)." msgstr "" -#: library/asyncio-eventloop.rst:1630 +#: library/asyncio-eventloop.rst:1650 msgid "Return the event loop associated with the server object." msgstr "" -#: library/asyncio-eventloop.rst:1636 +#: library/asyncio-eventloop.rst:1656 msgid "Start accepting connections." msgstr "" -#: library/asyncio-eventloop.rst:1638 +#: library/asyncio-eventloop.rst:1658 msgid "" "This method is idempotent, so it can be called when the server is already " "serving." msgstr "" -#: library/asyncio-eventloop.rst:1641 +#: library/asyncio-eventloop.rst:1661 msgid "" "The *start_serving* keyword-only parameter to :meth:`loop.create_server` " "and :meth:`asyncio.start_server` allows creating a Server object that is not " @@ -2000,112 +2104,133 @@ msgid "" "accepting connections." msgstr "" -#: library/asyncio-eventloop.rst:1652 +#: library/asyncio-eventloop.rst:1672 msgid "" "Start accepting connections until the coroutine is cancelled. Cancellation " "of ``serve_forever`` task causes the server to be closed." msgstr "" -#: library/asyncio-eventloop.rst:1656 +#: library/asyncio-eventloop.rst:1676 msgid "" "This method can be called if the server is already accepting connections. " "Only one ``serve_forever`` task can exist per one *Server* object." msgstr "" -#: library/asyncio-eventloop.rst:1678 +#: library/asyncio-eventloop.rst:1682 +msgid "" +"async def client_connected(reader, writer):\n" +" # Communicate with the client with\n" +" # reader/writer streams. For example:\n" +" await reader.readline()\n" +"\n" +"async def main(host, port):\n" +" srv = await asyncio.start_server(\n" +" client_connected, host, port)\n" +" await srv.serve_forever()\n" +"\n" +"asyncio.run(main('127.0.0.1', 0))" +msgstr "" + +#: library/asyncio-eventloop.rst:1698 msgid "Return ``True`` if the server is accepting new connections." msgstr "" -#: library/asyncio-eventloop.rst:1684 +#: library/asyncio-eventloop.rst:1704 msgid "" "Wait until the :meth:`close` method completes and all active connections " "have finished." msgstr "" -#: library/asyncio-eventloop.rst:1689 +#: library/asyncio-eventloop.rst:1709 msgid "" "List of socket-like objects, ``asyncio.trsock.TransportSocket``, which the " "server is listening on." msgstr "" -#: library/asyncio-eventloop.rst:1692 +#: library/asyncio-eventloop.rst:1712 msgid "" "Prior to Python 3.7 ``Server.sockets`` used to return an internal list of " "server sockets directly. In 3.7 a copy of that list is returned." msgstr "" -#: library/asyncio-eventloop.rst:1702 +#: library/asyncio-eventloop.rst:1722 msgid "Event Loop Implementations" msgstr "" -#: library/asyncio-eventloop.rst:1704 +#: library/asyncio-eventloop.rst:1724 msgid "" -"asyncio ships with two different event loop implementations: :class:" -"`SelectorEventLoop` and :class:`ProactorEventLoop`." +"asyncio ships with two different event loop " +"implementations: :class:`SelectorEventLoop` and :class:`ProactorEventLoop`." msgstr "" -#: library/asyncio-eventloop.rst:1707 +#: library/asyncio-eventloop.rst:1727 msgid "" "By default asyncio is configured to use :class:`SelectorEventLoop` on Unix " "and :class:`ProactorEventLoop` on Windows." msgstr "" -#: library/asyncio-eventloop.rst:1713 +#: library/asyncio-eventloop.rst:1733 msgid "An event loop based on the :mod:`selectors` module." msgstr "" -#: library/asyncio-eventloop.rst:1715 +#: library/asyncio-eventloop.rst:1735 msgid "" "Uses the most efficient *selector* available for the given platform. It is " "also possible to manually configure the exact selector implementation to be " "used::" msgstr "" -#: library/asyncio-eventloop.rst:1730 -msgid ":ref:`Availability `: Unix, Windows." +#: library/asyncio-eventloop.rst:1739 +msgid "" +"import asyncio\n" +"import selectors\n" +"\n" +"class MyPolicy(asyncio.DefaultEventLoopPolicy):\n" +" def new_event_loop(self):\n" +" selector = selectors.SelectSelector()\n" +" return asyncio.SelectorEventLoop(selector)\n" +"\n" +"asyncio.set_event_loop_policy(MyPolicy())" msgstr "" -#: library/asyncio-eventloop.rst:1735 +#: library/asyncio-eventloop.rst:1755 msgid "An event loop for Windows that uses \"I/O Completion Ports\" (IOCP)." msgstr "" -#: library/asyncio-eventloop.rst:1737 -msgid ":ref:`Availability `: Windows." -msgstr "" - -#: library/asyncio-eventloop.rst:1741 +#: library/asyncio-eventloop.rst:1761 msgid "" -"`MSDN documentation on I/O Completion Ports `_." +"`MSDN documentation on I/O Completion Ports `_." msgstr "" -#: library/asyncio-eventloop.rst:1747 +#: library/asyncio-eventloop.rst:1767 msgid "Abstract base class for asyncio-compliant event loops." msgstr "" -#: library/asyncio-eventloop.rst:1749 +#: library/asyncio-eventloop.rst:1769 msgid "" "The :ref:`asyncio-event-loop-methods` section lists all methods that an " "alternative implementation of ``AbstractEventLoop`` should have defined." msgstr "" -#: library/asyncio-eventloop.rst:1755 +#: library/asyncio-eventloop.rst:1775 msgid "Examples" msgstr "" -#: library/asyncio-eventloop.rst:1757 +#: library/asyncio-eventloop.rst:1777 msgid "" "Note that all examples in this section **purposefully** show how to use the " -"low-level event loop APIs, such as :meth:`loop.run_forever` and :meth:`loop." -"call_soon`. Modern asyncio applications rarely need to be written this way; " -"consider using the high-level functions like :func:`asyncio.run`." +"low-level event loop APIs, such as :meth:`loop.run_forever` " +"and :meth:`loop.call_soon`. Modern asyncio applications rarely need to be " +"written this way; consider using the high-level functions " +"like :func:`asyncio.run`." msgstr "" -#: library/asyncio-eventloop.rst:1767 +#: library/asyncio-eventloop.rst:1787 msgid "Hello World with call_soon()" msgstr "" -#: library/asyncio-eventloop.rst:1769 +#: library/asyncio-eventloop.rst:1789 msgid "" "An example using the :meth:`loop.call_soon` method to schedule a callback. " "The callback displays ``\"Hello World\"`` and then stops the event loop::" @@ -2113,59 +2238,169 @@ msgstr "" #: library/asyncio-eventloop.rst:1793 msgid "" +"import asyncio\n" +"\n" +"def hello_world(loop):\n" +" \"\"\"A callback to print 'Hello World' and stop the event loop\"\"\"\n" +" print('Hello World')\n" +" loop.stop()\n" +"\n" +"loop = asyncio.new_event_loop()\n" +"\n" +"# Schedule a call to hello_world()\n" +"loop.call_soon(hello_world, loop)\n" +"\n" +"# Blocking call interrupted by loop.stop()\n" +"try:\n" +" loop.run_forever()\n" +"finally:\n" +" loop.close()" +msgstr "" + +#: library/asyncio-eventloop.rst:1813 +msgid "" "A similar :ref:`Hello World ` example created with a coroutine " "and the :func:`run` function." msgstr "" -#: library/asyncio-eventloop.rst:1800 +#: library/asyncio-eventloop.rst:1820 msgid "Display the current date with call_later()" msgstr "" -#: library/asyncio-eventloop.rst:1802 +#: library/asyncio-eventloop.rst:1822 msgid "" "An example of a callback displaying the current date every second. The " "callback uses the :meth:`loop.call_later` method to reschedule itself after " "5 seconds, and then stops the event loop::" msgstr "" -#: library/asyncio-eventloop.rst:1830 +#: library/asyncio-eventloop.rst:1826 +msgid "" +"import asyncio\n" +"import datetime\n" +"\n" +"def display_date(end_time, loop):\n" +" print(datetime.datetime.now())\n" +" if (loop.time() + 1.0) < end_time:\n" +" loop.call_later(1, display_date, end_time, loop)\n" +" else:\n" +" loop.stop()\n" +"\n" +"loop = asyncio.new_event_loop()\n" +"\n" +"# Schedule the first call to display_date()\n" +"end_time = loop.time() + 5.0\n" +"loop.call_soon(display_date, end_time, loop)\n" +"\n" +"# Blocking call interrupted by loop.stop()\n" +"try:\n" +" loop.run_forever()\n" +"finally:\n" +" loop.close()" +msgstr "" + +#: library/asyncio-eventloop.rst:1850 msgid "" "A similar :ref:`current date ` example created with a " "coroutine and the :func:`run` function." msgstr "" -#: library/asyncio-eventloop.rst:1837 +#: library/asyncio-eventloop.rst:1857 msgid "Watch a file descriptor for read events" msgstr "" -#: library/asyncio-eventloop.rst:1839 -msgid "" -"Wait until a file descriptor received some data using the :meth:`loop." -"add_reader` method and then close the event loop::" -msgstr "" - -#: library/asyncio-eventloop.rst:1877 +#: library/asyncio-eventloop.rst:1859 +msgid "" +"Wait until a file descriptor received some data using " +"the :meth:`loop.add_reader` method and then close the event loop::" +msgstr "" + +#: library/asyncio-eventloop.rst:1862 +msgid "" +"import asyncio\n" +"from socket import socketpair\n" +"\n" +"# Create a pair of connected file descriptors\n" +"rsock, wsock = socketpair()\n" +"\n" +"loop = asyncio.new_event_loop()\n" +"\n" +"def reader():\n" +" data = rsock.recv(100)\n" +" print(\"Received:\", data.decode())\n" +"\n" +" # We are done: unregister the file descriptor\n" +" loop.remove_reader(rsock)\n" +"\n" +" # Stop the event loop\n" +" loop.stop()\n" +"\n" +"# Register the file descriptor for read event\n" +"loop.add_reader(rsock, reader)\n" +"\n" +"# Simulate the reception of data from the network\n" +"loop.call_soon(wsock.send, 'abc'.encode())\n" +"\n" +"try:\n" +" # Run the event loop\n" +" loop.run_forever()\n" +"finally:\n" +" # We are done. Close sockets and the event loop.\n" +" rsock.close()\n" +" wsock.close()\n" +" loop.close()" +msgstr "" + +#: library/asyncio-eventloop.rst:1897 msgid "" "A similar :ref:`example ` using " "transports, protocols, and the :meth:`loop.create_connection` method." msgstr "" -#: library/asyncio-eventloop.rst:1881 +#: library/asyncio-eventloop.rst:1901 msgid "" "Another similar :ref:`example ` " "using the high-level :func:`asyncio.open_connection` function and streams." msgstr "" -#: library/asyncio-eventloop.rst:1889 +#: library/asyncio-eventloop.rst:1909 msgid "Set signal handlers for SIGINT and SIGTERM" msgstr "" -#: library/asyncio-eventloop.rst:1891 +#: library/asyncio-eventloop.rst:1911 msgid "(This ``signals`` example only works on Unix.)" msgstr "" -#: library/asyncio-eventloop.rst:1893 -msgid "" -"Register handlers for signals :const:`~signal.SIGINT` and :const:`~signal." -"SIGTERM` using the :meth:`loop.add_signal_handler` method::" +#: library/asyncio-eventloop.rst:1913 +msgid "" +"Register handlers for signals :const:`~signal.SIGINT` " +"and :const:`~signal.SIGTERM` using the :meth:`loop.add_signal_handler` " +"method::" +msgstr "" + +#: library/asyncio-eventloop.rst:1916 +msgid "" +"import asyncio\n" +"import functools\n" +"import os\n" +"import signal\n" +"\n" +"def ask_exit(signame, loop):\n" +" print(\"got signal %s: exit\" % signame)\n" +" loop.stop()\n" +"\n" +"async def main():\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" for signame in {'SIGINT', 'SIGTERM'}:\n" +" loop.add_signal_handler(\n" +" getattr(signal, signame),\n" +" functools.partial(ask_exit, signame, loop))\n" +"\n" +" await asyncio.sleep(3600)\n" +"\n" +"print(\"Event loop running for 1 hour, press Ctrl+C to interrupt.\")\n" +"print(f\"pid {os.getpid()}: send SIGINT or SIGTERM to exit.\")\n" +"\n" +"asyncio.run(main())" msgstr "" diff --git a/library/asyncio-exceptions.po b/library/asyncio-exceptions.po index 6beed70f..bd7e4ece 100644 --- a/library/asyncio-exceptions.po +++ b/library/asyncio-exceptions.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/asyncio-extending.po b/library/asyncio-extending.po index a6f04f25..25068365 100644 --- a/library/asyncio-extending.po +++ b/library/asyncio-extending.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -69,8 +70,9 @@ msgstr "" #: library/asyncio-extending.rst:40 msgid "" ":class:`asyncio.Future` and :class:`asyncio.Task` should be never created " -"directly, please use corresponding :meth:`loop.create_future` and :meth:" -"`loop.create_task`, or :func:`asyncio.create_task` factories instead." +"directly, please use corresponding :meth:`loop.create_future` " +"and :meth:`loop.create_task`, or :func:`asyncio.create_task` factories " +"instead." msgstr "" #: library/asyncio-extending.rst:44 @@ -113,8 +115,8 @@ msgstr "" #: library/asyncio-extending.rst:71 msgid "" "A third party task implementation should call the following functions to " -"keep a task visible by :func:`asyncio.all_tasks` and :func:`asyncio." -"current_task`:" +"keep a task visible by :func:`asyncio.all_tasks` " +"and :func:`asyncio.current_task`:" msgstr "" #: library/asyncio-extending.rst:76 @@ -139,8 +141,8 @@ msgstr "" #: library/asyncio-extending.rst:90 msgid "" -"Call the function just before executing a portion of embedded *coroutine* (:" -"meth:`coroutine.send` or :meth:`coroutine.throw`)." +"Call the function just before executing a portion of embedded *coroutine* " +"(:meth:`coroutine.send` or :meth:`coroutine.throw`)." msgstr "" #: library/asyncio-extending.rst:95 @@ -149,6 +151,6 @@ msgstr "" #: library/asyncio-extending.rst:97 msgid "" -"Call the function just after :meth:`coroutine.send` or :meth:`coroutine." -"throw` execution." +"Call the function just after :meth:`coroutine.send` " +"or :meth:`coroutine.throw` execution." msgstr "" diff --git a/library/asyncio-future.po b/library/asyncio-future.po index bababb9a..355ce340 100644 --- a/library/asyncio-future.po +++ b/library/asyncio-future.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -64,15 +65,15 @@ msgstr "" #: library/asyncio-future.rst:42 msgid "" -"a :class:`Task` object wrapping *obj*, if *obj* is a coroutine (:func:" -"`iscoroutine` is used for the test); in this case the coroutine will be " -"scheduled by ``ensure_future()``." +"a :class:`Task` object wrapping *obj*, if *obj* is a coroutine " +"(:func:`iscoroutine` is used for the test); in this case the coroutine will " +"be scheduled by ``ensure_future()``." msgstr "" #: library/asyncio-future.rst:47 msgid "" -"a :class:`Task` object that would await on *obj*, if *obj* is an awaitable (:" -"func:`inspect.isawaitable` is used for the test.)" +"a :class:`Task` object that would await on *obj*, if *obj* is an awaitable " +"(:func:`inspect.isawaitable` is used for the test.)" msgstr "" #: library/asyncio-future.rst:50 @@ -103,8 +104,8 @@ msgstr "" #: library/asyncio-future.rst:70 msgid "" -"Wrap a :class:`concurrent.futures.Future` object in a :class:`asyncio." -"Future` object." +"Wrap a :class:`concurrent.futures.Future` object in " +"a :class:`asyncio.Future` object." msgstr "" #: library/asyncio-future.rst:73 @@ -140,9 +141,10 @@ msgstr "" #: library/asyncio-future.rst:96 msgid "" "The rule of thumb is to never expose Future objects in user-facing APIs, and " -"the recommended way to create a Future object is to call :meth:`loop." -"create_future`. This way alternative event loop implementations can inject " -"their own optimized implementations of a Future object." +"the recommended way to create a Future object is to " +"call :meth:`loop.create_future`. This way alternative event loop " +"implementations can inject their own optimized implementations of a Future " +"object." msgstr "" #: library/asyncio-future.rst:102 @@ -167,20 +169,20 @@ msgstr "" #: library/asyncio-future.rst:116 msgid "" -"If the Future is *done* and has an exception set by the :meth:" -"`set_exception` method, this method raises the exception." +"If the Future is *done* and has an exception set by " +"the :meth:`set_exception` method, this method raises the exception." msgstr "" #: library/asyncio-future.rst:207 msgid "" -"If the Future has been *cancelled*, this method raises a :exc:" -"`CancelledError` exception." +"If the Future has been *cancelled*, this method raises " +"a :exc:`CancelledError` exception." msgstr "" #: library/asyncio-future.rst:122 msgid "" -"If the Future's result isn't yet available, this method raises a :exc:" -"`InvalidStateError` exception." +"If the Future's result isn't yet available, this method raises " +"an :exc:`InvalidStateError` exception." msgstr "" #: library/asyncio-future.rst:127 @@ -189,7 +191,7 @@ msgstr "" #: library/asyncio-future.rst:136 msgid "" -"Raises a :exc:`InvalidStateError` error if the Future is already *done*." +"Raises an :exc:`InvalidStateError` error if the Future is already *done*." msgstr "" #: library/asyncio-future.rst:134 @@ -216,6 +218,12 @@ msgid "" "setting a result or an exception for it::" msgstr "" +#: library/asyncio-future.rst:154 +msgid "" +"if not fut.cancelled():\n" +" fut.set_result(42)" +msgstr "" + #: library/asyncio-future.rst:159 msgid "Add a callback to be run when the Future is *done*." msgstr "" @@ -232,15 +240,22 @@ msgstr "" #: library/asyncio-future.rst:167 msgid "" -"An optional keyword-only *context* argument allows specifying a custom :" -"class:`contextvars.Context` for the *callback* to run in. The current " -"context is used when no *context* is provided." +"An optional keyword-only *context* argument allows specifying a " +"custom :class:`contextvars.Context` for the *callback* to run in. The " +"current context is used when no *context* is provided." msgstr "" #: library/asyncio-future.rst:171 msgid "" -":func:`functools.partial` can be used to pass parameters to the callback, e." -"g.::" +":func:`functools.partial` can be used to pass parameters to the callback, " +"e.g.::" +msgstr "" + +#: library/asyncio-future.rst:174 +msgid "" +"# Call 'print(\"Future:\", fut)' when \"fut\" is done.\n" +"fut.add_done_callback(\n" +" functools.partial(print, \"Future:\"))" msgstr "" #: library/asyncio-future.rst:178 @@ -286,8 +301,8 @@ msgstr "" #: library/asyncio-future.rst:210 msgid "" -"If the Future isn't *done* yet, this method raises an :exc:" -"`InvalidStateError` exception." +"If the Future isn't *done* yet, this method raises " +"an :exc:`InvalidStateError` exception." msgstr "" #: library/asyncio-future.rst:215 @@ -300,6 +315,37 @@ msgid "" "Task to set result for the Future, and waits until the Future has a result::" msgstr "" +#: library/asyncio-future.rst:226 +msgid "" +"async def set_after(fut, delay, value):\n" +" # Sleep for *delay* seconds.\n" +" await asyncio.sleep(delay)\n" +"\n" +" # Set *value* as a result of *fut* Future.\n" +" fut.set_result(value)\n" +"\n" +"async def main():\n" +" # Get the current event loop.\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" # Create a new Future object.\n" +" fut = loop.create_future()\n" +"\n" +" # Run \"set_after()\" coroutine in a parallel Task.\n" +" # We are using the low-level \"loop.create_task()\" API here because\n" +" # we already have a reference to the event loop at hand.\n" +" # Otherwise we could have just used \"asyncio.create_task()\".\n" +" loop.create_task(\n" +" set_after(fut, 1, '... world'))\n" +"\n" +" print('hello ...')\n" +"\n" +" # Wait until *fut* has a result (1 second) and print it.\n" +" print(await fut)\n" +"\n" +"asyncio.run(main())" +msgstr "" + #: library/asyncio-future.rst:257 msgid "" "The Future object was designed to mimic :class:`concurrent.futures.Future`. " @@ -320,8 +366,8 @@ msgstr "" #: library/asyncio-future.rst:266 msgid "" -":meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception` raise an :" -"exc:`InvalidStateError` exception when the Future is not *done*." +":meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception` raise " +"an :exc:`InvalidStateError` exception when the Future is not *done*." msgstr "" #: library/asyncio-future.rst:270 @@ -338,6 +384,6 @@ msgstr "" #: library/asyncio-future.rst:278 msgid "" -":meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument, but :" -"meth:`concurrent.futures.Future.cancel` does not." +":meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument, " +"but :meth:`concurrent.futures.Future.cancel` does not." msgstr "" diff --git a/library/asyncio-llapi-index.po b/library/asyncio-llapi-index.po index 14315d66..9432df9d 100644 --- a/library/asyncio-llapi-index.po +++ b/library/asyncio-llapi-index.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -115,7 +116,7 @@ msgid "Close the event loop." msgstr "" #: library/asyncio-llapi-index.rst:59 -msgid ":meth:`loop.is_running()`" +msgid ":meth:`loop.is_running`" msgstr "" #: library/asyncio-llapi-index.rst:60 @@ -123,7 +124,7 @@ msgid "Return ``True`` if the event loop is running." msgstr "" #: library/asyncio-llapi-index.rst:62 -msgid ":meth:`loop.is_closed()`" +msgid ":meth:`loop.is_closed`" msgstr "" #: library/asyncio-llapi-index.rst:63 @@ -631,8 +632,9 @@ msgstr "" #: library/asyncio-llapi-index.rst:314 msgid "" "Transports that can receive data (TCP and Unix connections, pipes, etc). " -"Returned from methods like :meth:`loop.create_connection`, :meth:`loop." -"create_unix_connection`, :meth:`loop.connect_read_pipe`, etc:" +"Returned from methods " +"like :meth:`loop.create_connection`, :meth:`loop.create_unix_connection`, :meth:`loop.connect_read_pipe`, " +"etc:" msgstr "" #: library/asyncio-llapi-index.rst:319 @@ -666,8 +668,9 @@ msgstr "" #: library/asyncio-llapi-index.rst:334 msgid "" "Transports that can Send data (TCP and Unix connections, pipes, etc). " -"Returned from methods like :meth:`loop.create_connection`, :meth:`loop." -"create_unix_connection`, :meth:`loop.connect_write_pipe`, etc:" +"Returned from methods " +"like :meth:`loop.create_connection`, :meth:`loop.create_unix_connection`, :meth:`loop.connect_write_pipe`, " +"etc:" msgstr "" #: library/asyncio-llapi-index.rst:339 @@ -716,8 +719,8 @@ msgstr "" #: library/asyncio-llapi-index.rst:359 msgid "" -":meth:`transport.get_write_buffer_size() `" +":meth:`transport.get_write_buffer_size() " +"`" msgstr "" #: library/asyncio-llapi-index.rst:361 @@ -726,8 +729,8 @@ msgstr "" #: library/asyncio-llapi-index.rst:363 msgid "" -":meth:`transport.get_write_buffer_limits() `" +":meth:`transport.get_write_buffer_limits() " +"`" msgstr "" #: library/asyncio-llapi-index.rst:365 @@ -736,8 +739,8 @@ msgstr "" #: library/asyncio-llapi-index.rst:367 msgid "" -":meth:`transport.set_write_buffer_limits() `" +":meth:`transport.set_write_buffer_limits() " +"`" msgstr "" #: library/asyncio-llapi-index.rst:369 @@ -766,8 +769,8 @@ msgstr "" #: library/asyncio-llapi-index.rst:386 msgid "" -"Low-level transport abstraction over subprocesses. Returned by :meth:`loop." -"subprocess_exec` and :meth:`loop.subprocess_shell`:" +"Low-level transport abstraction over subprocesses. Returned " +"by :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell`:" msgstr "" #: library/asyncio-llapi-index.rst:390 @@ -784,8 +787,8 @@ msgstr "" #: library/asyncio-llapi-index.rst:398 msgid "" -":meth:`transport.get_pipe_transport() `" +":meth:`transport.get_pipe_transport() " +"`" msgstr "" #: library/asyncio-llapi-index.rst:400 @@ -969,9 +972,9 @@ msgstr "" #: library/asyncio-llapi-index.rst:497 msgid "" -"Called when the child process has exited. It can be called before :meth:" -"`~SubprocessProtocol.pipe_data_received` and :meth:`~SubprocessProtocol." -"pipe_connection_lost` methods." +"Called when the child process has exited. It can be called " +"before :meth:`~SubprocessProtocol.pipe_data_received` " +"and :meth:`~SubprocessProtocol.pipe_connection_lost` methods." msgstr "" #: library/asyncio-llapi-index.rst:503 @@ -980,9 +983,9 @@ msgstr "" #: library/asyncio-llapi-index.rst:505 msgid "" -"Policies is a low-level mechanism to alter the behavior of functions like :" -"func:`asyncio.get_event_loop`. See also the main :ref:`policies section " -"` for more details." +"Policies is a low-level mechanism to alter the behavior of functions " +"like :func:`asyncio.get_event_loop`. See also the main :ref:`policies " +"section ` for more details." msgstr "" #: library/asyncio-llapi-index.rst:511 diff --git a/library/asyncio-platforms.po b/library/asyncio-platforms.po index 9200d082..36377c60 100644 --- a/library/asyncio-platforms.po +++ b/library/asyncio-platforms.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -85,15 +86,15 @@ msgstr "" #: library/asyncio-platforms.rst:53 msgid "" -"Pipes are not supported, so the :meth:`loop.connect_read_pipe` and :meth:" -"`loop.connect_write_pipe` methods are not implemented." +"Pipes are not supported, so the :meth:`loop.connect_read_pipe` " +"and :meth:`loop.connect_write_pipe` methods are not implemented." msgstr "" #: library/asyncio-platforms.rst:56 msgid "" -":ref:`Subprocesses ` are not supported, i.e. :meth:`loop." -"subprocess_exec` and :meth:`loop.subprocess_shell` methods are not " -"implemented." +":ref:`Subprocesses ` are not supported, " +"i.e. :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell` methods " +"are not implemented." msgstr "" #: library/asyncio-platforms.rst:60 @@ -126,9 +127,10 @@ msgstr "" #: library/asyncio-platforms.rst:80 msgid "" -"The :meth:`policy.set_child_watcher() ` function is also not supported, as :class:" -"`ProactorEventLoop` has a different mechanism to watch child processes." +"The :meth:`policy.set_child_watcher() " +"` function is also not supported, " +"as :class:`ProactorEventLoop` has a different mechanism to watch child " +"processes." msgstr "" #: library/asyncio-platforms.rst:87 @@ -145,9 +147,20 @@ msgstr "" #: library/asyncio-platforms.rst:93 msgid "" -"On macOS 10.6, 10.7 and 10.8, the default event loop uses :class:`selectors." -"KqueueSelector`, which does not support character devices on these " -"versions. The :class:`SelectorEventLoop` can be manually configured to use :" -"class:`~selectors.SelectSelector` or :class:`~selectors.PollSelector` to " -"support character devices on these older versions of macOS. Example::" +"On macOS 10.6, 10.7 and 10.8, the default event loop " +"uses :class:`selectors.KqueueSelector`, which does not support character " +"devices on these versions. The :class:`SelectorEventLoop` can be manually " +"configured to use :class:`~selectors.SelectSelector` " +"or :class:`~selectors.PollSelector` to support character devices on these " +"older versions of macOS. Example::" +msgstr "" + +#: library/asyncio-platforms.rst:100 +msgid "" +"import asyncio\n" +"import selectors\n" +"\n" +"selector = selectors.SelectSelector()\n" +"loop = asyncio.SelectorEventLoop(selector)\n" +"asyncio.set_event_loop(loop)" msgstr "" diff --git a/library/asyncio-policy.po b/library/asyncio-policy.po index 94008f82..d72c84eb 100644 --- a/library/asyncio-policy.po +++ b/library/asyncio-policy.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -22,12 +23,12 @@ msgstr "" #: library/asyncio-policy.rst:10 msgid "" -"An event loop policy is a global object used to get and set the current :ref:" -"`event loop `, as well as create new event loops. The " -"default policy can be :ref:`replaced ` with :ref:" -"`built-in alternatives ` to use different event loop " -"implementations, or substituted by a :ref:`custom policy ` that can override these behaviors." +"An event loop policy is a global object used to get and set the " +"current :ref:`event loop `, as well as create new event " +"loops. The default policy can be :ref:`replaced ` " +"with :ref:`built-in alternatives ` to use different " +"event loop implementations, or substituted by a :ref:`custom policy ` that can override these behaviors." msgstr "" #: library/asyncio-policy.rst:19 @@ -39,14 +40,15 @@ msgstr "" #: library/asyncio-policy.rst:24 msgid "" -"Custom event loop policies can control the behavior of :func:" -"`get_event_loop`, :func:`set_event_loop`, and :func:`new_event_loop`." +"Custom event loop policies can control the behavior " +"of :func:`get_event_loop`, :func:`set_event_loop`, " +"and :func:`new_event_loop`." msgstr "" #: library/asyncio-policy.rst:27 msgid "" -"Policy objects should implement the APIs defined in the :class:" -"`AbstractEventLoopPolicy` abstract base class." +"Policy objects should implement the APIs defined in " +"the :class:`AbstractEventLoopPolicy` abstract base class." msgstr "" #: library/asyncio-policy.rst:34 @@ -129,8 +131,8 @@ msgstr "" #: library/asyncio-policy.rst:109 msgid "" -"The default asyncio policy. Uses :class:`SelectorEventLoop` on Unix and :" -"class:`ProactorEventLoop` on Windows." +"The default asyncio policy. Uses :class:`SelectorEventLoop` on Unix " +"and :class:`ProactorEventLoop` on Windows." msgstr "" #: library/asyncio-policy.rst:112 @@ -145,8 +147,8 @@ msgstr "" #: library/asyncio-policy.rst:119 msgid "" -"The :meth:`get_event_loop` method of the default asyncio policy now emits a :" -"exc:`DeprecationWarning` if there is no current event loop set and it " +"The :meth:`get_event_loop` method of the default asyncio policy now emits " +"a :exc:`DeprecationWarning` if there is no current event loop set and it " "decides to create one. In some future Python release this will become an " "error." msgstr "" @@ -158,7 +160,7 @@ msgid "" msgstr "" #: library/asyncio-policy.rst:139 -msgid ":ref:`Availability `: Windows." +msgid "Availability" msgstr "" #: library/asyncio-policy.rst:136 @@ -187,10 +189,10 @@ msgstr "" #: library/asyncio-policy.rst:155 msgid "" "asyncio defines the :class:`AbstractChildWatcher` abstract base class, which " -"child watchers should implement, and has four different implementations: :" -"class:`ThreadedChildWatcher` (configured to be used by default), :class:" -"`MultiLoopChildWatcher`, :class:`SafeChildWatcher`, and :class:" -"`FastChildWatcher`." +"child watchers should implement, and has four different " +"implementations: :class:`ThreadedChildWatcher` (configured to be used by " +"default), :class:`MultiLoopChildWatcher`, :class:`SafeChildWatcher`, " +"and :class:`FastChildWatcher`." msgstr "" #: library/asyncio-policy.rst:161 @@ -212,8 +214,8 @@ msgstr "" #: library/asyncio-policy.rst:175 msgid "" "Set the current child watcher to *watcher* for the current policy. " -"*watcher* must implement methods defined in the :class:" -"`AbstractChildWatcher` base class." +"*watcher* must implement methods defined in " +"the :class:`AbstractChildWatcher` base class." msgstr "" #: library/asyncio-policy.rst:182 @@ -268,8 +270,8 @@ msgstr "" #: library/asyncio-policy.rst:219 msgid "" -"Spawning a subprocess with *inactive* current child watcher raises :exc:" -"`RuntimeError`." +"Spawning a subprocess with *inactive* current child watcher " +"raises :exc:`RuntimeError`." msgstr "" #: library/asyncio-policy.rst:226 @@ -331,9 +333,10 @@ msgstr "" #: library/asyncio-policy.rst:269 msgid "" -"This implementation uses active event loop from the main thread to handle :" -"py:data:`SIGCHLD` signal. If the main thread has no running event loop " -"another thread cannot spawn a subprocess (:exc:`RuntimeError` is raised)." +"This implementation uses active event loop from the main thread to " +"handle :py:data:`SIGCHLD` signal. If the main thread has no running event " +"loop another thread cannot spawn a subprocess (:exc:`RuntimeError` is " +"raised)." msgstr "" #: library/asyncio-policy.rst:276 @@ -345,9 +348,9 @@ msgstr "" #: library/asyncio-policy.rst:283 msgid "" -"This implementation reaps every terminated processes by calling ``os." -"waitpid(-1)`` directly, possibly breaking other code spawning processes and " -"waiting for their termination." +"This implementation reaps every terminated processes by calling " +"``os.waitpid(-1)`` directly, possibly breaking other code spawning processes " +"and waiting for their termination." msgstr "" #: library/asyncio-policy.rst:287 @@ -358,8 +361,8 @@ msgstr "" #: library/asyncio-policy.rst:290 msgid "" -"This solution requires a running event loop in the main thread to work, as :" -"class:`SafeChildWatcher`." +"This solution requires a running event loop in the main thread to work, " +"as :class:`SafeChildWatcher`." msgstr "" #: library/asyncio-policy.rst:297 @@ -379,7 +382,23 @@ msgstr "" #: library/asyncio-policy.rst:313 msgid "" -"To implement a new event loop policy, it is recommended to subclass :class:" -"`DefaultEventLoopPolicy` and override the methods for which custom behavior " -"is wanted, e.g.::" +"To implement a new event loop policy, it is recommended to " +"subclass :class:`DefaultEventLoopPolicy` and override the methods for which " +"custom behavior is wanted, e.g.::" +msgstr "" + +#: library/asyncio-policy.rst:317 +msgid "" +"class MyEventLoopPolicy(asyncio.DefaultEventLoopPolicy):\n" +"\n" +" def get_event_loop(self):\n" +" \"\"\"Get the event loop.\n" +"\n" +" This may be None or an instance of EventLoop.\n" +" \"\"\"\n" +" loop = super().get_event_loop()\n" +" # Do something with loop ...\n" +" return loop\n" +"\n" +"asyncio.set_event_loop_policy(MyEventLoopPolicy())" msgstr "" diff --git a/library/asyncio-protocol.po b/library/asyncio-protocol.po index 20dd6720..9bdc6236 100644 --- a/library/asyncio-protocol.po +++ b/library/asyncio-protocol.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -75,11 +76,11 @@ msgstr "" #: library/asyncio-protocol.rst:44 msgid "" -"Most of connection oriented event loop methods (such as :meth:`loop." -"create_connection`) usually accept a *protocol_factory* argument used to " -"create a *Protocol* object for an accepted connection, represented by a " -"*Transport* object. Such methods usually return a tuple of ``(transport, " -"protocol)``." +"Most of connection oriented event loop methods (such " +"as :meth:`loop.create_connection`) usually accept a *protocol_factory* " +"argument used to create a *Protocol* object for an accepted connection, " +"represented by a *Transport* object. Such methods usually return a tuple of " +"``(transport, protocol)``." msgstr "" #: library/asyncio-protocol.rst:51 @@ -92,16 +93,16 @@ msgstr "" #: library/asyncio-protocol.rst:54 msgid "" -"The `Transports`_ section documents asyncio :class:`BaseTransport`, :class:" -"`ReadTransport`, :class:`WriteTransport`, :class:`Transport`, :class:" -"`DatagramTransport`, and :class:`SubprocessTransport` classes." +"The `Transports`_ section documents " +"asyncio :class:`BaseTransport`, :class:`ReadTransport`, :class:`WriteTransport`, :class:`Transport`, :class:`DatagramTransport`, " +"and :class:`SubprocessTransport` classes." msgstr "" #: library/asyncio-protocol.rst:59 msgid "" -"The `Protocols`_ section documents asyncio :class:`BaseProtocol`, :class:" -"`Protocol`, :class:`BufferedProtocol`, :class:`DatagramProtocol`, and :class:" -"`SubprocessProtocol` classes." +"The `Protocols`_ section documents " +"asyncio :class:`BaseProtocol`, :class:`Protocol`, :class:`BufferedProtocol`, :class:`DatagramProtocol`, " +"and :class:`SubprocessProtocol` classes." msgstr "" #: library/asyncio-protocol.rst:63 @@ -157,9 +158,9 @@ msgstr "" #: library/asyncio-protocol.rst:100 msgid "" -"Instances of the *WriteTransport* class are returned from the :meth:`loop." -"connect_write_pipe` event loop method and are also used by subprocess-" -"related methods like :meth:`loop.subprocess_exec`." +"Instances of the *WriteTransport* class are returned from " +"the :meth:`loop.connect_write_pipe` event loop method and are also used by " +"subprocess-related methods like :meth:`loop.subprocess_exec`." msgstr "" #: library/asyncio-protocol.rst:107 @@ -168,9 +169,9 @@ msgstr "" #: library/asyncio-protocol.rst:109 msgid "" -"Instances of the *ReadTransport* class are returned from the :meth:`loop." -"connect_read_pipe` event loop method and are also used by subprocess-related " -"methods like :meth:`loop.subprocess_exec`." +"Instances of the *ReadTransport* class are returned from " +"the :meth:`loop.connect_read_pipe` event loop method and are also used by " +"subprocess-related methods like :meth:`loop.subprocess_exec`." msgstr "" #: library/asyncio-protocol.rst:116 @@ -188,8 +189,8 @@ msgstr "" #: library/asyncio-protocol.rst:123 msgid "" "Instances of the *Transport* class are returned from or used by event loop " -"methods like :meth:`loop.create_connection`, :meth:`loop." -"create_unix_connection`, :meth:`loop.create_server`, :meth:`loop.sendfile`, " +"methods " +"like :meth:`loop.create_connection`, :meth:`loop.create_unix_connection`, :meth:`loop.create_server`, :meth:`loop.sendfile`, " "etc." msgstr "" @@ -199,8 +200,8 @@ msgstr "" #: library/asyncio-protocol.rst:133 msgid "" -"Instances of the *DatagramTransport* class are returned from the :meth:`loop." -"create_datagram_endpoint` event loop method." +"Instances of the *DatagramTransport* class are returned from " +"the :meth:`loop.create_datagram_endpoint` event loop method." msgstr "" #: library/asyncio-protocol.rst:139 @@ -259,6 +260,13 @@ msgid "" "of the transport::" msgstr "" +#: library/asyncio-protocol.rst:182 +msgid "" +"sock = transport.get_extra_info('socket')\n" +"if sock is not None:\n" +" print(sock.getsockopt(...))" +msgstr "" + #: library/asyncio-protocol.rst:186 msgid "Categories of information that can be queried on some transports:" msgstr "" @@ -279,8 +287,8 @@ msgstr "" #: library/asyncio-protocol.rst:196 msgid "" -"``'sockname'``: the socket's own address, result of :meth:`socket.socket." -"getsockname`" +"``'sockname'``: the socket's own address, result " +"of :meth:`socket.socket.getsockname`" msgstr "" #: library/asyncio-protocol.rst:199 @@ -290,8 +298,8 @@ msgstr "" #: library/asyncio-protocol.rst:201 msgid "" "``'compression'``: the compression algorithm being used as a string, or " -"``None`` if the connection isn't compressed; result of :meth:`ssl.SSLSocket." -"compression`" +"``None`` if the connection isn't compressed; result " +"of :meth:`ssl.SSLSocket.compression`" msgstr "" #: library/asyncio-protocol.rst:205 @@ -393,8 +401,8 @@ msgstr "" #: library/asyncio-protocol.rst:281 msgid "" -"Return :const:`True` if the transport supports :meth:`~WriteTransport." -"write_eof`, :const:`False` if not." +"Return :const:`True` if the transport " +"supports :meth:`~WriteTransport.write_eof`, :const:`False` if not." msgstr "" #: library/asyncio-protocol.rst:286 @@ -417,19 +425,19 @@ msgstr "" #: library/asyncio-protocol.rst:302 msgid "" -"These two values (measured in number of bytes) control when the protocol's :" -"meth:`protocol.pause_writing() ` and :meth:" -"`protocol.resume_writing() ` methods are " -"called. If specified, the low watermark must be less than or equal to the " -"high watermark. Neither *high* nor *low* can be negative." +"These two values (measured in number of bytes) control when the " +"protocol's :meth:`protocol.pause_writing() ` " +"and :meth:`protocol.resume_writing() ` methods " +"are called. If specified, the low watermark must be less than or equal to " +"the high watermark. Neither *high* nor *low* can be negative." msgstr "" #: library/asyncio-protocol.rst:310 msgid "" ":meth:`~BaseProtocol.pause_writing` is called when the buffer size becomes " -"greater than or equal to the *high* value. If writing has been paused, :meth:" -"`~BaseProtocol.resume_writing` is called when the buffer size becomes less " -"than or equal to the *low* value." +"greater than or equal to the *high* value. If writing has been " +"paused, :meth:`~BaseProtocol.resume_writing` is called when the buffer size " +"becomes less than or equal to the *low* value." msgstr "" #: library/asyncio-protocol.rst:315 @@ -438,10 +446,10 @@ msgid "" "given, the low watermark defaults to an implementation-specific value less " "than or equal to the high watermark. Setting *high* to zero forces *low* to " "zero as well, and causes :meth:`~BaseProtocol.pause_writing` to be called " -"whenever the buffer becomes non-empty. Setting *low* to zero causes :meth:" -"`~BaseProtocol.resume_writing` to be called only once the buffer is empty. " -"Use of zero for either limit is generally sub-optimal as it reduces " -"opportunities for doing I/O and computation concurrently." +"whenever the buffer becomes non-empty. Setting *low* to zero " +"causes :meth:`~BaseProtocol.resume_writing` to be called only once the " +"buffer is empty. Use of zero for either limit is generally sub-optimal as it " +"reduces opportunities for doing I/O and computation concurrently." msgstr "" #: library/asyncio-protocol.rst:326 @@ -512,20 +520,20 @@ msgstr "" #: library/asyncio-protocol.rst:388 msgid "" -"``0``: readable streaming transport of the standard input (*stdin*), or :" -"const:`None` if the subprocess was not created with ``stdin=PIPE``" +"``0``: readable streaming transport of the standard input (*stdin*), " +"or :const:`None` if the subprocess was not created with ``stdin=PIPE``" msgstr "" #: library/asyncio-protocol.rst:390 msgid "" -"``1``: writable streaming transport of the standard output (*stdout*), or :" -"const:`None` if the subprocess was not created with ``stdout=PIPE``" +"``1``: writable streaming transport of the standard output (*stdout*), " +"or :const:`None` if the subprocess was not created with ``stdout=PIPE``" msgstr "" #: library/asyncio-protocol.rst:392 msgid "" -"``2``: writable streaming transport of the standard error (*stderr*), or :" -"const:`None` if the subprocess was not created with ``stderr=PIPE``" +"``2``: writable streaming transport of the standard error (*stderr*), " +"or :const:`None` if the subprocess was not created with ``stderr=PIPE``" msgstr "" #: library/asyncio-protocol.rst:394 @@ -555,8 +563,8 @@ msgstr "" #: library/asyncio-protocol.rst:413 msgid "" -"Send the *signal* number to the subprocess, as in :meth:`subprocess.Popen." -"send_signal`." +"Send the *signal* number to the subprocess, as " +"in :meth:`subprocess.Popen.send_signal`." msgstr "" #: library/asyncio-protocol.rst:418 @@ -702,8 +710,9 @@ msgstr "" #: library/asyncio-protocol.rst:524 msgid "" -"If the buffer size equals the high watermark, :meth:`~BaseProtocol." -"pause_writing` is not called: the buffer size must go strictly over." +"If the buffer size equals the high " +"watermark, :meth:`~BaseProtocol.pause_writing` is not called: the buffer " +"size must go strictly over." msgstr "" #: library/asyncio-protocol.rst:528 @@ -719,11 +728,10 @@ msgstr "" #: library/asyncio-protocol.rst:537 msgid "" -"Event methods, such as :meth:`loop.create_server`, :meth:`loop." -"create_unix_server`, :meth:`loop.create_connection`, :meth:`loop." -"create_unix_connection`, :meth:`loop.connect_accepted_socket`, :meth:`loop." -"connect_read_pipe`, and :meth:`loop.connect_write_pipe` accept factories " -"that return streaming protocols." +"Event methods, such " +"as :meth:`loop.create_server`, :meth:`loop.create_unix_server`, :meth:`loop.create_connection`, :meth:`loop.create_unix_connection`, :meth:`loop.connect_accepted_socket`, :meth:`loop.connect_read_pipe`, " +"and :meth:`loop.connect_write_pipe` accept factories that return streaming " +"protocols." msgstr "" #: library/asyncio-protocol.rst:545 @@ -780,6 +788,14 @@ msgstr "" msgid "State machine:" msgstr "" +#: library/asyncio-protocol.rst:580 +msgid "" +"start -> connection_made\n" +" [-> data_received]*\n" +" [-> eof_received]?\n" +"-> connection_lost -> end" +msgstr "" + #: library/asyncio-protocol.rst:589 msgid "Buffered Streaming Protocols" msgstr "" @@ -833,17 +849,27 @@ msgstr "" #: library/asyncio-protocol.rst:626 msgid "" -"See the documentation of the :meth:`protocol.eof_received() ` method." +"See the documentation of the :meth:`protocol.eof_received() " +"` method." msgstr "" #: library/asyncio-protocol.rst:630 msgid "" ":meth:`~BufferedProtocol.get_buffer` can be called an arbitrary number of " "times during a connection. However, :meth:`protocol.eof_received() " -"` is called at most once and, if called, :meth:" -"`~BufferedProtocol.get_buffer` and :meth:`~BufferedProtocol.buffer_updated` " -"won't be called after it." +"` is called at most once and, if " +"called, :meth:`~BufferedProtocol.get_buffer` " +"and :meth:`~BufferedProtocol.buffer_updated` won't be called after it." +msgstr "" + +#: library/asyncio-protocol.rst:638 +msgid "" +"start -> connection_made\n" +" [-> get_buffer\n" +" [-> buffer_updated]?\n" +" ]*\n" +" [-> eof_received]?\n" +"-> connection_lost -> end" msgstr "" #: library/asyncio-protocol.rst:649 @@ -865,8 +891,8 @@ msgstr "" #: library/asyncio-protocol.rst:662 msgid "" -"Called when a previous send or receive operation raises an :class:" -"`OSError`. *exc* is the :class:`OSError` instance." +"Called when a previous send or receive operation raises " +"an :class:`OSError`. *exc* is the :class:`OSError` instance." msgstr "" #: library/asyncio-protocol.rst:665 @@ -885,10 +911,10 @@ msgstr "" #: library/asyncio-protocol.rst:676 msgid "" -"The socket always appears 'ready' and excess packets are dropped. An :class:" -"`OSError` with ``errno`` set to :const:`errno.ENOBUFS` may or may not be " -"raised; if it is raised, it will be reported to :meth:`DatagramProtocol." -"error_received` but otherwise ignored." +"The socket always appears 'ready' and excess packets are dropped. " +"An :class:`OSError` with ``errno`` set to :const:`errno.ENOBUFS` may or may " +"not be raised; if it is raised, it will be reported " +"to :meth:`DatagramProtocol.error_received` but otherwise ignored." msgstr "" #: library/asyncio-protocol.rst:685 @@ -930,8 +956,8 @@ msgstr "" #: library/asyncio-protocol.rst:711 msgid "" -"It can be called before :meth:`~SubprocessProtocol.pipe_data_received` and :" -"meth:`~SubprocessProtocol.pipe_connection_lost` methods." +"It can be called before :meth:`~SubprocessProtocol.pipe_data_received` " +"and :meth:`~SubprocessProtocol.pipe_connection_lost` methods." msgstr "" #: library/asyncio-protocol.rst:716 @@ -948,6 +974,44 @@ msgid "" "back received data, and close the connection::" msgstr "" +#: library/asyncio-protocol.rst:726 +msgid "" +"import asyncio\n" +"\n" +"\n" +"class EchoServerProtocol(asyncio.Protocol):\n" +" def connection_made(self, transport):\n" +" peername = transport.get_extra_info('peername')\n" +" print('Connection from {}'.format(peername))\n" +" self.transport = transport\n" +"\n" +" def data_received(self, data):\n" +" message = data.decode()\n" +" print('Data received: {!r}'.format(message))\n" +"\n" +" print('Send: {!r}'.format(message))\n" +" self.transport.write(data)\n" +"\n" +" print('Close the client socket')\n" +" self.transport.close()\n" +"\n" +"\n" +"async def main():\n" +" # Get a reference to the event loop as we plan to use\n" +" # low-level APIs.\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" server = await loop.create_server(\n" +" lambda: EchoServerProtocol(),\n" +" '127.0.0.1', 8888)\n" +"\n" +" async with server:\n" +" await server.serve_forever()\n" +"\n" +"\n" +"asyncio.run(main())" +msgstr "" + #: library/asyncio-protocol.rst:764 msgid "" "The :ref:`TCP echo server using streams ` " @@ -964,6 +1028,51 @@ msgid "" "data, and waits until the connection is closed::" msgstr "" +#: library/asyncio-protocol.rst:775 +msgid "" +"import asyncio\n" +"\n" +"\n" +"class EchoClientProtocol(asyncio.Protocol):\n" +" def __init__(self, message, on_con_lost):\n" +" self.message = message\n" +" self.on_con_lost = on_con_lost\n" +"\n" +" def connection_made(self, transport):\n" +" transport.write(self.message.encode())\n" +" print('Data sent: {!r}'.format(self.message))\n" +"\n" +" def data_received(self, data):\n" +" print('Data received: {!r}'.format(data.decode()))\n" +"\n" +" def connection_lost(self, exc):\n" +" print('The server closed the connection')\n" +" self.on_con_lost.set_result(True)\n" +"\n" +"\n" +"async def main():\n" +" # Get a reference to the event loop as we plan to use\n" +" # low-level APIs.\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" on_con_lost = loop.create_future()\n" +" message = 'Hello World!'\n" +"\n" +" transport, protocol = await loop.create_connection(\n" +" lambda: EchoClientProtocol(message, on_con_lost),\n" +" '127.0.0.1', 8888)\n" +"\n" +" # Wait until the protocol signals that the connection\n" +" # is lost and close the transport.\n" +" try:\n" +" await on_con_lost\n" +" finally:\n" +" transport.close()\n" +"\n" +"\n" +"asyncio.run(main())" +msgstr "" + #: library/asyncio-protocol.rst:820 msgid "" "The :ref:`TCP echo client using streams ` " @@ -980,6 +1089,44 @@ msgid "" "sends back received data::" msgstr "" +#: library/asyncio-protocol.rst:832 +msgid "" +"import asyncio\n" +"\n" +"\n" +"class EchoServerProtocol:\n" +" def connection_made(self, transport):\n" +" self.transport = transport\n" +"\n" +" def datagram_received(self, data, addr):\n" +" message = data.decode()\n" +" print('Received %r from %s' % (message, addr))\n" +" print('Send %r to %s' % (message, addr))\n" +" self.transport.sendto(data, addr)\n" +"\n" +"\n" +"async def main():\n" +" print(\"Starting UDP server\")\n" +"\n" +" # Get a reference to the event loop as we plan to use\n" +" # low-level APIs.\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" # One protocol instance will be created to serve all\n" +" # client requests.\n" +" transport, protocol = await loop.create_datagram_endpoint(\n" +" lambda: EchoServerProtocol(),\n" +" local_addr=('127.0.0.1', 9999))\n" +"\n" +" try:\n" +" await asyncio.sleep(3600) # Serve for 1 hour.\n" +" finally:\n" +" transport.close()\n" +"\n" +"\n" +"asyncio.run(main())" +msgstr "" + #: library/asyncio-protocol.rst:871 msgid "UDP Echo Client" msgstr "" @@ -990,6 +1137,57 @@ msgid "" "sends data and closes the transport when it receives the answer::" msgstr "" +#: library/asyncio-protocol.rst:876 +msgid "" +"import asyncio\n" +"\n" +"\n" +"class EchoClientProtocol:\n" +" def __init__(self, message, on_con_lost):\n" +" self.message = message\n" +" self.on_con_lost = on_con_lost\n" +" self.transport = None\n" +"\n" +" def connection_made(self, transport):\n" +" self.transport = transport\n" +" print('Send:', self.message)\n" +" self.transport.sendto(self.message.encode())\n" +"\n" +" def datagram_received(self, data, addr):\n" +" print(\"Received:\", data.decode())\n" +"\n" +" print(\"Close the socket\")\n" +" self.transport.close()\n" +"\n" +" def error_received(self, exc):\n" +" print('Error received:', exc)\n" +"\n" +" def connection_lost(self, exc):\n" +" print(\"Connection closed\")\n" +" self.on_con_lost.set_result(True)\n" +"\n" +"\n" +"async def main():\n" +" # Get a reference to the event loop as we plan to use\n" +" # low-level APIs.\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" on_con_lost = loop.create_future()\n" +" message = \"Hello World!\"\n" +"\n" +" transport, protocol = await loop.create_datagram_endpoint(\n" +" lambda: EchoClientProtocol(message, on_con_lost),\n" +" remote_addr=('127.0.0.1', 9999))\n" +"\n" +" try:\n" +" await on_con_lost\n" +" finally:\n" +" transport.close()\n" +"\n" +"\n" +"asyncio.run(main())" +msgstr "" + #: library/asyncio-protocol.rst:928 msgid "Connecting Existing Sockets" msgstr "" @@ -1000,11 +1198,63 @@ msgid "" "method with a protocol::" msgstr "" +#: library/asyncio-protocol.rst:933 +msgid "" +"import asyncio\n" +"import socket\n" +"\n" +"\n" +"class MyProtocol(asyncio.Protocol):\n" +"\n" +" def __init__(self, on_con_lost):\n" +" self.transport = None\n" +" self.on_con_lost = on_con_lost\n" +"\n" +" def connection_made(self, transport):\n" +" self.transport = transport\n" +"\n" +" def data_received(self, data):\n" +" print(\"Received:\", data.decode())\n" +"\n" +" # We are done: close the transport;\n" +" # connection_lost() will be called automatically.\n" +" self.transport.close()\n" +"\n" +" def connection_lost(self, exc):\n" +" # The socket has been closed\n" +" self.on_con_lost.set_result(True)\n" +"\n" +"\n" +"async def main():\n" +" # Get a reference to the event loop as we plan to use\n" +" # low-level APIs.\n" +" loop = asyncio.get_running_loop()\n" +" on_con_lost = loop.create_future()\n" +"\n" +" # Create a pair of connected sockets\n" +" rsock, wsock = socket.socketpair()\n" +"\n" +" # Register the socket to wait for data.\n" +" transport, protocol = await loop.create_connection(\n" +" lambda: MyProtocol(on_con_lost), sock=rsock)\n" +"\n" +" # Simulate the reception of data from the network.\n" +" loop.call_soon(wsock.send, 'abc'.encode())\n" +"\n" +" try:\n" +" await protocol.on_con_lost\n" +" finally:\n" +" transport.close()\n" +" wsock.close()\n" +"\n" +"asyncio.run(main())" +msgstr "" + #: library/asyncio-protocol.rst:984 msgid "" "The :ref:`watch a file descriptor for read events " -"` example uses the low-level :meth:`loop." -"add_reader` method to register an FD." +"` example uses the low-" +"level :meth:`loop.add_reader` method to register an FD." msgstr "" #: library/asyncio-protocol.rst:988 @@ -1028,6 +1278,67 @@ msgstr "" msgid "The subprocess is created by the :meth:`loop.subprocess_exec` method::" msgstr "" +#: library/asyncio-protocol.rst:1002 +msgid "" +"import asyncio\n" +"import sys\n" +"\n" +"class DateProtocol(asyncio.SubprocessProtocol):\n" +" def __init__(self, exit_future):\n" +" self.exit_future = exit_future\n" +" self.output = bytearray()\n" +" self.pipe_closed = False\n" +" self.exited = False\n" +"\n" +" def pipe_connection_lost(self, fd, exc):\n" +" self.pipe_closed = True\n" +" self.check_for_exit()\n" +"\n" +" def pipe_data_received(self, fd, data):\n" +" self.output.extend(data)\n" +"\n" +" def process_exited(self):\n" +" self.exited = True\n" +" # process_exited() method can be called before\n" +" # pipe_connection_lost() method: wait until both methods are\n" +" # called.\n" +" self.check_for_exit()\n" +"\n" +" def check_for_exit(self):\n" +" if self.pipe_closed and self.exited:\n" +" self.exit_future.set_result(True)\n" +"\n" +"async def get_date():\n" +" # Get a reference to the event loop as we plan to use\n" +" # low-level APIs.\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" code = 'import datetime; print(datetime.datetime.now())'\n" +" exit_future = asyncio.Future(loop=loop)\n" +"\n" +" # Create the subprocess controlled by DateProtocol;\n" +" # redirect the standard output into a pipe.\n" +" transport, protocol = await loop.subprocess_exec(\n" +" lambda: DateProtocol(exit_future),\n" +" sys.executable, '-c', code,\n" +" stdin=None, stderr=None)\n" +"\n" +" # Wait for the subprocess exit using the process_exited()\n" +" # method of the protocol.\n" +" await exit_future\n" +"\n" +" # Close the stdout pipe.\n" +" transport.close()\n" +"\n" +" # Read the output which was collected by the\n" +" # pipe_data_received() method of the protocol.\n" +" data = bytes(protocol.output)\n" +" return data.decode('ascii').rstrip()\n" +"\n" +"date = asyncio.run(get_date())\n" +"print(f\"Current date: {date}\")" +msgstr "" + #: library/asyncio-protocol.rst:1060 msgid "" "See also the :ref:`same example ` " diff --git a/library/asyncio-queue.po b/library/asyncio-queue.po index e3ac7147..afe47a8d 100644 --- a/library/asyncio-queue.po +++ b/library/asyncio-queue.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2025-01-22 13:33+0200\n" "Last-Translator: Marios Giannopoulos \n" "Language-Team: PyGreece \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -37,8 +38,8 @@ msgstr "" #: library/asyncio-queue.rst:17 msgid "" -"Note that methods of asyncio queues don't have a *timeout* parameter; use :" -"func:`asyncio.wait_for` function to do queue operations with a timeout." +"Note that methods of asyncio queues don't have a *timeout* parameter; " +"use :func:`asyncio.wait_for` function to do queue operations with a timeout." msgstr "" "Σημειώστε ότι οι μέθοδοι των ουρών asyncio δεν διαθέτουν παράμετρο " "*timeout*. Χρησιμοποιήστε την συνάρτηση :func:`asyncio.wait_for` για να " @@ -97,12 +98,13 @@ msgid "Return ``True`` if there are :attr:`maxsize` items in the queue." msgstr "Επιστρέφει ``True`` αν υπάρχουν :attr:`maxsize` αντικείμενα στην ουρά." #: library/asyncio-queue.rst:57 +#, fuzzy msgid "" -"If the queue was initialized with ``maxsize=0`` (the default), then :meth:" -"`full()` never returns ``True``." +"If the queue was initialized with ``maxsize=0`` (the default), " +"then :meth:`full` never returns ``True``." msgstr "" -"Αν η ουρά αρχικοποιήθηκε με ``maxsize=0`` (προεπιλογή), τότε η :meth:" -"`full()` δεν επιστρέφει ποτέ ``True``." +"Αν η ουρά αρχικοποιήθηκε με ``maxsize=0`` (προεπιλογή), τότε " +"η :meth:`full()` δεν επιστρέφει ποτέ ``True``." #: library/asyncio-queue.rst:62 msgid "" @@ -116,8 +118,8 @@ msgstr "" msgid "" "Return an item if one is immediately available, else raise :exc:`QueueEmpty`." msgstr "" -"Επιστρέφει ένα αντικείμενο, αν είναι άμεσα διαθέσιμο, αλλιώς κάνε raise την :" -"exc:`QueueEmpty`." +"Επιστρέφει ένα αντικείμενο, αν είναι άμεσα διαθέσιμο, αλλιώς κάνε raise " +"την :exc:`QueueEmpty`." #: library/asyncio-queue.rst:72 msgid "Block until all items in the queue have been received and processed." @@ -128,10 +130,10 @@ msgstr "" #: library/asyncio-queue.rst:74 msgid "" "The count of unfinished tasks goes up whenever an item is added to the " -"queue. The count goes down whenever a consumer coroutine calls :meth:" -"`task_done` to indicate that the item was retrieved and all work on it is " -"complete. When the count of unfinished tasks drops to zero, :meth:`join` " -"unblocks." +"queue. The count goes down whenever a consumer coroutine " +"calls :meth:`task_done` to indicate that the item was retrieved and all work " +"on it is complete. When the count of unfinished tasks drops to " +"zero, :meth:`join` unblocks." msgstr "" "Ο αριθμός των ημιτελών εργασιών αυξάνεται κάθε φορά που προστίθεται ένα " "αντικείμενο στην ουρά. Ο αριθμός μειώνεται όταν μια καταναλωτική coroutine " @@ -154,28 +156,30 @@ msgstr "Τοποθετεί ένα αντικείμενο στην ουρά χω #: library/asyncio-queue.rst:89 msgid "If no free slot is immediately available, raise :exc:`QueueFull`." msgstr "" -"Αν δεν είναι διαθέσιμη μια ελεύθερη θέση αμέσως, γίνεται raise η :exc:" -"`QueueFull`." +"Αν δεν είναι διαθέσιμη μια ελεύθερη θέση αμέσως, γίνεται raise " +"η :exc:`QueueFull`." #: library/asyncio-queue.rst:93 msgid "Return the number of items in the queue." msgstr "Επιστρέφει τον αριθμό των αντικειμένων στην ουρά." #: library/asyncio-queue.rst:97 -msgid "Indicate that a formerly enqueued task is complete." +#, fuzzy +msgid "Indicate that a formerly enqueued work item is complete." msgstr "" "Υποδεικνύει ότι μια εργασία που είχε προστεθεί στην ουρά έχει ολοκληρωθεί." #: library/asyncio-queue.rst:99 +#, fuzzy msgid "" -"Used by queue consumers. For each :meth:`~Queue.get` used to fetch a task, a " -"subsequent call to :meth:`task_done` tells the queue that the processing on " -"the task is complete." +"Used by queue consumers. For each :meth:`~Queue.get` used to fetch a work " +"item, a subsequent call to :meth:`task_done` tells the queue that the " +"processing on the work item is complete." msgstr "" -"Χρησιμοποιείται από τους καταναλωτές της ουράς. Για κάθε κλήση της :meth:" -"`~Queue.get` για να ανακτηθεί μια εργασία, μια επακόλουθη κλήση της :meth:" -"`task_done` ενημερώνει την ουρά ότι η επεξεργασία της εργασίας έχει " -"ολοκληρωθεί." +"Χρησιμοποιείται από τους καταναλωτές της ουράς. Για κάθε κλήση " +"της :meth:`~Queue.get` για να ανακτηθεί μια εργασία, μια επακόλουθη κλήση " +"της :meth:`task_done` ενημερώνει την ουρά ότι η επεξεργασία της εργασίας " +"έχει ολοκληρωθεί." #: library/asyncio-queue.rst:103 msgid "" @@ -184,9 +188,9 @@ msgid "" "item that had been :meth:`~Queue.put` into the queue)." msgstr "" "Εάν μια κλήση της :meth:`join` μπλοκάρει αυτή την στιγμή, θα συνεχιστεί όταν " -"όλα τα αντικείμενα έχουν επεξεργαστεί (σημαίνει ότι λήφθηκε μια κλήση της :" -"meth:`task_done` για κάθε αντικείμενο που είχε προστεθεί με :meth:`~Queue." -"put` στην ουρά)." +"όλα τα αντικείμενα έχουν επεξεργαστεί (σημαίνει ότι λήφθηκε μια κλήση " +"της :meth:`task_done` για κάθε αντικείμενο που είχε προστεθεί " +"με :meth:`~Queue.put` στην ουρά)." #: library/asyncio-queue.rst:108 msgid "" @@ -254,3 +258,60 @@ msgid "" msgstr "" "Οι ουρές μπορούν να χρησιμοποιηθούν για τη διανομή εργασίας μεταξύ αρκετών " "παράλληλων εργασιών::" + +#: library/asyncio-queue.rst:156 +msgid "" +"import asyncio\n" +"import random\n" +"import time\n" +"\n" +"\n" +"async def worker(name, queue):\n" +" while True:\n" +" # Get a \"work item\" out of the queue.\n" +" sleep_for = await queue.get()\n" +"\n" +" # Sleep for the \"sleep_for\" seconds.\n" +" await asyncio.sleep(sleep_for)\n" +"\n" +" # Notify the queue that the \"work item\" has been processed.\n" +" queue.task_done()\n" +"\n" +" print(f'{name} has slept for {sleep_for:.2f} seconds')\n" +"\n" +"\n" +"async def main():\n" +" # Create a queue that we will use to store our \"workload\".\n" +" queue = asyncio.Queue()\n" +"\n" +" # Generate random timings and put them into the queue.\n" +" total_sleep_time = 0\n" +" for _ in range(20):\n" +" sleep_for = random.uniform(0.05, 1.0)\n" +" total_sleep_time += sleep_for\n" +" queue.put_nowait(sleep_for)\n" +"\n" +" # Create three worker tasks to process the queue concurrently.\n" +" tasks = []\n" +" for i in range(3):\n" +" task = asyncio.create_task(worker(f'worker-{i}', queue))\n" +" tasks.append(task)\n" +"\n" +" # Wait until the queue is fully processed.\n" +" started_at = time.monotonic()\n" +" await queue.join()\n" +" total_slept_for = time.monotonic() - started_at\n" +"\n" +" # Cancel our worker tasks.\n" +" for task in tasks:\n" +" task.cancel()\n" +" # Wait until all worker tasks are cancelled.\n" +" await asyncio.gather(*tasks, return_exceptions=True)\n" +"\n" +" print('====')\n" +" print(f'3 workers slept in parallel for {total_slept_for:.2f} seconds')\n" +" print(f'total expected sleep time: {total_sleep_time:.2f} seconds')\n" +"\n" +"\n" +"asyncio.run(main())" +msgstr "" diff --git a/library/asyncio-runner.po b/library/asyncio-runner.po index 5d3b473e..2c8401c8 100644 --- a/library/asyncio-runner.po +++ b/library/asyncio-runner.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -58,8 +59,8 @@ msgstr "" #: library/asyncio-runner.rst:83 msgid "" "If *debug* is ``True``, the event loop will be run in debug mode. ``False`` " -"disables debug mode explicitly. ``None`` is used to respect the global :ref:" -"`asyncio-debug-mode` settings." +"disables debug mode explicitly. ``None`` is used to respect the " +"global :ref:`asyncio-debug-mode` settings." msgstr "" #: library/asyncio-runner.rst:40 @@ -82,6 +83,15 @@ msgstr "" msgid "Example::" msgstr "" +#: library/asyncio-runner.rst:52 +msgid "" +"async def main():\n" +" await asyncio.sleep(1)\n" +" print('hello')\n" +"\n" +"asyncio.run(main())" +msgstr "" + #: library/asyncio-runner.rst:60 msgid "Updated to use :meth:`loop.shutdown_default_executor`." msgstr "" @@ -107,8 +117,8 @@ msgstr "" #: library/asyncio-runner.rst:80 msgid "" -"Sometimes several top-level async functions should be called in the same :" -"ref:`event loop ` and :class:`contextvars.Context`." +"Sometimes several top-level async functions should be called in the " +"same :ref:`event loop ` and :class:`contextvars.Context`." msgstr "" #: library/asyncio-runner.rst:87 @@ -121,10 +131,20 @@ msgstr "" #: library/asyncio-runner.rst:92 msgid "" -"Basically, :func:`asyncio.run()` example can be rewritten with the runner " +"Basically, :func:`asyncio.run` example can be rewritten with the runner " "usage::" msgstr "" +#: library/asyncio-runner.rst:94 +msgid "" +"async def main():\n" +" await asyncio.sleep(1)\n" +" print('hello')\n" +"\n" +"with asyncio.Runner() as runner:\n" +" runner.run(main())" +msgstr "" + #: library/asyncio-runner.rst:105 msgid "Run a :term:`coroutine ` *coro* in the embedded loop." msgstr "" @@ -135,9 +155,9 @@ msgstr "" #: library/asyncio-runner.rst:109 msgid "" -"An optional keyword-only *context* argument allows specifying a custom :" -"class:`contextvars.Context` for the *coro* to run in. The runner's default " -"context is used if ``None``." +"An optional keyword-only *context* argument allows specifying a " +"custom :class:`contextvars.Context` for the *coro* to run in. The runner's " +"default context is used if ``None``." msgstr "" #: library/asyncio-runner.rst:118 @@ -172,10 +192,10 @@ msgstr "" #: library/asyncio-runner.rst:141 msgid "" -"When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-C`, :exc:" -"`KeyboardInterrupt` exception is raised in the main thread by default. " -"However this doesn't work with :mod:`asyncio` because it can interrupt " -"asyncio internals and can hang the program from exiting." +"When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-" +"C`, :exc:`KeyboardInterrupt` exception is raised in the main thread by " +"default. However this doesn't work with :mod:`asyncio` because it can " +"interrupt asyncio internals and can hang the program from exiting." msgstr "" #: library/asyncio-runner.rst:146 @@ -203,14 +223,14 @@ msgid "" "handler cancels the main task by calling :meth:`asyncio.Task.cancel` which " "raises :exc:`asyncio.CancelledError` inside the main task. This causes the " "Python stack to unwind, ``try/except`` and ``try/finally`` blocks can be " -"used for resource cleanup. After the main task is cancelled, :meth:`asyncio." -"Runner.run` raises :exc:`KeyboardInterrupt`." +"used for resource cleanup. After the main task is " +"cancelled, :meth:`asyncio.Runner.run` raises :exc:`KeyboardInterrupt`." msgstr "" #: library/asyncio-runner.rst:158 msgid "" -"A user could write a tight loop which cannot be interrupted by :meth:" -"`asyncio.Task.cancel`, in which case the second following :kbd:`Ctrl-C` " -"immediately raises the :exc:`KeyboardInterrupt` without cancelling the main " -"task." +"A user could write a tight loop which cannot be interrupted " +"by :meth:`asyncio.Task.cancel`, in which case the second " +"following :kbd:`Ctrl-C` immediately raises the :exc:`KeyboardInterrupt` " +"without cancelling the main task." msgstr "" diff --git a/library/asyncio-stream.po b/library/asyncio-stream.po index 2b276224..ee89a4bc 100644 --- a/library/asyncio-stream.po +++ b/library/asyncio-stream.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -35,6 +36,28 @@ msgstr "" msgid "Here is an example of a TCP echo client written using asyncio streams::" msgstr "" +#: library/asyncio-stream.rst:404 +msgid "" +"import asyncio\n" +"\n" +"async def tcp_echo_client(message):\n" +" reader, writer = await asyncio.open_connection(\n" +" '127.0.0.1', 8888)\n" +"\n" +" print(f'Send: {message!r}')\n" +" writer.write(message.encode())\n" +" await writer.drain()\n" +"\n" +" data = await reader.read(100)\n" +" print(f'Received: {data.decode()!r}')\n" +"\n" +" print('Close the connection')\n" +" writer.close()\n" +" await writer.wait_closed()\n" +"\n" +"asyncio.run(tcp_echo_client('Hello World!'))" +msgstr "" + #: library/asyncio-stream.rst:42 msgid "See also the `Examples`_ section below." msgstr "" @@ -57,27 +80,28 @@ msgstr "" #: library/asyncio-stream.rst:61 msgid "" -"The returned *reader* and *writer* objects are instances of :class:" -"`StreamReader` and :class:`StreamWriter` classes." +"The returned *reader* and *writer* objects are instances " +"of :class:`StreamReader` and :class:`StreamWriter` classes." msgstr "" #: library/asyncio-stream.rst:109 msgid "" -"*limit* determines the buffer size limit used by the returned :class:" -"`StreamReader` instance. By default the *limit* is set to 64 KiB." +"*limit* determines the buffer size limit used by the " +"returned :class:`StreamReader` instance. By default the *limit* is set to " +"64 KiB." msgstr "" #: library/asyncio-stream.rst:68 msgid "" -"The rest of the arguments are passed directly to :meth:`loop." -"create_connection`." +"The rest of the arguments are passed directly " +"to :meth:`loop.create_connection`." msgstr "" #: library/asyncio-stream.rst:147 msgid "" -"The *sock* argument transfers ownership of the socket to the :class:" -"`StreamWriter` created. To close the socket, call its :meth:`~asyncio." -"StreamWriter.close` method." +"The *sock* argument transfers ownership of the socket to " +"the :class:`StreamWriter` created. To close the socket, call " +"its :meth:`~asyncio.StreamWriter.close` method." msgstr "" #: library/asyncio-stream.rst:77 @@ -149,7 +173,7 @@ msgid "See also the documentation of :meth:`loop.create_unix_connection`." msgstr "" #: library/asyncio-stream.rst:181 -msgid ":ref:`Availability `: Unix." +msgid "Availability" msgstr "" #: library/asyncio-stream.rst:153 @@ -183,14 +207,14 @@ msgstr "" #: library/asyncio-stream.rst:199 msgid "" "Represents a reader object that provides APIs to read data from the IO " -"stream. As an :term:`asynchronous iterable`, the object supports the :" -"keyword:`async for` statement." +"stream. As an :term:`asynchronous iterable`, the object supports " +"the :keyword:`async for` statement." msgstr "" #: library/asyncio-stream.rst:203 msgid "" -"It is not recommended to instantiate *StreamReader* objects directly; use :" -"func:`open_connection` and :func:`start_server` instead." +"It is not recommended to instantiate *StreamReader* objects directly; " +"use :func:`open_connection` and :func:`start_server` instead." msgstr "" #: library/asyncio-stream.rst:209 @@ -259,16 +283,16 @@ msgstr "" #: library/asyncio-stream.rst:254 msgid "" -"If the amount of data read exceeds the configured stream limit, a :exc:" -"`LimitOverrunError` exception is raised, and the data is left in the " +"If the amount of data read exceeds the configured stream limit, " +"a :exc:`LimitOverrunError` exception is raised, and the data is left in the " "internal buffer and can be read again." msgstr "" #: library/asyncio-stream.rst:258 msgid "" -"If EOF is reached before the complete separator is found, an :exc:" -"`IncompleteReadError` exception is raised, and the internal buffer is " -"reset. The :attr:`IncompleteReadError.partial` attribute may contain a " +"If EOF is reached before the complete separator is found, " +"an :exc:`IncompleteReadError` exception is raised, and the internal buffer " +"is reset. The :attr:`IncompleteReadError.partial` attribute may contain a " "portion of the separator." msgstr "" @@ -287,8 +311,8 @@ msgstr "" #: library/asyncio-stream.rst:279 msgid "" -"It is not recommended to instantiate *StreamWriter* objects directly; use :" -"func:`open_connection` and :func:`start_server` instead." +"It is not recommended to instantiate *StreamWriter* objects directly; " +"use :func:`open_connection` and :func:`start_server` instead." msgstr "" #: library/asyncio-stream.rst:285 @@ -302,6 +326,12 @@ msgstr "" msgid "The method should be used along with the ``drain()`` method::" msgstr "" +#: library/asyncio-stream.rst:291 +msgid "" +"stream.write(data)\n" +"await stream.drain()" +msgstr "" + #: library/asyncio-stream.rst:296 msgid "" "The method writes a list (or any iterable) of bytes to the underlying socket " @@ -309,6 +339,12 @@ msgid "" "until it can be sent." msgstr "" +#: library/asyncio-stream.rst:303 +msgid "" +"stream.writelines(lines)\n" +"await stream.drain()" +msgstr "" + #: library/asyncio-stream.rst:308 msgid "The method closes the stream and the underlying socket." msgstr "" @@ -319,6 +355,12 @@ msgid "" "``wait_closed()`` method::" msgstr "" +#: library/asyncio-stream.rst:313 +msgid "" +"stream.close()\n" +"await stream.wait_closed()" +msgstr "" + #: library/asyncio-stream.rst:318 msgid "" "Return ``True`` if the underlying transport supports the :meth:`write_eof` " @@ -336,21 +378,27 @@ msgstr "" #: library/asyncio-stream.rst:332 msgid "" -"Access optional transport information; see :meth:`BaseTransport." -"get_extra_info` for details." +"Access optional transport information; " +"see :meth:`BaseTransport.get_extra_info` for details." msgstr "" #: library/asyncio-stream.rst:337 msgid "Wait until it is appropriate to resume writing to the stream. Example::" msgstr "" +#: library/asyncio-stream.rst:340 +msgid "" +"writer.write(data)\n" +"await writer.drain()" +msgstr "" + #: library/asyncio-stream.rst:343 msgid "" "This is a flow control method that interacts with the underlying IO write " "buffer. When the size of the buffer reaches the high watermark, *drain()* " "blocks until the size of the buffer is drained down to the low watermark and " -"writing can be resumed. When there is nothing to wait for, the :meth:" -"`drain` returns immediately." +"writing can be resumed. When there is nothing to wait for, " +"the :meth:`drain` returns immediately." msgstr "" #: library/asyncio-stream.rst:353 @@ -416,8 +464,8 @@ msgstr "" #: library/asyncio-stream.rst:426 msgid "" "The :ref:`TCP echo client protocol " -"` example uses the low-level :meth:" -"`loop.create_connection` method." +"` example uses the low-" +"level :meth:`loop.create_connection` method." msgstr "" #: library/asyncio-stream.rst:433 @@ -428,11 +476,43 @@ msgstr "" msgid "TCP echo server using the :func:`asyncio.start_server` function::" msgstr "" +#: library/asyncio-stream.rst:437 +msgid "" +"import asyncio\n" +"\n" +"async def handle_echo(reader, writer):\n" +" data = await reader.read(100)\n" +" message = data.decode()\n" +" addr = writer.get_extra_info('peername')\n" +"\n" +" print(f\"Received {message!r} from {addr!r}\")\n" +"\n" +" print(f\"Send: {message!r}\")\n" +" writer.write(data)\n" +" await writer.drain()\n" +"\n" +" print(\"Close the connection\")\n" +" writer.close()\n" +" await writer.wait_closed()\n" +"\n" +"async def main():\n" +" server = await asyncio.start_server(\n" +" handle_echo, '127.0.0.1', 8888)\n" +"\n" +" addrs = ', '.join(str(sock.getsockname()) for sock in server.sockets)\n" +" print(f'Serving on {addrs}')\n" +"\n" +" async with server:\n" +" await server.serve_forever()\n" +"\n" +"asyncio.run(main())" +msgstr "" + #: library/asyncio-stream.rst:469 msgid "" "The :ref:`TCP echo server protocol " -"` example uses the :meth:`loop." -"create_server` method." +"` example uses " +"the :meth:`loop.create_server` method." msgstr "" #: library/asyncio-stream.rst:474 @@ -444,22 +524,102 @@ msgid "" "Simple example querying HTTP headers of the URL passed on the command line::" msgstr "" +#: library/asyncio-stream.rst:478 +msgid "" +"import asyncio\n" +"import urllib.parse\n" +"import sys\n" +"\n" +"async def print_http_headers(url):\n" +" url = urllib.parse.urlsplit(url)\n" +" if url.scheme == 'https':\n" +" reader, writer = await asyncio.open_connection(\n" +" url.hostname, 443, ssl=True)\n" +" else:\n" +" reader, writer = await asyncio.open_connection(\n" +" url.hostname, 80)\n" +"\n" +" query = (\n" +" f\"HEAD {url.path or '/'} HTTP/1.0\\r\\n\"\n" +" f\"Host: {url.hostname}\\r\\n\"\n" +" f\"\\r\\n\"\n" +" )\n" +"\n" +" writer.write(query.encode('latin-1'))\n" +" while True:\n" +" line = await reader.readline()\n" +" if not line:\n" +" break\n" +"\n" +" line = line.decode('latin1').rstrip()\n" +" if line:\n" +" print(f'HTTP header> {line}')\n" +"\n" +" # Ignore the body, close the socket\n" +" writer.close()\n" +" await writer.wait_closed()\n" +"\n" +"url = sys.argv[1]\n" +"asyncio.run(print_http_headers(url))" +msgstr "" + #: library/asyncio-stream.rst:515 msgid "Usage::" msgstr "" +#: library/asyncio-stream.rst:517 +msgid "python example.py http://example.com/path/page.html" +msgstr "" + #: library/asyncio-stream.rst:519 msgid "or with HTTPS::" msgstr "" +#: library/asyncio-stream.rst:521 +msgid "python example.py https://example.com/path/page.html" +msgstr "" + #: library/asyncio-stream.rst:527 msgid "Register an open socket to wait for data using streams" msgstr "" #: library/asyncio-stream.rst:529 msgid "" -"Coroutine waiting until a socket receives data using the :func:" -"`open_connection` function::" +"Coroutine waiting until a socket receives data using " +"the :func:`open_connection` function::" +msgstr "" + +#: library/asyncio-stream.rst:532 +msgid "" +"import asyncio\n" +"import socket\n" +"\n" +"async def wait_for_data():\n" +" # Get a reference to the current event loop because\n" +" # we want to access low-level APIs.\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" # Create a pair of connected sockets.\n" +" rsock, wsock = socket.socketpair()\n" +"\n" +" # Register the open socket to wait for data.\n" +" reader, writer = await asyncio.open_connection(sock=rsock)\n" +"\n" +" # Simulate the reception of data from the network\n" +" loop.call_soon(wsock.send, 'abc'.encode())\n" +"\n" +" # Wait for data\n" +" data = await reader.read(100)\n" +"\n" +" # Got data, we are done: close the socket\n" +" print(\"Received:\", data.decode())\n" +" writer.close()\n" +" await writer.wait_closed()\n" +"\n" +" # Close the second socket\n" +" wsock.close()\n" +"\n" +"asyncio.run(wait_for_data())" msgstr "" #: library/asyncio-stream.rst:564 @@ -472,6 +632,6 @@ msgstr "" #: library/asyncio-stream.rst:568 msgid "" "The :ref:`watch a file descriptor for read events " -"` example uses the low-level :meth:`loop." -"add_reader` method to watch a file descriptor." +"` example uses the low-" +"level :meth:`loop.add_reader` method to watch a file descriptor." msgstr "" diff --git a/library/asyncio-subprocess.po b/library/asyncio-subprocess.po index e74b0603..10774c20 100644 --- a/library/asyncio-subprocess.po +++ b/library/asyncio-subprocess.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -38,10 +39,38 @@ msgid "" "result::" msgstr "" +#: library/asyncio-subprocess.rst:22 +msgid "" +"import asyncio\n" +"\n" +"async def run(cmd):\n" +" proc = await asyncio.create_subprocess_shell(\n" +" cmd,\n" +" stdout=asyncio.subprocess.PIPE,\n" +" stderr=asyncio.subprocess.PIPE)\n" +"\n" +" stdout, stderr = await proc.communicate()\n" +"\n" +" print(f'[{cmd!r} exited with {proc.returncode}]')\n" +" if stdout:\n" +" print(f'[stdout]\\n{stdout.decode()}')\n" +" if stderr:\n" +" print(f'[stderr]\\n{stderr.decode()}')\n" +"\n" +"asyncio.run(run('ls /zzz'))" +msgstr "" + #: library/asyncio-subprocess.rst:40 msgid "will print::" msgstr "" +#: library/asyncio-subprocess.rst:42 +msgid "" +"['ls /zzz' exited with 1]\n" +"[stderr]\n" +"ls: /zzz: No such file or directory" +msgstr "" + #: library/asyncio-subprocess.rst:46 msgid "" "Because all asyncio subprocess functions are asynchronous and asyncio " @@ -50,6 +79,16 @@ msgid "" "the above example to run several commands simultaneously::" msgstr "" +#: library/asyncio-subprocess.rst:51 +msgid "" +"async def main():\n" +" await asyncio.gather(\n" +" run('ls /zzz'),\n" +" run('sleep 1; echo \"hello\"'))\n" +"\n" +"asyncio.run(main())" +msgstr "" + #: library/asyncio-subprocess.rst:58 msgid "See also the `Examples`_ subsection." msgstr "" @@ -65,8 +104,8 @@ msgstr "" #: library/asyncio-subprocess.rst:69 library/asyncio-subprocess.rst:87 msgid "" "The *limit* argument sets the buffer limit for :class:`StreamReader` " -"wrappers for :attr:`Process.stdout` and :attr:`Process.stderr` (if :const:" -"`subprocess.PIPE` is passed to *stdout* and *stderr* arguments)." +"wrappers for :attr:`Process.stdout` and :attr:`Process.stderr` " +"(if :const:`subprocess.PIPE` is passed to *stdout* and *stderr* arguments)." msgstr "" #: library/asyncio-subprocess.rst:73 library/asyncio-subprocess.rst:91 @@ -110,11 +149,10 @@ msgstr "" #: library/asyncio-subprocess.rst:116 msgid "" -"asyncio also has the following *low-level* APIs to work with subprocesses: :" -"meth:`loop.subprocess_exec`, :meth:`loop.subprocess_shell`, :meth:`loop." -"connect_read_pipe`, :meth:`loop.connect_write_pipe`, as well as the :ref:" -"`Subprocess Transports ` and :ref:`Subprocess " -"Protocols `." +"asyncio also has the following *low-level* APIs to work with " +"subprocesses: :meth:`loop.subprocess_exec`, :meth:`loop.subprocess_shell`, :meth:`loop.connect_read_pipe`, :meth:`loop.connect_write_pipe`, " +"as well as the :ref:`Subprocess Transports ` " +"and :ref:`Subprocess Protocols `." msgstr "" #: library/asyncio-subprocess.rst:124 @@ -127,17 +165,17 @@ msgstr "" #: library/asyncio-subprocess.rst:131 msgid "" -"If *PIPE* is passed to *stdin* argument, the :attr:`Process.stdin ` attribute will point to a :class:`StreamWriter` " -"instance." +"If *PIPE* is passed to *stdin* argument, the :attr:`Process.stdin " +"` attribute will point to " +"a :class:`StreamWriter` instance." msgstr "" #: library/asyncio-subprocess.rst:135 msgid "" -"If *PIPE* is passed to *stdout* or *stderr* arguments, the :attr:`Process." -"stdout ` and :attr:`Process.stderr " -"` attributes will point to :class:" -"`StreamReader` instances." +"If *PIPE* is passed to *stdout* or *stderr* arguments, " +"the :attr:`Process.stdout ` " +"and :attr:`Process.stderr ` attributes " +"will point to :class:`StreamReader` instances." msgstr "" #: library/asyncio-subprocess.rst:143 @@ -149,8 +187,8 @@ msgstr "" #: library/asyncio-subprocess.rst:149 msgid "" "Special value that can be used as the *stdin*, *stdout* or *stderr* argument " -"to process creation functions. It indicates that the special file :data:`os." -"devnull` will be used for the corresponding subprocess stream." +"to process creation functions. It indicates that the special " +"file :data:`os.devnull` will be used for the corresponding subprocess stream." msgstr "" #: library/asyncio-subprocess.rst:155 @@ -167,27 +205,28 @@ msgstr "" #: library/asyncio-subprocess.rst:165 msgid "" -"An object that wraps OS processes created by the :func:" -"`create_subprocess_exec` and :func:`create_subprocess_shell` functions." +"An object that wraps OS processes created by " +"the :func:`create_subprocess_exec` and :func:`create_subprocess_shell` " +"functions." msgstr "" #: library/asyncio-subprocess.rst:169 msgid "" -"This class is designed to have a similar API to the :class:`subprocess." -"Popen` class, but there are some notable differences:" +"This class is designed to have a similar API to " +"the :class:`subprocess.Popen` class, but there are some notable differences:" msgstr "" #: library/asyncio-subprocess.rst:173 msgid "" -"unlike Popen, Process instances do not have an equivalent to the :meth:" -"`~subprocess.Popen.poll` method;" +"unlike Popen, Process instances do not have an equivalent to " +"the :meth:`~subprocess.Popen.poll` method;" msgstr "" #: library/asyncio-subprocess.rst:176 msgid "" -"the :meth:`~asyncio.subprocess.Process.communicate` and :meth:`~asyncio." -"subprocess.Process.wait` methods don't have a *timeout* parameter: use the :" -"func:`~asyncio.wait_for` function;" +"the :meth:`~asyncio.subprocess.Process.communicate` " +"and :meth:`~asyncio.subprocess.Process.wait` methods don't have a *timeout* " +"parameter: use the :func:`~asyncio.wait_for` function;" msgstr "" #: library/asyncio-subprocess.rst:180 @@ -391,8 +430,8 @@ msgstr "" #: library/asyncio-subprocess.rst:319 msgid "" -"On UNIX *child watchers* are used for subprocess finish waiting, see :ref:" -"`asyncio-watchers` for more info." +"On UNIX *child watchers* are used for subprocess finish waiting, " +"see :ref:`asyncio-watchers` for more info." msgstr "" #: library/asyncio-subprocess.rst:325 @@ -403,8 +442,8 @@ msgstr "" #: library/asyncio-subprocess.rst:328 msgid "" -"Spawning a subprocess with *inactive* current child watcher raises :exc:" -"`RuntimeError`." +"Spawning a subprocess with *inactive* current child watcher " +"raises :exc:`RuntimeError`." msgstr "" #: library/asyncio-subprocess.rst:331 @@ -435,6 +474,32 @@ msgid "" "The subprocess is created by the :func:`create_subprocess_exec` function::" msgstr "" +#: library/asyncio-subprocess.rst:352 +msgid "" +"import asyncio\n" +"import sys\n" +"\n" +"async def get_date():\n" +" code = 'import datetime; print(datetime.datetime.now())'\n" +"\n" +" # Create the subprocess; redirect the standard output\n" +" # into a pipe.\n" +" proc = await asyncio.create_subprocess_exec(\n" +" sys.executable, '-c', code,\n" +" stdout=asyncio.subprocess.PIPE)\n" +"\n" +" # Read one line of output.\n" +" data = await proc.stdout.readline()\n" +" line = data.decode('ascii').rstrip()\n" +"\n" +" # Wait for the subprocess exit.\n" +" await proc.wait()\n" +" return line\n" +"\n" +"date = asyncio.run(get_date())\n" +"print(f\"Current date: {date}\")" +msgstr "" + #: library/asyncio-subprocess.rst:376 msgid "" "See also the :ref:`same example ` written " diff --git a/library/asyncio-sync.po b/library/asyncio-sync.po index e0cb42ce..0312e497 100644 --- a/library/asyncio-sync.po +++ b/library/asyncio-sync.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -89,12 +90,33 @@ msgstr "" msgid "The preferred way to use a Lock is an :keyword:`async with` statement::" msgstr "" -#: library/asyncio-sync.rst:199 library/asyncio-sync.rst:298 +#: library/asyncio-sync.rst:50 +msgid "" +"lock = asyncio.Lock()\n" +"\n" +"# ... later\n" +"async with lock:\n" +" # access shared state" +msgstr "" + +#: library/asyncio-sync.rst:199 library/asyncio-sync.rst:299 msgid "which is equivalent to::" msgstr "" -#: library/asyncio-sync.rst:112 library/asyncio-sync.rst:286 -#: library/asyncio-sync.rst:341 +#: library/asyncio-sync.rst:58 +msgid "" +"lock = asyncio.Lock()\n" +"\n" +"# ... later\n" +"await lock.acquire()\n" +"try:\n" +" # access shared state\n" +"finally:\n" +" lock.release()" +msgstr "" + +#: library/asyncio-sync.rst:112 library/asyncio-sync.rst:287 +#: library/asyncio-sync.rst:342 msgid "Removed the *loop* parameter." msgstr "" @@ -152,16 +174,40 @@ msgstr "" #: library/asyncio-sync.rst:107 msgid "" -"An Event object manages an internal flag that can be set to *true* with the :" -"meth:`~Event.set` method and reset to *false* with the :meth:`clear` " +"An Event object manages an internal flag that can be set to *true* with " +"the :meth:`~Event.set` method and reset to *false* with the :meth:`clear` " "method. The :meth:`~Event.wait` method blocks until the flag is set to " "*true*. The flag is set to *false* initially." msgstr "" -#: library/asyncio-sync.rst:365 +#: library/asyncio-sync.rst:366 msgid "Example::" msgstr "" +#: library/asyncio-sync.rst:119 +msgid "" +"async def waiter(event):\n" +" print('waiting for it ...')\n" +" await event.wait()\n" +" print('... got it!')\n" +"\n" +"async def main():\n" +" # Create an Event object.\n" +" event = asyncio.Event()\n" +"\n" +" # Spawn a Task to wait until 'event' is set.\n" +" waiter_task = asyncio.create_task(waiter(event))\n" +"\n" +" # Sleep for 1 second and set the event.\n" +" await asyncio.sleep(1)\n" +" event.set()\n" +"\n" +" # Wait until the waiter task is finished.\n" +" await waiter_task\n" +"\n" +"asyncio.run(main())" +msgstr "" + #: library/asyncio-sync.rst:142 msgid "Wait until the event is set." msgstr "" @@ -186,8 +232,8 @@ msgstr "" #: library/asyncio-sync.rst:158 msgid "" -"Tasks awaiting on :meth:`~Event.wait` will now block until the :meth:`~Event." -"set` method is called again." +"Tasks awaiting on :meth:`~Event.wait` will now block until " +"the :meth:`~Event.set` method is called again." msgstr "" #: library/asyncio-sync.rst:163 @@ -210,11 +256,11 @@ msgstr "" #: library/asyncio-sync.rst:177 msgid "" -"In essence, a Condition object combines the functionality of an :class:" -"`Event` and a :class:`Lock`. It is possible to have multiple Condition " -"objects share one Lock, which allows coordinating exclusive access to a " -"shared resource between different tasks interested in particular states of " -"that shared resource." +"In essence, a Condition object combines the functionality of " +"an :class:`Event` and a :class:`Lock`. It is possible to have multiple " +"Condition objects share one Lock, which allows coordinating exclusive access " +"to a shared resource between different tasks interested in particular states " +"of that shared resource." msgstr "" #: library/asyncio-sync.rst:183 @@ -228,6 +274,27 @@ msgid "" "The preferred way to use a Condition is an :keyword:`async with` statement::" msgstr "" +#: library/asyncio-sync.rst:193 +msgid "" +"cond = asyncio.Condition()\n" +"\n" +"# ... later\n" +"async with cond:\n" +" await cond.wait()" +msgstr "" + +#: library/asyncio-sync.rst:201 +msgid "" +"cond = asyncio.Condition()\n" +"\n" +"# ... later\n" +"await cond.acquire()\n" +"try:\n" +" await cond.wait()\n" +"finally:\n" +" cond.release()" +msgstr "" + #: library/asyncio-sync.rst:212 msgid "Acquire the underlying lock." msgstr "" @@ -277,8 +344,8 @@ msgstr "" #: library/asyncio-sync.rst:252 msgid "" -"If the calling task has not acquired the lock when this method is called, a :" -"exc:`RuntimeError` is raised." +"If the calling task has not acquired the lock when this method is called, " +"a :exc:`RuntimeError` is raised." msgstr "" #: library/asyncio-sync.rst:255 @@ -295,177 +362,241 @@ msgstr "" #: library/asyncio-sync.rst:264 msgid "" "The predicate must be a callable which result will be interpreted as a " -"boolean value. The final value is the return value." +"boolean value. The method will repeatedly :meth:`~Condition.wait` until the " +"predicate evaluates to *true*. The final value is the return value." msgstr "" -#: library/asyncio-sync.rst:270 +#: library/asyncio-sync.rst:271 msgid "Semaphore" msgstr "" -#: library/asyncio-sync.rst:274 +#: library/asyncio-sync.rst:275 msgid "A Semaphore object. Not thread-safe." msgstr "" -#: library/asyncio-sync.rst:276 +#: library/asyncio-sync.rst:277 msgid "" -"A semaphore manages an internal counter which is decremented by each :meth:" -"`acquire` call and incremented by each :meth:`release` call. The counter can " -"never go below zero; when :meth:`acquire` finds that it is zero, it blocks, " -"waiting until some task calls :meth:`release`." +"A semaphore manages an internal counter which is decremented by " +"each :meth:`acquire` call and incremented by each :meth:`release` call. The " +"counter can never go below zero; when :meth:`acquire` finds that it is zero, " +"it blocks, waiting until some task calls :meth:`release`." msgstr "" -#: library/asyncio-sync.rst:282 +#: library/asyncio-sync.rst:283 msgid "" "The optional *value* argument gives the initial value for the internal " -"counter (``1`` by default). If the given value is less than ``0`` a :exc:" -"`ValueError` is raised." +"counter (``1`` by default). If the given value is less than ``0`` " +"a :exc:`ValueError` is raised." msgstr "" -#: library/asyncio-sync.rst:289 +#: library/asyncio-sync.rst:290 msgid "" "The preferred way to use a Semaphore is an :keyword:`async with` statement::" msgstr "" -#: library/asyncio-sync.rst:311 +#: library/asyncio-sync.rst:293 +msgid "" +"sem = asyncio.Semaphore(10)\n" +"\n" +"# ... later\n" +"async with sem:\n" +" # work with shared resource" +msgstr "" + +#: library/asyncio-sync.rst:301 +msgid "" +"sem = asyncio.Semaphore(10)\n" +"\n" +"# ... later\n" +"await sem.acquire()\n" +"try:\n" +" # work with shared resource\n" +"finally:\n" +" sem.release()" +msgstr "" + +#: library/asyncio-sync.rst:312 msgid "Acquire a semaphore." msgstr "" -#: library/asyncio-sync.rst:313 +#: library/asyncio-sync.rst:314 msgid "" "If the internal counter is greater than zero, decrement it by one and return " "``True`` immediately. If it is zero, wait until a :meth:`release` is called " "and return ``True``." msgstr "" -#: library/asyncio-sync.rst:319 +#: library/asyncio-sync.rst:320 msgid "Returns ``True`` if semaphore can not be acquired immediately." msgstr "" -#: library/asyncio-sync.rst:323 +#: library/asyncio-sync.rst:324 msgid "" "Release a semaphore, incrementing the internal counter by one. Can wake up a " "task waiting to acquire the semaphore." msgstr "" -#: library/asyncio-sync.rst:326 +#: library/asyncio-sync.rst:327 msgid "" "Unlike :class:`BoundedSemaphore`, :class:`Semaphore` allows making more " "``release()`` calls than ``acquire()`` calls." msgstr "" -#: library/asyncio-sync.rst:331 +#: library/asyncio-sync.rst:332 msgid "BoundedSemaphore" msgstr "" -#: library/asyncio-sync.rst:335 +#: library/asyncio-sync.rst:336 msgid "A bounded semaphore object. Not thread-safe." msgstr "" -#: library/asyncio-sync.rst:337 +#: library/asyncio-sync.rst:338 msgid "" -"Bounded Semaphore is a version of :class:`Semaphore` that raises a :exc:" -"`ValueError` in :meth:`~Semaphore.release` if it increases the internal " -"counter above the initial *value*." +"Bounded Semaphore is a version of :class:`Semaphore` that raises " +"a :exc:`ValueError` in :meth:`~Semaphore.release` if it increases the " +"internal counter above the initial *value*." msgstr "" -#: library/asyncio-sync.rst:346 +#: library/asyncio-sync.rst:347 msgid "Barrier" msgstr "" -#: library/asyncio-sync.rst:350 +#: library/asyncio-sync.rst:351 msgid "A barrier object. Not thread-safe." msgstr "" -#: library/asyncio-sync.rst:352 +#: library/asyncio-sync.rst:353 msgid "" "A barrier is a simple synchronization primitive that allows to block until " -"*parties* number of tasks are waiting on it. Tasks can wait on the :meth:" -"`~Barrier.wait` method and would be blocked until the specified number of " -"tasks end up waiting on :meth:`~Barrier.wait`. At that point all of the " -"waiting tasks would unblock simultaneously." +"*parties* number of tasks are waiting on it. Tasks can wait on " +"the :meth:`~Barrier.wait` method and would be blocked until the specified " +"number of tasks end up waiting on :meth:`~Barrier.wait`. At that point all " +"of the waiting tasks would unblock simultaneously." msgstr "" -#: library/asyncio-sync.rst:358 +#: library/asyncio-sync.rst:359 msgid "" -":keyword:`async with` can be used as an alternative to awaiting on :meth:" -"`~Barrier.wait`." +":keyword:`async with` can be used as an alternative to awaiting " +"on :meth:`~Barrier.wait`." msgstr "" -#: library/asyncio-sync.rst:361 +#: library/asyncio-sync.rst:362 msgid "The barrier can be reused any number of times." msgstr "" -#: library/asyncio-sync.rst:388 +#: library/asyncio-sync.rst:368 +msgid "" +"async def example_barrier():\n" +" # barrier with 3 parties\n" +" b = asyncio.Barrier(3)\n" +"\n" +" # create 2 new waiting tasks\n" +" asyncio.create_task(b.wait())\n" +" asyncio.create_task(b.wait())\n" +"\n" +" await asyncio.sleep(0)\n" +" print(b)\n" +"\n" +" # The third .wait() call passes the barrier\n" +" await b.wait()\n" +" print(b)\n" +" print(\"barrier passed\")\n" +"\n" +" await asyncio.sleep(0)\n" +" print(b)\n" +"\n" +"asyncio.run(example_barrier())" +msgstr "" + +#: library/asyncio-sync.rst:389 msgid "Result of this example is::" msgstr "" -#: library/asyncio-sync.rst:399 +#: library/asyncio-sync.rst:391 +msgid "" +"\n" +"\n" +"barrier passed\n" +"" +msgstr "" + +#: library/asyncio-sync.rst:400 msgid "" "Pass the barrier. When all the tasks party to the barrier have called this " "function, they are all unblocked simultaneously." msgstr "" -#: library/asyncio-sync.rst:402 +#: library/asyncio-sync.rst:403 msgid "" "When a waiting or blocked task in the barrier is cancelled, this task exits " "the barrier which stays in the same state. If the state of the barrier is " "\"filling\", the number of waiting task decreases by 1." msgstr "" -#: library/asyncio-sync.rst:407 +#: library/asyncio-sync.rst:408 msgid "" "The return value is an integer in the range of 0 to ``parties-1``, different " "for each task. This can be used to select a task to do some special " "housekeeping, e.g.::" msgstr "" -#: library/asyncio-sync.rst:417 +#: library/asyncio-sync.rst:412 +msgid "" +"...\n" +"async with barrier as position:\n" +" if position == 0:\n" +" # Only one task prints this\n" +" print('End of *draining phase*')" +msgstr "" + +#: library/asyncio-sync.rst:418 msgid "" "This method may raise a :class:`BrokenBarrierError` exception if the barrier " -"is broken or reset while a task is waiting. It could raise a :exc:" -"`CancelledError` if a task is cancelled." +"is broken or reset while a task is waiting. It could raise " +"a :exc:`CancelledError` if a task is cancelled." msgstr "" -#: library/asyncio-sync.rst:423 +#: library/asyncio-sync.rst:424 msgid "" "Return the barrier to the default, empty state. Any tasks waiting on it " "will receive the :class:`BrokenBarrierError` exception." msgstr "" -#: library/asyncio-sync.rst:426 +#: library/asyncio-sync.rst:427 msgid "" "If a barrier is broken it may be better to just leave it and create a new " "one." msgstr "" -#: library/asyncio-sync.rst:430 +#: library/asyncio-sync.rst:431 msgid "" "Put the barrier into a broken state. This causes any active or future calls " -"to :meth:`wait` to fail with the :class:`BrokenBarrierError`. Use this for " -"example if one of the tasks needs to abort, to avoid infinite waiting tasks." +"to :meth:`~Barrier.wait` to fail with the :class:`BrokenBarrierError`. Use " +"this for example if one of the tasks needs to abort, to avoid infinite " +"waiting tasks." msgstr "" -#: library/asyncio-sync.rst:437 +#: library/asyncio-sync.rst:438 msgid "The number of tasks required to pass the barrier." msgstr "" -#: library/asyncio-sync.rst:441 +#: library/asyncio-sync.rst:442 msgid "The number of tasks currently waiting in the barrier while filling." msgstr "" -#: library/asyncio-sync.rst:445 +#: library/asyncio-sync.rst:446 msgid "A boolean that is ``True`` if the barrier is in the broken state." msgstr "" -#: library/asyncio-sync.rst:450 +#: library/asyncio-sync.rst:451 msgid "" -"This exception, a subclass of :exc:`RuntimeError`, is raised when the :class:" -"`Barrier` object is reset or broken." +"This exception, a subclass of :exc:`RuntimeError`, is raised when " +"the :class:`Barrier` object is reset or broken." msgstr "" -#: library/asyncio-sync.rst:458 +#: library/asyncio-sync.rst:459 msgid "" -"Acquiring a lock using ``await lock`` or ``yield from lock`` and/or :keyword:" -"`with` statement (``with await lock``, ``with (yield from lock)``) was " -"removed. Use ``async with lock`` instead." +"Acquiring a lock using ``await lock`` or ``yield from lock`` and/" +"or :keyword:`with` statement (``with await lock``, ``with (yield from " +"lock)``) was removed. Use ``async with lock`` instead." msgstr "" diff --git a/library/asyncio-task.po b/library/asyncio-task.po index 59f36ed1..066b7841 100644 --- a/library/asyncio-task.po +++ b/library/asyncio-task.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -41,11 +42,31 @@ msgid "" "snippet of code prints \"hello\", waits 1 second, and then prints \"world\"::" msgstr "" +#: library/asyncio-task.rst:30 +msgid "" +">>> import asyncio\n" +"\n" +">>> async def main():\n" +"... print('hello')\n" +"... await asyncio.sleep(1)\n" +"... print('world')\n" +"\n" +">>> asyncio.run(main())\n" +"hello\n" +"world" +msgstr "" + #: library/asyncio-task.rst:41 msgid "" "Note that simply calling a coroutine will not schedule it to be executed::" msgstr "" +#: library/asyncio-task.rst:44 +msgid "" +">>> main()\n" +"" +msgstr "" + #: library/asyncio-task.rst:47 msgid "To actually run a coroutine, asyncio provides the following mechanisms:" msgstr "" @@ -63,10 +84,38 @@ msgid "" "*another* 2 seconds::" msgstr "" +#: library/asyncio-task.rst:56 +msgid "" +"import asyncio\n" +"import time\n" +"\n" +"async def say_after(delay, what):\n" +" await asyncio.sleep(delay)\n" +" print(what)\n" +"\n" +"async def main():\n" +" print(f\"started at {time.strftime('%X')}\")\n" +"\n" +" await say_after(1, 'hello')\n" +" await say_after(2, 'world')\n" +"\n" +" print(f\"finished at {time.strftime('%X')}\")\n" +"\n" +"asyncio.run(main())" +msgstr "" + #: library/asyncio-task.rst:73 msgid "Expected output::" msgstr "" +#: library/asyncio-task.rst:75 +msgid "" +"started at 17:13:52\n" +"hello\n" +"world\n" +"finished at 17:13:55" +msgstr "" + #: library/asyncio-task.rst:80 msgid "" "The :func:`asyncio.create_task` function to run coroutines concurrently as " @@ -79,16 +128,60 @@ msgid "" "*concurrently*::" msgstr "" +#: library/asyncio-task.rst:86 +msgid "" +"async def main():\n" +" task1 = asyncio.create_task(\n" +" say_after(1, 'hello'))\n" +"\n" +" task2 = asyncio.create_task(\n" +" say_after(2, 'world'))\n" +"\n" +" print(f\"started at {time.strftime('%X')}\")\n" +"\n" +" # Wait until both tasks are completed (should take\n" +" # around 2 seconds.)\n" +" await task1\n" +" await task2\n" +"\n" +" print(f\"finished at {time.strftime('%X')}\")" +msgstr "" + #: library/asyncio-task.rst:102 msgid "" "Note that expected output now shows that the snippet runs 1 second faster " "than before::" msgstr "" +#: library/asyncio-task.rst:105 +msgid "" +"started at 17:14:32\n" +"hello\n" +"world\n" +"finished at 17:14:34" +msgstr "" + #: library/asyncio-task.rst:110 msgid "" -"The :class:`asyncio.TaskGroup` class provides a more modern alternative to :" -"func:`create_task`. Using this API, the last example becomes::" +"The :class:`asyncio.TaskGroup` class provides a more modern alternative " +"to :func:`create_task`. Using this API, the last example becomes::" +msgstr "" + +#: library/asyncio-task.rst:114 +msgid "" +"async def main():\n" +" async with asyncio.TaskGroup() as tg:\n" +" task1 = tg.create_task(\n" +" say_after(1, 'hello'))\n" +"\n" +" task2 = tg.create_task(\n" +" say_after(2, 'world'))\n" +"\n" +" print(f\"started at {time.strftime('%X')}\")\n" +"\n" +" # The await is implicit when the context manager exits.\n" +"\n" +" print(f\"finished at {time.strftime('%X')}\")" msgstr "" #: library/asyncio-task.rst:128 @@ -105,8 +198,8 @@ msgstr "" #: library/asyncio-task.rst:139 msgid "" -"We say that an object is an **awaitable** object if it can be used in an :" -"keyword:`await` expression. Many asyncio APIs are designed to accept " +"We say that an object is an **awaitable** object if it can be used in " +"an :keyword:`await` expression. Many asyncio APIs are designed to accept " "awaitables." msgstr "" @@ -122,6 +215,25 @@ msgid "" "coroutines::" msgstr "" +#: library/asyncio-task.rst:152 +msgid "" +"import asyncio\n" +"\n" +"async def nested():\n" +" return 42\n" +"\n" +"async def main():\n" +" # Nothing happens if we just call \"nested()\".\n" +" # A coroutine object is created but not awaited,\n" +" # so it *won't run at all*.\n" +" nested() # will raise a \"RuntimeWarning\".\n" +"\n" +" # Let's do it differently now and await it:\n" +" print(await nested()) # will print \"42\".\n" +"\n" +"asyncio.run(main())" +msgstr "" + #: library/asyncio-task.rst:170 msgid "" "In this documentation the term \"coroutine\" can be used for two closely " @@ -147,8 +259,28 @@ msgstr "" #: library/asyncio-task.rst:183 msgid "" -"When a coroutine is wrapped into a *Task* with functions like :func:`asyncio." -"create_task` the coroutine is automatically scheduled to run soon::" +"When a coroutine is wrapped into a *Task* with functions " +"like :func:`asyncio.create_task` the coroutine is automatically scheduled to " +"run soon::" +msgstr "" + +#: library/asyncio-task.rst:187 +msgid "" +"import asyncio\n" +"\n" +"async def nested():\n" +" return 42\n" +"\n" +"async def main():\n" +" # Schedule nested() to run soon concurrently\n" +" # with \"main()\".\n" +" task = asyncio.create_task(nested())\n" +"\n" +" # \"task\" can now be used to cancel \"nested()\", or\n" +" # can simply be awaited to wait until it is complete:\n" +" await task\n" +"\n" +"asyncio.run(main())" msgstr "" #: library/asyncio-task.rst:205 @@ -185,10 +317,22 @@ msgid "" "awaited::" msgstr "" +#: library/asyncio-task.rst:221 +msgid "" +"async def main():\n" +" await function_that_returns_a_future_object()\n" +"\n" +" # this is also valid:\n" +" await asyncio.gather(\n" +" function_that_returns_a_future_object(),\n" +" some_python_coroutine()\n" +" )" +msgstr "" + #: library/asyncio-task.rst:230 msgid "" -"A good example of a low-level function that returns a Future object is :meth:" -"`loop.run_in_executor`." +"A good example of a low-level function that returns a Future object " +"is :meth:`loop.run_in_executor`." msgstr "" #: library/asyncio-task.rst:235 @@ -207,21 +351,22 @@ msgstr "" #: library/asyncio-task.rst:246 msgid "" -"If *name* is not ``None``, it is set as the name of the task using :meth:" -"`Task.set_name`." +"If *name* is not ``None``, it is set as the name of the task " +"using :meth:`Task.set_name`." msgstr "" #: library/asyncio-task.rst:249 msgid "" -"An optional keyword-only *context* argument allows specifying a custom :" -"class:`contextvars.Context` for the *coro* to run in. The current context " -"copy is created when no *context* is provided." +"An optional keyword-only *context* argument allows specifying a " +"custom :class:`contextvars.Context` for the *coro* to run in. The current " +"context copy is created when no *context* is provided." msgstr "" #: library/asyncio-task.rst:253 msgid "" -"The task is executed in the loop returned by :func:`get_running_loop`, :exc:" -"`RuntimeError` is raised if there is no running loop in current thread." +"The task is executed in the loop returned " +"by :func:`get_running_loop`, :exc:`RuntimeError` is raised if there is no " +"running loop in current thread." msgstr "" #: library/asyncio-task.rst:259 @@ -240,11 +385,27 @@ msgid "" "tasks, gather them in a collection::" msgstr "" -#: library/asyncio-task.rst:1075 +#: library/asyncio-task.rst:272 +msgid "" +"background_tasks = set()\n" +"\n" +"for i in range(10):\n" +" task = asyncio.create_task(some_coro(param=i))\n" +"\n" +" # Add task to the set. This creates a strong reference.\n" +" background_tasks.add(task)\n" +"\n" +" # To prevent keeping references to finished tasks forever,\n" +" # make each task remove its own reference from the set after\n" +" # completion:\n" +" task.add_done_callback(background_tasks.discard)" +msgstr "" + +#: library/asyncio-task.rst:1122 msgid "Added the *name* parameter." msgstr "" -#: library/asyncio-task.rst:1082 +#: library/asyncio-task.rst:1129 msgid "Added the *context* parameter." msgstr "" @@ -254,28 +415,30 @@ msgstr "" #: library/asyncio-task.rst:297 msgid "" -"Tasks can easily and safely be cancelled. When a task is cancelled, :exc:" -"`asyncio.CancelledError` will be raised in the task at the next opportunity." +"Tasks can easily and safely be cancelled. When a task is " +"cancelled, :exc:`asyncio.CancelledError` will be raised in the task at the " +"next opportunity." msgstr "" #: library/asyncio-task.rst:301 msgid "" "It is recommended that coroutines use ``try/finally`` blocks to robustly " "perform clean-up logic. In case :exc:`asyncio.CancelledError` is explicitly " -"caught, it should generally be propagated when clean-up is complete. :exc:" -"`asyncio.CancelledError` directly subclasses :exc:`BaseException` so most " -"code will not need to be aware of it." +"caught, it should generally be propagated when clean-up is " +"complete. :exc:`asyncio.CancelledError` directly " +"subclasses :exc:`BaseException` so most code will not need to be aware of it." msgstr "" #: library/asyncio-task.rst:307 msgid "" -"The asyncio components that enable structured concurrency, like :class:" -"`asyncio.TaskGroup` and :func:`asyncio.timeout`, are implemented using " -"cancellation internally and might misbehave if a coroutine swallows :exc:" -"`asyncio.CancelledError`. Similarly, user code should not generally call :" -"meth:`uncancel `. However, in cases when suppressing :" -"exc:`asyncio.CancelledError` is truly desired, it is necessary to also call " -"``uncancel()`` to completely remove the cancellation state." +"The asyncio components that enable structured concurrency, " +"like :class:`asyncio.TaskGroup` and :func:`asyncio.timeout`, are implemented " +"using cancellation internally and might misbehave if a coroutine " +"swallows :exc:`asyncio.CancelledError`. Similarly, user code should not " +"generally call :meth:`uncancel `. However, in cases " +"when suppressing :exc:`asyncio.CancelledError` is truly desired, it is " +"necessary to also call ``uncancel()`` to completely remove the cancellation " +"state." msgstr "" #: library/asyncio-task.rst:319 @@ -297,15 +460,25 @@ msgstr "" #: library/asyncio-task.rst:335 msgid "" -"Create a task in this task group. The signature matches that of :func:" -"`asyncio.create_task`." +"Create a task in this task group. The signature matches that " +"of :func:`asyncio.create_task`." msgstr "" -#: library/asyncio-task.rst:472 library/asyncio-task.rst:703 -#: library/asyncio-task.rst:769 library/asyncio-task.rst:868 +#: library/asyncio-task.rst:519 library/asyncio-task.rst:750 +#: library/asyncio-task.rst:816 library/asyncio-task.rst:915 msgid "Example::" msgstr "" +#: library/asyncio-task.rst:340 +msgid "" +"async def main():\n" +" async with asyncio.TaskGroup() as tg:\n" +" task1 = tg.create_task(some_coro(...))\n" +" task2 = tg.create_task(another_coro(...))\n" +" print(f\"Both tasks have completed now: {task1.result()}, " +"{task2.result()}\")" +msgstr "" + #: library/asyncio-task.rst:346 msgid "" "The ``async with`` statement will wait for all tasks in the group to finish. " @@ -320,11 +493,11 @@ msgid "" "The first time any of the tasks belonging to the group fails with an " "exception other than :exc:`asyncio.CancelledError`, the remaining tasks in " "the group are cancelled. No further tasks can then be added to the group. At " -"this point, if the body of the ``async with`` statement is still active (i." -"e., :meth:`~object.__aexit__` hasn't been called yet), the task directly " -"containing the ``async with`` statement is also cancelled. The resulting :" -"exc:`asyncio.CancelledError` will interrupt an ``await``, but it will not " -"bubble out of the containing ``async with`` statement." +"this point, if the body of the ``async with`` statement is still active " +"(i.e., :meth:`~object.__aexit__` hasn't been called yet), the task directly " +"containing the ``async with`` statement is also cancelled. The " +"resulting :exc:`asyncio.CancelledError` will interrupt an ``await``, but it " +"will not bubble out of the containing ``async with`` statement." msgstr "" #: library/asyncio-task.rst:363 @@ -337,85 +510,158 @@ msgstr "" #: library/asyncio-task.rst:370 msgid "" -"Two base exceptions are treated specially: If any task fails with :exc:" -"`KeyboardInterrupt` or :exc:`SystemExit`, the task group still cancels the " -"remaining tasks and waits for them, but then the initial :exc:" -"`KeyboardInterrupt` or :exc:`SystemExit` is re-raised instead of :exc:" -"`ExceptionGroup` or :exc:`BaseExceptionGroup`." +"Two base exceptions are treated specially: If any task fails " +"with :exc:`KeyboardInterrupt` or :exc:`SystemExit`, the task group still " +"cancels the remaining tasks and waits for them, but then the " +"initial :exc:`KeyboardInterrupt` or :exc:`SystemExit` is re-raised instead " +"of :exc:`ExceptionGroup` or :exc:`BaseExceptionGroup`." msgstr "" #: library/asyncio-task.rst:376 msgid "" -"If the body of the ``async with`` statement exits with an exception (so :" -"meth:`~object.__aexit__` is called with an exception set), this is treated " -"the same as if one of the tasks failed: the remaining tasks are cancelled " -"and then waited for, and non-cancellation exceptions are grouped into an " -"exception group and raised. The exception passed into :meth:`~object." -"__aexit__`, unless it is :exc:`asyncio.CancelledError`, is also included in " -"the exception group. The same special case is made for :exc:" -"`KeyboardInterrupt` and :exc:`SystemExit` as in the previous paragraph." +"If the body of the ``async with`` statement exits with an exception " +"(so :meth:`~object.__aexit__` is called with an exception set), this is " +"treated the same as if one of the tasks failed: the remaining tasks are " +"cancelled and then waited for, and non-cancellation exceptions are grouped " +"into an exception group and raised. The exception passed " +"into :meth:`~object.__aexit__`, unless it is :exc:`asyncio.CancelledError`, " +"is also included in the exception group. The same special case is made " +"for :exc:`KeyboardInterrupt` and :exc:`SystemExit` as in the previous " +"paragraph." msgstr "" #: library/asyncio-task.rst:390 +msgid "Terminating a Task Group" +msgstr "" + +#: library/asyncio-task.rst:392 +msgid "" +"While terminating a task group is not natively supported by the standard " +"library, termination can be achieved by adding an exception-raising task to " +"the task group and ignoring the raised exception:" +msgstr "" + +#: library/asyncio-task.rst:396 +msgid "" +"import asyncio\n" +"from asyncio import TaskGroup\n" +"\n" +"class TerminateTaskGroup(Exception):\n" +" \"\"\"Exception raised to terminate a task group.\"\"\"\n" +"\n" +"async def force_terminate_task_group():\n" +" \"\"\"Used to force termination of a task group.\"\"\"\n" +" raise TerminateTaskGroup()\n" +"\n" +"async def job(task_id, sleep_time):\n" +" print(f'Task {task_id}: start')\n" +" await asyncio.sleep(sleep_time)\n" +" print(f'Task {task_id}: done')\n" +"\n" +"async def main():\n" +" try:\n" +" async with TaskGroup() as group:\n" +" # spawn some tasks\n" +" group.create_task(job(1, 0.5))\n" +" group.create_task(job(2, 1.5))\n" +" # sleep for 1 second\n" +" await asyncio.sleep(1)\n" +" # add an exception-raising task to force the group to terminate\n" +" group.create_task(force_terminate_task_group())\n" +" except* TerminateTaskGroup:\n" +" pass\n" +"\n" +"asyncio.run(main())" +msgstr "" + +#: library/asyncio-task.rst:428 +msgid "Expected output:" +msgstr "" + +#: library/asyncio-task.rst:430 +msgid "" +"Task 1: start\n" +"Task 2: start\n" +"Task 1: done" +msgstr "" + +#: library/asyncio-task.rst:437 msgid "Sleeping" msgstr "" -#: library/asyncio-task.rst:394 +#: library/asyncio-task.rst:441 msgid "Block for *delay* seconds." msgstr "" -#: library/asyncio-task.rst:396 +#: library/asyncio-task.rst:443 msgid "" "If *result* is provided, it is returned to the caller when the coroutine " "completes." msgstr "" -#: library/asyncio-task.rst:399 +#: library/asyncio-task.rst:446 msgid "" "``sleep()`` always suspends the current task, allowing other tasks to run." msgstr "" -#: library/asyncio-task.rst:402 +#: library/asyncio-task.rst:449 msgid "" "Setting the delay to 0 provides an optimized path to allow other tasks to " "run. This can be used by long-running functions to avoid blocking the event " "loop for the full duration of the function call." msgstr "" -#: library/asyncio-task.rst:408 +#: library/asyncio-task.rst:455 msgid "" "Example of coroutine displaying the current date every second for 5 seconds::" msgstr "" -#: library/asyncio-task.rst:521 library/asyncio-task.rst:794 -#: library/asyncio-task.rst:874 +#: library/asyncio-task.rst:458 +msgid "" +"import asyncio\n" +"import datetime\n" +"\n" +"async def display_date():\n" +" loop = asyncio.get_running_loop()\n" +" end_time = loop.time() + 5.0\n" +" while True:\n" +" print(datetime.datetime.now())\n" +" if (loop.time() + 1.0) >= end_time:\n" +" break\n" +" await asyncio.sleep(1)\n" +"\n" +"asyncio.run(display_date())" +msgstr "" + +#: library/asyncio-task.rst:568 library/asyncio-task.rst:841 +#: library/asyncio-task.rst:921 msgid "Removed the *loop* parameter." msgstr "" -#: library/asyncio-task.rst:431 +#: library/asyncio-task.rst:478 msgid "Running Tasks Concurrently" msgstr "" -#: library/asyncio-task.rst:435 +#: library/asyncio-task.rst:482 msgid "" "Run :ref:`awaitable objects ` in the *aws* sequence " "*concurrently*." msgstr "" -#: library/asyncio-task.rst:438 +#: library/asyncio-task.rst:485 msgid "" "If any awaitable in *aws* is a coroutine, it is automatically scheduled as a " "Task." msgstr "" -#: library/asyncio-task.rst:441 +#: library/asyncio-task.rst:488 msgid "" "If all awaitables are completed successfully, the result is an aggregate " "list of returned values. The order of result values corresponds to the " "order of awaitables in *aws*." msgstr "" -#: library/asyncio-task.rst:445 +#: library/asyncio-task.rst:492 msgid "" "If *return_exceptions* is ``False`` (default), the first raised exception is " "immediately propagated to the task that awaits on ``gather()``. Other " @@ -423,19 +669,19 @@ msgid "" "run." msgstr "" -#: library/asyncio-task.rst:450 +#: library/asyncio-task.rst:497 msgid "" "If *return_exceptions* is ``True``, exceptions are treated the same as " "successful results, and aggregated in the result list." msgstr "" -#: library/asyncio-task.rst:453 +#: library/asyncio-task.rst:500 msgid "" "If ``gather()`` is *cancelled*, all submitted awaitables (that have not " "completed yet) are also *cancelled*." msgstr "" -#: library/asyncio-task.rst:456 +#: library/asyncio-task.rst:503 msgid "" "If any Task or Future from the *aws* sequence is *cancelled*, it is treated " "as if it raised :exc:`CancelledError` -- the ``gather()`` call is **not** " @@ -443,7 +689,7 @@ msgid "" "submitted Task/Future to cause other Tasks/Futures to be cancelled." msgstr "" -#: library/asyncio-task.rst:463 +#: library/asyncio-task.rst:510 msgid "" "A new alternative to create and run tasks concurrently and wait for their " "completion is :class:`asyncio.TaskGroup`. *TaskGroup* provides stronger " @@ -453,53 +699,92 @@ msgid "" "tasks)." msgstr "" -#: library/asyncio-task.rst:510 -msgid "" -"If *return_exceptions* is False, cancelling gather() after it has been " +#: library/asyncio-task.rst:521 +msgid "" +"import asyncio\n" +"\n" +"async def factorial(name, number):\n" +" f = 1\n" +" for i in range(2, number + 1):\n" +" print(f\"Task {name}: Compute factorial({number}), currently i={i}..." +"\")\n" +" await asyncio.sleep(1)\n" +" f *= i\n" +" print(f\"Task {name}: factorial({number}) = {f}\")\n" +" return f\n" +"\n" +"async def main():\n" +" # Schedule three calls *concurrently*:\n" +" L = await asyncio.gather(\n" +" factorial(\"A\", 2),\n" +" factorial(\"B\", 3),\n" +" factorial(\"C\", 4),\n" +" )\n" +" print(L)\n" +"\n" +"asyncio.run(main())\n" +"\n" +"# Expected output:\n" +"#\n" +"# Task A: Compute factorial(2), currently i=2...\n" +"# Task B: Compute factorial(3), currently i=2...\n" +"# Task C: Compute factorial(4), currently i=2...\n" +"# Task A: factorial(2) = 2\n" +"# Task B: Compute factorial(3), currently i=3...\n" +"# Task C: Compute factorial(4), currently i=3...\n" +"# Task B: factorial(3) = 6\n" +"# Task C: Compute factorial(4), currently i=4...\n" +"# Task C: factorial(4) = 24\n" +"# [2, 6, 24]" +msgstr "" + +#: library/asyncio-task.rst:557 +msgid "" +"If *return_exceptions* is false, cancelling gather() after it has been " "marked done won't cancel any submitted awaitables. For instance, gather can " "be marked done after propagating an exception to the caller, therefore, " "calling ``gather.cancel()`` after catching an exception (raised by one of " "the awaitables) from gather won't cancel any other awaitables." msgstr "" -#: library/asyncio-task.rst:517 +#: library/asyncio-task.rst:564 msgid "" "If the *gather* itself is cancelled, the cancellation is propagated " "regardless of *return_exceptions*." msgstr "" -#: library/asyncio-task.rst:524 +#: library/asyncio-task.rst:571 msgid "" "Deprecation warning is emitted if no positional arguments are provided or " "not all positional arguments are Future-like objects and there is no running " "event loop." msgstr "" -#: library/asyncio-task.rst:533 +#: library/asyncio-task.rst:580 msgid "Eager Task Factory" msgstr "" -#: library/asyncio-task.rst:537 +#: library/asyncio-task.rst:584 msgid "A task factory for eager task execution." msgstr "" -#: library/asyncio-task.rst:539 +#: library/asyncio-task.rst:586 msgid "" -"When using this factory (via :meth:`loop.set_task_factory(asyncio." -"eager_task_factory) `), coroutines begin execution " -"synchronously during :class:`Task` construction. Tasks are only scheduled on " -"the event loop if they block. This can be a performance improvement as the " -"overhead of loop scheduling is avoided for coroutines that complete " -"synchronously." +"When using this factory " +"(via :meth:`loop.set_task_factory(asyncio.eager_task_factory) " +"`), coroutines begin execution synchronously " +"during :class:`Task` construction. Tasks are only scheduled on the event " +"loop if they block. This can be a performance improvement as the overhead of " +"loop scheduling is avoided for coroutines that complete synchronously." msgstr "" -#: library/asyncio-task.rst:545 +#: library/asyncio-task.rst:592 msgid "" "A common example where this is beneficial is coroutines which employ caching " "or memoization to avoid actual I/O when possible." msgstr "" -#: library/asyncio-task.rst:550 +#: library/asyncio-task.rst:597 msgid "" "Immediate execution of the coroutine is a semantic change. If the coroutine " "returns or raises, the task is never scheduled to the event loop. If the " @@ -508,72 +793,91 @@ msgid "" "the application's task execution order is likely to change." msgstr "" -#: library/asyncio-task.rst:561 +#: library/asyncio-task.rst:608 msgid "" "Create an eager task factory, similar to :func:`eager_task_factory`, using " "the provided *custom_task_constructor* when creating a new task instead of " "the default :class:`Task`." msgstr "" -#: library/asyncio-task.rst:565 +#: library/asyncio-task.rst:612 msgid "" "*custom_task_constructor* must be a *callable* with the signature matching " -"the signature of :class:`Task.__init__ `. The callable must return a :" -"class:`asyncio.Task`-compatible object." +"the signature of :class:`Task.__init__ `. The callable must return " +"a :class:`asyncio.Task`-compatible object." msgstr "" -#: library/asyncio-task.rst:569 +#: library/asyncio-task.rst:616 msgid "" "This function returns a *callable* intended to be used as a task factory of " -"an event loop via :meth:`loop.set_task_factory(factory) `)." +"an event loop via :meth:`loop.set_task_factory(factory) " +"`)." msgstr "" -#: library/asyncio-task.rst:576 +#: library/asyncio-task.rst:623 msgid "Shielding From Cancellation" msgstr "" -#: library/asyncio-task.rst:580 +#: library/asyncio-task.rst:627 msgid "" -"Protect an :ref:`awaitable object ` from being :meth:" -"`cancelled `." +"Protect an :ref:`awaitable object ` from " +"being :meth:`cancelled `." msgstr "" -#: library/asyncio-task.rst:749 +#: library/asyncio-task.rst:796 msgid "If *aw* is a coroutine it is automatically scheduled as a Task." msgstr "" -#: library/asyncio-task.rst:585 +#: library/asyncio-task.rst:632 msgid "The statement::" msgstr "" -#: library/asyncio-task.rst:590 +#: library/asyncio-task.rst:634 +msgid "" +"task = asyncio.create_task(something())\n" +"res = await shield(task)" +msgstr "" + +#: library/asyncio-task.rst:637 msgid "is equivalent to::" msgstr "" -#: library/asyncio-task.rst:594 +#: library/asyncio-task.rst:639 +msgid "res = await something()" +msgstr "" + +#: library/asyncio-task.rst:641 msgid "" "*except* that if the coroutine containing it is cancelled, the Task running " "in ``something()`` is not cancelled. From the point of view of " "``something()``, the cancellation did not happen. Although its caller is " -"still cancelled, so the \"await\" expression still raises a :exc:" -"`CancelledError`." +"still cancelled, so the \"await\" expression still raises " +"a :exc:`CancelledError`." msgstr "" -#: library/asyncio-task.rst:600 +#: library/asyncio-task.rst:647 msgid "" "If ``something()`` is cancelled by other means (i.e. from within itself) " "that would also cancel ``shield()``." msgstr "" -#: library/asyncio-task.rst:603 +#: library/asyncio-task.rst:650 msgid "" "If it is desired to completely ignore cancellation (not recommended) the " "``shield()`` function should be combined with a try/except clause, as " "follows::" msgstr "" -#: library/asyncio-task.rst:615 +#: library/asyncio-task.rst:654 +msgid "" +"task = asyncio.create_task(something())\n" +"try:\n" +" res = await shield(task)\n" +"except CancelledError:\n" +" res = None" +msgstr "" + +#: library/asyncio-task.rst:662 msgid "" "Save a reference to tasks passed to this function, to avoid a task " "disappearing mid-execution. The event loop only keeps weak references to " @@ -581,229 +885,305 @@ msgid "" "any time, even before it's done." msgstr "" -#: library/asyncio-task.rst:623 +#: library/asyncio-task.rst:670 msgid "" "Deprecation warning is emitted if *aw* is not Future-like object and there " "is no running event loop." msgstr "" -#: library/asyncio-task.rst:629 +#: library/asyncio-task.rst:676 msgid "Timeouts" msgstr "" -#: library/asyncio-task.rst:633 +#: library/asyncio-task.rst:680 msgid "" "Return an :ref:`asynchronous context manager ` that " "can be used to limit the amount of time spent waiting on something." msgstr "" -#: library/asyncio-task.rst:637 +#: library/asyncio-task.rst:684 msgid "" "*delay* can either be ``None``, or a float/int number of seconds to wait. If " "*delay* is ``None``, no time limit will be applied; this can be useful if " "the delay is unknown when the context manager is created." msgstr "" -#: library/asyncio-task.rst:642 +#: library/asyncio-task.rst:689 +msgid "" +"In either case, the context manager can be rescheduled after creation " +"using :meth:`Timeout.reschedule`." +msgstr "" + +#: library/asyncio-task.rst:694 msgid "" -"In either case, the context manager can be rescheduled after creation using :" -"meth:`Timeout.reschedule`." +"async def main():\n" +" async with asyncio.timeout(10):\n" +" await long_running_task()" msgstr "" -#: library/asyncio-task.rst:651 +#: library/asyncio-task.rst:698 msgid "" "If ``long_running_task`` takes more than 10 seconds to complete, the context " -"manager will cancel the current task and handle the resulting :exc:`asyncio." -"CancelledError` internally, transforming it into a :exc:`TimeoutError` which " -"can be caught and handled." +"manager will cancel the current task and handle the " +"resulting :exc:`asyncio.CancelledError` internally, transforming it into " +"a :exc:`TimeoutError` which can be caught and handled." msgstr "" -#: library/asyncio-task.rst:658 +#: library/asyncio-task.rst:705 msgid "" -"The :func:`asyncio.timeout` context manager is what transforms the :exc:" -"`asyncio.CancelledError` into a :exc:`TimeoutError`, which means the :exc:" -"`TimeoutError` can only be caught *outside* of the context manager." +"The :func:`asyncio.timeout` context manager is what transforms " +"the :exc:`asyncio.CancelledError` into a :exc:`TimeoutError`, which means " +"the :exc:`TimeoutError` can only be caught *outside* of the context manager." msgstr "" -#: library/asyncio-task.rst:663 +#: library/asyncio-task.rst:710 msgid "Example of catching :exc:`TimeoutError`::" msgstr "" -#: library/asyncio-task.rst:674 +#: library/asyncio-task.rst:712 +msgid "" +"async def main():\n" +" try:\n" +" async with asyncio.timeout(10):\n" +" await long_running_task()\n" +" except TimeoutError:\n" +" print(\"The long operation timed out, but we've handled it.\")\n" +"\n" +" print(\"This statement will run regardless.\")" +msgstr "" + +#: library/asyncio-task.rst:721 msgid "" "The context manager produced by :func:`asyncio.timeout` can be rescheduled " "to a different deadline and inspected." msgstr "" -#: library/asyncio-task.rst:679 +#: library/asyncio-task.rst:726 msgid "" "An :ref:`asynchronous context manager ` for " "cancelling overdue coroutines." msgstr "" -#: library/asyncio-task.rst:682 +#: library/asyncio-task.rst:729 msgid "" "``when`` should be an absolute time at which the context should time out, as " "measured by the event loop's clock:" msgstr "" -#: library/asyncio-task.rst:685 +#: library/asyncio-task.rst:732 msgid "If ``when`` is ``None``, the timeout will never trigger." msgstr "" -#: library/asyncio-task.rst:686 +#: library/asyncio-task.rst:733 msgid "" "If ``when < loop.time()``, the timeout will trigger on the next iteration of " "the event loop." msgstr "" -#: library/asyncio-task.rst:691 +#: library/asyncio-task.rst:738 msgid "" "Return the current deadline, or ``None`` if the current deadline is not set." msgstr "" -#: library/asyncio-task.rst:696 +#: library/asyncio-task.rst:743 msgid "Reschedule the timeout." msgstr "" -#: library/asyncio-task.rst:700 +#: library/asyncio-task.rst:747 msgid "Return whether the context manager has exceeded its deadline (expired)." msgstr "" -#: library/asyncio-task.rst:720 +#: library/asyncio-task.rst:752 +msgid "" +"async def main():\n" +" try:\n" +" # We do not know the timeout when starting, so we pass ``None``.\n" +" async with asyncio.timeout(None) as cm:\n" +" # We know the timeout now, so we reschedule it.\n" +" new_deadline = get_running_loop().time() + 10\n" +" cm.reschedule(new_deadline)\n" +"\n" +" await long_running_task()\n" +" except TimeoutError:\n" +" pass\n" +"\n" +" if cm.expired():\n" +" print(\"Looks like we haven't finished on time.\")" +msgstr "" + +#: library/asyncio-task.rst:767 msgid "Timeout context managers can be safely nested." msgstr "" -#: library/asyncio-task.rst:726 +#: library/asyncio-task.rst:773 msgid "" "Similar to :func:`asyncio.timeout`, except *when* is the absolute time to " "stop waiting, or ``None``." msgstr "" -#: library/asyncio-task.rst:746 +#: library/asyncio-task.rst:778 +msgid "" +"async def main():\n" +" loop = get_running_loop()\n" +" deadline = loop.time() + 20\n" +" try:\n" +" async with asyncio.timeout_at(deadline):\n" +" await long_running_task()\n" +" except TimeoutError:\n" +" print(\"The long operation timed out, but we've handled it.\")\n" +"\n" +" print(\"This statement will run regardless.\")" +msgstr "" + +#: library/asyncio-task.rst:793 msgid "" "Wait for the *aw* :ref:`awaitable ` to complete with a " "timeout." msgstr "" -#: library/asyncio-task.rst:751 +#: library/asyncio-task.rst:798 msgid "" "*timeout* can either be ``None`` or a float or int number of seconds to wait " "for. If *timeout* is ``None``, block until the future completes." msgstr "" -#: library/asyncio-task.rst:755 +#: library/asyncio-task.rst:802 msgid "" "If a timeout occurs, it cancels the task and raises :exc:`TimeoutError`." msgstr "" -#: library/asyncio-task.rst:758 +#: library/asyncio-task.rst:805 msgid "" -"To avoid the task :meth:`cancellation `, wrap it in :func:" -"`shield`." +"To avoid the task :meth:`cancellation `, wrap it " +"in :func:`shield`." msgstr "" -#: library/asyncio-task.rst:761 +#: library/asyncio-task.rst:808 msgid "" "The function will wait until the future is actually cancelled, so the total " "wait time may exceed the *timeout*. If an exception happens during " "cancellation, it is propagated." msgstr "" -#: library/asyncio-task.rst:765 +#: library/asyncio-task.rst:812 msgid "If the wait is cancelled, the future *aw* is also cancelled." msgstr "" -#: library/asyncio-task.rst:789 +#: library/asyncio-task.rst:818 +msgid "" +"async def eternity():\n" +" # Sleep for one hour\n" +" await asyncio.sleep(3600)\n" +" print('yay!')\n" +"\n" +"async def main():\n" +" # Wait for at most 1 second\n" +" try:\n" +" await asyncio.wait_for(eternity(), timeout=1.0)\n" +" except TimeoutError:\n" +" print('timeout!')\n" +"\n" +"asyncio.run(main())\n" +"\n" +"# Expected output:\n" +"#\n" +"# timeout!" +msgstr "" + +#: library/asyncio-task.rst:836 msgid "" "When *aw* is cancelled due to a timeout, ``wait_for`` waits for *aw* to be " "cancelled. Previously, it raised :exc:`TimeoutError` immediately." msgstr "" -#: library/asyncio-task.rst:797 +#: library/asyncio-task.rst:844 msgid "Raises :exc:`TimeoutError` instead of :exc:`asyncio.TimeoutError`." msgstr "" -#: library/asyncio-task.rst:802 +#: library/asyncio-task.rst:849 msgid "Waiting Primitives" msgstr "" -#: library/asyncio-task.rst:806 +#: library/asyncio-task.rst:853 msgid "" "Run :class:`~asyncio.Future` and :class:`~asyncio.Task` instances in the " "*aws* iterable concurrently and block until the condition specified by " "*return_when*." msgstr "" -#: library/asyncio-task.rst:810 +#: library/asyncio-task.rst:857 msgid "The *aws* iterable must not be empty." msgstr "" -#: library/asyncio-task.rst:812 +#: library/asyncio-task.rst:859 msgid "Returns two sets of Tasks/Futures: ``(done, pending)``." msgstr "" -#: library/asyncio-task.rst:814 +#: library/asyncio-task.rst:861 msgid "Usage::" msgstr "" -#: library/asyncio-task.rst:818 +#: library/asyncio-task.rst:863 +msgid "done, pending = await asyncio.wait(aws)" +msgstr "" + +#: library/asyncio-task.rst:865 msgid "" "*timeout* (a float or int), if specified, can be used to control the maximum " "number of seconds to wait before returning." msgstr "" -#: library/asyncio-task.rst:821 +#: library/asyncio-task.rst:868 msgid "" "Note that this function does not raise :exc:`TimeoutError`. Futures or Tasks " "that aren't done when the timeout occurs are simply returned in the second " "set." msgstr "" -#: library/asyncio-task.rst:825 +#: library/asyncio-task.rst:872 msgid "" "*return_when* indicates when this function should return. It must be one of " "the following constants:" msgstr "" -#: library/asyncio-task.rst:831 +#: library/asyncio-task.rst:878 msgid "Constant" msgstr "" -#: library/asyncio-task.rst:832 +#: library/asyncio-task.rst:879 msgid "Description" msgstr "" -#: library/asyncio-task.rst:835 +#: library/asyncio-task.rst:882 msgid "The function will return when any future finishes or is cancelled." msgstr "" -#: library/asyncio-task.rst:838 +#: library/asyncio-task.rst:885 msgid "" "The function will return when any future finishes by raising an exception. " -"If no future raises an exception then it is equivalent to :const:" -"`ALL_COMPLETED`." +"If no future raises an exception then it is equivalent " +"to :const:`ALL_COMPLETED`." msgstr "" -#: library/asyncio-task.rst:843 +#: library/asyncio-task.rst:890 msgid "The function will return when all futures finish or are cancelled." msgstr "" -#: library/asyncio-task.rst:845 +#: library/asyncio-task.rst:892 msgid "" "Unlike :func:`~asyncio.wait_for`, ``wait()`` does not cancel the futures " "when a timeout occurs." msgstr "" -#: library/asyncio-task.rst:851 +#: library/asyncio-task.rst:898 msgid "Passing coroutine objects to ``wait()`` directly is forbidden." msgstr "" -#: library/asyncio-task.rst:881 +#: library/asyncio-task.rst:928 msgid "Added support for generators yielding tasks." msgstr "" -#: library/asyncio-task.rst:860 +#: library/asyncio-task.rst:907 msgid "" "Run :ref:`awaitable objects ` in the *aws* iterable " "concurrently. Return an iterator of coroutines. Each coroutine returned can " @@ -811,26 +1191,33 @@ msgid "" "remaining awaitables." msgstr "" -#: library/asyncio-task.rst:865 +#: library/asyncio-task.rst:912 msgid "" "Raises :exc:`TimeoutError` if the timeout occurs before all Futures are done." msgstr "" -#: library/asyncio-task.rst:877 +#: library/asyncio-task.rst:917 +msgid "" +"for coro in as_completed(aws):\n" +" earliest_result = await coro\n" +" # ..." +msgstr "" + +#: library/asyncio-task.rst:924 msgid "" "Deprecation warning is emitted if not all awaitable objects in the *aws* " "iterable are Future-like objects and there is no running event loop." msgstr "" -#: library/asyncio-task.rst:886 +#: library/asyncio-task.rst:933 msgid "Running in Threads" msgstr "" -#: library/asyncio-task.rst:890 +#: library/asyncio-task.rst:937 msgid "Asynchronously run function *func* in a separate thread." msgstr "" -#: library/asyncio-task.rst:892 +#: library/asyncio-task.rst:939 msgid "" "Any \\*args and \\*\\*kwargs supplied for this function are directly passed " "to *func*. Also, the current :class:`contextvars.Context` is propagated, " @@ -838,19 +1225,48 @@ msgid "" "separate thread." msgstr "" -#: library/asyncio-task.rst:897 +#: library/asyncio-task.rst:944 msgid "" "Return a coroutine that can be awaited to get the eventual result of *func*." msgstr "" -#: library/asyncio-task.rst:899 +#: library/asyncio-task.rst:946 msgid "" "This coroutine function is primarily intended to be used for executing IO-" "bound functions/methods that would otherwise block the event loop if they " "were run in the main thread. For example::" msgstr "" -#: library/asyncio-task.rst:929 +#: library/asyncio-task.rst:950 +msgid "" +"def blocking_io():\n" +" print(f\"start blocking_io at {time.strftime('%X')}\")\n" +" # Note that time.sleep() can be replaced with any blocking\n" +" # IO-bound operation, such as file operations.\n" +" time.sleep(1)\n" +" print(f\"blocking_io complete at {time.strftime('%X')}\")\n" +"\n" +"async def main():\n" +" print(f\"started main at {time.strftime('%X')}\")\n" +"\n" +" await asyncio.gather(\n" +" asyncio.to_thread(blocking_io),\n" +" asyncio.sleep(1))\n" +"\n" +" print(f\"finished main at {time.strftime('%X')}\")\n" +"\n" +"\n" +"asyncio.run(main())\n" +"\n" +"# Expected output:\n" +"#\n" +"# started main at 19:50:53\n" +"# start blocking_io at 19:50:53\n" +"# blocking_io complete at 19:50:54\n" +"# finished main at 19:50:54" +msgstr "" + +#: library/asyncio-task.rst:976 msgid "" "Directly calling ``blocking_io()`` in any coroutine would block the event " "loop for its duration, resulting in an additional 1 second of run time. " @@ -858,7 +1274,7 @@ msgid "" "thread without blocking the event loop." msgstr "" -#: library/asyncio-task.rst:936 +#: library/asyncio-task.rst:983 msgid "" "Due to the :term:`GIL`, ``asyncio.to_thread()`` can typically only be used " "to make IO-bound functions non-blocking. However, for extension modules that " @@ -866,85 +1282,110 @@ msgid "" "``asyncio.to_thread()`` can also be used for CPU-bound functions." msgstr "" -#: library/asyncio-task.rst:945 +#: library/asyncio-task.rst:992 msgid "Scheduling From Other Threads" msgstr "" -#: library/asyncio-task.rst:949 +#: library/asyncio-task.rst:996 msgid "Submit a coroutine to the given event loop. Thread-safe." msgstr "" -#: library/asyncio-task.rst:951 +#: library/asyncio-task.rst:998 msgid "" "Return a :class:`concurrent.futures.Future` to wait for the result from " "another OS thread." msgstr "" -#: library/asyncio-task.rst:954 +#: library/asyncio-task.rst:1001 msgid "" "This function is meant to be called from a different OS thread than the one " "where the event loop is running. Example::" msgstr "" -#: library/asyncio-task.rst:966 +#: library/asyncio-task.rst:1004 +msgid "" +"# Create a coroutine\n" +"coro = asyncio.sleep(1, result=3)\n" +"\n" +"# Submit the coroutine to a given loop\n" +"future = asyncio.run_coroutine_threadsafe(coro, loop)\n" +"\n" +"# Wait for the result with an optional timeout argument\n" +"assert future.result(timeout) == 3" +msgstr "" + +#: library/asyncio-task.rst:1013 msgid "" "If an exception is raised in the coroutine, the returned Future will be " "notified. It can also be used to cancel the task in the event loop::" msgstr "" -#: library/asyncio-task.rst:980 +#: library/asyncio-task.rst:1017 +msgid "" +"try:\n" +" result = future.result(timeout)\n" +"except TimeoutError:\n" +" print('The coroutine took too long, cancelling the task...')\n" +" future.cancel()\n" +"except Exception as exc:\n" +" print(f'The coroutine raised an exception: {exc!r}')\n" +"else:\n" +" print(f'The coroutine returned: {result!r}')" +msgstr "" + +#: library/asyncio-task.rst:1027 msgid "" "See the :ref:`concurrency and multithreading ` " "section of the documentation." msgstr "" -#: library/asyncio-task.rst:983 +#: library/asyncio-task.rst:1030 msgid "" "Unlike other asyncio functions this function requires the *loop* argument to " "be passed explicitly." msgstr "" -#: library/asyncio-task.rst:990 +#: library/asyncio-task.rst:1037 msgid "Introspection" msgstr "" -#: library/asyncio-task.rst:995 +#: library/asyncio-task.rst:1042 msgid "" "Return the currently running :class:`Task` instance, or ``None`` if no task " "is running." msgstr "" -#: library/asyncio-task.rst:998 +#: library/asyncio-task.rst:1045 msgid "" "If *loop* is ``None`` :func:`get_running_loop` is used to get the current " "loop." msgstr "" -#: library/asyncio-task.rst:1006 +#: library/asyncio-task.rst:1053 msgid "Return a set of not yet finished :class:`Task` objects run by the loop." msgstr "" -#: library/asyncio-task.rst:1009 +#: library/asyncio-task.rst:1056 msgid "" "If *loop* is ``None``, :func:`get_running_loop` is used for getting current " "loop." msgstr "" -#: library/asyncio-task.rst:1017 +#: library/asyncio-task.rst:1064 msgid "Return ``True`` if *obj* is a coroutine object." msgstr "" -#: library/asyncio-task.rst:1023 +#: library/asyncio-task.rst:1070 msgid "Task Object" msgstr "" -#: library/asyncio-task.rst:1027 +#: library/asyncio-task.rst:1074 msgid "" "A :class:`Future-like ` object that runs a Python :ref:`coroutine " "`. Not thread-safe." msgstr "" -#: library/asyncio-task.rst:1030 +#: library/asyncio-task.rst:1077 msgid "" "Tasks are used to run coroutines in event loops. If a coroutine awaits on a " "Future, the Task suspends the execution of the coroutine and waits for the " @@ -952,21 +1393,21 @@ msgid "" "wrapped coroutine resumes." msgstr "" -#: library/asyncio-task.rst:1036 +#: library/asyncio-task.rst:1083 msgid "" "Event loops use cooperative scheduling: an event loop runs one Task at a " "time. While a Task awaits for the completion of a Future, the event loop " "runs other Tasks, callbacks, or performs IO operations." msgstr "" -#: library/asyncio-task.rst:1041 +#: library/asyncio-task.rst:1088 msgid "" "Use the high-level :func:`asyncio.create_task` function to create Tasks, or " "the low-level :meth:`loop.create_task` or :func:`ensure_future` functions. " "Manual instantiation of Tasks is discouraged." msgstr "" -#: library/asyncio-task.rst:1046 +#: library/asyncio-task.rst:1093 msgid "" "To cancel a running Task use the :meth:`cancel` method. Calling it will " "cause the Task to throw a :exc:`CancelledError` exception into the wrapped " @@ -974,28 +1415,28 @@ msgid "" "cancellation, the Future object will be cancelled." msgstr "" -#: library/asyncio-task.rst:1051 +#: library/asyncio-task.rst:1098 msgid "" ":meth:`cancelled` can be used to check if the Task was cancelled. The method " -"returns ``True`` if the wrapped coroutine did not suppress the :exc:" -"`CancelledError` exception and was actually cancelled." +"returns ``True`` if the wrapped coroutine did not suppress " +"the :exc:`CancelledError` exception and was actually cancelled." msgstr "" -#: library/asyncio-task.rst:1056 +#: library/asyncio-task.rst:1103 msgid "" -":class:`asyncio.Task` inherits from :class:`Future` all of its APIs except :" -"meth:`Future.set_result` and :meth:`Future.set_exception`." +":class:`asyncio.Task` inherits from :class:`Future` all of its APIs " +"except :meth:`Future.set_result` and :meth:`Future.set_exception`." msgstr "" -#: library/asyncio-task.rst:1060 +#: library/asyncio-task.rst:1107 msgid "" -"An optional keyword-only *context* argument allows specifying a custom :" -"class:`contextvars.Context` for the *coro* to run in. If no *context* is " -"provided, the Task copies the current context and later runs its coroutine " -"in the copied context." +"An optional keyword-only *context* argument allows specifying a " +"custom :class:`contextvars.Context` for the *coro* to run in. If no " +"*context* is provided, the Task copies the current context and later runs " +"its coroutine in the copied context." msgstr "" -#: library/asyncio-task.rst:1065 +#: library/asyncio-task.rst:1112 msgid "" "An optional keyword-only *eager_start* argument allows eagerly starting the " "execution of the :class:`asyncio.Task` at task creation time. If set to " @@ -1005,96 +1446,96 @@ msgid "" "eagerly and will skip scheduling to the event loop." msgstr "" -#: library/asyncio-task.rst:1072 +#: library/asyncio-task.rst:1119 msgid "Added support for the :mod:`contextvars` module." msgstr "" -#: library/asyncio-task.rst:1078 +#: library/asyncio-task.rst:1125 msgid "" "Deprecation warning is emitted if *loop* is not specified and there is no " "running event loop." msgstr "" -#: library/asyncio-task.rst:1085 +#: library/asyncio-task.rst:1132 msgid "Added the *eager_start* parameter." msgstr "" -#: library/asyncio-task.rst:1090 +#: library/asyncio-task.rst:1137 msgid "Return ``True`` if the Task is *done*." msgstr "" -#: library/asyncio-task.rst:1092 +#: library/asyncio-task.rst:1139 msgid "" "A Task is *done* when the wrapped coroutine either returned a value, raised " "an exception, or the Task was cancelled." msgstr "" -#: library/asyncio-task.rst:1097 +#: library/asyncio-task.rst:1144 msgid "Return the result of the Task." msgstr "" -#: library/asyncio-task.rst:1099 +#: library/asyncio-task.rst:1146 msgid "" "If the Task is *done*, the result of the wrapped coroutine is returned (or " "if the coroutine raised an exception, that exception is re-raised.)" msgstr "" -#: library/asyncio-task.rst:1117 +#: library/asyncio-task.rst:1164 msgid "" "If the Task has been *cancelled*, this method raises a :exc:`CancelledError` " "exception." msgstr "" -#: library/asyncio-task.rst:1106 +#: library/asyncio-task.rst:1153 msgid "" -"If the Task's result isn't yet available, this method raises a :exc:" -"`InvalidStateError` exception." +"If the Task's result isn't yet available, this method raises " +"an :exc:`InvalidStateError` exception." msgstr "" -#: library/asyncio-task.rst:1111 +#: library/asyncio-task.rst:1158 msgid "Return the exception of the Task." msgstr "" -#: library/asyncio-task.rst:1113 +#: library/asyncio-task.rst:1160 msgid "" "If the wrapped coroutine raised an exception that exception is returned. If " "the wrapped coroutine returned normally this method returns ``None``." msgstr "" -#: library/asyncio-task.rst:1120 +#: library/asyncio-task.rst:1167 msgid "" "If the Task isn't *done* yet, this method raises an :exc:`InvalidStateError` " "exception." msgstr "" -#: library/asyncio-task.rst:1125 +#: library/asyncio-task.rst:1172 msgid "Add a callback to be run when the Task is *done*." msgstr "" -#: library/asyncio-task.rst:1136 +#: library/asyncio-task.rst:1183 msgid "This method should only be used in low-level callback-based code." msgstr "" -#: library/asyncio-task.rst:1129 +#: library/asyncio-task.rst:1176 msgid "" "See the documentation of :meth:`Future.add_done_callback` for more details." msgstr "" -#: library/asyncio-task.rst:1134 +#: library/asyncio-task.rst:1181 msgid "Remove *callback* from the callbacks list." msgstr "" -#: library/asyncio-task.rst:1138 +#: library/asyncio-task.rst:1185 msgid "" "See the documentation of :meth:`Future.remove_done_callback` for more " "details." msgstr "" -#: library/asyncio-task.rst:1143 +#: library/asyncio-task.rst:1190 msgid "Return the list of stack frames for this Task." msgstr "" -#: library/asyncio-task.rst:1145 +#: library/asyncio-task.rst:1192 msgid "" "If the wrapped coroutine is not done, this returns the stack where it is " "suspended. If the coroutine has completed successfully or was cancelled, " @@ -1102,15 +1543,15 @@ msgid "" "this returns the list of traceback frames." msgstr "" -#: library/asyncio-task.rst:1151 +#: library/asyncio-task.rst:1198 msgid "The frames are always ordered from oldest to newest." msgstr "" -#: library/asyncio-task.rst:1153 +#: library/asyncio-task.rst:1200 msgid "Only one stack frame is returned for a suspended coroutine." msgstr "" -#: library/asyncio-task.rst:1155 +#: library/asyncio-task.rst:1202 msgid "" "The optional *limit* argument sets the maximum number of frames to return; " "by default all available frames are returned. The ordering of the returned " @@ -1119,163 +1560,214 @@ msgid "" "are returned. (This matches the behavior of the traceback module.)" msgstr "" -#: library/asyncio-task.rst:1164 +#: library/asyncio-task.rst:1211 msgid "Print the stack or traceback for this Task." msgstr "" -#: library/asyncio-task.rst:1166 +#: library/asyncio-task.rst:1213 msgid "" "This produces output similar to that of the traceback module for the frames " "retrieved by :meth:`get_stack`." msgstr "" -#: library/asyncio-task.rst:1169 +#: library/asyncio-task.rst:1216 msgid "The *limit* argument is passed to :meth:`get_stack` directly." msgstr "" -#: library/asyncio-task.rst:1171 +#: library/asyncio-task.rst:1218 msgid "" "The *file* argument is an I/O stream to which the output is written; by " "default output is written to :data:`sys.stdout`." msgstr "" -#: library/asyncio-task.rst:1176 +#: library/asyncio-task.rst:1223 msgid "Return the coroutine object wrapped by the :class:`Task`." msgstr "" -#: library/asyncio-task.rst:1180 +#: library/asyncio-task.rst:1227 msgid "" "This will return ``None`` for Tasks which have already completed eagerly. " "See the :ref:`Eager Task Factory `." msgstr "" -#: library/asyncio-task.rst:1187 +#: library/asyncio-task.rst:1234 msgid "Newly added eager task execution means result may be ``None``." msgstr "" -#: library/asyncio-task.rst:1191 +#: library/asyncio-task.rst:1238 msgid "" "Return the :class:`contextvars.Context` object associated with the task." msgstr "" -#: library/asyncio-task.rst:1198 +#: library/asyncio-task.rst:1245 msgid "Return the name of the Task." msgstr "" -#: library/asyncio-task.rst:1200 +#: library/asyncio-task.rst:1247 msgid "" "If no name has been explicitly assigned to the Task, the default asyncio " "Task implementation generates a default name during instantiation." msgstr "" -#: library/asyncio-task.rst:1208 +#: library/asyncio-task.rst:1255 msgid "Set the name of the Task." msgstr "" -#: library/asyncio-task.rst:1210 +#: library/asyncio-task.rst:1257 msgid "" "The *value* argument can be any object, which is then converted to a string." msgstr "" -#: library/asyncio-task.rst:1213 +#: library/asyncio-task.rst:1260 msgid "" -"In the default Task implementation, the name will be visible in the :func:" -"`repr` output of a task object." +"In the default Task implementation, the name will be visible in " +"the :func:`repr` output of a task object." msgstr "" -#: library/asyncio-task.rst:1220 +#: library/asyncio-task.rst:1267 msgid "Request the Task to be cancelled." msgstr "" -#: library/asyncio-task.rst:1222 +#: library/asyncio-task.rst:1269 msgid "" "This arranges for a :exc:`CancelledError` exception to be thrown into the " "wrapped coroutine on the next cycle of the event loop." msgstr "" -#: library/asyncio-task.rst:1225 +#: library/asyncio-task.rst:1272 msgid "" "The coroutine then has a chance to clean up or even deny the request by " "suppressing the exception with a :keyword:`try` ... ... ``except " -"CancelledError`` ... :keyword:`finally` block. Therefore, unlike :meth:" -"`Future.cancel`, :meth:`Task.cancel` does not guarantee that the Task will " -"be cancelled, although suppressing cancellation completely is not common and " -"is actively discouraged. Should the coroutine nevertheless decide to " -"suppress the cancellation, it needs to call :meth:`Task.uncancel` in " -"addition to catching the exception." +"CancelledError`` ... :keyword:`finally` block. Therefore, " +"unlike :meth:`Future.cancel`, :meth:`Task.cancel` does not guarantee that " +"the Task will be cancelled, although suppressing cancellation completely is " +"not common and is actively discouraged. Should the coroutine nevertheless " +"decide to suppress the cancellation, it needs to call :meth:`Task.uncancel` " +"in addition to catching the exception." msgstr "" -#: library/asyncio-task.rst:1235 +#: library/asyncio-task.rst:1282 msgid "Added the *msg* parameter." msgstr "" -#: library/asyncio-task.rst:1238 +#: library/asyncio-task.rst:1285 msgid "The ``msg`` parameter is propagated from cancelled task to its awaiter." msgstr "" -#: library/asyncio-task.rst:1243 +#: library/asyncio-task.rst:1290 msgid "" "The following example illustrates how coroutines can intercept the " "cancellation request::" msgstr "" -#: library/asyncio-task.rst:1282 +#: library/asyncio-task.rst:1293 +msgid "" +"async def cancel_me():\n" +" print('cancel_me(): before sleep')\n" +"\n" +" try:\n" +" # Wait for 1 hour\n" +" await asyncio.sleep(3600)\n" +" except asyncio.CancelledError:\n" +" print('cancel_me(): cancel sleep')\n" +" raise\n" +" finally:\n" +" print('cancel_me(): after sleep')\n" +"\n" +"async def main():\n" +" # Create a \"cancel_me\" Task\n" +" task = asyncio.create_task(cancel_me())\n" +"\n" +" # Wait for 1 second\n" +" await asyncio.sleep(1)\n" +"\n" +" task.cancel()\n" +" try:\n" +" await task\n" +" except asyncio.CancelledError:\n" +" print(\"main(): cancel_me is cancelled now\")\n" +"\n" +"asyncio.run(main())\n" +"\n" +"# Expected output:\n" +"#\n" +"# cancel_me(): before sleep\n" +"# cancel_me(): cancel sleep\n" +"# cancel_me(): after sleep\n" +"# main(): cancel_me is cancelled now" +msgstr "" + +#: library/asyncio-task.rst:1329 msgid "Return ``True`` if the Task is *cancelled*." msgstr "" -#: library/asyncio-task.rst:1284 +#: library/asyncio-task.rst:1331 msgid "" -"The Task is *cancelled* when the cancellation was requested with :meth:" -"`cancel` and the wrapped coroutine propagated the :exc:`CancelledError` " -"exception thrown into it." +"The Task is *cancelled* when the cancellation was requested " +"with :meth:`cancel` and the wrapped coroutine propagated " +"the :exc:`CancelledError` exception thrown into it." msgstr "" -#: library/asyncio-task.rst:1290 +#: library/asyncio-task.rst:1337 msgid "Decrement the count of cancellation requests to this Task." msgstr "" -#: library/asyncio-task.rst:1292 +#: library/asyncio-task.rst:1339 msgid "Returns the remaining number of cancellation requests." msgstr "" -#: library/asyncio-task.rst:1294 +#: library/asyncio-task.rst:1341 msgid "" -"Note that once execution of a cancelled task completed, further calls to :" -"meth:`uncancel` are ineffective." +"Note that once execution of a cancelled task completed, further calls " +"to :meth:`uncancel` are ineffective." msgstr "" -#: library/asyncio-task.rst:1299 +#: library/asyncio-task.rst:1346 msgid "" "This method is used by asyncio's internals and isn't expected to be used by " "end-user code. In particular, if a Task gets successfully uncancelled, this " -"allows for elements of structured concurrency like :ref:`taskgroups` and :" -"func:`asyncio.timeout` to continue running, isolating cancellation to the " -"respective structured block. For example::" +"allows for elements of structured concurrency like :ref:`taskgroups` " +"and :func:`asyncio.timeout` to continue running, isolating cancellation to " +"the respective structured block. For example::" msgstr "" -#: library/asyncio-task.rst:1317 +#: library/asyncio-task.rst:1353 +msgid "" +"async def make_request_with_timeout():\n" +" try:\n" +" async with asyncio.timeout(1):\n" +" # Structured block affected by the timeout:\n" +" await make_request()\n" +" await make_another_request()\n" +" except TimeoutError:\n" +" log(\"There was a timeout\")\n" +" # Outer code not affected by the timeout:\n" +" await unrelated_code()" +msgstr "" + +#: library/asyncio-task.rst:1364 msgid "" "While the block with ``make_request()`` and ``make_another_request()`` might " "get cancelled due to the timeout, ``unrelated_code()`` should continue " -"running even in case of the timeout. This is implemented with :meth:" -"`uncancel`. :class:`TaskGroup` context managers use :func:`uncancel` in a " -"similar fashion." +"running even in case of the timeout. This is implemented " +"with :meth:`uncancel`. :class:`TaskGroup` context managers " +"use :func:`uncancel` in a similar fashion." msgstr "" -#: library/asyncio-task.rst:1323 +#: library/asyncio-task.rst:1370 msgid "" -"If end-user code is, for some reason, suppresing cancellation by catching :" -"exc:`CancelledError`, it needs to call this method to remove the " +"If end-user code is, for some reason, suppressing cancellation by " +"catching :exc:`CancelledError`, it needs to call this method to remove the " "cancellation state." msgstr "" -#: library/asyncio-task.rst:1329 +#: library/asyncio-task.rst:1376 msgid "" "Return the number of pending cancellation requests to this Task, i.e., the " "number of calls to :meth:`cancel` less the number of :meth:`uncancel` calls." msgstr "" -#: library/asyncio-task.rst:1333 +#: library/asyncio-task.rst:1380 msgid "" "Note that if this number is greater than zero but the Task is still " "executing, :meth:`cancelled` will still return ``False``. This is because " @@ -1284,7 +1776,7 @@ msgid "" "to zero." msgstr "" -#: library/asyncio-task.rst:1339 +#: library/asyncio-task.rst:1386 msgid "" "This method is used by asyncio's internals and isn't expected to be used by " "end-user code. See :meth:`uncancel` for more details." diff --git a/library/asyncio.po b/library/asyncio.po index 1cc23f41..2a2f6df8 100644 --- a/library/asyncio.po +++ b/library/asyncio.po @@ -8,34 +8,47 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: library/asyncio.rst:80 +#: library/asyncio.rst:87 msgid "High-level APIs" msgstr "" -#: library/asyncio.rst:92 +#: library/asyncio.rst:99 msgid "Low-level APIs" msgstr "" -#: library/asyncio.rst:103 +#: library/asyncio.rst:110 msgid "Guides and Tutorials" msgstr "" #: library/asyncio.rst:2 -msgid ":mod:`asyncio` --- Asynchronous I/O" +msgid ":mod:`!asyncio` --- Asynchronous I/O" msgstr "" #: library/asyncio.rst:-1 msgid "Hello World!" msgstr "" +#: library/asyncio.rst:13 +msgid "" +"import asyncio\n" +"\n" +"async def main():\n" +" print('Hello ...')\n" +" await asyncio.sleep(1)\n" +" print('... World!')\n" +"\n" +"asyncio.run(main())" +msgstr "" + #: library/asyncio.rst:22 msgid "" "asyncio is a library to write **concurrent** code using the **async/await** " @@ -90,9 +103,9 @@ msgstr "" #: library/asyncio.rst:48 msgid "" "create and manage :ref:`event loops `, which provide " -"asynchronous APIs for :ref:`networking `, running :ref:" -"`subprocesses `, handling :ref:`OS signals " -"`, etc;" +"asynchronous APIs for :ref:`networking `, " +"running :ref:`subprocesses `, handling :ref:`OS " +"signals `, etc;" msgstr "" #: library/asyncio.rst:53 @@ -107,12 +120,8 @@ msgid "" "await syntax." msgstr "" -#: library/asyncio.rst:61 -msgid "You can experiment with an ``asyncio`` concurrent context in the REPL:" -msgstr "" - #: includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." +msgid "Availability" msgstr "" #: includes/wasm-notavail.rst:5 @@ -122,10 +131,40 @@ msgid "" "more information." msgstr "" +#: library/asyncio.rst:64 +msgid "asyncio REPL" +msgstr "" + +#: library/asyncio.rst:65 +msgid "You can experiment with an ``asyncio`` concurrent context in the REPL:" +msgstr "" + +#: library/asyncio.rst:67 +msgid "" +"$ python -m asyncio\n" +"asyncio REPL ...\n" +"Use \"await\" directly instead of \"asyncio.run()\".\n" +"Type \"help\", \"copyright\", \"credits\" or \"license\" for more " +"information.\n" +">>> import asyncio\n" +">>> await asyncio.sleep(10, result='hello')\n" +"'hello'" +msgstr "" + +#: library/asyncio.rst:77 +msgid "" +"Raises an :ref:`auditing event ` ``cpython.run_stdin`` with no " +"arguments." +msgstr "" + #: library/asyncio.rst:79 +msgid "(also 3.11.10, 3.10.15, 3.9.20, and 3.8.20) Emits audit events." +msgstr "" + +#: library/asyncio.rst:86 msgid "Reference" msgstr "" -#: library/asyncio.rst:112 +#: library/asyncio.rst:119 msgid "The source code for asyncio can be found in :source:`Lib/asyncio/`." msgstr "" diff --git a/library/asyncore.po b/library/asyncore.po new file mode 100644 index 00000000..fdc9069d --- /dev/null +++ b/library/asyncore.po @@ -0,0 +1,38 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: library/asyncore.rst:2 +msgid ":mod:`!asyncore` --- Asynchronous socket handler" +msgstr "" + +#: library/asyncore.rst:10 +msgid "" +"This module is no longer part of the Python standard library. It " +"was :ref:`removed in Python 3.12 ` after being " +"deprecated in Python 3.6. The removal was decided in :pep:`594`." +msgstr "" + +#: library/asyncore.rst:14 +msgid "Applications should use the :mod:`asyncio` module instead." +msgstr "" + +#: library/asyncore.rst:16 +msgid "" +"The last version of Python that provided the :mod:`!asyncore` module was " +"`Python 3.11 `_." +msgstr "" diff --git a/library/atexit.po b/library/atexit.po index dc967c3f..8baedcaa 100644 --- a/library/atexit.po +++ b/library/atexit.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/atexit.rst:2 -msgid ":mod:`atexit` --- Exit handlers" +msgid ":mod:`!atexit` --- Exit handlers" msgstr "" #: library/atexit.rst:12 @@ -52,9 +53,9 @@ msgstr "" #: library/atexit.rst:32 msgid "" "Register *func* as a function to be executed at termination. Any optional " -"arguments that are to be passed to *func* must be passed as arguments to :" -"func:`register`. It is possible to register the same function and arguments " -"more than once." +"arguments that are to be passed to *func* must be passed as arguments " +"to :func:`register`. It is possible to register the same function and " +"arguments more than once." msgstr "" #: library/atexit.rst:37 @@ -96,15 +97,16 @@ msgstr "" #: library/atexit.rst:64 msgid "" -"Remove *func* from the list of functions to be run at interpreter shutdown. :" -"func:`unregister` silently does nothing if *func* was not previously " -"registered. If *func* has been registered more than once, every occurrence " -"of that function in the :mod:`atexit` call stack will be removed. Equality " -"comparisons (``==``) are used internally during unregistration, so function " -"references do not need to have matching identities." +"Remove *func* from the list of functions to be run at interpreter " +"shutdown. :func:`unregister` silently does nothing if *func* was not " +"previously registered. If *func* has been registered more than once, every " +"occurrence of that function in the :mod:`atexit` call stack will be " +"removed. Equality comparisons (``==``) are used internally during " +"unregistration, so function references do not need to have matching " +"identities." msgstr "" -#: library/atexit.rst:75 +#: library/atexit.rst:74 msgid "Module :mod:`readline`" msgstr "" @@ -126,16 +128,58 @@ msgid "" "making an explicit call into this module at termination. ::" msgstr "" +#: library/atexit.rst:89 +msgid "" +"try:\n" +" with open('counterfile') as infile:\n" +" _count = int(infile.read())\n" +"except FileNotFoundError:\n" +" _count = 0\n" +"\n" +"def incrcounter(n):\n" +" global _count\n" +" _count = _count + n\n" +"\n" +"def savecounter():\n" +" with open('counterfile', 'w') as outfile:\n" +" outfile.write('%d' % _count)\n" +"\n" +"import atexit\n" +"\n" +"atexit.register(savecounter)" +msgstr "" + #: library/atexit.rst:107 msgid "" "Positional and keyword arguments may also be passed to :func:`register` to " "be passed along to the registered function when it is called::" msgstr "" +#: library/atexit.rst:110 +msgid "" +"def goodbye(name, adjective):\n" +" print('Goodbye %s, it was %s to meet you.' % (name, adjective))\n" +"\n" +"import atexit\n" +"\n" +"atexit.register(goodbye, 'Donny', 'nice')\n" +"# or:\n" +"atexit.register(goodbye, adjective='nice', name='Donny')" +msgstr "" + #: library/atexit.rst:119 msgid "Usage as a :term:`decorator`::" msgstr "" +#: library/atexit.rst:121 +msgid "" +"import atexit\n" +"\n" +"@atexit.register\n" +"def goodbye():\n" +" print('You are now leaving the Python sector.')" +msgstr "" + #: library/atexit.rst:127 msgid "This only works with functions that can be called without arguments." msgstr "" diff --git a/library/audioop.po b/library/audioop.po index 6d954999..4778a169 100644 --- a/library/audioop.po +++ b/library/audioop.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -20,7 +21,7 @@ msgstr "" msgid ":mod:`audioop` --- Manipulate raw audio data" msgstr "" -#: library/audioop.rst:11 +#: library/audioop.rst:8 msgid "" "The :mod:`audioop` module is deprecated (see :pep:`PEP 594 <594#audioop>` " "for details)." @@ -37,8 +38,9 @@ msgstr "" #: library/audioop.rst:19 msgid "" -"Support for 24-bit samples was added. All functions now accept any :term:" -"`bytes-like object`. String input now results in an immediate error." +"Support for 24-bit samples was added. All functions now accept " +"any :term:`bytes-like object`. String input now results in an immediate " +"error." msgstr "" #: library/audioop.rst:30 @@ -187,6 +189,12 @@ msgid "" "samples for these formats, you need to also add 128 to the result::" msgstr "" +#: library/audioop.rst:163 +msgid "" +"new_frames = audioop.lin2lin(frames, old_width, 1)\n" +"new_frames = audioop.bias(new_frames, 1, 128)" +msgstr "" + #: library/audioop.rst:166 msgid "" "The same, in reverse, has to be applied when converting from 8 to 16, 24 or " @@ -284,6 +292,18 @@ msgid "" "that::" msgstr "" +#: library/audioop.rst:249 +msgid "" +"def mul_stereo(sample, width, lfactor, rfactor):\n" +" lsample = audioop.tomono(sample, width, 1, 0)\n" +" rsample = audioop.tomono(sample, width, 0, 1)\n" +" lsample = audioop.mul(lsample, width, lfactor)\n" +" rsample = audioop.mul(rsample, width, rfactor)\n" +" lsample = audioop.tostereo(lsample, width, 1, 0)\n" +" rsample = audioop.tostereo(rsample, width, 0, 1)\n" +" return audioop.add(lsample, rsample, width)" +msgstr "" + #: library/audioop.rst:258 msgid "" "If you use the ADPCM coder to build network packets and you want your " @@ -311,6 +331,22 @@ msgid "" "input sample and subtract the whole output sample from the input sample::" msgstr "" +#: library/audioop.rst:275 +msgid "" +"def echocancel(outputdata, inputdata):\n" +" pos = audioop.findmax(outputdata, 800) # one tenth second\n" +" out_test = outputdata[pos*2:]\n" +" in_test = inputdata[pos*2:]\n" +" ipos, factor = audioop.findfit(in_test, out_test)\n" +" # Optional (for better cancellation):\n" +" # factor = audioop.findfactor(in_test[ipos*2:ipos*2+len(out_test)],\n" +" # out_test)\n" +" prefill = '\\0'*(pos+ipos)*2\n" +" postfill = '\\0'*(len(inputdata)-len(prefill)-len(outputdata))\n" +" outputdata = prefill + audioop.mul(outputdata, 2, -factor) + postfill\n" +" return audioop.add(inputdata, outputdata, 2)" +msgstr "" + #: library/audioop.rst:24 msgid "Intel/DVI ADPCM" msgstr "" diff --git a/library/audit_events.po b/library/audit_events.po index a6b94292..0fafd4c9 100644 --- a/library/audit_events.po +++ b/library/audit_events.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -22,9 +23,9 @@ msgstr "" #: library/audit_events.rst:8 msgid "" -"This table contains all events raised by :func:`sys.audit` or :c:func:" -"`PySys_Audit` calls throughout the CPython runtime and the standard " -"library. These calls were added in 3.8 or later (see :pep:`578`)." +"This table contains all events raised by :func:`sys.audit` " +"or :c:func:`PySys_Audit` calls throughout the CPython runtime and the " +"standard library. These calls were added in 3.8 or later (see :pep:`578`)." msgstr "" #: library/audit_events.rst:12 diff --git a/library/base64.po b/library/base64.po index 1c0a7a3c..6c44a3aa 100644 --- a/library/base64.po +++ b/library/base64.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/base64.rst:2 -msgid ":mod:`base64` --- Base16, Base32, Base64, Base85 Data Encodings" +msgid ":mod:`!base64` --- Base16, Base32, Base64, Base85 Data Encodings" msgstr "" #: library/base64.rst:8 @@ -37,17 +38,18 @@ msgstr "" msgid "" "The :rfc:`4648` encodings are suitable for encoding binary data so that it " "can be safely sent by email, used as parts of URLs, or included as part of " -"an HTTP POST request. The encoding algorithm is not the same as the :" -"program:`uuencode` program." +"an HTTP POST request. The encoding algorithm is not the same as " +"the :program:`uuencode` program." msgstr "" #: library/base64.rst:27 msgid "" "There are two interfaces provided by this module. The modern interface " -"supports encoding :term:`bytes-like objects ` to ASCII :" -"class:`bytes`, and decoding :term:`bytes-like objects ` " -"or strings containing ASCII to :class:`bytes`. Both base-64 alphabets " -"defined in :rfc:`4648` (normal, and URL- and filesystem-safe) are supported." +"supports encoding :term:`bytes-like objects ` to " +"ASCII :class:`bytes`, and decoding :term:`bytes-like objects ` or strings containing ASCII to :class:`bytes`. Both base-64 " +"alphabets defined in :rfc:`4648` (normal, and URL- and filesystem-safe) are " +"supported." msgstr "" #: library/base64.rst:33 @@ -56,8 +58,8 @@ msgid "" "provide functions for encoding and decoding to and from :term:`file objects " "`. It only supports the Base64 standard alphabet, and it adds " "newlines every 76 characters as per :rfc:`2045`. Note that if you are " -"looking for :rfc:`2045` support you probably want to be looking at the :mod:" -"`email` package instead." +"looking for :rfc:`2045` support you probably want to be looking at " +"the :mod:`email` package instead." msgstr "" #: library/base64.rst:41 @@ -127,8 +129,8 @@ msgstr "" #: library/base64.rst:83 msgid "" -"For more information about the strict base64 check, see :func:`binascii." -"a2b_base64`" +"For more information about the strict base64 check, " +"see :func:`binascii.a2b_base64`" msgstr "" #: library/base64.rst:85 @@ -160,8 +162,8 @@ msgstr "" msgid "" "Decode :term:`bytes-like object` or ASCII string *s* using the URL- and " "filesystem-safe alphabet, which substitutes ``-`` instead of ``+`` and ``_`` " -"instead of ``/`` in the standard Base64 alphabet, and return the decoded :" -"class:`bytes`." +"instead of ``/`` in the standard Base64 alphabet, and return the " +"decoded :class:`bytes`." msgstr "" #: library/base64.rst:119 @@ -248,7 +250,7 @@ msgstr "" msgid "" "*wrapcol* controls whether the output should have newline (``b'\\n'``) " "characters added to it. If this is non-zero, each output line will be at " -"most this many characters long." +"most this many characters long, excluding the trailing newline." msgstr "" #: library/base64.rst:198 @@ -330,11 +332,12 @@ msgstr "" #: library/base64.rst:267 msgid "" "Encode the contents of the binary *input* file and write the resulting " -"base64 encoded data to the *output* file. *input* and *output* must be :term:" -"`file objects `. *input* will be read until ``input.read()`` " -"returns an empty bytes object. :func:`encode` inserts a newline character " -"(``b'\\n'``) after every 76 bytes of the output, as well as ensuring that " -"the output always ends with a newline, as per :rfc:`2045` (MIME)." +"base64 encoded data to the *output* file. *input* and *output* must " +"be :term:`file objects `. *input* will be read until " +"``input.read()`` returns an empty bytes object. :func:`encode` inserts a " +"newline character (``b'\\n'``) after every 76 bytes of the output, as well " +"as ensuring that the output always ends with a newline, as per :rfc:`2045` " +"(MIME)." msgstr "" #: library/base64.rst:277 @@ -360,7 +363,7 @@ msgid "" "production." msgstr "" -#: library/base64.rst:306 +#: library/base64.rst:305 msgid "Module :mod:`binascii`" msgstr "" @@ -369,7 +372,7 @@ msgid "" "Support module containing ASCII-to-binary and binary-to-ASCII conversions." msgstr "" -#: library/base64.rst:309 +#: library/base64.rst:308 msgid "" ":rfc:`1521` - MIME (Multipurpose Internet Mail Extensions) Part One: " "Mechanisms for Specifying and Describing the Format of Internet Message " diff --git a/library/bdb.po b/library/bdb.po index b12ca4a4..40731e0e 100644 --- a/library/bdb.po +++ b/library/bdb.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/bdb.rst:2 -msgid ":mod:`bdb` --- Debugger framework" +msgid ":mod:`!bdb` --- Debugger framework" msgstr "" #: library/bdb.rst:7 @@ -59,10 +60,10 @@ msgstr "" #: library/bdb.rst:33 msgid "" "When creating a breakpoint, its associated :attr:`file name ` should " -"be in canonical form. If a :attr:`funcname` is defined, a breakpoint :attr:" -"`hit ` will be counted when the first line of that function is " -"executed. A :attr:`conditional ` breakpoint always counts a :attr:" -"`hit `." +"be in canonical form. If a :attr:`funcname` is defined, a " +"breakpoint :attr:`hit ` will be counted when the first line of that " +"function is executed. A :attr:`conditional ` breakpoint always counts " +"a :attr:`hit `." msgstr "" #: library/bdb.rst:39 @@ -133,7 +134,7 @@ msgid "Line number of the :class:`Breakpoint` within :attr:`file`." msgstr "" #: library/bdb.rst:89 -msgid "True if a :class:`Breakpoint` at (file, line) is temporary." +msgid "``True`` if a :class:`Breakpoint` at (file, line) is temporary." msgstr "" #: library/bdb.rst:93 @@ -147,7 +148,7 @@ msgid "" msgstr "" #: library/bdb.rst:102 -msgid "True if :class:`Breakpoint` is enabled." +msgid "``True`` if :class:`Breakpoint` is enabled." msgstr "" #: library/bdb.rst:106 @@ -156,8 +157,8 @@ msgstr "" #: library/bdb.rst:110 msgid "" -"Dictionary of :class:`Breakpoint` instances indexed by (:attr:`file`, :attr:" -"`line`) tuples." +"Dictionary of :class:`Breakpoint` instances indexed by " +"(:attr:`file`, :attr:`line`) tuples." msgstr "" #: library/bdb.rst:115 @@ -175,8 +176,8 @@ msgstr "" #: library/bdb.rst:125 msgid "" "This class takes care of the details of the trace facility; a derived class " -"should implement user interaction. The standard debugger class (:class:`pdb." -"Pdb`) is an example." +"should implement user interaction. The standard debugger class " +"(:class:`pdb.Pdb`) is an example." msgstr "" #: library/bdb.rst:129 @@ -203,16 +204,16 @@ msgstr "" #: library/bdb.rst:144 msgid "" -"For real file names, the canonical form is an operating-system-dependent, :" -"func:`case-normalized ` :func:`absolute path `. A *filename* with angle brackets, such as ``\"\"`` " -"generated in interactive mode, is returned unchanged." +"For real file names, the canonical form is an operating-system-" +"dependent, :func:`case-normalized ` :func:`absolute path " +"`. A *filename* with angle brackets, such as " +"``\"\"`` generated in interactive mode, is returned unchanged." msgstr "" #: library/bdb.rst:151 msgid "" -"Set the :attr:`!botframe`, :attr:`!stopframe`, :attr:`!returnframe` and :" -"attr:`quitting ` attributes with values ready to start " +"Set the :attr:`!botframe`, :attr:`!stopframe`, :attr:`!returnframe` " +"and :attr:`quitting ` attributes with values ready to start " "debugging." msgstr "" @@ -272,44 +273,45 @@ msgstr "" #: library/bdb.rst:177 msgid "" "See the documentation for :func:`sys.settrace` for more information on the " -"trace function. For more information on code and frame objects, refer to :" -"ref:`types`." +"trace function. For more information on code and frame objects, refer " +"to :ref:`types`." msgstr "" #: library/bdb.rst:183 msgid "" -"If the debugger should stop on the current line, invoke the :meth:" -"`user_line` method (which should be overridden in subclasses). Raise a :exc:" -"`BdbQuit` exception if the :attr:`quitting ` flag is set " -"(which can be set from :meth:`user_line`). Return a reference to the :meth:" -"`trace_dispatch` method for further tracing in that scope." +"If the debugger should stop on the current line, invoke " +"the :meth:`user_line` method (which should be overridden in subclasses). " +"Raise a :exc:`BdbQuit` exception if the :attr:`quitting ` " +"flag is set (which can be set from :meth:`user_line`). Return a reference " +"to the :meth:`trace_dispatch` method for further tracing in that scope." msgstr "" #: library/bdb.rst:191 msgid "" -"If the debugger should stop on this function call, invoke the :meth:" -"`user_call` method (which should be overridden in subclasses). Raise a :exc:" -"`BdbQuit` exception if the :attr:`quitting ` flag is set " -"(which can be set from :meth:`user_call`). Return a reference to the :meth:" -"`trace_dispatch` method for further tracing in that scope." +"If the debugger should stop on this function call, invoke " +"the :meth:`user_call` method (which should be overridden in subclasses). " +"Raise a :exc:`BdbQuit` exception if the :attr:`quitting ` " +"flag is set (which can be set from :meth:`user_call`). Return a reference " +"to the :meth:`trace_dispatch` method for further tracing in that scope." msgstr "" #: library/bdb.rst:199 msgid "" -"If the debugger should stop on this function return, invoke the :meth:" -"`user_return` method (which should be overridden in subclasses). Raise a :" -"exc:`BdbQuit` exception if the :attr:`quitting ` flag is set " -"(which can be set from :meth:`user_return`). Return a reference to the :" -"meth:`trace_dispatch` method for further tracing in that scope." +"If the debugger should stop on this function return, invoke " +"the :meth:`user_return` method (which should be overridden in subclasses). " +"Raise a :exc:`BdbQuit` exception if the :attr:`quitting ` " +"flag is set (which can be set from :meth:`user_return`). Return a reference " +"to the :meth:`trace_dispatch` method for further tracing in that scope." msgstr "" #: library/bdb.rst:207 msgid "" -"If the debugger should stop at this exception, invokes the :meth:" -"`user_exception` method (which should be overridden in subclasses). Raise a :" -"exc:`BdbQuit` exception if the :attr:`quitting ` flag is set " -"(which can be set from :meth:`user_exception`). Return a reference to the :" -"meth:`trace_dispatch` method for further tracing in that scope." +"If the debugger should stop at this exception, invokes " +"the :meth:`user_exception` method (which should be overridden in " +"subclasses). Raise a :exc:`BdbQuit` exception if the :attr:`quitting " +"` flag is set (which can be set from :meth:`user_exception`). " +"Return a reference to the :meth:`trace_dispatch` method for further tracing " +"in that scope." msgstr "" #: library/bdb.rst:213 @@ -319,15 +321,15 @@ msgid "" msgstr "" #: library/bdb.rst:218 -msgid "Return True if *module_name* matches any skip pattern." +msgid "Return ``True`` if *module_name* matches any skip pattern." msgstr "" #: library/bdb.rst:222 -msgid "Return True if *frame* is below the starting frame in the stack." +msgid "Return ``True`` if *frame* is below the starting frame in the stack." msgstr "" #: library/bdb.rst:226 -msgid "Return True if there is an effective breakpoint for this line." +msgid "Return ``True`` if there is an effective breakpoint for this line." msgstr "" #: library/bdb.rst:228 @@ -337,7 +339,7 @@ msgid "" msgstr "" #: library/bdb.rst:233 -msgid "Return True if any breakpoint exists for *frame*'s filename." +msgid "Return ``True`` if any breakpoint exists for *frame*'s filename." msgstr "" #: library/bdb.rst:235 @@ -352,112 +354,118 @@ msgid "" "function." msgstr "" -#: library/bdb.rst:245 +#: library/bdb.rst:243 msgid "" -"Called from :meth:`dispatch_line` when either :meth:`stop_here` or :meth:" -"`break_here` returns ``True``." +"*argument_list* is not used anymore and will always be ``None``. The " +"argument is kept for backwards compatibility." msgstr "" -#: library/bdb.rst:250 +#: library/bdb.rst:248 +msgid "" +"Called from :meth:`dispatch_line` when either :meth:`stop_here` " +"or :meth:`break_here` returns ``True``." +msgstr "" + +#: library/bdb.rst:253 msgid "" "Called from :meth:`dispatch_return` when :meth:`stop_here` returns ``True``." msgstr "" -#: library/bdb.rst:254 +#: library/bdb.rst:257 msgid "" "Called from :meth:`dispatch_exception` when :meth:`stop_here` returns " "``True``." msgstr "" -#: library/bdb.rst:259 +#: library/bdb.rst:262 msgid "Handle how a breakpoint must be removed when it is a temporary one." msgstr "" -#: library/bdb.rst:261 +#: library/bdb.rst:264 msgid "This method must be implemented by derived classes." msgstr "" -#: library/bdb.rst:264 +#: library/bdb.rst:267 msgid "" "Derived classes and clients can call the following methods to affect the " "stepping state." msgstr "" -#: library/bdb.rst:269 +#: library/bdb.rst:272 msgid "Stop after one line of code." msgstr "" -#: library/bdb.rst:273 +#: library/bdb.rst:276 msgid "Stop on the next line in or below the given frame." msgstr "" -#: library/bdb.rst:277 +#: library/bdb.rst:280 msgid "Stop when returning from the given frame." msgstr "" -#: library/bdb.rst:281 +#: library/bdb.rst:284 msgid "" "Stop when the line with the *lineno* greater than the current one is reached " "or when returning from current frame." msgstr "" -#: library/bdb.rst:286 +#: library/bdb.rst:289 msgid "" "Start debugging from *frame*. If *frame* is not specified, debugging starts " "from caller's frame." msgstr "" -#: library/bdb.rst:291 +#: library/bdb.rst:294 msgid "" "Stop only at breakpoints or when finished. If there are no breakpoints, set " "the system trace function to ``None``." msgstr "" -#: library/bdb.rst:298 +#: library/bdb.rst:301 msgid "" "Set the :attr:`!quitting` attribute to ``True``. This raises :exc:`BdbQuit` " "in the next call to one of the :meth:`!dispatch_\\*` methods." msgstr "" -#: library/bdb.rst:302 +#: library/bdb.rst:305 msgid "" "Derived classes and clients can call the following methods to manipulate " "breakpoints. These methods return a string containing an error message if " "something went wrong, or ``None`` if all is well." msgstr "" -#: library/bdb.rst:308 +#: library/bdb.rst:311 msgid "" "Set a new breakpoint. If the *lineno* line doesn't exist for the *filename* " "passed as argument, return an error message. The *filename* should be in " "canonical form, as described in the :meth:`canonic` method." msgstr "" -#: library/bdb.rst:314 +#: library/bdb.rst:317 msgid "" "Delete the breakpoints in *filename* and *lineno*. If none were set, return " "an error message." msgstr "" -#: library/bdb.rst:319 +#: library/bdb.rst:322 msgid "" -"Delete the breakpoint which has the index *arg* in the :attr:`Breakpoint." -"bpbynumber`. If *arg* is not numeric or out of range, return an error " -"message." +"Delete the breakpoint which has the index *arg* in " +"the :attr:`Breakpoint.bpbynumber`. If *arg* is not numeric or out of range, " +"return an error message." msgstr "" -#: library/bdb.rst:325 +#: library/bdb.rst:328 msgid "" "Delete all breakpoints in *filename*. If none were set, return an error " "message." msgstr "" -#: library/bdb.rst:330 +#: library/bdb.rst:333 msgid "" "Delete all existing breakpoints. If none were set, return an error message." msgstr "" -#: library/bdb.rst:335 +#: library/bdb.rst:338 msgid "" "Return a breakpoint specified by the given number. If *arg* is a string, it " "will be converted to a number. If *arg* is a non-numeric string, if the " @@ -465,138 +473,139 @@ msgid "" "raised." msgstr "" -#: library/bdb.rst:344 -msgid "Return True if there is a breakpoint for *lineno* in *filename*." +#: library/bdb.rst:347 +msgid "Return ``True`` if there is a breakpoint for *lineno* in *filename*." msgstr "" -#: library/bdb.rst:348 +#: library/bdb.rst:351 msgid "" "Return all breakpoints for *lineno* in *filename*, or an empty list if none " "are set." msgstr "" -#: library/bdb.rst:353 +#: library/bdb.rst:356 msgid "Return all breakpoints in *filename*, or an empty list if none are set." msgstr "" -#: library/bdb.rst:357 +#: library/bdb.rst:360 msgid "Return all breakpoints that are set." msgstr "" -#: library/bdb.rst:360 +#: library/bdb.rst:363 msgid "" "Derived classes and clients can call the following methods to get a data " "structure representing a stack trace." msgstr "" -#: library/bdb.rst:365 +#: library/bdb.rst:368 msgid "Return a list of (frame, lineno) tuples in a stack trace, and a size." msgstr "" -#: library/bdb.rst:367 +#: library/bdb.rst:370 msgid "" "The most recently called frame is last in the list. The size is the number " "of frames below the frame where the debugger was invoked." msgstr "" -#: library/bdb.rst:372 +#: library/bdb.rst:375 msgid "" "Return a string with information about a stack entry, which is a ``(frame, " "lineno)`` tuple. The return string contains:" msgstr "" -#: library/bdb.rst:375 +#: library/bdb.rst:378 msgid "The canonical filename which contains the frame." msgstr "" -#: library/bdb.rst:376 +#: library/bdb.rst:379 msgid "The function name or ``\"\"``." msgstr "" -#: library/bdb.rst:377 +#: library/bdb.rst:380 msgid "The input arguments." msgstr "" -#: library/bdb.rst:378 +#: library/bdb.rst:381 msgid "The return value." msgstr "" -#: library/bdb.rst:379 +#: library/bdb.rst:382 msgid "The line of code (if it exists)." msgstr "" -#: library/bdb.rst:382 +#: library/bdb.rst:385 msgid "" "The following two methods can be called by clients to use a debugger to " "debug a :term:`statement`, given as a string." msgstr "" -#: library/bdb.rst:387 +#: library/bdb.rst:390 msgid "" "Debug a statement executed via the :func:`exec` function. *globals* " "defaults to :attr:`!__main__.__dict__`, *locals* defaults to *globals*." msgstr "" -#: library/bdb.rst:392 +#: library/bdb.rst:395 msgid "" "Debug an expression executed via the :func:`eval` function. *globals* and " "*locals* have the same meaning as in :meth:`run`." msgstr "" -#: library/bdb.rst:397 +#: library/bdb.rst:400 msgid "For backwards compatibility. Calls the :meth:`run` method." msgstr "" -#: library/bdb.rst:401 +#: library/bdb.rst:404 msgid "Debug a single function call, and return its result." msgstr "" -#: library/bdb.rst:404 +#: library/bdb.rst:407 msgid "Finally, the module defines the following functions:" msgstr "" -#: library/bdb.rst:408 +#: library/bdb.rst:411 msgid "" -"Return True if we should break here, depending on the way the :class:" -"`Breakpoint` *b* was set." +"Return ``True`` if we should break here, depending on the way " +"the :class:`Breakpoint` *b* was set." msgstr "" -#: library/bdb.rst:411 +#: library/bdb.rst:414 msgid "" -"If it was set via line number, it checks if :attr:`b.line ` is the same as the one in *frame*. If the breakpoint was set via :" -"attr:`function name `, we have to check we are in " -"the right *frame* (the right function) and if we are on its first executable " -"line." +"If it was set via line number, it checks if :attr:`b.line " +"` is the same as the one in *frame*. If the breakpoint " +"was set via :attr:`function name `, we have to " +"check we are in the right *frame* (the right function) and if we are on its " +"first executable line." msgstr "" -#: library/bdb.rst:420 +#: library/bdb.rst:423 msgid "" "Return ``(active breakpoint, delete temporary flag)`` or ``(None, None)`` as " "the breakpoint to act upon." msgstr "" -#: library/bdb.rst:423 +#: library/bdb.rst:426 msgid "" -"The *active breakpoint* is the first entry in :attr:`bplist ` for the (:attr:`file `, :attr:`line `) (which must exist) that is :attr:`enabled `, for which :func:`checkfuncname` is True, and that has neither a " -"False :attr:`condition ` nor positive :attr:`ignore " +"The *active breakpoint* is the first entry in :attr:`bplist " +"` for the (:attr:`file " +"`, :attr:`line `) (which must " +"exist) that is :attr:`enabled `, for " +"which :func:`checkfuncname` is true, and that has neither a " +"false :attr:`condition ` nor positive :attr:`ignore " "` count. The *flag*, meaning that a temporary " -"breakpoint should be deleted, is False only when the :attr:`cond ` cannot be evaluated (in which case, :attr:`ignore ` count is ignored)." +"breakpoint should be deleted, is ``False`` only when the :attr:`cond " +"` cannot be evaluated (in which case, :attr:`ignore " +"` count is ignored)." msgstr "" -#: library/bdb.rst:434 -msgid "If no such entry exists, then (None, None) is returned." +#: library/bdb.rst:437 +msgid "If no such entry exists, then ``(None, None)`` is returned." msgstr "" -#: library/bdb.rst:439 +#: library/bdb.rst:442 msgid "Start debugging with a :class:`Bdb` instance from caller's frame." msgstr "" -#: library/bdb.rst:296 +#: library/bdb.rst:299 msgid "quitting (bdb.Bdb attribute)" msgstr "" diff --git a/library/binary.po b/library/binary.po index 8eefeeb7..e8cd886c 100644 --- a/library/binary.po +++ b/library/binary.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/binascii.po b/library/binascii.po index fdfd920f..3bbed3ba 100644 --- a/library/binascii.po +++ b/library/binascii.po @@ -8,24 +8,25 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/binascii.rst:2 -msgid ":mod:`binascii` --- Convert between binary and ASCII" +msgid ":mod:`!binascii` --- Convert between binary and ASCII" msgstr "" #: library/binascii.rst:14 msgid "" "The :mod:`binascii` module contains a number of methods to convert between " "binary and various ASCII-encoded binary representations. Normally, you will " -"not use these functions directly but use wrapper modules like :mod:`uu` or :" -"mod:`base64` instead. The :mod:`binascii` module contains low-level " +"not use these functions directly but use wrapper modules like :mod:`uu` " +"or :mod:`base64` instead. The :mod:`binascii` module contains low-level " "functions written in C for greater speed that are used by the higher-level " "modules." msgstr "" @@ -151,6 +152,15 @@ msgid "" "algorithm. Use as follows::" msgstr "" +#: library/binascii.rst:117 +msgid "" +"print(binascii.crc32(b\"hello world\"))\n" +"# Or, in two pieces:\n" +"crc = binascii.crc32(b\"hello\")\n" +"crc = binascii.crc32(b\" world\", crc)\n" +"print('crc32 = {:#010x}'.format(crc))" +msgstr "" + #: library/binascii.rst:123 msgid "The result is always unsigned." msgstr "" @@ -191,8 +201,8 @@ msgstr "" #: library/binascii.rst:162 msgid "" "Similar functionality (accepting only text string arguments, but more " -"liberal towards whitespace) is also accessible using the :meth:`bytes." -"fromhex` class method." +"liberal towards whitespace) is also accessible using " +"the :meth:`bytes.fromhex` class method." msgstr "" #: library/binascii.rst:168 @@ -205,7 +215,7 @@ msgid "" "errors, but may be handled by reading a little more data and trying again." msgstr "" -#: library/binascii.rst:181 +#: library/binascii.rst:179 msgid "Module :mod:`base64`" msgstr "" @@ -214,7 +224,7 @@ msgid "" "Support for RFC compliant base64-style encoding in base 16, 32, 64, and 85." msgstr "" -#: library/binascii.rst:184 +#: library/binascii.rst:183 msgid "Module :mod:`uu`" msgstr "" diff --git a/library/bisect.po b/library/bisect.po index 7c4ce512..ed4bd2eb 100644 --- a/library/bisect.po +++ b/library/bisect.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/bisect.rst:2 -msgid ":mod:`bisect` --- Array bisection algorithm" +msgid ":mod:`!bisect` --- Array bisection algorithm" msgstr "" #: library/bisect.rst:10 @@ -37,10 +38,10 @@ msgid "" "The module is called :mod:`bisect` because it uses a basic bisection " "algorithm to do its work. Unlike other bisection tools that search for a " "specific value, the functions in this module are designed to locate an " -"insertion point. Accordingly, the functions never call an :meth:`~object." -"__eq__` method to determine whether a value has been found. Instead, the " -"functions only call the :meth:`~object.__lt__` method and will return an " -"insertion point between values in an array." +"insertion point. Accordingly, the functions never call " +"an :meth:`~object.__eq__` method to determine whether a value has been " +"found. Instead, the functions only call the :meth:`~object.__lt__` method " +"and will return an insertion point between values in an array." msgstr "" #: library/bisect.rst:29 @@ -159,10 +160,10 @@ msgid "" "The search functions are stateless and discard key function results after " "they are used. Consequently, if the search functions are used in a loop, " "the key function may be called again and again on the same array elements. " -"If the key function isn't fast, consider wrapping it with :py:func:" -"`functools.cache` to avoid duplicate computations. Alternatively, consider " -"searching an array of precomputed keys to locate the insertion point (as " -"shown in the examples section below)." +"If the key function isn't fast, consider wrapping it " +"with :py:func:`functools.cache` to avoid duplicate computations. " +"Alternatively, consider searching an array of precomputed keys to locate the " +"insertion point (as shown in the examples section below)." msgstr "" #: library/bisect.rst:131 @@ -193,6 +194,44 @@ msgid "" "sorted lists::" msgstr "" +#: library/bisect.rst:150 +msgid "" +"def index(a, x):\n" +" 'Locate the leftmost value exactly equal to x'\n" +" i = bisect_left(a, x)\n" +" if i != len(a) and a[i] == x:\n" +" return i\n" +" raise ValueError\n" +"\n" +"def find_lt(a, x):\n" +" 'Find rightmost value less than x'\n" +" i = bisect_left(a, x)\n" +" if i:\n" +" return a[i-1]\n" +" raise ValueError\n" +"\n" +"def find_le(a, x):\n" +" 'Find rightmost value less than or equal to x'\n" +" i = bisect_right(a, x)\n" +" if i:\n" +" return a[i-1]\n" +" raise ValueError\n" +"\n" +"def find_gt(a, x):\n" +" 'Find leftmost value greater than x'\n" +" i = bisect_right(a, x)\n" +" if i != len(a):\n" +" return a[i]\n" +" raise ValueError\n" +"\n" +"def find_ge(a, x):\n" +" 'Find leftmost item greater than or equal to x'\n" +" i = bisect_left(a, x)\n" +" if i != len(a):\n" +" return a[i]\n" +" raise ValueError" +msgstr "" + #: library/bisect.rst:187 msgid "Examples" msgstr "" @@ -205,6 +244,16 @@ msgid "" "90 and up is an 'A', 80 to 89 is a 'B', and so on::" msgstr "" +#: library/bisect.rst:196 +msgid "" +">>> def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'):\n" +"... i = bisect(breakpoints, score)\n" +"... return grades[i]\n" +"...\n" +">>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]\n" +"['F', 'A', 'C', 'C', 'B', 'A', 'A']" +msgstr "" + #: library/bisect.rst:203 msgid "" "The :py:func:`~bisect.bisect` and :py:func:`~bisect.insort` functions also " @@ -212,8 +261,56 @@ msgid "" "field used for ordering records in a table::" msgstr "" +#: library/bisect.rst:207 +msgid "" +">>> from collections import namedtuple\n" +">>> from operator import attrgetter\n" +">>> from bisect import bisect, insort\n" +">>> from pprint import pprint\n" +"\n" +">>> Movie = namedtuple('Movie', ('name', 'released', 'director'))\n" +"\n" +">>> movies = [\n" +"... Movie('Jaws', 1975, 'Spielberg'),\n" +"... Movie('Titanic', 1997, 'Cameron'),\n" +"... Movie('The Birds', 1963, 'Hitchcock'),\n" +"... Movie('Aliens', 1986, 'Cameron')\n" +"... ]\n" +"\n" +">>> # Find the first movie released after 1960\n" +">>> by_year = attrgetter('released')\n" +">>> movies.sort(key=by_year)\n" +">>> movies[bisect(movies, 1960, key=by_year)]\n" +"Movie(name='The Birds', released=1963, director='Hitchcock')\n" +"\n" +">>> # Insert a movie while maintaining sort order\n" +">>> romance = Movie('Love Story', 1970, 'Hiller')\n" +">>> insort(movies, romance, key=by_year)\n" +">>> pprint(movies)\n" +"[Movie(name='The Birds', released=1963, director='Hitchcock'),\n" +" Movie(name='Love Story', released=1970, director='Hiller'),\n" +" Movie(name='Jaws', released=1975, director='Spielberg'),\n" +" Movie(name='Aliens', released=1986, director='Cameron'),\n" +" Movie(name='Titanic', released=1997, director='Cameron')]" +msgstr "" + #: library/bisect.rst:237 msgid "" "If the key function is expensive, it is possible to avoid repeated function " "calls by searching a list of precomputed keys to find the index of a record::" msgstr "" + +#: library/bisect.rst:240 +msgid "" +">>> data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)]\n" +">>> data.sort(key=lambda r: r[1]) # Or use operator.itemgetter(1).\n" +">>> keys = [r[1] for r in data] # Precompute a list of keys.\n" +">>> data[bisect_left(keys, 0)]\n" +"('black', 0)\n" +">>> data[bisect_left(keys, 1)]\n" +"('blue', 1)\n" +">>> data[bisect_left(keys, 5)]\n" +"('red', 5)\n" +">>> data[bisect_left(keys, 8)]\n" +"('yellow', 8)" +msgstr "" diff --git a/library/builtins.po b/library/builtins.po index 331c429b..7e6e0b5d 100644 --- a/library/builtins.po +++ b/library/builtins.po @@ -8,27 +8,27 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/builtins.rst:2 -msgid ":mod:`builtins` --- Built-in objects" +msgid ":mod:`!builtins` --- Built-in objects" msgstr "" #: library/builtins.rst:9 msgid "" "This module provides direct access to all 'built-in' identifiers of Python; " -"for example, ``builtins.open`` is the full name for the built-in function :" -"func:`open`. See :ref:`built-in-funcs` and :ref:`built-in-consts` for " -"documentation." +"for example, ``builtins.open`` is the full name for the built-in " +"function :func:`open`." msgstr "" -#: library/builtins.rst:15 +#: library/builtins.rst:12 msgid "" "This module is not normally accessed explicitly by most applications, but " "can be useful in modules that provide objects with the same name as a built-" @@ -37,11 +37,47 @@ msgid "" "wraps the built-in :func:`open`, this module can be used directly::" msgstr "" -#: library/builtins.rst:38 +#: library/builtins.rst:18 +msgid "" +"import builtins\n" +"\n" +"def open(path):\n" +" f = builtins.open(path, 'r')\n" +" return UpperCaser(f)\n" +"\n" +"class UpperCaser:\n" +" '''Wrapper around a file that converts output to uppercase.'''\n" +"\n" +" def __init__(self, f):\n" +" self._f = f\n" +"\n" +" def read(self, count=-1):\n" +" return self._f.read(count).upper()\n" +"\n" +" # ..." +msgstr "" + +#: library/builtins.rst:35 msgid "" "As an implementation detail, most modules have the name ``__builtins__`` " "made available as part of their globals. The value of ``__builtins__`` is " -"normally either this module or the value of this module's :attr:`~object." -"__dict__` attribute. Since this is an implementation detail, it may not be " -"used by alternate implementations of Python." +"normally either this module or the value of this " +"module's :attr:`~object.__dict__` attribute. Since this is an implementation " +"detail, it may not be used by alternate implementations of Python." +msgstr "" + +#: library/builtins.rst:43 +msgid ":ref:`built-in-consts`" +msgstr "" + +#: library/builtins.rst:44 +msgid ":ref:`bltin-exceptions`" +msgstr "" + +#: library/builtins.rst:45 +msgid ":ref:`built-in-funcs`" +msgstr "" + +#: library/builtins.rst:46 +msgid ":ref:`bltin-types`" msgstr "" diff --git a/library/bz2.po b/library/bz2.po index 61052271..30a82bba 100644 --- a/library/bz2.po +++ b/library/bz2.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/bz2.rst:2 -msgid ":mod:`bz2` --- Support for :program:`bzip2` compression" +msgid ":mod:`!bz2` --- Support for :program:`bzip2` compression" msgstr "" #: library/bz2.rst:12 @@ -78,8 +79,8 @@ msgstr "" #: library/bz2.rst:45 msgid "" -"The *compresslevel* argument is an integer from 1 to 9, as for the :class:" -"`BZ2File` constructor." +"The *compresslevel* argument is an integer from 1 to 9, as for " +"the :class:`BZ2File` constructor." msgstr "" #: library/bz2.rst:48 @@ -92,8 +93,8 @@ msgstr "" #: library/bz2.rst:53 msgid "" -"For text mode, a :class:`BZ2File` object is created, and wrapped in an :" -"class:`io.TextIOWrapper` instance with the specified encoding, error " +"For text mode, a :class:`BZ2File` object is created, and wrapped in " +"an :class:`io.TextIOWrapper` instance with the specified encoding, error " "handling behavior, and line ending(s)." msgstr "" @@ -145,9 +146,10 @@ msgstr "" #: library/bz2.rst:89 msgid "" -":class:`BZ2File` provides all of the members specified by the :class:`io." -"BufferedIOBase`, except for :meth:`~io.BufferedIOBase.detach` and :meth:`~io." -"IOBase.truncate`. Iteration and the :keyword:`with` statement are supported." +":class:`BZ2File` provides all of the members specified by " +"the :class:`io.BufferedIOBase`, except for :meth:`~io.BufferedIOBase.detach` " +"and :meth:`~io.IOBase.truncate`. Iteration and the :keyword:`with` statement " +"are supported." msgstr "" #: library/bz2.rst:94 @@ -163,10 +165,10 @@ msgstr "" #: library/bz2.rst:102 msgid "" -"While calling :meth:`peek` does not change the file position of the :class:" -"`BZ2File`, it may change the position of the underlying file object (e.g. if " -"the :class:`BZ2File` was constructed by passing a file object for " -"*filename*)." +"While calling :meth:`peek` does not change the file position of " +"the :class:`BZ2File`, it may change the position of the underlying file " +"object (e.g. if the :class:`BZ2File` was constructed by passing a file " +"object for *filename*)." msgstr "" #: library/bz2.rst:111 @@ -268,8 +270,8 @@ msgstr "" #: library/bz2.rst:202 msgid "" -"When you have finished providing data to the compressor, call the :meth:" -"`flush` method to finish the compression process." +"When you have finished providing data to the compressor, call " +"the :meth:`flush` method to finish the compression process." msgstr "" #: library/bz2.rst:208 @@ -324,9 +326,9 @@ msgstr "" #: library/bz2.rst:246 msgid "" -"Attempting to decompress data after the end of stream is reached raises an :" -"exc:`EOFError`. Any data found after the end of the stream is ignored and " -"saved in the :attr:`~.unused_data` attribute." +"Attempting to decompress data after the end of stream is reached raises " +"an :exc:`EOFError`. Any data found after the end of the stream is ignored " +"and saved in the :attr:`~.unused_data` attribute." msgstr "" #: library/bz2.rst:250 diff --git a/library/calendar.po b/library/calendar.po index 70e0e251..f6fe2964 100644 --- a/library/calendar.po +++ b/library/calendar.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/calendar.rst:2 -msgid ":mod:`calendar` --- General calendar-related functions" +msgid ":mod:`!calendar` --- General calendar-related functions" msgstr "" #: library/calendar.rst:10 @@ -49,8 +50,8 @@ msgstr "" #: library/calendar.rst:33 msgid "" "Creates a :class:`Calendar` object. *firstweekday* is an integer specifying " -"the first day of the week. :const:`MONDAY` is ``0`` (the default), :const:" -"`SUNDAY` is ``6``." +"the first day of the week. :const:`MONDAY` is ``0`` (the " +"default), :const:`SUNDAY` is ``6``." msgstr "" #: library/calendar.rst:36 @@ -61,17 +62,45 @@ msgid "" msgstr "" #: library/calendar.rst:41 -msgid ":class:`Calendar` instances have the following methods:" +msgid ":class:`Calendar` instances have the following methods and attributes:" msgstr "" #: library/calendar.rst:45 +msgid "The first weekday as an integer (0--6)." +msgstr "" + +#: library/calendar.rst:47 +msgid "" +"This property can also be set and read " +"using :meth:`~Calendar.setfirstweekday` " +"and :meth:`~Calendar.getfirstweekday` respectively." +msgstr "" + +#: library/calendar.rst:53 +msgid "Return an :class:`int` for the current first weekday (0--6)." +msgstr "" + +#: library/calendar.rst:55 +msgid "Identical to reading the :attr:`~Calendar.firstweekday` property." +msgstr "" + +#: library/calendar.rst:59 +msgid "" +"Set the first weekday to *firstweekday*, passed as an :class:`int` (0--6)" +msgstr "" + +#: library/calendar.rst:61 +msgid "Identical to setting the :attr:`~Calendar.firstweekday` property." +msgstr "" + +#: library/calendar.rst:65 msgid "" "Return an iterator for the week day numbers that will be used for one week. " -"The first value from the iterator will be the same as the value of the :attr:" -"`firstweekday` property." +"The first value from the iterator will be the same as the value of " +"the :attr:`~Calendar.firstweekday` property." msgstr "" -#: library/calendar.rst:52 +#: library/calendar.rst:72 msgid "" "Return an iterator for the month *month* (1--12) in the year *year*. This " "iterator will return all days (as :class:`datetime.date` objects) for the " @@ -79,57 +108,57 @@ msgid "" "month that are required to get a complete week." msgstr "" -#: library/calendar.rst:60 +#: library/calendar.rst:80 msgid "" -"Return an iterator for the month *month* in the year *year* similar to :meth:" -"`itermonthdates`, but not restricted by the :class:`datetime.date` range. " -"Days returned will simply be day of the month numbers. For the days outside " -"of the specified month, the day number is ``0``." +"Return an iterator for the month *month* in the year *year* similar " +"to :meth:`itermonthdates`, but not restricted by the :class:`datetime.date` " +"range. Days returned will simply be day of the month numbers. For the days " +"outside of the specified month, the day number is ``0``." msgstr "" -#: library/calendar.rst:68 +#: library/calendar.rst:88 msgid "" -"Return an iterator for the month *month* in the year *year* similar to :meth:" -"`itermonthdates`, but not restricted by the :class:`datetime.date` range. " -"Days returned will be tuples consisting of a day of the month number and a " -"week day number." +"Return an iterator for the month *month* in the year *year* similar " +"to :meth:`itermonthdates`, but not restricted by the :class:`datetime.date` " +"range. Days returned will be tuples consisting of a day of the month number " +"and a week day number." msgstr "" -#: library/calendar.rst:76 +#: library/calendar.rst:96 msgid "" -"Return an iterator for the month *month* in the year *year* similar to :meth:" -"`itermonthdates`, but not restricted by the :class:`datetime.date` range. " -"Days returned will be tuples consisting of a year, a month and a day of the " -"month numbers." +"Return an iterator for the month *month* in the year *year* similar " +"to :meth:`itermonthdates`, but not restricted by the :class:`datetime.date` " +"range. Days returned will be tuples consisting of a year, a month and a day " +"of the month numbers." msgstr "" -#: library/calendar.rst:86 +#: library/calendar.rst:106 msgid "" -"Return an iterator for the month *month* in the year *year* similar to :meth:" -"`itermonthdates`, but not restricted by the :class:`datetime.date` range. " -"Days returned will be tuples consisting of a year, a month, a day of the " -"month, and a day of the week numbers." +"Return an iterator for the month *month* in the year *year* similar " +"to :meth:`itermonthdates`, but not restricted by the :class:`datetime.date` " +"range. Days returned will be tuples consisting of a year, a month, a day of " +"the month, and a day of the week numbers." msgstr "" -#: library/calendar.rst:96 +#: library/calendar.rst:116 msgid "" "Return a list of the weeks in the month *month* of the *year* as full " "weeks. Weeks are lists of seven :class:`datetime.date` objects." msgstr "" -#: library/calendar.rst:102 +#: library/calendar.rst:122 msgid "" "Return a list of the weeks in the month *month* of the *year* as full " "weeks. Weeks are lists of seven tuples of day numbers and weekday numbers." msgstr "" -#: library/calendar.rst:109 +#: library/calendar.rst:129 msgid "" "Return a list of the weeks in the month *month* of the *year* as full " "weeks. Weeks are lists of seven day numbers." msgstr "" -#: library/calendar.rst:115 +#: library/calendar.rst:135 msgid "" "Return the data for the specified year ready for formatting. The return " "value is a list of month rows. Each month row contains up to *width* months " @@ -137,77 +166,114 @@ msgid "" "contains 1--7 days. Days are :class:`datetime.date` objects." msgstr "" -#: library/calendar.rst:123 +#: library/calendar.rst:143 msgid "" -"Return the data for the specified year ready for formatting (similar to :" -"meth:`yeardatescalendar`). Entries in the week lists are tuples of day " +"Return the data for the specified year ready for formatting (similar " +"to :meth:`yeardatescalendar`). Entries in the week lists are tuples of day " "numbers and weekday numbers. Day numbers outside this month are zero." msgstr "" -#: library/calendar.rst:130 +#: library/calendar.rst:150 msgid "" -"Return the data for the specified year ready for formatting (similar to :" -"meth:`yeardatescalendar`). Entries in the week lists are day numbers. Day " -"numbers outside this month are zero." +"Return the data for the specified year ready for formatting (similar " +"to :meth:`yeardatescalendar`). Entries in the week lists are day numbers. " +"Day numbers outside this month are zero." msgstr "" -#: library/calendar.rst:137 +#: library/calendar.rst:157 msgid "This class can be used to generate plain text calendars." msgstr "" -#: library/calendar.rst:139 +#: library/calendar.rst:159 msgid ":class:`TextCalendar` instances have the following methods:" msgstr "" -#: library/calendar.rst:143 +#: library/calendar.rst:164 +msgid "" +"Return a string representing a single day formatted with the given *width*. " +"If *theday* is ``0``, return a string of spaces of the specified width, " +"representing an empty day. The *weekday* parameter is unused." +msgstr "" + +#: library/calendar.rst:171 +msgid "" +"Return a single week in a string with no newline. If *w* is provided, it " +"specifies the width of the date columns, which are centered. Depends on the " +"first weekday as specified in the constructor or set by " +"the :meth:`setfirstweekday` method." +msgstr "" + +#: library/calendar.rst:178 +msgid "" +"Return a string representing the name of a single weekday formatted to the " +"specified *width*. The *weekday* parameter is an integer representing the " +"day of the week, where ``0`` is Monday and ``6`` is Sunday." +msgstr "" + +#: library/calendar.rst:184 +msgid "" +"Return a string containing the header row of weekday names, formatted with " +"the given *width* for each column. The names depend on the locale settings " +"and are padded to the specified width." +msgstr "" + +#: library/calendar.rst:190 msgid "" "Return a month's calendar in a multi-line string. If *w* is provided, it " "specifies the width of the date columns, which are centered. If *l* is " "given, it specifies the number of lines that each week will use. Depends on " -"the first weekday as specified in the constructor or set by the :meth:" -"`setfirstweekday` method." +"the first weekday as specified in the constructor or set by " +"the :meth:`setfirstweekday` method." +msgstr "" + +#: library/calendar.rst:198 +msgid "" +"Return a string representing the month's name centered within the specified " +"*width*. If *withyear* is ``True``, include the year in the output. The " +"*theyear* and *themonth* parameters specify the year and month for the name " +"to be formatted respectively." msgstr "" -#: library/calendar.rst:152 +#: library/calendar.rst:205 msgid "Print a month's calendar as returned by :meth:`formatmonth`." msgstr "" -#: library/calendar.rst:157 +#: library/calendar.rst:210 msgid "" "Return a *m*-column calendar for an entire year as a multi-line string. " "Optional parameters *w*, *l*, and *c* are for date column width, lines per " "week, and number of spaces between month columns, respectively. Depends on " -"the first weekday as specified in the constructor or set by the :meth:" -"`setfirstweekday` method. The earliest year for which a calendar can be " -"generated is platform-dependent." +"the first weekday as specified in the constructor or set by " +"the :meth:`setfirstweekday` method. The earliest year for which a calendar " +"can be generated is platform-dependent." msgstr "" -#: library/calendar.rst:167 +#: library/calendar.rst:220 msgid "" "Print the calendar for an entire year as returned by :meth:`formatyear`." msgstr "" -#: library/calendar.rst:172 +#: library/calendar.rst:225 msgid "This class can be used to generate HTML calendars." msgstr "" -#: library/calendar.rst:175 +#: library/calendar.rst:228 msgid ":class:`!HTMLCalendar` instances have the following methods:" msgstr "" -#: library/calendar.rst:179 +#: library/calendar.rst:232 msgid "" "Return a month's calendar as an HTML table. If *withyear* is true the year " "will be included in the header, otherwise just the month name will be used." msgstr "" -#: library/calendar.rst:186 +#: library/calendar.rst:239 msgid "" "Return a year's calendar as an HTML table. *width* (defaulting to 3) " "specifies the number of months per row." msgstr "" -#: library/calendar.rst:192 +#: library/calendar.rst:245 msgid "" "Return a year's calendar as a complete HTML page. *width* (defaulting to 3) " "specifies the number of months per row. *css* is the name for the cascading " @@ -216,89 +282,114 @@ msgid "" "(defaulting to the system default encoding)." msgstr "" -#: library/calendar.rst:201 +#: library/calendar.rst:254 msgid "" "Return a month name as an HTML table row. If *withyear* is true the year " "will be included in the row, otherwise just the month name will be used." msgstr "" -#: library/calendar.rst:206 +#: library/calendar.rst:259 msgid "" ":class:`!HTMLCalendar` has the following attributes you can override to " "customize the CSS classes used by the calendar:" msgstr "" -#: library/calendar.rst:211 +#: library/calendar.rst:264 msgid "" "A list of CSS classes used for each weekday. The default class list is::" msgstr "" -#: library/calendar.rst:215 +#: library/calendar.rst:266 +msgid "" +"cssclasses = [\"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\", \"sun\"]" +msgstr "" + +#: library/calendar.rst:268 msgid "more styles can be added for each day::" msgstr "" -#: library/calendar.rst:219 +#: library/calendar.rst:270 +msgid "" +"cssclasses = [\"mon text-bold\", \"tue\", \"wed\", \"thu\", \"fri\", " +"\"sat\", \"sun red\"]" +msgstr "" + +#: library/calendar.rst:272 msgid "Note that the length of this list must be seven items." msgstr "" -#: library/calendar.rst:224 +#: library/calendar.rst:277 msgid "The CSS class for a weekday occurring in the previous or coming month." msgstr "" -#: library/calendar.rst:231 +#: library/calendar.rst:284 msgid "" "A list of CSS classes used for weekday names in the header row. The default " "is the same as :attr:`cssclasses`." msgstr "" -#: library/calendar.rst:239 +#: library/calendar.rst:292 msgid "" "The month's head CSS class (used by :meth:`formatmonthname`). The default " "value is ``\"month\"``." msgstr "" -#: library/calendar.rst:247 +#: library/calendar.rst:300 msgid "" "The CSS class for the whole month's table (used by :meth:`formatmonth`). The " "default value is ``\"month\"``." msgstr "" -#: library/calendar.rst:255 +#: library/calendar.rst:308 msgid "" -"The CSS class for the whole year's table of tables (used by :meth:" -"`formatyear`). The default value is ``\"year\"``." +"The CSS class for the whole year's table of tables (used " +"by :meth:`formatyear`). The default value is ``\"year\"``." msgstr "" -#: library/calendar.rst:263 +#: library/calendar.rst:316 msgid "" -"The CSS class for the table head for the whole year (used by :meth:" -"`formatyear`). The default value is ``\"year\"``." +"The CSS class for the table head for the whole year (used " +"by :meth:`formatyear`). The default value is ``\"year\"``." msgstr "" -#: library/calendar.rst:269 +#: library/calendar.rst:322 msgid "" "Note that although the naming for the above described class attributes is " "singular (e.g. ``cssclass_month`` ``cssclass_noday``), one can replace the " "single CSS class with a space separated list of CSS classes, for example::" msgstr "" -#: library/calendar.rst:275 +#: library/calendar.rst:326 +msgid "\"text-bold text-red\"" +msgstr "" + +#: library/calendar.rst:328 msgid "Here is an example how :class:`!HTMLCalendar` can be customized::" msgstr "" -#: library/calendar.rst:287 +#: library/calendar.rst:330 +msgid "" +"class CustomHTMLCal(calendar.HTMLCalendar):\n" +" cssclasses = [style + \" text-nowrap\" for style in\n" +" calendar.HTMLCalendar.cssclasses]\n" +" cssclass_month_head = \"text-center month-head\"\n" +" cssclass_month = \"text-center month\"\n" +" cssclass_year = \"text-italic lead\"" +msgstr "" + +#: library/calendar.rst:340 msgid "" "This subclass of :class:`TextCalendar` can be passed a locale name in the " "constructor and will return month and weekday names in the specified locale." msgstr "" -#: library/calendar.rst:293 +#: library/calendar.rst:346 msgid "" "This subclass of :class:`HTMLCalendar` can be passed a locale name in the " "constructor and will return month and weekday names in the specified locale." msgstr "" -#: library/calendar.rst:299 +#: library/calendar.rst:352 msgid "" "The constructor, :meth:`!formatweekday` and :meth:`!formatmonthname` methods " "of these two classes temporarily change the ``LC_TIME`` locale to the given " @@ -306,84 +397,90 @@ msgid "" "thread-safe." msgstr "" -#: library/calendar.rst:305 +#: library/calendar.rst:358 msgid "For simple text calendars this module provides the following functions." msgstr "" -#: library/calendar.rst:309 +#: library/calendar.rst:362 msgid "" "Sets the weekday (``0`` is Monday, ``6`` is Sunday) to start each week. The " -"values :const:`MONDAY`, :const:`TUESDAY`, :const:`WEDNESDAY`, :const:" -"`THURSDAY`, :const:`FRIDAY`, :const:`SATURDAY`, and :const:`SUNDAY` are " -"provided for convenience. For example, to set the first weekday to Sunday::" +"values :const:`MONDAY`, :const:`TUESDAY`, :const:`WEDNESDAY`, :const:`THURSDAY`, :const:`FRIDAY`, :const:`SATURDAY`, " +"and :const:`SUNDAY` are provided for convenience. For example, to set the " +"first weekday to Sunday::" +msgstr "" + +#: library/calendar.rst:367 +msgid "" +"import calendar\n" +"calendar.setfirstweekday(calendar.SUNDAY)" msgstr "" -#: library/calendar.rst:320 +#: library/calendar.rst:373 msgid "Returns the current setting for the weekday to start each week." msgstr "" -#: library/calendar.rst:325 +#: library/calendar.rst:378 msgid "" "Returns :const:`True` if *year* is a leap year, otherwise :const:`False`." msgstr "" -#: library/calendar.rst:330 +#: library/calendar.rst:383 msgid "" "Returns the number of leap years in the range from *y1* to *y2* (exclusive), " "where *y1* and *y2* are years." msgstr "" -#: library/calendar.rst:333 +#: library/calendar.rst:386 msgid "This function works for ranges spanning a century change." msgstr "" -#: library/calendar.rst:338 +#: library/calendar.rst:391 msgid "" "Returns the day of the week (``0`` is Monday) for *year* (``1970``--...), " "*month* (``1``--``12``), *day* (``1``--``31``)." msgstr "" -#: library/calendar.rst:344 +#: library/calendar.rst:397 msgid "" "Return a header containing abbreviated weekday names. *n* specifies the " "width in characters for one weekday." msgstr "" -#: library/calendar.rst:350 +#: library/calendar.rst:403 msgid "" "Returns weekday of first day of the month and number of days in month, for " "the specified *year* and *month*." msgstr "" -#: library/calendar.rst:356 +#: library/calendar.rst:409 msgid "" "Returns a matrix representing a month's calendar. Each row represents a " "week; days outside of the month are represented by zeros. Each week begins " "with Monday unless set by :func:`setfirstweekday`." msgstr "" -#: library/calendar.rst:363 +#: library/calendar.rst:416 msgid "Prints a month's calendar as returned by :func:`month`." msgstr "" -#: library/calendar.rst:368 +#: library/calendar.rst:421 msgid "" -"Returns a month's calendar in a multi-line string using the :meth:" -"`~TextCalendar.formatmonth` of the :class:`TextCalendar` class." +"Returns a month's calendar in a multi-line string using " +"the :meth:`~TextCalendar.formatmonth` of the :class:`TextCalendar` class." msgstr "" -#: library/calendar.rst:374 +#: library/calendar.rst:427 msgid "" "Prints the calendar for an entire year as returned by :func:`calendar`." msgstr "" -#: library/calendar.rst:379 +#: library/calendar.rst:432 msgid "" "Returns a 3-column calendar for an entire year as a multi-line string using " "the :meth:`~TextCalendar.formatyear` of the :class:`TextCalendar` class." msgstr "" -#: library/calendar.rst:385 +#: library/calendar.rst:438 msgid "" "An unrelated but handy function that takes a time tuple such as returned by " "the :func:`~time.gmtime` function in the :mod:`time` module, and returns the " @@ -392,182 +489,232 @@ msgid "" "inverse." msgstr "" -#: library/calendar.rst:392 +#: library/calendar.rst:445 msgid "The :mod:`calendar` module exports the following data attributes:" msgstr "" -#: library/calendar.rst:396 -msgid "An array that represents the days of the week in the current locale." +#: library/calendar.rst:449 +msgid "" +"A sequence that represents the days of the week in the current locale, where " +"Monday is day number 0." msgstr "" -#: library/calendar.rst:401 +#: library/calendar.rst:459 msgid "" -"An array that represents the abbreviated days of the week in the current " -"locale." +"A sequence that represents the abbreviated days of the week in the current " +"locale, where Mon is day number 0." msgstr "" -#: library/calendar.rst:412 +#: library/calendar.rst:474 msgid "" "Aliases for the days of the week, where ``MONDAY`` is ``0`` and ``SUNDAY`` " "is ``6``." msgstr "" -#: library/calendar.rst:420 +#: library/calendar.rst:482 msgid "" "Enumeration defining days of the week as integer constants. The members of " -"this enumeration are exported to the module scope as :data:`MONDAY` through :" -"data:`SUNDAY`." +"this enumeration are exported to the module scope as :data:`MONDAY` " +"through :data:`SUNDAY`." msgstr "" -#: library/calendar.rst:429 +#: library/calendar.rst:491 msgid "" -"An array that represents the months of the year in the current locale. This " -"follows normal convention of January being month number 1, so it has a " -"length of 13 and ``month_name[0]`` is the empty string." +"A sequence that represents the months of the year in the current locale. " +"This follows normal convention of January being month number 1, so it has a " +"length of 13 and ``month_name[0]`` is the empty string." msgstr "" -#: library/calendar.rst:436 +#: library/calendar.rst:502 msgid "" -"An array that represents the abbreviated months of the year in the current " +"A sequence that represents the abbreviated months of the year in the current " "locale. This follows normal convention of January being month number 1, so " "it has a length of 13 and ``month_abbr[0]`` is the empty string." msgstr "" -#: library/calendar.rst:454 +#: library/calendar.rst:523 msgid "" "Aliases for the months of the year, where ``JANUARY`` is ``1`` and " "``DECEMBER`` is ``12``." msgstr "" -#: library/calendar.rst:462 +#: library/calendar.rst:531 msgid "" "Enumeration defining months of the year as integer constants. The members of " "this enumeration are exported to the module scope as :data:`JANUARY` " "through :data:`DECEMBER`." msgstr "" -#: library/calendar.rst:469 +#: library/calendar.rst:538 msgid "The :mod:`calendar` module defines the following exceptions:" msgstr "" -#: library/calendar.rst:473 +#: library/calendar.rst:542 msgid "" "A subclass of :exc:`ValueError`, raised when the given month number is " "outside of the range 1-12 (inclusive)." msgstr "" -#: library/calendar.rst:478 +#: library/calendar.rst:547 msgid "The invalid month number." msgstr "" -#: library/calendar.rst:483 +#: library/calendar.rst:552 msgid "" "A subclass of :exc:`ValueError`, raised when the given weekday number is " "outside of the range 0-6 (inclusive)." msgstr "" -#: library/calendar.rst:488 +#: library/calendar.rst:557 msgid "The invalid weekday number." msgstr "" -#: library/calendar.rst:495 +#: library/calendar.rst:562 msgid "Module :mod:`datetime`" msgstr "" -#: library/calendar.rst:494 +#: library/calendar.rst:563 msgid "" "Object-oriented interface to dates and times with similar functionality to " "the :mod:`time` module." msgstr "" -#: library/calendar.rst:497 +#: library/calendar.rst:566 msgid "Module :mod:`time`" msgstr "" -#: library/calendar.rst:498 +#: library/calendar.rst:567 msgid "Low-level time related functions." msgstr "" -#: library/calendar.rst:504 +#: library/calendar.rst:573 msgid "Command-Line Usage" msgstr "" -#: library/calendar.rst:508 +#: library/calendar.rst:577 msgid "" "The :mod:`calendar` module can be executed as a script from the command line " "to interactively print a calendar." msgstr "" -#: library/calendar.rst:518 +#: library/calendar.rst:580 +msgid "" +"python -m calendar [-h] [-L LOCALE] [-e ENCODING] [-t {text,html}]\n" +" [-w WIDTH] [-l LINES] [-s SPACING] [-m MONTHS] [-c CSS]\n" +" [year] [month]" +msgstr "" + +#: library/calendar.rst:587 msgid "For example, to print a calendar for the year 2000:" msgstr "" -#: library/calendar.rst:561 +#: library/calendar.rst:589 +msgid "" +"$ python -m calendar 2000\n" +" 2000\n" +"\n" +" January February March\n" +"Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su\n" +" 1 2 1 2 3 4 5 6 1 2 3 4 5\n" +" 3 4 5 6 7 8 9 7 8 9 10 11 12 13 6 7 8 9 10 11 12\n" +"10 11 12 13 14 15 16 14 15 16 17 18 19 20 13 14 15 16 17 18 19\n" +"17 18 19 20 21 22 23 21 22 23 24 25 26 27 20 21 22 23 24 25 26\n" +"24 25 26 27 28 29 30 28 29 27 28 29 30 31\n" +"31\n" +"\n" +" April May June\n" +"Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su\n" +" 1 2 1 2 3 4 5 6 7 1 2 3 4\n" +" 3 4 5 6 7 8 9 8 9 10 11 12 13 14 5 6 7 8 9 10 11\n" +"10 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 18\n" +"17 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 25\n" +"24 25 26 27 28 29 30 29 30 31 26 27 28 29 30\n" +"\n" +" July August September\n" +"Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su\n" +" 1 2 1 2 3 4 5 6 1 2 3\n" +" 3 4 5 6 7 8 9 7 8 9 10 11 12 13 4 5 6 7 8 9 10\n" +"10 11 12 13 14 15 16 14 15 16 17 18 19 20 11 12 13 14 15 16 17\n" +"17 18 19 20 21 22 23 21 22 23 24 25 26 27 18 19 20 21 22 23 24\n" +"24 25 26 27 28 29 30 28 29 30 31 25 26 27 28 29 30\n" +"31\n" +"\n" +" October November December\n" +"Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su\n" +" 1 1 2 3 4 5 1 2 3\n" +" 2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10\n" +" 9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17\n" +"16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24\n" +"23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31\n" +"30 31" +msgstr "" + +#: library/calendar.rst:630 msgid "The following options are accepted:" msgstr "" -#: library/calendar.rst:568 +#: library/calendar.rst:637 msgid "Show the help message and exit." msgstr "" -#: library/calendar.rst:573 +#: library/calendar.rst:642 msgid "The locale to use for month and weekday names. Defaults to English." msgstr "" -#: library/calendar.rst:579 +#: library/calendar.rst:648 msgid "" -"The encoding to use for output. :option:`--encoding` is required if :option:" -"`--locale` is set." +"The encoding to use for output. :option:`--encoding` is required " +"if :option:`--locale` is set." msgstr "" -#: library/calendar.rst:585 +#: library/calendar.rst:654 msgid "Print the calendar to the terminal as text, or as an HTML document." msgstr "" -#: library/calendar.rst:591 +#: library/calendar.rst:660 msgid "" "The year to print the calendar for. Must be a number between 1 and 9999. " "Defaults to the current year." msgstr "" -#: library/calendar.rst:598 +#: library/calendar.rst:667 msgid "" "The month of the specified :option:`year` to print the calendar for. Must be " "a number between 1 and 12, and may only be used in text mode. Defaults to " "printing a calendar for the full year." msgstr "" -#: library/calendar.rst:604 +#: library/calendar.rst:673 msgid "*Text-mode options:*" msgstr "" -#: library/calendar.rst:608 +#: library/calendar.rst:677 msgid "" "The width of the date column in terminal columns. The date is printed " "centred in the column. Any value lower than 2 is ignored. Defaults to 2." msgstr "" -#: library/calendar.rst:616 +#: library/calendar.rst:685 msgid "" "The number of lines for each week in terminal rows. The date is printed top-" "aligned. Any value lower than 1 is ignored. Defaults to 1." msgstr "" -#: library/calendar.rst:624 +#: library/calendar.rst:693 msgid "" "The space between months in columns. Any value lower than 2 is ignored. " "Defaults to 6." msgstr "" -#: library/calendar.rst:631 +#: library/calendar.rst:700 msgid "The number of months printed per row. Defaults to 3." msgstr "" -#: library/calendar.rst:635 +#: library/calendar.rst:704 msgid "*HTML-mode options:*" msgstr "" -#: library/calendar.rst:639 +#: library/calendar.rst:708 msgid "" "The path of a CSS stylesheet to use for the calendar. This must either be " "relative to the generated HTML, or an absolute HTTP or ``file:///`` URL." diff --git a/library/cgi.po b/library/cgi.po index 2e7eeff5..4d98b536 100644 --- a/library/cgi.po +++ b/library/cgi.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,7 +25,7 @@ msgstr "" msgid "**Source code:** :source:`Lib/cgi.py`" msgstr "" -#: library/cgi.rst:27 +#: library/cgi.rst:18 msgid "" "The :mod:`cgi` module is deprecated (see :pep:`PEP 594 <594#cgi>` for " "details and alternatives)." @@ -32,11 +33,11 @@ msgstr "" #: library/cgi.rst:22 msgid "" -"The :class:`FieldStorage` class can typically be replaced with :func:`urllib." -"parse.parse_qsl` for ``GET`` and ``HEAD`` requests, and the :mod:`email." -"message` module or `multipart `_ for " -"``POST`` and ``PUT``. Most :ref:`utility functions ` have replacements." +"The :class:`FieldStorage` class can typically be replaced " +"with :func:`urllib.parse.parse_qsl` for ``GET`` and ``HEAD`` requests, and " +"the :mod:`email.message` module or :pypi:`multipart` for ``POST`` and " +"``PUT``. Most :ref:`utility functions ` have " +"replacements." msgstr "" #: library/cgi.rst:30 @@ -58,7 +59,7 @@ msgid "" msgstr "" #: includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." +msgid "Availability" msgstr "" #: includes/wasm-notavail.rst:5 @@ -106,6 +107,12 @@ msgid "" "header section looks like this::" msgstr "" +#: library/cgi.rst:68 +msgid "" +"print(\"Content-Type: text/html\") # HTML is following\n" +"print() # blank line, end of headers" +msgstr "" + #: library/cgi.rst:71 msgid "" "The second section is usually HTML, which allows the client software to " @@ -113,6 +120,13 @@ msgid "" "Python code that prints a simple piece of HTML::" msgstr "" +#: library/cgi.rst:75 +msgid "" +"print(\"CGI script output\")\n" +"print(\"

This is my first CGI script

\")\n" +"print(\"Hello, world!\")" +msgstr "" + #: library/cgi.rst:83 msgid "Using the cgi module" msgstr "" @@ -125,6 +139,12 @@ msgstr "" msgid "When you write a new script, consider adding these lines::" msgstr "" +#: library/cgi.rst:505 +msgid "" +"import cgitb\n" +"cgitb.enable()" +msgstr "" + #: library/cgi.rst:92 msgid "" "This activates a special exception handler that will display detailed " @@ -133,6 +153,12 @@ msgid "" "saved to files instead, with code like this::" msgstr "" +#: library/cgi.rst:97 +msgid "" +"import cgitb\n" +"cgitb.enable(display=0, logdir=\"/path/to/logdir\")" +msgstr "" + #: library/cgi.rst:100 msgid "" "It's very helpful to use this feature during script development. The reports " @@ -160,15 +186,28 @@ msgid "" "supports the standard dictionary method :meth:`~dict.keys` and the built-in " "function :func:`len`. Form fields containing empty strings are ignored and " "do not appear in the dictionary; to keep such values, provide a true value " -"for the optional *keep_blank_values* keyword parameter when creating the :" -"class:`FieldStorage` instance." +"for the optional *keep_blank_values* keyword parameter when creating " +"the :class:`FieldStorage` instance." msgstr "" #: library/cgi.rst:122 msgid "" -"For instance, the following code (which assumes that the :mailheader:" -"`Content-Type` header and blank line have already been printed) checks that " -"the fields ``name`` and ``addr`` are both set to a non-empty string::" +"For instance, the following code (which assumes that " +"the :mailheader:`Content-Type` header and blank line have already been " +"printed) checks that the fields ``name`` and ``addr`` are both set to a non-" +"empty string::" +msgstr "" + +#: library/cgi.rst:127 +msgid "" +"form = cgi.FieldStorage()\n" +"if \"name\" not in form or \"addr\" not in form:\n" +" print(\"

Error

\")\n" +" print(\"Please fill in the name and addr fields.\")\n" +" return\n" +"print(\"

name:\", form[\"name\"].value)\n" +"print(\"

addr:\", form[\"addr\"].value)\n" +"...further form processing here..." msgstr "" #: library/cgi.rst:136 @@ -184,27 +223,46 @@ msgstr "" #: library/cgi.rst:143 msgid "" "If the submitted form data contains more than one field with the same name, " -"the object retrieved by ``form[key]`` is not a :class:`FieldStorage` or :" -"class:`MiniFieldStorage` instance but a list of such instances. Similarly, " -"in this situation, ``form.getvalue(key)`` would return a list of strings. If " -"you expect this possibility (when your HTML form contains multiple fields " -"with the same name), use the :meth:`~FieldStorage.getlist` method, which " -"always returns a list of values (so that you do not need to special-case the " -"single item case). For example, this code concatenates any number of " -"username fields, separated by commas::" +"the object retrieved by ``form[key]`` is not a :class:`FieldStorage` " +"or :class:`MiniFieldStorage` instance but a list of such instances. " +"Similarly, in this situation, ``form.getvalue(key)`` would return a list of " +"strings. If you expect this possibility (when your HTML form contains " +"multiple fields with the same name), use the :meth:`~FieldStorage.getlist` " +"method, which always returns a list of values (so that you do not need to " +"special-case the single item case). For example, this code concatenates any " +"number of username fields, separated by commas::" +msgstr "" + +#: library/cgi.rst:153 +msgid "" +"value = form.getlist(\"username\")\n" +"usernames = \",\".join(value)" msgstr "" #: library/cgi.rst:156 msgid "" -"If a field represents an uploaded file, accessing the value via the :attr:" -"`~FieldStorage.value` attribute or the :meth:`~FieldStorage.getvalue` method " -"reads the entire file in memory as bytes. This may not be what you want. " -"You can test for an uploaded file by testing either the :attr:`~FieldStorage." -"filename` attribute or the :attr:`~FieldStorage.file` attribute. You can " -"then read the data from the :attr:`!file` attribute before it is " -"automatically closed as part of the garbage collection of the :class:" -"`FieldStorage` instance (the :func:`~io.RawIOBase.read` and :func:`~io." -"IOBase.readline` methods will return bytes)::" +"If a field represents an uploaded file, accessing the value via " +"the :attr:`~FieldStorage.value` attribute or " +"the :meth:`~FieldStorage.getvalue` method reads the entire file in memory as " +"bytes. This may not be what you want. You can test for an uploaded file by " +"testing either the :attr:`~FieldStorage.filename` attribute or " +"the :attr:`~FieldStorage.file` attribute. You can then read the data from " +"the :attr:`!file` attribute before it is automatically closed as part of the " +"garbage collection of the :class:`FieldStorage` instance " +"(the :func:`~io.RawIOBase.read` and :func:`~io.IOBase.readline` methods will " +"return bytes)::" +msgstr "" + +#: library/cgi.rst:167 +msgid "" +"fileitem = form[\"userfile\"]\n" +"if fileitem.file:\n" +" # It's an uploaded file; count lines\n" +" linecount = 0\n" +" while True:\n" +" line = fileitem.file.readline()\n" +" if not line: break\n" +" linecount = linecount + 1" msgstr "" #: library/cgi.rst:176 @@ -225,11 +283,12 @@ msgstr "" msgid "" "The file upload draft standard entertains the possibility of uploading " "multiple files from one field (using a recursive :mimetype:`multipart/\\*` " -"encoding). When this occurs, the item will be a dictionary-like :class:" -"`FieldStorage` item. This can be determined by testing its :attr:`!type` " -"attribute, which should be :mimetype:`multipart/form-data` (or perhaps " -"another MIME type matching :mimetype:`multipart/\\*`). In this case, it can " -"be iterated over recursively just like the top-level form object." +"encoding). When this occurs, the item will be a dictionary-" +"like :class:`FieldStorage` item. This can be determined by testing " +"its :attr:`!type` attribute, which should be :mimetype:`multipart/form-data` " +"(or perhaps another MIME type matching :mimetype:`multipart/\\*`). In this " +"case, it can be iterated over recursively just like the top-level form " +"object." msgstr "" #: library/cgi.rst:192 @@ -243,8 +302,8 @@ msgstr "" #: library/cgi.rst:197 msgid "" -"A form submitted via POST that also has a query string will contain both :" -"class:`FieldStorage` and :class:`MiniFieldStorage` items." +"A form submitted via POST that also has a query string will contain " +"both :class:`FieldStorage` and :class:`MiniFieldStorage` items." msgstr "" #: library/cgi.rst:200 @@ -255,8 +314,8 @@ msgstr "" #: library/cgi.rst:204 msgid "" -"Added support for the context management protocol to the :class:" -"`FieldStorage` class." +"Added support for the context management protocol to " +"the :class:`FieldStorage` class." msgstr "" #: library/cgi.rst:210 @@ -265,12 +324,12 @@ msgstr "" #: library/cgi.rst:212 msgid "" -"The previous section explains how to read CGI form data using the :class:" -"`FieldStorage` class. This section describes a higher level interface which " -"was added to this class to allow one to do it in a more readable and " -"intuitive way. The interface doesn't make the techniques described in " -"previous sections obsolete --- they are still useful to process file uploads " -"efficiently, for example." +"The previous section explains how to read CGI form data using " +"the :class:`FieldStorage` class. This section describes a higher level " +"interface which was added to this class to allow one to do it in a more " +"readable and intuitive way. The interface doesn't make the techniques " +"described in previous sections obsolete --- they are still useful to process " +"file uploads efficiently, for example." msgstr "" #: library/cgi.rst:221 @@ -286,12 +345,27 @@ msgid "" "expected a user to post more than one value under one name::" msgstr "" +#: library/cgi.rst:228 +msgid "" +"item = form.getvalue(\"item\")\n" +"if isinstance(item, list):\n" +" # The user is requesting more than one item.\n" +"else:\n" +" # The user is requesting only one item." +msgstr "" + #: library/cgi.rst:234 msgid "" "This situation is common for example when a form contains a group of " "multiple checkboxes with the same name::" msgstr "" +#: library/cgi.rst:237 +msgid "" +"\n" +"" +msgstr "" + #: library/cgi.rst:240 msgid "" "In most situations, however, there's only one form control with a particular " @@ -299,6 +373,10 @@ msgid "" "this name. So you write a script containing for example this code::" msgstr "" +#: library/cgi.rst:244 +msgid "user = form.getvalue(\"user\").upper()" +msgstr "" + #: library/cgi.rst:246 msgid "" "The problem with the code is that you should never expect that a client will " @@ -319,9 +397,9 @@ msgstr "" #: library/cgi.rst:258 msgid "" -"A more convenient approach is to use the methods :meth:`~FieldStorage." -"getfirst` and :meth:`~FieldStorage.getlist` provided by this higher level " -"interface." +"A more convenient approach is to use the " +"methods :meth:`~FieldStorage.getfirst` and :meth:`~FieldStorage.getlist` " +"provided by this higher level interface." msgstr "" #: library/cgi.rst:264 @@ -347,6 +425,15 @@ msgstr "" msgid "Using these methods you can write nice compact code::" msgstr "" +#: library/cgi.rst:281 +msgid "" +"import cgi\n" +"form = cgi.FieldStorage()\n" +"user = form.getfirst(\"user\", \"\").upper() # This way it's safe.\n" +"for item in form.getlist(\"item\"):\n" +" do_something(item)" +msgstr "" + #: library/cgi.rst:291 msgid "Functions" msgstr "" @@ -359,12 +446,12 @@ msgstr "" #: library/cgi.rst:299 msgid "" -"Parse a query in the environment or from a file (the file defaults to ``sys." -"stdin``). The *keep_blank_values*, *strict_parsing* and *separator* " +"Parse a query in the environment or from a file (the file defaults to " +"``sys.stdin``). The *keep_blank_values*, *strict_parsing* and *separator* " "parameters are passed to :func:`urllib.parse.parse_qs` unchanged." msgstr "" -#: library/cgi.rst:307 +#: library/cgi.rst:303 msgid "" "This function, like the rest of the :mod:`cgi` module, is deprecated. It can " "be replaced by calling :func:`urllib.parse.parse_qs` directly on the desired " @@ -404,13 +491,13 @@ msgstr "" msgid "Added the *separator* parameter." msgstr "" -#: library/cgi.rst:337 +#: library/cgi.rst:332 msgid "" "This function, like the rest of the :mod:`cgi` module, is deprecated. It can " -"be replaced with the functionality in the :mod:`email` package (e.g. :class:" -"`email.message.EmailMessage`/:class:`email.message.Message`) which " -"implements the same MIME RFCs, or with the `multipart `__ PyPI project." +"be replaced with the functionality in the :mod:`email` package " +"(e.g. :class:`email.message.EmailMessage`/:class:`email.message.Message`) " +"which implements the same MIME RFCs, or with the :pypi:`multipart` PyPI " +"project." msgstr "" #: library/cgi.rst:342 @@ -419,7 +506,7 @@ msgid "" "and a dictionary of parameters." msgstr "" -#: library/cgi.rst:355 +#: library/cgi.rst:345 msgid "" "This function, like the rest of the :mod:`cgi` module, is deprecated. It can " "be replaced with the functionality in the :mod:`email` package, which " @@ -430,6 +517,14 @@ msgstr "" msgid "For example, with :class:`email.message.EmailMessage`::" msgstr "" +#: library/cgi.rst:352 +msgid "" +"from email.message import EmailMessage\n" +"msg = EmailMessage()\n" +"msg['content-type'] = 'application/json; charset=\"utf8\"'\n" +"main, params = msg.get_content_type(), msg['content-type'].params" +msgstr "" + #: library/cgi.rst:360 msgid "" "Robust test CGI script, usable as main program. Writes minimal HTTP headers " @@ -458,13 +553,13 @@ msgstr "" #: library/cgi.rst:391 msgid "" -"There's one important rule: if you invoke an external program (via :func:`os." -"system`, :func:`os.popen` or other functions with similar functionality), " -"make very sure you don't pass arbitrary strings received from the client to " -"the shell. This is a well-known security hole whereby clever hackers " -"anywhere on the web can exploit a gullible CGI script to invoke arbitrary " -"shell commands. Even parts of the URL or field names cannot be trusted, " -"since the request doesn't have to come from your form!" +"There's one important rule: if you invoke an external program " +"(via :func:`os.system`, :func:`os.popen` or other functions with similar " +"functionality), make very sure you don't pass arbitrary strings received " +"from the client to the shell. This is a well-known security hole whereby " +"clever hackers anywhere on the web can exploit a gullible CGI script to " +"invoke arbitrary shell commands. Even parts of the URL or field names " +"cannot be trusted, since the request doesn't have to come from your form!" msgstr "" #: library/cgi.rst:399 @@ -493,6 +588,10 @@ msgid "" "column 1 followed by the pathname of the Python interpreter, for instance::" msgstr "" +#: library/cgi.rst:416 +msgid "#!/usr/local/bin/python" +msgstr "" + #: library/cgi.rst:418 msgid "" "Make sure the Python interpreter exists and is executable by \"others\"." @@ -508,9 +607,9 @@ msgid "" "(write, execute). The current directory at execution time is also different " "(it is usually the server's cgi-bin directory) and the set of environment " "variables is also different from what you get when you log in. In " -"particular, don't count on the shell's search path for executables (:envvar:" -"`PATH`) or the Python module search path (:envvar:`PYTHONPATH`) to be set to " -"anything interesting." +"particular, don't count on the shell's search path for executables " +"(:envvar:`PATH`) or the Python module search path (:envvar:`PYTHONPATH`) to " +"be set to anything interesting." msgstr "" #: library/cgi.rst:431 @@ -520,6 +619,13 @@ msgid "" "importing other modules. For example::" msgstr "" +#: library/cgi.rst:435 +msgid "" +"import sys\n" +"sys.path.insert(0, \"/usr/home/joe/lib/python\")\n" +"sys.path.insert(0, \"/usr/local/lib/python\")" +msgstr "" + #: library/cgi.rst:439 msgid "(This way, the directory inserted last will be searched first!)" msgstr "" @@ -567,6 +673,10 @@ msgid "" "your browser of the form:" msgstr "" +#: library/cgi.rst:473 +msgid "http://yourhostname/cgi-bin/cgi.py?name=Joe+Blow&addr=At+Home" +msgstr "" + #: library/cgi.rst:477 msgid "" "If this gives an error of type 404, the server cannot find the script -- " @@ -585,10 +695,14 @@ msgid "" "from your script: replace its main code with the single statement ::" msgstr "" +#: library/cgi.rst:489 +msgid "cgi.test()" +msgstr "" + #: library/cgi.rst:491 msgid "" -"This should produce the same results as those gotten from installing the :" -"file:`cgi.py` file itself." +"This should produce the same results as those gotten from installing " +"the :file:`cgi.py` file itself." msgstr "" #: library/cgi.rst:494 @@ -604,8 +718,8 @@ msgstr "" #: library/cgi.rst:501 msgid "" "Fortunately, once you have managed to get your script to execute *some* " -"code, you can easily send tracebacks to the web browser using the :mod:" -"`cgitb` module. If you haven't done so already, just add the lines::" +"code, you can easily send tracebacks to the web browser using " +"the :mod:`cgitb` module. If you haven't done so already, just add the lines::" msgstr "" #: library/cgi.rst:508 @@ -622,6 +736,15 @@ msgid "" "modules)::" msgstr "" +#: library/cgi.rst:515 +msgid "" +"import sys\n" +"sys.stderr = sys.stdout\n" +"print(\"Content-Type: text/plain\")\n" +"print()\n" +"...your code here..." +msgstr "" + #: library/cgi.rst:521 msgid "" "This relies on the Python interpreter to print the traceback. The content " diff --git a/library/cgitb.po b/library/cgitb.po index 77eda8ba..acbc852b 100644 --- a/library/cgitb.po +++ b/library/cgitb.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,7 +25,7 @@ msgstr "" msgid "**Source code:** :source:`Lib/cgitb.py`" msgstr "" -#: library/cgitb.rst:22 +#: library/cgitb.rst:19 msgid "" "The :mod:`cgitb` module is deprecated (see :pep:`PEP 594 <594#cgitb>` for " "details)." @@ -48,6 +49,12 @@ msgstr "" msgid "To enable this feature, simply add this to the top of your CGI script::" msgstr "" +#: library/cgitb.rst:37 +msgid "" +"import cgitb\n" +"cgitb.enable()" +msgstr "" + #: library/cgitb.rst:40 msgid "" "The options to the :func:`enable` function control whether the report is " @@ -58,8 +65,8 @@ msgstr "" #: library/cgitb.rst:49 msgid "" "This function causes the :mod:`cgitb` module to take over the interpreter's " -"default handling for exceptions by setting the value of :attr:`sys." -"excepthook`." +"default handling for exceptions by setting the value " +"of :attr:`sys.excepthook`." msgstr "" #: library/cgitb.rst:52 @@ -99,9 +106,9 @@ msgid "" "a report in the browser, but don't log to a file). This can be used when " "you've caught an exception and want to report it using :mod:`cgitb`. The " "optional *info* argument should be a 3-tuple containing an exception type, " -"exception value, and traceback object, exactly like the tuple returned by :" -"func:`sys.exc_info`. If the *info* argument is not supplied, the current " -"exception is obtained from :func:`sys.exc_info`." +"exception value, and traceback object, exactly like the tuple returned " +"by :func:`sys.exc_info`. If the *info* argument is not supplied, the " +"current exception is obtained from :func:`sys.exc_info`." msgstr "" #: library/cgitb.rst:13 diff --git a/library/chunk.po b/library/chunk.po index 3f9f9ad7..c487335b 100644 --- a/library/chunk.po +++ b/library/chunk.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,7 +25,7 @@ msgstr "" msgid "**Source code:** :source:`Lib/chunk.py`" msgstr "" -#: library/chunk.rst:23 +#: library/chunk.rst:20 msgid "" "The :mod:`chunk` module is deprecated (see :pep:`PEP 594 <594#chunk>` for " "details)." @@ -117,17 +118,17 @@ msgstr "" msgid "" "Class which represents a chunk. The *file* argument is expected to be a " "file-like object. An instance of this class is specifically allowed. The " -"only method that is needed is :meth:`~io.IOBase.read`. If the methods :meth:" -"`~io.IOBase.seek` and :meth:`~io.IOBase.tell` are present and don't raise an " -"exception, they are also used. If these methods are present and raise an " -"exception, they are expected to not have altered the object. If the " -"optional argument *align* is true, chunks are assumed to be aligned on 2-" -"byte boundaries. If *align* is false, no alignment is assumed. The default " -"value is true. If the optional argument *bigendian* is false, the chunk " -"size is assumed to be in little-endian order. This is needed for WAVE audio " -"files. The default value is true. If the optional argument *inclheader* is " -"true, the size given in the chunk header includes the size of the header. " -"The default value is false." +"only method that is needed is :meth:`~io.IOBase.read`. If the " +"methods :meth:`~io.IOBase.seek` and :meth:`~io.IOBase.tell` are present and " +"don't raise an exception, they are also used. If these methods are present " +"and raise an exception, they are expected to not have altered the object. " +"If the optional argument *align* is true, chunks are assumed to be aligned " +"on 2-byte boundaries. If *align* is false, no alignment is assumed. The " +"default value is true. If the optional argument *bigendian* is false, the " +"chunk size is assumed to be in little-endian order. This is needed for WAVE " +"audio files. The default value is true. If the optional argument " +"*inclheader* is true, the size given in the chunk header includes the size " +"of the header. The default value is false." msgstr "" #: library/chunk.rst:78 @@ -151,9 +152,9 @@ msgstr "" #: library/chunk.rst:97 msgid "" -"The remaining methods will raise :exc:`OSError` if called after the :meth:" -"`close` method has been called. Before Python 3.3, they used to raise :exc:" -"`IOError`, now an alias of :exc:`OSError`." +"The remaining methods will raise :exc:`OSError` if called after " +"the :meth:`close` method has been called. Before Python 3.3, they used to " +"raise :exc:`IOError`, now an alias of :exc:`OSError`." msgstr "" #: library/chunk.rst:104 diff --git a/library/cmath.po b/library/cmath.po index c374024f..35c08274 100644 --- a/library/cmath.po +++ b/library/cmath.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/cmath.rst:2 -msgid ":mod:`cmath` --- Mathematical functions for complex numbers" +msgid ":mod:`!cmath` --- Mathematical functions for complex numbers" msgstr "" #: library/cmath.rst:9 @@ -50,12 +51,24 @@ msgid "" "imaginary axis::" msgstr "" +#: library/cmath.rst:31 +msgid "" +">>> cmath.sqrt(complex(-2.0, -0.0))\n" +"-1.4142135623730951j" +msgstr "" + #: library/cmath.rst:34 msgid "" "But an argument of ``complex(-2.0, 0.0)`` is treated as though it lies above " "the branch cut::" msgstr "" +#: library/cmath.rst:37 +msgid "" +">>> cmath.sqrt(complex(-2.0, 0.0))\n" +"1.4142135623730951j" +msgstr "" + #: library/cmath.rst:42 msgid "Conversions to and from polar coordinates" msgstr "" @@ -63,11 +76,11 @@ msgstr "" #: library/cmath.rst:44 msgid "" "A Python complex number ``z`` is stored internally using *rectangular* or " -"*Cartesian* coordinates. It is completely determined by its *real part* ``z." -"real`` and its *imaginary part* ``z.imag``. In other words::" +"*Cartesian* coordinates. It is completely determined by its *real part* " +"``z.real`` and its *imaginary part* ``z.imag``." msgstr "" -#: library/cmath.rst:51 +#: library/cmath.rst:48 msgid "" "*Polar coordinates* give an alternative way to represent a complex number. " "In polar coordinates, a complex number *z* is defined by the modulus *r* and " @@ -77,13 +90,13 @@ msgid "" "to *z*." msgstr "" -#: library/cmath.rst:58 +#: library/cmath.rst:55 msgid "" "The following functions can be used to convert from the native rectangular " "coordinates to polar coordinates and back." msgstr "" -#: library/cmath.rst:63 +#: library/cmath.rst:60 msgid "" "Return the phase of *x* (also known as the *argument* of *x*), as a float. " "``phase(x)`` is equivalent to ``math.atan2(x.imag, x.real)``. The result " @@ -92,181 +105,188 @@ msgid "" "sign of ``x.imag``, even when ``x.imag`` is zero::" msgstr "" -#: library/cmath.rst:77 +#: library/cmath.rst:66 +msgid "" +">>> phase(complex(-1.0, 0.0))\n" +"3.141592653589793\n" +">>> phase(complex(-1.0, -0.0))\n" +"-3.141592653589793" +msgstr "" + +#: library/cmath.rst:74 msgid "" "The modulus (absolute value) of a complex number *x* can be computed using " "the built-in :func:`abs` function. There is no separate :mod:`cmath` module " "function for this operation." msgstr "" -#: library/cmath.rst:84 +#: library/cmath.rst:81 msgid "" "Return the representation of *x* in polar coordinates. Returns a pair ``(r, " "phi)`` where *r* is the modulus of *x* and phi is the phase of *x*. " "``polar(x)`` is equivalent to ``(abs(x), phase(x))``." msgstr "" -#: library/cmath.rst:92 +#: library/cmath.rst:89 msgid "" "Return the complex number *x* with polar coordinates *r* and *phi*. " -"Equivalent to ``r * (math.cos(phi) + math.sin(phi)*1j)``." +"Equivalent to ``complex(r * math.cos(phi), r * math.sin(phi))``." msgstr "" -#: library/cmath.rst:97 +#: library/cmath.rst:94 msgid "Power and logarithmic functions" msgstr "" -#: library/cmath.rst:101 +#: library/cmath.rst:98 msgid "" "Return *e* raised to the power *x*, where *e* is the base of natural " "logarithms." msgstr "" -#: library/cmath.rst:107 +#: library/cmath.rst:104 msgid "" "Returns the logarithm of *x* to the given *base*. If the *base* is not " "specified, returns the natural logarithm of *x*. There is one branch cut, " "from 0 along the negative real axis to -∞." msgstr "" -#: library/cmath.rst:114 +#: library/cmath.rst:111 msgid "" -"Return the base-10 logarithm of *x*. This has the same branch cut as :func:" -"`log`." +"Return the base-10 logarithm of *x*. This has the same branch cut " +"as :func:`log`." msgstr "" -#: library/cmath.rst:120 +#: library/cmath.rst:117 msgid "" "Return the square root of *x*. This has the same branch cut as :func:`log`." msgstr "" -#: library/cmath.rst:124 +#: library/cmath.rst:121 msgid "Trigonometric functions" msgstr "" -#: library/cmath.rst:128 +#: library/cmath.rst:125 msgid "" "Return the arc cosine of *x*. There are two branch cuts: One extends right " "from 1 along the real axis to ∞. The other extends left from -1 along the " "real axis to -∞." msgstr "" -#: library/cmath.rst:135 +#: library/cmath.rst:132 msgid "" "Return the arc sine of *x*. This has the same branch cuts as :func:`acos`." msgstr "" -#: library/cmath.rst:140 +#: library/cmath.rst:137 msgid "" "Return the arc tangent of *x*. There are two branch cuts: One extends from " "``1j`` along the imaginary axis to ``∞j``. The other extends from ``-1j`` " "along the imaginary axis to ``-∞j``." msgstr "" -#: library/cmath.rst:147 +#: library/cmath.rst:144 msgid "Return the cosine of *x*." msgstr "" -#: library/cmath.rst:152 +#: library/cmath.rst:149 msgid "Return the sine of *x*." msgstr "" -#: library/cmath.rst:157 +#: library/cmath.rst:154 msgid "Return the tangent of *x*." msgstr "" -#: library/cmath.rst:161 +#: library/cmath.rst:158 msgid "Hyperbolic functions" msgstr "" -#: library/cmath.rst:165 +#: library/cmath.rst:162 msgid "" "Return the inverse hyperbolic cosine of *x*. There is one branch cut, " "extending left from 1 along the real axis to -∞." msgstr "" -#: library/cmath.rst:171 +#: library/cmath.rst:168 msgid "" "Return the inverse hyperbolic sine of *x*. There are two branch cuts: One " "extends from ``1j`` along the imaginary axis to ``∞j``. The other extends " "from ``-1j`` along the imaginary axis to ``-∞j``." msgstr "" -#: library/cmath.rst:178 +#: library/cmath.rst:175 msgid "" "Return the inverse hyperbolic tangent of *x*. There are two branch cuts: One " "extends from ``1`` along the real axis to ``∞``. The other extends from " "``-1`` along the real axis to ``-∞``." msgstr "" -#: library/cmath.rst:185 +#: library/cmath.rst:182 msgid "Return the hyperbolic cosine of *x*." msgstr "" -#: library/cmath.rst:190 +#: library/cmath.rst:187 msgid "Return the hyperbolic sine of *x*." msgstr "" -#: library/cmath.rst:195 +#: library/cmath.rst:192 msgid "Return the hyperbolic tangent of *x*." msgstr "" -#: library/cmath.rst:199 +#: library/cmath.rst:196 msgid "Classification functions" msgstr "" -#: library/cmath.rst:203 +#: library/cmath.rst:200 msgid "" "Return ``True`` if both the real and imaginary parts of *x* are finite, and " "``False`` otherwise." msgstr "" -#: library/cmath.rst:211 +#: library/cmath.rst:208 msgid "" "Return ``True`` if either the real or the imaginary part of *x* is an " "infinity, and ``False`` otherwise." msgstr "" -#: library/cmath.rst:217 +#: library/cmath.rst:214 msgid "" "Return ``True`` if either the real or the imaginary part of *x* is a NaN, " "and ``False`` otherwise." msgstr "" -#: library/cmath.rst:223 +#: library/cmath.rst:220 msgid "" "Return ``True`` if the values *a* and *b* are close to each other and " "``False`` otherwise." msgstr "" -#: library/cmath.rst:226 +#: library/cmath.rst:223 msgid "" "Whether or not two values are considered close is determined according to " -"given absolute and relative tolerances." +"given absolute and relative tolerances. If no errors occur, the result will " +"be: ``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``." msgstr "" -#: library/cmath.rst:229 +#: library/cmath.rst:227 msgid "" "*rel_tol* is the relative tolerance -- it is the maximum allowed difference " "between *a* and *b*, relative to the larger absolute value of *a* or *b*. " "For example, to set a tolerance of 5%, pass ``rel_tol=0.05``. The default " "tolerance is ``1e-09``, which assures that the two values are the same " -"within about 9 decimal digits. *rel_tol* must be greater than zero." -msgstr "" - -#: library/cmath.rst:235 -msgid "" -"*abs_tol* is the minimum absolute tolerance -- useful for comparisons near " -"zero. *abs_tol* must be at least zero." +"within about 9 decimal digits. *rel_tol* must be nonnegative and less than " +"``1.0``." msgstr "" -#: library/cmath.rst:238 +#: library/cmath.rst:234 msgid "" -"If no errors occur, the result will be: ``abs(a-b) <= max(rel_tol * " -"max(abs(a), abs(b)), abs_tol)``." +"*abs_tol* is the absolute tolerance; it defaults to ``0.0`` and it must be " +"nonnegative. When comparing ``x`` to ``0.0``, ``isclose(x, 0)`` is computed " +"as ``abs(x) <= rel_tol * abs(x)``, which is ``False`` for any ``x`` and " +"rel_tol less than ``1.0``. So add an appropriate positive abs_tol argument " +"to the call." msgstr "" -#: library/cmath.rst:241 +#: library/cmath.rst:240 msgid "" "The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be " "handled according to IEEE rules. Specifically, ``NaN`` is not considered " @@ -274,61 +294,61 @@ msgid "" "considered close to themselves." msgstr "" -#: library/cmath.rst:250 +#: library/cmath.rst:249 msgid ":pep:`485` -- A function for testing approximate equality" msgstr "" -#: library/cmath.rst:254 +#: library/cmath.rst:253 msgid "Constants" msgstr "" -#: library/cmath.rst:258 +#: library/cmath.rst:257 msgid "The mathematical constant *π*, as a float." msgstr "" -#: library/cmath.rst:263 +#: library/cmath.rst:262 msgid "The mathematical constant *e*, as a float." msgstr "" -#: library/cmath.rst:268 +#: library/cmath.rst:267 msgid "The mathematical constant *τ*, as a float." msgstr "" -#: library/cmath.rst:275 +#: library/cmath.rst:274 msgid "Floating-point positive infinity. Equivalent to ``float('inf')``." msgstr "" -#: library/cmath.rst:282 +#: library/cmath.rst:281 msgid "" "Complex number with zero real part and positive infinity imaginary part. " "Equivalent to ``complex(0.0, float('inf'))``." msgstr "" -#: library/cmath.rst:290 +#: library/cmath.rst:289 msgid "" "A floating-point \"not a number\" (NaN) value. Equivalent to " "``float('nan')``." msgstr "" -#: library/cmath.rst:298 +#: library/cmath.rst:297 msgid "" "Complex number with zero real part and NaN imaginary part. Equivalent to " "``complex(0.0, float('nan'))``." msgstr "" -#: library/cmath.rst:306 +#: library/cmath.rst:305 msgid "" "Note that the selection of functions is similar, but not identical, to that " "in module :mod:`math`. The reason for having two modules is that some users " "aren't interested in complex numbers, and perhaps don't even know what they " "are. They would rather have ``math.sqrt(-1)`` raise an exception than " -"return a complex number. Also note that the functions defined in :mod:" -"`cmath` always return a complex number, even if the answer can be expressed " -"as a real number (in which case the complex number has an imaginary part of " -"zero)." +"return a complex number. Also note that the functions defined " +"in :mod:`cmath` always return a complex number, even if the answer can be " +"expressed as a real number (in which case the complex number has an " +"imaginary part of zero)." msgstr "" -#: library/cmath.rst:314 +#: library/cmath.rst:313 msgid "" "A note on branch cuts: They are curves along which the given function fails " "to be continuous. They are a necessary feature of many complex functions. " @@ -339,17 +359,17 @@ msgid "" "following:" msgstr "" -#: library/cmath.rst:324 +#: library/cmath.rst:323 msgid "" "Kahan, W: Branch cuts for complex elementary functions; or, Much ado about " "nothing's sign bit. In Iserles, A., and Powell, M. (eds.), The state of the " "art in numerical analysis. Clarendon Press (1987) pp165--211." msgstr "" -#: library/cmath.rst:304 +#: library/cmath.rst:303 msgid "module" msgstr "" -#: library/cmath.rst:304 +#: library/cmath.rst:303 msgid "math" msgstr "" diff --git a/library/cmd.po b/library/cmd.po index ab4ece5f..320254f1 100644 --- a/library/cmd.po +++ b/library/cmd.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/cmd.rst:2 -msgid ":mod:`cmd` --- Support for line-oriented command interpreters" +msgid ":mod:`!cmd` --- Support for line-oriented command interpreters" msgstr "" #: library/cmd.rst:9 @@ -44,24 +45,24 @@ msgstr "" #: library/cmd.rst:25 msgid "" "The optional argument *completekey* is the :mod:`readline` name of a " -"completion key; it defaults to :kbd:`Tab`. If *completekey* is not :const:" -"`None` and :mod:`readline` is available, command completion is done " -"automatically." +"completion key; it defaults to :kbd:`Tab`. If *completekey* is " +"not :const:`None` and :mod:`readline` is available, command completion is " +"done automatically." msgstr "" #: library/cmd.rst:29 msgid "" "The optional arguments *stdin* and *stdout* specify the input and output " "file objects that the Cmd instance or subclass instance will use for input " -"and output. If not specified, they will default to :data:`sys.stdin` and :" -"data:`sys.stdout`." +"and output. If not specified, they will default to :data:`sys.stdin` " +"and :data:`sys.stdout`." msgstr "" #: library/cmd.rst:34 msgid "" -"If you want a given *stdin* to be used, make sure to set the instance's :" -"attr:`use_rawinput` attribute to ``False``, otherwise *stdin* will be " -"ignored." +"If you want a given *stdin* to be used, make sure to set the " +"instance's :attr:`use_rawinput` attribute to ``False``, otherwise *stdin* " +"will be ignored." msgstr "" #: library/cmd.rst:42 @@ -87,11 +88,12 @@ msgstr "" #: library/cmd.rst:56 msgid "" -"If the :mod:`readline` module is loaded, input will automatically inherit :" -"program:`bash`\\ -like history-list editing (e.g. :kbd:`Control-P` scrolls " -"back to the last command, :kbd:`Control-N` forward to the next one, :kbd:" -"`Control-F` moves the cursor to the right non-destructively, :kbd:`Control-" -"B` moves the cursor to the left non-destructively, etc.)." +"If the :mod:`readline` module is loaded, input will automatically " +"inherit :program:`bash`\\ -like history-list editing (e.g. :kbd:`Control-P` " +"scrolls back to the last command, :kbd:`Control-N` forward to the next " +"one, :kbd:`Control-F` moves the cursor to the right non-" +"destructively, :kbd:`Control-B` moves the cursor to the left non-" +"destructively, etc.)." msgstr "" #: library/cmd.rst:62 @@ -129,10 +131,10 @@ msgstr "" #: library/cmd.rst:89 msgid "" "All subclasses of :class:`Cmd` inherit a predefined :meth:`!do_help`. This " -"method, called with an argument ``'bar'``, invokes the corresponding method :" -"meth:`!help_bar`, and if that is not present, prints the docstring of :meth:" -"`!do_bar`, if available. With no argument, :meth:`!do_help` lists all " -"available help topics (that is, all commands with corresponding :meth:`!" +"method, called with an argument ``'bar'``, invokes the corresponding " +"method :meth:`!help_bar`, and if that is not present, prints the docstring " +"of :meth:`!do_bar`, if available. With no argument, :meth:`!do_help` lists " +"all available help topics (that is, all commands with corresponding :meth:`!" "help_\\*` methods or commands that have docstrings), and also lists any " "undocumented commands." msgstr "" @@ -140,10 +142,10 @@ msgstr "" #: library/cmd.rst:100 msgid "" "Interpret the argument as though it had been typed in response to the " -"prompt. This may be overridden, but should not normally need to be; see the :" -"meth:`precmd` and :meth:`postcmd` methods for useful execution hooks. The " -"return value is a flag indicating whether interpretation of commands by the " -"interpreter should stop. If there is a :meth:`!do_\\*` method for the " +"prompt. This may be overridden, but should not normally need to be; see " +"the :meth:`precmd` and :meth:`postcmd` methods for useful execution hooks. " +"The return value is a flag indicating whether interpretation of commands by " +"the interpreter should stop. If there is a :meth:`!do_\\*` method for the " "command *str*, the return value of that method is returned, otherwise the " "return value from the :meth:`default` method is returned." msgstr "" @@ -176,9 +178,9 @@ msgstr "" #: library/cmd.rst:136 msgid "" "Hook method executed just before the command line *line* is interpreted, but " -"after the input prompt is generated and issued. This method is a stub in :" -"class:`Cmd`; it exists to be overridden by subclasses. The return value is " -"used as the command which will be executed by the :meth:`onecmd` method; " +"after the input prompt is generated and issued. This method is a stub " +"in :class:`Cmd`; it exists to be overridden by subclasses. The return value " +"is used as the command which will be executed by the :meth:`onecmd` method; " "the :meth:`precmd` implementation may re-write the command or simply return " "*line* unchanged." msgstr "" @@ -225,15 +227,15 @@ msgstr "" #: library/cmd.rst:186 msgid "" -"A list of queued input lines. The cmdqueue list is checked in :meth:" -"`cmdloop` when new input is needed; if it is nonempty, its elements will be " -"processed in order, as if entered at the prompt." +"A list of queued input lines. The cmdqueue list is checked " +"in :meth:`cmdloop` when new input is needed; if it is nonempty, its elements " +"will be processed in order, as if entered at the prompt." msgstr "" #: library/cmd.rst:193 msgid "" -"A string to issue as an intro or banner. May be overridden by giving the :" -"meth:`cmdloop` method an argument." +"A string to issue as an intro or banner. May be overridden by giving " +"the :meth:`cmdloop` method an argument." msgstr "" #: library/cmd.rst:199 @@ -244,15 +246,15 @@ msgstr "" #: library/cmd.rst:204 msgid "" "The header to issue if the help output has a section for miscellaneous help " -"topics (that is, there are :meth:`!help_\\*` methods without corresponding :" -"meth:`!do_\\*` methods)." +"topics (that is, there are :meth:`!help_\\*` methods without " +"corresponding :meth:`!do_\\*` methods)." msgstr "" #: library/cmd.rst:211 msgid "" "The header to issue if the help output has a section for undocumented " -"commands (that is, there are :meth:`!do_\\*` methods without corresponding :" -"meth:`!help_\\*` methods)." +"commands (that is, there are :meth:`!do_\\*` methods without " +"corresponding :meth:`!help_\\*` methods)." msgstr "" #: library/cmd.rst:218 @@ -264,11 +266,12 @@ msgstr "" #: library/cmd.rst:224 msgid "" "A flag, defaulting to true. If true, :meth:`cmdloop` uses :func:`input` to " -"display a prompt and read the next command; if false, :data:`sys.stdout." -"write() ` and :data:`sys.stdin.readline() ` are used. " -"(This means that by importing :mod:`readline`, on systems that support it, " -"the interpreter will automatically support :program:`Emacs`\\ -like line " -"editing and command-history keystrokes.)" +"display a prompt and read the next command; if " +"false, :data:`sys.stdout.write() ` " +"and :data:`sys.stdin.readline() ` are used. (This means that by " +"importing :mod:`readline`, on systems that support it, the interpreter will " +"automatically support :program:`Emacs`\\ -like line editing and command-" +"history keystrokes.)" msgstr "" #: library/cmd.rst:234 @@ -289,10 +292,10 @@ msgstr "" #: library/cmd.rst:244 msgid "" -"Basic turtle commands such as :meth:`~turtle.forward` are added to a :class:" -"`Cmd` subclass with method named :meth:`!do_forward`. The argument is " -"converted to a number and dispatched to the turtle module. The docstring is " -"used in the help utility provided by the shell." +"Basic turtle commands such as :meth:`~turtle.forward` are added to " +"a :class:`Cmd` subclass with method named :meth:`!do_forward`. The argument " +"is converted to a number and dispatched to the turtle module. The docstring " +"is used in the help utility provided by the shell." msgstr "" #: library/cmd.rst:249 @@ -300,8 +303,88 @@ msgid "" "The example also includes a basic record and playback facility implemented " "with the :meth:`~Cmd.precmd` method which is responsible for converting the " "input to lowercase and writing the commands to a file. The :meth:`!" -"do_playback` method reads the file and adds the recorded commands to the :" -"attr:`~Cmd.cmdqueue` for immediate playback::" +"do_playback` method reads the file and adds the recorded commands to " +"the :attr:`~Cmd.cmdqueue` for immediate playback::" +msgstr "" + +#: library/cmd.rst:255 +msgid "" +"import cmd, sys\n" +"from turtle import *\n" +"\n" +"class TurtleShell(cmd.Cmd):\n" +" intro = 'Welcome to the turtle shell. Type help or ? to list commands." +"\\n'\n" +" prompt = '(turtle) '\n" +" file = None\n" +"\n" +" # ----- basic turtle commands -----\n" +" def do_forward(self, arg):\n" +" 'Move the turtle forward by the specified distance: FORWARD 10'\n" +" forward(*parse(arg))\n" +" def do_right(self, arg):\n" +" 'Turn turtle right by given number of degrees: RIGHT 20'\n" +" right(*parse(arg))\n" +" def do_left(self, arg):\n" +" 'Turn turtle left by given number of degrees: LEFT 90'\n" +" left(*parse(arg))\n" +" def do_goto(self, arg):\n" +" 'Move turtle to an absolute position with changing orientation. " +"GOTO 100 200'\n" +" goto(*parse(arg))\n" +" def do_home(self, arg):\n" +" 'Return turtle to the home position: HOME'\n" +" home()\n" +" def do_circle(self, arg):\n" +" 'Draw circle with given radius an options extent and steps: CIRCLE " +"50'\n" +" circle(*parse(arg))\n" +" def do_position(self, arg):\n" +" 'Print the current turtle position: POSITION'\n" +" print('Current position is %d %d\\n' % position())\n" +" def do_heading(self, arg):\n" +" 'Print the current turtle heading in degrees: HEADING'\n" +" print('Current heading is %d\\n' % (heading(),))\n" +" def do_color(self, arg):\n" +" 'Set the color: COLOR BLUE'\n" +" color(arg.lower())\n" +" def do_undo(self, arg):\n" +" 'Undo (repeatedly) the last turtle action(s): UNDO'\n" +" def do_reset(self, arg):\n" +" 'Clear the screen and return turtle to center: RESET'\n" +" reset()\n" +" def do_bye(self, arg):\n" +" 'Stop recording, close the turtle window, and exit: BYE'\n" +" print('Thank you for using Turtle')\n" +" self.close()\n" +" bye()\n" +" return True\n" +"\n" +" # ----- record and playback -----\n" +" def do_record(self, arg):\n" +" 'Save future commands to filename: RECORD rose.cmd'\n" +" self.file = open(arg, 'w')\n" +" def do_playback(self, arg):\n" +" 'Playback commands from a file: PLAYBACK rose.cmd'\n" +" self.close()\n" +" with open(arg) as f:\n" +" self.cmdqueue.extend(f.read().splitlines())\n" +" def precmd(self, line):\n" +" line = line.lower()\n" +" if self.file and 'playback' not in line:\n" +" print(line, file=self.file)\n" +" return line\n" +" def close(self):\n" +" if self.file:\n" +" self.file.close()\n" +" self.file = None\n" +"\n" +"def parse(arg):\n" +" 'Convert a series of zero or more numbers to an argument tuple'\n" +" return tuple(map(int, arg.split()))\n" +"\n" +"if __name__ == '__main__':\n" +" TurtleShell().cmdloop()" msgstr "" #: library/cmd.rst:330 @@ -311,6 +394,67 @@ msgid "" "facility:" msgstr "" +#: library/cmd.rst:333 +msgid "" +"Welcome to the turtle shell. Type help or ? to list commands.\n" +"\n" +"(turtle) ?\n" +"\n" +"Documented commands (type help ):\n" +"========================================\n" +"bye color goto home playback record right\n" +"circle forward heading left position reset undo\n" +"\n" +"(turtle) help forward\n" +"Move the turtle forward by the specified distance: FORWARD 10\n" +"(turtle) record spiral.cmd\n" +"(turtle) position\n" +"Current position is 0 0\n" +"\n" +"(turtle) heading\n" +"Current heading is 0\n" +"\n" +"(turtle) reset\n" +"(turtle) circle 20\n" +"(turtle) right 30\n" +"(turtle) circle 40\n" +"(turtle) right 30\n" +"(turtle) circle 60\n" +"(turtle) right 30\n" +"(turtle) circle 80\n" +"(turtle) right 30\n" +"(turtle) circle 100\n" +"(turtle) right 30\n" +"(turtle) circle 120\n" +"(turtle) right 30\n" +"(turtle) circle 120\n" +"(turtle) heading\n" +"Current heading is 180\n" +"\n" +"(turtle) forward 100\n" +"(turtle)\n" +"(turtle) right 90\n" +"(turtle) forward 100\n" +"(turtle)\n" +"(turtle) right 90\n" +"(turtle) forward 400\n" +"(turtle) right 90\n" +"(turtle) forward 500\n" +"(turtle) right 90\n" +"(turtle) forward 400\n" +"(turtle) right 90\n" +"(turtle) forward 300\n" +"(turtle) playback spiral.cmd\n" +"Current position is 0 0\n" +"\n" +"Current heading is 0\n" +"\n" +"Current heading is 180\n" +"\n" +"(turtle) bye\n" +"Thank you for using Turtle" +msgstr "" + #: library/cmd.rst:64 msgid "? (question mark)" msgstr "" diff --git a/library/cmdline.po b/library/cmdline.po index 89a507c9..4f3d2e53 100644 --- a/library/cmdline.po +++ b/library/cmdline.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/code.po b/library/code.po index 336b3306..a769855c 100644 --- a/library/code.po +++ b/library/code.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/code.rst:2 -msgid ":mod:`code` --- Interpreter base classes" +msgid ":mod:`!code` --- Interpreter base classes" msgstr "" #: library/code.rst:7 @@ -54,10 +55,10 @@ msgid "" "instance of :class:`InteractiveConsole` and sets *readfunc* to be used as " "the :meth:`InteractiveConsole.raw_input` method, if provided. If *local* is " "provided, it is passed to the :class:`InteractiveConsole` constructor for " -"use as the default namespace for the interpreter loop. The :meth:`interact` " -"method of the instance is then run with *banner* and *exitmsg* passed as the " -"banner and exit message to use, if provided. The console object is " -"discarded after use." +"use as the default namespace for the interpreter loop. " +"The :meth:`~InteractiveConsole.interact` method of the instance is then run " +"with *banner* and *exitmsg* passed as the banner and exit message to use, if " +"provided. The console object is discarded after use." msgstr "" #: library/code.rst:44 @@ -104,10 +105,10 @@ msgstr "" #: library/code.rst:81 msgid "" -"The input is incorrect; :func:`compile_command` raised an exception (:exc:" -"`SyntaxError` or :exc:`OverflowError`). A syntax traceback will be printed " -"by calling the :meth:`showsyntaxerror` method. :meth:`runsource` returns " -"``False``." +"The input is incorrect; :func:`compile_command` raised an exception " +"(:exc:`SyntaxError` or :exc:`OverflowError`). A syntax traceback will be " +"printed by calling the :meth:`showsyntaxerror` method. :meth:`runsource` " +"returns ``False``." msgstr "" #: library/code.rst:86 @@ -126,15 +127,15 @@ msgstr "" #: library/code.rst:93 msgid "" -"The return value can be used to decide whether to use ``sys.ps1`` or ``sys." -"ps2`` to prompt the next line." +"The return value can be used to decide whether to use ``sys.ps1`` or " +"``sys.ps2`` to prompt the next line." msgstr "" #: library/code.rst:99 msgid "" "Execute a code object. When an exception occurs, :meth:`showtraceback` is " -"called to display a traceback. All exceptions are caught except :exc:" -"`SystemExit`, which is allowed to propagate." +"called to display a traceback. All exceptions are caught " +"except :exc:`SystemExit`, which is allowed to propagate." msgstr "" #: library/code.rst:103 @@ -179,9 +180,9 @@ msgstr "" #: library/code.rst:138 msgid "" -"The :class:`InteractiveConsole` class is a subclass of :class:" -"`InteractiveInterpreter`, and so offers all the methods of the interpreter " -"objects as well as the following additions." +"The :class:`InteractiveConsole` class is a subclass " +"of :class:`InteractiveInterpreter`, and so offers all the methods of the " +"interpreter objects as well as the following additions." msgstr "" #: library/code.rst:145 @@ -229,7 +230,7 @@ msgstr "" #: library/code.rst:181 msgid "" "Write a prompt and read a line. The returned line does not include the " -"trailing newline. When the user enters the EOF key sequence, :exc:" -"`EOFError` is raised. The base implementation reads from ``sys.stdin``; a " -"subclass may replace this with a different implementation." +"trailing newline. When the user enters the EOF key " +"sequence, :exc:`EOFError` is raised. The base implementation reads from " +"``sys.stdin``; a subclass may replace this with a different implementation." msgstr "" diff --git a/library/codecs.po b/library/codecs.po index 1bbda107..daf6afa6 100644 --- a/library/codecs.po +++ b/library/codecs.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/codecs.rst:2 -msgid ":mod:`codecs` --- Codec registry and base classes" +msgid ":mod:`!codecs` --- Codec registry and base classes" msgstr "" #: library/codecs.rst:11 @@ -50,9 +51,9 @@ msgstr "" #: library/codecs.rst:40 msgid "" "*Errors* may be given to set the desired error handling scheme. The default " -"error handler is ``'strict'`` meaning that encoding errors raise :exc:" -"`ValueError` (or a more codec specific subclass, such as :exc:" -"`UnicodeEncodeError`). Refer to :ref:`codec-base-classes` for more " +"error handler is ``'strict'`` meaning that encoding errors " +"raise :exc:`ValueError` (or a more codec specific subclass, such " +"as :exc:`UnicodeEncodeError`). Refer to :ref:`codec-base-classes` for more " "information on codec error handling." msgstr "" @@ -63,9 +64,9 @@ msgstr "" #: library/codecs.rst:50 msgid "" "*Errors* may be given to set the desired error handling scheme. The default " -"error handler is ``'strict'`` meaning that decoding errors raise :exc:" -"`ValueError` (or a more codec specific subclass, such as :exc:" -"`UnicodeDecodeError`). Refer to :ref:`codec-base-classes` for more " +"error handler is ``'strict'`` meaning that decoding errors " +"raise :exc:`ValueError` (or a more codec specific subclass, such " +"as :exc:`UnicodeDecodeError`). Refer to :ref:`codec-base-classes` for more " "information on codec error handling." msgstr "" @@ -75,16 +76,17 @@ msgstr "" #: library/codecs.rst:60 msgid "" -"Looks up the codec info in the Python codec registry and returns a :class:" -"`CodecInfo` object as defined below." +"Looks up the codec info in the Python codec registry and returns " +"a :class:`CodecInfo` object as defined below." msgstr "" #: library/codecs.rst:63 msgid "" "Encodings are first looked up in the registry's cache. If not found, the " "list of registered search functions is scanned. If no :class:`CodecInfo` " -"object is found, a :exc:`LookupError` is raised. Otherwise, the :class:" -"`CodecInfo` object is stored in the cache and returned to the caller." +"object is found, a :exc:`LookupError` is raised. Otherwise, " +"the :class:`CodecInfo` object is stored in the cache and returned to the " +"caller." msgstr "" #: library/codecs.rst:70 @@ -100,25 +102,25 @@ msgstr "" #: library/codecs.rst:82 msgid "" "The stateless encoding and decoding functions. These must be functions or " -"methods which have the same interface as the :meth:`~Codec.encode` and :meth:" -"`~Codec.decode` methods of Codec instances (see :ref:`Codec Interface `). The functions or methods are expected to work in a stateless " -"mode." +"methods which have the same interface as the :meth:`~Codec.encode` " +"and :meth:`~Codec.decode` methods of Codec instances (see :ref:`Codec " +"Interface `). The functions or methods are expected to work " +"in a stateless mode." msgstr "" #: library/codecs.rst:92 msgid "" "Incremental encoder and decoder classes or factory functions. These have to " -"provide the interface defined by the base classes :class:" -"`IncrementalEncoder` and :class:`IncrementalDecoder`, respectively. " -"Incremental codecs can maintain state." +"provide the interface defined by the base " +"classes :class:`IncrementalEncoder` and :class:`IncrementalDecoder`, " +"respectively. Incremental codecs can maintain state." msgstr "" #: library/codecs.rst:101 msgid "" "Stream writer and reader classes or factory functions. These have to provide " -"the interface defined by the base classes :class:`StreamWriter` and :class:" -"`StreamReader`, respectively. Stream codecs can maintain state." +"the interface defined by the base classes :class:`StreamWriter` " +"and :class:`StreamReader`, respectively. Stream codecs can maintain state." msgstr "" #: library/codecs.rst:106 @@ -167,14 +169,14 @@ msgstr "" #: library/codecs.rst:143 msgid "" -"Look up the codec for the given encoding and return its :class:" -"`StreamReader` class or factory function." +"Look up the codec for the given encoding and return " +"its :class:`StreamReader` class or factory function." msgstr "" #: library/codecs.rst:151 msgid "" -"Look up the codec for the given encoding and return its :class:" -"`StreamWriter` class or factory function." +"Look up the codec for the given encoding and return " +"its :class:`StreamWriter` class or factory function." msgstr "" #: library/codecs.rst:156 @@ -212,9 +214,9 @@ msgstr "" #: library/codecs.rst:186 msgid "" -"Open an encoded file using the given *mode* and return an instance of :class:" -"`StreamReaderWriter`, providing transparent encoding/decoding. The default " -"file mode is ``'r'``, meaning to open the file in read mode." +"Open an encoded file using the given *mode* and return an instance " +"of :class:`StreamReaderWriter`, providing transparent encoding/decoding. The " +"default file mode is ``'r'``, meaning to open the file in read mode." msgstr "" #: library/codecs.rst:192 @@ -302,8 +304,8 @@ msgstr "" msgid "" "This function requires that the codec accept :class:`bytes` objects to " "decode. Therefore it does not support text-to-text encoders such as " -"``rot_13``, although ``rot_13`` may be used equivalently with :func:" -"`iterencode`." +"``rot_13``, although ``rot_13`` may be used equivalently " +"with :func:`iterencode`." msgstr "" #: library/codecs.rst:256 @@ -317,11 +319,11 @@ msgid "" "These constants define various byte sequences, being Unicode byte order " "marks (BOMs) for several encodings. They are used in UTF-16 and UTF-32 data " "streams to indicate the byte order used, and in UTF-8 as a Unicode " -"signature. :const:`BOM_UTF16` is either :const:`BOM_UTF16_BE` or :const:" -"`BOM_UTF16_LE` depending on the platform's native byte order, :const:`BOM` " -"is an alias for :const:`BOM_UTF16`, :const:`BOM_LE` for :const:" -"`BOM_UTF16_LE` and :const:`BOM_BE` for :const:`BOM_UTF16_BE`. The others " -"represent the BOM in UTF-8 and UTF-32 encodings." +"signature. :const:`BOM_UTF16` is either :const:`BOM_UTF16_BE` " +"or :const:`BOM_UTF16_LE` depending on the platform's native byte " +"order, :const:`BOM` is an alias for :const:`BOM_UTF16`, :const:`BOM_LE` " +"for :const:`BOM_UTF16_LE` and :const:`BOM_BE` for :const:`BOM_UTF16_BE`. The " +"others represent the BOM in UTF-8 and UTF-32 encodings." msgstr "" #: library/codecs.rst:285 @@ -406,9 +408,10 @@ msgstr "" #: library/codecs.rst:346 msgid "" "Replace with backslashed escape sequences. On encoding, use hexadecimal form " -"of Unicode code point with formats :samp:`\\\\x{hh}` :samp:`\\\\u{xxxx}` :" -"samp:`\\\\U{xxxxxxxx}`. On decoding, use hexadecimal form of byte value with " -"format :samp:`\\\\x{hh}`. Implemented in :func:`backslashreplace_errors`." +"of Unicode code point with formats :samp:`\\\\x{hh}` :samp:`\\\\u{xxxx}" +"` :samp:`\\\\U{xxxxxxxx}`. On decoding, use hexadecimal form of byte value " +"with format :samp:`\\\\x{hh}`. Implemented " +"in :func:`backslashreplace_errors`." msgstr "" #: library/codecs.rst:355 @@ -425,8 +428,8 @@ msgstr "" #: library/codecs.rst:369 msgid "" -"The following error handlers are only applicable to encoding (within :term:" -"`text encodings `):" +"The following error handlers are only applicable to encoding " +"(within :term:`text encodings `):" msgstr "" #: library/codecs.rst:375 @@ -436,8 +439,8 @@ msgstr "" #: library/codecs.rst:375 msgid "" "Replace with XML/HTML numeric character reference, which is a decimal form " -"of Unicode code point with format :samp:`&#{num};`. Implemented in :func:" -"`xmlcharrefreplace_errors`." +"of Unicode code point with format :samp:`&#{num};`. Implemented " +"in :func:`xmlcharrefreplace_errors`." msgstr "" #: library/codecs.rst:381 @@ -447,8 +450,8 @@ msgstr "" #: library/codecs.rst:381 msgid "" "Replace with ``\\N{...}`` escape sequences, what appears in the braces is " -"the Name property from Unicode Character Database. Implemented in :func:" -"`namereplace_errors`." +"the Name property from Unicode Character Database. Implemented " +"in :func:`namereplace_errors`." msgstr "" #: library/codecs.rst:390 @@ -510,17 +513,18 @@ msgstr "" #: library/codecs.rst:425 msgid "" -"For encoding, *error_handler* will be called with a :exc:" -"`UnicodeEncodeError` instance, which contains information about the location " -"of the error. The error handler must either raise this or a different " -"exception, or return a tuple with a replacement for the unencodable part of " -"the input and a position where encoding should continue. The replacement may " -"be either :class:`str` or :class:`bytes`. If the replacement is bytes, the " -"encoder will simply copy them into the output buffer. If the replacement is " -"a string, the encoder will encode the replacement. Encoding continues on " -"original input at the specified position. Negative position values will be " -"treated as being relative to the end of the input string. If the resulting " -"position is out of bound an :exc:`IndexError` will be raised." +"For encoding, *error_handler* will be called with " +"a :exc:`UnicodeEncodeError` instance, which contains information about the " +"location of the error. The error handler must either raise this or a " +"different exception, or return a tuple with a replacement for the " +"unencodable part of the input and a position where encoding should continue. " +"The replacement may be either :class:`str` or :class:`bytes`. If the " +"replacement is bytes, the encoder will simply copy them into the output " +"buffer. If the replacement is a string, the encoder will encode the " +"replacement. Encoding continues on original input at the specified position. " +"Negative position values will be treated as being relative to the end of the " +"input string. If the resulting position is out of bound an :exc:`IndexError` " +"will be raised." msgstr "" #: library/codecs.rst:437 @@ -596,8 +600,8 @@ msgstr "" #: library/codecs.rst:493 msgid "" -"Implements the ``'xmlcharrefreplace'`` error handling (for encoding within :" -"term:`text encoding` only)." +"Implements the ``'xmlcharrefreplace'`` error handling (for encoding " +"within :term:`text encoding` only)." msgstr "" #: library/codecs.rst:496 @@ -609,8 +613,8 @@ msgstr "" #: library/codecs.rst:503 msgid "" -"Implements the ``'namereplace'`` error handling (for encoding within :term:" -"`text encoding` only)." +"Implements the ``'namereplace'`` error handling (for encoding " +"within :term:`text encoding` only)." msgstr "" #: library/codecs.rst:506 @@ -647,9 +651,9 @@ msgstr "" #: library/codecs.rst:535 msgid "" -"The method may not store state in the :class:`Codec` instance. Use :class:" -"`StreamWriter` for codecs which have to keep state in order to make encoding " -"efficient." +"The method may not store state in the :class:`Codec` instance. " +"Use :class:`StreamWriter` for codecs which have to keep state in order to " +"make encoding efficient." msgstr "" #: library/codecs.rst:539 @@ -675,9 +679,9 @@ msgstr "" #: library/codecs.rst:557 msgid "" -"The method may not store state in the :class:`Codec` instance. Use :class:" -"`StreamReader` for codecs which have to keep state in order to make decoding " -"efficient." +"The method may not store state in the :class:`Codec` instance. " +"Use :class:`StreamReader` for codecs which have to keep state in order to " +"make decoding efficient." msgstr "" #: library/codecs.rst:561 @@ -695,18 +699,18 @@ msgid "" "The :class:`IncrementalEncoder` and :class:`IncrementalDecoder` classes " "provide the basic interface for incremental encoding and decoding. Encoding/" "decoding the input isn't done with one call to the stateless encoder/decoder " -"function, but with multiple calls to the :meth:`~IncrementalEncoder.encode`/:" -"meth:`~IncrementalDecoder.decode` method of the incremental encoder/decoder. " -"The incremental encoder/decoder keeps track of the encoding/decoding process " -"during method calls." +"function, but with multiple calls to " +"the :meth:`~IncrementalEncoder.encode`/:meth:`~IncrementalDecoder.decode` " +"method of the incremental encoder/decoder. The incremental encoder/decoder " +"keeps track of the encoding/decoding process during method calls." msgstr "" #: library/codecs.rst:576 msgid "" -"The joined output of calls to the :meth:`~IncrementalEncoder.encode`/:meth:" -"`~IncrementalDecoder.decode` method is the same as if all the single inputs " -"were joined into one, and this input was encoded/decoded with the stateless " -"encoder/decoder." +"The joined output of calls to " +"the :meth:`~IncrementalEncoder.encode`/:meth:`~IncrementalDecoder.decode` " +"method is the same as if all the single inputs were joined into one, and " +"this input was encoded/decoded with the stateless encoder/decoder." msgstr "" #: library/codecs.rst:585 @@ -742,21 +746,21 @@ msgstr "" msgid "" "The *errors* argument will be assigned to an attribute of the same name. " "Assigning to this attribute makes it possible to switch between different " -"error handling strategies during the lifetime of the :class:" -"`IncrementalEncoder` object." +"error handling strategies during the lifetime of " +"the :class:`IncrementalEncoder` object." msgstr "" #: library/codecs.rst:612 msgid "" "Encodes *object* (taking the current state of the encoder into account) and " -"returns the resulting encoded object. If this is the last call to :meth:" -"`encode` *final* must be true (the default is false)." +"returns the resulting encoded object. If this is the last call " +"to :meth:`encode` *final* must be true (the default is false)." msgstr "" #: library/codecs.rst:619 msgid "" -"Reset the encoder to the initial state. The output is discarded: call ``." -"encode(object, final=True)``, passing an empty byte or text string if " +"Reset the encoder to the initial state. The output is discarded: call " +"``.encode(object, final=True)``, passing an empty byte or text string if " "necessary, to reset the encoder and to get the output." msgstr "" @@ -808,19 +812,19 @@ msgstr "" msgid "" "The *errors* argument will be assigned to an attribute of the same name. " "Assigning to this attribute makes it possible to switch between different " -"error handling strategies during the lifetime of the :class:" -"`IncrementalDecoder` object." +"error handling strategies during the lifetime of " +"the :class:`IncrementalDecoder` object." msgstr "" #: library/codecs.rst:669 msgid "" "Decodes *object* (taking the current state of the decoder into account) and " -"returns the resulting decoded object. If this is the last call to :meth:" -"`decode` *final* must be true (the default is false). If *final* is true the " -"decoder must decode the input completely and must flush all buffers. If this " -"isn't possible (e.g. because of incomplete byte sequences at the end of the " -"input) it must initiate error handling just like in the stateless case " -"(which might raise an exception)." +"returns the resulting decoded object. If this is the last call " +"to :meth:`decode` *final* must be true (the default is false). If *final* is " +"true the decoder must decode the input completely and must flush all " +"buffers. If this isn't possible (e.g. because of incomplete byte sequences " +"at the end of the input) it must initiate error handling just like in the " +"stateless case (which might raise an exception)." msgstr "" #: library/codecs.rst:680 @@ -975,8 +979,8 @@ msgstr "" #: library/codecs.rst:797 msgid "" -"The set of allowed values for the *errors* argument can be extended with :" -"func:`register_error`." +"The set of allowed values for the *errors* argument can be extended " +"with :func:`register_error`." msgstr "" #: library/codecs.rst:803 @@ -1042,8 +1046,8 @@ msgstr "" #: library/codecs.rst:846 msgid "" -"*sizehint*, if given, is passed as the *size* argument to the stream's :meth:" -"`read` method." +"*sizehint*, if given, is passed as the *size* argument to the " +"stream's :meth:`read` method." msgstr "" #: library/codecs.rst:854 @@ -1070,8 +1074,8 @@ msgstr "" #: library/codecs.rst:893 msgid "" -"The design is such that one can use the factory functions returned by the :" -"func:`lookup` function to construct the instance." +"The design is such that one can use the factory functions returned by " +"the :func:`lookup` function to construct the instance." msgstr "" #: library/codecs.rst:875 @@ -1085,8 +1089,8 @@ msgstr "" #: library/codecs.rst:880 msgid "" -":class:`StreamReaderWriter` instances define the combined interfaces of :" -"class:`StreamReader` and :class:`StreamWriter` classes. They inherit all " +":class:`StreamReaderWriter` instances define the combined interfaces " +"of :class:`StreamReader` and :class:`StreamWriter` classes. They inherit all " "other methods and attributes from the underlying stream." msgstr "" @@ -1134,9 +1138,9 @@ msgstr "" #: library/codecs.rst:919 msgid "" -":class:`StreamRecoder` instances define the combined interfaces of :class:" -"`StreamReader` and :class:`StreamWriter` classes. They inherit all other " -"methods and attributes from the underlying stream." +":class:`StreamRecoder` instances define the combined interfaces " +"of :class:`StreamReader` and :class:`StreamWriter` classes. They inherit all " +"other methods and attributes from the underlying stream." msgstr "" #: library/codecs.rst:927 @@ -2279,9 +2283,9 @@ msgstr "" #: library/codecs.rst:1323 msgid "" -"The following codecs provide :class:`str` to :class:`bytes` encoding and :" -"term:`bytes-like object` to :class:`str` decoding, similar to the Unicode " -"text encodings." +"The following codecs provide :class:`str` to :class:`bytes` encoding " +"and :term:`bytes-like object` to :class:`str` decoding, similar to the " +"Unicode text encodings." msgstr "" #: library/codecs.rst:1332 @@ -2509,9 +2513,9 @@ msgstr "" #: library/codecs.rst:1448 msgid "" -"The following codec provides a text transform: a :class:`str` to :class:" -"`str` mapping. It is not supported by :meth:`str.encode` (which only " -"produces :class:`bytes` output)." +"The following codec provides a text transform: a :class:`str` " +"to :class:`str` mapping. It is not supported by :meth:`str.encode` (which " +"only produces :class:`bytes` output)." msgstr "" #: library/codecs.rst:1457 @@ -2550,21 +2554,21 @@ msgstr "" #: library/codecs.rst:1481 msgid "" "If you need the IDNA 2008 standard from :rfc:`5891` and :rfc:`5895`, use the " -"third-party `idna module `_." +"third-party :pypi:`idna` module." msgstr "" #: library/codecs.rst:1484 msgid "" "These RFCs together define a protocol to support non-ASCII characters in " -"domain names. A domain name containing non-ASCII characters (such as ``www." -"Alliancefrançaise.nu``) is converted into an ASCII-compatible encoding (ACE, " -"such as ``www.xn--alliancefranaise-npb.nu``). The ACE form of the domain " -"name is then used in all places where arbitrary characters are not allowed " -"by the protocol, such as DNS queries, HTTP :mailheader:`Host` fields, and so " -"on. This conversion is carried out in the application; if possible invisible " -"to the user: The application should transparently convert Unicode domain " -"labels to IDNA on the wire, and convert back ACE labels to Unicode before " -"presenting them to the user." +"domain names. A domain name containing non-ASCII characters (such as " +"``www.Alliancefrançaise.nu``) is converted into an ASCII-compatible encoding " +"(ACE, such as ``www.xn--alliancefranaise-npb.nu``). The ACE form of the " +"domain name is then used in all places where arbitrary characters are not " +"allowed by the protocol, such as DNS queries, HTTP :mailheader:`Host` " +"fields, and so on. This conversion is carried out in the application; if " +"possible invisible to the user: The application should transparently convert " +"Unicode domain labels to IDNA on the wire, and convert back ACE labels to " +"Unicode before presenting them to the user." msgstr "" #: library/codecs.rst:1495 @@ -2578,8 +2582,8 @@ msgid "" "the :mod:`socket` module transparently converts Unicode host names to ACE, " "so that applications need not be concerned about converting host names " "themselves when they pass them to the socket module. On top of that, modules " -"that have host names as function parameters, such as :mod:`http.client` and :" -"mod:`ftplib`, accept Unicode host names (:mod:`http.client` then also " +"that have host names as function parameters, such as :mod:`http.client` " +"and :mod:`ftplib`, accept Unicode host names (:mod:`http.client` then also " "transparently sends an IDNA hostname in the :mailheader:`Host` field if it " "sends that field at all)." msgstr "" @@ -2624,7 +2628,7 @@ msgid "This module implements the ANSI codepage (CP_ACP)." msgstr "" #: library/codecs.rst:1543 -msgid ":ref:`Availability `: Windows." +msgid "Availability" msgstr "" #: library/codecs.rst:1545 diff --git a/library/codeop.po b/library/codeop.po index 250dffca..41539bf5 100644 --- a/library/codeop.po +++ b/library/codeop.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/codeop.rst:2 -msgid ":mod:`codeop` --- Compile Python code" +msgid ":mod:`!codeop` --- Compile Python code" msgstr "" #: library/codeop.rst:10 @@ -70,17 +71,17 @@ msgstr "" #: library/codeop.rst:41 msgid "" -"If there is a problem with *source*, an exception will be raised. :exc:" -"`SyntaxError` is raised if there is invalid Python syntax, and :exc:" -"`OverflowError` or :exc:`ValueError` if there is an invalid literal." +"If there is a problem with *source*, an exception will be " +"raised. :exc:`SyntaxError` is raised if there is invalid Python syntax, " +"and :exc:`OverflowError` or :exc:`ValueError` if there is an invalid literal." msgstr "" #: library/codeop.rst:45 msgid "" "The *symbol* argument determines whether *source* is compiled as a statement " "(``'single'``, the default), as a sequence of :term:`statement` (``'exec'``) " -"or as an :term:`expression` (``'eval'``). Any other value will cause :exc:" -"`ValueError` to be raised." +"or as an :term:`expression` (``'eval'``). Any other value will " +"cause :exc:`ValueError` to be raised." msgstr "" #: library/codeop.rst:52 diff --git a/library/collections.abc.po b/library/collections.abc.po index f4009c40..14820435 100644 --- a/library/collections.abc.po +++ b/library/collections.abc.po @@ -8,16 +8,18 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2025-01-03 15:43+0200\n" "Last-Translator: Marios Giannopoulos \n" "Language-Team: PyGreece \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/collections.abc.rst:2 -msgid ":mod:`collections.abc` --- Abstract Base Classes for Containers" +#, fuzzy +msgid ":mod:`!collections.abc` --- Abstract Base Classes for Containers" msgstr ":mod:`collections.abc` --- Αφηρημένες Βασικές Κλάσεις για Containers" #: library/collections.abc.rst:10 @@ -32,8 +34,8 @@ msgstr "**Πηγαίος κώδικας:** :source:`Lib/_collections_abc.py`" msgid "" "This module provides :term:`abstract base classes ` " "that can be used to test whether a class provides a particular interface; " -"for example, whether it is :term:`hashable` or whether it is a :term:" -"`mapping`." +"for example, whether it is :term:`hashable` or whether it is " +"a :term:`mapping`." msgstr "" "Αυτό το module παρέχει :term:`αφηρημένες βασικές κλάσεις ` που μπορούν να χρησιμοποιηθούν για να ελεγχθεί εάν μια κλάση παρέχει " @@ -61,6 +63,24 @@ msgstr "" "παρακαμφθούν αν χρειάζεται. Άλλες μέθοδοι μπορούν να προστεθούν όταν είναι " "αναγκαίο:" +#: library/collections.abc.rst:35 +msgid "" +"class C(Sequence): # Direct inheritance\n" +" def __init__(self): ... # Extra method not required by the " +"ABC\n" +" def __getitem__(self, index): ... # Required abstract method\n" +" def __len__(self): ... # Required abstract method\n" +" def count(self, value): ... # Optionally override a mixin method" +msgstr "" + +#: library/collections.abc.rst:43 +msgid "" +">>> issubclass(C, Sequence)\n" +"True\n" +">>> isinstance(C(), Sequence)\n" +"True" +msgstr "" + #: library/collections.abc.rst:50 msgid "" "2) Existing classes and built-in classes can be registered as \"virtual " @@ -73,18 +93,39 @@ msgstr "" "2) Υπάρχουσες κλάσεις και ενσωματωμένες κλάσεις μπορούν να καταχωρηθούν ως " "\"εικονικές υποκλάσεις\" των ABCs. Αυτές οι κλάσεις θα πρέπει να ορίζουν το " "πλήρες API, συμπεριλαμβανομένων όλων των αφηρημένων μεθόδων και όλων των " -"μεθόδων mixin. Αυτό επιτρέπει στους χρήστες να βασίζονται στους ελέγχους :" -"func:`issubclass` ή :func:`isinstance` για να καθορίσουν εάν υποστηρίζεται η " -"πλήρης διεπαφή. Η εξαίρεση σε αυτό τον κανόνα είναι για τις μεθόδους που " -"προσδιορίζονται αυτόματα από το υπόλοιπο API:" +"μεθόδων mixin. Αυτό επιτρέπει στους χρήστες να βασίζονται στους " +"ελέγχους :func:`issubclass` ή :func:`isinstance` για να καθορίσουν εάν " +"υποστηρίζεται η πλήρης διεπαφή. Η εξαίρεση σε αυτό τον κανόνα είναι για τις " +"μεθόδους που προσδιορίζονται αυτόματα από το υπόλοιπο API:" + +#: library/collections.abc.rst:58 +msgid "" +"class D: # No inheritance\n" +" def __init__(self): ... # Extra method not required by the " +"ABC\n" +" def __getitem__(self, index): ... # Abstract method\n" +" def __len__(self): ... # Abstract method\n" +" def count(self, value): ... # Mixin method\n" +" def index(self, value): ... # Mixin method\n" +"\n" +"Sequence.register(D) # Register instead of inherit" +msgstr "" + +#: library/collections.abc.rst:69 +msgid "" +">>> issubclass(D, Sequence)\n" +"True\n" +">>> isinstance(D(), Sequence)\n" +"True" +msgstr "" #: library/collections.abc.rst:76 msgid "" "In this example, class :class:`!D` does not need to define ``__contains__``, " "``__iter__``, and ``__reversed__`` because the :ref:`in-operator " -"`, the :term:`iteration ` logic, and the :func:" -"`reversed` function automatically fall back to using ``__getitem__`` and " -"``__len__``." +"`, the :term:`iteration ` logic, and " +"the :func:`reversed` function automatically fall back to using " +"``__getitem__`` and ``__len__``." msgstr "" "Σε αυτό το παράδειγμα, η κλάση :class:`!D` δεν χρειάζεται να ορίσει τις " "μεθόδους ``__contains__``, ``__iter__``, και ``__reversed__`` επειδή ο " @@ -98,8 +139,23 @@ msgid "" "required methods (unless those methods have been set to :const:`None`):" msgstr "" "3) Ορισμένες απλές διεπαφές είναι άμεσα αναγνωρίσιμες από την παρουσία των " -"απαιτούμενων μεθόδων (εκτός αν αυτές οι μέθοδοι έχουν οριστεί σε :const:" -"`None`): " +"απαιτούμενων μεθόδων (εκτός αν αυτές οι μέθοδοι έχουν οριστεί " +"σε :const:`None`): " + +#: library/collections.abc.rst:86 +msgid "" +"class E:\n" +" def __iter__(self): ...\n" +" def __next__(self): ..." +msgstr "" + +#: library/collections.abc.rst:92 +msgid "" +">>> issubclass(E, Iterable)\n" +"True\n" +">>> isinstance(E(), Iterable)\n" +"True" +msgstr "" #: library/collections.abc.rst:99 msgid "" @@ -205,7 +261,7 @@ msgstr ":class:`Generator` [1]_" msgid ":class:`Iterator`" msgstr ":class:`Iterator`" -#: library/collections.abc.rst:128 library/collections.abc.rst:176 +#: library/collections.abc.rst:128 library/collections.abc.rst:177 msgid "``send``, ``throw``" msgstr "``send``, ``throw``" @@ -217,7 +273,7 @@ msgstr "``close``, ``__iter__``, ``__next__``" msgid ":class:`Sized` [1]_" msgstr ":class:`Sized` [1]_" -#: library/collections.abc.rst:129 library/collections.abc.rst:168 +#: library/collections.abc.rst:129 msgid "``__len__``" msgstr "``__len__``" @@ -286,31 +342,33 @@ msgstr ":class:`ByteString`" msgid "Inherited :class:`Sequence` methods" msgstr "Κληρονομημένες :class:`Sequence` μέθοδοι" -#: library/collections.abc.rst:147 library/collections.abc.rst:151 +#: library/collections.abc.rst:147 library/collections.abc.rst:152 msgid ":class:`Set`" msgstr ":class:`Set`" -#: library/collections.abc.rst:147 library/collections.abc.rst:157 +#: library/collections.abc.rst:147 library/collections.abc.rst:158 msgid ":class:`Collection`" msgstr ":class:`Collection`" #: library/collections.abc.rst:147 +#, fuzzy msgid "" "``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, ``__gt__``, ``__ge__``, " -"``__and__``, ``__or__``, ``__sub__``, ``__xor__``, and ``isdisjoint``" +"``__and__``, ``__or__``, ``__sub__``, ``__rsub__``, ``__xor__``, " +"``__rxor__`` and ``isdisjoint``" msgstr "" "``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, ``__gt__``, ``__ge__``, " "``__and__``, ``__or__``, ``__sub__``, ``__xor__``, και ``isdisjoint``" -#: library/collections.abc.rst:151 +#: library/collections.abc.rst:152 msgid ":class:`MutableSet`" msgstr ":class:`MutableSet`" -#: library/collections.abc.rst:151 +#: library/collections.abc.rst:152 msgid "``__contains__``, ``__iter__``, ``__len__``, ``add``, ``discard``" msgstr "``__contains__``, ``__iter__``, ``__len__``, ``add``, ``discard``" -#: library/collections.abc.rst:151 +#: library/collections.abc.rst:152 msgid "" "Inherited :class:`Set` methods and ``clear``, ``pop``, ``remove``, " "``__ior__``, ``__iand__``, ``__ixor__``, and ``__isub__``" @@ -318,15 +376,15 @@ msgstr "" "Κληρονομημένες :class:`Set` μέθοδοι και ``clear``, ``pop``, ``remove``, " "``__ior__``, ``__iand__``, ``__ixor__``, και ``__isub__``" -#: library/collections.abc.rst:157 library/collections.abc.rst:161 +#: library/collections.abc.rst:158 library/collections.abc.rst:162 msgid ":class:`Mapping`" msgstr ":class:`Mapping`" -#: library/collections.abc.rst:157 +#: library/collections.abc.rst:158 msgid "``__getitem__``, ``__iter__``, ``__len__``" msgstr "``__getitem__``, ``__iter__``, ``__len__``" -#: library/collections.abc.rst:157 +#: library/collections.abc.rst:158 msgid "" "``__contains__``, ``keys``, ``items``, ``values``, ``get``, ``__eq__``, and " "``__ne__``" @@ -334,17 +392,17 @@ msgstr "" "``__contains__``, ``keys``, ``items``, ``values``, ``get``, ``__eq__``, και " "``__ne__``" -#: library/collections.abc.rst:161 +#: library/collections.abc.rst:162 msgid ":class:`MutableMapping`" msgstr ":class:`MutableMapping`" -#: library/collections.abc.rst:161 +#: library/collections.abc.rst:162 msgid "" "``__getitem__``, ``__setitem__``, ``__delitem__``, ``__iter__``, ``__len__``" msgstr "" "``__getitem__``, ``__setitem__``, ``__delitem__``, ``__iter__``, ``__len__``" -#: library/collections.abc.rst:161 +#: library/collections.abc.rst:162 msgid "" "Inherited :class:`Mapping` methods and ``pop``, ``popitem``, ``clear``, " "``update``, and ``setdefault``" @@ -352,108 +410,113 @@ msgstr "" "Κληρονομημένες :class:`Mapping` μέθοδοι και ``pop``, ``popitem``, ``clear``, " "``update``, και ``setdefault``" -#: library/collections.abc.rst:168 +#: library/collections.abc.rst:169 msgid ":class:`MappingView`" msgstr ":class:`MappingView`" -#: library/collections.abc.rst:168 +#: library/collections.abc.rst:169 msgid ":class:`Sized`" msgstr ":class:`Sized`" #: library/collections.abc.rst:169 +#, fuzzy +msgid "``__init__``, ``__len__`` and ``__repr__``" +msgstr "``__getitem__``, ``__iter__``, ``__len__``" + +#: library/collections.abc.rst:170 msgid ":class:`ItemsView`" msgstr ":class:`ItemsView`" -#: library/collections.abc.rst:169 library/collections.abc.rst:171 +#: library/collections.abc.rst:170 library/collections.abc.rst:172 msgid ":class:`MappingView`, :class:`Set`" msgstr ":class:`MappingView`, :class:`Set`" -#: library/collections.abc.rst:169 library/collections.abc.rst:171 -#: library/collections.abc.rst:173 +#: library/collections.abc.rst:170 library/collections.abc.rst:172 +#: library/collections.abc.rst:174 msgid "``__contains__``, ``__iter__``" msgstr "``__contains__``, ``__iter__``" -#: library/collections.abc.rst:171 +#: library/collections.abc.rst:172 msgid ":class:`KeysView`" msgstr ":class:`KeysView`" -#: library/collections.abc.rst:173 +#: library/collections.abc.rst:174 msgid ":class:`ValuesView`" msgstr ":class:`ValuesView`" -#: library/collections.abc.rst:173 +#: library/collections.abc.rst:174 msgid ":class:`MappingView`, :class:`Collection`" msgstr ":class:`MappingView`, :class:`Collection`" -#: library/collections.abc.rst:175 +#: library/collections.abc.rst:176 msgid ":class:`Awaitable` [1]_" msgstr ":class:`Awaitable` [1]_" -#: library/collections.abc.rst:175 +#: library/collections.abc.rst:176 msgid "``__await__``" msgstr "``__await__``" -#: library/collections.abc.rst:176 +#: library/collections.abc.rst:177 msgid ":class:`Coroutine` [1]_" msgstr ":class:`Coroutine` [1]_" -#: library/collections.abc.rst:176 +#: library/collections.abc.rst:177 msgid ":class:`Awaitable`" msgstr ":class:`Awaitable`" -#: library/collections.abc.rst:176 +#: library/collections.abc.rst:177 msgid "``close``" msgstr "``close``" -#: library/collections.abc.rst:177 +#: library/collections.abc.rst:178 msgid ":class:`AsyncIterable` [1]_" msgstr ":class:`AsyncIterable` [1]_" -#: library/collections.abc.rst:177 library/collections.abc.rst:178 +#: library/collections.abc.rst:178 library/collections.abc.rst:179 msgid "``__aiter__``" msgstr "``__aiter__``" -#: library/collections.abc.rst:178 +#: library/collections.abc.rst:179 msgid ":class:`AsyncIterator` [1]_" msgstr ":class:`AsyncIterator` [1]_" -#: library/collections.abc.rst:178 +#: library/collections.abc.rst:179 msgid ":class:`AsyncIterable`" msgstr ":class:`AsyncIterable`" -#: library/collections.abc.rst:178 +#: library/collections.abc.rst:179 msgid "``__anext__``" msgstr "``__anext__``" -#: library/collections.abc.rst:179 +#: library/collections.abc.rst:180 msgid ":class:`AsyncGenerator` [1]_" msgstr ":class:`AsyncGenerator` [1]_" -#: library/collections.abc.rst:179 +#: library/collections.abc.rst:180 msgid ":class:`AsyncIterator`" msgstr ":class:`AsyncIterator`" -#: library/collections.abc.rst:179 +#: library/collections.abc.rst:180 msgid "``asend``, ``athrow``" msgstr "``asend``, ``athrow``" -#: library/collections.abc.rst:179 +#: library/collections.abc.rst:180 msgid "``aclose``, ``__aiter__``, ``__anext__``" msgstr "``aclose``, ``__aiter__``, ``__anext__``" -#: library/collections.abc.rst:180 +#: library/collections.abc.rst:181 msgid ":class:`Buffer` [1]_" msgstr ":class:`Buffer` [1]_" -#: library/collections.abc.rst:180 +#: library/collections.abc.rst:181 msgid "``__buffer__``" msgstr "``__buffer__``" -#: library/collections.abc.rst:185 +#: library/collections.abc.rst:186 msgid "Footnotes" msgstr "Υποσημειώσεις" -#: library/collections.abc.rst:186 +#: library/collections.abc.rst:187 msgid "" "These ABCs override :meth:`~abc.ABCMeta.__subclasshook__` to support testing " "an interface by verifying the required methods are present and have not been " @@ -462,178 +525,195 @@ msgid "" msgstr "" "Αυτές οι ABCs παρακάμπτουν την μέθοδο :meth:`~abc.ABCMeta.__subclasshook__` " "για να υποστηρίξουν τον έλεγχο μιας διεπαφής μέσω της επαλήθευσης της " -"παρουσίας των απαιτούμενων μεθόδων και του ότι δεν έχουν ρυθμιστεί σε :const:" -"`None`. Αυτό λειτουργεί μόνο για απλές διεπαφές. Πιο σύνθετες διεπαφές " -"απαιτούν εγγραφή ή άμεση υποκλάση." +"παρουσίας των απαιτούμενων μεθόδων και του ότι δεν έχουν ρυθμιστεί " +"σε :const:`None`. Αυτό λειτουργεί μόνο για απλές διεπαφές. Πιο σύνθετες " +"διεπαφές απαιτούν εγγραφή ή άμεση υποκλάση." -#: library/collections.abc.rst:192 +#: library/collections.abc.rst:193 msgid "" "Checking ``isinstance(obj, Iterable)`` detects classes that are registered " "as :class:`Iterable` or that have an :meth:`~container.__iter__` method, but " "it does not detect classes that iterate with the :meth:`~object.__getitem__` " -"method. The only reliable way to determine whether an object is :term:" -"`iterable` is to call ``iter(obj)``." +"method. The only reliable way to determine whether an object " +"is :term:`iterable` is to call ``iter(obj)``." msgstr "" "Ο έλεγχος ``isinstance(obj, Iterable)`` εντοπίζει κλάσεις που είναι " -"καταχωρημένες ως :class:`Iterable` ή που έχουν την μέθοδο :meth:`~container." -"__iter__`, αλλά δεν εντοπίζει τις κλάσεις που πραγματοποιούν επανάληψη με τη " -"μέθοδο :meth:`~object.__getitem__`. Ο μόνος αξιόπιστος τρόπος για να " -"προσδιοριστεί αν ένα αντικείμενο είναι :term:`iterable` είναι να καλέσετε " -"``iter(obj)``." +"καταχωρημένες ως :class:`Iterable` ή που έχουν την " +"μέθοδο :meth:`~container.__iter__`, αλλά δεν εντοπίζει τις κλάσεις που " +"πραγματοποιούν επανάληψη με τη μέθοδο :meth:`~object.__getitem__`. Ο μόνος " +"αξιόπιστος τρόπος για να προσδιοριστεί αν ένα αντικείμενο " +"είναι :term:`iterable` είναι να καλέσετε ``iter(obj)``." -#: library/collections.abc.rst:200 +#: library/collections.abc.rst:201 msgid "Collections Abstract Base Classes -- Detailed Descriptions" msgstr "Αφηρημένες Βασικές Κλάσεις Συλλογών -- Αναλυτικές Περιγραφές" -#: library/collections.abc.rst:205 +#: library/collections.abc.rst:206 msgid "ABC for classes that provide the :meth:`~object.__contains__` method." msgstr "ABC για κλάσεις που παρέχουν την μέθοδο :meth:`~object.__contains__`." -#: library/collections.abc.rst:209 +#: library/collections.abc.rst:210 msgid "ABC for classes that provide the :meth:`~object.__hash__` method." msgstr "ABC για κλάσεις που παρέχουν την μέθοδο :meth:`~object.__hash__`." -#: library/collections.abc.rst:213 +#: library/collections.abc.rst:214 msgid "ABC for classes that provide the :meth:`~object.__len__` method." msgstr "ABC για κλάσεις που παρέχουν την μέθοδο :meth:`~object.__len__`." -#: library/collections.abc.rst:217 +#: library/collections.abc.rst:218 msgid "ABC for classes that provide the :meth:`~object.__call__` method." msgstr "ABC για κλάσεις που παρέχουν την μέθοδο :meth:`~object.__call__`." -#: library/collections.abc.rst:221 +#: library/collections.abc.rst:220 +msgid "" +"See :ref:`annotating-callables` for details on how to use :class:`!Callable` " +"in type annotations." +msgstr "" + +#: library/collections.abc.rst:225 msgid "ABC for classes that provide the :meth:`~container.__iter__` method." msgstr "ABC για κλάσεις που παρέχουν την μέθοδο :meth:`~container.__iter__`." -#: library/collections.abc.rst:223 +#: library/collections.abc.rst:227 msgid "" "Checking ``isinstance(obj, Iterable)`` detects classes that are registered " "as :class:`Iterable` or that have an :meth:`~container.__iter__` method, but " "it does not detect classes that iterate with the :meth:`~object.__getitem__` " -"method. The only reliable way to determine whether an object is :term:" -"`iterable` is to call ``iter(obj)``." +"method. The only reliable way to determine whether an object " +"is :term:`iterable` is to call ``iter(obj)``." msgstr "" "Ο έλεγχος ``isinstance(obj, Iterable)`` εντοπίζει κλάσεις που είναι " -"καταχωρημένες ως :class:`Iterable` ή που διαθέτουν τη μέθοδο :meth:" -"`~container.__iter__`, αλλά δεν εντοπίζει κλάσεις που πραγματοποιούν " -"επανάληψη με τη μέθοδο :meth:`~object.__getitem__`. Ο μόνος αξιόπιστος " -"τρόπος για να προσδιοριστεί αν ένα αντικείμενο είναι :term:`iterable` είναι " -"να κληθεί ``iter(obj)``." +"καταχωρημένες ως :class:`Iterable` ή που διαθέτουν τη " +"μέθοδο :meth:`~container.__iter__`, αλλά δεν εντοπίζει κλάσεις που " +"πραγματοποιούν επανάληψη με τη μέθοδο :meth:`~object.__getitem__`. Ο μόνος " +"αξιόπιστος τρόπος για να προσδιοριστεί αν ένα αντικείμενο " +"είναι :term:`iterable` είναι να κληθεί ``iter(obj)``." -#: library/collections.abc.rst:232 +#: library/collections.abc.rst:236 msgid "ABC for sized iterable container classes." msgstr "ABC για τις κλάσεις επαναλαμβανόμενων container με μέγεθος." -#: library/collections.abc.rst:238 +#: library/collections.abc.rst:242 msgid "" -"ABC for classes that provide the :meth:`~iterator.__iter__` and :meth:" -"`~iterator.__next__` methods. See also the definition of :term:`iterator`." +"ABC for classes that provide the :meth:`~iterator.__iter__` " +"and :meth:`~iterator.__next__` methods. See also the definition " +"of :term:`iterator`." msgstr "" -"ABC για κλάσεις που παρέχουν τις μεθόδους :meth:`~iterator.__iter__` και :" -"meth:`~iterator.__next__`. Δείτε επίσης τον ορισμό του :term:`iterator`." +"ABC για κλάσεις που παρέχουν τις μεθόδους :meth:`~iterator.__iter__` " +"και :meth:`~iterator.__next__`. Δείτε επίσης τον ορισμό του :term:`iterator`." -#: library/collections.abc.rst:244 +#: library/collections.abc.rst:248 msgid "" "ABC for iterable classes that also provide the :meth:`~object.__reversed__` " "method." msgstr "" -"ABC για τις επαναλαμβανόμενες κλάσεις που παρέχουν επίσης τη μέθοδο :meth:" -"`~object.__reversed__`" +"ABC για τις επαναλαμβανόμενες κλάσεις που παρέχουν επίσης τη " +"μέθοδο :meth:`~object.__reversed__`" -#: library/collections.abc.rst:251 +#: library/collections.abc.rst:255 msgid "" -"ABC for :term:`generator` classes that implement the protocol defined in :" -"pep:`342` that extends :term:`iterators ` with the :meth:" -"`~generator.send`, :meth:`~generator.throw` and :meth:`~generator.close` " -"methods." +"ABC for :term:`generator` classes that implement the protocol defined " +"in :pep:`342` that extends :term:`iterators ` with " +"the :meth:`~generator.send`, :meth:`~generator.throw` " +"and :meth:`~generator.close` methods." msgstr "" "ABC για τις κλάσεις :term:`generator` που υλοποιούν το πρωτόκολλο που " "ορίζεται στο :pep:`342` το οποίο επεκτείνει τους :term:`iterators " -"` με τις μεθόδους :meth:`~generator.send`, :meth:`~generator." -"throw` και :meth:`~generator.close`." +"` με τις " +"μεθόδους :meth:`~generator.send`, :meth:`~generator.throw` " +"και :meth:`~generator.close`." -#: library/collections.abc.rst:262 +#: library/collections.abc.rst:260 +msgid "" +"See :ref:`annotating-generators-and-coroutines` for details on " +"using :class:`!Generator` in type annotations." +msgstr "" + +#: library/collections.abc.rst:269 msgid "ABCs for read-only and mutable :term:`sequences `." msgstr "" "ABCs μόνο για ανάγνωση (read-only) και mutable :term:`sequences `." -#: library/collections.abc.rst:264 +#: library/collections.abc.rst:271 msgid "" -"Implementation note: Some of the mixin methods, such as :meth:`~container." -"__iter__`, :meth:`~object.__reversed__` and :meth:`index`, make repeated " -"calls to the underlying :meth:`~object.__getitem__` method. Consequently, " +"Implementation note: Some of the mixin methods, such " +"as :meth:`~container.__iter__`, :meth:`~object.__reversed__` " +"and :meth:`index`, make repeated calls to the " +"underlying :meth:`~object.__getitem__` method. Consequently, " "if :meth:`~object.__getitem__` is implemented with constant access speed, " "the mixin methods will have linear performance; however, if the underlying " "method is linear (as it would be with a linked list), the mixins will have " "quadratic performance and will likely need to be overridden." msgstr "" -"Σημείωση υλοποίησης: Μερικές από τις μεθόδους mixin, όπως :meth:`~cotnainer." -"__iter__`, :meth:`~object.__reversed__` και :meth`index`, κάνουν " -"επανειλημμένες κλήσεις στην μέθοδο :meth:`~object.__getitem__`. Ως " -"αποτέλεσμα, αν η :meth:`~object.__getitem__` είναι υλοποιημένη με σταθερή " -"ταχύτητα πρόσβασης, οι μέθοδοι mixin θα έχουν γραμμική απόδοση. Ωστόσο, αν η " +"Σημείωση υλοποίησης: Μερικές από τις μεθόδους mixin, " +"όπως :meth:`~cotnainer.__iter__`, :meth:`~object.__reversed__` " +"και :meth`index`, κάνουν επανειλημμένες κλήσεις στην " +"μέθοδο :meth:`~object.__getitem__`. Ως αποτέλεσμα, αν " +"η :meth:`~object.__getitem__` είναι υλοποιημένη με σταθερή ταχύτητα " +"πρόσβασης, οι μέθοδοι mixin θα έχουν γραμμική απόδοση. Ωστόσο, αν η " "υποκείμενη μέθοδος είναι γραμμική (όπως θα ήταν με μια συνδεδεμένη λίστα), " "οι mixins θα έχουν τετραγωνική απόδοση και πιθανώς θα χρειαστεί να " "αντικατασταθούν." -#: library/collections.abc.rst:273 +#: library/collections.abc.rst:280 msgid "The index() method added support for *stop* and *start* arguments." msgstr "" "Η μέθοδος index() πρόσθεσε υποστήριξη για τα ορίσματα *stop* και *start*." -#: library/collections.abc.rst:281 +#: library/collections.abc.rst:284 msgid "" "The :class:`ByteString` ABC has been deprecated. For use in typing, prefer a " "union, like ``bytes | bytearray``, or :class:`collections.abc.Buffer`. For " "use as an ABC, prefer :class:`Sequence` or :class:`collections.abc.Buffer`." msgstr "" "Η ABC :class:`ByteString` έχει αποσυρθεί. Για χρήση στην δακτυλογράφηση, " -"προτιμάται ένωση, όπως ``bytes | bytearray``, ή :class:`collections.abc." -"Buffer`. Για χρήση ως ABC, προτιμάται :class:`Sequence` ή :class:" -"`collections.abc.Buffer`." +"προτιμάται ένωση, όπως ``bytes | bytearray``, " +"ή :class:`collections.abc.Buffer`. Για χρήση ως ABC, " +"προτιμάται :class:`Sequence` ή :class:`collections.abc.Buffer`." -#: library/collections.abc.rst:286 +#: library/collections.abc.rst:293 msgid "ABCs for read-only and mutable :ref:`sets `." msgstr "" "ABCs μόνο για ανάγνωση (read-only) και mutable :ref:`sets `." -#: library/collections.abc.rst:291 +#: library/collections.abc.rst:298 msgid "ABCs for read-only and mutable :term:`mappings `." msgstr "" "ABCs μόνο για ανάγνωση (read-only) και mutable :term:`mappings `." -#: library/collections.abc.rst:298 +#: library/collections.abc.rst:305 msgid "" "ABCs for mapping, items, keys, and values :term:`views `." msgstr "" "ABCs για αντιστοιχήσεις, στοιχεία, κλειδιά και τιμές :term:`views " "`." -#: library/collections.abc.rst:302 +#: library/collections.abc.rst:309 msgid "" "ABC for :term:`awaitable` objects, which can be used in :keyword:`await` " -"expressions. Custom implementations must provide the :meth:`~object." -"__await__` method." +"expressions. Custom implementations must provide " +"the :meth:`~object.__await__` method." msgstr "" "ABC για αντικείμενα :term:`awaitable`, που μπορούν να χρησιμοποιηθούν σε " "εκφράσεις :keyword:`await`. Οι προσαρμοσμένες υλοποιήσεις πρέπει να παρέχουν " "τη μέθοδο :meth:`~object.__await__`." -#: library/collections.abc.rst:306 +#: library/collections.abc.rst:313 msgid "" -":term:`Coroutine ` objects and instances of the :class:" -"`~collections.abc.Coroutine` ABC are all instances of this ABC." +":term:`Coroutine ` objects and instances of " +"the :class:`~collections.abc.Coroutine` ABC are all instances of this ABC." msgstr "" -"Τα αντικείμενα :term:`Coroutine ` και τα στιγμιότυπα της κλάσης :" -"class:`~collections.abc.Coroutine` είναι όλα παραδείγματα αυτής της ABC." +"Τα αντικείμενα :term:`Coroutine ` και τα στιγμιότυπα της " +"κλάσης :class:`~collections.abc.Coroutine` είναι όλα παραδείγματα αυτής της " +"ABC." -#: library/collections.abc.rst:310 +#: library/collections.abc.rst:317 msgid "" "In CPython, generator-based coroutines (:term:`generators ` " "decorated with :func:`@types.coroutine `) are *awaitables*, " "even though they do not have an :meth:`~object.__await__` method. Using " -"``isinstance(gencoro, Awaitable)`` for them will return ``False``. Use :func:" -"`inspect.isawaitable` to detect them." +"``isinstance(gencoro, Awaitable)`` for them will return ``False``. " +"Use :func:`inspect.isawaitable` to detect them." msgstr "" "Στην CPython, οι generator-based coroutines (:term:`generators ` " "που είναι decorated με :func:`@types.coroutine `) είναι " @@ -642,28 +722,29 @@ msgstr "" "Χρησιμοποιείτε τη συνάρτηση :func:`inspect.isawaitable` για να τις " "εντοπίσετε." -#: library/collections.abc.rst:320 +#: library/collections.abc.rst:327 msgid "" "ABC for :term:`coroutine` compatible classes. These implement the following " -"methods, defined in :ref:`coroutine-objects`: :meth:`~coroutine.send`, :meth:" -"`~coroutine.throw`, and :meth:`~coroutine.close`. Custom implementations " -"must also implement :meth:`~object.__await__`. All :class:`Coroutine` " -"instances are also instances of :class:`Awaitable`." +"methods, defined in :ref:`coroutine-" +"objects`: :meth:`~coroutine.send`, :meth:`~coroutine.throw`, " +"and :meth:`~coroutine.close`. Custom implementations must also " +"implement :meth:`~object.__await__`. All :class:`Coroutine` instances are " +"also instances of :class:`Awaitable`." msgstr "" "ABC για κλάσεις συμβατές με το :term:`coroutine`. Αυτές υλοποιούν τις εξής " -"μεθόδους, οι οποίες ορίζονται στο :ref:`coroutine-objects`: :meth:" -"`~coroutine.send`, :meth:`~coroutine.throw`, και :meth:`~coroutine.close`. " -"Οι προσαρμοσμένες υλοποιήσεις πρέπει επίσης να υλοποιούν τη μέθοδο :meth:" -"`~object.__await__`. Όλα τα :class:`Coroutine` στιγμιότυπα είναι επίσης " -"στιγμιότυπα της κλάσης :class:`Awaitable`." +"μεθόδους, οι οποίες ορίζονται στο :ref:`coroutine-" +"objects`: :meth:`~coroutine.send`, :meth:`~coroutine.throw`, " +"και :meth:`~coroutine.close`. Οι προσαρμοσμένες υλοποιήσεις πρέπει επίσης να " +"υλοποιούν τη μέθοδο :meth:`~object.__await__`. Όλα τα :class:`Coroutine` " +"στιγμιότυπα είναι επίσης στιγμιότυπα της κλάσης :class:`Awaitable`." -#: library/collections.abc.rst:328 +#: library/collections.abc.rst:335 msgid "" "In CPython, generator-based coroutines (:term:`generators ` " "decorated with :func:`@types.coroutine `) are *awaitables*, " "even though they do not have an :meth:`~object.__await__` method. Using " -"``isinstance(gencoro, Coroutine)`` for them will return ``False``. Use :func:" -"`inspect.isawaitable` to detect them." +"``isinstance(gencoro, Coroutine)`` for them will return ``False``. " +"Use :func:`inspect.isawaitable` to detect them." msgstr "" "Στην CPython, οι generator-based coroutines (:term:`generators ` " "που είναι διακοσμημένες με :func:`@types.coroutine `) είναι " @@ -671,7 +752,14 @@ msgstr "" "της ``isinstance (gencoro, Coroutine)`` γι' αυτές θα επιστρέψει ``False``. " "Χρησιμοποιείται η συνάρτηση :func:`inspect.isawaitable` για να εντοπιστούν." -#: library/collections.abc.rst:338 +#: library/collections.abc.rst:341 +msgid "" +"See :ref:`annotating-generators-and-coroutines` for details on " +"using :class:`!Coroutine` in type annotations. The variance and order of " +"type parameters correspond to those of :class:`Generator`." +msgstr "" + +#: library/collections.abc.rst:350 msgid "" "ABC for classes that provide an ``__aiter__`` method. See also the " "definition of :term:`asynchronous iterable`." @@ -679,7 +767,7 @@ msgstr "" "ABC για κλάσεις που παρέχουν μια μέθοδο ``__aiter__``. Δείτε επίσης τον " "ορισμό του :term:`asynchronous iterable`." -#: library/collections.abc.rst:345 +#: library/collections.abc.rst:357 msgid "" "ABC for classes that provide ``__aiter__`` and ``__anext__`` methods. See " "also the definition of :term:`asynchronous iterator`." @@ -687,7 +775,7 @@ msgstr "" "ABC για κλάσεις που παρέχουν τις μεθόδους ``__aiter__`` και ``__anext__``. " "Δείτε επίσης τον ορισμό του :term:`asynchronous iterator`." -#: library/collections.abc.rst:352 +#: library/collections.abc.rst:364 msgid "" "ABC for :term:`asynchronous generator` classes that implement the protocol " "defined in :pep:`525` and :pep:`492`." @@ -695,7 +783,13 @@ msgstr "" "ABC για κλάσεις :term:`asynchronous generator` που υλοποιούν το πρωτόκολλο " "που ορίζεται στο :pep:`525` και :pep:`492`." -#: library/collections.abc.rst:359 +#: library/collections.abc.rst:367 +msgid "" +"See :ref:`annotating-generators-and-coroutines` for details on " +"using :class:`!AsyncGenerator` in type annotations." +msgstr "" + +#: library/collections.abc.rst:374 msgid "" "ABC for classes that provide the :meth:`~object.__buffer__` method, " "implementing the :ref:`buffer protocol `. See :pep:`688`." @@ -703,11 +797,11 @@ msgstr "" "ABC για κλάσεις που παρέχουν τη μέθοδο :meth:`~object.__buffer__`, " "υλοποιώντας το :ref:`buffer protocol `. Δείτε το :pep:`688`." -#: library/collections.abc.rst:365 +#: library/collections.abc.rst:380 msgid "Examples and Recipes" msgstr "Παραδείγματα και Συνταγές" -#: library/collections.abc.rst:367 +#: library/collections.abc.rst:382 msgid "" "ABCs allow us to ask classes or instances if they provide particular " "functionality, for example::" @@ -715,63 +809,97 @@ msgstr "" "Οι ABCs επιτρέπουν να ρωτήσουμε τις κλάσεις ή τα αντικείμενα αν παρέχουν " "συγκεκριμένη λειτουργικότητα, για παράδειγμα::" -#: library/collections.abc.rst:374 +#: library/collections.abc.rst:385 +msgid "" +"size = None\n" +"if isinstance(myvar, collections.abc.Sized):\n" +" size = len(myvar)" +msgstr "" + +#: library/collections.abc.rst:389 msgid "" "Several of the ABCs are also useful as mixins that make it easier to develop " "classes supporting container APIs. For example, to write a class supporting " "the full :class:`Set` API, it is only necessary to supply the three " -"underlying abstract methods: :meth:`~object.__contains__`, :meth:`~container." -"__iter__`, and :meth:`~object.__len__`. The ABC supplies the remaining " -"methods such as :meth:`!__and__` and :meth:`~frozenset.isdisjoint`::" +"underlying abstract " +"methods: :meth:`~object.__contains__`, :meth:`~container.__iter__`, " +"and :meth:`~object.__len__`. The ABC supplies the remaining methods such " +"as :meth:`!__and__` and :meth:`~frozenset.isdisjoint`::" msgstr "" "Μερικές από τις ABCs είναι επίσης χρήσιμες ως mixins που διευκολύνουν την " "ανάπτυξη κλάσεων που υποστηρίζουν τα APIs των container. Για παράδειγμα, για " "να γράψετε μια κλάση που υποστηρίζει το πλήρες API του :class:`Set`, αρκεί " -"να παρέχετε τις τρεις υποκείμενες αφηρημένες μεθόδους: :meth:`~object." -"__contains__`, :meth:`~container.__iter__`, και :meth:`~object.__len__`. Η " -"ABC παρέχει τις υπόλοιπες μεθόδους, όπως :meth:`!__and__` και :meth:" -"`~frozenset.isdisjoint`::" - -#: library/collections.abc.rst:403 +"να παρέχετε τις τρεις υποκείμενες αφηρημένες " +"μεθόδους: :meth:`~object.__contains__`, :meth:`~container.__iter__`, " +"και :meth:`~object.__len__`. Η ABC παρέχει τις υπόλοιπες μεθόδους, " +"όπως :meth:`!__and__` και :meth:`~frozenset.isdisjoint`::" + +#: library/collections.abc.rst:396 +msgid "" +"class ListBasedSet(collections.abc.Set):\n" +" ''' Alternate set implementation favoring space over speed\n" +" and not requiring the set elements to be hashable. '''\n" +" def __init__(self, iterable):\n" +" self.elements = lst = []\n" +" for value in iterable:\n" +" if value not in lst:\n" +" lst.append(value)\n" +"\n" +" def __iter__(self):\n" +" return iter(self.elements)\n" +"\n" +" def __contains__(self, value):\n" +" return value in self.elements\n" +"\n" +" def __len__(self):\n" +" return len(self.elements)\n" +"\n" +"s1 = ListBasedSet('abcdef')\n" +"s2 = ListBasedSet('defghi')\n" +"overlap = s1 & s2 # The __and__() method is supported " +"automatically" +msgstr "" + +#: library/collections.abc.rst:418 msgid "Notes on using :class:`Set` and :class:`MutableSet` as a mixin:" msgstr "" "Σημειώσεις για τη χρήση των :class:`Set` και :class:`MutableSet` ως mixin:" -#: library/collections.abc.rst:406 +#: library/collections.abc.rst:421 msgid "" "Since some set operations create new sets, the default mixin methods need a " "way to create new instances from an :term:`iterable`. The class constructor " "is assumed to have a signature in the form ``ClassName(iterable)``. That " -"assumption is factored-out to an internal :class:`classmethod` called :meth:" -"`!_from_iterable` which calls ``cls(iterable)`` to produce a new set. If " -"the :class:`Set` mixin is being used in a class with a different constructor " -"signature, you will need to override :meth:`!_from_iterable` with a " -"classmethod or regular method that can construct new instances from an " -"iterable argument." +"assumption is factored-out to an internal :class:`classmethod` " +"called :meth:`!_from_iterable` which calls ``cls(iterable)`` to produce a " +"new set. If the :class:`Set` mixin is being used in a class with a different " +"constructor signature, you will need to override :meth:`!_from_iterable` " +"with a classmethod or regular method that can construct new instances from " +"an iterable argument." msgstr "" "Δεδομένου ότι ορισμένες λειτουργίες συνόλων δημιουργούν νέα σύνολα, οι " "προεπιλεγμένες μέθοδοι mixin χρειάζονται έναν τρόπο δημιουργίας νέων " "αντικειμένων από ένα :term:`iterable`. Υποτίθεται ότι ο κατασκευαστής της " "κλάσης έχει μια υπογραφή της μορφής ``ClassName(iterable)``. Αυτή η υπόθεση " -"είναι αποσυνδεδεμένη σε μια εσωτερική :class:`classmethod` που ονομάζεται :" -"meth:`!_from_iterable`, η οποία καλεί το ``cls(iterable)`` για να " -"δημιουργήσει ένα νέο σύνολο. Εάν το mixin :class:`Set` χρησιμοποιείται σε " +"είναι αποσυνδεδεμένη σε μια εσωτερική :class:`classmethod` που " +"ονομάζεται :meth:`!_from_iterable`, η οποία καλεί το ``cls(iterable)`` για " +"να δημιουργήσει ένα νέο σύνολο. Εάν το mixin :class:`Set` χρησιμοποιείται σε " "μια κλάση με διαφορετική υπογραφή κατασκευαστή, θα χρειαστεί να " "αντικαταστήσετε την :meth:`!_from_iterable` με μια μέθοδο κλάσης ή κανονική " "μέθοδο που μπορεί να δημιουργήσει νέα αντικείμενα από ένα όρισμα iterable." -#: library/collections.abc.rst:417 +#: library/collections.abc.rst:432 msgid "" "To override the comparisons (presumably for speed, as the semantics are " "fixed), redefine :meth:`~object.__le__` and :meth:`~object.__ge__`, then the " "other operations will automatically follow suit." msgstr "" "Για να παρακάμψετε τις συγκρίσεις (πιθανότατα για λόγους απόδοσης, καθώς η " -"σημασιολογία είναι καθορισμένη), ορίστε ξανά τις μεθόδους :meth:`~object." -"__le__`, και :meth:`~object.__ge__`, και οι άλλες λειτουργίες θα " -"ακολουθήσουν αυτόματα." +"σημασιολογία είναι καθορισμένη), ορίστε ξανά τις " +"μεθόδους :meth:`~object.__le__`, και :meth:`~object.__ge__`, και οι άλλες " +"λειτουργίες θα ακολουθήσουν αυτόματα." -#: library/collections.abc.rst:423 +#: library/collections.abc.rst:438 msgid "" "The :class:`Set` mixin provides a :meth:`!_hash` method to compute a hash " "value for the set; however, :meth:`~object.__hash__` is not defined because " @@ -780,13 +908,13 @@ msgid "" "define ``__hash__ = Set._hash``." msgstr "" "Το mixin :class:`Set` παρέχει τη μέθοδο meth:`!_hash` για να υπολογίσει μια " -"τιμή κατακερματισμού για το σύνολο. Ωστόσο, η μέθοδος :meth:`~object." -"__hash__` δεν είναι ορισμένη, επειδή δεν είναι όλα τα σύνολα :term:" -"`hashable` ή αμετάβλητα. Για να προσθέσετε hashability σε ένα σύνολο " -"χρησιμοποιώντας mixins, κληρονομήστε τόσο από τις κλάσεις :meth:`Set` όσο " -"και :meth:`Hashable`, και στη συνέχεια ορίστε ``__hash__ = Set._hash``." +"τιμή κατακερματισμού για το σύνολο. Ωστόσο, η " +"μέθοδος :meth:`~object.__hash__` δεν είναι ορισμένη, επειδή δεν είναι όλα τα " +"σύνολα :term:`hashable` ή αμετάβλητα. Για να προσθέσετε hashability σε ένα " +"σύνολο χρησιμοποιώντας mixins, κληρονομήστε τόσο από τις κλάσεις :meth:`Set` " +"όσο και :meth:`Hashable`, και στη συνέχεια ορίστε ``__hash__ = Set._hash``." -#: library/collections.abc.rst:431 +#: library/collections.abc.rst:446 msgid "" "`OrderedSet recipe `_ for an " "example built on :class:`MutableSet`." @@ -794,8 +922,8 @@ msgstr "" "Συνταγή `OrderedSet `_ για ένα " "παράδειγμα που βασίζεται στην κλάση :class:`MutableSet`." -#: library/collections.abc.rst:434 +#: library/collections.abc.rst:449 msgid "For more about ABCs, see the :mod:`abc` module and :pep:`3119`." msgstr "" -"Για περισσότερα σχετικά με τις ABCs, δείτε το :mod:`abc` module και το :pep:" -"`3119`." +"Για περισσότερα σχετικά με τις ABCs, δείτε το :mod:`abc` module και " +"το :pep:`3119`." diff --git a/library/collections.po b/library/collections.po index d76a298b..5f5febc9 100644 --- a/library/collections.po +++ b/library/collections.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/collections.rst:2 -msgid ":mod:`collections` --- Container datatypes" +msgid ":mod:`!collections` --- Container datatypes" msgstr "" #: library/collections.rst:10 @@ -27,8 +28,8 @@ msgstr "" #: library/collections.rst:20 msgid "" "This module implements specialized container datatypes providing " -"alternatives to Python's general purpose built-in containers, :class:" -"`dict`, :class:`list`, :class:`set`, and :class:`tuple`." +"alternatives to Python's general purpose built-in " +"containers, :class:`dict`, :class:`list`, :class:`set`, and :class:`tuple`." msgstr "" #: library/collections.rst:25 @@ -186,24 +187,41 @@ msgstr "" msgid "" "Property returning a new :class:`ChainMap` containing all of the maps in the " "current instance except the first one. This is useful for skipping the " -"first map in the search. Use cases are similar to those for the :keyword:" -"`nonlocal` keyword used in :term:`nested scopes `. The use " -"cases also parallel those for the built-in :func:`super` function. A " -"reference to ``d.parents`` is equivalent to: ``ChainMap(*d.maps[1:])``." +"first map in the search. Use cases are similar to those for " +"the :keyword:`nonlocal` keyword used in :term:`nested scopes `. The use cases also parallel those for the built-in :func:`super` " +"function. A reference to ``d.parents`` is equivalent to: " +"``ChainMap(*d.maps[1:])``." msgstr "" #: library/collections.rst:102 msgid "" -"Note, the iteration order of a :class:`ChainMap()` is determined by scanning " +"Note, the iteration order of a :class:`ChainMap` is determined by scanning " "the mappings last to first::" msgstr "" +#: library/collections.rst:105 +msgid "" +">>> baseline = {'music': 'bach', 'art': 'rembrandt'}\n" +">>> adjustments = {'art': 'van gogh', 'opera': 'carmen'}\n" +">>> list(ChainMap(adjustments, baseline))\n" +"['music', 'art', 'opera']" +msgstr "" + #: library/collections.rst:110 msgid "" "This gives the same ordering as a series of :meth:`dict.update` calls " "starting with the last mapping::" msgstr "" +#: library/collections.rst:113 +msgid "" +">>> combined = baseline.copy()\n" +">>> combined.update(adjustments)\n" +">>> list(combined)\n" +"['music', 'art', 'opera']" +msgstr "" + #: library/collections.rst:118 msgid "Added support for ``|`` and ``|=`` operators, specified in :pep:`584`." msgstr "" @@ -220,22 +238,23 @@ msgstr "" msgid "" "Django's `Context class `_ for templating is a read-only chain of mappings. It " -"also features pushing and popping of contexts similar to the :meth:" -"`~collections.ChainMap.new_child` method and the :attr:`~collections." -"ChainMap.parents` property." +"also features pushing and popping of contexts similar to " +"the :meth:`~collections.ChainMap.new_child` method and " +"the :attr:`~collections.ChainMap.parents` property." msgstr "" #: library/collections.rst:136 msgid "" -"The `Nested Contexts recipe `_ " -"has options to control whether writes and other mutations apply only to the " -"first mapping or to any mapping in the chain." +"The `Nested Contexts recipe `_ has options to control " +"whether writes and other mutations apply only to the first mapping or to any " +"mapping in the chain." msgstr "" #: library/collections.rst:141 msgid "" -"A `greatly simplified read-only version of Chainmap `_." +"A `greatly simplified read-only version of Chainmap `_." msgstr "" #: library/collections.rst:146 @@ -250,6 +269,12 @@ msgstr "" msgid "Example of simulating Python's internal lookup chain::" msgstr "" +#: library/collections.rst:153 +msgid "" +"import builtins\n" +"pylookup = ChainMap(locals(), globals(), vars(builtins))" +msgstr "" + #: library/collections.rst:156 msgid "" "Example of letting user specified command-line arguments take precedence " @@ -257,12 +282,50 @@ msgid "" "values::" msgstr "" +#: library/collections.rst:159 +msgid "" +"import os, argparse\n" +"\n" +"defaults = {'color': 'red', 'user': 'guest'}\n" +"\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument('-u', '--user')\n" +"parser.add_argument('-c', '--color')\n" +"namespace = parser.parse_args()\n" +"command_line_args = {k: v for k, v in vars(namespace).items() if v is not " +"None}\n" +"\n" +"combined = ChainMap(command_line_args, os.environ, defaults)\n" +"print(combined['color'])\n" +"print(combined['user'])" +msgstr "" + #: library/collections.rst:173 msgid "" "Example patterns for using the :class:`ChainMap` class to simulate nested " "contexts::" msgstr "" +#: library/collections.rst:176 +msgid "" +"c = ChainMap() # Create root context\n" +"d = c.new_child() # Create nested child context\n" +"e = c.new_child() # Child of c, independent from d\n" +"e.maps[0] # Current context dictionary -- like Python's " +"locals()\n" +"e.maps[-1] # Root context -- like Python's globals()\n" +"e.parents # Enclosing context chain -- like Python's nonlocals\n" +"\n" +"d['x'] = 1 # Set value in current context\n" +"d['x'] # Get first key in the chain of contexts\n" +"del d['x'] # Delete from current context\n" +"list(d) # All nested values\n" +"k in d # Check all nested values\n" +"len(d) # Number of nested values\n" +"d.items() # All nested items\n" +"dict(d) # Flatten into a regular dictionary" +msgstr "" + #: library/collections.rst:192 msgid "" "The :class:`ChainMap` class only makes updates (writes and deletions) to the " @@ -271,6 +334,34 @@ msgid "" "subclass that updates keys found deeper in the chain::" msgstr "" +#: library/collections.rst:197 +msgid "" +"class DeepChainMap(ChainMap):\n" +" 'Variant of ChainMap that allows direct updates to inner scopes'\n" +"\n" +" def __setitem__(self, key, value):\n" +" for mapping in self.maps:\n" +" if key in mapping:\n" +" mapping[key] = value\n" +" return\n" +" self.maps[0][key] = value\n" +"\n" +" def __delitem__(self, key):\n" +" for mapping in self.maps:\n" +" if key in mapping:\n" +" del mapping[key]\n" +" return\n" +" raise KeyError(key)\n" +"\n" +">>> d = DeepChainMap({'zebra': 'black'}, {'elephant': 'blue'}, {'lion': " +"'yellow'})\n" +">>> d['lion'] = 'orange' # update an existing key two levels down\n" +">>> d['snake'] = 'red' # new keys get added to the topmost dict\n" +">>> del d['elephant'] # remove an existing key one level down\n" +">>> d # display result\n" +"DeepChainMap({'zebra': 'black', 'snake': 'red'}, {}, {'lion': 'orange'})" +msgstr "" + #: library/collections.rst:223 msgid ":class:`Counter` objects" msgstr "" @@ -281,6 +372,24 @@ msgid "" "example::" msgstr "" +#: library/collections.rst:228 +msgid "" +">>> # Tally occurrences of words in a list\n" +">>> cnt = Counter()\n" +">>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:\n" +"... cnt[word] += 1\n" +"...\n" +">>> cnt\n" +"Counter({'blue': 3, 'red': 2, 'green': 1})\n" +"\n" +">>> # Find the ten most common words in Hamlet\n" +">>> import re\n" +">>> words = re.findall(r'\\w+', open('hamlet.txt').read().lower())\n" +">>> Counter(words).most_common(10)\n" +"[('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631),\n" +" ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)]" +msgstr "" + #: library/collections.rst:245 msgid "" "A :class:`Counter` is a :class:`dict` subclass for counting :term:`hashable` " @@ -390,6 +499,19 @@ msgstr "" msgid "Common patterns for working with :class:`Counter` objects::" msgstr "" +#: library/collections.rst:356 +msgid "" +"c.total() # total of all counts\n" +"c.clear() # reset all counts\n" +"list(c) # list unique elements\n" +"set(c) # convert to a set\n" +"dict(c) # convert to a regular dictionary\n" +"c.items() # convert to a list of (elem, cnt) pairs\n" +"Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs\n" +"c.most_common()[:-n-1:-1] # n least common elements\n" +"+c # remove zero and negative counts" +msgstr "" + #: library/collections.rst:366 msgid "" "Several mathematical operations are provided for combining :class:`Counter` " @@ -401,6 +523,24 @@ msgid "" "but the output will exclude results with counts of zero or less." msgstr "" +#: library/collections.rst:374 +msgid "" +">>> c = Counter(a=3, b=1)\n" +">>> d = Counter(a=1, b=2)\n" +">>> c + d # add two counters together: c[x] + d[x]\n" +"Counter({'a': 4, 'b': 3})\n" +">>> c - d # subtract (keeping only positive counts)\n" +"Counter({'a': 2})\n" +">>> c & d # intersection: min(c[x], d[x])\n" +"Counter({'a': 1, 'b': 1})\n" +">>> c | d # union: max(c[x], d[x])\n" +"Counter({'a': 3, 'b': 2})\n" +">>> c == d # equality: c[x] == d[x]\n" +"False\n" +">>> c <= d # inclusion: c[x] <= d[x]\n" +"False" +msgstr "" + #: library/collections.rst:391 msgid "" "Unary addition and subtraction are shortcuts for adding an empty counter or " @@ -437,9 +577,9 @@ msgstr "" msgid "" "For in-place operations such as ``c[key] += 1``, the value type need only " "support addition and subtraction. So fractions, floats, and decimals would " -"work and negative values are supported. The same is also true for :meth:" -"`~Counter.update` and :meth:`~Counter.subtract` which allow negative and " -"zero values for both inputs and outputs." +"work and negative values are supported. The same is also true " +"for :meth:`~Counter.update` and :meth:`~Counter.subtract` which allow " +"negative and zero values for both inputs and outputs." msgstr "" #: library/collections.rst:422 @@ -458,8 +598,8 @@ msgstr "" #: library/collections.rst:432 msgid "" -"`Bag class `_ in Smalltalk." +"`Bag class `_ in Smalltalk." msgstr "" #: library/collections.rst:435 @@ -486,6 +626,11 @@ msgid "" "elements, see :func:`itertools.combinations_with_replacement`::" msgstr "" +#: library/collections.rst:447 +msgid "" +"map(Counter, combinations_with_replacement('ABC', 2)) # --> AA AB AC BB BC CC" +msgstr "" + #: library/collections.rst:451 msgid ":class:`deque` objects" msgstr "" @@ -574,8 +719,8 @@ msgstr "" #: library/collections.rst:535 msgid "" -"If the insertion would cause a bounded deque to grow beyond *maxlen*, an :" -"exc:`IndexError` is raised." +"If the insertion would cause a bounded deque to grow beyond *maxlen*, " +"an :exc:`IndexError` is raised." msgstr "" #: library/collections.rst:543 @@ -592,8 +737,8 @@ msgstr "" #: library/collections.rst:555 msgid "" -"Remove the first occurrence of *value*. If not found, raises a :exc:" -"`ValueError`." +"Remove the first occurrence of *value*. If not found, raises " +"a :exc:`ValueError`." msgstr "" #: library/collections.rst:561 @@ -641,6 +786,62 @@ msgstr "" msgid "Example:" msgstr "" +#: library/collections.rst:596 +msgid "" +">>> from collections import deque\n" +">>> d = deque('ghi') # make a new deque with three items\n" +">>> for elem in d: # iterate over the deque's elements\n" +"... print(elem.upper())\n" +"G\n" +"H\n" +"I\n" +"\n" +">>> d.append('j') # add a new entry to the right side\n" +">>> d.appendleft('f') # add a new entry to the left side\n" +">>> d # show the representation of the deque\n" +"deque(['f', 'g', 'h', 'i', 'j'])\n" +"\n" +">>> d.pop() # return and remove the rightmost item\n" +"'j'\n" +">>> d.popleft() # return and remove the leftmost item\n" +"'f'\n" +">>> list(d) # list the contents of the deque\n" +"['g', 'h', 'i']\n" +">>> d[0] # peek at leftmost item\n" +"'g'\n" +">>> d[-1] # peek at rightmost item\n" +"'i'\n" +"\n" +">>> list(reversed(d)) # list the contents of a deque in " +"reverse\n" +"['i', 'h', 'g']\n" +">>> 'h' in d # search the deque\n" +"True\n" +">>> d.extend('jkl') # add multiple elements at once\n" +">>> d\n" +"deque(['g', 'h', 'i', 'j', 'k', 'l'])\n" +">>> d.rotate(1) # right rotation\n" +">>> d\n" +"deque(['l', 'g', 'h', 'i', 'j', 'k'])\n" +">>> d.rotate(-1) # left rotation\n" +">>> d\n" +"deque(['g', 'h', 'i', 'j', 'k', 'l'])\n" +"\n" +">>> deque(reversed(d)) # make a new deque in reverse order\n" +"deque(['l', 'k', 'j', 'i', 'h', 'g'])\n" +">>> d.clear() # empty the deque\n" +">>> d.pop() # cannot pop from an empty deque\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in -toplevel-\n" +" d.pop()\n" +"IndexError: pop from an empty deque\n" +"\n" +">>> d.extendleft('abc') # extendleft() reverses the input " +"order\n" +">>> d\n" +"deque(['c', 'b', 'a'])" +msgstr "" + #: library/collections.rst:651 msgid ":class:`deque` Recipes" msgstr "" @@ -655,20 +856,58 @@ msgid "" "in Unix::" msgstr "" +#: library/collections.rst:658 +msgid "" +"def tail(filename, n=10):\n" +" 'Return the last n lines of a file'\n" +" with open(filename) as f:\n" +" return deque(f, n)" +msgstr "" + #: library/collections.rst:663 msgid "" "Another approach to using deques is to maintain a sequence of recently added " "elements by appending to the right and popping to the left::" msgstr "" +#: library/collections.rst:666 +msgid "" +"def moving_average(iterable, n=3):\n" +" # moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0\n" +" # https://en.wikipedia.org/wiki/Moving_average\n" +" it = iter(iterable)\n" +" d = deque(itertools.islice(it, n-1))\n" +" d.appendleft(0)\n" +" s = sum(d)\n" +" for elem in it:\n" +" s += elem - d.popleft()\n" +" d.append(elem)\n" +" yield s / n" +msgstr "" + #: library/collections.rst:678 msgid "" "A `round-robin scheduler `_ can be implemented with input iterators stored in a :" -"class:`deque`. Values are yielded from the active iterator in position " -"zero. If that iterator is exhausted, it can be removed with :meth:`~deque." -"popleft`; otherwise, it can be cycled back to the end with the :meth:`~deque." -"rotate` method::" +"robin_scheduling>`_ can be implemented with input iterators stored in " +"a :class:`deque`. Values are yielded from the active iterator in position " +"zero. If that iterator is exhausted, it can be removed " +"with :meth:`~deque.popleft`; otherwise, it can be cycled back to the end " +"with the :meth:`~deque.rotate` method::" +msgstr "" + +#: library/collections.rst:685 +msgid "" +"def roundrobin(*iterables):\n" +" \"roundrobin('ABC', 'D', 'EF') --> A D E B F C\"\n" +" iterators = deque(map(iter, iterables))\n" +" while iterators:\n" +" try:\n" +" while True:\n" +" yield next(iterators[0])\n" +" iterators.rotate(-1)\n" +" except StopIteration:\n" +" # Remove an exhausted iterator.\n" +" iterators.popleft()" msgstr "" #: library/collections.rst:697 @@ -678,14 +917,23 @@ msgid "" "d[n]`` relies on the ``rotate()`` method to position elements to be popped::" msgstr "" +#: library/collections.rst:701 +msgid "" +"def delete_nth(d, n):\n" +" d.rotate(-n)\n" +" d.popleft()\n" +" d.rotate(n)" +msgstr "" + #: library/collections.rst:706 msgid "" -"To implement :class:`deque` slicing, use a similar approach applying :meth:" -"`~deque.rotate` to bring a target element to the left side of the deque. " -"Remove old entries with :meth:`~deque.popleft`, add new entries with :meth:" -"`~deque.extend`, and then reverse the rotation. With minor variations on " -"that approach, it is easy to implement Forth style stack manipulations such " -"as ``dup``, ``drop``, ``swap``, ``over``, ``pick``, ``rot``, and ``roll``." +"To implement :class:`deque` slicing, use a similar approach " +"applying :meth:`~deque.rotate` to bring a target element to the left side of " +"the deque. Remove old entries with :meth:`~deque.popleft`, add new entries " +"with :meth:`~deque.extend`, and then reverse the rotation. With minor " +"variations on that approach, it is easy to implement Forth style stack " +"manipulations such as ``dup``, ``drop``, ``swap``, ``over``, ``pick``, " +"``rot``, and ``roll``." msgstr "" #: library/collections.rst:716 @@ -702,10 +950,10 @@ msgstr "" #: library/collections.rst:725 msgid "" -"The first argument provides the initial value for the :attr:" -"`default_factory` attribute; it defaults to ``None``. All remaining " -"arguments are treated the same as if they were passed to the :class:`dict` " -"constructor, including keyword arguments." +"The first argument provides the initial value for " +"the :attr:`default_factory` attribute; it defaults to ``None``. All " +"remaining arguments are treated the same as if they were passed to " +"the :class:`dict` constructor, including keyword arguments." msgstr "" #: library/collections.rst:731 @@ -716,8 +964,8 @@ msgstr "" #: library/collections.rst:736 msgid "" -"If the :attr:`default_factory` attribute is ``None``, this raises a :exc:" -"`KeyError` exception with the *key* as argument." +"If the :attr:`default_factory` attribute is ``None``, this raises " +"a :exc:`KeyError` exception with the *key* as argument." msgstr "" #: library/collections.rst:739 @@ -735,17 +983,17 @@ msgstr "" #: library/collections.rst:746 msgid "" -"This method is called by the :meth:`~object.__getitem__` method of the :" -"class:`dict` class when the requested key is not found; whatever it returns " -"or raises is then returned or raised by :meth:`~object.__getitem__`." +"This method is called by the :meth:`~object.__getitem__` method of " +"the :class:`dict` class when the requested key is not found; whatever it " +"returns or raises is then returned or raised by :meth:`~object.__getitem__`." msgstr "" #: library/collections.rst:750 msgid "" -"Note that :meth:`__missing__` is *not* called for any operations besides :" -"meth:`~object.__getitem__`. This means that :meth:`get` will, like normal " -"dictionaries, return ``None`` as a default rather than using :attr:" -"`default_factory`." +"Note that :meth:`__missing__` is *not* called for any operations " +"besides :meth:`~object.__getitem__`. This means that :meth:`get` will, like " +"normal dictionaries, return ``None`` as a default rather than " +"using :attr:`default_factory`." msgstr "" #: library/collections.rst:756 @@ -759,7 +1007,7 @@ msgid "" "absent." msgstr "" -#: library/collections.rst:1182 +#: library/collections.rst:1185 msgid "" "Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`." msgstr "" @@ -777,28 +1025,29 @@ msgstr "" #: library/collections.rst:784 msgid "" "When each key is encountered for the first time, it is not already in the " -"mapping; so an entry is automatically created using the :attr:`~defaultdict." -"default_factory` function which returns an empty :class:`list`. The :meth:" -"`list.append` operation then attaches the value to the new list. When keys " -"are encountered again, the look-up proceeds normally (returning the list for " -"that key) and the :meth:`list.append` operation adds another value to the " -"list. This technique is simpler and faster than an equivalent technique " +"mapping; so an entry is automatically created using " +"the :attr:`~defaultdict.default_factory` function which returns an " +"empty :class:`list`. The :meth:`!list.append` operation then attaches the " +"value to the new list. When keys are encountered again, the look-up " +"proceeds normally (returning the list for that key) and the :meth:`!" +"list.append` operation adds another value to the list. This technique is " +"simpler and faster than an equivalent technique " "using :meth:`dict.setdefault`:" msgstr "" #: library/collections.rst:799 msgid "" -"Setting the :attr:`~defaultdict.default_factory` to :class:`int` makes the :" -"class:`defaultdict` useful for counting (like a bag or multiset in other " -"languages):" +"Setting the :attr:`~defaultdict.default_factory` to :class:`int` makes " +"the :class:`defaultdict` useful for counting (like a bag or multiset in " +"other languages):" msgstr "" #: library/collections.rst:811 msgid "" -"When a letter is first encountered, it is missing from the mapping, so the :" -"attr:`~defaultdict.default_factory` function calls :func:`int` to supply a " -"default count of zero. The increment operation then builds up the count for " -"each letter." +"When a letter is first encountered, it is missing from the mapping, so " +"the :attr:`~defaultdict.default_factory` function calls :func:`int` to " +"supply a default count of zero. The increment operation then builds up the " +"count for each letter." msgstr "" #: library/collections.rst:815 @@ -811,8 +1060,8 @@ msgstr "" #: library/collections.rst:828 msgid "" -"Setting the :attr:`~defaultdict.default_factory` to :class:`set` makes the :" -"class:`defaultdict` useful for building a dictionary of sets:" +"Setting the :attr:`~defaultdict.default_factory` to :class:`set` makes " +"the :class:`defaultdict` useful for building a dictionary of sets:" msgstr "" #: library/collections.rst:841 @@ -832,8 +1081,9 @@ msgid "" "Returns a new tuple subclass named *typename*. The new subclass is used to " "create tuple-like objects that have fields accessible by attribute lookup as " "well as being indexable and iterable. Instances of the subclass also have a " -"helpful docstring (with typename and field_names) and a helpful :meth:" -"`__repr__` method which lists the tuple contents in a ``name=value`` format." +"helpful docstring (with typename and field_names) and a " +"helpful :meth:`__repr__` method which lists the tuple contents in a " +"``name=value`` format." msgstr "" #: library/collections.rst:855 @@ -847,8 +1097,9 @@ msgstr "" msgid "" "Any valid Python identifier may be used for a fieldname except for names " "starting with an underscore. Valid identifiers consist of letters, digits, " -"and underscores but do not start with a digit or underscore and cannot be a :" -"mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, or *raise*." +"and underscores but do not start with a digit or underscore and cannot be " +"a :mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, or " +"*raise*." msgstr "" #: library/collections.rst:865 @@ -871,8 +1122,8 @@ msgstr "" #: library/collections.rst:877 msgid "" -"If *module* is defined, the ``__module__`` attribute of the named tuple is " -"set to that value." +"If *module* is defined, the :attr:`~type.__module__` attribute of the named " +"tuple is set to that value." msgstr "" #: library/collections.rst:880 @@ -910,12 +1161,48 @@ msgid "" "Added the *defaults* parameter and the :attr:`_field_defaults` attribute." msgstr "" +#: library/collections.rst:903 +msgid "" +">>> # Basic example\n" +">>> Point = namedtuple('Point', ['x', 'y'])\n" +">>> p = Point(11, y=22) # instantiate with positional or keyword " +"arguments\n" +">>> p[0] + p[1] # indexable like the plain tuple (11, 22)\n" +"33\n" +">>> x, y = p # unpack like a regular tuple\n" +">>> x, y\n" +"(11, 22)\n" +">>> p.x + p.y # fields also accessible by name\n" +"33\n" +">>> p # readable __repr__ with a name=value style\n" +"Point(x=11, y=22)" +msgstr "" + #: library/collections.rst:919 msgid "" "Named tuples are especially useful for assigning field names to result " "tuples returned by the :mod:`csv` or :mod:`sqlite3` modules::" msgstr "" +#: library/collections.rst:922 +msgid "" +"EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title, department, " +"paygrade')\n" +"\n" +"import csv\n" +"for emp in map(EmployeeRecord._make, csv.reader(open(\"employees.csv\", " +"\"rb\"))):\n" +" print(emp.name, emp.title)\n" +"\n" +"import sqlite3\n" +"conn = sqlite3.connect('/companydata')\n" +"cursor = conn.cursor()\n" +"cursor.execute('SELECT name, age, title, department, paygrade FROM " +"employees')\n" +"for emp in map(EmployeeRecord._make, cursor.fetchall()):\n" +" print(emp.name, emp.title)" +msgstr "" + #: library/collections.rst:935 msgid "" "In addition to the methods inherited from tuples, named tuples support three " @@ -928,12 +1215,26 @@ msgid "" "Class method that makes a new instance from an existing sequence or iterable." msgstr "" +#: library/collections.rst:943 +msgid "" +">>> t = [11, 22]\n" +">>> Point._make(t)\n" +"Point(x=11, y=22)" +msgstr "" + #: library/collections.rst:951 msgid "" "Return a new :class:`dict` which maps field names to their corresponding " "values:" msgstr "" +#: library/collections.rst:954 +msgid "" +">>> p = Point(x=11, y=22)\n" +">>> p._asdict()\n" +"{'x': 11, 'y': 22}" +msgstr "" + #: library/collections.rst:960 msgid "Returns an :class:`OrderedDict` instead of a regular :class:`dict`." msgstr "" @@ -952,20 +1253,51 @@ msgid "" "values::" msgstr "" +#: library/collections.rst:975 +msgid "" +">>> p = Point(x=11, y=22)\n" +">>> p._replace(x=33)\n" +"Point(x=33, y=22)\n" +"\n" +">>> for partnum, record in inventory.items():\n" +"... inventory[partnum] = record._replace(price=newprices[partnum], " +"timestamp=time.now())" +msgstr "" + #: library/collections.rst:984 msgid "" "Tuple of strings listing the field names. Useful for introspection and for " "creating new named tuple types from existing named tuples." msgstr "" +#: library/collections.rst:987 +msgid "" +">>> p._fields # view the field names\n" +"('x', 'y')\n" +"\n" +">>> Color = namedtuple('Color', 'red green blue')\n" +">>> Pixel = namedtuple('Pixel', Point._fields + Color._fields)\n" +">>> Pixel(11, 22, 128, 255, 0)\n" +"Pixel(x=11, y=22, red=128, green=255, blue=0)" +msgstr "" + #: library/collections.rst:999 msgid "Dictionary mapping field names to default values." msgstr "" +#: library/collections.rst:1001 +msgid "" +">>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0])\n" +">>> Account._field_defaults\n" +"{'balance': 0}\n" +">>> Account('premium')\n" +"Account(type='premium', balance=0)" +msgstr "" + #: library/collections.rst:1009 msgid "" -"To retrieve a field whose name is stored in a string, use the :func:" -"`getattr` function:" +"To retrieve a field whose name is stored in a string, use " +"the :func:`getattr` function:" msgstr "" #: library/collections.rst:1015 @@ -981,6 +1313,23 @@ msgid "" "fixed-width print format:" msgstr "" +#: library/collections.rst:1026 +msgid "" +">>> class Point(namedtuple('Point', ['x', 'y'])):\n" +"... __slots__ = ()\n" +"... @property\n" +"... def hypot(self):\n" +"... return (self.x ** 2 + self.y ** 2) ** 0.5\n" +"... def __str__(self):\n" +"... return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, " +"self.hypot)\n" +"\n" +">>> for p in Point(3, 4), Point(14, 5/7):\n" +"... print(p)\n" +"Point: x= 3.000 y= 4.000 hypot= 5.000\n" +"Point: x=14.000 y= 0.714 hypot=14.018" +msgstr "" + #: library/collections.rst:1041 msgid "" "The subclass shown above sets ``__slots__`` to an empty tuple. This helps " @@ -1012,6 +1361,14 @@ msgid "" "keyword::" msgstr "" +#: library/collections.rst:1067 +msgid "" +"class Component(NamedTuple):\n" +" part_number: int\n" +" weight: float\n" +" description: Optional[str] = None" +msgstr "" + #: library/collections.rst:1072 msgid "" "See :meth:`types.SimpleNamespace` for a mutable namespace based on an " @@ -1135,39 +1492,54 @@ msgid "" "if *last* is false. Raises :exc:`KeyError` if the *key* does not exist:" msgstr "" +#: library/collections.rst:1151 +msgid "" +">>> d = OrderedDict.fromkeys('abcde')\n" +">>> d.move_to_end('b')\n" +">>> ''.join(d)\n" +"'acdeb'\n" +">>> d.move_to_end('b', last=False)\n" +">>> ''.join(d)\n" +"'bacde'" +msgstr "" + #: library/collections.rst:1163 msgid "" "In addition to the usual mapping methods, ordered dictionaries also support " "reverse iteration using :func:`reversed`." msgstr "" -#: library/collections.rst:1166 +#: library/collections.rst:1168 msgid "" "Equality tests between :class:`OrderedDict` objects are order-sensitive and " -"are implemented as ``list(od1.items())==list(od2.items())``. Equality tests " -"between :class:`OrderedDict` objects and other :class:`~collections.abc." -"Mapping` objects are order-insensitive like regular dictionaries. This " -"allows :class:`OrderedDict` objects to be substituted anywhere a regular " -"dictionary is used." +"are roughly equivalent to ``list(od1.items())==list(od2.items())``." msgstr "" -#: library/collections.rst:1173 +#: library/collections.rst:1171 msgid "" -"The items, keys, and values :term:`views ` of :class:" -"`OrderedDict` now support reverse iteration using :func:`reversed`." +"Equality tests between :class:`OrderedDict` objects and " +"other :class:`~collections.abc.Mapping` objects are order-insensitive like " +"regular dictionaries. This allows :class:`OrderedDict` objects to be " +"substituted anywhere a regular dictionary is used." msgstr "" -#: library/collections.rst:1177 +#: library/collections.rst:1176 +msgid "" +"The items, keys, and values :term:`views ` " +"of :class:`OrderedDict` now support reverse iteration using :func:`reversed`." +msgstr "" + +#: library/collections.rst:1180 msgid "" "With the acceptance of :pep:`468`, order is retained for keyword arguments " "passed to the :class:`OrderedDict` constructor and its :meth:`update` method." msgstr "" -#: library/collections.rst:1187 +#: library/collections.rst:1190 msgid ":class:`OrderedDict` Examples and Recipes" msgstr "" -#: library/collections.rst:1189 +#: library/collections.rst:1192 msgid "" "It is straightforward to create an ordered dictionary variant that remembers " "the order the keys were *last* inserted. If a new entry overwrites an " @@ -1175,17 +1547,92 @@ msgid "" "end::" msgstr "" -#: library/collections.rst:1201 -msgid "" -"An :class:`OrderedDict` would also be useful for implementing variants of :" -"func:`functools.lru_cache`:" -msgstr "" - -#: library/collections.rst:1300 +#: library/collections.rst:1197 +msgid "" +"class LastUpdatedOrderedDict(OrderedDict):\n" +" 'Store items in the order the keys were last added'\n" +"\n" +" def __setitem__(self, key, value):\n" +" super().__setitem__(key, value)\n" +" self.move_to_end(key)" +msgstr "" + +#: library/collections.rst:1204 +msgid "" +"An :class:`OrderedDict` would also be useful for implementing variants " +"of :func:`functools.lru_cache`:" +msgstr "" + +#: library/collections.rst:1207 +msgid "" +"from collections import OrderedDict\n" +"from time import time\n" +"\n" +"class TimeBoundedLRU:\n" +" \"LRU Cache that invalidates and refreshes old entries.\"\n" +"\n" +" def __init__(self, func, maxsize=128, maxage=30):\n" +" self.cache = OrderedDict() # { args : (timestamp, result)}\n" +" self.func = func\n" +" self.maxsize = maxsize\n" +" self.maxage = maxage\n" +"\n" +" def __call__(self, *args):\n" +" if args in self.cache:\n" +" self.cache.move_to_end(args)\n" +" timestamp, result = self.cache[args]\n" +" if time() - timestamp <= self.maxage:\n" +" return result\n" +" result = self.func(*args)\n" +" self.cache[args] = time(), result\n" +" if len(self.cache) > self.maxsize:\n" +" self.cache.popitem(0)\n" +" return result" +msgstr "" + +#: library/collections.rst:1234 +msgid "" +"class MultiHitLRUCache:\n" +" \"\"\" LRU cache that defers caching a result until\n" +" it has been requested multiple times.\n" +"\n" +" To avoid flushing the LRU cache with one-time requests,\n" +" we don't cache until a request has been made more than once.\n" +"\n" +" \"\"\"\n" +"\n" +" def __init__(self, func, maxsize=128, maxrequests=4096, cache_after=1):\n" +" self.requests = OrderedDict() # { uncached_key : request_count }\n" +" self.cache = OrderedDict() # { cached_key : function_result }\n" +" self.func = func\n" +" self.maxrequests = maxrequests # max number of uncached requests\n" +" self.maxsize = maxsize # max number of stored return " +"values\n" +" self.cache_after = cache_after\n" +"\n" +" def __call__(self, *args):\n" +" if args in self.cache:\n" +" self.cache.move_to_end(args)\n" +" return self.cache[args]\n" +" result = self.func(*args)\n" +" self.requests[args] = self.requests.get(args, 0) + 1\n" +" if self.requests[args] <= self.cache_after:\n" +" self.requests.move_to_end(args)\n" +" if len(self.requests) > self.maxrequests:\n" +" self.requests.popitem(0)\n" +" else:\n" +" self.requests.pop(args, None)\n" +" self.cache[args] = result\n" +" if len(self.cache) > self.maxsize:\n" +" self.cache.popitem(0)\n" +" return result" +msgstr "" + +#: library/collections.rst:1303 msgid ":class:`UserDict` objects" msgstr "" -#: library/collections.rst:1302 +#: library/collections.rst:1305 msgid "" "The class, :class:`UserDict` acts as a wrapper around dictionary objects. " "The need for this class has been partially supplanted by the ability to " @@ -1193,31 +1640,31 @@ msgid "" "work with because the underlying dictionary is accessible as an attribute." msgstr "" -#: library/collections.rst:1310 +#: library/collections.rst:1313 msgid "" "Class that simulates a dictionary. The instance's contents are kept in a " -"regular dictionary, which is accessible via the :attr:`data` attribute of :" -"class:`UserDict` instances. If *initialdata* is provided, :attr:`data` is " -"initialized with its contents; note that a reference to *initialdata* will " -"not be kept, allowing it to be used for other purposes." +"regular dictionary, which is accessible via the :attr:`data` attribute " +"of :class:`UserDict` instances. If *initialdata* is provided, :attr:`data` " +"is initialized with its contents; note that a reference to *initialdata* " +"will not be kept, allowing it to be used for other purposes." msgstr "" -#: library/collections.rst:1316 +#: library/collections.rst:1319 msgid "" -"In addition to supporting the methods and operations of mappings, :class:" -"`UserDict` instances provide the following attribute:" +"In addition to supporting the methods and operations of " +"mappings, :class:`UserDict` instances provide the following attribute:" msgstr "" -#: library/collections.rst:1321 +#: library/collections.rst:1324 msgid "" "A real dictionary used to store the contents of the :class:`UserDict` class." msgstr "" -#: library/collections.rst:1327 +#: library/collections.rst:1330 msgid ":class:`UserList` objects" msgstr "" -#: library/collections.rst:1329 +#: library/collections.rst:1332 msgid "" "This class acts as a wrapper around list objects. It is a useful base class " "for your own list-like classes which can inherit from them and override " @@ -1225,35 +1672,35 @@ msgid "" "lists." msgstr "" -#: library/collections.rst:1334 +#: library/collections.rst:1337 msgid "" "The need for this class has been partially supplanted by the ability to " "subclass directly from :class:`list`; however, this class can be easier to " "work with because the underlying list is accessible as an attribute." msgstr "" -#: library/collections.rst:1340 +#: library/collections.rst:1343 msgid "" "Class that simulates a list. The instance's contents are kept in a regular " -"list, which is accessible via the :attr:`data` attribute of :class:" -"`UserList` instances. The instance's contents are initially set to a copy " -"of *list*, defaulting to the empty list ``[]``. *list* can be any iterable, " -"for example a real Python list or a :class:`UserList` object." +"list, which is accessible via the :attr:`data` attribute " +"of :class:`UserList` instances. The instance's contents are initially set " +"to a copy of *list*, defaulting to the empty list ``[]``. *list* can be any " +"iterable, for example a real Python list or a :class:`UserList` object." msgstr "" -#: library/collections.rst:1346 +#: library/collections.rst:1349 msgid "" -"In addition to supporting the methods and operations of mutable sequences, :" -"class:`UserList` instances provide the following attribute:" +"In addition to supporting the methods and operations of mutable " +"sequences, :class:`UserList` instances provide the following attribute:" msgstr "" -#: library/collections.rst:1351 +#: library/collections.rst:1354 msgid "" -"A real :class:`list` object used to store the contents of the :class:" -"`UserList` class." +"A real :class:`list` object used to store the contents of " +"the :class:`UserList` class." msgstr "" -#: library/collections.rst:1354 +#: library/collections.rst:1357 msgid "" "**Subclassing requirements:** Subclasses of :class:`UserList` are expected " "to offer a constructor which can be called with either no arguments or one " @@ -1263,7 +1710,7 @@ msgid "" "object used as a data source." msgstr "" -#: library/collections.rst:1361 +#: library/collections.rst:1364 msgid "" "If a derived class does not wish to comply with this requirement, all of the " "special methods supported by this class will need to be overridden; please " @@ -1271,11 +1718,11 @@ msgid "" "provided in that case." msgstr "" -#: library/collections.rst:1367 +#: library/collections.rst:1370 msgid ":class:`UserString` objects" msgstr "" -#: library/collections.rst:1369 +#: library/collections.rst:1372 msgid "" "The class, :class:`UserString` acts as a wrapper around string objects. The " "need for this class has been partially supplanted by the ability to subclass " @@ -1283,7 +1730,7 @@ msgid "" "because the underlying string is accessible as an attribute." msgstr "" -#: library/collections.rst:1377 +#: library/collections.rst:1380 msgid "" "Class that simulates a string object. The instance's content is kept in a " "regular string object, which is accessible via the :attr:`data` attribute " @@ -1292,19 +1739,19 @@ msgid "" "converted into a string using the built-in :func:`str` function." msgstr "" -#: library/collections.rst:1384 +#: library/collections.rst:1387 msgid "" -"In addition to supporting the methods and operations of strings, :class:" -"`UserString` instances provide the following attribute:" +"In addition to supporting the methods and operations of " +"strings, :class:`UserString` instances provide the following attribute:" msgstr "" -#: library/collections.rst:1389 +#: library/collections.rst:1392 msgid "" -"A real :class:`str` object used to store the contents of the :class:" -"`UserString` class." +"A real :class:`str` object used to store the contents of " +"the :class:`UserString` class." msgstr "" -#: library/collections.rst:1392 +#: library/collections.rst:1395 msgid "" "New methods ``__getnewargs__``, ``__rmod__``, ``casefold``, ``format_map``, " "``isprintable``, and ``maketrans``." diff --git a/library/colorsys.po b/library/colorsys.po index 76181447..e3f42e40 100644 --- a/library/colorsys.po +++ b/library/colorsys.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/colorsys.rst:2 -msgid ":mod:`colorsys` --- Conversions between color systems" +msgid ":mod:`!colorsys` --- Conversions between color systems" msgstr "" #: library/colorsys.rst:9 @@ -30,7 +31,7 @@ msgid "" "between colors expressed in the RGB (Red Green Blue) color space used in " "computer monitors and three other coordinate systems: YIQ, HLS (Hue " "Lightness Saturation) and HSV (Hue Saturation Value). Coordinates in all of " -"these color spaces are floating point values. In the YIQ space, the Y " +"these color spaces are floating-point values. In the YIQ space, the Y " "coordinate is between 0 and 1, but the I and Q coordinates can be positive " "or negative. In all other spaces, the coordinates are all between 0 and 1." msgstr "" @@ -38,8 +39,8 @@ msgstr "" #: library/colorsys.rst:23 msgid "" "More information about color spaces can be found at https://poynton.ca/" -"ColorFAQ.html and https://www.cambridgeincolour.com/tutorials/color-spaces." -"htm." +"ColorFAQ.html and https://www.cambridgeincolour.com/tutorials/color-" +"spaces.htm." msgstr "" #: library/colorsys.rst:27 @@ -73,3 +74,12 @@ msgstr "" #: library/colorsys.rst:59 msgid "Example::" msgstr "" + +#: library/colorsys.rst:61 +msgid "" +">>> import colorsys\n" +">>> colorsys.rgb_to_hsv(0.2, 0.4, 0.4)\n" +"(0.5, 0.5, 0.4)\n" +">>> colorsys.hsv_to_rgb(0.5, 0.5, 0.4)\n" +"(0.2, 0.4, 0.4)" +msgstr "" diff --git a/library/compileall.po b/library/compileall.po index cf4c49a8..bf0fd7d2 100644 --- a/library/compileall.po +++ b/library/compileall.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/compileall.rst:2 -msgid ":mod:`compileall` --- Byte-compile Python libraries" +msgid ":mod:`!compileall` --- Byte-compile Python libraries" msgstr "" #: library/compileall.rst:7 @@ -34,7 +35,7 @@ msgid "" msgstr "" #: includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." +msgid "Availability" msgstr "" #: includes/wasm-notavail.rst:5 @@ -124,7 +125,7 @@ msgstr "" #: library/compileall.rst:92 msgid "" "Use *N* workers to compile the files within the given directory. If ``0`` is " -"used, then the result of :func:`os.cpu_count()` will be used." +"used, then the result of :func:`os.cpu_count` will be used." msgstr "" #: library/compileall.rst:98 @@ -135,9 +136,9 @@ msgid "" "values cause hash-based pycs to be generated. Hash-based pycs embed a hash " "of the source file contents rather than a timestamp. See :ref:`pyc-" "invalidation` for more information on how Python validates bytecode cache " -"files at runtime. The default is ``timestamp`` if the :envvar:" -"`SOURCE_DATE_EPOCH` environment variable is not set, and ``checked-hash`` if " -"the ``SOURCE_DATE_EPOCH`` environment variable is set." +"files at runtime. The default is ``timestamp`` if " +"the :envvar:`SOURCE_DATE_EPOCH` environment variable is not set, and " +"``checked-hash`` if the ``SOURCE_DATE_EPOCH`` environment variable is set." msgstr "" #: library/compileall.rst:111 @@ -188,10 +189,10 @@ msgstr "" #: library/compileall.rst:146 msgid "" -"Similarly, the :func:`compile` function respects the :data:`sys." -"pycache_prefix` setting. The generated bytecode cache will only be useful " -"if :func:`compile` is run with the same :data:`sys.pycache_prefix` (if any) " -"that will be used at runtime." +"Similarly, the :func:`compile` function respects " +"the :data:`sys.pycache_prefix` setting. The generated bytecode cache will " +"only be useful if :func:`compile` is run with the " +"same :data:`sys.pycache_prefix` (if any) that will be used at runtime." msgstr "" #: library/compileall.rst:152 @@ -200,9 +201,9 @@ msgstr "" #: library/compileall.rst:156 msgid "" -"Recursively descend the directory tree named by *dir*, compiling all :file:`." -"py` files along the way. Return a true value if all the files compiled " -"successfully, and a false value otherwise." +"Recursively descend the directory tree named by *dir*, compiling " +"all :file:`.py` files along the way. Return a true value if all the files " +"compiled successfully, and a false value otherwise." msgstr "" #: library/compileall.rst:160 @@ -264,15 +265,15 @@ msgid "" "in parallel. The default is to not use multiple workers. If the platform " "can't use multiple workers and *workers* argument is given, then sequential " "compilation will be used as a fallback. If *workers* is 0, the number of " -"cores in the system is used. If *workers* is lower than ``0``, a :exc:" -"`ValueError` will be raised." +"cores in the system is used. If *workers* is lower than ``0``, " +"a :exc:`ValueError` will be raised." msgstr "" #: library/compileall.rst:268 msgid "" -"*invalidation_mode* should be a member of the :class:`py_compile." -"PycInvalidationMode` enum and controls how the generated pycs are " -"invalidated at runtime." +"*invalidation_mode* should be a member of " +"the :class:`py_compile.PycInvalidationMode` enum and controls how the " +"generated pycs are invalidated at runtime." msgstr "" #: library/compileall.rst:272 @@ -316,7 +317,8 @@ msgid "The *invalidation_mode* parameter was added." msgstr "" #: library/compileall.rst:291 library/compileall.rst:320 -msgid "The *invalidation_mode* parameter's default value is updated to None." +msgid "" +"The *invalidation_mode* parameter's default value is updated to ``None``." msgstr "" #: library/compileall.rst:231 @@ -326,8 +328,8 @@ msgstr "" #: library/compileall.rst:234 msgid "" "Added *stripdir*, *prependdir*, *limit_sl_dest* and *hardlink_dupes* " -"arguments. Default value of *maxlevels* was changed from ``10`` to ``sys." -"getrecursionlimit()``" +"arguments. Default value of *maxlevels* was changed from ``10`` to " +"``sys.getrecursionlimit()``" msgstr "" #: library/compileall.rst:240 @@ -370,9 +372,9 @@ msgstr "" #: library/compileall.rst:302 msgid "" "If *skip_curdir* is true (the default), the current directory is not " -"included in the search. All other parameters are passed to the :func:" -"`compile_dir` function. Note that unlike the other compile functions, " -"``maxlevels`` defaults to ``0``." +"included in the search. All other parameters are passed to " +"the :func:`compile_dir` function. Note that unlike the other compile " +"functions, ``maxlevels`` defaults to ``0``." msgstr "" #: library/compileall.rst:323 @@ -381,6 +383,21 @@ msgid "" "subdirectory and all its subdirectories::" msgstr "" +#: library/compileall.rst:326 +msgid "" +"import compileall\n" +"\n" +"compileall.compile_dir('Lib/', force=True)\n" +"\n" +"# Perform same compilation, excluding files in .svn directories.\n" +"import re\n" +"compileall.compile_dir('Lib/', rx=re.compile(r'[/\\\\][.]svn'), force=True)\n" +"\n" +"# pathlib.Path objects can also be used.\n" +"import pathlib\n" +"compileall.compile_dir(pathlib.Path('Lib/'), force=True)" +msgstr "" + #: library/compileall.rst:340 msgid "Module :mod:`py_compile`" msgstr "" diff --git a/library/concurrency.po b/library/concurrency.po index 5619e78f..ff730c50 100644 --- a/library/concurrency.po +++ b/library/concurrency.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/concurrent.futures.po b/library/concurrent.futures.po index a7b7b065..919f513d 100644 --- a/library/concurrent.futures.po +++ b/library/concurrent.futures.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/concurrent.futures.rst:2 -msgid ":mod:`concurrent.futures` --- Launching parallel tasks" +msgid ":mod:`!concurrent.futures` --- Launching parallel tasks" msgstr "" #: library/concurrent.futures.rst:9 @@ -34,14 +35,14 @@ msgstr "" #: library/concurrent.futures.rst:17 msgid "" -"The asynchronous execution can be performed with threads, using :class:" -"`ThreadPoolExecutor`, or separate processes, using :class:" -"`ProcessPoolExecutor`. Both implement the same interface, which is defined " -"by the abstract :class:`Executor` class." +"The asynchronous execution can be performed with threads, " +"using :class:`ThreadPoolExecutor`, or separate processes, " +"using :class:`ProcessPoolExecutor`. Both implement the same interface, " +"which is defined by the abstract :class:`Executor` class." msgstr "" #: includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." +msgid "Availability" msgstr "" #: includes/wasm-notavail.rst:5 @@ -68,6 +69,13 @@ msgid "" "callable. ::" msgstr "" +#: library/concurrent.futures.rst:38 +msgid "" +"with ThreadPoolExecutor(max_workers=1) as executor:\n" +" future = executor.submit(pow, 323, 1235)\n" +" print(future.result())" +msgstr "" + #: library/concurrent.futures.rst:44 msgid "Similar to :func:`map(fn, *iterables) ` except:" msgstr "" @@ -84,11 +92,11 @@ msgstr "" #: library/concurrent.futures.rst:51 msgid "" -"The returned iterator raises a :exc:`TimeoutError` if :meth:`~iterator." -"__next__` is called and the result isn't available after *timeout* seconds " -"from the original call to :meth:`Executor.map`. *timeout* can be an int or a " -"float. If *timeout* is not specified or ``None``, there is no limit to the " -"wait time." +"The returned iterator raises a :exc:`TimeoutError` " +"if :meth:`~iterator.__next__` is called and the result isn't available after " +"*timeout* seconds from the original call to :meth:`Executor.map`. *timeout* " +"can be an int or a float. If *timeout* is not specified or ``None``, there " +"is no limit to the wait time." msgstr "" #: library/concurrent.futures.rst:57 @@ -114,9 +122,9 @@ msgstr "" #: library/concurrent.futures.rst:73 msgid "" "Signal the executor that it should free any resources that it is using when " -"the currently pending futures are done executing. Calls to :meth:`Executor." -"submit` and :meth:`Executor.map` made after shutdown will raise :exc:" -"`RuntimeError`." +"the currently pending futures are done executing. Calls " +"to :meth:`Executor.submit` and :meth:`Executor.map` made after shutdown will " +"raise :exc:`RuntimeError`." msgstr "" #: library/concurrent.futures.rst:78 @@ -146,9 +154,20 @@ msgstr "" #: library/concurrent.futures.rst:95 msgid "" -"You can avoid having to call this method explicitly if you use the :keyword:" -"`with` statement, which will shutdown the :class:`Executor` (waiting as if :" -"meth:`Executor.shutdown` were called with *wait* set to ``True``)::" +"You can avoid having to call this method explicitly if you use " +"the :keyword:`with` statement, which will shutdown the :class:`Executor` " +"(waiting as if :meth:`Executor.shutdown` were called with *wait* set to " +"``True``)::" +msgstr "" + +#: library/concurrent.futures.rst:100 +msgid "" +"import shutil\n" +"with ThreadPoolExecutor(max_workers=4) as e:\n" +" e.submit(shutil.copy, 'src1.txt', 'dest1.txt')\n" +" e.submit(shutil.copy, 'src2.txt', 'dest2.txt')\n" +" e.submit(shutil.copy, 'src3.txt', 'dest3.txt')\n" +" e.submit(shutil.copy, 'src4.txt', 'dest4.txt')" msgstr "" #: library/concurrent.futures.rst:107 @@ -171,10 +190,41 @@ msgid "" "waits on the results of another :class:`Future`. For example::" msgstr "" +#: library/concurrent.futures.rst:120 +msgid "" +"import time\n" +"def wait_on_b():\n" +" time.sleep(5)\n" +" print(b.result()) # b will never complete because it is waiting on a.\n" +" return 5\n" +"\n" +"def wait_on_a():\n" +" time.sleep(5)\n" +" print(a.result()) # a will never complete because it is waiting on b.\n" +" return 6\n" +"\n" +"\n" +"executor = ThreadPoolExecutor(max_workers=2)\n" +"a = executor.submit(wait_on_b)\n" +"b = executor.submit(wait_on_a)" +msgstr "" + #: library/concurrent.futures.rst:136 msgid "And::" msgstr "" +#: library/concurrent.futures.rst:138 +msgid "" +"def wait_on_future():\n" +" f = executor.submit(pow, 5, 2)\n" +" # This will never complete because there is only one worker thread and\n" +" # it is executing this function.\n" +" print(f.result())\n" +"\n" +"executor = ThreadPoolExecutor(max_workers=1)\n" +"executor.submit(wait_on_future)" +msgstr "" + #: library/concurrent.futures.rst:150 msgid "" "An :class:`Executor` subclass that uses a pool of at most *max_workers* " @@ -203,17 +253,17 @@ msgstr "" #: library/concurrent.futures.rst:166 msgid "" "If *max_workers* is ``None`` or not given, it will default to the number of " -"processors on the machine, multiplied by ``5``, assuming that :class:" -"`ThreadPoolExecutor` is often used to overlap I/O instead of CPU work and " -"the number of workers should be higher than the number of workers for :class:" -"`ProcessPoolExecutor`." +"processors on the machine, multiplied by ``5``, assuming " +"that :class:`ThreadPoolExecutor` is often used to overlap I/O instead of CPU " +"work and the number of workers should be higher than the number of workers " +"for :class:`ProcessPoolExecutor`." msgstr "" #: library/concurrent.futures.rst:174 msgid "" -"Added the *thread_name_prefix* parameter to allow users to control the :" -"class:`threading.Thread` names for worker threads created by the pool for " -"easier debugging." +"Added the *thread_name_prefix* parameter to allow users to control " +"the :class:`threading.Thread` names for worker threads created by the pool " +"for easier debugging." msgstr "" #: library/concurrent.futures.rst:179 library/concurrent.futures.rst:283 @@ -238,6 +288,37 @@ msgstr "" msgid "ThreadPoolExecutor Example" msgstr "" +#: library/concurrent.futures.rst:198 +msgid "" +"import concurrent.futures\n" +"import urllib.request\n" +"\n" +"URLS = ['http://www.foxnews.com/',\n" +" 'http://www.cnn.com/',\n" +" 'http://europe.wsj.com/',\n" +" 'http://www.bbc.co.uk/',\n" +" 'http://nonexistant-subdomain.python.org/']\n" +"\n" +"# Retrieve a single page and report the URL and contents\n" +"def load_url(url, timeout):\n" +" with urllib.request.urlopen(url, timeout=timeout) as conn:\n" +" return conn.read()\n" +"\n" +"# We can use a with statement to ensure threads are cleaned up promptly\n" +"with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:\n" +" # Start the load operations and mark each future with its URL\n" +" future_to_url = {executor.submit(load_url, url, 60): url for url in " +"URLS}\n" +" for future in concurrent.futures.as_completed(future_to_url):\n" +" url = future_to_url[future]\n" +" try:\n" +" data = future.result()\n" +" except Exception as exc:\n" +" print('%r generated an exception: %s' % (url, exc))\n" +" else:\n" +" print('%r page is %d bytes' % (url, len(data)))" +msgstr "" + #: library/concurrent.futures.rst:227 msgid "ProcessPoolExecutor" msgstr "" @@ -245,11 +326,11 @@ msgstr "" #: library/concurrent.futures.rst:229 msgid "" "The :class:`ProcessPoolExecutor` class is an :class:`Executor` subclass that " -"uses a pool of processes to execute calls asynchronously. :class:" -"`ProcessPoolExecutor` uses the :mod:`multiprocessing` module, which allows " -"it to side-step the :term:`Global Interpreter Lock ` but also means that only picklable objects can be executed and " -"returned." +"uses a pool of processes to execute calls " +"asynchronously. :class:`ProcessPoolExecutor` uses the :mod:`multiprocessing` " +"module, which allows it to side-step the :term:`Global Interpreter Lock " +"` but also means that only picklable objects can be " +"executed and returned." msgstr "" #: library/concurrent.futures.rst:236 @@ -302,10 +383,10 @@ msgstr "" #: library/concurrent.futures.rst:272 msgid "" -"When one of the worker processes terminates abruptly, a :exc:`~concurrent." -"futures.process.BrokenProcessPool` error is now raised. Previously, " -"behaviour was undefined but operations on the executor or its futures would " -"often freeze or deadlock." +"When one of the worker processes terminates abruptly, " +"a :exc:`~concurrent.futures.process.BrokenProcessPool` error is now raised. " +"Previously, behaviour was undefined but operations on the executor or its " +"futures would often freeze or deadlock." msgstr "" #: library/concurrent.futures.rst:279 @@ -319,8 +400,8 @@ msgid "" "The default :mod:`multiprocessing` start method (see :ref:`multiprocessing-" "start-methods`) will change away from *fork* in Python 3.14. Code that " "requires *fork* be used for their :class:`ProcessPoolExecutor` should " -"explicitly specify that by passing a ``mp_context=multiprocessing." -"get_context(\"fork\")`` parameter." +"explicitly specify that by passing a " +"``mp_context=multiprocessing.get_context(\"fork\")`` parameter." msgstr "" #: library/concurrent.futures.rst:293 @@ -331,17 +412,54 @@ msgstr "" #: library/concurrent.futures.rst:297 msgid "" -"On POSIX systems, if your application has multiple threads and the :mod:" -"`multiprocessing` context uses the ``\"fork\"`` start method: The :func:`os." -"fork` function called internally to spawn workers may raise a :exc:" -"`DeprecationWarning`. Pass a *mp_context* configured to use a different " -"start method. See the :func:`os.fork` documentation for further explanation." +"On POSIX systems, if your application has multiple threads and " +"the :mod:`multiprocessing` context uses the ``\"fork\"`` start method: " +"The :func:`os.fork` function called internally to spawn workers may raise " +"a :exc:`DeprecationWarning`. Pass a *mp_context* configured to use a " +"different start method. See the :func:`os.fork` documentation for further " +"explanation." msgstr "" #: library/concurrent.futures.rst:308 msgid "ProcessPoolExecutor Example" msgstr "" +#: library/concurrent.futures.rst:311 +msgid "" +"import concurrent.futures\n" +"import math\n" +"\n" +"PRIMES = [\n" +" 112272535095293,\n" +" 112582705942171,\n" +" 112272535095293,\n" +" 115280095190773,\n" +" 115797848077099,\n" +" 1099726899285419]\n" +"\n" +"def is_prime(n):\n" +" if n < 2:\n" +" return False\n" +" if n == 2:\n" +" return True\n" +" if n % 2 == 0:\n" +" return False\n" +"\n" +" sqrt_n = int(math.floor(math.sqrt(n)))\n" +" for i in range(3, sqrt_n + 1, 2):\n" +" if n % i == 0:\n" +" return False\n" +" return True\n" +"\n" +"def main():\n" +" with concurrent.futures.ProcessPoolExecutor() as executor:\n" +" for number, prime in zip(PRIMES, executor.map(is_prime, PRIMES)):\n" +" print('%d is prime: %s' % (number, prime))\n" +"\n" +"if __name__ == '__main__':\n" +" main()" +msgstr "" + #: library/concurrent.futures.rst:346 msgid "Future Objects" msgstr "" @@ -439,8 +557,8 @@ msgstr "" #: library/concurrent.futures.rst:421 msgid "" -"The following :class:`Future` methods are meant for use in unit tests and :" -"class:`Executor` implementations." +"The following :class:`Future` methods are meant for use in unit tests " +"and :class:`Executor` implementations." msgstr "" #: library/concurrent.futures.rst:426 @@ -452,8 +570,8 @@ msgstr "" #: library/concurrent.futures.rst:430 msgid "" -"If the method returns ``False`` then the :class:`Future` was cancelled, i." -"e. :meth:`Future.cancel` was called and returned ``True``. Any threads " +"If the method returns ``False`` then the :class:`Future` was cancelled, " +"i.e. :meth:`Future.cancel` was called and returned ``True``. Any threads " "waiting on the :class:`Future` completing (i.e. through :func:`as_completed` " "or :func:`wait`) will be woken up." msgstr "" @@ -467,8 +585,9 @@ msgstr "" #: library/concurrent.futures.rst:439 msgid "" -"This method can only be called once and cannot be called after :meth:`Future." -"set_result` or :meth:`Future.set_exception` have been called." +"This method can only be called once and cannot be called " +"after :meth:`Future.set_result` or :meth:`Future.set_exception` have been " +"called." msgstr "" #: library/concurrent.futures.rst:445 @@ -484,14 +603,14 @@ msgstr "" #: library/concurrent.futures.rst:451 library/concurrent.futures.rst:464 msgid "" -"This method raises :exc:`concurrent.futures.InvalidStateError` if the :class:" -"`Future` is already done." +"This method raises :exc:`concurrent.futures.InvalidStateError` if " +"the :class:`Future` is already done." msgstr "" #: library/concurrent.futures.rst:458 msgid "" -"Sets the result of the work associated with the :class:`Future` to the :" -"class:`Exception` *exception*." +"Sets the result of the work associated with the :class:`Future` to " +"the :class:`Exception` *exception*." msgstr "" #: library/concurrent.futures.rst:470 @@ -500,13 +619,13 @@ msgstr "" #: library/concurrent.futures.rst:474 msgid "" -"Wait for the :class:`Future` instances (possibly created by different :class:" -"`Executor` instances) given by *fs* to complete. Duplicate futures given to " -"*fs* are removed and will be returned only once. Returns a named 2-tuple of " -"sets. The first set, named ``done``, contains the futures that completed " -"(finished or cancelled futures) before the wait completed. The second set, " -"named ``not_done``, contains the futures that did not complete (pending or " -"running futures)." +"Wait for the :class:`Future` instances (possibly created by " +"different :class:`Executor` instances) given by *fs* to complete. Duplicate " +"futures given to *fs* are removed and will be returned only once. Returns a " +"named 2-tuple of sets. The first set, named ``done``, contains the futures " +"that completed (finished or cancelled futures) before the wait completed. " +"The second set, named ``not_done``, contains the futures that did not " +"complete (pending or running futures)." msgstr "" #: library/concurrent.futures.rst:482 @@ -537,8 +656,8 @@ msgstr "" #: library/concurrent.futures.rst:499 msgid "" "The function will return when any future finishes by raising an exception. " -"If no future raises an exception then it is equivalent to :const:" -"`ALL_COMPLETED`." +"If no future raises an exception then it is equivalent " +"to :const:`ALL_COMPLETED`." msgstr "" #: library/concurrent.futures.rst:504 @@ -558,7 +677,7 @@ msgid "" "*timeout* is not specified or ``None``, there is no limit to the wait time." msgstr "" -#: library/concurrent.futures.rst:522 +#: library/concurrent.futures.rst:521 msgid ":pep:`3148` -- futures - execute computations asynchronously" msgstr "" @@ -602,14 +721,15 @@ msgstr "" #: library/concurrent.futures.rst:564 msgid "" "Derived from :exc:`~concurrent.futures.BrokenExecutor`, this exception class " -"is raised when one of the workers of a :class:`~concurrent.futures." -"ThreadPoolExecutor` has failed initializing." +"is raised when one of the workers of " +"a :class:`~concurrent.futures.ThreadPoolExecutor` has failed initializing." msgstr "" #: library/concurrent.futures.rst:575 msgid "" -"Derived from :exc:`~concurrent.futures.BrokenExecutor` (formerly :exc:" -"`RuntimeError`), this exception class is raised when one of the workers of " -"a :class:`~concurrent.futures.ProcessPoolExecutor` has terminated in a non-" -"clean fashion (for example, if it was killed from the outside)." +"Derived from :exc:`~concurrent.futures.BrokenExecutor` " +"(formerly :exc:`RuntimeError`), this exception class is raised when one of " +"the workers of a :class:`~concurrent.futures.ProcessPoolExecutor` has " +"terminated in a non-clean fashion (for example, if it was killed from the " +"outside)." msgstr "" diff --git a/library/concurrent.po b/library/concurrent.po index e3a505a4..9d047e35 100644 --- a/library/concurrent.po +++ b/library/concurrent.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/configparser.po b/library/configparser.po index 60f192d9..58546df4 100644 --- a/library/configparser.po +++ b/library/configparser.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/configparser.rst:2 -msgid ":mod:`configparser` --- Configuration file parser" +msgid ":mod:`!configparser` --- Configuration file parser" msgstr "" #: library/configparser.rst:14 @@ -38,7 +39,7 @@ msgid "" "the Windows Registry extended version of INI syntax." msgstr "" -#: library/configparser.rst:38 +#: library/configparser.rst:36 msgid "Module :mod:`tomllib`" msgstr "" @@ -48,7 +49,7 @@ msgid "" "specifically designed to be an improved version of INI." msgstr "" -#: library/configparser.rst:42 +#: library/configparser.rst:40 msgid "Module :mod:`shlex`" msgstr "" @@ -58,7 +59,7 @@ msgid "" "for application configuration files." msgstr "" -#: library/configparser.rst:45 +#: library/configparser.rst:44 msgid "Module :mod:`json`" msgstr "" @@ -68,15 +69,31 @@ msgid "" "sometimes used for configuration, but does not support comments." msgstr "" -#: library/configparser.rst:60 +#: library/configparser.rst:61 msgid "Quick Start" msgstr "" -#: library/configparser.rst:62 +#: library/configparser.rst:63 msgid "Let's take a very basic configuration file that looks like this:" msgstr "" -#: library/configparser.rst:79 +#: library/configparser.rst:65 +msgid "" +"[DEFAULT]\n" +"ServerAliveInterval = 45\n" +"Compression = yes\n" +"CompressionLevel = 9\n" +"ForwardX11 = yes\n" +"\n" +"[forge.example]\n" +"User = hg\n" +"\n" +"[topsecret.server.example]\n" +"Port = 50022\n" +"ForwardX11 = no" +msgstr "" + +#: library/configparser.rst:80 msgid "" "The structure of INI files is described `in the following section " "<#supported-ini-file-structure>`_. Essentially, the file consists of " @@ -85,20 +102,72 @@ msgid "" "configuration file programmatically." msgstr "" -#: library/configparser.rst:103 +#: library/configparser.rst:86 +msgid "" +">>> import configparser\n" +">>> config = configparser.ConfigParser()\n" +">>> config['DEFAULT'] = {'ServerAliveInterval': '45',\n" +"... 'Compression': 'yes',\n" +"... 'CompressionLevel': '9'}\n" +">>> config['forge.example'] = {}\n" +">>> config['forge.example']['User'] = 'hg'\n" +">>> config['topsecret.server.example'] = {}\n" +">>> topsecret = config['topsecret.server.example']\n" +">>> topsecret['Port'] = '50022' # mutates the parser\n" +">>> topsecret['ForwardX11'] = 'no' # same here\n" +">>> config['DEFAULT']['ForwardX11'] = 'yes'\n" +">>> with open('example.ini', 'w') as configfile:\n" +"... config.write(configfile)\n" +"..." +msgstr "" + +#: library/configparser.rst:104 msgid "" "As you can see, we can treat a config parser much like a dictionary. There " "are differences, `outlined later <#mapping-protocol-access>`_, but the " "behavior is very close to what you would expect from a dictionary." msgstr "" -#: library/configparser.rst:107 +#: library/configparser.rst:108 msgid "" "Now that we have created and saved a configuration file, let's read it back " "and explore the data it holds." msgstr "" -#: library/configparser.rst:142 +#: library/configparser.rst:111 +msgid "" +">>> config = configparser.ConfigParser()\n" +">>> config.sections()\n" +"[]\n" +">>> config.read('example.ini')\n" +"['example.ini']\n" +">>> config.sections()\n" +"['forge.example', 'topsecret.server.example']\n" +">>> 'forge.example' in config\n" +"True\n" +">>> 'python.org' in config\n" +"False\n" +">>> config['forge.example']['User']\n" +"'hg'\n" +">>> config['DEFAULT']['Compression']\n" +"'yes'\n" +">>> topsecret = config['topsecret.server.example']\n" +">>> topsecret['ForwardX11']\n" +"'no'\n" +">>> topsecret['Port']\n" +"'50022'\n" +">>> for key in config['forge.example']: \n" +"... print(key)\n" +"user\n" +"compressionlevel\n" +"serveraliveinterval\n" +"compression\n" +"forwardx11\n" +">>> config['forge.example']['ForwardX11']\n" +"'yes'" +msgstr "" + +#: library/configparser.rst:143 msgid "" "As we can see above, the API is pretty straightforward. The only bit of " "magic involves the ``DEFAULT`` section which provides default values for all " @@ -106,32 +175,62 @@ msgid "" "and stored in lowercase [1]_." msgstr "" -#: library/configparser.rst:147 +#: library/configparser.rst:967 +msgid "" +"It is possible to read several configurations into a " +"single :class:`ConfigParser`, where the most recently added configuration " +"has the highest priority. Any conflicting keys are taken from the more " +"recent configuration while the previously existing keys are retained. The " +"example below reads in an ``override.ini`` file, which will override any " +"conflicting keys from the ``example.ini`` file." +msgstr "" + +#: library/configparser.rst:974 +msgid "" +"[DEFAULT]\n" +"ServerAliveInterval = -1" +msgstr "" + +#: library/configparser.rst:979 msgid "" -"It is possible to read several configurations into a single :class:" -"`ConfigParser`, where the most recently added configuration has the highest " -"priority. Any conflicting keys are taken from the more recent configuration " -"while the previously existing keys are retained." +">>> config_override = configparser.ConfigParser()\n" +">>> config_override['DEFAULT'] = {'ServerAliveInterval': '-1'}\n" +">>> with open('override.ini', 'w') as configfile:\n" +"... config_override.write(configfile)\n" +"...\n" +">>> config_override = configparser.ConfigParser()\n" +">>> config_override.read(['example.ini', 'override.ini'])\n" +"['example.ini', 'override.ini']\n" +">>> print(config_override.get('DEFAULT', 'ServerAliveInterval'))\n" +"-1" msgstr "" -#: library/configparser.rst:168 +#: library/configparser.rst:174 msgid "" "This behaviour is equivalent to a :meth:`ConfigParser.read` call with " "several files passed to the *filenames* parameter." msgstr "" -#: library/configparser.rst:173 +#: library/configparser.rst:179 msgid "Supported Datatypes" msgstr "" -#: library/configparser.rst:175 +#: library/configparser.rst:181 msgid "" "Config parsers do not guess datatypes of values in configuration files, " "always storing them internally as strings. This means that if you need " "other datatypes, you should convert on your own:" msgstr "" -#: library/configparser.rst:186 +#: library/configparser.rst:185 +msgid "" +">>> int(topsecret['Port'])\n" +"50022\n" +">>> float(topsecret['CompressionLevel'])\n" +"9.0" +msgstr "" + +#: library/configparser.rst:192 msgid "" "Since this task is so common, config parsers provide a range of handy getter " "methods to handle integers, floats and booleans. The last one is the most " @@ -142,7 +241,17 @@ msgid "" "``'true'``/``'false'`` and ``'1'``/``'0'`` [1]_. For example:" msgstr "" -#: library/configparser.rst:203 +#: library/configparser.rst:200 +msgid "" +">>> topsecret.getboolean('ForwardX11')\n" +"False\n" +">>> config['forge.example'].getboolean('ForwardX11')\n" +"True\n" +">>> config.getboolean('forge.example', 'Compression')\n" +"True" +msgstr "" + +#: library/configparser.rst:209 msgid "" "Apart from :meth:`~ConfigParser.getboolean`, config parsers also provide " "equivalent :meth:`~ConfigParser.getint` and :meth:`~ConfigParser.getfloat` " @@ -150,17 +259,28 @@ msgid "" "ones. [1]_" msgstr "" -#: library/configparser.rst:209 +#: library/configparser.rst:215 msgid "Fallback Values" msgstr "" -#: library/configparser.rst:211 +#: library/configparser.rst:217 msgid "" "As with a dictionary, you can use a section's :meth:`~ConfigParser.get` " "method to provide fallback values:" msgstr "" -#: library/configparser.rst:224 +#: library/configparser.rst:220 +msgid "" +">>> topsecret.get('Port')\n" +"'50022'\n" +">>> topsecret.get('CompressionLevel')\n" +"'9'\n" +">>> topsecret.get('Cipher')\n" +">>> topsecret.get('Cipher', '3des-cbc')\n" +"'3des-cbc'" +msgstr "" + +#: library/configparser.rst:230 msgid "" "Please note that default values have precedence over fallback values. For " "instance, in our example the ``'CompressionLevel'`` key was specified only " @@ -169,26 +289,50 @@ msgid "" "specify a fallback:" msgstr "" -#: library/configparser.rst:235 +#: library/configparser.rst:236 msgid "" -"One more thing to be aware of is that the parser-level :meth:`~ConfigParser." -"get` method provides a custom, more complex interface, maintained for " -"backwards compatibility. When using this method, a fallback value can be " -"provided via the ``fallback`` keyword-only argument:" +">>> topsecret.get('CompressionLevel', '3')\n" +"'9'" +msgstr "" + +#: library/configparser.rst:241 +msgid "" +"One more thing to be aware of is that the parser-" +"level :meth:`~ConfigParser.get` method provides a custom, more complex " +"interface, maintained for backwards compatibility. When using this method, " +"a fallback value can be provided via the ``fallback`` keyword-only argument:" msgstr "" #: library/configparser.rst:246 msgid "" -"The same ``fallback`` argument can be used with the :meth:`~ConfigParser." -"getint`, :meth:`~ConfigParser.getfloat` and :meth:`~ConfigParser.getboolean` " -"methods, for example:" +">>> config.get('forge.example', 'monster',\n" +"... fallback='No such things as monsters')\n" +"'No such things as monsters'" +msgstr "" + +#: library/configparser.rst:252 +msgid "" +"The same ``fallback`` argument can be used with " +"the :meth:`~ConfigParser.getint`, :meth:`~ConfigParser.getfloat` " +"and :meth:`~ConfigParser.getboolean` methods, for example:" msgstr "" -#: library/configparser.rst:262 +#: library/configparser.rst:256 +msgid "" +">>> 'BatchMode' in topsecret\n" +"False\n" +">>> topsecret.getboolean('BatchMode', fallback=True)\n" +"True\n" +">>> config['DEFAULT']['BatchMode'] = 'no'\n" +">>> topsecret.getboolean('BatchMode', fallback=True)\n" +"False" +msgstr "" + +#: library/configparser.rst:268 msgid "Supported INI File Structure" msgstr "" -#: library/configparser.rst:264 +#: library/configparser.rst:270 msgid "" "A configuration file consists of sections, each led by a ``[section]`` " "header, followed by key/value entries separated by a specific string (``=`` " @@ -201,35 +345,80 @@ msgid "" "parts of multiline values or ignored." msgstr "" -#: library/configparser.rst:274 +#: library/configparser.rst:280 msgid "" "By default, a valid section name can be any string that does not contain '\\" "\\n'. To change this, see :attr:`ConfigParser.SECTCRE`." msgstr "" -#: library/configparser.rst:277 +#: library/configparser.rst:283 msgid "" "Configuration files may include comments, prefixed by specific characters " "(``#`` and ``;`` by default [1]_). Comments may appear on their own on an " "otherwise empty line, possibly indented. [1]_" msgstr "" -#: library/configparser.rst:344 +#: library/configparser.rst:350 msgid "For example:" msgstr "" -#: library/configparser.rst:329 +#: library/configparser.rst:289 +msgid "" +"[Simple Values]\n" +"key=value\n" +"spaces in keys=allowed\n" +"spaces in values=allowed as well\n" +"spaces around the delimiter = obviously\n" +"you can also use : to delimit keys from values\n" +"\n" +"[All Values Are Strings]\n" +"values like this: 1000000\n" +"or this: 3.14159265359\n" +"are they treated as numbers? : no\n" +"integers, floats and booleans are held as: strings\n" +"can use the API to get converted values directly: true\n" +"\n" +"[Multiline Values]\n" +"chorus: I'm a lumberjack, and I'm okay\n" +" I sleep all night and I work all day\n" +"\n" +"[No Values]\n" +"key_without_value\n" +"empty string value here =\n" +"\n" +"[You can use comments]\n" +"# like this\n" +"; or this\n" +"\n" +"# By default only in an empty line.\n" +"# Inline comments can be harmful because they prevent users\n" +"# from using the delimiting characters as parts of values.\n" +"# That being said, this can be customized.\n" +"\n" +" [Sections Can Be Indented]\n" +" can_values_be_as_well = True\n" +" does_that_mean_anything_special = False\n" +" purpose = formatting for readability\n" +" multiline_values = are\n" +" handled just fine as\n" +" long as they are indented\n" +" deeper than the first line\n" +" of a value\n" +" # Did I mention we can indent comments, too?" +msgstr "" + +#: library/configparser.rst:335 msgid "Interpolation of values" msgstr "" -#: library/configparser.rst:331 +#: library/configparser.rst:337 msgid "" "On top of the core functionality, :class:`ConfigParser` supports " "interpolation. This means values can be preprocessed before returning them " "from ``get()`` calls." msgstr "" -#: library/configparser.rst:339 +#: library/configparser.rst:345 msgid "" "The default implementation used by :class:`ConfigParser`. It enables values " "to contain format strings which refer to other values in the same section, " @@ -237,7 +426,20 @@ msgid "" "can be provided on initialization." msgstr "" -#: library/configparser.rst:357 +#: library/configparser.rst:352 +msgid "" +"[Paths]\n" +"home_dir: /Users\n" +"my_dir: %(home_dir)s/lumberjack\n" +"my_pictures: %(my_dir)s/Pictures\n" +"\n" +"[Escape]\n" +"# use a %% to escape the % sign (% is the only character that needs to be " +"escaped):\n" +"gain: 80%%" +msgstr "" + +#: library/configparser.rst:363 msgid "" "In the example above, :class:`ConfigParser` with *interpolation* set to " "``BasicInterpolation()`` would resolve ``%(home_dir)s`` to the value of " @@ -247,46 +449,79 @@ msgid "" "specific order in the configuration file." msgstr "" -#: library/configparser.rst:364 +#: library/configparser.rst:370 msgid "" -"With ``interpolation`` set to ``None``, the parser would simply return " -"``%(my_dir)s/Pictures`` as the value of ``my_pictures`` and ``%(home_dir)s/" +"With ``interpolation`` set to ``None``, the parser would simply return ``%" +"(my_dir)s/Pictures`` as the value of ``my_pictures`` and ``%(home_dir)s/" "lumberjack`` as the value of ``my_dir``." msgstr "" -#: library/configparser.rst:372 +#: library/configparser.rst:378 msgid "" "An alternative handler for interpolation which implements a more advanced " "syntax, used for instance in ``zc.buildout``. Extended interpolation is " "using ``${section:option}`` to denote a value from a foreign section. " -"Interpolation can span multiple levels. For convenience, if the ``section:" -"`` part is omitted, interpolation defaults to the current section (and " -"possibly the default values from the special section)." +"Interpolation can span multiple levels. For convenience, if the " +"``section:`` part is omitted, interpolation defaults to the current section " +"(and possibly the default values from the special section)." msgstr "" -#: library/configparser.rst:379 +#: library/configparser.rst:385 msgid "" "For example, the configuration specified above with basic interpolation, " "would look like this with extended interpolation:" msgstr "" -#: library/configparser.rst:393 +#: library/configparser.rst:388 +msgid "" +"[Paths]\n" +"home_dir: /Users\n" +"my_dir: ${home_dir}/lumberjack\n" +"my_pictures: ${my_dir}/Pictures\n" +"\n" +"[Escape]\n" +"# use a $$ to escape the $ sign ($ is the only character that needs to be " +"escaped):\n" +"cost: $$80" +msgstr "" + +#: library/configparser.rst:399 msgid "Values from other sections can be fetched as well:" msgstr "" -#: library/configparser.rst:415 +#: library/configparser.rst:401 +msgid "" +"[Common]\n" +"home_dir: /Users\n" +"library_dir: /Library\n" +"system_dir: /System\n" +"macports_dir: /opt/local\n" +"\n" +"[Frameworks]\n" +"Python: 3.2\n" +"path: ${Common:system_dir}/Library/Frameworks/\n" +"\n" +"[Arthur]\n" +"nickname: Two Sheds\n" +"last_name: Jackson\n" +"my_dir: ${Common:home_dir}/twosheds\n" +"my_pictures: ${my_dir}/Pictures\n" +"python_dir: ${Frameworks:path}/Python/Versions/${Frameworks:Python}" +msgstr "" + +#: library/configparser.rst:421 msgid "Mapping Protocol Access" msgstr "" -#: library/configparser.rst:419 +#: library/configparser.rst:425 msgid "" "Mapping protocol access is a generic name for functionality that enables " -"using custom objects as if they were dictionaries. In case of :mod:" -"`configparser`, the mapping interface implementation is using the " +"using custom objects as if they were dictionaries. In case " +"of :mod:`configparser`, the mapping interface implementation is using the " "``parser['section']['option']`` notation." msgstr "" -#: library/configparser.rst:424 +#: library/configparser.rst:430 msgid "" "``parser['section']`` in particular returns a proxy for the section's data " "in the parser. This means that the values are not copied but they are taken " @@ -295,15 +530,15 @@ msgid "" "original parser." msgstr "" -#: library/configparser.rst:430 +#: library/configparser.rst:436 msgid "" ":mod:`configparser` objects behave as close to actual dictionaries as " -"possible. The mapping interface is complete and adheres to the :class:" -"`~collections.abc.MutableMapping` ABC. However, there are a few differences " -"that should be taken into account:" +"possible. The mapping interface is complete and adheres to " +"the :class:`~collections.abc.MutableMapping` ABC. However, there are a few " +"differences that should be taken into account:" msgstr "" -#: library/configparser.rst:435 +#: library/configparser.rst:441 msgid "" "By default, all keys in sections are accessible in a case-insensitive manner " "[1]_. E.g. ``for option in parser[\"section\"]`` yields only " @@ -312,61 +547,67 @@ msgid "" "expressions return ``True``::" msgstr "" -#: library/configparser.rst:443 +#: library/configparser.rst:446 msgid "" -"All sections include ``DEFAULTSECT`` values as well which means that ``." -"clear()`` on a section may not leave the section visibly empty. This is " +"\"a\" in parser[\"section\"]\n" +"\"A\" in parser[\"section\"]" +msgstr "" + +#: library/configparser.rst:449 +msgid "" +"All sections include ``DEFAULTSECT`` values as well which means that " +"``.clear()`` on a section may not leave the section visibly empty. This is " "because default values cannot be deleted from the section (because " "technically they are not there). If they are overridden in the section, " "deleting causes the default value to be visible again. Trying to delete a " "default value causes a :exc:`KeyError`." msgstr "" -#: library/configparser.rst:450 +#: library/configparser.rst:456 msgid "``DEFAULTSECT`` cannot be removed from the parser:" msgstr "" -#: library/configparser.rst:452 +#: library/configparser.rst:458 msgid "trying to delete it raises :exc:`ValueError`," msgstr "" -#: library/configparser.rst:454 +#: library/configparser.rst:460 msgid "``parser.clear()`` leaves it intact," msgstr "" -#: library/configparser.rst:456 +#: library/configparser.rst:462 msgid "``parser.popitem()`` never returns it." msgstr "" -#: library/configparser.rst:458 +#: library/configparser.rst:464 msgid "" "``parser.get(section, option, **kwargs)`` - the second argument is **not** a " "fallback value. Note however that the section-level ``get()`` methods are " "compatible both with the mapping protocol and the classic configparser API." msgstr "" -#: library/configparser.rst:462 +#: library/configparser.rst:468 msgid "" "``parser.items()`` is compatible with the mapping protocol (returns a list " "of *section_name*, *section_proxy* pairs including the DEFAULTSECT). " -"However, this method can also be invoked with arguments: ``parser." -"items(section, raw, vars)``. The latter call returns a list of *option*, " -"*value* pairs for a specified ``section``, with all interpolations expanded " -"(unless ``raw=True`` is provided)." +"However, this method can also be invoked with arguments: " +"``parser.items(section, raw, vars)``. The latter call returns a list of " +"*option*, *value* pairs for a specified ``section``, with all interpolations " +"expanded (unless ``raw=True`` is provided)." msgstr "" -#: library/configparser.rst:469 +#: library/configparser.rst:475 msgid "" "The mapping protocol is implemented on top of the existing legacy API so " "that subclasses overriding the original interface still should have mappings " "working as expected." msgstr "" -#: library/configparser.rst:475 +#: library/configparser.rst:481 msgid "Customizing Parser Behaviour" msgstr "" -#: library/configparser.rst:477 +#: library/configparser.rst:483 msgid "" "There are nearly as many INI format variants as there are applications using " "it. :mod:`configparser` goes a long way to provide support for the largest " @@ -375,17 +616,17 @@ msgid "" "customize some of the features." msgstr "" -#: library/configparser.rst:483 +#: library/configparser.rst:489 msgid "" "The most common way to change the way a specific config parser works is to " "use the :meth:`!__init__` options:" msgstr "" -#: library/configparser.rst:486 +#: library/configparser.rst:492 msgid "*defaults*, default value: ``None``" msgstr "" -#: library/configparser.rst:488 +#: library/configparser.rst:494 msgid "" "This option accepts a dictionary of key-value pairs which will be initially " "put in the ``DEFAULT`` section. This makes for an elegant way to support " @@ -393,17 +634,17 @@ msgid "" "the documented default." msgstr "" -#: library/configparser.rst:493 +#: library/configparser.rst:499 msgid "" -"Hint: if you want to specify default values for a specific section, use :" -"meth:`~ConfigParser.read_dict` before you read the actual file." +"Hint: if you want to specify default values for a specific section, " +"use :meth:`~ConfigParser.read_dict` before you read the actual file." msgstr "" -#: library/configparser.rst:496 +#: library/configparser.rst:502 msgid "*dict_type*, default value: :class:`dict`" msgstr "" -#: library/configparser.rst:498 +#: library/configparser.rst:504 msgid "" "This option has a major impact on how the mapping protocol will behave and " "how the written configuration files look. With the standard dictionary, " @@ -411,24 +652,43 @@ msgid "" "goes for options within sections." msgstr "" -#: library/configparser.rst:503 +#: library/configparser.rst:509 msgid "" "An alternative dictionary type can be used for example to sort sections and " "options on write-back." msgstr "" -#: library/configparser.rst:506 +#: library/configparser.rst:512 msgid "" "Please note: there are ways to add a set of key-value pairs in a single " "operation. When you use a regular dictionary in those operations, the order " "of the keys will be ordered. For example:" msgstr "" -#: library/configparser.rst:528 +#: library/configparser.rst:516 +msgid "" +">>> parser = configparser.ConfigParser()\n" +">>> parser.read_dict({'section1': {'key1': 'value1',\n" +"... 'key2': 'value2',\n" +"... 'key3': 'value3'},\n" +"... 'section2': {'keyA': 'valueA',\n" +"... 'keyB': 'valueB',\n" +"... 'keyC': 'valueC'},\n" +"... 'section3': {'foo': 'x',\n" +"... 'bar': 'y',\n" +"... 'baz': 'z'}\n" +"... })\n" +">>> parser.sections()\n" +"['section1', 'section2', 'section3']\n" +">>> [option for option in parser['section3']]\n" +"['foo', 'bar', 'baz']" +msgstr "" + +#: library/configparser.rst:534 msgid "*allow_no_value*, default value: ``False``" msgstr "" -#: library/configparser.rst:530 +#: library/configparser.rst:536 msgid "" "Some configuration files are known to include settings without values, but " "which otherwise conform to the syntax supported by :mod:`configparser`. The " @@ -436,32 +696,63 @@ msgid "" "such values should be accepted:" msgstr "" -#: library/configparser.rst:565 +#: library/configparser.rst:541 +msgid "" +">>> import configparser\n" +"\n" +">>> sample_config = \"\"\"\n" +"... [mysqld]\n" +"... user = mysql\n" +"... pid-file = /var/run/mysqld/mysqld.pid\n" +"... skip-external-locking\n" +"... old_passwords = 1\n" +"... skip-bdb\n" +"... # we don't need ACID today\n" +"... skip-innodb\n" +"... \"\"\"\n" +">>> config = configparser.ConfigParser(allow_no_value=True)\n" +">>> config.read_string(sample_config)\n" +"\n" +">>> # Settings with values are treated as before:\n" +">>> config[\"mysqld\"][\"user\"]\n" +"'mysql'\n" +"\n" +">>> # Settings without values provide None:\n" +">>> config[\"mysqld\"][\"skip-bdb\"]\n" +"\n" +">>> # Settings which aren't specified still raise an error:\n" +">>> config[\"mysqld\"][\"does-not-exist\"]\n" +"Traceback (most recent call last):\n" +" ...\n" +"KeyError: 'does-not-exist'" +msgstr "" + +#: library/configparser.rst:571 msgid "*delimiters*, default value: ``('=', ':')``" msgstr "" -#: library/configparser.rst:567 +#: library/configparser.rst:573 msgid "" "Delimiters are substrings that delimit keys from values within a section. " "The first occurrence of a delimiting substring on a line is considered a " "delimiter. This means values (but not keys) can contain the delimiters." msgstr "" -#: library/configparser.rst:571 +#: library/configparser.rst:577 msgid "" -"See also the *space_around_delimiters* argument to :meth:`ConfigParser." -"write`." +"See also the *space_around_delimiters* argument " +"to :meth:`ConfigParser.write`." msgstr "" -#: library/configparser.rst:574 +#: library/configparser.rst:580 msgid "*comment_prefixes*, default value: ``('#', ';')``" msgstr "" -#: library/configparser.rst:576 +#: library/configparser.rst:582 msgid "*inline_comment_prefixes*, default value: ``None``" msgstr "" -#: library/configparser.rst:578 +#: library/configparser.rst:584 msgid "" "Comment prefixes are strings that indicate the start of a valid comment " "within a config file. *comment_prefixes* are used only on otherwise empty " @@ -471,13 +762,13 @@ msgid "" "used as prefixes for whole line comments." msgstr "" -#: library/configparser.rst:585 +#: library/configparser.rst:591 msgid "" "In previous versions of :mod:`configparser` behaviour matched " "``comment_prefixes=('#',';')`` and ``inline_comment_prefixes=(';',)``." msgstr "" -#: library/configparser.rst:589 +#: library/configparser.rst:595 msgid "" "Please note that config parsers don't support escaping of comment prefixes " "so using *inline_comment_prefixes* may prevent users from specifying option " @@ -487,29 +778,72 @@ msgid "" "values is to interpolate the prefix, for example::" msgstr "" -#: library/configparser.rst:635 +#: library/configparser.rst:602 +msgid "" +">>> from configparser import ConfigParser, ExtendedInterpolation\n" +">>> parser = ConfigParser(interpolation=ExtendedInterpolation())\n" +">>> # the default BasicInterpolation could be used as well\n" +">>> parser.read_string(\"\"\"\n" +"... [DEFAULT]\n" +"... hash = #\n" +"...\n" +"... [hashes]\n" +"... shebang =\n" +"... ${hash}!/usr/bin/env python\n" +"... ${hash} -*- coding: utf-8 -*-\n" +"...\n" +"... extensions =\n" +"... enabled_extension\n" +"... another_extension\n" +"... #disabled_by_comment\n" +"... yet_another_extension\n" +"...\n" +"... interpolation not necessary = if # is not at line start\n" +"... even in multiline values = line #1\n" +"... line #2\n" +"... line #3\n" +"... \"\"\")\n" +">>> print(parser['hashes']['shebang'])\n" +"\n" +"#!/usr/bin/env python\n" +"# -*- coding: utf-8 -*-\n" +">>> print(parser['hashes']['extensions'])\n" +"\n" +"enabled_extension\n" +"another_extension\n" +"yet_another_extension\n" +">>> print(parser['hashes']['interpolation not necessary'])\n" +"if # is not at line start\n" +">>> print(parser['hashes']['even in multiline values'])\n" +"line #1\n" +"line #2\n" +"line #3" +msgstr "" + +#: library/configparser.rst:641 msgid "*strict*, default value: ``True``" msgstr "" -#: library/configparser.rst:637 +#: library/configparser.rst:643 msgid "" "When set to ``True``, the parser will not allow for any section or option " -"duplicates while reading from a single source (using :meth:`~ConfigParser." -"read_file`, :meth:`~ConfigParser.read_string` or :meth:`~ConfigParser." -"read_dict`). It is recommended to use strict parsers in new applications." +"duplicates while reading from a single source " +"(using :meth:`~ConfigParser.read_file`, :meth:`~ConfigParser.read_string` " +"or :meth:`~ConfigParser.read_dict`). It is recommended to use strict " +"parsers in new applications." msgstr "" -#: library/configparser.rst:642 +#: library/configparser.rst:648 msgid "" "In previous versions of :mod:`configparser` behaviour matched " "``strict=False``." msgstr "" -#: library/configparser.rst:646 +#: library/configparser.rst:652 msgid "*empty_lines_in_values*, default value: ``True``" msgstr "" -#: library/configparser.rst:648 +#: library/configparser.rst:654 msgid "" "In config parsers, values can span multiple lines as long as they are " "indented more than the key that holds them. By default parsers also let " @@ -519,7 +853,16 @@ msgid "" "lose track of the file structure. Take for instance:" msgstr "" -#: library/configparser.rst:663 +#: library/configparser.rst:661 +msgid "" +"[Section]\n" +"key = multiline\n" +" value with a gotcha\n" +"\n" +" this = is still a part of the multiline value of 'key'" +msgstr "" + +#: library/configparser.rst:669 msgid "" "This can be especially problematic for the user to see if she's using a " "proportional font to edit the file. That is why when your application does " @@ -528,13 +871,13 @@ msgid "" "would produce two keys, ``key`` and ``this``." msgstr "" -#: library/configparser.rst:669 +#: library/configparser.rst:675 msgid "" "*default_section*, default value: ``configparser.DEFAULTSECT`` (that is: " "``\"DEFAULT\"``)" msgstr "" -#: library/configparser.rst:672 +#: library/configparser.rst:678 msgid "" "The convention of allowing a special section of default values for other " "sections or interpolation purposes is a powerful concept of this library, " @@ -543,44 +886,44 @@ msgid "" "other valid section name. Some typical values include: ``\"general\"`` or " "``\"common\"``. The name provided is used for recognizing default sections " "when reading from any source and is used when writing configuration back to " -"a file. Its current value can be retrieved using the ``parser_instance." -"default_section`` attribute and may be modified at runtime (i.e. to convert " -"files from one format to another)." +"a file. Its current value can be retrieved using the " +"``parser_instance.default_section`` attribute and may be modified at runtime " +"(i.e. to convert files from one format to another)." msgstr "" -#: library/configparser.rst:683 +#: library/configparser.rst:689 msgid "*interpolation*, default value: ``configparser.BasicInterpolation``" msgstr "" -#: library/configparser.rst:685 +#: library/configparser.rst:691 msgid "" "Interpolation behaviour may be customized by providing a custom handler " "through the *interpolation* argument. ``None`` can be used to turn off " "interpolation completely, ``ExtendedInterpolation()`` provides a more " "advanced variant inspired by ``zc.buildout``. More on the subject in the " -"`dedicated documentation section <#interpolation-of-values>`_. :class:" -"`RawConfigParser` has a default value of ``None``." +"`dedicated documentation section <#interpolation-of-" +"values>`_. :class:`RawConfigParser` has a default value of ``None``." msgstr "" -#: library/configparser.rst:692 +#: library/configparser.rst:698 msgid "*converters*, default value: not set" msgstr "" -#: library/configparser.rst:694 +#: library/configparser.rst:700 msgid "" "Config parsers provide option value getters that perform type conversion. " "By default :meth:`~ConfigParser.getint`, :meth:`~ConfigParser.getfloat`, " "and :meth:`~ConfigParser.getboolean` are implemented. Should other getters " "be desirable, users may define them in a subclass or pass a dictionary where " "each key is a name of the converter and each value is a callable " -"implementing said conversion. For instance, passing ``{'decimal': decimal." -"Decimal}`` would add :meth:`!getdecimal` on both the parser object and all " -"section proxies. In other words, it will be possible to write both " +"implementing said conversion. For instance, passing ``{'decimal': " +"decimal.Decimal}`` would add :meth:`!getdecimal` on both the parser object " +"and all section proxies. In other words, it will be possible to write both " "``parser_instance.getdecimal('section', 'key', fallback=0)`` and " "``parser_instance['section'].getdecimal('key', 0)``." msgstr "" -#: library/configparser.rst:705 +#: library/configparser.rst:711 msgid "" "If the converter needs to access the state of the parser, it can be " "implemented as a method on a config parser subclass. If the name of this " @@ -588,14 +931,14 @@ msgid "" "the dict-compatible form (see the ``getdecimal()`` example above)." msgstr "" -#: library/configparser.rst:710 +#: library/configparser.rst:716 msgid "" "More advanced customization may be achieved by overriding default values of " "these parser attributes. The defaults are defined on the classes, so they " "may be overridden by subclasses or by attribute assignment." msgstr "" -#: library/configparser.rst:716 +#: library/configparser.rst:722 msgid "" "By default when using :meth:`~ConfigParser.getboolean`, config parsers " "consider the following values ``True``: ``'1'``, ``'yes'``, ``'true'``, " @@ -604,13 +947,26 @@ msgid "" "strings and their Boolean outcomes. For example:" msgstr "" -#: library/configparser.rst:734 +#: library/configparser.rst:728 +msgid "" +">>> custom = configparser.ConfigParser()\n" +">>> custom['section1'] = {'funky': 'nope'}\n" +">>> custom['section1'].getboolean('funky')\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: Not a boolean: nope\n" +">>> custom.BOOLEAN_STATES = {'sure': True, 'nope': False}\n" +">>> custom['section1'].getboolean('funky')\n" +"False" +msgstr "" + +#: library/configparser.rst:740 msgid "" "Other typical Boolean pairs include ``accept``/``reject`` or ``enabled``/" "``disabled``." msgstr "" -#: library/configparser.rst:740 +#: library/configparser.rst:746 msgid "" "This method transforms option names on every read, get, or set operation. " "The default converts the name to lowercase. This also means that when a " @@ -618,14 +974,38 @@ msgid "" "method if that's unsuitable. For example:" msgstr "" -#: library/configparser.rst:770 +#: library/configparser.rst:752 +msgid "" +">>> config = \"\"\"\n" +"... [Section1]\n" +"... Key = Value\n" +"...\n" +"... [Section2]\n" +"... AnotherKey = Value\n" +"... \"\"\"\n" +">>> typical = configparser.ConfigParser()\n" +">>> typical.read_string(config)\n" +">>> list(typical['Section1'].keys())\n" +"['key']\n" +">>> list(typical['Section2'].keys())\n" +"['anotherkey']\n" +">>> custom = configparser.RawConfigParser()\n" +">>> custom.optionxform = lambda option: option\n" +">>> custom.read_string(config)\n" +">>> list(custom['Section1'].keys())\n" +"['Key']\n" +">>> list(custom['Section2'].keys())\n" +"['AnotherKey']" +msgstr "" + +#: library/configparser.rst:776 msgid "" "The optionxform function transforms option names to a canonical form. This " "should be an idempotent function: if the name is already in canonical form, " "it should be returned unchanged." msgstr "" -#: library/configparser.rst:777 +#: library/configparser.rst:783 msgid "" "A compiled regular expression used to parse section headers. The default " "matches ``[section]`` to the name ``\"section\"``. Whitespace is considered " @@ -634,18 +1014,39 @@ msgid "" "example:" msgstr "" -#: library/configparser.rst:805 +#: library/configparser.rst:789 +msgid "" +">>> import re\n" +">>> config = \"\"\"\n" +"... [Section 1]\n" +"... option = value\n" +"...\n" +"... [ Section 2 ]\n" +"... another = val\n" +"... \"\"\"\n" +">>> typical = configparser.ConfigParser()\n" +">>> typical.read_string(config)\n" +">>> typical.sections()\n" +"['Section 1', ' Section 2 ']\n" +">>> custom = configparser.ConfigParser()\n" +">>> custom.SECTCRE = re.compile(r\"\\[ *(?P

[^]]+?) *\\]\")\n" +">>> custom.read_string(config)\n" +">>> custom.sections()\n" +"['Section 1', 'Section 2']" +msgstr "" + +#: library/configparser.rst:811 msgid "" "While ConfigParser objects also use an ``OPTCRE`` attribute for recognizing " "option lines, it's not recommended to override it because that would " "interfere with constructor options *allow_no_value* and *delimiters*." msgstr "" -#: library/configparser.rst:811 +#: library/configparser.rst:817 msgid "Legacy API Examples" msgstr "" -#: library/configparser.rst:813 +#: library/configparser.rst:819 msgid "" "Mainly because of backwards compatibility concerns, :mod:`configparser` " "provides also a legacy API with explicit ``get``/``set`` methods. While " @@ -654,29 +1055,121 @@ msgid "" "advanced, low-level and downright counterintuitive." msgstr "" -#: library/configparser.rst:819 +#: library/configparser.rst:825 msgid "An example of writing to a configuration file::" msgstr "" -#: library/configparser.rst:842 +#: library/configparser.rst:827 +msgid "" +"import configparser\n" +"\n" +"config = configparser.RawConfigParser()\n" +"\n" +"# Please note that using RawConfigParser's set functions, you can assign\n" +"# non-string values to keys internally, but will receive an error when\n" +"# attempting to write to a file or when you get it in non-raw mode. Setting\n" +"# values using the mapping protocol or ConfigParser's set() does not allow\n" +"# such assignments to take place.\n" +"config.add_section('Section1')\n" +"config.set('Section1', 'an_int', '15')\n" +"config.set('Section1', 'a_bool', 'true')\n" +"config.set('Section1', 'a_float', '3.1415')\n" +"config.set('Section1', 'baz', 'fun')\n" +"config.set('Section1', 'bar', 'Python')\n" +"config.set('Section1', 'foo', '%(bar)s is %(baz)s!')\n" +"\n" +"# Writing our configuration file to 'example.cfg'\n" +"with open('example.cfg', 'w') as configfile:\n" +" config.write(configfile)" +msgstr "" + +#: library/configparser.rst:848 msgid "An example of reading the configuration file again::" msgstr "" -#: library/configparser.rst:860 +#: library/configparser.rst:850 +msgid "" +"import configparser\n" +"\n" +"config = configparser.RawConfigParser()\n" +"config.read('example.cfg')\n" +"\n" +"# getfloat() raises an exception if the value is not a float\n" +"# getint() and getboolean() also do this for their respective types\n" +"a_float = config.getfloat('Section1', 'a_float')\n" +"an_int = config.getint('Section1', 'an_int')\n" +"print(a_float + an_int)\n" +"\n" +"# Notice that the next output does not interpolate '%(bar)s' or '%(baz)s'.\n" +"# This is because we are using a RawConfigParser().\n" +"if config.getboolean('Section1', 'a_bool'):\n" +" print(config.get('Section1', 'foo'))" +msgstr "" + +#: library/configparser.rst:866 msgid "To get interpolation, use :class:`ConfigParser`::" msgstr "" -#: library/configparser.rst:893 +#: library/configparser.rst:868 +msgid "" +"import configparser\n" +"\n" +"cfg = configparser.ConfigParser()\n" +"cfg.read('example.cfg')\n" +"\n" +"# Set the optional *raw* argument of get() to True if you wish to disable\n" +"# interpolation in a single get operation.\n" +"print(cfg.get('Section1', 'foo', raw=False)) # -> \"Python is fun!\"\n" +"print(cfg.get('Section1', 'foo', raw=True)) # -> \"%(bar)s is %(baz)s!\"\n" +"\n" +"# The optional *vars* argument is a dict with members that will take\n" +"# precedence in interpolation.\n" +"print(cfg.get('Section1', 'foo', vars={'bar': 'Documentation',\n" +" 'baz': 'evil'}))\n" +"\n" +"# The optional *fallback* argument can be used to provide a fallback value\n" +"print(cfg.get('Section1', 'foo'))\n" +" # -> \"Python is fun!\"\n" +"\n" +"print(cfg.get('Section1', 'foo', fallback='Monty is not.'))\n" +" # -> \"Python is fun!\"\n" +"\n" +"print(cfg.get('Section1', 'monster', fallback='No such things as " +"monsters.'))\n" +" # -> \"No such things as monsters.\"\n" +"\n" +"# A bare print(cfg.get('Section1', 'monster')) would raise NoOptionError\n" +"# but we can also use:\n" +"\n" +"print(cfg.get('Section1', 'monster', fallback=None))\n" +" # -> None" +msgstr "" + +#: library/configparser.rst:899 msgid "" "Default values are available in both types of ConfigParsers. They are used " "in interpolation if an option used is not defined elsewhere. ::" msgstr "" -#: library/configparser.rst:911 +#: library/configparser.rst:902 +msgid "" +"import configparser\n" +"\n" +"# New instance with 'bar' and 'baz' defaulting to 'Life' and 'hard' each\n" +"config = configparser.ConfigParser({'bar': 'Life', 'baz': 'hard'})\n" +"config.read('example.cfg')\n" +"\n" +"print(config.get('Section1', 'foo')) # -> \"Python is fun!\"\n" +"config.remove_option('Section1', 'bar')\n" +"config.remove_option('Section1', 'baz')\n" +"print(config.get('Section1', 'foo')) # -> \"Life is hard!\"" +msgstr "" + +#: library/configparser.rst:917 msgid "ConfigParser Objects" msgstr "" -#: library/configparser.rst:915 +#: library/configparser.rst:921 msgid "" "The main configuration parser. When *defaults* is given, it is initialized " "into the dictionary of intrinsic defaults. When *dict_type* is given, it " @@ -684,7 +1177,7 @@ msgid "" "the options within a section, and for the default values." msgstr "" -#: library/configparser.rst:920 +#: library/configparser.rst:926 msgid "" "When *delimiters* is given, it is used as the set of substrings that divide " "keys from values. When *comment_prefixes* is given, it will be used as the " @@ -693,20 +1186,20 @@ msgid "" "as the set of substrings that prefix comments in non-empty lines." msgstr "" -#: library/configparser.rst:926 +#: library/configparser.rst:932 msgid "" "When *strict* is ``True`` (the default), the parser won't allow for any " "section or option duplicates while reading from a single source (file, " -"string or dictionary), raising :exc:`DuplicateSectionError` or :exc:" -"`DuplicateOptionError`. When *empty_lines_in_values* is ``False`` (default: " -"``True``), each empty line marks the end of an option. Otherwise, internal " -"empty lines of a multiline option are kept as part of the value. When " -"*allow_no_value* is ``True`` (default: ``False``), options without values " -"are accepted; the value held for these is ``None`` and they are serialized " -"without the trailing delimiter." +"string or dictionary), raising :exc:`DuplicateSectionError` " +"or :exc:`DuplicateOptionError`. When *empty_lines_in_values* is ``False`` " +"(default: ``True``), each empty line marks the end of an option. Otherwise, " +"internal empty lines of a multiline option are kept as part of the value. " +"When *allow_no_value* is ``True`` (default: ``False``), options without " +"values are accepted; the value held for these is ``None`` and they are " +"serialized without the trailing delimiter." msgstr "" -#: library/configparser.rst:936 +#: library/configparser.rst:942 msgid "" "When *default_section* is given, it specifies the name for the special " "section holding default values for other sections and interpolation purposes " @@ -716,7 +1209,7 @@ msgid "" "settings to a new config file." msgstr "" -#: library/configparser.rst:943 +#: library/configparser.rst:949 msgid "" "Interpolation behaviour may be customized by providing a custom handler " "through the *interpolation* argument. ``None`` can be used to turn off " @@ -725,62 +1218,62 @@ msgid "" "`dedicated documentation section <#interpolation-of-values>`_." msgstr "" -#: library/configparser.rst:949 +#: library/configparser.rst:955 msgid "" -"All option names used in interpolation will be passed through the :meth:" -"`optionxform` method just like any other option name reference. For " -"example, using the default implementation of :meth:`optionxform` (which " -"converts option names to lower case), the values ``foo %(bar)s`` and ``foo " -"%(BAR)s`` are equivalent." +"All option names used in interpolation will be passed through " +"the :meth:`optionxform` method just like any other option name reference. " +"For example, using the default implementation of :meth:`optionxform` (which " +"converts option names to lower case), the values ``foo %(bar)s`` and ``foo %" +"(BAR)s`` are equivalent." msgstr "" -#: library/configparser.rst:955 +#: library/configparser.rst:961 msgid "" "When *converters* is given, it should be a dictionary where each key " "represents the name of a type converter and each value is a callable " "implementing the conversion from string to the desired datatype. Every " -"converter gets its own corresponding :meth:`!get*()` method on the parser " +"converter gets its own corresponding :meth:`!get*` method on the parser " "object and section proxies." msgstr "" -#: library/configparser.rst:961 +#: library/configparser.rst:992 msgid "The default *dict_type* is :class:`collections.OrderedDict`." msgstr "" -#: library/configparser.rst:964 +#: library/configparser.rst:995 msgid "" "*allow_no_value*, *delimiters*, *comment_prefixes*, *strict*, " "*empty_lines_in_values*, *default_section* and *interpolation* were added." msgstr "" -#: library/configparser.rst:969 +#: library/configparser.rst:1000 msgid "The *converters* argument was added." msgstr "" -#: library/configparser.rst:972 +#: library/configparser.rst:1003 msgid "" -"The *defaults* argument is read with :meth:`read_dict()`, providing " -"consistent behavior across the parser: non-string keys and values are " -"implicitly converted to strings." +"The *defaults* argument is read with :meth:`read_dict`, providing consistent " +"behavior across the parser: non-string keys and values are implicitly " +"converted to strings." msgstr "" -#: library/configparser.rst:1240 +#: library/configparser.rst:1271 msgid "" "The default *dict_type* is :class:`dict`, since it now preserves insertion " "order." msgstr "" -#: library/configparser.rst:983 +#: library/configparser.rst:1014 msgid "Return a dictionary containing the instance-wide defaults." msgstr "" -#: library/configparser.rst:988 +#: library/configparser.rst:1019 msgid "" "Return a list of the sections available; the *default section* is not " "included in the list." msgstr "" -#: library/configparser.rst:994 +#: library/configparser.rst:1025 msgid "" "Add a section named *section* to the instance. If a section by the given " "name already exists, :exc:`DuplicateSectionError` is raised. If the " @@ -788,34 +1281,34 @@ msgid "" "the section must be a string; if not, :exc:`TypeError` is raised." msgstr "" -#: library/configparser.rst:999 +#: library/configparser.rst:1030 msgid "Non-string section names raise :exc:`TypeError`." msgstr "" -#: library/configparser.rst:1005 +#: library/configparser.rst:1036 msgid "" "Indicates whether the named *section* is present in the configuration. The " "*default section* is not acknowledged." msgstr "" -#: library/configparser.rst:1011 +#: library/configparser.rst:1042 msgid "Return a list of options available in the specified *section*." msgstr "" -#: library/configparser.rst:1016 +#: library/configparser.rst:1047 msgid "" -"If the given *section* exists, and contains the given *option*, return :" -"const:`True`; otherwise return :const:`False`. If the specified *section* " -"is :const:`None` or an empty string, DEFAULT is assumed." +"If the given *section* exists, and contains the given *option*, " +"return :const:`True`; otherwise return :const:`False`. If the specified " +"*section* is :const:`None` or an empty string, DEFAULT is assumed." msgstr "" -#: library/configparser.rst:1023 +#: library/configparser.rst:1054 msgid "" "Attempt to read and parse an iterable of filenames, returning a list of " "filenames which were successfully parsed." msgstr "" -#: library/configparser.rst:1026 +#: library/configparser.rst:1057 msgid "" "If *filenames* is a string, a :class:`bytes` object or a :term:`path-like " "object`, it is treated as a single filename. If a file named in *filenames* " @@ -826,57 +1319,67 @@ msgid "" "be read." msgstr "" -#: library/configparser.rst:1035 +#: library/configparser.rst:1066 msgid "" "If none of the named files exist, the :class:`ConfigParser` instance will " "contain an empty dataset. An application which requires initial values to " -"be loaded from a file should load the required file or files using :meth:" -"`read_file` before calling :meth:`read` for any optional files::" +"be loaded from a file should load the required file or files " +"using :meth:`read_file` before calling :meth:`read` for any optional files::" +msgstr "" + +#: library/configparser.rst:1072 +msgid "" +"import configparser, os\n" +"\n" +"config = configparser.ConfigParser()\n" +"config.read_file(open('defaults.cfg'))\n" +"config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')],\n" +" encoding='cp1250')" msgstr "" -#: library/configparser.rst:1048 +#: library/configparser.rst:1079 msgid "" "Added the *encoding* parameter. Previously, all files were read using the " "default encoding for :func:`open`." msgstr "" -#: library/configparser.rst:1052 +#: library/configparser.rst:1083 msgid "The *filenames* parameter accepts a :term:`path-like object`." msgstr "" -#: library/configparser.rst:1055 +#: library/configparser.rst:1086 msgid "The *filenames* parameter accepts a :class:`bytes` object." msgstr "" -#: library/configparser.rst:1061 +#: library/configparser.rst:1092 msgid "" "Read and parse configuration data from *f* which must be an iterable " "yielding Unicode strings (for example files opened in text mode)." msgstr "" -#: library/configparser.rst:1064 +#: library/configparser.rst:1095 msgid "" "Optional argument *source* specifies the name of the file being read. If " "not given and *f* has a :attr:`!name` attribute, that is used for *source*; " "the default is ``''``." msgstr "" -#: library/configparser.rst:1068 +#: library/configparser.rst:1099 msgid "Replaces :meth:`!readfp`." msgstr "" -#: library/configparser.rst:1073 +#: library/configparser.rst:1104 msgid "Parse configuration data from a string." msgstr "" -#: library/configparser.rst:1075 +#: library/configparser.rst:1106 msgid "" "Optional argument *source* specifies a context-specific name of the string " "passed. If not given, ``''`` is used. This should commonly be a " "filesystem path or a URL." msgstr "" -#: library/configparser.rst:1084 +#: library/configparser.rst:1115 msgid "" "Load configuration from any object that provides a dict-like ``items()`` " "method. Keys are section names, values are dictionaries with keys and " @@ -885,17 +1388,17 @@ msgid "" "automatically converted to strings." msgstr "" -#: library/configparser.rst:1090 +#: library/configparser.rst:1121 msgid "" "Optional argument *source* specifies a context-specific name of the " "dictionary passed. If not given, ```` is used." msgstr "" -#: library/configparser.rst:1093 +#: library/configparser.rst:1124 msgid "This method can be used to copy state between parsers." msgstr "" -#: library/configparser.rst:1100 +#: library/configparser.rst:1131 msgid "" "Get an *option* value for the named *section*. If *vars* is provided, it " "must be a dictionary. The *option* is looked up in *vars* (if provided), " @@ -904,74 +1407,74 @@ msgid "" "provided as a *fallback* value." msgstr "" -#: library/configparser.rst:1106 +#: library/configparser.rst:1137 msgid "" "All the ``'%'`` interpolations are expanded in the return values, unless the " "*raw* argument is true. Values for interpolation keys are looked up in the " "same manner as the option." msgstr "" -#: library/configparser.rst:1110 +#: library/configparser.rst:1141 msgid "" "Arguments *raw*, *vars* and *fallback* are keyword only to protect users " "from trying to use the third argument as the *fallback* fallback (especially " "when using the mapping protocol)." msgstr "" -#: library/configparser.rst:1118 +#: library/configparser.rst:1149 msgid "" "A convenience method which coerces the *option* in the specified *section* " "to an integer. See :meth:`get` for explanation of *raw*, *vars* and " "*fallback*." msgstr "" -#: library/configparser.rst:1125 +#: library/configparser.rst:1156 msgid "" "A convenience method which coerces the *option* in the specified *section* " -"to a floating point number. See :meth:`get` for explanation of *raw*, " +"to a floating-point number. See :meth:`get` for explanation of *raw*, " "*vars* and *fallback*." msgstr "" -#: library/configparser.rst:1132 +#: library/configparser.rst:1163 msgid "" "A convenience method which coerces the *option* in the specified *section* " "to a Boolean value. Note that the accepted values for the option are " "``'1'``, ``'yes'``, ``'true'``, and ``'on'``, which cause this method to " "return ``True``, and ``'0'``, ``'no'``, ``'false'``, and ``'off'``, which " "cause it to return ``False``. These string values are checked in a case-" -"insensitive manner. Any other value will cause it to raise :exc:" -"`ValueError`. See :meth:`get` for explanation of *raw*, *vars* and " -"*fallback*." +"insensitive manner. Any other value will cause it to " +"raise :exc:`ValueError`. See :meth:`get` for explanation of *raw*, *vars* " +"and *fallback*." msgstr "" -#: library/configparser.rst:1145 +#: library/configparser.rst:1176 msgid "" "When *section* is not given, return a list of *section_name*, " "*section_proxy* pairs, including DEFAULTSECT." msgstr "" -#: library/configparser.rst:1148 +#: library/configparser.rst:1179 msgid "" "Otherwise, return a list of *name*, *value* pairs for the options in the " -"given *section*. Optional arguments have the same meaning as for the :meth:" -"`get` method." +"given *section*. Optional arguments have the same meaning as for " +"the :meth:`get` method." msgstr "" -#: library/configparser.rst:1152 +#: library/configparser.rst:1183 msgid "" "Items present in *vars* no longer appear in the result. The previous " "behaviour mixed actual parser options with variables provided for " "interpolation." msgstr "" -#: library/configparser.rst:1160 +#: library/configparser.rst:1191 msgid "" "If the given section exists, set the given option to the specified value; " "otherwise raise :exc:`NoSectionError`. *option* and *value* must be " "strings; if not, :exc:`TypeError` is raised." msgstr "" -#: library/configparser.rst:1167 +#: library/configparser.rst:1198 msgid "" "Write a representation of the configuration to the specified :term:`file " "object`, which must be opened in text mode (accepting strings). This " @@ -980,27 +1483,27 @@ msgid "" "surrounded by spaces." msgstr "" -#: library/configparser.rst:1175 +#: library/configparser.rst:1206 msgid "" "Comments in the original configuration file are not preserved when writing " "the configuration back. What is considered a comment, depends on the given " "values for *comment_prefix* and *inline_comment_prefix*." msgstr "" -#: library/configparser.rst:1183 +#: library/configparser.rst:1214 msgid "" "Remove the specified *option* from the specified *section*. If the section " "does not exist, raise :exc:`NoSectionError`. If the option existed to be " "removed, return :const:`True`; otherwise return :const:`False`." msgstr "" -#: library/configparser.rst:1191 +#: library/configparser.rst:1222 msgid "" "Remove the specified *section* from the configuration. If the section in " "fact existed, return ``True``. Otherwise return ``False``." msgstr "" -#: library/configparser.rst:1197 +#: library/configparser.rst:1228 msgid "" "Transforms the option name *option* as found in an input file or as passed " "in by client code to the form that should be used in the internal " @@ -1009,7 +1512,7 @@ msgid "" "of this name on instances to affect this behavior." msgstr "" -#: library/configparser.rst:1203 +#: library/configparser.rst:1234 msgid "" "You don't need to subclass the parser to use this method, you can also set " "it on an instance, to a function that takes a string argument and returns a " @@ -1017,24 +1520,30 @@ msgid "" "sensitive::" msgstr "" -#: library/configparser.rst:1211 +#: library/configparser.rst:1239 +msgid "" +"cfgparser = ConfigParser()\n" +"cfgparser.optionxform = str" +msgstr "" + +#: library/configparser.rst:1242 msgid "" "Note that when reading configuration files, whitespace around the option " "names is stripped before :meth:`optionxform` is called." msgstr "" -#: library/configparser.rst:1217 +#: library/configparser.rst:1248 msgid "" -"The maximum depth for recursive interpolation for :meth:`~configparser." -"ConfigParser.get` when the *raw* parameter is false. This is relevant only " -"when the default *interpolation* is used." +"The maximum depth for recursive interpolation " +"for :meth:`~configparser.ConfigParser.get` when the *raw* parameter is " +"false. This is relevant only when the default *interpolation* is used." msgstr "" -#: library/configparser.rst:1225 +#: library/configparser.rst:1256 msgid "RawConfigParser Objects" msgstr "" -#: library/configparser.rst:1235 +#: library/configparser.rst:1266 msgid "" "Legacy variant of the :class:`ConfigParser`. It has interpolation disabled " "by default and allows for non-string section names, option names, and values " @@ -1042,37 +1551,37 @@ msgid "" "``defaults=`` keyword argument handling." msgstr "" -#: library/configparser.rst:1245 +#: library/configparser.rst:1276 msgid "" "Consider using :class:`ConfigParser` instead which checks types of the " "values to be stored internally. If you don't want interpolation, you can " "use ``ConfigParser(interpolation=None)``." msgstr "" -#: library/configparser.rst:1252 +#: library/configparser.rst:1283 msgid "" "Add a section named *section* to the instance. If a section by the given " "name already exists, :exc:`DuplicateSectionError` is raised. If the " "*default section* name is passed, :exc:`ValueError` is raised." msgstr "" -#: library/configparser.rst:1256 +#: library/configparser.rst:1287 msgid "" "Type of *section* is not checked which lets users create non-string named " "sections. This behaviour is unsupported and may cause internal errors." msgstr "" -#: library/configparser.rst:1262 +#: library/configparser.rst:1293 msgid "" "If the given section exists, set the given option to the specified value; " -"otherwise raise :exc:`NoSectionError`. While it is possible to use :class:" -"`RawConfigParser` (or :class:`ConfigParser` with *raw* parameters set to " -"true) for *internal* storage of non-string values, full functionality " +"otherwise raise :exc:`NoSectionError`. While it is possible to " +"use :class:`RawConfigParser` (or :class:`ConfigParser` with *raw* parameters " +"set to true) for *internal* storage of non-string values, full functionality " "(including interpolation and output to files) can only be achieved using " "string values." msgstr "" -#: library/configparser.rst:1269 +#: library/configparser.rst:1300 msgid "" "This method lets users assign non-string values to keys internally. This " "behaviour is unsupported and will cause errors when attempting to write to a " @@ -1080,32 +1589,32 @@ msgid "" "not allow such assignments to take place." msgstr "" -#: library/configparser.rst:1276 +#: library/configparser.rst:1307 msgid "Exceptions" msgstr "" -#: library/configparser.rst:1280 +#: library/configparser.rst:1311 msgid "Base class for all other :mod:`configparser` exceptions." msgstr "" -#: library/configparser.rst:1285 +#: library/configparser.rst:1316 msgid "Exception raised when a specified section is not found." msgstr "" -#: library/configparser.rst:1290 +#: library/configparser.rst:1321 msgid "" "Exception raised if :meth:`~ConfigParser.add_section` is called with the " "name of a section that is already present or in strict parsers when a " "section if found more than once in a single input file, string or dictionary." msgstr "" -#: library/configparser.rst:1294 +#: library/configparser.rst:1325 msgid "" -"Added the optional *source* and *lineno* attributes and parameters to :meth:" -"`!__init__`." +"Added the optional *source* and *lineno* attributes and parameters " +"to :meth:`!__init__`." msgstr "" -#: library/configparser.rst:1301 +#: library/configparser.rst:1332 msgid "" "Exception raised by strict parsers if a single option appears twice during " "reading from a single file, string or dictionary. This catches misspellings " @@ -1113,58 +1622,58 @@ msgid "" "representing the same case-insensitive configuration key." msgstr "" -#: library/configparser.rst:1309 +#: library/configparser.rst:1340 msgid "" "Exception raised when a specified option is not found in the specified " "section." msgstr "" -#: library/configparser.rst:1315 +#: library/configparser.rst:1346 msgid "" "Base class for exceptions raised when problems occur performing string " "interpolation." msgstr "" -#: library/configparser.rst:1321 +#: library/configparser.rst:1352 msgid "" "Exception raised when string interpolation cannot be completed because the " -"number of iterations exceeds :const:`MAX_INTERPOLATION_DEPTH`. Subclass of :" -"exc:`InterpolationError`." +"number of iterations exceeds :const:`MAX_INTERPOLATION_DEPTH`. Subclass " +"of :exc:`InterpolationError`." msgstr "" -#: library/configparser.rst:1328 +#: library/configparser.rst:1359 msgid "" "Exception raised when an option referenced from a value does not exist. " "Subclass of :exc:`InterpolationError`." msgstr "" -#: library/configparser.rst:1334 +#: library/configparser.rst:1365 msgid "" "Exception raised when the source text into which substitutions are made does " "not conform to the required syntax. Subclass of :exc:`InterpolationError`." msgstr "" -#: library/configparser.rst:1340 +#: library/configparser.rst:1371 msgid "" "Exception raised when attempting to parse a file which has no section " "headers." msgstr "" -#: library/configparser.rst:1346 +#: library/configparser.rst:1377 msgid "Exception raised when errors occur attempting to parse a file." msgstr "" -#: library/configparser.rst:1348 +#: library/configparser.rst:1379 msgid "" "The ``filename`` attribute and :meth:`!__init__` constructor argument were " "removed. They have been available using the name ``source`` since 3.2." msgstr "" -#: library/configparser.rst:1353 +#: library/configparser.rst:1384 msgid "Footnotes" msgstr "" -#: library/configparser.rst:1354 +#: library/configparser.rst:1385 msgid "" "Config parsers allow for heavy customization. If you are interested in " "changing the behaviour outlined by the footnote reference, consult the " @@ -1191,14 +1700,14 @@ msgstr "" msgid "Windows ini file" msgstr "" -#: library/configparser.rst:335 +#: library/configparser.rst:341 msgid "% (percent)" msgstr "" -#: library/configparser.rst:368 +#: library/configparser.rst:374 msgid "interpolation in configuration files" msgstr "" -#: library/configparser.rst:368 +#: library/configparser.rst:374 msgid "$ (dollar)" msgstr "" diff --git a/library/constants.po b/library/constants.po index 1e28244c..713a93a7 100644 --- a/library/constants.po +++ b/library/constants.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -46,14 +47,14 @@ msgstr "" #: library/constants.rst:30 msgid "" -"A special value which should be returned by the binary special methods (e." -"g. :meth:`~object.__eq__`, :meth:`~object.__lt__`, :meth:`~object.__add__`, :" -"meth:`~object.__rsub__`, etc.) to indicate that the operation is not " -"implemented with respect to the other type; may be returned by the in-place " -"binary special methods (e.g. :meth:`~object.__imul__`, :meth:`~object." -"__iand__`, etc.) for the same purpose. It should not be evaluated in a " -"boolean context. :data:`!NotImplemented` is the sole instance of the :data:" -"`types.NotImplementedType` type." +"A special value which should be returned by the binary special methods " +"(e.g. :meth:`~object.__eq__`, :meth:`~object.__lt__`, :meth:`~object.__add__`, :meth:`~object.__rsub__`, " +"etc.) to indicate that the operation is not implemented with respect to the " +"other type; may be returned by the in-place binary special methods " +"(e.g. :meth:`~object.__imul__`, :meth:`~object.__iand__`, etc.) for the same " +"purpose. It should not be evaluated in a boolean context. :data:`!" +"NotImplemented` is the sole instance of the :data:`types.NotImplementedType` " +"type." msgstr "" #: library/constants.rst:40 @@ -74,8 +75,8 @@ msgstr "" #: library/constants.rst:51 msgid "" "``NotImplementedError`` and :data:`!NotImplemented` are not interchangeable, " -"even though they have similar names and purposes. See :exc:" -"`NotImplementedError` for details on when to use it." +"even though they have similar names and purposes. " +"See :exc:`NotImplementedError` for details on when to use it." msgstr "" #: library/constants.rst:55 @@ -102,15 +103,15 @@ msgstr "" #: library/constants.rst:77 msgid "" "The names :data:`None`, :data:`False`, :data:`True` and :data:`__debug__` " -"cannot be reassigned (assignments to them, even as an attribute name, raise :" -"exc:`SyntaxError`), so they can be considered \"true\" constants." +"cannot be reassigned (assignments to them, even as an attribute name, " +"raise :exc:`SyntaxError`), so they can be considered \"true\" constants." msgstr "" -#: library/constants.rst:83 +#: library/constants.rst:85 msgid "Constants added by the :mod:`site` module" msgstr "" -#: library/constants.rst:85 +#: library/constants.rst:87 msgid "" "The :mod:`site` module (which is imported automatically during startup, " "except if the :option:`-S` command-line option is given) adds several " @@ -118,20 +119,27 @@ msgid "" "interpreter shell and should not be used in programs." msgstr "" -#: library/constants.rst:93 +#: library/constants.rst:95 msgid "" "Objects that when printed, print a message like \"Use quit() or Ctrl-D (i.e. " "EOF) to exit\", and when called, raise :exc:`SystemExit` with the specified " "exit code." msgstr "" -#: library/constants.rst:100 +#: library/constants.rst:102 +msgid "" +"Object that when printed, prints the message \"Type help() for interactive " +"help, or help(object) for help about object.\", and when called, acts as " +"described :func:`elsewhere `." +msgstr "" + +#: library/constants.rst:109 msgid "" "Objects that when printed or called, print the text of copyright or credits, " "respectively." msgstr "" -#: library/constants.rst:105 +#: library/constants.rst:114 msgid "" "Object that when printed, prints the message \"Type license() to see the " "full license text\", and when called, displays the full license text in a " diff --git a/library/contextlib.po b/library/contextlib.po index 62c6e6f8..c8b025ae 100644 --- a/library/contextlib.po +++ b/library/contextlib.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -27,9 +28,9 @@ msgstr "" #: library/contextlib.rst:11 msgid "" -"This module provides utilities for common tasks involving the :keyword:" -"`with` statement. For more information see also :ref:`typecontextmanager` " -"and :ref:`context-managers`." +"This module provides utilities for common tasks involving " +"the :keyword:`with` statement. For more information see " +"also :ref:`typecontextmanager` and :ref:`context-managers`." msgstr "" #: library/contextlib.rst:17 @@ -42,36 +43,38 @@ msgstr "" #: library/contextlib.rst:23 msgid "" -"An :term:`abstract base class` for classes that implement :meth:`object." -"__enter__` and :meth:`object.__exit__`. A default implementation for :meth:" -"`object.__enter__` is provided which returns ``self`` while :meth:`object." -"__exit__` is an abstract method which by default returns ``None``. See also " -"the definition of :ref:`typecontextmanager`." +"An :term:`abstract base class` for classes that " +"implement :meth:`object.__enter__` and :meth:`object.__exit__`. A default " +"implementation for :meth:`object.__enter__` is provided which returns " +"``self`` while :meth:`object.__exit__` is an abstract method which by " +"default returns ``None``. See also the definition " +"of :ref:`typecontextmanager`." msgstr "" #: library/contextlib.rst:34 msgid "" -"An :term:`abstract base class` for classes that implement :meth:`object." -"__aenter__` and :meth:`object.__aexit__`. A default implementation for :meth:" -"`object.__aenter__` is provided which returns ``self`` while :meth:`object." -"__aexit__` is an abstract method which by default returns ``None``. See also " -"the definition of :ref:`async-context-managers`." +"An :term:`abstract base class` for classes that " +"implement :meth:`object.__aenter__` and :meth:`object.__aexit__`. A default " +"implementation for :meth:`object.__aenter__` is provided which returns " +"``self`` while :meth:`object.__aexit__` is an abstract method which by " +"default returns ``None``. See also the definition of :ref:`async-context-" +"managers`." msgstr "" #: library/contextlib.rst:46 msgid "" "This function is a :term:`decorator` that can be used to define a factory " "function for :keyword:`with` statement context managers, without needing to " -"create a class or separate :meth:`~object.__enter__` and :meth:`~object." -"__exit__` methods." +"create a class or separate :meth:`~object.__enter__` " +"and :meth:`~object.__exit__` methods." msgstr "" #: library/contextlib.rst:50 msgid "" "While many objects natively support use in with statements, sometimes a " "resource needs to be managed that isn't a context manager in its own right, " -"and doesn't implement a ``close()`` method for use with ``contextlib." -"closing``" +"and doesn't implement a ``close()`` method for use with " +"``contextlib.closing``" msgstr "" #: library/contextlib.rst:54 @@ -80,10 +83,32 @@ msgid "" "management::" msgstr "" +#: library/contextlib.rst:57 +msgid "" +"from contextlib import contextmanager\n" +"\n" +"@contextmanager\n" +"def managed_resource(*args, **kwds):\n" +" # Code to acquire resource, e.g.:\n" +" resource = acquire_resource(*args, **kwds)\n" +" try:\n" +" yield resource\n" +" finally:\n" +" # Code to release resource, e.g.:\n" +" release_resource(resource)" +msgstr "" + #: library/contextlib.rst:69 msgid "The function can then be used like this::" msgstr "" +#: library/contextlib.rst:71 +msgid "" +">>> with managed_resource(timeout=3600) as resource:\n" +"... # Resource is released at the end of this block,\n" +"... # even if code in the block raises an exception" +msgstr "" + #: library/contextlib.rst:75 msgid "" "The function being decorated must return a :term:`generator`-iterator when " @@ -93,18 +118,18 @@ msgstr "" #: library/contextlib.rst:79 msgid "" -"At the point where the generator yields, the block nested in the :keyword:" -"`with` statement is executed. The generator is then resumed after the block " -"is exited. If an unhandled exception occurs in the block, it is reraised " -"inside the generator at the point where the yield occurred. Thus, you can " -"use a :keyword:`try`...\\ :keyword:`except`...\\ :keyword:`finally` " -"statement to trap the error (if any), or ensure that some cleanup takes " -"place. If an exception is trapped merely in order to log it or to perform " -"some action (rather than to suppress it entirely), the generator must " -"reraise that exception. Otherwise the generator context manager will " -"indicate to the :keyword:`!with` statement that the exception has been " -"handled, and execution will resume with the statement immediately following " -"the :keyword:`!with` statement." +"At the point where the generator yields, the block nested in " +"the :keyword:`with` statement is executed. The generator is then resumed " +"after the block is exited. If an unhandled exception occurs in the block, it " +"is reraised inside the generator at the point where the yield occurred. " +"Thus, you can use a :keyword:`try`...\\ :keyword:`except`..." +"\\ :keyword:`finally` statement to trap the error (if any), or ensure that " +"some cleanup takes place. If an exception is trapped merely in order to log " +"it or to perform some action (rather than to suppress it entirely), the " +"generator must reraise that exception. Otherwise the generator context " +"manager will indicate to the :keyword:`!with` statement that the exception " +"has been handled, and execution will resume with the statement immediately " +"following the :keyword:`!with` statement." msgstr "" #: library/contextlib.rst:91 @@ -124,8 +149,8 @@ msgstr "" #: library/contextlib.rst:104 msgid "" -"Similar to :func:`~contextlib.contextmanager`, but creates an :ref:" -"`asynchronous context manager `." +"Similar to :func:`~contextlib.contextmanager`, but creates " +"an :ref:`asynchronous context manager `." msgstr "" #: library/contextlib.rst:107 @@ -133,20 +158,55 @@ msgid "" "This function is a :term:`decorator` that can be used to define a factory " "function for :keyword:`async with` statement asynchronous context managers, " "without needing to create a class or separate :meth:`~object.__aenter__` " -"and :meth:`~object.__aexit__` methods. It must be applied to an :term:" -"`asynchronous generator` function." +"and :meth:`~object.__aexit__` methods. It must be applied to " +"an :term:`asynchronous generator` function." msgstr "" #: library/contextlib.rst:113 msgid "A simple example::" msgstr "" +#: library/contextlib.rst:115 +msgid "" +"from contextlib import asynccontextmanager\n" +"\n" +"@asynccontextmanager\n" +"async def get_connection():\n" +" conn = await acquire_db_connection()\n" +" try:\n" +" yield conn\n" +" finally:\n" +" await release_db_connection(conn)\n" +"\n" +"async def get_all_users():\n" +" async with get_connection() as conn:\n" +" return conn.query('SELECT ...')" +msgstr "" + #: library/contextlib.rst:131 msgid "" "Context managers defined with :func:`asynccontextmanager` can be used either " "as decorators or with :keyword:`async with` statements::" msgstr "" +#: library/contextlib.rst:134 +msgid "" +"import time\n" +"from contextlib import asynccontextmanager\n" +"\n" +"@asynccontextmanager\n" +"async def timeit():\n" +" now = time.monotonic()\n" +" try:\n" +" yield\n" +" finally:\n" +" print(f'it took {time.monotonic() - now}s to run')\n" +"\n" +"@timeit()\n" +"async def main():\n" +" # ... async code ..." +msgstr "" + #: library/contextlib.rst:149 msgid "" "When used as a decorator, a new generator instance is implicitly created on " @@ -167,10 +227,32 @@ msgid "" "This is basically equivalent to::" msgstr "" +#: library/contextlib.rst:164 +msgid "" +"from contextlib import contextmanager\n" +"\n" +"@contextmanager\n" +"def closing(thing):\n" +" try:\n" +" yield thing\n" +" finally:\n" +" thing.close()" +msgstr "" + #: library/contextlib.rst:173 msgid "And lets you write code like this::" msgstr "" +#: library/contextlib.rst:175 +msgid "" +"from contextlib import closing\n" +"from urllib.request import urlopen\n" +"\n" +"with closing(urlopen('https://www.python.org')) as page:\n" +" for line in page:\n" +" print(line)" +msgstr "" + #: library/contextlib.rst:182 msgid "" "without needing to explicitly close ``page``. Even if an error occurs, " @@ -180,10 +262,11 @@ msgstr "" #: library/contextlib.rst:187 msgid "" "Most types managing resources support the :term:`context manager` protocol, " -"which closes *thing* on leaving the :keyword:`with` statement. As such, :" -"func:`!closing` is most useful for third party types that don't support " -"context managers. This example is purely for illustration purposes, as :func:" -"`~urllib.request.urlopen` would normally be used in a context manager." +"which closes *thing* on leaving the :keyword:`with` statement. As " +"such, :func:`!closing` is most useful for third party types that don't " +"support context managers. This example is purely for illustration purposes, " +"as :func:`~urllib.request.urlopen` would normally be used in a context " +"manager." msgstr "" #: library/contextlib.rst:196 @@ -192,6 +275,18 @@ msgid "" "*thing* upon completion of the block. This is basically equivalent to::" msgstr "" +#: library/contextlib.rst:199 +msgid "" +"from contextlib import asynccontextmanager\n" +"\n" +"@asynccontextmanager\n" +"async def aclosing(thing):\n" +" try:\n" +" yield thing\n" +" finally:\n" +" await thing.aclose()" +msgstr "" + #: library/contextlib.rst:208 msgid "" "Significantly, ``aclosing()`` supports deterministic cleanup of async " @@ -199,6 +294,16 @@ msgid "" "exception. For example::" msgstr "" +#: library/contextlib.rst:212 +msgid "" +"from contextlib import aclosing\n" +"\n" +"async with aclosing(my_generator()) as values:\n" +" async for value in values:\n" +" if value == 42:\n" +" break" +msgstr "" + #: library/contextlib.rst:219 msgid "" "This pattern ensures that the generator's async exit code is executed in the " @@ -214,16 +319,57 @@ msgid "" "optional context manager, for example::" msgstr "" +#: library/contextlib.rst:235 +msgid "" +"def myfunction(arg, ignore_exceptions=False):\n" +" if ignore_exceptions:\n" +" # Use suppress to ignore all exceptions.\n" +" cm = contextlib.suppress(Exception)\n" +" else:\n" +" # Do not ignore any exceptions, cm has no effect.\n" +" cm = contextlib.nullcontext()\n" +" with cm:\n" +" # Do something" +msgstr "" + #: library/contextlib.rst:245 msgid "An example using *enter_result*::" msgstr "" +#: library/contextlib.rst:247 +msgid "" +"def process_file(file_or_path):\n" +" if isinstance(file_or_path, str):\n" +" # If string, open file\n" +" cm = open(file_or_path)\n" +" else:\n" +" # Caller is responsible for closing file\n" +" cm = nullcontext(file_or_path)\n" +"\n" +" with cm as file:\n" +" # Perform processing on the file" +msgstr "" + #: library/contextlib.rst:258 msgid "" "It can also be used as a stand-in for :ref:`asynchronous context managers " "`::" msgstr "" +#: library/contextlib.rst:261 +msgid "" +"async def send_http(session=None):\n" +" if not session:\n" +" # If no http session, create it with aiohttp\n" +" cm = aiohttp.ClientSession()\n" +" else:\n" +" # Caller is responsible for closing the session\n" +" cm = nullcontext(session)\n" +"\n" +" async with cm as session:\n" +" # Send http requests with session" +msgstr "" + #: library/contextlib.rst:274 msgid ":term:`asynchronous context manager` support was added." msgstr "" @@ -248,60 +394,105 @@ msgstr "" msgid "For example::" msgstr "" +#: library/contextlib.rst:293 +msgid "" +"from contextlib import suppress\n" +"\n" +"with suppress(FileNotFoundError):\n" +" os.remove('somefile.tmp')\n" +"\n" +"with suppress(FileNotFoundError):\n" +" os.remove('someotherfile.tmp')" +msgstr "" + #: library/contextlib.rst:301 msgid "This code is equivalent to::" msgstr "" -#: library/contextlib.rst:360 library/contextlib.rst:387 +#: library/contextlib.rst:303 +msgid "" +"try:\n" +" os.remove('somefile.tmp')\n" +"except FileNotFoundError:\n" +" pass\n" +"\n" +"try:\n" +" os.remove('someotherfile.tmp')\n" +"except FileNotFoundError:\n" +" pass" +msgstr "" + +#: library/contextlib.rst:362 library/contextlib.rst:389 msgid "This context manager is :ref:`reentrant `." msgstr "" #: library/contextlib.rst:315 msgid "" -"If the code within the :keyword:`!with` block raises a :exc:" -"`BaseExceptionGroup`, suppressed exceptions are removed from the group. If " -"any exceptions in the group are not suppressed, a group containing them is " -"re-raised." +"If the code within the :keyword:`!with` block raises " +"a :exc:`BaseExceptionGroup`, suppressed exceptions are removed from the " +"group. Any exceptions of the group which are not suppressed are re-raised " +"in a new group which is created using the original " +"group's :meth:`~BaseExceptionGroup.derive` method." msgstr "" -#: library/contextlib.rst:321 +#: library/contextlib.rst:323 msgid "" -"``suppress`` now supports suppressing exceptions raised as part of an :exc:" -"`BaseExceptionGroup`." +"``suppress`` now supports suppressing exceptions raised as part of " +"a :exc:`BaseExceptionGroup`." msgstr "" -#: library/contextlib.rst:327 +#: library/contextlib.rst:329 msgid "" "Context manager for temporarily redirecting :data:`sys.stdout` to another " "file or file-like object." msgstr "" -#: library/contextlib.rst:330 +#: library/contextlib.rst:332 msgid "" "This tool adds flexibility to existing functions or classes whose output is " "hardwired to stdout." msgstr "" -#: library/contextlib.rst:333 +#: library/contextlib.rst:335 msgid "" "For example, the output of :func:`help` normally is sent to *sys.stdout*. " -"You can capture that output in a string by redirecting the output to an :" -"class:`io.StringIO` object. The replacement stream is returned from the " -"``__enter__`` method and so is available as the target of the :keyword:" -"`with` statement::" +"You can capture that output in a string by redirecting the output to " +"an :class:`io.StringIO` object. The replacement stream is returned from the " +"``__enter__`` method and so is available as the target of " +"the :keyword:`with` statement::" msgstr "" -#: library/contextlib.rst:343 +#: library/contextlib.rst:341 +msgid "" +"with redirect_stdout(io.StringIO()) as f:\n" +" help(pow)\n" +"s = f.getvalue()" +msgstr "" + +#: library/contextlib.rst:345 msgid "" "To send the output of :func:`help` to a file on disk, redirect the output to " "a regular file::" msgstr "" -#: library/contextlib.rst:350 +#: library/contextlib.rst:348 +msgid "" +"with open('help.txt', 'w') as f:\n" +" with redirect_stdout(f):\n" +" help(pow)" +msgstr "" + +#: library/contextlib.rst:352 msgid "To send the output of :func:`help` to *sys.stderr*::" msgstr "" -#: library/contextlib.rst:355 +#: library/contextlib.rst:354 +msgid "" +"with redirect_stdout(sys.stderr):\n" +" help(pow)" +msgstr "" + +#: library/contextlib.rst:357 msgid "" "Note that the global side effect on :data:`sys.stdout` means that this " "context manager is not suitable for use in library code and most threaded " @@ -309,13 +500,13 @@ msgid "" "it is still a useful approach for many utility scripts." msgstr "" -#: library/contextlib.rst:367 +#: library/contextlib.rst:369 msgid "" -"Similar to :func:`~contextlib.redirect_stdout` but redirecting :data:`sys." -"stderr` to another file or file-like object." +"Similar to :func:`~contextlib.redirect_stdout` but " +"redirecting :data:`sys.stderr` to another file or file-like object." msgstr "" -#: library/contextlib.rst:377 +#: library/contextlib.rst:379 msgid "" "Non parallel-safe context manager to change the current working directory. " "As this changes a global state, the working directory, it is not suitable " @@ -325,60 +516,119 @@ msgid "" "when this context manager is active." msgstr "" -#: library/contextlib.rst:384 +#: library/contextlib.rst:386 msgid "" "This is a simple wrapper around :func:`~os.chdir`, it changes the current " "working directory upon entering and restores the old one on exit." msgstr "" -#: library/contextlib.rst:394 +#: library/contextlib.rst:396 msgid "" "A base class that enables a context manager to also be used as a decorator." msgstr "" -#: library/contextlib.rst:396 +#: library/contextlib.rst:398 msgid "" "Context managers inheriting from ``ContextDecorator`` have to implement " "``__enter__`` and ``__exit__`` as normal. ``__exit__`` retains its optional " "exception handling even when used as a decorator." msgstr "" -#: library/contextlib.rst:400 +#: library/contextlib.rst:402 msgid "" "``ContextDecorator`` is used by :func:`contextmanager`, so you get this " "functionality automatically." msgstr "" -#: library/contextlib.rst:403 +#: library/contextlib.rst:405 msgid "Example of ``ContextDecorator``::" msgstr "" -#: library/contextlib.rst:488 +#: library/contextlib.rst:407 +msgid "" +"from contextlib import ContextDecorator\n" +"\n" +"class mycontext(ContextDecorator):\n" +" def __enter__(self):\n" +" print('Starting')\n" +" return self\n" +"\n" +" def __exit__(self, *exc):\n" +" print('Finishing')\n" +" return False" +msgstr "" + +#: library/contextlib.rst:490 msgid "The class can then be used like this::" msgstr "" -#: library/contextlib.rst:434 +#: library/contextlib.rst:420 +msgid "" +">>> @mycontext()\n" +"... def function():\n" +"... print('The bit in the middle')\n" +"...\n" +">>> function()\n" +"Starting\n" +"The bit in the middle\n" +"Finishing\n" +"\n" +">>> with mycontext():\n" +"... print('The bit in the middle')\n" +"...\n" +"Starting\n" +"The bit in the middle\n" +"Finishing" +msgstr "" + +#: library/contextlib.rst:436 msgid "" "This change is just syntactic sugar for any construct of the following form::" msgstr "" -#: library/contextlib.rst:440 +#: library/contextlib.rst:438 +msgid "" +"def f():\n" +" with cm():\n" +" # Do stuff" +msgstr "" + +#: library/contextlib.rst:442 msgid "``ContextDecorator`` lets you instead write::" msgstr "" -#: library/contextlib.rst:446 +#: library/contextlib.rst:444 +msgid "" +"@cm()\n" +"def f():\n" +" # Do stuff" +msgstr "" + +#: library/contextlib.rst:448 msgid "" "It makes it clear that the ``cm`` applies to the whole function, rather than " "just a piece of it (and saving an indentation level is nice, too)." msgstr "" -#: library/contextlib.rst:449 +#: library/contextlib.rst:451 msgid "" "Existing context managers that already have a base class can be extended by " "using ``ContextDecorator`` as a mixin class::" msgstr "" -#: library/contextlib.rst:462 +#: library/contextlib.rst:454 +msgid "" +"from contextlib import ContextDecorator\n" +"\n" +"class mycontext(ContextBaseClass, ContextDecorator):\n" +" def __enter__(self):\n" +" return self\n" +"\n" +" def __exit__(self, *exc):\n" +" return False" +msgstr "" + +#: library/contextlib.rst:464 msgid "" "As the decorated function must be able to be called multiple times, the " "underlying context manager must support use in multiple :keyword:`with` " @@ -386,35 +636,80 @@ msgid "" "explicit :keyword:`!with` statement inside the function should be used." msgstr "" -#: library/contextlib.rst:472 +#: library/contextlib.rst:474 msgid "" "Similar to :class:`ContextDecorator` but only for asynchronous functions." msgstr "" -#: library/contextlib.rst:474 +#: library/contextlib.rst:476 msgid "Example of ``AsyncContextDecorator``::" msgstr "" -#: library/contextlib.rst:513 +#: library/contextlib.rst:478 +msgid "" +"from asyncio import run\n" +"from contextlib import AsyncContextDecorator\n" +"\n" +"class mycontext(AsyncContextDecorator):\n" +" async def __aenter__(self):\n" +" print('Starting')\n" +" return self\n" +"\n" +" async def __aexit__(self, *exc):\n" +" print('Finishing')\n" +" return False" +msgstr "" + +#: library/contextlib.rst:492 +msgid "" +">>> @mycontext()\n" +"... async def function():\n" +"... print('The bit in the middle')\n" +"...\n" +">>> run(function())\n" +"Starting\n" +"The bit in the middle\n" +"Finishing\n" +"\n" +">>> async def function():\n" +"... async with mycontext():\n" +"... print('The bit in the middle')\n" +"...\n" +">>> run(function())\n" +"Starting\n" +"The bit in the middle\n" +"Finishing" +msgstr "" + +#: library/contextlib.rst:515 msgid "" "A context manager that is designed to make it easy to programmatically " "combine other context managers and cleanup functions, especially those that " "are optional or otherwise driven by input data." msgstr "" -#: library/contextlib.rst:517 +#: library/contextlib.rst:519 msgid "" "For example, a set of files may easily be handled in a single with statement " "as follows::" msgstr "" -#: library/contextlib.rst:526 +#: library/contextlib.rst:522 +msgid "" +"with ExitStack() as stack:\n" +" files = [stack.enter_context(open(fname)) for fname in filenames]\n" +" # All opened files will automatically be closed at the end of\n" +" # the with statement, even if attempts to open files later\n" +" # in the list raise an exception" +msgstr "" + +#: library/contextlib.rst:528 msgid "" "The :meth:`~object.__enter__` method returns the :class:`ExitStack` " "instance, and performs no additional operations." msgstr "" -#: library/contextlib.rst:529 +#: library/contextlib.rst:531 msgid "" "Each instance maintains a stack of registered callbacks that are called in " "reverse order when the instance is closed (either explicitly or implicitly " @@ -422,14 +717,14 @@ msgid "" "invoked implicitly when the context stack instance is garbage collected." msgstr "" -#: library/contextlib.rst:534 +#: library/contextlib.rst:536 msgid "" "This stack model is used so that context managers that acquire their " "resources in their ``__init__`` method (such as file objects) can be handled " "correctly." msgstr "" -#: library/contextlib.rst:538 +#: library/contextlib.rst:540 msgid "" "Since registered callbacks are invoked in the reverse order of registration, " "this ends up behaving as if multiple nested :keyword:`with` statements had " @@ -439,7 +734,7 @@ msgid "" "updated state." msgstr "" -#: library/contextlib.rst:545 +#: library/contextlib.rst:547 msgid "" "This is a relatively low level API that takes care of the details of " "correctly unwinding the stack of exit callbacks. It provides a suitable " @@ -447,76 +742,77 @@ msgid "" "in application specific ways." msgstr "" -#: library/contextlib.rst:554 +#: library/contextlib.rst:556 msgid "" "Enters a new context manager and adds its :meth:`~object.__exit__` method to " "the callback stack. The return value is the result of the context manager's " "own :meth:`~object.__enter__` method." msgstr "" -#: library/contextlib.rst:558 +#: library/contextlib.rst:560 msgid "" "These context managers may suppress exceptions just as they normally would " "if used directly as part of a :keyword:`with` statement." msgstr "" -#: library/contextlib.rst:561 +#: library/contextlib.rst:563 msgid "" "Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm* is not a " "context manager." msgstr "" -#: library/contextlib.rst:567 +#: library/contextlib.rst:569 msgid "" "Adds a context manager's :meth:`~object.__exit__` method to the callback " "stack." msgstr "" -#: library/contextlib.rst:569 +#: library/contextlib.rst:571 msgid "" "As ``__enter__`` is *not* invoked, this method can be used to cover part of " -"an :meth:`~object.__enter__` implementation with a context manager's own :" -"meth:`~object.__exit__` method." +"an :meth:`~object.__enter__` implementation with a context manager's " +"own :meth:`~object.__exit__` method." msgstr "" -#: library/contextlib.rst:573 +#: library/contextlib.rst:575 msgid "" "If passed an object that is not a context manager, this method assumes it is " -"a callback with the same signature as a context manager's :meth:`~object." -"__exit__` method and adds it directly to the callback stack." +"a callback with the same signature as a context " +"manager's :meth:`~object.__exit__` method and adds it directly to the " +"callback stack." msgstr "" -#: library/contextlib.rst:577 +#: library/contextlib.rst:579 msgid "" "By returning true values, these callbacks can suppress exceptions the same " "way context manager :meth:`~object.__exit__` methods can." msgstr "" -#: library/contextlib.rst:580 +#: library/contextlib.rst:582 msgid "" "The passed in object is returned from the function, allowing this method to " "be used as a function decorator." msgstr "" -#: library/contextlib.rst:585 +#: library/contextlib.rst:587 msgid "" "Accepts an arbitrary callback function and arguments and adds it to the " "callback stack." msgstr "" -#: library/contextlib.rst:588 +#: library/contextlib.rst:590 msgid "" "Unlike the other methods, callbacks added this way cannot suppress " "exceptions (as they are never passed the exception details)." msgstr "" -#: library/contextlib.rst:591 +#: library/contextlib.rst:593 msgid "" "The passed in callback is returned from the function, allowing this method " "to be used as a function decorator." msgstr "" -#: library/contextlib.rst:596 +#: library/contextlib.rst:598 msgid "" "Transfers the callback stack to a fresh :class:`ExitStack` instance and " "returns it. No callbacks are invoked by this operation - instead, they will " @@ -524,77 +820,100 @@ msgid "" "at the end of a :keyword:`with` statement)." msgstr "" -#: library/contextlib.rst:601 +#: library/contextlib.rst:603 msgid "" "For example, a group of files can be opened as an \"all or nothing\" " "operation as follows::" msgstr "" -#: library/contextlib.rst:615 +#: library/contextlib.rst:606 +msgid "" +"with ExitStack() as stack:\n" +" files = [stack.enter_context(open(fname)) for fname in filenames]\n" +" # Hold onto the close method, but don't call it yet.\n" +" close_files = stack.pop_all().close\n" +" # If opening any file fails, all previously opened files will be\n" +" # closed automatically. If all files are opened successfully,\n" +" # they will remain open even after the with statement ends.\n" +" # close_files() can then be invoked explicitly to close them all." +msgstr "" + +#: library/contextlib.rst:617 msgid "" "Immediately unwinds the callback stack, invoking callbacks in the reverse " "order of registration. For any context managers and exit callbacks " "registered, the arguments passed in will indicate that no exception occurred." msgstr "" -#: library/contextlib.rst:622 +#: library/contextlib.rst:624 msgid "" -"An :ref:`asynchronous context manager `, similar to :" -"class:`ExitStack`, that supports combining both synchronous and asynchronous " -"context managers, as well as having coroutines for cleanup logic." +"An :ref:`asynchronous context manager `, similar " +"to :class:`ExitStack`, that supports combining both synchronous and " +"asynchronous context managers, as well as having coroutines for cleanup " +"logic." msgstr "" -#: library/contextlib.rst:627 +#: library/contextlib.rst:629 msgid "" "The :meth:`~ExitStack.close` method is not implemented; :meth:`aclose` must " "be used instead." msgstr "" -#: library/contextlib.rst:632 +#: library/contextlib.rst:634 msgid "" "Similar to :meth:`ExitStack.enter_context` but expects an asynchronous " "context manager." msgstr "" -#: library/contextlib.rst:635 +#: library/contextlib.rst:637 msgid "" "Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm* is not an " "asynchronous context manager." msgstr "" -#: library/contextlib.rst:641 +#: library/contextlib.rst:643 msgid "" "Similar to :meth:`ExitStack.push` but expects either an asynchronous context " "manager or a coroutine function." msgstr "" -#: library/contextlib.rst:646 +#: library/contextlib.rst:648 msgid "Similar to :meth:`ExitStack.callback` but expects a coroutine function." msgstr "" -#: library/contextlib.rst:650 +#: library/contextlib.rst:652 msgid "Similar to :meth:`ExitStack.close` but properly handles awaitables." msgstr "" -#: library/contextlib.rst:652 +#: library/contextlib.rst:654 msgid "Continuing the example for :func:`asynccontextmanager`::" msgstr "" -#: library/contextlib.rst:664 -msgid "Examples and Recipes" +#: library/contextlib.rst:656 +msgid "" +"async with AsyncExitStack() as stack:\n" +" connections = [await stack.enter_async_context(get_connection())\n" +" for i in range(5)]\n" +" # All opened connections will automatically be released at the end of\n" +" # the async with statement, even if attempts to open a connection\n" +" # later in the list raise an exception." msgstr "" #: library/contextlib.rst:666 +msgid "Examples and Recipes" +msgstr "" + +#: library/contextlib.rst:668 msgid "" "This section describes some examples and recipes for making effective use of " "the tools provided by :mod:`contextlib`." msgstr "" -#: library/contextlib.rst:671 +#: library/contextlib.rst:673 msgid "Supporting a variable number of context managers" msgstr "" -#: library/contextlib.rst:673 +#: library/contextlib.rst:675 msgid "" "The primary use case for :class:`ExitStack` is the one given in the class " "documentation: supporting a variable number of context managers and other " @@ -604,60 +923,121 @@ msgid "" "of the context managers being optional::" msgstr "" -#: library/contextlib.rst:688 +#: library/contextlib.rst:682 +msgid "" +"with ExitStack() as stack:\n" +" for resource in resources:\n" +" stack.enter_context(resource)\n" +" if need_special_resource():\n" +" special = acquire_special_resource()\n" +" stack.callback(release_special_resource, special)\n" +" # Perform operations that use the acquired resources" +msgstr "" + +#: library/contextlib.rst:690 msgid "" "As shown, :class:`ExitStack` also makes it quite easy to use :keyword:`with` " "statements to manage arbitrary resources that don't natively support the " "context management protocol." msgstr "" -#: library/contextlib.rst:694 +#: library/contextlib.rst:696 msgid "Catching exceptions from ``__enter__`` methods" msgstr "" -#: library/contextlib.rst:696 +#: library/contextlib.rst:698 msgid "" "It is occasionally desirable to catch exceptions from an ``__enter__`` " -"method implementation, *without* inadvertently catching exceptions from the :" -"keyword:`with` statement body or the context manager's ``__exit__`` method. " -"By using :class:`ExitStack` the steps in the context management protocol can " -"be separated slightly in order to allow this::" +"method implementation, *without* inadvertently catching exceptions from " +"the :keyword:`with` statement body or the context manager's ``__exit__`` " +"method. By using :class:`ExitStack` the steps in the context management " +"protocol can be separated slightly in order to allow this::" +msgstr "" + +#: library/contextlib.rst:704 +msgid "" +"stack = ExitStack()\n" +"try:\n" +" x = stack.enter_context(cm)\n" +"except Exception:\n" +" # handle __enter__ exception\n" +"else:\n" +" with stack:\n" +" # Handle normal case" msgstr "" -#: library/contextlib.rst:711 +#: library/contextlib.rst:713 msgid "" "Actually needing to do this is likely to indicate that the underlying API " -"should be providing a direct resource management interface for use with :" -"keyword:`try`/:keyword:`except`/:keyword:`finally` statements, but not all " -"APIs are well designed in that regard. When a context manager is the only " -"resource management API provided, then :class:`ExitStack` can make it easier " -"to handle various situations that can't be handled directly in a :keyword:" -"`with` statement." +"should be providing a direct resource management interface for use " +"with :keyword:`try`/:keyword:`except`/:keyword:`finally` statements, but not " +"all APIs are well designed in that regard. When a context manager is the " +"only resource management API provided, then :class:`ExitStack` can make it " +"easier to handle various situations that can't be handled directly in " +"a :keyword:`with` statement." msgstr "" -#: library/contextlib.rst:721 +#: library/contextlib.rst:723 msgid "Cleaning up in an ``__enter__`` implementation" msgstr "" -#: library/contextlib.rst:723 +#: library/contextlib.rst:725 msgid "" "As noted in the documentation of :meth:`ExitStack.push`, this method can be " -"useful in cleaning up an already allocated resource if later steps in the :" -"meth:`~object.__enter__` implementation fail." +"useful in cleaning up an already allocated resource if later steps in " +"the :meth:`~object.__enter__` implementation fail." msgstr "" -#: library/contextlib.rst:727 +#: library/contextlib.rst:729 msgid "" "Here's an example of doing this for a context manager that accepts resource " "acquisition and release functions, along with an optional validation " "function, and maps them to the context management protocol::" msgstr "" -#: library/contextlib.rst:767 -msgid "Replacing any use of ``try-finally`` and flag variables" +#: library/contextlib.rst:733 +msgid "" +"from contextlib import contextmanager, AbstractContextManager, ExitStack\n" +"\n" +"class ResourceManager(AbstractContextManager):\n" +"\n" +" def __init__(self, acquire_resource, release_resource, " +"check_resource_ok=None):\n" +" self.acquire_resource = acquire_resource\n" +" self.release_resource = release_resource\n" +" if check_resource_ok is None:\n" +" def check_resource_ok(resource):\n" +" return True\n" +" self.check_resource_ok = check_resource_ok\n" +"\n" +" @contextmanager\n" +" def _cleanup_on_error(self):\n" +" with ExitStack() as stack:\n" +" stack.push(self)\n" +" yield\n" +" # The validation check passed and didn't raise an exception\n" +" # Accordingly, we want to keep the resource, and pass it\n" +" # back to our caller\n" +" stack.pop_all()\n" +"\n" +" def __enter__(self):\n" +" resource = self.acquire_resource()\n" +" with self._cleanup_on_error():\n" +" if not self.check_resource_ok(resource):\n" +" msg = \"Failed validation for {!r}\"\n" +" raise RuntimeError(msg.format(resource))\n" +" return resource\n" +"\n" +" def __exit__(self, *exc_details):\n" +" # We don't need to duplicate any of our resource release logic\n" +" self.release_resource()" msgstr "" #: library/contextlib.rst:769 +msgid "Replacing any use of ``try-finally`` and flag variables" +msgstr "" + +#: library/contextlib.rst:771 msgid "" "A pattern you will sometimes see is a ``try-finally`` statement with a flag " "variable to indicate whether or not the body of the ``finally`` clause " @@ -665,57 +1045,111 @@ msgid "" "by using an ``except`` clause instead), it looks something like this::" msgstr "" -#: library/contextlib.rst:783 +#: library/contextlib.rst:776 +msgid "" +"cleanup_needed = True\n" +"try:\n" +" result = perform_operation()\n" +" if result:\n" +" cleanup_needed = False\n" +"finally:\n" +" if cleanup_needed:\n" +" cleanup_resources()" +msgstr "" + +#: library/contextlib.rst:785 msgid "" "As with any ``try`` statement based code, this can cause problems for " "development and review, because the setup code and the cleanup code can end " "up being separated by arbitrarily long sections of code." msgstr "" -#: library/contextlib.rst:787 +#: library/contextlib.rst:789 msgid "" ":class:`ExitStack` makes it possible to instead register a callback for " "execution at the end of a ``with`` statement, and then later decide to skip " "executing that callback::" msgstr "" -#: library/contextlib.rst:799 +#: library/contextlib.rst:793 +msgid "" +"from contextlib import ExitStack\n" +"\n" +"with ExitStack() as stack:\n" +" stack.callback(cleanup_resources)\n" +" result = perform_operation()\n" +" if result:\n" +" stack.pop_all()" +msgstr "" + +#: library/contextlib.rst:801 msgid "" -"This allows the intended cleanup up behaviour to be made explicit up front, " +"This allows the intended cleanup behaviour to be made explicit up front, " "rather than requiring a separate flag variable." msgstr "" -#: library/contextlib.rst:802 +#: library/contextlib.rst:804 msgid "" "If a particular application uses this pattern a lot, it can be simplified " "even further by means of a small helper class::" msgstr "" -#: library/contextlib.rst:820 +#: library/contextlib.rst:807 +msgid "" +"from contextlib import ExitStack\n" +"\n" +"class Callback(ExitStack):\n" +" def __init__(self, callback, /, *args, **kwds):\n" +" super().__init__()\n" +" self.callback(callback, *args, **kwds)\n" +"\n" +" def cancel(self):\n" +" self.pop_all()\n" +"\n" +"with Callback(cleanup_resources) as cb:\n" +" result = perform_operation()\n" +" if result:\n" +" cb.cancel()" +msgstr "" + +#: library/contextlib.rst:822 msgid "" "If the resource cleanup isn't already neatly bundled into a standalone " -"function, then it is still possible to use the decorator form of :meth:" -"`ExitStack.callback` to declare the resource cleanup in advance::" +"function, then it is still possible to use the decorator form " +"of :meth:`ExitStack.callback` to declare the resource cleanup in advance::" msgstr "" -#: library/contextlib.rst:835 +#: library/contextlib.rst:827 +msgid "" +"from contextlib import ExitStack\n" +"\n" +"with ExitStack() as stack:\n" +" @stack.callback\n" +" def cleanup_resources():\n" +" ...\n" +" result = perform_operation()\n" +" if result:\n" +" stack.pop_all()" +msgstr "" + +#: library/contextlib.rst:837 msgid "" "Due to the way the decorator protocol works, a callback function declared " "this way cannot take any parameters. Instead, any resources to be released " "must be accessed as closure variables." msgstr "" -#: library/contextlib.rst:841 +#: library/contextlib.rst:843 msgid "Using a context manager as a function decorator" msgstr "" -#: library/contextlib.rst:843 +#: library/contextlib.rst:845 msgid "" ":class:`ContextDecorator` makes it possible to use a context manager in both " "an ordinary ``with`` statement and also as a function decorator." msgstr "" -#: library/contextlib.rst:846 +#: library/contextlib.rst:848 msgid "" "For example, it is sometimes useful to wrap functions or groups of " "statements with a logger that can track the time of entry and time of exit. " @@ -724,37 +1158,70 @@ msgid "" "in a single definition::" msgstr "" -#: library/contextlib.rst:867 +#: library/contextlib.rst:854 +msgid "" +"from contextlib import ContextDecorator\n" +"import logging\n" +"\n" +"logging.basicConfig(level=logging.INFO)\n" +"\n" +"class track_entry_and_exit(ContextDecorator):\n" +" def __init__(self, name):\n" +" self.name = name\n" +"\n" +" def __enter__(self):\n" +" logging.info('Entering: %s', self.name)\n" +"\n" +" def __exit__(self, exc_type, exc, exc_tb):\n" +" logging.info('Exiting: %s', self.name)" +msgstr "" + +#: library/contextlib.rst:869 msgid "Instances of this class can be used as both a context manager::" msgstr "" -#: library/contextlib.rst:873 +#: library/contextlib.rst:871 +msgid "" +"with track_entry_and_exit('widget loader'):\n" +" print('Some time consuming activity goes here')\n" +" load_widget()" +msgstr "" + +#: library/contextlib.rst:875 msgid "And also as a function decorator::" msgstr "" -#: library/contextlib.rst:880 +#: library/contextlib.rst:877 +msgid "" +"@track_entry_and_exit('widget loader')\n" +"def activity():\n" +" print('Some time consuming activity goes here')\n" +" load_widget()" +msgstr "" + +#: library/contextlib.rst:882 msgid "" "Note that there is one additional limitation when using context managers as " -"function decorators: there's no way to access the return value of :meth:" -"`~object.__enter__`. If that value is needed, then it is still necessary to " -"use an explicit ``with`` statement." +"function decorators: there's no way to access the return value " +"of :meth:`~object.__enter__`. If that value is needed, then it is still " +"necessary to use an explicit ``with`` statement." msgstr "" -#: library/contextlib.rst:888 +#: library/contextlib.rst:889 msgid ":pep:`343` - The \"with\" statement" msgstr "" -#: library/contextlib.rst:888 +#: library/contextlib.rst:890 msgid "" "The specification, background, and examples for the Python :keyword:`with` " "statement." msgstr "" -#: library/contextlib.rst:894 +#: library/contextlib.rst:896 msgid "Single use, reusable and reentrant context managers" msgstr "" -#: library/contextlib.rst:896 +#: library/contextlib.rst:898 msgid "" "Most context managers are written in a way that means they can only be used " "effectively in a :keyword:`with` statement once. These single use context " @@ -762,32 +1229,55 @@ msgid "" "them a second time will trigger an exception or otherwise not work correctly." msgstr "" -#: library/contextlib.rst:902 +#: library/contextlib.rst:904 msgid "" "This common limitation means that it is generally advisable to create " "context managers directly in the header of the :keyword:`with` statement " "where they are used (as shown in all of the usage examples above)." msgstr "" -#: library/contextlib.rst:906 +#: library/contextlib.rst:908 msgid "" "Files are an example of effectively single use context managers, since the " "first :keyword:`with` statement will close the file, preventing any further " "IO operations using that file object." msgstr "" -#: library/contextlib.rst:910 +#: library/contextlib.rst:912 msgid "" "Context managers created using :func:`contextmanager` are also single use " "context managers, and will complain about the underlying generator failing " "to yield if an attempt is made to use them a second time::" msgstr "" -#: library/contextlib.rst:938 -msgid "Reentrant context managers" +#: library/contextlib.rst:916 +msgid "" +">>> from contextlib import contextmanager\n" +">>> @contextmanager\n" +"... def singleuse():\n" +"... print(\"Before\")\n" +"... yield\n" +"... print(\"After\")\n" +"...\n" +">>> cm = singleuse()\n" +">>> with cm:\n" +"... pass\n" +"...\n" +"Before\n" +"After\n" +">>> with cm:\n" +"... pass\n" +"...\n" +"Traceback (most recent call last):\n" +" ...\n" +"RuntimeError: generator didn't yield" msgstr "" #: library/contextlib.rst:940 +msgid "Reentrant context managers" +msgstr "" + +#: library/contextlib.rst:942 msgid "" "More sophisticated context managers may be \"reentrant\". These context " "managers can not only be used in multiple :keyword:`with` statements, but " @@ -795,33 +1285,51 @@ msgid "" "the same context manager." msgstr "" -#: library/contextlib.rst:945 +#: library/contextlib.rst:947 msgid "" ":class:`threading.RLock` is an example of a reentrant context manager, as " "are :func:`suppress`, :func:`redirect_stdout`, and :func:`chdir`. Here's a " "very simple example of reentrant use::" msgstr "" -#: library/contextlib.rst:964 +#: library/contextlib.rst:951 +msgid "" +">>> from contextlib import redirect_stdout\n" +">>> from io import StringIO\n" +">>> stream = StringIO()\n" +">>> write_to_stream = redirect_stdout(stream)\n" +">>> with write_to_stream:\n" +"... print(\"This is written to the stream rather than stdout\")\n" +"... with write_to_stream:\n" +"... print(\"This is also written to the stream\")\n" +"...\n" +">>> print(\"This is written directly to stdout\")\n" +"This is written directly to stdout\n" +">>> print(stream.getvalue())\n" +"This is written to the stream rather than stdout\n" +"This is also written to the stream" +msgstr "" + +#: library/contextlib.rst:966 msgid "" "Real world examples of reentrancy are more likely to involve multiple " "functions calling each other and hence be far more complicated than this " "example." msgstr "" -#: library/contextlib.rst:968 +#: library/contextlib.rst:970 msgid "" "Note also that being reentrant is *not* the same thing as being thread " "safe. :func:`redirect_stdout`, for example, is definitely not thread safe, " -"as it makes a global modification to the system state by binding :data:`sys." -"stdout` to a different stream." +"as it makes a global modification to the system state by " +"binding :data:`sys.stdout` to a different stream." msgstr "" -#: library/contextlib.rst:977 +#: library/contextlib.rst:979 msgid "Reusable context managers" msgstr "" -#: library/contextlib.rst:979 +#: library/contextlib.rst:981 msgid "" "Distinct from both single use and reentrant context managers are " "\"reusable\" context managers (or, to be completely explicit, \"reusable, " @@ -831,21 +1339,51 @@ msgid "" "manager instance has already been used in a containing with statement." msgstr "" -#: library/contextlib.rst:986 +#: library/contextlib.rst:988 msgid "" ":class:`threading.Lock` is an example of a reusable, but not reentrant, " -"context manager (for a reentrant lock, it is necessary to use :class:" -"`threading.RLock` instead)." -msgstr "" - -#: library/contextlib.rst:990 -msgid "" -"Another example of a reusable, but not reentrant, context manager is :class:" -"`ExitStack`, as it invokes *all* currently registered callbacks when leaving " -"any with statement, regardless of where those callbacks were added::" -msgstr "" - -#: library/contextlib.rst:1021 +"context manager (for a reentrant lock, it is necessary to " +"use :class:`threading.RLock` instead)." +msgstr "" + +#: library/contextlib.rst:992 +msgid "" +"Another example of a reusable, but not reentrant, context manager " +"is :class:`ExitStack`, as it invokes *all* currently registered callbacks " +"when leaving any with statement, regardless of where those callbacks were " +"added::" +msgstr "" + +#: library/contextlib.rst:997 +msgid "" +">>> from contextlib import ExitStack\n" +">>> stack = ExitStack()\n" +">>> with stack:\n" +"... stack.callback(print, \"Callback: from first context\")\n" +"... print(\"Leaving first context\")\n" +"...\n" +"Leaving first context\n" +"Callback: from first context\n" +">>> with stack:\n" +"... stack.callback(print, \"Callback: from second context\")\n" +"... print(\"Leaving second context\")\n" +"...\n" +"Leaving second context\n" +"Callback: from second context\n" +">>> with stack:\n" +"... stack.callback(print, \"Callback: from outer context\")\n" +"... with stack:\n" +"... stack.callback(print, \"Callback: from inner context\")\n" +"... print(\"Leaving inner context\")\n" +"... print(\"Leaving outer context\")\n" +"...\n" +"Leaving inner context\n" +"Callback: from inner context\n" +"Callback: from outer context\n" +"Leaving outer context" +msgstr "" + +#: library/contextlib.rst:1023 msgid "" "As the output from the example shows, reusing a single stack object across " "multiple with statements works correctly, but attempting to nest them will " @@ -853,8 +1391,24 @@ msgid "" "which is unlikely to be desirable behaviour." msgstr "" -#: library/contextlib.rst:1026 +#: library/contextlib.rst:1028 msgid "" "Using separate :class:`ExitStack` instances instead of reusing a single " "instance avoids that problem::" msgstr "" + +#: library/contextlib.rst:1031 +msgid "" +">>> from contextlib import ExitStack\n" +">>> with ExitStack() as outer_stack:\n" +"... outer_stack.callback(print, \"Callback: from outer context\")\n" +"... with ExitStack() as inner_stack:\n" +"... inner_stack.callback(print, \"Callback: from inner context\")\n" +"... print(\"Leaving inner context\")\n" +"... print(\"Leaving outer context\")\n" +"...\n" +"Leaving inner context\n" +"Callback: from inner context\n" +"Leaving outer context\n" +"Callback: from outer context" +msgstr "" diff --git a/library/contextvars.po b/library/contextvars.po index 2007ab1f..bfe9b311 100644 --- a/library/contextvars.po +++ b/library/contextvars.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/contextvars.rst:2 -msgid ":mod:`contextvars` --- Context Variables" +msgid ":mod:`!contextvars` --- Context Variables" msgstr "" #: library/contextvars.rst:11 @@ -31,9 +32,9 @@ msgstr "" #: library/contextvars.rst:17 msgid "" -"Context managers that have state should use Context Variables instead of :" -"func:`threading.local()` to prevent their state from bleeding to other code " -"unexpectedly, when used in concurrent code." +"Context managers that have state should use Context Variables instead " +"of :func:`threading.local` to prevent their state from bleeding to other " +"code unexpectedly, when used in concurrent code." msgstr "" #: library/contextvars.rst:21 @@ -48,6 +49,10 @@ msgstr "" msgid "This class is used to declare a new Context Variable, e.g.::" msgstr "" +#: library/contextvars.rst:33 +msgid "var: ContextVar[int] = ContextVar('var', default=42)" +msgstr "" + #: library/contextvars.rst:35 msgid "" "The required *name* parameter is used for introspection and debug purposes." @@ -55,9 +60,9 @@ msgstr "" #: library/contextvars.rst:38 msgid "" -"The optional keyword-only *default* parameter is returned by :meth:" -"`ContextVar.get` when no value for the variable is found in the current " -"context." +"The optional keyword-only *default* parameter is returned " +"by :meth:`ContextVar.get` when no value for the variable is found in the " +"current context." msgstr "" #: library/contextvars.rst:42 @@ -115,14 +120,26 @@ msgstr "" #: library/contextvars.rst:82 msgid "" -"Reset the context variable to the value it had before the :meth:`ContextVar." -"set` that created the *token* was used." +"Reset the context variable to the value it had before " +"the :meth:`ContextVar.set` that created the *token* was used." msgstr "" #: library/contextvars.rst:85 msgid "For example::" msgstr "" +#: library/contextvars.rst:87 +msgid "" +"var = ContextVar('var')\n" +"\n" +"token = var.set('new value')\n" +"# code that uses 'var'; var.get() returns 'new value'.\n" +"var.reset(token)\n" +"\n" +"# After the reset call the var has no value again, so\n" +"# var.get() would raise a LookupError." +msgstr "" + #: library/contextvars.rst:99 msgid "" "*Token* objects are returned by the :meth:`ContextVar.set` method. They can " @@ -138,9 +155,9 @@ msgstr "" #: library/contextvars.rst:111 msgid "" -"A read-only property. Set to the value the variable had before the :meth:" -"`ContextVar.set` method call that created the token. It points to :attr:" -"`Token.MISSING` if the variable was not set before the call." +"A read-only property. Set to the value the variable had before " +"the :meth:`ContextVar.set` method call that created the token. It points " +"to :attr:`Token.MISSING` if the variable was not set before the call." msgstr "" #: library/contextvars.rst:118 @@ -161,6 +178,12 @@ msgid "" "variables and their values that are set in it::" msgstr "" +#: library/contextvars.rst:131 +msgid "" +"ctx: Context = copy_context()\n" +"print(list(ctx.items()))" +msgstr "" + #: library/contextvars.rst:134 msgid "" "The function has an *O*\\ (1) complexity, i.e. works equally fast for " @@ -182,7 +205,7 @@ msgstr "" msgid "" "Every thread will have a different top-level :class:`~contextvars.Context` " "object. This means that a :class:`ContextVar` object behaves in a similar " -"fashion to :func:`threading.local()` when values are assigned in different " +"fashion to :func:`threading.local` when values are assigned in different " "threads." msgstr "" @@ -203,6 +226,35 @@ msgid "" "in the context object::" msgstr "" +#: library/contextvars.rst:163 +msgid "" +"var = ContextVar('var')\n" +"var.set('spam')\n" +"\n" +"def main():\n" +" # 'var' was set to 'spam' before\n" +" # calling 'copy_context()' and 'ctx.run(main)', so:\n" +" # var.get() == ctx[var] == 'spam'\n" +"\n" +" var.set('ham')\n" +"\n" +" # Now, after setting 'var' to 'ham':\n" +" # var.get() == ctx[var] == 'ham'\n" +"\n" +"ctx = copy_context()\n" +"\n" +"# Any changes that the 'main' function makes to 'var'\n" +"# will be contained in 'ctx'.\n" +"ctx.run(main)\n" +"\n" +"# The 'main()' function was run in the 'ctx' context,\n" +"# so changes to 'var' are contained in it:\n" +"# ctx[var] == 'ham'\n" +"\n" +"# However, outside of 'ctx', 'var' is still set to 'spam':\n" +"# var.get() == 'spam'" +msgstr "" + #: library/contextvars.rst:189 msgid "" "The method raises a :exc:`RuntimeError` when called on the same context " @@ -264,3 +316,49 @@ msgid "" "server, that uses a context variable to make the address of a remote client " "available in the Task that handles that client::" msgstr "" + +#: library/contextvars.rst:247 +msgid "" +"import asyncio\n" +"import contextvars\n" +"\n" +"client_addr_var = contextvars.ContextVar('client_addr')\n" +"\n" +"def render_goodbye():\n" +" # The address of the currently handled client can be accessed\n" +" # without passing it explicitly to this function.\n" +"\n" +" client_addr = client_addr_var.get()\n" +" return f'Good bye, client @ {client_addr}\\r\\n'.encode()\n" +"\n" +"async def handle_request(reader, writer):\n" +" addr = writer.transport.get_extra_info('socket').getpeername()\n" +" client_addr_var.set(addr)\n" +"\n" +" # In any code that we call is now possible to get\n" +" # client's address by calling 'client_addr_var.get()'.\n" +"\n" +" while True:\n" +" line = await reader.readline()\n" +" print(line)\n" +" if not line.strip():\n" +" break\n" +"\n" +" writer.write(b'HTTP/1.1 200 OK\\r\\n') # status line\n" +" writer.write(b'\\r\\n') # headers\n" +" writer.write(render_goodbye()) # body\n" +" writer.close()\n" +"\n" +"async def main():\n" +" srv = await asyncio.start_server(\n" +" handle_request, '127.0.0.1', 8081)\n" +"\n" +" async with srv:\n" +" await srv.serve_forever()\n" +"\n" +"asyncio.run(main())\n" +"\n" +"# To test it you can use telnet or curl:\n" +"# telnet 127.0.0.1 8081\n" +"# curl 127.0.0.1:8081" +msgstr "" diff --git a/library/copy.po b/library/copy.po index f9085add..8f68978f 100644 --- a/library/copy.po +++ b/library/copy.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/copy.rst:2 -msgid ":mod:`copy` --- Shallow and deep copy operations" +msgid ":mod:`!copy` --- Shallow and deep copy operations" msgstr "" #: library/copy.rst:7 @@ -107,8 +108,8 @@ msgid "" "This module does not copy types like module, method, stack trace, stack " "frame, file, socket, window, or any similar types. It does \"copy\" " "functions and classes (shallow and deeply), by returning the original object " -"unchanged; this is compatible with the way these are treated by the :mod:" -"`pickle` module." +"unchanged; this is compatible with the way these are treated by " +"the :mod:`pickle` module." msgstr "" #: library/copy.rst:67 @@ -133,13 +134,13 @@ msgid "" "called to implement the shallow copy operation; no additional arguments are " "passed. The latter is called to implement the deep copy operation; it is " "passed one argument, the ``memo`` dictionary. If the :meth:`__deepcopy__` " -"implementation needs to make a deep copy of a component, it should call the :" -"func:`deepcopy` function with the component as first argument and the memo " -"dictionary as second argument. The memo dictionary should be treated as an " -"opaque object." +"implementation needs to make a deep copy of a component, it should call " +"the :func:`deepcopy` function with the component as first argument and the " +"memo dictionary as second argument. The memo dictionary should be treated as " +"an opaque object." msgstr "" -#: library/copy.rst:95 +#: library/copy.rst:94 msgid "Module :mod:`pickle`" msgstr "" diff --git a/library/copyreg.po b/library/copyreg.po index d612616c..be411f2c 100644 --- a/library/copyreg.po +++ b/library/copyreg.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/copyreg.rst:2 -msgid ":mod:`copyreg` --- Register :mod:`pickle` support functions" +msgid ":mod:`!copyreg` --- Register :mod:`!pickle` support functions" msgstr "" #: library/copyreg.rst:7 @@ -43,8 +44,9 @@ msgstr "" msgid "" "Declares that *function* should be used as a \"reduction\" function for " "objects of type *type*. *function* must return either a string or a tuple " -"containing between two and six elements. See the :attr:`~pickle.Pickler." -"dispatch_table` for more details on the interface of *function*." +"containing between two and six elements. See " +"the :attr:`~pickle.Pickler.dispatch_table` for more details on the interface " +"of *function*." msgstr "" #: library/copyreg.rst:35 diff --git a/library/crypt.po b/library/crypt.po index 6f216e7e..c7ad332f 100644 --- a/library/crypt.po +++ b/library/crypt.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,12 +25,12 @@ msgstr "" msgid "**Source code:** :source:`Lib/crypt.py`" msgstr "" -#: library/crypt.rst:24 +#: library/crypt.rst:19 msgid "" "The :mod:`crypt` module is deprecated (see :pep:`PEP 594 <594#crypt>` for " "details and alternatives). The :mod:`hashlib` module is a potential " -"replacement for certain use cases. The `passlib `_ package can replace all use cases of this module." +"replacement for certain use cases. The :pypi:`passlib` package can replace " +"all use cases of this module." msgstr "" #: library/crypt.rst:27 @@ -49,12 +50,8 @@ msgid "" "be available on this module." msgstr "" -#: library/crypt.rst:40 -msgid ":ref:`Availability `: Unix, not VxWorks." -msgstr "" - #: includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." +msgid "Availability" msgstr "" #: includes/wasm-notavail.rst:5 @@ -173,8 +170,8 @@ msgstr "" #: library/crypt.rst:135 msgid "" -"The return value is a string suitable for passing as the *salt* argument to :" -"func:`crypt`." +"The return value is a string suitable for passing as the *salt* argument " +"to :func:`crypt`." msgstr "" #: library/crypt.rst:138 @@ -183,8 +180,8 @@ msgid "" "``METHOD_SHA512`` and ``METHOD_BLOWFISH``. For ``METHOD_SHA256`` and " "``METHOD_SHA512`` it must be an integer between ``1000`` and " "``999_999_999``, the default is ``5000``. For ``METHOD_BLOWFISH`` it must " -"be a power of two between ``16`` (2\\ :sup:`4`) and ``2_147_483_648`` (2\\ :" -"sup:`31`), the default is ``4096`` (2\\ :sup:`12`)." +"be a power of two between ``16`` (2\\ :sup:`4`) and ``2_147_483_648`` " +"(2\\ :sup:`31`), the default is ``4096`` (2\\ :sup:`12`)." msgstr "" #: library/crypt.rst:148 @@ -198,8 +195,28 @@ msgstr "" #: library/crypt.rst:155 msgid "" "A simple example illustrating typical use (a constant-time comparison " -"operation is needed to limit exposure to timing attacks. :func:`hmac." -"compare_digest` is suitable for this purpose)::" +"operation is needed to limit exposure to timing " +"attacks. :func:`hmac.compare_digest` is suitable for this purpose)::" +msgstr "" + +#: library/crypt.rst:159 +msgid "" +"import pwd\n" +"import crypt\n" +"import getpass\n" +"from hmac import compare_digest as compare_hash\n" +"\n" +"def login():\n" +" username = input('Python login: ')\n" +" cryptedpasswd = pwd.getpwnam(username)[1]\n" +" if cryptedpasswd:\n" +" if cryptedpasswd == 'x' or cryptedpasswd == '*':\n" +" raise ValueError('no support for shadow passwords')\n" +" cleartext = getpass.getpass()\n" +" return compare_hash(crypt.crypt(cleartext, cryptedpasswd), " +"cryptedpasswd)\n" +" else:\n" +" return True" msgstr "" #: library/crypt.rst:175 @@ -208,6 +225,16 @@ msgid "" "check it against the original::" msgstr "" +#: library/crypt.rst:178 +msgid "" +"import crypt\n" +"from hmac import compare_digest as compare_hash\n" +"\n" +"hashed = crypt.crypt(plaintext)\n" +"if not compare_hash(hashed, crypt.crypt(plaintext, hashed)):\n" +" raise ValueError(\"hashed version doesn't validate against original\")" +msgstr "" + #: library/crypt.rst:33 library/crypt.rst:119 msgid "crypt(3)" msgstr "" diff --git a/library/crypto.po b/library/crypto.po index ce956935..daae59e7 100644 --- a/library/crypto.po +++ b/library/crypto.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/csv.po b/library/csv.po index 3f1f9816..53ad3b78 100644 --- a/library/csv.po +++ b/library/csv.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/csv.rst:2 -msgid ":mod:`csv` --- CSV File Reading and Writing" +msgid ":mod:`!csv` --- CSV File Reading and Writing" msgstr "" #: library/csv.rst:9 @@ -94,10 +95,21 @@ msgid "" "into floats)." msgstr "" -#: library/csv.rst:106 library/csv.rst:217 +#: library/csv.rst:106 library/csv.rst:219 msgid "A short usage example::" msgstr "" +#: library/csv.rst:78 +msgid "" +">>> import csv\n" +">>> with open('eggs.csv', newline='') as csvfile:\n" +"... spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')\n" +"... for row in spamreader:\n" +"... print(', '.join(row))\n" +"Spam, Spam, Spam, Spam, Spam, Baked Beans\n" +"Spam, Lovely Spam, Wonderful Spam" +msgstr "" + #: library/csv.rst:89 msgid "" "Return a writer object responsible for converting the user's data into " @@ -105,12 +117,12 @@ msgid "" "object with a :meth:`~io.TextIOBase.write` method. If *csvfile* is a file " "object, it should be opened with ``newline=''`` [1]_. An optional *dialect* " "parameter can be given which is used to define a set of parameters specific " -"to a particular CSV dialect. It may be an instance of a subclass of the :" -"class:`Dialect` class or one of the strings returned by the :func:" -"`list_dialects` function. The other optional *fmtparams* keyword arguments " -"can be given to override individual formatting parameters in the current " -"dialect. For full details about dialects and formatting parameters, see " -"the :ref:`csv-fmt-params` section. To make it as easy as possible to " +"to a particular CSV dialect. It may be an instance of a subclass of " +"the :class:`Dialect` class or one of the strings returned by " +"the :func:`list_dialects` function. The other optional *fmtparams* keyword " +"arguments can be given to override individual formatting parameters in the " +"current dialect. For full details about dialects and formatting parameters, " +"see the :ref:`csv-fmt-params` section. To make it as easy as possible to " "interface with modules which implement the DB API, the value :const:`None` " "is written as the empty string. While this isn't a reversible " "transformation, it makes it easier to dump SQL NULL data values to CSV files " @@ -118,6 +130,16 @@ msgid "" "other non-string data are stringified with :func:`str` before being written." msgstr "" +#: library/csv.rst:108 +msgid "" +"import csv\n" +"with open('eggs.csv', 'w', newline='') as csvfile:\n" +" spamwriter = csv.writer(csvfile, delimiter=' ',\n" +" quotechar='|', quoting=csv.QUOTE_MINIMAL)\n" +" spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])\n" +" spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])" +msgstr "" + #: library/csv.rst:118 msgid "" "Associate *dialect* with *name*. *name* must be a string. The dialect can " @@ -129,8 +151,8 @@ msgstr "" #: library/csv.rst:127 msgid "" -"Delete the dialect associated with *name* from the dialect registry. An :" -"exc:`Error` is raised if *name* is not a registered dialect name." +"Delete the dialect associated with *name* from the dialect registry. " +"An :exc:`Error` is raised if *name* is not a registered dialect name." msgstr "" #: library/csv.rst:133 @@ -165,11 +187,13 @@ msgstr "" msgid "" "The *fieldnames* parameter is a :term:`sequence`. If *fieldnames* is " "omitted, the values in the first row of file *f* will be used as the " -"fieldnames. Regardless of how the fieldnames are determined, the dictionary " +"fieldnames and will be omitted from the results. If *fieldnames* is " +"provided, they will be used and the first row will be included in the " +"results. Regardless of how the fieldnames are determined, the dictionary " "preserves their original ordering." msgstr "" -#: library/csv.rst:162 +#: library/csv.rst:164 msgid "" "If a row has more fields than fieldnames, the remaining data is put in a " "list and stored with the fieldname specified by *restkey* (which defaults to " @@ -178,27 +202,42 @@ msgid "" "``None``)." msgstr "" -#: library/csv.rst:168 +#: library/csv.rst:170 msgid "" -"All other optional or keyword arguments are passed to the underlying :class:" -"`reader` instance." +"All other optional or keyword arguments are passed to the " +"underlying :class:`reader` instance." msgstr "" -#: library/csv.rst:215 +#: library/csv.rst:217 msgid "" "If the argument passed to *fieldnames* is an iterator, it will be coerced to " "a :class:`list`." msgstr "" -#: library/csv.rst:173 +#: library/csv.rst:175 msgid "Returned rows are now of type :class:`OrderedDict`." msgstr "" -#: library/csv.rst:176 +#: library/csv.rst:178 msgid "Returned rows are now of type :class:`dict`." msgstr "" -#: library/csv.rst:197 +#: library/csv.rst:183 +msgid "" +">>> import csv\n" +">>> with open('names.csv', newline='') as csvfile:\n" +"... reader = csv.DictReader(csvfile)\n" +"... for row in reader:\n" +"... print(row['first_name'], row['last_name'])\n" +"...\n" +"Eric Idle\n" +"John Cleese\n" +"\n" +">>> print(row)\n" +"{'first_name': 'John', 'last_name': 'Cleese'}" +msgstr "" + +#: library/csv.rst:199 msgid "" "Create an object which operates like a regular writer but maps dictionaries " "onto output rows. The *fieldnames* parameter is a :mod:`sequence " @@ -208,129 +247,160 @@ msgid "" "written if the dictionary is missing a key in *fieldnames*. If the " "dictionary passed to the :meth:`~csvwriter.writerow` method contains a key " "not found in *fieldnames*, the optional *extrasaction* parameter indicates " -"what action to take. If it is set to ``'raise'``, the default value, a :exc:" -"`ValueError` is raised. If it is set to ``'ignore'``, extra values in the " -"dictionary are ignored. Any other optional or keyword arguments are passed " -"to the underlying :class:`writer` instance." +"what action to take. If it is set to ``'raise'``, the default value, " +"a :exc:`ValueError` is raised. If it is set to ``'ignore'``, extra values in " +"the dictionary are ignored. Any other optional or keyword arguments are " +"passed to the underlying :class:`writer` instance." msgstr "" -#: library/csv.rst:212 +#: library/csv.rst:214 msgid "" "Note that unlike the :class:`DictReader` class, the *fieldnames* parameter " "of the :class:`DictWriter` class is not optional." msgstr "" -#: library/csv.rst:233 +#: library/csv.rst:221 +msgid "" +"import csv\n" +"\n" +"with open('names.csv', 'w', newline='') as csvfile:\n" +" fieldnames = ['first_name', 'last_name']\n" +" writer = csv.DictWriter(csvfile, fieldnames=fieldnames)\n" +"\n" +" writer.writeheader()\n" +" writer.writerow({'first_name': 'Baked', 'last_name': 'Beans'})\n" +" writer.writerow({'first_name': 'Lovely', 'last_name': 'Spam'})\n" +" writer.writerow({'first_name': 'Wonderful', 'last_name': 'Spam'})" +msgstr "" + +#: library/csv.rst:235 msgid "" "The :class:`Dialect` class is a container class whose attributes contain " "information for how to handle doublequotes, whitespace, delimiters, etc. Due " "to the lack of a strict CSV specification, different applications produce " -"subtly different CSV data. :class:`Dialect` instances define how :class:" -"`reader` and :class:`writer` instances behave." +"subtly different CSV data. :class:`Dialect` instances define " +"how :class:`reader` and :class:`writer` instances behave." msgstr "" -#: library/csv.rst:239 +#: library/csv.rst:241 msgid "" "All available :class:`Dialect` names are returned by :func:`list_dialects`, " "and they can be registered with specific :class:`reader` and :class:`writer` " "classes through their initializer (``__init__``) functions like this::" msgstr "" -#: library/csv.rst:251 +#: library/csv.rst:245 +msgid "" +"import csv\n" +"\n" +"with open('students.csv', 'w', newline='') as csvfile:\n" +" writer = csv.writer(csvfile, dialect='unix')" +msgstr "" + +#: library/csv.rst:253 msgid "" "The :class:`excel` class defines the usual properties of an Excel-generated " "CSV file. It is registered with the dialect name ``'excel'``." msgstr "" -#: library/csv.rst:257 +#: library/csv.rst:259 msgid "" "The :class:`excel_tab` class defines the usual properties of an Excel-" "generated TAB-delimited file. It is registered with the dialect name " "``'excel-tab'``." msgstr "" -#: library/csv.rst:263 +#: library/csv.rst:265 msgid "" "The :class:`unix_dialect` class defines the usual properties of a CSV file " "generated on UNIX systems, i.e. using ``'\\n'`` as line terminator and " "quoting all fields. It is registered with the dialect name ``'unix'``." msgstr "" -#: library/csv.rst:272 +#: library/csv.rst:274 msgid "The :class:`Sniffer` class is used to deduce the format of a CSV file." msgstr "" -#: library/csv.rst:274 +#: library/csv.rst:276 msgid "The :class:`Sniffer` class provides two methods:" msgstr "" -#: library/csv.rst:278 +#: library/csv.rst:280 msgid "" "Analyze the given *sample* and return a :class:`Dialect` subclass reflecting " "the parameters found. If the optional *delimiters* parameter is given, it " "is interpreted as a string containing possible valid delimiter characters." msgstr "" -#: library/csv.rst:286 +#: library/csv.rst:288 msgid "" -"Analyze the sample text (presumed to be in CSV format) and return :const:" -"`True` if the first row appears to be a series of column headers. Inspecting " -"each column, one of two key criteria will be considered to estimate if the " -"sample contains a header:" +"Analyze the sample text (presumed to be in CSV format) and " +"return :const:`True` if the first row appears to be a series of column " +"headers. Inspecting each column, one of two key criteria will be considered " +"to estimate if the sample contains a header:" msgstr "" -#: library/csv.rst:291 +#: library/csv.rst:293 msgid "the second through n-th rows contain numeric values" msgstr "" -#: library/csv.rst:292 +#: library/csv.rst:294 msgid "" "the second through n-th rows contain strings where at least one value's " "length differs from that of the putative header of that column." msgstr "" -#: library/csv.rst:295 +#: library/csv.rst:297 msgid "" "Twenty rows after the first row are sampled; if more than half of columns + " "rows meet the criteria, :const:`True` is returned." msgstr "" -#: library/csv.rst:300 +#: library/csv.rst:302 msgid "" "This method is a rough heuristic and may produce both false positives and " "negatives." msgstr "" -#: library/csv.rst:303 +#: library/csv.rst:305 msgid "An example for :class:`Sniffer` use::" msgstr "" -#: library/csv.rst:314 +#: library/csv.rst:307 +msgid "" +"with open('example.csv', newline='') as csvfile:\n" +" dialect = csv.Sniffer().sniff(csvfile.read(1024))\n" +" csvfile.seek(0)\n" +" reader = csv.reader(csvfile, dialect)\n" +" # ... process CSV file contents here ..." +msgstr "" + +#: library/csv.rst:316 msgid "The :mod:`csv` module defines the following constants:" msgstr "" -#: library/csv.rst:318 +#: library/csv.rst:320 msgid "Instructs :class:`writer` objects to quote all fields." msgstr "" -#: library/csv.rst:323 +#: library/csv.rst:325 msgid "" "Instructs :class:`writer` objects to only quote those fields which contain " "special characters such as *delimiter*, *quotechar* or any of the characters " "in *lineterminator*." msgstr "" -#: library/csv.rst:330 +#: library/csv.rst:332 msgid "Instructs :class:`writer` objects to quote all non-numeric fields." msgstr "" -#: library/csv.rst:332 +#: library/csv.rst:334 msgid "" "Instructs :class:`reader` objects to convert all non-quoted fields to type " "*float*." msgstr "" -#: library/csv.rst:337 +#: library/csv.rst:339 msgid "" "Instructs :class:`writer` objects to never quote fields. When the current " "*delimiter* occurs in output data it is preceded by the current *escapechar* " @@ -338,87 +408,94 @@ msgid "" "if any characters that require escaping are encountered." msgstr "" -#: library/csv.rst:342 +#: library/csv.rst:344 msgid "" "Instructs :class:`reader` objects to perform no special processing of quote " "characters." msgstr "" -#: library/csv.rst:346 +#: library/csv.rst:348 msgid "" "Instructs :class:`writer` objects to quote all fields which are not " "``None``. This is similar to :data:`QUOTE_ALL`, except that if a field " "value is ``None`` an empty (unquoted) string is written." msgstr "" -#: library/csv.rst:350 +#: library/csv.rst:352 msgid "" "Instructs :class:`reader` objects to interpret an empty (unquoted) field as " -"None and to otherwise behave as :data:`QUOTE_ALL`." +"``None`` and to otherwise behave as :data:`QUOTE_ALL`." msgstr "" -#: library/csv.rst:357 +#: library/csv.rst:359 msgid "" "Instructs :class:`writer` objects to always place quotes around fields which " "are strings. This is similar to :data:`QUOTE_NONNUMERIC`, except that if a " "field value is ``None`` an empty (unquoted) string is written." msgstr "" -#: library/csv.rst:361 +#: library/csv.rst:363 msgid "" "Instructs :class:`reader` objects to interpret an empty (unquoted) string as " "``None`` and to otherwise behave as :data:`QUOTE_NONNUMERIC`." msgstr "" -#: library/csv.rst:366 +#: library/csv.rst:370 +msgid "" +"Due to a bug, constants :data:`QUOTE_NOTNULL` and :data:`QUOTE_STRINGS` do " +"not affect behaviour of :class:`reader` objects. This bug is fixed in Python " +"3.13." +msgstr "" + +#: library/csv.rst:374 msgid "The :mod:`csv` module defines the following exception:" msgstr "" -#: library/csv.rst:371 +#: library/csv.rst:379 msgid "Raised by any of the functions when an error is detected." msgstr "" -#: library/csv.rst:376 +#: library/csv.rst:384 msgid "Dialects and Formatting Parameters" msgstr "" -#: library/csv.rst:378 +#: library/csv.rst:386 msgid "" "To make it easier to specify the format of input and output records, " "specific formatting parameters are grouped together into dialects. A " "dialect is a subclass of the :class:`Dialect` class containing various " -"attributes describing the format of the CSV file. When creating :class:" -"`reader` or :class:`writer` objects, the programmer can specify a string or " -"a subclass of the :class:`Dialect` class as the dialect parameter. In " -"addition to, or instead of, the *dialect* parameter, the programmer can also " -"specify individual formatting parameters, which have the same names as the " -"attributes defined below for the :class:`Dialect` class." +"attributes describing the format of the CSV file. When " +"creating :class:`reader` or :class:`writer` objects, the programmer can " +"specify a string or a subclass of the :class:`Dialect` class as the dialect " +"parameter. In addition to, or instead of, the *dialect* parameter, the " +"programmer can also specify individual formatting parameters, which have the " +"same names as the attributes defined below for the :class:`Dialect` class." msgstr "" -#: library/csv.rst:388 +#: library/csv.rst:396 msgid "Dialects support the following attributes:" msgstr "" -#: library/csv.rst:393 +#: library/csv.rst:401 msgid "" "A one-character string used to separate fields. It defaults to ``','``." msgstr "" -#: library/csv.rst:398 +#: library/csv.rst:406 msgid "" "Controls how instances of *quotechar* appearing inside a field should " -"themselves be quoted. When :const:`True`, the character is doubled. When :" -"const:`False`, the *escapechar* is used as a prefix to the *quotechar*. It " -"defaults to :const:`True`." +"themselves be quoted. When :const:`True`, the character is doubled. " +"When :const:`False`, the *escapechar* is used as a prefix to the " +"*quotechar*. It defaults to :const:`True`." msgstr "" -#: library/csv.rst:403 +#: library/csv.rst:411 msgid "" -"On output, if *doublequote* is :const:`False` and no *escapechar* is set, :" -"exc:`Error` is raised if a *quotechar* is found in a field." +"On output, if *doublequote* is :const:`False` and no *escapechar* is " +"set, :exc:`Error` is raised if a *quotechar* is found in a field." msgstr "" -#: library/csv.rst:409 +#: library/csv.rst:417 msgid "" "A one-character string used by the writer to escape the *delimiter* if " "*quoting* is set to :const:`QUOTE_NONE` and the *quotechar* if *doublequote* " @@ -427,64 +504,64 @@ msgid "" "escaping." msgstr "" -#: library/csv.rst:414 +#: library/csv.rst:422 msgid "An empty *escapechar* is not allowed." msgstr "" -#: library/csv.rst:419 +#: library/csv.rst:427 msgid "" "The string used to terminate lines produced by the :class:`writer`. It " "defaults to ``'\\r\\n'``." msgstr "" -#: library/csv.rst:424 +#: library/csv.rst:432 msgid "" "The :class:`reader` is hard-coded to recognise either ``'\\r'`` or ``'\\n'`` " "as end-of-line, and ignores *lineterminator*. This behavior may change in " "the future." msgstr "" -#: library/csv.rst:431 +#: library/csv.rst:439 msgid "" "A one-character string used to quote fields containing special characters, " "such as the *delimiter* or *quotechar*, or which contain new-line " "characters. It defaults to ``'\"'``." msgstr "" -#: library/csv.rst:435 +#: library/csv.rst:443 msgid "An empty *quotechar* is not allowed." msgstr "" -#: library/csv.rst:440 +#: library/csv.rst:448 msgid "" "Controls when quotes should be generated by the writer and recognised by the " "reader. It can take on any of the :ref:`QUOTE_\\* constants ` and defaults to :const:`QUOTE_MINIMAL`." msgstr "" -#: library/csv.rst:447 +#: library/csv.rst:455 msgid "" "When :const:`True`, spaces immediately following the *delimiter* are " "ignored. The default is :const:`False`." msgstr "" -#: library/csv.rst:453 +#: library/csv.rst:461 msgid "" "When ``True``, raise exception :exc:`Error` on bad CSV input. The default is " "``False``." msgstr "" -#: library/csv.rst:459 +#: library/csv.rst:467 msgid "Reader Objects" msgstr "" -#: library/csv.rst:461 +#: library/csv.rst:469 msgid "" -"Reader objects (:class:`DictReader` instances and objects returned by the :" -"func:`reader` function) have the following public methods:" +"Reader objects (:class:`DictReader` instances and objects returned by " +"the :func:`reader` function) have the following public methods:" msgstr "" -#: library/csv.rst:466 +#: library/csv.rst:474 msgid "" "Return the next row of the reader's iterable object as a list (if the object " "was returned from :func:`reader`) or a dict (if it is a :class:`DictReader` " @@ -492,35 +569,35 @@ msgid "" "should call this as ``next(reader)``." msgstr "" -#: library/csv.rst:472 +#: library/csv.rst:480 msgid "Reader objects have the following public attributes:" msgstr "" -#: library/csv.rst:476 +#: library/csv.rst:484 msgid "A read-only description of the dialect in use by the parser." msgstr "" -#: library/csv.rst:481 +#: library/csv.rst:489 msgid "" "The number of lines read from the source iterator. This is not the same as " "the number of records returned, as records can span multiple lines." msgstr "" -#: library/csv.rst:485 +#: library/csv.rst:493 msgid "DictReader objects have the following public attribute:" msgstr "" -#: library/csv.rst:489 +#: library/csv.rst:497 msgid "" "If not passed as a parameter when creating the object, this attribute is " "initialized upon first access or when the first record is read from the file." msgstr "" -#: library/csv.rst:496 +#: library/csv.rst:504 msgid "Writer Objects" msgstr "" -#: library/csv.rst:498 +#: library/csv.rst:506 msgid "" ":class:`writer` objects (:class:`DictWriter` instances and objects returned " "by the :func:`writer` function) have the following public methods. A *row* " @@ -532,106 +609,169 @@ msgid "" "complex numbers at all)." msgstr "" -#: library/csv.rst:509 +#: library/csv.rst:517 msgid "" "Write the *row* parameter to the writer's file object, formatted according " "to the current :class:`Dialect`. Return the return value of the call to the " "*write* method of the underlying file object." msgstr "" -#: library/csv.rst:513 +#: library/csv.rst:521 msgid "Added support of arbitrary iterables." msgstr "" -#: library/csv.rst:518 +#: library/csv.rst:526 msgid "" "Write all elements in *rows* (an iterable of *row* objects as described " "above) to the writer's file object, formatted according to the current " "dialect." msgstr "" -#: library/csv.rst:522 +#: library/csv.rst:530 msgid "Writer objects have the following public attribute:" msgstr "" -#: library/csv.rst:527 +#: library/csv.rst:535 msgid "A read-only description of the dialect in use by the writer." msgstr "" -#: library/csv.rst:530 +#: library/csv.rst:538 msgid "DictWriter objects have the following public method:" msgstr "" -#: library/csv.rst:535 +#: library/csv.rst:543 msgid "" "Write a row with the field names (as specified in the constructor) to the " "writer's file object, formatted according to the current dialect. Return the " "return value of the :meth:`csvwriter.writerow` call used internally." msgstr "" -#: library/csv.rst:540 +#: library/csv.rst:548 msgid "" -":meth:`writeheader` now also returns the value returned by the :meth:" -"`csvwriter.writerow` method it uses internally." +":meth:`writeheader` now also returns the value returned by " +"the :meth:`csvwriter.writerow` method it uses internally." msgstr "" -#: library/csv.rst:548 +#: library/csv.rst:556 msgid "Examples" msgstr "" -#: library/csv.rst:550 +#: library/csv.rst:558 msgid "The simplest example of reading a CSV file::" msgstr "" -#: library/csv.rst:558 -msgid "Reading a file with an alternate format::" +#: library/csv.rst:560 +msgid "" +"import csv\n" +"with open('some.csv', newline='') as f:\n" +" reader = csv.reader(f)\n" +" for row in reader:\n" +" print(row)" msgstr "" #: library/csv.rst:566 +msgid "Reading a file with an alternate format::" +msgstr "" + +#: library/csv.rst:568 +msgid "" +"import csv\n" +"with open('passwd', newline='') as f:\n" +" reader = csv.reader(f, delimiter=':', quoting=csv.QUOTE_NONE)\n" +" for row in reader:\n" +" print(row)" +msgstr "" + +#: library/csv.rst:574 msgid "The corresponding simplest possible writing example is::" msgstr "" -#: library/csv.rst:573 +#: library/csv.rst:576 +msgid "" +"import csv\n" +"with open('some.csv', 'w', newline='') as f:\n" +" writer = csv.writer(f)\n" +" writer.writerows(someiterable)" +msgstr "" + +#: library/csv.rst:581 msgid "" "Since :func:`open` is used to open a CSV file for reading, the file will by " -"default be decoded into unicode using the system default encoding (see :func:" -"`locale.getencoding`). To decode a file using a different encoding, use the " -"``encoding`` argument of open::" +"default be decoded into unicode using the system default encoding " +"(see :func:`locale.getencoding`). To decode a file using a different " +"encoding, use the ``encoding`` argument of open::" +msgstr "" + +#: library/csv.rst:586 +msgid "" +"import csv\n" +"with open('some.csv', newline='', encoding='utf-8') as f:\n" +" reader = csv.reader(f)\n" +" for row in reader:\n" +" print(row)" msgstr "" -#: library/csv.rst:584 +#: library/csv.rst:592 msgid "" "The same applies to writing in something other than the system default " "encoding: specify the encoding argument when opening the output file." msgstr "" -#: library/csv.rst:587 +#: library/csv.rst:595 msgid "Registering a new dialect::" msgstr "" -#: library/csv.rst:594 +#: library/csv.rst:597 +msgid "" +"import csv\n" +"csv.register_dialect('unixpwd', delimiter=':', quoting=csv.QUOTE_NONE)\n" +"with open('passwd', newline='') as f:\n" +" reader = csv.reader(f, 'unixpwd')" +msgstr "" + +#: library/csv.rst:602 msgid "" "A slightly more advanced use of the reader --- catching and reporting " "errors::" msgstr "" -#: library/csv.rst:606 +#: library/csv.rst:604 +msgid "" +"import csv, sys\n" +"filename = 'some.csv'\n" +"with open(filename, newline='') as f:\n" +" reader = csv.reader(f)\n" +" try:\n" +" for row in reader:\n" +" print(row)\n" +" except csv.Error as e:\n" +" sys.exit('file {}, line {}: {}'.format(filename, reader.line_num, e))" +msgstr "" + +#: library/csv.rst:614 msgid "" "And while the module doesn't directly support parsing strings, it can easily " "be done::" msgstr "" -#: library/csv.rst:615 +#: library/csv.rst:617 +msgid "" +"import csv\n" +"for row in csv.reader(['one,two,three']):\n" +" print(row)" +msgstr "" + +#: library/csv.rst:623 msgid "Footnotes" msgstr "" -#: library/csv.rst:616 +#: library/csv.rst:624 msgid "" "If ``newline=''`` is not specified, newlines embedded inside quoted fields " "will not be interpreted correctly, and on platforms that use ``\\r\\n`` " "linendings on write an extra ``\\r`` will be added. It should always be " -"safe to specify ``newline=''``, since the csv module does its own (:term:" -"`universal `) newline handling." +"safe to specify ``newline=''``, since the csv module does its own " +"(:term:`universal `) newline handling." msgstr "" #: library/csv.rst:11 diff --git a/library/ctypes.po b/library/ctypes.po index 7edd1cba..b9842292 100644 --- a/library/ctypes.po +++ b/library/ctypes.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/ctypes.rst:2 -msgid ":mod:`ctypes` --- A foreign function library for Python" +msgid ":mod:`!ctypes` --- A foreign function library for Python" msgstr "" #: library/ctypes.rst:9 @@ -45,9 +46,10 @@ msgstr "" #: library/ctypes.rst:27 msgid "" "Note: Some code samples reference the ctypes :class:`c_int` type. On " -"platforms where ``sizeof(long) == sizeof(int)`` it is an alias to :class:" -"`c_long`. So, you should not be confused if :class:`c_long` is printed if " -"you would expect :class:`c_int` --- they are actually the same type." +"platforms where ``sizeof(long) == sizeof(int)`` it is an alias " +"to :class:`c_long`. So, you should not be confused if :class:`c_long` is " +"printed if you would expect :class:`c_int` --- they are actually the same " +"type." msgstr "" #: library/ctypes.rst:35 @@ -73,15 +75,26 @@ msgstr "" #: library/ctypes.rst:48 msgid "" -"Windows errors used to raise :exc:`WindowsError`, which is now an alias of :" -"exc:`OSError`." +"Windows errors used to raise :exc:`WindowsError`, which is now an alias " +"of :exc:`OSError`." msgstr "" #: library/ctypes.rst:53 msgid "" "Here are some examples for Windows. Note that ``msvcrt`` is the MS standard " -"C library containing most standard C functions, and uses the cdecl calling " -"convention::" +"C library containing most standard C functions, and uses the ``cdecl`` " +"calling convention::" +msgstr "" + +#: library/ctypes.rst:57 +msgid "" +">>> from ctypes import *\n" +">>> print(windll.kernel32) \n" +"\n" +">>> print(cdll.msvcrt) \n" +"\n" +">>> libc = cdll.msvcrt \n" +">>>" msgstr "" #: library/ctypes.rst:65 @@ -105,6 +118,16 @@ msgid "" "CDLL by calling the constructor::" msgstr "" +#: library/ctypes.rst:79 +msgid "" +">>> cdll.LoadLibrary(\"libc.so.6\") \n" +"\n" +">>> libc = CDLL(\"libc.so.6\") \n" +">>> libc \n" +"\n" +">>>" +msgstr "" + #: library/ctypes.rst:92 msgid "Accessing functions from loaded dlls" msgstr "" @@ -113,76 +136,158 @@ msgstr "" msgid "Functions are accessed as attributes of dll objects::" msgstr "" -#: library/ctypes.rst:109 +#: library/ctypes.rst:96 +msgid "" +">>> libc.printf\n" +"<_FuncPtr object at 0x...>\n" +">>> print(windll.kernel32.GetModuleHandleA) \n" +"<_FuncPtr object at 0x...>\n" +">>> print(windll.kernel32.MyOwnFunction) \n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" File \"ctypes.py\", line 239, in __getattr__\n" +" func = _StdcallFuncPtr(name, self)\n" +"AttributeError: function 'MyOwnFunction' not found\n" +">>>" +msgstr "" + +#: library/ctypes.rst:108 msgid "" "Note that win32 system dlls like ``kernel32`` and ``user32`` often export " "ANSI as well as UNICODE versions of a function. The UNICODE version is " -"exported with an ``W`` appended to the name, while the ANSI version is " +"exported with a ``W`` appended to the name, while the ANSI version is " "exported with an ``A`` appended to the name. The win32 ``GetModuleHandle`` " "function, which returns a *module handle* for a given module name, has the " "following C prototype, and a macro is used to expose one of them as " "``GetModuleHandle`` depending on whether UNICODE is defined or not::" msgstr "" -#: library/ctypes.rst:122 +#: library/ctypes.rst:116 +msgid "" +"/* ANSI version */\n" +"HMODULE GetModuleHandleA(LPCSTR lpModuleName);\n" +"/* UNICODE version */\n" +"HMODULE GetModuleHandleW(LPCWSTR lpModuleName);" +msgstr "" + +#: library/ctypes.rst:121 msgid "" "*windll* does not try to select one of them by magic, you must access the " "version you need by specifying ``GetModuleHandleA`` or ``GetModuleHandleW`` " "explicitly, and then call it with bytes or string objects respectively." msgstr "" -#: library/ctypes.rst:126 +#: library/ctypes.rst:125 msgid "" "Sometimes, dlls export functions with names which aren't valid Python " -"identifiers, like ``\"??2@YAPAXI@Z\"``. In this case you have to use :func:" -"`getattr` to retrieve the function::" +"identifiers, like ``\"??2@YAPAXI@Z\"``. In this case you have to " +"use :func:`getattr` to retrieve the function::" +msgstr "" + +#: library/ctypes.rst:129 +msgid "" +">>> getattr(cdll.msvcrt, \"??2@YAPAXI@Z\") \n" +"<_FuncPtr object at 0x...>\n" +">>>" msgstr "" -#: library/ctypes.rst:134 +#: library/ctypes.rst:133 msgid "" "On Windows, some dlls export functions not by name but by ordinal. These " "functions can be accessed by indexing the dll object with the ordinal " "number::" msgstr "" -#: library/ctypes.rst:151 +#: library/ctypes.rst:136 +msgid "" +">>> cdll.kernel32[1] \n" +"<_FuncPtr object at 0x...>\n" +">>> cdll.kernel32[0] \n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" File \"ctypes.py\", line 310, in __getitem__\n" +" func = _StdcallFuncPtr(name, self)\n" +"AttributeError: function ordinal 0 not found\n" +">>>" +msgstr "" + +#: library/ctypes.rst:150 msgid "Calling functions" msgstr "" -#: library/ctypes.rst:153 +#: library/ctypes.rst:152 msgid "" "You can call these functions like any other Python callable. This example " "uses the ``rand()`` function, which takes no arguments and returns a pseudo-" "random integer::" msgstr "" -#: library/ctypes.rst:159 +#: library/ctypes.rst:155 +msgid "" +">>> print(libc.rand()) \n" +"1804289383" +msgstr "" + +#: library/ctypes.rst:158 msgid "" "On Windows, you can call the ``GetModuleHandleA()`` function, which returns " "a win32 module handle (passing ``None`` as single argument to call it with a " "``NULL`` pointer)::" msgstr "" -#: library/ctypes.rst:166 +#: library/ctypes.rst:161 +msgid "" +">>> print(hex(windll.kernel32.GetModuleHandleA(None))) \n" +"0x1d000000\n" +">>>" +msgstr "" + +#: library/ctypes.rst:165 msgid "" ":exc:`ValueError` is raised when you call an ``stdcall`` function with the " "``cdecl`` calling convention, or vice versa::" msgstr "" -#: library/ctypes.rst:181 +#: library/ctypes.rst:168 +msgid "" +">>> cdll.kernel32.GetModuleHandleA(None) \n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ValueError: Procedure probably called with not enough arguments (4 bytes " +"missing)\n" +">>>\n" +"\n" +">>> windll.msvcrt.printf(b\"spam\") \n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ValueError: Procedure probably called with too many arguments (4 bytes in " +"excess)\n" +">>>" +msgstr "" + +#: library/ctypes.rst:180 msgid "" "To find out the correct calling convention you have to look into the C " "header file or the documentation for the function you want to call." msgstr "" -#: library/ctypes.rst:184 +#: library/ctypes.rst:183 msgid "" "On Windows, :mod:`ctypes` uses win32 structured exception handling to " "prevent crashes from general protection faults when functions are called " "with invalid argument values::" msgstr "" -#: library/ctypes.rst:194 +#: library/ctypes.rst:187 +msgid "" +">>> windll.kernel32.GetModuleHandleA(32) \n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"OSError: exception: access violation reading 0x00000020\n" +">>>" +msgstr "" + +#: library/ctypes.rst:193 msgid "" "There are, however, enough ways to crash Python with :mod:`ctypes`, so you " "should be careful anyway. The :mod:`faulthandler` module can be helpful in " @@ -190,283 +295,347 @@ msgid "" "library calls)." msgstr "" -#: library/ctypes.rst:199 +#: library/ctypes.rst:198 msgid "" "``None``, integers, bytes objects and (unicode) strings are the only native " "Python objects that can directly be used as parameters in these function " "calls. ``None`` is passed as a C ``NULL`` pointer, bytes objects and strings " -"are passed as pointer to the memory block that contains their data (:c:expr:" -"`char *` or :c:expr:`wchar_t *`). Python integers are passed as the " -"platforms default C :c:expr:`int` type, their value is masked to fit into " -"the C type." +"are passed as pointer to the memory block that contains their data " +"(:c:expr:`char *` or :c:expr:`wchar_t *`). Python integers are passed as " +"the platforms default C :c:expr:`int` type, their value is masked to fit " +"into the C type." msgstr "" -#: library/ctypes.rst:206 +#: library/ctypes.rst:205 msgid "" "Before we move on calling functions with other parameter types, we have to " "learn more about :mod:`ctypes` data types." msgstr "" -#: library/ctypes.rst:2199 +#: library/ctypes.rst:2237 msgid "Fundamental data types" msgstr "" -#: library/ctypes.rst:215 +#: library/ctypes.rst:214 msgid ":mod:`ctypes` defines a number of primitive C compatible data types:" msgstr "" -#: library/ctypes.rst:218 +#: library/ctypes.rst:217 msgid "ctypes type" msgstr "" -#: library/ctypes.rst:218 +#: library/ctypes.rst:217 msgid "C type" msgstr "" -#: library/ctypes.rst:218 +#: library/ctypes.rst:217 msgid "Python type" msgstr "" -#: library/ctypes.rst:220 +#: library/ctypes.rst:219 msgid ":class:`c_bool`" msgstr "" -#: library/ctypes.rst:220 +#: library/ctypes.rst:219 msgid ":c:expr:`_Bool`" msgstr "" -#: library/ctypes.rst:220 +#: library/ctypes.rst:219 msgid "bool (1)" msgstr "" -#: library/ctypes.rst:222 +#: library/ctypes.rst:221 msgid ":class:`c_char`" msgstr "" -#: library/ctypes.rst:226 +#: library/ctypes.rst:225 msgid ":c:expr:`char`" msgstr "" -#: library/ctypes.rst:222 +#: library/ctypes.rst:221 msgid "1-character bytes object" msgstr "" -#: library/ctypes.rst:224 +#: library/ctypes.rst:223 msgid ":class:`c_wchar`" msgstr "" -#: library/ctypes.rst:224 +#: library/ctypes.rst:223 msgid ":c:type:`wchar_t`" msgstr "" -#: library/ctypes.rst:224 +#: library/ctypes.rst:223 msgid "1-character string" msgstr "" -#: library/ctypes.rst:226 +#: library/ctypes.rst:225 msgid ":class:`c_byte`" msgstr "" -#: library/ctypes.rst:228 library/ctypes.rst:232 library/ctypes.rst:236 -#: library/ctypes.rst:240 library/ctypes.rst:244 library/ctypes.rst:249 -#: library/ctypes.rst:252 +#: library/ctypes.rst:227 library/ctypes.rst:231 library/ctypes.rst:235 +#: library/ctypes.rst:239 library/ctypes.rst:243 library/ctypes.rst:248 +#: library/ctypes.rst:251 msgid "int" msgstr "" -#: library/ctypes.rst:228 +#: library/ctypes.rst:227 msgid ":class:`c_ubyte`" msgstr "" -#: library/ctypes.rst:228 +#: library/ctypes.rst:227 msgid ":c:expr:`unsigned char`" msgstr "" -#: library/ctypes.rst:230 +#: library/ctypes.rst:229 msgid ":class:`c_short`" msgstr "" -#: library/ctypes.rst:230 +#: library/ctypes.rst:229 msgid ":c:expr:`short`" msgstr "" -#: library/ctypes.rst:232 +#: library/ctypes.rst:231 msgid ":class:`c_ushort`" msgstr "" -#: library/ctypes.rst:232 +#: library/ctypes.rst:231 msgid ":c:expr:`unsigned short`" msgstr "" -#: library/ctypes.rst:234 +#: library/ctypes.rst:233 msgid ":class:`c_int`" msgstr "" -#: library/ctypes.rst:234 +#: library/ctypes.rst:233 msgid ":c:expr:`int`" msgstr "" -#: library/ctypes.rst:236 +#: library/ctypes.rst:235 msgid ":class:`c_uint`" msgstr "" -#: library/ctypes.rst:236 +#: library/ctypes.rst:235 msgid ":c:expr:`unsigned int`" msgstr "" -#: library/ctypes.rst:238 +#: library/ctypes.rst:237 msgid ":class:`c_long`" msgstr "" -#: library/ctypes.rst:238 +#: library/ctypes.rst:237 msgid ":c:expr:`long`" msgstr "" -#: library/ctypes.rst:240 +#: library/ctypes.rst:239 msgid ":class:`c_ulong`" msgstr "" -#: library/ctypes.rst:240 +#: library/ctypes.rst:239 msgid ":c:expr:`unsigned long`" msgstr "" -#: library/ctypes.rst:242 +#: library/ctypes.rst:241 msgid ":class:`c_longlong`" msgstr "" -#: library/ctypes.rst:242 +#: library/ctypes.rst:241 msgid ":c:expr:`__int64` or :c:expr:`long long`" msgstr "" -#: library/ctypes.rst:244 +#: library/ctypes.rst:243 msgid ":class:`c_ulonglong`" msgstr "" -#: library/ctypes.rst:244 +#: library/ctypes.rst:243 msgid ":c:expr:`unsigned __int64` or :c:expr:`unsigned long long`" msgstr "" -#: library/ctypes.rst:247 +#: library/ctypes.rst:246 msgid ":class:`c_size_t`" msgstr "" -#: library/ctypes.rst:247 +#: library/ctypes.rst:246 msgid ":c:type:`size_t`" msgstr "" -#: library/ctypes.rst:249 +#: library/ctypes.rst:248 msgid ":class:`c_ssize_t`" msgstr "" -#: library/ctypes.rst:249 +#: library/ctypes.rst:248 msgid ":c:type:`ssize_t` or :c:expr:`Py_ssize_t`" msgstr "" -#: library/ctypes.rst:252 +#: library/ctypes.rst:251 msgid ":class:`c_time_t`" msgstr "" -#: library/ctypes.rst:252 +#: library/ctypes.rst:251 msgid ":c:type:`time_t`" msgstr "" -#: library/ctypes.rst:254 +#: library/ctypes.rst:253 msgid ":class:`c_float`" msgstr "" -#: library/ctypes.rst:254 +#: library/ctypes.rst:253 msgid ":c:expr:`float`" msgstr "" -#: library/ctypes.rst:256 library/ctypes.rst:258 +#: library/ctypes.rst:255 library/ctypes.rst:257 msgid "float" msgstr "" -#: library/ctypes.rst:256 +#: library/ctypes.rst:255 msgid ":class:`c_double`" msgstr "" -#: library/ctypes.rst:256 +#: library/ctypes.rst:255 msgid ":c:expr:`double`" msgstr "" -#: library/ctypes.rst:258 +#: library/ctypes.rst:257 msgid ":class:`c_longdouble`" msgstr "" -#: library/ctypes.rst:258 +#: library/ctypes.rst:257 msgid ":c:expr:`long double`" msgstr "" -#: library/ctypes.rst:260 +#: library/ctypes.rst:259 msgid ":class:`c_char_p`" msgstr "" -#: library/ctypes.rst:260 +#: library/ctypes.rst:259 msgid ":c:expr:`char *` (NUL terminated)" msgstr "" -#: library/ctypes.rst:260 +#: library/ctypes.rst:259 msgid "bytes object or ``None``" msgstr "" -#: library/ctypes.rst:262 +#: library/ctypes.rst:261 msgid ":class:`c_wchar_p`" msgstr "" -#: library/ctypes.rst:262 +#: library/ctypes.rst:261 msgid ":c:expr:`wchar_t *` (NUL terminated)" msgstr "" -#: library/ctypes.rst:262 +#: library/ctypes.rst:261 msgid "string or ``None``" msgstr "" -#: library/ctypes.rst:264 +#: library/ctypes.rst:263 msgid ":class:`c_void_p`" msgstr "" -#: library/ctypes.rst:264 +#: library/ctypes.rst:263 msgid ":c:expr:`void *`" msgstr "" -#: library/ctypes.rst:264 +#: library/ctypes.rst:263 msgid "int or ``None``" msgstr "" -#: library/ctypes.rst:268 +#: library/ctypes.rst:267 msgid "The constructor accepts any object with a truth value." msgstr "" -#: library/ctypes.rst:270 +#: library/ctypes.rst:269 msgid "" "All these types can be created by calling them with an optional initializer " "of the correct type and value::" msgstr "" -#: library/ctypes.rst:281 +#: library/ctypes.rst:272 +msgid "" +">>> c_int()\n" +"c_long(0)\n" +">>> c_wchar_p(\"Hello, World\")\n" +"c_wchar_p(140018365411392)\n" +">>> c_ushort(-3)\n" +"c_ushort(65533)\n" +">>>" +msgstr "" + +#: library/ctypes.rst:280 msgid "" "Since these types are mutable, their value can also be changed afterwards::" msgstr "" -#: library/ctypes.rst:293 +#: library/ctypes.rst:282 msgid "" -"Assigning a new value to instances of the pointer types :class:`c_char_p`, :" -"class:`c_wchar_p`, and :class:`c_void_p` changes the *memory location* they " -"point to, *not the contents* of the memory block (of course not, because " -"Python bytes objects are immutable)::" +">>> i = c_int(42)\n" +">>> print(i)\n" +"c_long(42)\n" +">>> print(i.value)\n" +"42\n" +">>> i.value = -99\n" +">>> print(i.value)\n" +"-99\n" +">>>" msgstr "" -#: library/ctypes.rst:313 +#: library/ctypes.rst:292 msgid "" -"You should be careful, however, not to pass them to functions expecting " -"pointers to mutable memory. If you need mutable memory blocks, ctypes has a :" -"func:`create_string_buffer` function which creates these in various ways. " -"The current memory block contents can be accessed (or changed) with the " -"``raw`` property; if you want to access it as NUL terminated string, use the " -"``value`` property::" +"Assigning a new value to instances of the pointer " +"types :class:`c_char_p`, :class:`c_wchar_p`, and :class:`c_void_p` changes " +"the *memory location* they point to, *not the contents* of the memory block " +"(of course not, because Python bytes objects are immutable)::" msgstr "" -#: library/ctypes.rst:337 +#: library/ctypes.rst:297 +msgid "" +">>> s = \"Hello, World\"\n" +">>> c_s = c_wchar_p(s)\n" +">>> print(c_s)\n" +"c_wchar_p(139966785747344)\n" +">>> print(c_s.value)\n" +"Hello World\n" +">>> c_s.value = \"Hi, there\"\n" +">>> print(c_s) # the memory location has changed\n" +"c_wchar_p(139966783348904)\n" +">>> print(c_s.value)\n" +"Hi, there\n" +">>> print(s) # first object is unchanged\n" +"Hello, World\n" +">>>" +msgstr "" + +#: library/ctypes.rst:312 +msgid "" +"You should be careful, however, not to pass them to functions expecting " +"pointers to mutable memory. If you need mutable memory blocks, ctypes has " +"a :func:`create_string_buffer` function which creates these in various " +"ways. The current memory block contents can be accessed (or changed) with " +"the ``raw`` property; if you want to access it as NUL terminated string, use " +"the ``value`` property::" +msgstr "" + +#: library/ctypes.rst:319 +msgid "" +">>> from ctypes import *\n" +">>> p = create_string_buffer(3) # create a 3 byte buffer, " +"initialized to NUL bytes\n" +">>> print(sizeof(p), repr(p.raw))\n" +"3 b'\\x00\\x00\\x00'\n" +">>> p = create_string_buffer(b\"Hello\") # create a buffer containing a " +"NUL terminated string\n" +">>> print(sizeof(p), repr(p.raw))\n" +"6 b'Hello\\x00'\n" +">>> print(repr(p.value))\n" +"b'Hello'\n" +">>> p = create_string_buffer(b\"Hello\", 10) # create a 10 byte buffer\n" +">>> print(sizeof(p), repr(p.raw))\n" +"10 b'Hello\\x00\\x00\\x00\\x00\\x00'\n" +">>> p.value = b\"Hi\"\n" +">>> print(sizeof(p), repr(p.raw))\n" +"10 b'Hi\\x00lo\\x00\\x00\\x00\\x00\\x00'\n" +">>>" +msgstr "" + +#: library/ctypes.rst:336 msgid "" "The :func:`create_string_buffer` function replaces the old :func:`!c_buffer` " "function (which is still available as an alias). To create a mutable memory " @@ -474,29 +643,56 @@ msgid "" "the :func:`create_unicode_buffer` function." msgstr "" -#: library/ctypes.rst:346 +#: library/ctypes.rst:345 msgid "Calling functions, continued" msgstr "" -#: library/ctypes.rst:348 +#: library/ctypes.rst:347 msgid "" -"Note that printf prints to the real standard output channel, *not* to :data:" -"`sys.stdout`, so these examples will only work at the console prompt, not " -"from within *IDLE* or *PythonWin*::" +"Note that printf prints to the real standard output channel, *not* " +"to :data:`sys.stdout`, so these examples will only work at the console " +"prompt, not from within *IDLE* or *PythonWin*::" msgstr "" -#: library/ctypes.rst:368 +#: library/ctypes.rst:351 +msgid "" +">>> printf = libc.printf\n" +">>> printf(b\"Hello, %s\\n\", b\"World!\")\n" +"Hello, World!\n" +"14\n" +">>> printf(b\"Hello, %S\\n\", \"World!\")\n" +"Hello, World!\n" +"14\n" +">>> printf(b\"%d bottles of beer\\n\", 42)\n" +"42 bottles of beer\n" +"19\n" +">>> printf(b\"%f bottles of beer\\n\", 42.5)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ArgumentError: argument 2: TypeError: Don't know how to convert parameter 2\n" +">>>" +msgstr "" + +#: library/ctypes.rst:367 msgid "" "As has been mentioned before, all Python types except integers, strings, and " "bytes objects have to be wrapped in their corresponding :mod:`ctypes` type, " "so that they can be converted to the required C data type::" msgstr "" -#: library/ctypes.rst:380 +#: library/ctypes.rst:371 +msgid "" +">>> printf(b\"An int %d, a double %f\\n\", 1234, c_double(3.14))\n" +"An int 1234, a double 3.140000\n" +"31\n" +">>>" +msgstr "" + +#: library/ctypes.rst:379 msgid "Calling variadic functions" msgstr "" -#: library/ctypes.rst:382 +#: library/ctypes.rst:381 msgid "" "On a lot of platforms calling variadic functions through ctypes is exactly " "the same as calling functions with a fixed number of parameters. On some " @@ -505,23 +701,27 @@ msgid "" "functions." msgstr "" -#: library/ctypes.rst:387 +#: library/ctypes.rst:386 msgid "" -"On those platforms it is required to specify the :attr:`~_FuncPtr.argtypes` " +"On those platforms it is required to specify the :attr:`~_CFuncPtr.argtypes` " "attribute for the regular, non-variadic, function arguments:" msgstr "" -#: library/ctypes.rst:394 +#: library/ctypes.rst:389 +msgid "libc.printf.argtypes = [ctypes.c_char_p]" +msgstr "" + +#: library/ctypes.rst:393 msgid "" "Because specifying the attribute does not inhibit portability it is advised " -"to always specify :attr:`~_FuncPtr.argtypes` for all variadic functions." +"to always specify :attr:`~_CFuncPtr.argtypes` for all variadic functions." msgstr "" -#: library/ctypes.rst:401 +#: library/ctypes.rst:400 msgid "Calling functions with your own custom data types" msgstr "" -#: library/ctypes.rst:403 +#: library/ctypes.rst:402 msgid "" "You can also customize :mod:`ctypes` argument conversion to allow instances " "of your own classes be used as function arguments. :mod:`ctypes` looks for " @@ -530,105 +730,204 @@ msgid "" "or an object with an :attr:`!_as_parameter_` attribute::" msgstr "" -#: library/ctypes.rst:419 +#: library/ctypes.rst:408 +msgid "" +">>> class Bottles:\n" +"... def __init__(self, number):\n" +"... self._as_parameter_ = number\n" +"...\n" +">>> bottles = Bottles(42)\n" +">>> printf(b\"%d bottles of beer\\n\", bottles)\n" +"42 bottles of beer\n" +"19\n" +">>>" +msgstr "" + +#: library/ctypes.rst:418 msgid "" "If you don't want to store the instance's data in the :attr:`!" "_as_parameter_` instance variable, you could define a :class:`property` " "which makes the attribute available on request." msgstr "" -#: library/ctypes.rst:427 +#: library/ctypes.rst:426 msgid "Specifying the required argument types (function prototypes)" msgstr "" -#: library/ctypes.rst:429 +#: library/ctypes.rst:428 msgid "" "It is possible to specify the required argument types of functions exported " -"from DLLs by setting the :attr:`~_FuncPtr.argtypes` attribute." +"from DLLs by setting the :attr:`~_CFuncPtr.argtypes` attribute." msgstr "" -#: library/ctypes.rst:432 +#: library/ctypes.rst:431 msgid "" -":attr:`~_FuncPtr.argtypes` must be a sequence of C data types (the :func:`!" +":attr:`~_CFuncPtr.argtypes` must be a sequence of C data types (the :func:`!" "printf` function is probably not a good example here, because it takes a " "variable number and different types of parameters depending on the format " "string, on the other hand this is quite handy to experiment with this " "feature)::" msgstr "" -#: library/ctypes.rst:443 +#: library/ctypes.rst:436 +msgid "" +">>> printf.argtypes = [c_char_p, c_char_p, c_int, c_double]\n" +">>> printf(b\"String '%s', Int %d, Double %f\\n\", b\"Hi\", 10, 2.2)\n" +"String 'Hi', Int 10, Double 2.200000\n" +"37\n" +">>>" +msgstr "" + +#: library/ctypes.rst:442 msgid "" "Specifying a format protects against incompatible argument types (just as a " "prototype for a C function), and tries to convert the arguments to valid " "types::" msgstr "" -#: library/ctypes.rst:455 +#: library/ctypes.rst:445 +msgid "" +">>> printf(b\"%d %d %d\", 1, 2, 3)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ArgumentError: argument 2: TypeError: wrong type\n" +">>> printf(b\"%s %d %f\\n\", b\"X\", 2, 3)\n" +"X 2 3.000000\n" +"13\n" +">>>" +msgstr "" + +#: library/ctypes.rst:454 msgid "" "If you have defined your own classes which you pass to function calls, you " "have to implement a :meth:`~_CData.from_param` class method for them to be " -"able to use them in the :attr:`~_FuncPtr.argtypes` sequence. The :meth:" -"`~_CData.from_param` class method receives the Python object passed to the " -"function call, it should do a typecheck or whatever is needed to make sure " -"this object is acceptable, and then return the object itself, its :attr:`!" -"_as_parameter_` attribute, or whatever you want to pass as the C function " -"argument in this case. Again, the result should be an integer, string, " -"bytes, a :mod:`ctypes` instance, or an object with an :attr:`!" +"able to use them in the :attr:`~_CFuncPtr.argtypes` sequence. " +"The :meth:`~_CData.from_param` class method receives the Python object " +"passed to the function call, it should do a typecheck or whatever is needed " +"to make sure this object is acceptable, and then return the object itself, " +"its :attr:`!_as_parameter_` attribute, or whatever you want to pass as the C " +"function argument in this case. Again, the result should be an integer, " +"string, bytes, a :mod:`ctypes` instance, or an object with an :attr:`!" "_as_parameter_` attribute." msgstr "" -#: library/ctypes.rst:469 +#: library/ctypes.rst:468 msgid "Return types" msgstr "" -#: library/ctypes.rst:479 +#: library/ctypes.rst:478 msgid "" "By default functions are assumed to return the C :c:expr:`int` type. Other " -"return types can be specified by setting the :attr:`~_FuncPtr.restype` " +"return types can be specified by setting the :attr:`~_CFuncPtr.restype` " "attribute of the function object." msgstr "" -#: library/ctypes.rst:483 +#: library/ctypes.rst:482 msgid "" -"The C prototype of :c:func:`time` is ``time_t time(time_t *)``. Because :c:" -"type:`time_t` might be of a different type than the default return type :c:" -"expr:`int`, you should specify the :attr:`!restype` attribute::" +"The C prototype of :c:func:`time` is ``time_t time(time_t *)``. " +"Because :c:type:`time_t` might be of a different type than the default " +"return type :c:expr:`int`, you should specify the :attr:`!restype` " +"attribute::" +msgstr "" + +#: library/ctypes.rst:486 +msgid ">>> libc.time.restype = c_time_t" +msgstr "" + +#: library/ctypes.rst:488 +msgid "The argument types can be specified using :attr:`~_CFuncPtr.argtypes`::" msgstr "" -#: library/ctypes.rst:489 -msgid "The argument types can be specified using :attr:`~_FuncPtr.argtypes`::" +#: library/ctypes.rst:490 +msgid ">>> libc.time.argtypes = (POINTER(c_time_t),)" msgstr "" -#: library/ctypes.rst:493 +#: library/ctypes.rst:492 msgid "" "To call the function with a ``NULL`` pointer as first argument, use " "``None``::" msgstr "" -#: library/ctypes.rst:498 +#: library/ctypes.rst:494 +msgid "" +">>> print(libc.time(None)) \n" +"1150640792" +msgstr "" + +#: library/ctypes.rst:497 msgid "" "Here is a more advanced example, it uses the :func:`!strchr` function, which " "expects a string pointer and a char, and returns a pointer to a string::" msgstr "" -#: library/ctypes.rst:511 +#: library/ctypes.rst:500 +msgid "" +">>> strchr = libc.strchr\n" +">>> strchr(b\"abcdef\", ord(\"d\")) \n" +"8059983\n" +">>> strchr.restype = c_char_p # c_char_p is a pointer to a string\n" +">>> strchr(b\"abcdef\", ord(\"d\"))\n" +"b'def'\n" +">>> print(strchr(b\"abcdef\", ord(\"x\")))\n" +"None\n" +">>>" +msgstr "" + +#: library/ctypes.rst:510 msgid "" "If you want to avoid the :func:`ord(\"x\") ` calls above, you can set " -"the :attr:`~_FuncPtr.argtypes` attribute, and the second argument will be " +"the :attr:`~_CFuncPtr.argtypes` attribute, and the second argument will be " "converted from a single character Python bytes object into a C char:" msgstr "" -#: library/ctypes.rst:530 +#: library/ctypes.rst:514 msgid "" -"You can also use a callable Python object (a function or a class for " -"example) as the :attr:`~_FuncPtr.restype` attribute, if the foreign function " -"returns an integer. The callable will be called with the *integer* the C " -"function returns, and the result of this call will be used as the result of " -"your function call. This is useful to check for error return values and " -"automatically raise an exception::" +">>> strchr.restype = c_char_p\n" +">>> strchr.argtypes = [c_char_p, c_char]\n" +">>> strchr(b\"abcdef\", b\"d\")\n" +"b'def'\n" +">>> strchr(b\"abcdef\", b\"def\")\n" +"Traceback (most recent call last):\n" +"ctypes.ArgumentError: argument 2: TypeError: one character bytes, bytearray " +"or integer expected\n" +">>> print(strchr(b\"abcdef\", b\"x\"))\n" +"None\n" +">>> strchr(b\"abcdef\", b\"d\")\n" +"b'def'\n" +">>>" msgstr "" -#: library/ctypes.rst:553 +#: library/ctypes.rst:529 +msgid "" +"You can also use a callable Python object (a function or a class for " +"example) as the :attr:`~_CFuncPtr.restype` attribute, if the foreign " +"function returns an integer. The callable will be called with the *integer* " +"the C function returns, and the result of this call will be used as the " +"result of your function call. This is useful to check for error return " +"values and automatically raise an exception::" +msgstr "" + +#: library/ctypes.rst:535 +msgid "" +">>> GetModuleHandle = windll.kernel32.GetModuleHandleA \n" +">>> def ValidHandle(value):\n" +"... if value == 0:\n" +"... raise WinError()\n" +"... return value\n" +"...\n" +">>>\n" +">>> GetModuleHandle.restype = ValidHandle \n" +">>> GetModuleHandle(None) \n" +"486539264\n" +">>> GetModuleHandle(\"something silly\") \n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" File \"\", line 3, in ValidHandle\n" +"OSError: [Errno 126] The specified module could not be found.\n" +">>>" +msgstr "" + +#: library/ctypes.rst:552 msgid "" "``WinError`` is a function which will call Windows ``FormatMessage()`` api " "to get the string representation of an error code, and *returns* an " @@ -636,18 +935,18 @@ msgid "" "used, it calls :func:`GetLastError` to retrieve it." msgstr "" -#: library/ctypes.rst:558 +#: library/ctypes.rst:557 msgid "" "Please note that a much more powerful error checking mechanism is available " -"through the :attr:`~_FuncPtr.errcheck` attribute; see the reference manual " +"through the :attr:`~_CFuncPtr.errcheck` attribute; see the reference manual " "for details." msgstr "" -#: library/ctypes.rst:566 +#: library/ctypes.rst:565 msgid "Passing pointers (or: passing parameters by reference)" msgstr "" -#: library/ctypes.rst:568 +#: library/ctypes.rst:567 msgid "" "Sometimes a C api function expects a *pointer* to a data type as parameter, " "probably to write into the corresponding location, or if the data is too " @@ -655,66 +954,130 @@ msgid "" "reference*." msgstr "" -#: library/ctypes.rst:572 +#: library/ctypes.rst:571 msgid "" ":mod:`ctypes` exports the :func:`byref` function which is used to pass " -"parameters by reference. The same effect can be achieved with the :func:" -"`pointer` function, although :func:`pointer` does a lot more work since it " -"constructs a real pointer object, so it is faster to use :func:`byref` if " -"you don't need the pointer object in Python itself::" +"parameters by reference. The same effect can be achieved with " +"the :func:`pointer` function, although :func:`pointer` does a lot more work " +"since it constructs a real pointer object, so it is faster to " +"use :func:`byref` if you don't need the pointer object in Python itself::" msgstr "" -#: library/ctypes.rst:594 +#: library/ctypes.rst:577 +msgid "" +">>> i = c_int()\n" +">>> f = c_float()\n" +">>> s = create_string_buffer(b'\\000' * 32)\n" +">>> print(i.value, f.value, repr(s.value))\n" +"0 0.0 b''\n" +">>> libc.sscanf(b\"1 3.14 Hello\", b\"%d %f %s\",\n" +"... byref(i), byref(f), s)\n" +"3\n" +">>> print(i.value, f.value, repr(s.value))\n" +"1 3.1400001049 b'Hello'\n" +">>>" +msgstr "" + +#: library/ctypes.rst:593 msgid "Structures and unions" msgstr "" -#: library/ctypes.rst:596 +#: library/ctypes.rst:595 msgid "" -"Structures and unions must derive from the :class:`Structure` and :class:" -"`Union` base classes which are defined in the :mod:`ctypes` module. Each " -"subclass must define a :attr:`~Structure._fields_` attribute. :attr:`!" -"_fields_` must be a list of *2-tuples*, containing a *field name* and a " -"*field type*." +"Structures and unions must derive from the :class:`Structure` " +"and :class:`Union` base classes which are defined in the :mod:`ctypes` " +"module. Each subclass must define a :attr:`~Structure._fields_` " +"attribute. :attr:`!_fields_` must be a list of *2-tuples*, containing a " +"*field name* and a *field type*." msgstr "" -#: library/ctypes.rst:601 +#: library/ctypes.rst:600 msgid "" "The field type must be a :mod:`ctypes` type like :class:`c_int`, or any " "other derived :mod:`ctypes` type: structure, union, array, pointer." msgstr "" -#: library/ctypes.rst:604 +#: library/ctypes.rst:603 msgid "" "Here is a simple example of a POINT structure, which contains two integers " "named *x* and *y*, and also shows how to initialize a structure in the " "constructor::" msgstr "" -#: library/ctypes.rst:624 +#: library/ctypes.rst:606 +msgid "" +">>> from ctypes import *\n" +">>> class POINT(Structure):\n" +"... _fields_ = [(\"x\", c_int),\n" +"... (\"y\", c_int)]\n" +"...\n" +">>> point = POINT(10, 20)\n" +">>> print(point.x, point.y)\n" +"10 20\n" +">>> point = POINT(y=5)\n" +">>> print(point.x, point.y)\n" +"0 5\n" +">>> POINT(1, 2, 3)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: too many initializers\n" +">>>" +msgstr "" + +#: library/ctypes.rst:623 msgid "" "You can, however, build much more complicated structures. A structure can " "itself contain other structures by using a structure as a field type." msgstr "" -#: library/ctypes.rst:627 +#: library/ctypes.rst:626 msgid "" "Here is a RECT structure which contains two POINTs named *upperleft* and " "*lowerright*::" msgstr "" -#: library/ctypes.rst:641 +#: library/ctypes.rst:629 +msgid "" +">>> class RECT(Structure):\n" +"... _fields_ = [(\"upperleft\", POINT),\n" +"... (\"lowerright\", POINT)]\n" +"...\n" +">>> rc = RECT(point)\n" +">>> print(rc.upperleft.x, rc.upperleft.y)\n" +"0 5\n" +">>> print(rc.lowerright.x, rc.lowerright.y)\n" +"0 0\n" +">>>" +msgstr "" + +#: library/ctypes.rst:640 msgid "" "Nested structures can also be initialized in the constructor in several " "ways::" msgstr "" -#: library/ctypes.rst:646 +#: library/ctypes.rst:642 +msgid "" +">>> r = RECT(POINT(1, 2), POINT(3, 4))\n" +">>> r = RECT((1, 2), (3, 4))" +msgstr "" + +#: library/ctypes.rst:645 msgid "" "Field :term:`descriptor`\\s can be retrieved from the *class*, they are " "useful for debugging because they can provide useful information::" msgstr "" -#: library/ctypes.rst:660 +#: library/ctypes.rst:648 +msgid "" +">>> print(POINT.x)\n" +"\n" +">>> print(POINT.y)\n" +"\n" +">>>" +msgstr "" + +#: library/ctypes.rst:659 msgid "" ":mod:`ctypes` does not support passing unions or structures with bit-fields " "to functions by value. While this may work on 32-bit x86, it's not " @@ -722,113 +1085,216 @@ msgid "" "structures with bit-fields should always be passed to functions by pointer." msgstr "" -#: library/ctypes.rst:666 +#: library/ctypes.rst:665 msgid "Structure/union alignment and byte order" msgstr "" -#: library/ctypes.rst:668 +#: library/ctypes.rst:667 msgid "" "By default, Structure and Union fields are aligned in the same way the C " -"compiler does it. It is possible to override this behavior by specifying a :" -"attr:`~Structure._pack_` class attribute in the subclass definition. This " +"compiler does it. It is possible to override this behavior by specifying " +"a :attr:`~Structure._pack_` class attribute in the subclass definition. This " "must be set to a positive integer and specifies the maximum alignment for " "the fields. This is what ``#pragma pack(n)`` also does in MSVC." msgstr "" -#: library/ctypes.rst:674 +#: library/ctypes.rst:673 msgid "" ":mod:`ctypes` uses the native byte order for Structures and Unions. To " -"build structures with non-native byte order, you can use one of the :class:" -"`BigEndianStructure`, :class:`LittleEndianStructure`, :class:" -"`BigEndianUnion`, and :class:`LittleEndianUnion` base classes. These " -"classes cannot contain pointer fields." +"build structures with non-native byte order, you can use one of " +"the :class:`BigEndianStructure`, :class:`LittleEndianStructure`, :class:`BigEndianUnion`, " +"and :class:`LittleEndianUnion` base classes. These classes cannot contain " +"pointer fields." msgstr "" -#: library/ctypes.rst:684 +#: library/ctypes.rst:683 msgid "Bit fields in structures and unions" msgstr "" -#: library/ctypes.rst:686 +#: library/ctypes.rst:685 msgid "" "It is possible to create structures and unions containing bit fields. Bit " "fields are only possible for integer fields, the bit width is specified as " "the third item in the :attr:`~Structure._fields_` tuples::" msgstr "" -#: library/ctypes.rst:704 +#: library/ctypes.rst:689 +msgid "" +">>> class Int(Structure):\n" +"... _fields_ = [(\"first_16\", c_int, 16),\n" +"... (\"second_16\", c_int, 16)]\n" +"...\n" +">>> print(Int.first_16)\n" +"\n" +">>> print(Int.second_16)\n" +"\n" +">>>" +msgstr "" + +#: library/ctypes.rst:703 msgid "Arrays" msgstr "" -#: library/ctypes.rst:706 +#: library/ctypes.rst:705 msgid "" "Arrays are sequences, containing a fixed number of instances of the same " "type." msgstr "" -#: library/ctypes.rst:708 +#: library/ctypes.rst:707 msgid "" "The recommended way to create array types is by multiplying a data type with " "a positive integer::" msgstr "" -#: library/ctypes.rst:713 +#: library/ctypes.rst:710 +msgid "TenPointsArrayType = POINT * 10" +msgstr "" + +#: library/ctypes.rst:712 msgid "" "Here is an example of a somewhat artificial data type, a structure " "containing 4 POINTs among other stuff::" msgstr "" -#: library/ctypes.rst:729 +#: library/ctypes.rst:715 +msgid "" +">>> from ctypes import *\n" +">>> class POINT(Structure):\n" +"... _fields_ = (\"x\", c_int), (\"y\", c_int)\n" +"...\n" +">>> class MyStruct(Structure):\n" +"... _fields_ = [(\"a\", c_int),\n" +"... (\"b\", c_float),\n" +"... (\"point_array\", POINT * 4)]\n" +">>>\n" +">>> print(len(MyStruct().point_array))\n" +"4\n" +">>>" +msgstr "" + +#: library/ctypes.rst:728 msgid "Instances are created in the usual way, by calling the class::" msgstr "" -#: library/ctypes.rst:735 +#: library/ctypes.rst:730 +msgid "" +"arr = TenPointsArrayType()\n" +"for pt in arr:\n" +" print(pt.x, pt.y)" +msgstr "" + +#: library/ctypes.rst:734 msgid "" "The above code print a series of ``0 0`` lines, because the array contents " "is initialized to zeros." msgstr "" -#: library/ctypes.rst:738 +#: library/ctypes.rst:737 msgid "Initializers of the correct type can also be specified::" msgstr "" -#: library/ctypes.rst:754 +#: library/ctypes.rst:739 +msgid "" +">>> from ctypes import *\n" +">>> TenIntegers = c_int * 10\n" +">>> ii = TenIntegers(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n" +">>> print(ii)\n" +"\n" +">>> for i in ii: print(i, end=\" \")\n" +"...\n" +"1 2 3 4 5 6 7 8 9 10\n" +">>>" +msgstr "" + +#: library/ctypes.rst:753 msgid "Pointers" msgstr "" -#: library/ctypes.rst:756 +#: library/ctypes.rst:755 msgid "" -"Pointer instances are created by calling the :func:`pointer` function on a :" -"mod:`ctypes` type::" +"Pointer instances are created by calling the :func:`pointer` function on " +"a :mod:`ctypes` type::" msgstr "" -#: library/ctypes.rst:764 +#: library/ctypes.rst:758 +msgid "" +">>> from ctypes import *\n" +">>> i = c_int(42)\n" +">>> pi = pointer(i)\n" +">>>" +msgstr "" + +#: library/ctypes.rst:763 msgid "" "Pointer instances have a :attr:`~_Pointer.contents` attribute which returns " "the object to which the pointer points, the ``i`` object above::" msgstr "" -#: library/ctypes.rst:771 +#: library/ctypes.rst:766 +msgid "" +">>> pi.contents\n" +"c_long(42)\n" +">>>" +msgstr "" + +#: library/ctypes.rst:770 msgid "" "Note that :mod:`ctypes` does not have OOR (original object return), it " "constructs a new, equivalent object each time you retrieve an attribute::" msgstr "" -#: library/ctypes.rst:780 +#: library/ctypes.rst:773 +msgid "" +">>> pi.contents is i\n" +"False\n" +">>> pi.contents is pi.contents\n" +"False\n" +">>>" +msgstr "" + +#: library/ctypes.rst:779 msgid "" "Assigning another :class:`c_int` instance to the pointer's contents " "attribute would cause the pointer to point to the memory location where this " "is stored::" msgstr "" -#: library/ctypes.rst:792 +#: library/ctypes.rst:782 +msgid "" +">>> i = c_int(99)\n" +">>> pi.contents = i\n" +">>> pi.contents\n" +"c_long(99)\n" +">>>" +msgstr "" + +#: library/ctypes.rst:791 msgid "Pointer instances can also be indexed with integers::" msgstr "" -#: library/ctypes.rst:798 +#: library/ctypes.rst:793 +msgid "" +">>> pi[0]\n" +"99\n" +">>>" +msgstr "" + +#: library/ctypes.rst:797 msgid "Assigning to an integer index changes the pointed to value::" msgstr "" -#: library/ctypes.rst:807 +#: library/ctypes.rst:799 +msgid "" +">>> print(i)\n" +"c_long(99)\n" +">>> pi[0] = 22\n" +">>> print(i)\n" +"c_long(22)\n" +">>>" +msgstr "" + +#: library/ctypes.rst:806 msgid "" "It is also possible to use indexes different from 0, but you must know what " "you're doing, just as in C: You can access or change arbitrary memory " @@ -837,7 +1303,7 @@ msgid "" "instead of a single item." msgstr "" -#: library/ctypes.rst:813 +#: library/ctypes.rst:812 msgid "" "Behind the scenes, the :func:`pointer` function does more than simply create " "pointer instances, it has to create pointer *types* first. This is done with " @@ -845,26 +1311,63 @@ msgid "" "returns a new type::" msgstr "" -#: library/ctypes.rst:829 +#: library/ctypes.rst:817 +msgid "" +">>> PI = POINTER(c_int)\n" +">>> PI\n" +"\n" +">>> PI(42)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: expected c_long instead of int\n" +">>> PI(c_int(42))\n" +"\n" +">>>" +msgstr "" + +#: library/ctypes.rst:828 msgid "" "Calling the pointer type without an argument creates a ``NULL`` pointer. " "``NULL`` pointers have a ``False`` boolean value::" msgstr "" -#: library/ctypes.rst:837 +#: library/ctypes.rst:831 +msgid "" +">>> null_ptr = POINTER(c_int)()\n" +">>> print(bool(null_ptr))\n" +"False\n" +">>>" +msgstr "" + +#: library/ctypes.rst:836 msgid "" ":mod:`ctypes` checks for ``NULL`` when dereferencing pointers (but " "dereferencing invalid non-\\ ``NULL`` pointers would crash Python)::" msgstr "" -#: library/ctypes.rst:856 +#: library/ctypes.rst:839 +msgid "" +">>> null_ptr[0]\n" +"Traceback (most recent call last):\n" +" ....\n" +"ValueError: NULL pointer access\n" +">>>\n" +"\n" +">>> null_ptr[0] = 1234\n" +"Traceback (most recent call last):\n" +" ....\n" +"ValueError: NULL pointer access\n" +">>>" +msgstr "" + +#: library/ctypes.rst:855 msgid "Type conversions" msgstr "" -#: library/ctypes.rst:858 +#: library/ctypes.rst:857 msgid "" "Usually, ctypes does strict type checking. This means, if you have " -"``POINTER(c_int)`` in the :attr:`~_FuncPtr.argtypes` list of a function or " +"``POINTER(c_int)`` in the :attr:`~_CFuncPtr.argtypes` list of a function or " "as the type of a member field in a structure definition, only instances of " "exactly the same type are accepted. There are some exceptions to this rule, " "where ctypes accepts other objects. For example, you can pass compatible " @@ -872,20 +1375,43 @@ msgid "" "ctypes accepts an array of c_int::" msgstr "" -#: library/ctypes.rst:879 +#: library/ctypes.rst:864 +msgid "" +">>> class Bar(Structure):\n" +"... _fields_ = [(\"count\", c_int), (\"values\", POINTER(c_int))]\n" +"...\n" +">>> bar = Bar()\n" +">>> bar.values = (c_int * 3)(1, 2, 3)\n" +">>> bar.count = 3\n" +">>> for i in range(bar.count):\n" +"... print(bar.values[i])\n" +"...\n" +"1\n" +"2\n" +"3\n" +">>>" +msgstr "" + +#: library/ctypes.rst:878 msgid "" "In addition, if a function argument is explicitly declared to be a pointer " -"type (such as ``POINTER(c_int)``) in :attr:`~_FuncPtr.argtypes`, an object " +"type (such as ``POINTER(c_int)``) in :attr:`~_CFuncPtr.argtypes`, an object " "of the pointed type (``c_int`` in this case) can be passed to the function. " "ctypes will apply the required :func:`byref` conversion in this case " "automatically." msgstr "" -#: library/ctypes.rst:884 +#: library/ctypes.rst:883 msgid "To set a POINTER type field to ``NULL``, you can assign ``None``::" msgstr "" -#: library/ctypes.rst:891 +#: library/ctypes.rst:885 +msgid "" +">>> bar.values = None\n" +">>>" +msgstr "" + +#: library/ctypes.rst:890 msgid "" "Sometimes you have instances of incompatible types. In C, you can cast one " "type into another type. :mod:`ctypes` provides a :func:`cast` function " @@ -894,11 +1420,21 @@ msgid "" "``values`` field, but not instances of other types::" msgstr "" -#: library/ctypes.rst:903 +#: library/ctypes.rst:896 +msgid "" +">>> bar.values = (c_byte * 4)()\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: incompatible types, c_byte_Array_4 instance instead of LP_c_long " +"instance\n" +">>>" +msgstr "" + +#: library/ctypes.rst:902 msgid "For these cases, the :func:`cast` function is handy." msgstr "" -#: library/ctypes.rst:905 +#: library/ctypes.rst:904 msgid "" "The :func:`cast` function can be used to cast a ctypes instance into a " "pointer to a different ctypes data type. :func:`cast` takes two parameters, " @@ -907,60 +1443,128 @@ msgid "" "references the same memory block as the first argument::" msgstr "" -#: library/ctypes.rst:916 +#: library/ctypes.rst:910 +msgid "" +">>> a = (c_byte * 4)()\n" +">>> cast(a, POINTER(c_int))\n" +"\n" +">>>" +msgstr "" + +#: library/ctypes.rst:915 msgid "" "So, :func:`cast` can be used to assign to the ``values`` field of ``Bar`` " "the structure::" msgstr "" -#: library/ctypes.rst:929 +#: library/ctypes.rst:918 +msgid "" +">>> bar = Bar()\n" +">>> bar.values = cast((c_byte * 4)(), POINTER(c_int))\n" +">>> print(bar.values[0])\n" +"0\n" +">>>" +msgstr "" + +#: library/ctypes.rst:928 msgid "Incomplete Types" msgstr "" -#: library/ctypes.rst:931 +#: library/ctypes.rst:930 msgid "" "*Incomplete Types* are structures, unions or arrays whose members are not " "yet specified. In C, they are specified by forward declarations, which are " "defined later::" msgstr "" -#: library/ctypes.rst:942 +#: library/ctypes.rst:934 +msgid "" +"struct cell; /* forward declaration */\n" +"\n" +"struct cell {\n" +" char *name;\n" +" struct cell *next;\n" +"};" +msgstr "" + +#: library/ctypes.rst:941 msgid "" "The straightforward translation into ctypes code would be this, but it does " "not work::" msgstr "" -#: library/ctypes.rst:955 +#: library/ctypes.rst:944 +msgid "" +">>> class cell(Structure):\n" +"... _fields_ = [(\"name\", c_char_p),\n" +"... (\"next\", POINTER(cell))]\n" +"...\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" File \"\", line 2, in cell\n" +"NameError: name 'cell' is not defined\n" +">>>" +msgstr "" + +#: library/ctypes.rst:954 msgid "" "because the new ``class cell`` is not available in the class statement " -"itself. In :mod:`ctypes`, we can define the ``cell`` class and set the :attr:" -"`~Structure._fields_` attribute later, after the class statement::" +"itself. In :mod:`ctypes`, we can define the ``cell`` class and set " +"the :attr:`~Structure._fields_` attribute later, after the class statement::" +msgstr "" + +#: library/ctypes.rst:958 +msgid "" +">>> from ctypes import *\n" +">>> class cell(Structure):\n" +"... pass\n" +"...\n" +">>> cell._fields_ = [(\"name\", c_char_p),\n" +"... (\"next\", POINTER(cell))]\n" +">>>" msgstr "" -#: library/ctypes.rst:967 +#: library/ctypes.rst:966 msgid "" "Let's try it. We create two instances of ``cell``, and let them point to " "each other, and finally follow the pointer chain a few times::" msgstr "" -#: library/ctypes.rst:988 +#: library/ctypes.rst:969 +msgid "" +">>> c1 = cell()\n" +">>> c1.name = b\"foo\"\n" +">>> c2 = cell()\n" +">>> c2.name = b\"bar\"\n" +">>> c1.next = pointer(c2)\n" +">>> c2.next = pointer(c1)\n" +">>> p = c1\n" +">>> for i in range(8):\n" +"... print(p.name, end=\" \")\n" +"... p = p.next[0]\n" +"...\n" +"foo bar foo bar foo bar foo bar\n" +">>>" +msgstr "" + +#: library/ctypes.rst:987 msgid "Callback functions" msgstr "" -#: library/ctypes.rst:990 +#: library/ctypes.rst:989 msgid "" ":mod:`ctypes` allows creating C callable function pointers from Python " "callables. These are sometimes called *callback functions*." msgstr "" -#: library/ctypes.rst:993 +#: library/ctypes.rst:992 msgid "" "First, you must create a class for the callback function. The class knows " "the calling convention, the return type, and the number and types of " "arguments this function will receive." msgstr "" -#: library/ctypes.rst:997 +#: library/ctypes.rst:996 msgid "" "The :func:`CFUNCTYPE` factory function creates types for callback functions " "using the ``cdecl`` calling convention. On Windows, the :func:`WINFUNCTYPE` " @@ -968,21 +1572,30 @@ msgid "" "calling convention." msgstr "" -#: library/ctypes.rst:1002 +#: library/ctypes.rst:1001 msgid "" "Both of these factory functions are called with the result type as first " "argument, and the callback functions expected argument types as the " "remaining arguments." msgstr "" -#: library/ctypes.rst:1006 +#: library/ctypes.rst:1005 msgid "" "I will present an example here which uses the standard C library's :c:func:`!" "qsort` function, that is used to sort items with the help of a callback " "function. :c:func:`!qsort` will be used to sort an array of integers::" msgstr "" -#: library/ctypes.rst:1016 +#: library/ctypes.rst:1009 +msgid "" +">>> IntArray5 = c_int * 5\n" +">>> ia = IntArray5(5, 1, 7, 33, 99)\n" +">>> qsort = libc.qsort\n" +">>> qsort.restype = None\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1015 msgid "" ":func:`!qsort` must be called with a pointer to the data to sort, the number " "of items in the data array, the size of one item, and a pointer to the " @@ -992,44 +1605,111 @@ msgid "" "otherwise." msgstr "" -#: library/ctypes.rst:1022 +#: library/ctypes.rst:1021 msgid "" "So our callback function receives pointers to integers, and must return an " "integer. First we create the ``type`` for the callback function::" msgstr "" -#: library/ctypes.rst:1028 +#: library/ctypes.rst:1024 +msgid "" +">>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1027 msgid "" "To get started, here is a simple callback that shows the values it gets " "passed::" msgstr "" -#: library/ctypes.rst:1038 +#: library/ctypes.rst:1030 +msgid "" +">>> def py_cmp_func(a, b):\n" +"... print(\"py_cmp_func\", a[0], b[0])\n" +"... return 0\n" +"...\n" +">>> cmp_func = CMPFUNC(py_cmp_func)\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1037 msgid "The result::" msgstr "" -#: library/ctypes.rst:1048 +#: library/ctypes.rst:1039 +msgid "" +">>> qsort(ia, len(ia), sizeof(c_int), cmp_func) \n" +"py_cmp_func 5 1\n" +"py_cmp_func 33 99\n" +"py_cmp_func 7 33\n" +"py_cmp_func 5 7\n" +"py_cmp_func 1 7\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1047 msgid "Now we can actually compare the two items and return a useful result::" msgstr "" -#: library/ctypes.rst:1063 +#: library/ctypes.rst:1049 +msgid "" +">>> def py_cmp_func(a, b):\n" +"... print(\"py_cmp_func\", a[0], b[0])\n" +"... return a[0] - b[0]\n" +"...\n" +">>>\n" +">>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func)) \n" +"py_cmp_func 5 1\n" +"py_cmp_func 33 99\n" +"py_cmp_func 7 33\n" +"py_cmp_func 1 7\n" +"py_cmp_func 5 7\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1062 msgid "As we can easily check, our array is sorted now::" msgstr "" -#: library/ctypes.rst:1070 +#: library/ctypes.rst:1064 +msgid "" +">>> for i in ia: print(i, end=\" \")\n" +"...\n" +"1 5 7 33 99\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1069 msgid "" "The function factories can be used as decorator factories, so we may as well " "write::" msgstr "" -#: library/ctypes.rst:1088 +#: library/ctypes.rst:1072 +msgid "" +">>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" +"... def py_cmp_func(a, b):\n" +"... print(\"py_cmp_func\", a[0], b[0])\n" +"... return a[0] - b[0]\n" +"...\n" +">>> qsort(ia, len(ia), sizeof(c_int), py_cmp_func)\n" +"py_cmp_func 5 1\n" +"py_cmp_func 33 99\n" +"py_cmp_func 7 33\n" +"py_cmp_func 1 7\n" +"py_cmp_func 5 7\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1087 msgid "" "Make sure you keep references to :func:`CFUNCTYPE` objects as long as they " "are used from C code. :mod:`ctypes` doesn't, and if you don't, they may be " "garbage collected, crashing your program when a callback is made." msgstr "" -#: library/ctypes.rst:1092 +#: library/ctypes.rst:1091 msgid "" "Also, note that if the callback function is called in a thread created " "outside of Python's control (e.g. by the foreign code that calls the " @@ -1039,35 +1719,42 @@ msgid "" "even when those calls are made from the same C thread." msgstr "" -#: library/ctypes.rst:1102 +#: library/ctypes.rst:1101 msgid "Accessing values exported from dlls" msgstr "" -#: library/ctypes.rst:1104 +#: library/ctypes.rst:1103 msgid "" "Some shared libraries not only export functions, they also export variables. " "An example in the Python library itself is the :c:data:`Py_Version`, Python " "runtime version number encoded in a single constant integer." msgstr "" -#: library/ctypes.rst:1108 +#: library/ctypes.rst:1107 msgid "" ":mod:`ctypes` can access values like this with the :meth:`~_CData.in_dll` " "class methods of the type. *pythonapi* is a predefined symbol giving access " "to the Python C api::" msgstr "" -#: library/ctypes.rst:1116 +#: library/ctypes.rst:1111 +msgid "" +">>> version = ctypes.c_int.in_dll(ctypes.pythonapi, \"Py_Version\")\n" +">>> print(hex(version.value))\n" +"0x30c00a0" +msgstr "" + +#: library/ctypes.rst:1115 msgid "" "An extended example which also demonstrates the use of pointers accesses " "the :c:data:`PyImport_FrozenModules` pointer exported by Python." msgstr "" -#: library/ctypes.rst:1119 +#: library/ctypes.rst:1118 msgid "Quoting the docs for that value:" msgstr "" -#: library/ctypes.rst:1121 +#: library/ctypes.rst:1120 msgid "" "This pointer is initialized to point to an array of :c:struct:`_frozen` " "records, terminated by one whose members are all ``NULL`` or zero. When a " @@ -1076,19 +1763,40 @@ msgid "" "frozen modules." msgstr "" -#: library/ctypes.rst:1126 +#: library/ctypes.rst:1125 msgid "" "So manipulating this pointer could even prove useful. To restrict the " "example size, we show only how this table can be read with :mod:`ctypes`::" msgstr "" -#: library/ctypes.rst:1140 +#: library/ctypes.rst:1128 +msgid "" +">>> from ctypes import *\n" +">>>\n" +">>> class struct_frozen(Structure):\n" +"... _fields_ = [(\"name\", c_char_p),\n" +"... (\"code\", POINTER(c_ubyte)),\n" +"... (\"size\", c_int),\n" +"... (\"get_code\", POINTER(c_ubyte)), # Function pointer\n" +"... ]\n" +"...\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1139 msgid "" "We have defined the :c:struct:`_frozen` data type, so we can get the pointer " "to the table::" msgstr "" -#: library/ctypes.rst:1147 +#: library/ctypes.rst:1142 +msgid "" +">>> FrozenTable = POINTER(struct_frozen)\n" +">>> table = FrozenTable.in_dll(pythonapi, \"_PyImport_FrozenBootstrap\")\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1146 msgid "" "Since ``table`` is a ``pointer`` to the array of ``struct_frozen`` records, " "we can iterate over it, but we just have to make sure that our loop " @@ -1097,34 +1805,76 @@ msgid "" "the loop when we hit the ``NULL`` entry::" msgstr "" -#: library/ctypes.rst:1163 +#: library/ctypes.rst:1152 +msgid "" +">>> for item in table:\n" +"... if item.name is None:\n" +"... break\n" +"... print(item.name.decode(\"ascii\"), item.size)\n" +"...\n" +"_frozen_importlib 31764\n" +"_frozen_importlib_external 41499\n" +"zipimport 12345\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1162 msgid "" "The fact that standard Python has a frozen module and a frozen package " "(indicated by the negative ``size`` member) is not well known, it is only " "used for testing. Try it out with ``import __hello__`` for example." msgstr "" -#: library/ctypes.rst:1171 +#: library/ctypes.rst:1170 msgid "Surprises" msgstr "" -#: library/ctypes.rst:1173 +#: library/ctypes.rst:1172 msgid "" "There are some edges in :mod:`ctypes` where you might expect something other " "than what actually happens." msgstr "" -#: library/ctypes.rst:1176 +#: library/ctypes.rst:1175 msgid "Consider the following example::" msgstr "" -#: library/ctypes.rst:1196 +#: library/ctypes.rst:1177 +msgid "" +">>> from ctypes import *\n" +">>> class POINT(Structure):\n" +"... _fields_ = (\"x\", c_int), (\"y\", c_int)\n" +"...\n" +">>> class RECT(Structure):\n" +"... _fields_ = (\"a\", POINT), (\"b\", POINT)\n" +"...\n" +">>> p1 = POINT(1, 2)\n" +">>> p2 = POINT(3, 4)\n" +">>> rc = RECT(p1, p2)\n" +">>> print(rc.a.x, rc.a.y, rc.b.x, rc.b.y)\n" +"1 2 3 4\n" +">>> # now swap the two points\n" +">>> rc.a, rc.b = rc.b, rc.a\n" +">>> print(rc.a.x, rc.a.y, rc.b.x, rc.b.y)\n" +"3 4 3 4\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1195 msgid "" "Hm. We certainly expected the last statement to print ``3 4 1 2``. What " "happened? Here are the steps of the ``rc.a, rc.b = rc.b, rc.a`` line above::" msgstr "" -#: library/ctypes.rst:1204 +#: library/ctypes.rst:1198 +msgid "" +">>> temp0, temp1 = rc.b, rc.a\n" +">>> rc.a = temp0\n" +">>> rc.b = temp1\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1203 msgid "" "Note that ``temp0`` and ``temp1`` are objects still using the internal " "buffer of the ``rc`` object above. So executing ``rc.a = temp0`` copies the " @@ -1133,26 +1883,37 @@ msgid "" "have the expected effect." msgstr "" -#: library/ctypes.rst:1210 +#: library/ctypes.rst:1209 msgid "" "Keep in mind that retrieving sub-objects from Structure, Unions, and Arrays " "doesn't *copy* the sub-object, instead it retrieves a wrapper object " "accessing the root-object's underlying buffer." msgstr "" -#: library/ctypes.rst:1214 +#: library/ctypes.rst:1213 msgid "" "Another example that may behave differently from what one would expect is " "this::" msgstr "" -#: library/ctypes.rst:1226 +#: library/ctypes.rst:1215 +msgid "" +">>> s = c_char_p()\n" +">>> s.value = b\"abc def ghi\"\n" +">>> s.value\n" +"b'abc def ghi'\n" +">>> s.value is s.value\n" +"False\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1225 msgid "" "Objects instantiated from :class:`c_char_p` can only have their value set to " "bytes or integers." msgstr "" -#: library/ctypes.rst:1229 +#: library/ctypes.rst:1228 msgid "" "Why is it printing ``False``? ctypes instances are objects containing a " "memory block plus some :term:`descriptor`\\s accessing the contents of the " @@ -1161,16 +1922,16 @@ msgid "" "the contents again constructs a new Python object each time!" msgstr "" -#: library/ctypes.rst:1239 +#: library/ctypes.rst:1238 msgid "Variable-sized data types" msgstr "" -#: library/ctypes.rst:1241 +#: library/ctypes.rst:1240 msgid "" ":mod:`ctypes` provides some support for variable-sized arrays and structures." msgstr "" -#: library/ctypes.rst:1243 +#: library/ctypes.rst:1242 msgid "" "The :func:`resize` function can be used to resize the memory buffer of an " "existing ctypes object. The function takes the object as first argument, " @@ -1179,35 +1940,63 @@ msgid "" "objects type, a :exc:`ValueError` is raised if this is tried::" msgstr "" -#: library/ctypes.rst:1263 +#: library/ctypes.rst:1248 +msgid "" +">>> short_array = (c_short * 4)()\n" +">>> print(sizeof(short_array))\n" +"8\n" +">>> resize(short_array, 4)\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: minimum size is 8\n" +">>> resize(short_array, 32)\n" +">>> sizeof(short_array)\n" +"32\n" +">>> sizeof(type(short_array))\n" +"8\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1262 msgid "" "This is nice and fine, but how would one access the additional elements " "contained in this array? Since the type still only knows about 4 elements, " "we get errors accessing other elements::" msgstr "" -#: library/ctypes.rst:1275 +#: library/ctypes.rst:1266 +msgid "" +">>> short_array[:]\n" +"[0, 0, 0, 0]\n" +">>> short_array[7]\n" +"Traceback (most recent call last):\n" +" ...\n" +"IndexError: invalid index\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1274 msgid "" "Another way to use variable-sized data types with :mod:`ctypes` is to use " "the dynamic nature of Python, and (re-)define the data type after the " "required size is already known, on a case by case basis." msgstr "" -#: library/ctypes.rst:1283 +#: library/ctypes.rst:1282 msgid "ctypes reference" msgstr "" -#: library/ctypes.rst:1289 +#: library/ctypes.rst:1288 msgid "Finding shared libraries" msgstr "" -#: library/ctypes.rst:1291 +#: library/ctypes.rst:1290 msgid "" "When programming in a compiled language, shared libraries are accessed when " "compiling/linking a program, and when the program is run." msgstr "" -#: library/ctypes.rst:1294 +#: library/ctypes.rst:1293 msgid "" "The purpose of the :func:`~ctypes.util.find_library` function is to locate a " "library in a way similar to what the compiler or runtime loader does (on " @@ -1216,13 +2005,13 @@ msgid "" "and call the runtime loader directly." msgstr "" -#: library/ctypes.rst:1300 +#: library/ctypes.rst:1299 msgid "" "The :mod:`!ctypes.util` module provides a function which can help to " "determine the library to load." msgstr "" -#: library/ctypes.rst:1308 +#: library/ctypes.rst:1307 msgid "" "Try to find a library and return a pathname. *name* is the library name " "without any prefix like *lib*, suffix like ``.so``, ``.dylib`` or version " @@ -1230,36 +2019,62 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: library/ctypes.rst:1973 +#: library/ctypes.rst:1997 msgid "The exact functionality is system dependent." msgstr "" -#: library/ctypes.rst:1315 +#: library/ctypes.rst:1314 msgid "" "On Linux, :func:`~ctypes.util.find_library` tries to run external programs " "(``/sbin/ldconfig``, ``gcc``, ``objdump`` and ``ld``) to find the library " "file. It returns the filename of the library file." msgstr "" -#: library/ctypes.rst:1319 +#: library/ctypes.rst:1318 msgid "" "On Linux, the value of the environment variable ``LD_LIBRARY_PATH`` is used " "when searching for libraries, if a library cannot be found by any other " "means." msgstr "" -#: library/ctypes.rst:1323 +#: library/ctypes.rst:1322 msgid "Here are some examples::" msgstr "" -#: library/ctypes.rst:1334 +#: library/ctypes.rst:1324 +msgid "" +">>> from ctypes.util import find_library\n" +">>> find_library(\"m\")\n" +"'libm.so.6'\n" +">>> find_library(\"c\")\n" +"'libc.so.6'\n" +">>> find_library(\"bz2\")\n" +"'libbz2.so.1.0'\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1333 msgid "" "On macOS, :func:`~ctypes.util.find_library` tries several predefined naming " "schemes and paths to locate the library, and returns a full pathname if " "successful::" msgstr "" -#: library/ctypes.rst:1348 +#: library/ctypes.rst:1336 +msgid "" +">>> from ctypes.util import find_library\n" +">>> find_library(\"c\")\n" +"'/usr/lib/libc.dylib'\n" +">>> find_library(\"m\")\n" +"'/usr/lib/libm.dylib'\n" +">>> find_library(\"bz2\")\n" +"'/usr/lib/libbz2.dylib'\n" +">>> find_library(\"AGL\")\n" +"'/System/Library/Frameworks/AGL.framework/AGL'\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1347 msgid "" "On Windows, :func:`~ctypes.util.find_library` searches along the system " "search path, and returns the full pathname, but since there is no predefined " @@ -1267,7 +2082,7 @@ msgid "" "``None``." msgstr "" -#: library/ctypes.rst:1352 +#: library/ctypes.rst:1351 msgid "" "If wrapping a shared library with :mod:`ctypes`, it *may* be better to " "determine the shared library name at development time, and hardcode that " @@ -1275,75 +2090,82 @@ msgid "" "to locate the library at runtime." msgstr "" -#: library/ctypes.rst:1360 +#: library/ctypes.rst:1359 msgid "Loading shared libraries" msgstr "" -#: library/ctypes.rst:1362 +#: library/ctypes.rst:1361 msgid "" "There are several ways to load shared libraries into the Python process. " "One way is to instantiate one of the following classes:" msgstr "" -#: library/ctypes.rst:1368 +#: library/ctypes.rst:1367 msgid "" "Instances of this class represent loaded shared libraries. Functions in " "these libraries use the standard C calling convention, and are assumed to " "return :c:expr:`int`." msgstr "" -#: library/ctypes.rst:1372 +#: library/ctypes.rst:1371 msgid "" "On Windows creating a :class:`CDLL` instance may fail even if the DLL name " -"exists. When a dependent DLL of the loaded DLL is not found, a :exc:" -"`OSError` error is raised with the message *\"[WinError 126] The specified " -"module could not be found\".* This error message does not contain the name " -"of the missing DLL because the Windows API does not return this information " -"making this error hard to diagnose. To resolve this error and determine " -"which DLL is not found, you need to find the list of dependent DLLs and " -"determine which one is not found using Windows debugging and tracing tools." +"exists. When a dependent DLL of the loaded DLL is not found, " +"a :exc:`OSError` error is raised with the message *\"[WinError 126] The " +"specified module could not be found\".* This error message does not contain " +"the name of the missing DLL because the Windows API does not return this " +"information making this error hard to diagnose. To resolve this error and " +"determine which DLL is not found, you need to find the list of dependent " +"DLLs and determine which one is not found using Windows debugging and " +"tracing tools." msgstr "" -#: library/ctypes.rst:1407 library/ctypes.rst:1435 +#: library/ctypes.rst:1408 library/ctypes.rst:1439 msgid "The *name* parameter can now be a :term:`path-like object`." msgstr "" -#: library/ctypes.rst:1388 +#: library/ctypes.rst:1387 msgid "" "`Microsoft DUMPBIN tool `_ -- A tool to find DLL dependents." msgstr "" -#: library/ctypes.rst:1394 +#: library/ctypes.rst:1393 msgid "" -"Windows only: Instances of this class represent loaded shared libraries, " -"functions in these libraries use the ``stdcall`` calling convention, and are " -"assumed to return the windows specific :class:`HRESULT` code. :class:" -"`HRESULT` values contain information specifying whether the function call " -"failed or succeeded, together with additional error code. If the return " -"value signals a failure, an :class:`OSError` is automatically raised." +"Instances of this class represent loaded shared libraries, functions in " +"these libraries use the ``stdcall`` calling convention, and are assumed to " +"return the windows specific :class:`HRESULT` code. :class:`HRESULT` values " +"contain information specifying whether the function call failed or " +"succeeded, together with additional error code. If the return value signals " +"a failure, an :class:`OSError` is automatically raised." +msgstr "" + +#: library/ctypes.rst:1417 library/ctypes.rst:1569 library/ctypes.rst:1977 +#: library/ctypes.rst:2011 library/ctypes.rst:2029 library/ctypes.rst:2101 +#: library/ctypes.rst:2473 +msgid "Availability" msgstr "" -#: library/ctypes.rst:1401 +#: library/ctypes.rst:1402 msgid "" -":exc:`WindowsError` used to be raised, which is now an alias of :exc:" -"`OSError`." +":exc:`WindowsError` used to be raised, which is now an alias " +"of :exc:`OSError`." msgstr "" -#: library/ctypes.rst:1412 +#: library/ctypes.rst:1413 msgid "" -"Windows only: Instances of this class represent loaded shared libraries, " -"functions in these libraries use the ``stdcall`` calling convention, and are " -"assumed to return :c:expr:`int` by default." +"Instances of this class represent loaded shared libraries, functions in " +"these libraries use the ``stdcall`` calling convention, and are assumed to " +"return :c:expr:`int` by default." msgstr "" -#: library/ctypes.rst:1420 +#: library/ctypes.rst:1424 msgid "" "The Python :term:`global interpreter lock` is released before calling any " "function exported by these libraries, and reacquired afterwards." msgstr "" -#: library/ctypes.rst:1426 +#: library/ctypes.rst:1430 msgid "" "Instances of this class behave like :class:`CDLL` instances, except that the " "Python GIL is *not* released during the function call, and after the " @@ -1351,11 +2173,11 @@ msgid "" "set, a Python exception is raised." msgstr "" -#: library/ctypes.rst:1431 +#: library/ctypes.rst:1435 msgid "Thus, this is only useful to call Python C api functions directly." msgstr "" -#: library/ctypes.rst:1437 +#: library/ctypes.rst:1441 msgid "" "All these classes can be instantiated by calling them with at least one " "argument, the pathname of the shared library. If you have an existing " @@ -1365,7 +2187,7 @@ msgid "" "the process, and to get a handle to it." msgstr "" -#: library/ctypes.rst:1444 +#: library/ctypes.rst:1448 msgid "" "The *mode* parameter can be used to specify how the library is loaded. For " "details, consult the :manpage:`dlopen(3)` manpage. On Windows, *mode* is " @@ -1373,33 +2195,35 @@ msgid "" "configurable." msgstr "" -#: library/ctypes.rst:1449 +#: library/ctypes.rst:1453 msgid "" "The *use_errno* parameter, when set to true, enables a ctypes mechanism that " -"allows accessing the system :data:`errno` error number in a safe way. :mod:" -"`ctypes` maintains a thread-local copy of the systems :data:`errno` " -"variable; if you call foreign functions created with ``use_errno=True`` then " -"the :data:`errno` value before the function call is swapped with the ctypes " -"private copy, the same happens immediately after the function call." +"allows accessing the system :data:`errno` error number in a safe " +"way. :mod:`ctypes` maintains a thread-local copy of the " +"systems :data:`errno` variable; if you call foreign functions created with " +"``use_errno=True`` then the :data:`errno` value before the function call is " +"swapped with the ctypes private copy, the same happens immediately after the " +"function call." msgstr "" -#: library/ctypes.rst:1456 +#: library/ctypes.rst:1460 msgid "" "The function :func:`ctypes.get_errno` returns the value of the ctypes " "private copy, and the function :func:`ctypes.set_errno` changes the ctypes " "private copy to a new value and returns the former value." msgstr "" -#: library/ctypes.rst:1460 +#: library/ctypes.rst:1464 msgid "" "The *use_last_error* parameter, when set to true, enables the same mechanism " -"for the Windows error code which is managed by the :func:`GetLastError` and :" -"func:`!SetLastError` Windows API functions; :func:`ctypes.get_last_error` " -"and :func:`ctypes.set_last_error` are used to request and change the ctypes " -"private copy of the windows error code." +"for the Windows error code which is managed by the :func:`GetLastError` " +"and :func:`!SetLastError` Windows API " +"functions; :func:`ctypes.get_last_error` and :func:`ctypes.set_last_error` " +"are used to request and change the ctypes private copy of the windows error " +"code." msgstr "" -#: library/ctypes.rst:1466 +#: library/ctypes.rst:1470 msgid "" "The *winmode* parameter is used on Windows to specify how the library is " "loaded (since *mode* is ignored). It takes any value that is valid for the " @@ -1409,29 +2233,29 @@ msgid "" "ensure the correct library and dependencies are loaded." msgstr "" -#: library/ctypes.rst:1473 +#: library/ctypes.rst:1477 msgid "Added *winmode* parameter." msgstr "" -#: library/ctypes.rst:1480 +#: library/ctypes.rst:1484 msgid "" "Flag to use as *mode* parameter. On platforms where this flag is not " "available, it is defined as the integer zero." msgstr "" -#: library/ctypes.rst:1487 +#: library/ctypes.rst:1491 msgid "" "Flag to use as *mode* parameter. On platforms where this is not available, " "it is the same as *RTLD_GLOBAL*." msgstr "" -#: library/ctypes.rst:1494 +#: library/ctypes.rst:1498 msgid "" "The default mode which is used to load shared libraries. On OSX 10.3, this " "is *RTLD_GLOBAL*, otherwise it is the same as *RTLD_LOCAL*." msgstr "" -#: library/ctypes.rst:1497 +#: library/ctypes.rst:1501 msgid "" "Instances of these classes have no public methods. Functions exported by " "the shared library can be accessed as attributes or by index. Please note " @@ -1440,21 +2264,31 @@ msgid "" "other hand, accessing it through an index returns a new object each time::" msgstr "" -#: library/ctypes.rst:1510 +#: library/ctypes.rst:1507 +msgid "" +">>> from ctypes import CDLL\n" +">>> libc = CDLL(\"libc.so.6\") # On Linux\n" +">>> libc.time == libc.time\n" +"True\n" +">>> libc['time'] == libc['time']\n" +"False" +msgstr "" + +#: library/ctypes.rst:1514 msgid "" "The following public attributes are available, their name starts with an " "underscore to not clash with exported function names:" msgstr "" -#: library/ctypes.rst:1516 +#: library/ctypes.rst:1520 msgid "The system handle used to access the library." msgstr "" -#: library/ctypes.rst:1521 +#: library/ctypes.rst:1525 msgid "The name of the library passed in the constructor." msgstr "" -#: library/ctypes.rst:1523 +#: library/ctypes.rst:1527 msgid "" "Shared libraries can also be loaded by using one of the prefabricated " "objects, which are instances of the :class:`LibraryLoader` class, either by " @@ -1462,13 +2296,13 @@ msgid "" "library as attribute of the loader instance." msgstr "" -#: library/ctypes.rst:1531 +#: library/ctypes.rst:1535 msgid "" -"Class which loads shared libraries. *dlltype* should be one of the :class:" -"`CDLL`, :class:`PyDLL`, :class:`WinDLL`, or :class:`OleDLL` types." +"Class which loads shared libraries. *dlltype* should be one of " +"the :class:`CDLL`, :class:`PyDLL`, :class:`WinDLL`, or :class:`OleDLL` types." msgstr "" -#: library/ctypes.rst:1534 +#: library/ctypes.rst:1538 msgid "" ":meth:`!__getattr__` has special behavior: It allows loading a shared " "library by accessing it as attribute of a library loader instance. The " @@ -1476,121 +2310,119 @@ msgid "" "each time." msgstr "" -#: library/ctypes.rst:1540 +#: library/ctypes.rst:1544 msgid "" "Load a shared library into the process and return it. This method always " "returns a new instance of the library." msgstr "" -#: library/ctypes.rst:1544 +#: library/ctypes.rst:1548 msgid "These prefabricated library loaders are available:" msgstr "" -#: library/ctypes.rst:1549 +#: library/ctypes.rst:1553 msgid "Creates :class:`CDLL` instances." msgstr "" -#: library/ctypes.rst:1555 -msgid "Windows only: Creates :class:`WinDLL` instances." +#: library/ctypes.rst:1559 +msgid "Creates :class:`WinDLL` instances." msgstr "" -#: library/ctypes.rst:1561 -msgid "Windows only: Creates :class:`OleDLL` instances." +#: library/ctypes.rst:1567 +msgid "Creates :class:`OleDLL` instances." msgstr "" -#: library/ctypes.rst:1567 +#: library/ctypes.rst:1575 msgid "Creates :class:`PyDLL` instances." msgstr "" -#: library/ctypes.rst:1570 +#: library/ctypes.rst:1578 msgid "" "For accessing the C Python api directly, a ready-to-use Python shared " "library object is available:" msgstr "" -#: library/ctypes.rst:1576 +#: library/ctypes.rst:1584 msgid "" "An instance of :class:`PyDLL` that exposes Python C API functions as " -"attributes. Note that all these functions are assumed to return C :c:expr:" -"`int`, which is of course not always the truth, so you have to assign the " -"correct :attr:`!restype` attribute to use these functions." -msgstr "" - -#: library/ctypes.rst:1581 -msgid "" -"Raises an :ref:`auditing event ` ``ctypes.dlopen`` with argument " -"``name``." +"attributes. Note that all these functions are assumed to return " +"C :c:expr:`int`, which is of course not always the truth, so you have to " +"assign the correct :attr:`!restype` attribute to use these functions." msgstr "" -#: library/ctypes.rst:1583 +#: library/ctypes.rst:1591 msgid "" "Loading a library through any of these objects raises an :ref:`auditing " "event ` ``ctypes.dlopen`` with string argument ``name``, the name " "used to load the library." msgstr "" -#: library/ctypes.rst:1587 -msgid "" -"Raises an :ref:`auditing event ` ``ctypes.dlsym`` with arguments " -"``library``, ``name``." -msgstr "" - -#: library/ctypes.rst:1589 -msgid "" -"Accessing a function on a loaded library raises an auditing event ``ctypes." -"dlsym`` with arguments ``library`` (the library object) and ``name`` (the " -"symbol's name as a string or integer)." -msgstr "" - -#: library/ctypes.rst:1593 +#: library/ctypes.rst:1597 msgid "" -"Raises an :ref:`auditing event ` ``ctypes.dlsym/handle`` with " -"arguments ``handle``, ``name``." +"Accessing a function on a loaded library raises an auditing event " +"``ctypes.dlsym`` with arguments ``library`` (the library object) and " +"``name`` (the symbol's name as a string or integer)." msgstr "" -#: library/ctypes.rst:1595 +#: library/ctypes.rst:1603 msgid "" "In cases when only the library handle is available rather than the object, " "accessing a function raises an auditing event ``ctypes.dlsym/handle`` with " "arguments ``handle`` (the raw library handle) and ``name``." msgstr "" -#: library/ctypes.rst:1602 +#: library/ctypes.rst:1610 msgid "Foreign functions" msgstr "" -#: library/ctypes.rst:1604 +#: library/ctypes.rst:1612 msgid "" "As explained in the previous section, foreign functions can be accessed as " "attributes of loaded shared libraries. The function objects created in this " "way by default accept any number of arguments, accept any ctypes data " "instances as arguments, and return the default result type specified by the " -"library loader. They are instances of a private class:" +"library loader." +msgstr "" + +#: library/ctypes.rst:1617 +msgid "" +"They are instances of a private local class :class:`!_FuncPtr` (not exposed " +"in :mod:`!ctypes`) which inherits from the private :class:`_CFuncPtr` class:" msgstr "" -#: library/ctypes.rst:1613 +#: library/ctypes.rst:1620 +msgid "" +">>> import ctypes\n" +">>> lib = ctypes.CDLL(None)\n" +">>> issubclass(lib._FuncPtr, ctypes._CFuncPtr)\n" +"True\n" +">>> lib._FuncPtr is ctypes._CFuncPtr\n" +"False" +msgstr "" + +#: library/ctypes.rst:1631 msgid "Base class for C callable foreign functions." msgstr "" -#: library/ctypes.rst:1615 +#: library/ctypes.rst:1633 msgid "" "Instances of foreign functions are also C compatible data types; they " "represent C function pointers." msgstr "" -#: library/ctypes.rst:1618 +#: library/ctypes.rst:1636 msgid "" "This behavior can be customized by assigning to special attributes of the " "foreign function object." msgstr "" -#: library/ctypes.rst:1623 +#: library/ctypes.rst:1641 msgid "" "Assign a ctypes type to specify the result type of the foreign function. Use " "``None`` for :c:expr:`void`, a function not returning anything." msgstr "" -#: library/ctypes.rst:1626 +#: library/ctypes.rst:1644 msgid "" "It is possible to assign a callable Python object that is not a ctypes type, " "in this case the function is assumed to return a C :c:expr:`int`, and the " @@ -1600,7 +2432,7 @@ msgid "" "callable to the :attr:`errcheck` attribute." msgstr "" -#: library/ctypes.rst:1635 +#: library/ctypes.rst:1653 msgid "" "Assign a tuple of ctypes types to specify the argument types that the " "function accepts. Functions using the ``stdcall`` calling convention can " @@ -1609,17 +2441,17 @@ msgid "" "unspecified arguments as well." msgstr "" -#: library/ctypes.rst:1641 +#: library/ctypes.rst:1659 msgid "" -"When a foreign function is called, each actual argument is passed to the :" -"meth:`~_CData.from_param` class method of the items in the :attr:`argtypes` " -"tuple, this method allows adapting the actual argument to an object that the " -"foreign function accepts. For example, a :class:`c_char_p` item in the :" -"attr:`argtypes` tuple will convert a string passed as argument into a bytes " -"object using ctypes conversion rules." +"When a foreign function is called, each actual argument is passed to " +"the :meth:`~_CData.from_param` class method of the items in " +"the :attr:`argtypes` tuple, this method allows adapting the actual argument " +"to an object that the foreign function accepts. For example, " +"a :class:`c_char_p` item in the :attr:`argtypes` tuple will convert a string " +"passed as argument into a bytes object using ctypes conversion rules." msgstr "" -#: library/ctypes.rst:1648 +#: library/ctypes.rst:1666 msgid "" "New: It is now possible to put items in argtypes which are not ctypes types, " "but each item must have a :meth:`~_CData.from_param` method which returns a " @@ -1627,76 +2459,64 @@ msgid "" "defining adapters that can adapt custom objects as function parameters." msgstr "" -#: library/ctypes.rst:1655 +#: library/ctypes.rst:1673 msgid "" "Assign a Python function or another callable to this attribute. The callable " "will be called with three or more arguments:" msgstr "" -#: library/ctypes.rst:1662 +#: library/ctypes.rst:1680 msgid "" "*result* is what the foreign function returns, as specified by the :attr:`!" "restype` attribute." msgstr "" -#: library/ctypes.rst:1665 +#: library/ctypes.rst:1683 msgid "" "*func* is the foreign function object itself, this allows reusing the same " "callable object to check or post process the results of several functions." msgstr "" -#: library/ctypes.rst:1669 +#: library/ctypes.rst:1687 msgid "" "*arguments* is a tuple containing the parameters originally passed to the " "function call, this allows specializing the behavior on the arguments used." msgstr "" -#: library/ctypes.rst:1673 +#: library/ctypes.rst:1691 msgid "" "The object that this function returns will be returned from the foreign " "function call, but it can also check the result value and raise an exception " "if the foreign function call failed." msgstr "" -#: library/ctypes.rst:1680 +#: library/ctypes.rst:1698 msgid "" "This exception is raised when a foreign function call cannot convert one of " "the passed arguments." msgstr "" -#: library/ctypes.rst:1684 -msgid "" -"Raises an :ref:`auditing event ` ``ctypes.set_exception`` with " -"argument ``code``." -msgstr "" - -#: library/ctypes.rst:1686 +#: library/ctypes.rst:1704 msgid "" "On Windows, when a foreign function call raises a system exception (for " "example, due to an access violation), it will be captured and replaced with " -"a suitable Python exception. Further, an auditing event ``ctypes." -"set_exception`` with argument ``code`` will be raised, allowing an audit " -"hook to replace the exception with its own." +"a suitable Python exception. Further, an auditing event " +"``ctypes.set_exception`` with argument ``code`` will be raised, allowing an " +"audit hook to replace the exception with its own." msgstr "" -#: library/ctypes.rst:1692 -msgid "" -"Raises an :ref:`auditing event ` ``ctypes.call_function`` with " -"arguments ``func_pointer``, ``arguments``." -msgstr "" - -#: library/ctypes.rst:1694 +#: library/ctypes.rst:1712 msgid "" "Some ways to invoke foreign function calls may raise an auditing event " "``ctypes.call_function`` with arguments ``function pointer`` and " "``arguments``." msgstr "" -#: library/ctypes.rst:1700 +#: library/ctypes.rst:1718 msgid "Function prototypes" msgstr "" -#: library/ctypes.rst:1702 +#: library/ctypes.rst:1720 msgid "" "Foreign functions can also be created by instantiating function prototypes. " "Function prototypes are similar to function prototypes in C; they describe a " @@ -1707,46 +2527,47 @@ msgid "" "``@wrapper`` syntax. See :ref:`ctypes-callback-functions` for examples." msgstr "" -#: library/ctypes.rst:1713 +#: library/ctypes.rst:1731 msgid "" "The returned function prototype creates functions that use the standard C " "calling convention. The function will release the GIL during the call. If " -"*use_errno* is set to true, the ctypes private copy of the system :data:" -"`errno` variable is exchanged with the real :data:`errno` value before and " -"after the call; *use_last_error* does the same for the Windows error code." +"*use_errno* is set to true, the ctypes private copy of the " +"system :data:`errno` variable is exchanged with the real :data:`errno` value " +"before and after the call; *use_last_error* does the same for the Windows " +"error code." msgstr "" -#: library/ctypes.rst:1723 +#: library/ctypes.rst:1741 msgid "" -"Windows only: The returned function prototype creates functions that use the " -"``stdcall`` calling convention. The function will release the GIL during " -"the call. *use_errno* and *use_last_error* have the same meaning as above." +"The returned function prototype creates functions that use the ``stdcall`` " +"calling convention. The function will release the GIL during the call. " +"*use_errno* and *use_last_error* have the same meaning as above." msgstr "" -#: library/ctypes.rst:1731 +#: library/ctypes.rst:1751 msgid "" "The returned function prototype creates functions that use the Python " "calling convention. The function will *not* release the GIL during the call." msgstr "" -#: library/ctypes.rst:1734 +#: library/ctypes.rst:1754 msgid "" "Function prototypes created by these factory functions can be instantiated " "in different ways, depending on the type and number of the parameters in the " "call:" msgstr "" -#: library/ctypes.rst:1741 +#: library/ctypes.rst:1761 msgid "" "Returns a foreign function at the specified address which must be an integer." msgstr "" -#: library/ctypes.rst:1748 +#: library/ctypes.rst:1768 msgid "" "Create a C callable function (a callback function) from a Python *callable*." msgstr "" -#: library/ctypes.rst:1755 +#: library/ctypes.rst:1775 msgid "" "Returns a foreign function exported by a shared library. *func_spec* must be " "a 2-tuple ``(name_or_ordinal, library)``. The first item is the name of the " @@ -1754,7 +2575,7 @@ msgid "" "small integer. The second item is the shared library instance." msgstr "" -#: library/ctypes.rst:1765 +#: library/ctypes.rst:1785 msgid "" "Returns a foreign function that will call a COM method. *vtbl_index* is the " "index into the virtual function table, a small non-negative integer. *name* " @@ -1762,87 +2583,114 @@ msgid "" "identifier which is used in extended error reporting." msgstr "" -#: library/ctypes.rst:1770 +#: library/ctypes.rst:1790 msgid "" "COM methods use a special calling convention: They require a pointer to the " "COM interface as first argument, in addition to those parameters that are " "specified in the :attr:`!argtypes` tuple." msgstr "" -#: library/ctypes.rst:1774 +#: library/ctypes.rst:1794 msgid "" "The optional *paramflags* parameter creates foreign function wrappers with " "much more functionality than the features described above." msgstr "" -#: library/ctypes.rst:1777 +#: library/ctypes.rst:1797 msgid "" -"*paramflags* must be a tuple of the same length as :attr:`~_FuncPtr." -"argtypes`." +"*paramflags* must be a tuple of the same length " +"as :attr:`~_CFuncPtr.argtypes`." msgstr "" -#: library/ctypes.rst:1779 +#: library/ctypes.rst:1799 msgid "" "Each item in this tuple contains further information about a parameter, it " "must be a tuple containing one, two, or three items." msgstr "" -#: library/ctypes.rst:1782 +#: library/ctypes.rst:1802 msgid "" "The first item is an integer containing a combination of direction flags for " "the parameter:" msgstr "" -#: library/ctypes.rst:1786 +#: library/ctypes.rst:1805 msgid "1" msgstr "" -#: library/ctypes.rst:1786 +#: library/ctypes.rst:1806 msgid "Specifies an input parameter to the function." msgstr "" -#: library/ctypes.rst:1789 +#: library/ctypes.rst:1808 msgid "2" msgstr "" -#: library/ctypes.rst:1789 +#: library/ctypes.rst:1809 msgid "Output parameter. The foreign function fills in a value." msgstr "" -#: library/ctypes.rst:1792 +#: library/ctypes.rst:1811 msgid "4" msgstr "" -#: library/ctypes.rst:1792 +#: library/ctypes.rst:1812 msgid "Input parameter which defaults to the integer zero." msgstr "" -#: library/ctypes.rst:1794 +#: library/ctypes.rst:1814 msgid "" "The optional second item is the parameter name as string. If this is " "specified, the foreign function can be called with named parameters." msgstr "" -#: library/ctypes.rst:1797 +#: library/ctypes.rst:1817 msgid "The optional third item is the default value for this parameter." msgstr "" -#: library/ctypes.rst:1800 +#: library/ctypes.rst:1820 msgid "" "The following example demonstrates how to wrap the Windows ``MessageBoxW`` " "function so that it supports default parameters and named arguments. The C " "declaration from the windows header file is this::" msgstr "" -#: library/ctypes.rst:1834 +#: library/ctypes.rst:1824 +msgid "" +"WINUSERAPI int WINAPI\n" +"MessageBoxW(\n" +" HWND hWnd,\n" +" LPCWSTR lpText,\n" +" LPCWSTR lpCaption,\n" +" UINT uType);" +msgstr "" + +#: library/ctypes.rst:1854 msgid "Here is the wrapping with :mod:`ctypes`::" msgstr "" -#: library/ctypes.rst:1819 +#: library/ctypes.rst:1833 +msgid "" +">>> from ctypes import c_int, WINFUNCTYPE, windll\n" +">>> from ctypes.wintypes import HWND, LPCWSTR, UINT\n" +">>> prototype = WINFUNCTYPE(c_int, HWND, LPCWSTR, LPCWSTR, UINT)\n" +">>> paramflags = (1, \"hwnd\", 0), (1, \"text\", \"Hi\"), (1, \"caption\", " +"\"Hello from ctypes\"), (1, \"flags\", 0)\n" +">>> MessageBox = prototype((\"MessageBoxW\", windll.user32), paramflags)" +msgstr "" + +#: library/ctypes.rst:1839 msgid "The ``MessageBox`` foreign function can now be called in these ways::" msgstr "" -#: library/ctypes.rst:1825 +#: library/ctypes.rst:1841 +msgid "" +">>> MessageBox()\n" +">>> MessageBox(text=\"Spam, spam, spam\")\n" +">>> MessageBox(flags=2, text=\"foo bar\")" +msgstr "" + +#: library/ctypes.rst:1845 msgid "" "A second example demonstrates output parameters. The win32 " "``GetWindowRect`` function retrieves the dimensions of a specified window by " @@ -1850,7 +2698,26 @@ msgid "" "the C declaration::" msgstr "" -#: library/ctypes.rst:1843 +#: library/ctypes.rst:1849 +msgid "" +"WINUSERAPI BOOL WINAPI\n" +"GetWindowRect(\n" +" HWND hWnd,\n" +" LPRECT lpRect);" +msgstr "" + +#: library/ctypes.rst:1856 +msgid "" +">>> from ctypes import POINTER, WINFUNCTYPE, windll, WinError\n" +">>> from ctypes.wintypes import BOOL, HWND, RECT\n" +">>> prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT))\n" +">>> paramflags = (1, \"hwnd\"), (2, \"lprect\")\n" +">>> GetWindowRect = prototype((\"GetWindowRect\", windll.user32), " +"paramflags)\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1863 msgid "" "Functions with output parameters will automatically return the output " "parameter value if there is a single one, or a tuple containing the output " @@ -1858,64 +2725,91 @@ msgid "" "now returns a RECT instance, when called." msgstr "" -#: library/ctypes.rst:1848 +#: library/ctypes.rst:1868 msgid "" -"Output parameters can be combined with the :attr:`~_FuncPtr.errcheck` " +"Output parameters can be combined with the :attr:`~_CFuncPtr.errcheck` " "protocol to do further output processing and error checking. The win32 " "``GetWindowRect`` api function returns a ``BOOL`` to signal success or " "failure, so this function could do the error checking, and raises an " "exception when the api call failed::" msgstr "" -#: library/ctypes.rst:1861 +#: library/ctypes.rst:1873 msgid "" -"If the :attr:`~_FuncPtr.errcheck` function returns the argument tuple it " +">>> def errcheck(result, func, args):\n" +"... if not result:\n" +"... raise WinError()\n" +"... return args\n" +"...\n" +">>> GetWindowRect.errcheck = errcheck\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1881 +msgid "" +"If the :attr:`~_CFuncPtr.errcheck` function returns the argument tuple it " "receives unchanged, :mod:`ctypes` continues the normal processing it does on " "the output parameters. If you want to return a tuple of window coordinates " "instead of a ``RECT`` instance, you can retrieve the fields in the function " "and return them instead, the normal processing will no longer take place::" msgstr "" -#: library/ctypes.rst:1880 +#: library/ctypes.rst:1887 +msgid "" +">>> def errcheck(result, func, args):\n" +"... if not result:\n" +"... raise WinError()\n" +"... rc = args[1]\n" +"... return rc.left, rc.top, rc.bottom, rc.right\n" +"...\n" +">>> GetWindowRect.errcheck = errcheck\n" +">>>" +msgstr "" + +#: library/ctypes.rst:1900 msgid "Utility functions" msgstr "" -#: library/ctypes.rst:1884 +#: library/ctypes.rst:1904 msgid "" "Returns the address of the memory buffer as integer. *obj* must be an " "instance of a ctypes type." msgstr "" -#: library/ctypes.rst:1887 +#: library/ctypes.rst:1907 msgid "" "Raises an :ref:`auditing event ` ``ctypes.addressof`` with " "argument ``obj``." msgstr "" -#: library/ctypes.rst:1892 +#: library/ctypes.rst:1912 msgid "" "Returns the alignment requirements of a ctypes type. *obj_or_type* must be a " "ctypes type or instance." msgstr "" -#: library/ctypes.rst:1898 +#: library/ctypes.rst:1918 msgid "" "Returns a light-weight pointer to *obj*, which must be an instance of a " "ctypes type. *offset* defaults to zero, and must be an integer that will be " "added to the internal pointer value." msgstr "" -#: library/ctypes.rst:1902 +#: library/ctypes.rst:1922 msgid "``byref(obj, offset)`` corresponds to this C code::" msgstr "" -#: library/ctypes.rst:1906 +#: library/ctypes.rst:1924 +msgid "(((char *)&obj) + offset)" +msgstr "" + +#: library/ctypes.rst:1926 msgid "" "The returned object can only be used as a foreign function call parameter. " "It behaves similar to ``pointer(obj)``, but the construction is a lot faster." msgstr "" -#: library/ctypes.rst:1912 +#: library/ctypes.rst:1932 msgid "" "This function is similar to the cast operator in C. It returns a new " "instance of *type* which points to the same memory block as *obj*. *type* " @@ -1923,19 +2817,19 @@ msgid "" "as a pointer." msgstr "" -#: library/ctypes.rst:1920 +#: library/ctypes.rst:1940 msgid "" "This function creates a mutable character buffer. The returned object is a " "ctypes array of :class:`c_char`." msgstr "" -#: library/ctypes.rst:1923 +#: library/ctypes.rst:1943 msgid "" "*init_or_size* must be an integer which specifies the size of the array, or " "a bytes object which will be used to initialize the array items." msgstr "" -#: library/ctypes.rst:1926 +#: library/ctypes.rst:1946 msgid "" "If a bytes object is specified as first argument, the buffer is made one " "item larger than its length so that the last element in the array is a NUL " @@ -1944,25 +2838,25 @@ msgid "" "not be used." msgstr "" -#: library/ctypes.rst:1931 +#: library/ctypes.rst:1951 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_string_buffer`` " "with arguments ``init``, ``size``." msgstr "" -#: library/ctypes.rst:1936 +#: library/ctypes.rst:1956 msgid "" "This function creates a mutable unicode character buffer. The returned " "object is a ctypes array of :class:`c_wchar`." msgstr "" -#: library/ctypes.rst:1939 +#: library/ctypes.rst:1959 msgid "" "*init_or_size* must be an integer which specifies the size of the array, or " "a string which will be used to initialize the array items." msgstr "" -#: library/ctypes.rst:1942 +#: library/ctypes.rst:1962 msgid "" "If a string is specified as first argument, the buffer is made one item " "larger than the length of the string so that the last element in the array " @@ -1971,27 +2865,27 @@ msgid "" "should not be used." msgstr "" -#: library/ctypes.rst:1948 +#: library/ctypes.rst:1968 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_unicode_buffer`` " "with arguments ``init``, ``size``." msgstr "" -#: library/ctypes.rst:1953 +#: library/ctypes.rst:1973 msgid "" -"Windows only: This function is a hook which allows implementing in-process " -"COM servers with ctypes. It is called from the DllCanUnloadNow function " -"that the _ctypes extension dll exports." +"This function is a hook which allows implementing in-process COM servers " +"with ctypes. It is called from the DllCanUnloadNow function that the " +"_ctypes extension dll exports." msgstr "" -#: library/ctypes.rst:1960 +#: library/ctypes.rst:1982 msgid "" -"Windows only: This function is a hook which allows implementing in-process " -"COM servers with ctypes. It is called from the DllGetClassObject function " -"that the ``_ctypes`` extension dll exports." +"This function is a hook which allows implementing in-process COM servers " +"with ctypes. It is called from the DllGetClassObject function that the " +"``_ctypes`` extension dll exports." msgstr "" -#: library/ctypes.rst:1968 +#: library/ctypes.rst:1992 msgid "" "Try to find a library and return a pathname. *name* is the library name " "without any prefix like ``lib``, suffix like ``.so``, ``.dylib`` or version " @@ -1999,92 +2893,92 @@ msgid "" "If no library can be found, returns ``None``." msgstr "" -#: library/ctypes.rst:1979 +#: library/ctypes.rst:2003 msgid "" -"Windows only: return the filename of the VC runtime library used by Python, " -"and by the extension modules. If the name of the library cannot be " -"determined, ``None`` is returned." +"Returns the filename of the VC runtime library used by Python, and by the " +"extension modules. If the name of the library cannot be determined, " +"``None`` is returned." msgstr "" -#: library/ctypes.rst:1983 +#: library/ctypes.rst:2007 msgid "" "If you need to free memory, for example, allocated by an extension module " "with a call to the ``free(void *)``, it is important that you use the " "function in the same library that allocated the memory." msgstr "" -#: library/ctypes.rst:1990 +#: library/ctypes.rst:2016 msgid "" -"Windows only: Returns a textual description of the error code *code*. If no " -"error code is specified, the last error code is used by calling the Windows " -"api function GetLastError." +"Returns a textual description of the error code *code*. If no error code is " +"specified, the last error code is used by calling the Windows api function " +"GetLastError." msgstr "" -#: library/ctypes.rst:1997 +#: library/ctypes.rst:2025 msgid "" -"Windows only: Returns the last error code set by Windows in the calling " -"thread. This function calls the Windows ``GetLastError()`` function " -"directly, it does not return the ctypes-private copy of the error code." +"Returns the last error code set by Windows in the calling thread. This " +"function calls the Windows ``GetLastError()`` function directly, it does not " +"return the ctypes-private copy of the error code." msgstr "" -#: library/ctypes.rst:2003 +#: library/ctypes.rst:2034 msgid "" -"Returns the current value of the ctypes-private copy of the system :data:" -"`errno` variable in the calling thread." +"Returns the current value of the ctypes-private copy of the " +"system :data:`errno` variable in the calling thread." msgstr "" -#: library/ctypes.rst:2006 +#: library/ctypes.rst:2037 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_errno`` with no " "arguments." msgstr "" -#: library/ctypes.rst:2010 +#: library/ctypes.rst:2041 msgid "" -"Windows only: returns the current value of the ctypes-private copy of the " -"system :data:`!LastError` variable in the calling thread." +"Returns the current value of the ctypes-private copy of the system :data:`!" +"LastError` variable in the calling thread." msgstr "" -#: library/ctypes.rst:2013 +#: library/ctypes.rst:2046 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_last_error`` with no " "arguments." msgstr "" -#: library/ctypes.rst:2017 +#: library/ctypes.rst:2051 msgid "" "Same as the standard C memmove library function: copies *count* bytes from " "*src* to *dst*. *dst* and *src* must be integers or ctypes instances that " "can be converted to pointers." msgstr "" -#: library/ctypes.rst:2024 +#: library/ctypes.rst:2058 msgid "" "Same as the standard C memset library function: fills the memory block at " "address *dst* with *count* bytes of value *c*. *dst* must be an integer " "specifying an address, or a ctypes instance." msgstr "" -#: library/ctypes.rst:2031 +#: library/ctypes.rst:2065 msgid "" "Create and return a new ctypes pointer type. Pointer types are cached and " "reused internally, so calling this function repeatedly is cheap. *type* must " "be a ctypes type." msgstr "" -#: library/ctypes.rst:2038 +#: library/ctypes.rst:2072 msgid "" "Create a new pointer instance, pointing to *obj*. The returned object is of " "the type ``POINTER(type(obj))``." msgstr "" -#: library/ctypes.rst:2041 +#: library/ctypes.rst:2075 msgid "" "Note: If you just want to pass a pointer to an object to a foreign function " "call, you should use ``byref(obj)`` which is much faster." msgstr "" -#: library/ctypes.rst:2047 +#: library/ctypes.rst:2081 msgid "" "This function resizes the internal memory buffer of *obj*, which must be an " "instance of a ctypes type. It is not possible to make the buffer smaller " @@ -2092,115 +2986,113 @@ msgid "" "but it is possible to enlarge the buffer." msgstr "" -#: library/ctypes.rst:2055 +#: library/ctypes.rst:2089 msgid "" "Set the current value of the ctypes-private copy of the system :data:`errno` " "variable in the calling thread to *value* and return the previous value." msgstr "" -#: library/ctypes.rst:2058 +#: library/ctypes.rst:2092 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_errno`` with " "argument ``errno``." msgstr "" -#: library/ctypes.rst:2063 +#: library/ctypes.rst:2097 msgid "" -"Windows only: set the current value of the ctypes-private copy of the " -"system :data:`!LastError` variable in the calling thread to *value* and " -"return the previous value." +"Sets the current value of the ctypes-private copy of the system :data:`!" +"LastError` variable in the calling thread to *value* and return the previous " +"value." msgstr "" -#: library/ctypes.rst:2067 +#: library/ctypes.rst:2103 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_last_error`` with " "argument ``error``." msgstr "" -#: library/ctypes.rst:2072 +#: library/ctypes.rst:2108 msgid "" "Returns the size in bytes of a ctypes type or instance memory buffer. Does " "the same as the C ``sizeof`` operator." msgstr "" -#: library/ctypes.rst:2078 +#: library/ctypes.rst:2114 msgid "" -"This function returns the C string starting at memory address *address* as a " -"bytes object. If size is specified, it is used as size, otherwise the string " -"is assumed to be zero-terminated." +"Return the byte string at *void \\*ptr*. If *size* is specified, it is used " +"as size, otherwise the string is assumed to be zero-terminated." msgstr "" -#: library/ctypes.rst:2082 +#: library/ctypes.rst:2118 msgid "" "Raises an :ref:`auditing event ` ``ctypes.string_at`` with " -"arguments ``address``, ``size``." +"arguments ``ptr``, ``size``." msgstr "" -#: library/ctypes.rst:2087 +#: library/ctypes.rst:2123 msgid "" -"Windows only: this function is probably the worst-named thing in ctypes. It " -"creates an instance of :exc:`OSError`. If *code* is not specified, " -"``GetLastError`` is called to determine the error code. If *descr* is not " +"This function is probably the worst-named thing in ctypes. It creates an " +"instance of :exc:`OSError`. If *code* is not specified, ``GetLastError`` is " +"called to determine the error code. If *descr* is not " "specified, :func:`FormatError` is called to get a textual description of the " "error." msgstr "" -#: library/ctypes.rst:2093 +#: library/ctypes.rst:2131 msgid "" "An instance of :exc:`WindowsError` used to be created, which is now an alias " "of :exc:`OSError`." msgstr "" -#: library/ctypes.rst:2100 +#: library/ctypes.rst:2138 msgid "" -"This function returns the wide character string starting at memory address " -"*address* as a string. If *size* is specified, it is used as the number of " -"characters of the string, otherwise the string is assumed to be zero-" -"terminated." +"Return the wide-character string at *void \\*ptr*. If *size* is specified, " +"it is used as the number of characters of the string, otherwise the string " +"is assumed to be zero-terminated." msgstr "" -#: library/ctypes.rst:2105 +#: library/ctypes.rst:2143 msgid "" "Raises an :ref:`auditing event ` ``ctypes.wstring_at`` with " -"arguments ``address``, ``size``." +"arguments ``ptr``, ``size``." msgstr "" -#: library/ctypes.rst:2111 +#: library/ctypes.rst:2149 msgid "Data types" msgstr "" -#: library/ctypes.rst:2116 +#: library/ctypes.rst:2154 msgid "" "This non-public class is the common base class of all ctypes data types. " "Among other things, all ctypes type instances contain a memory block that " -"hold C compatible data; the address of the memory block is returned by the :" -"func:`addressof` helper function. Another instance variable is exposed as :" -"attr:`_objects`; this contains other Python objects that need to be kept " +"hold C compatible data; the address of the memory block is returned by " +"the :func:`addressof` helper function. Another instance variable is exposed " +"as :attr:`_objects`; this contains other Python objects that need to be kept " "alive in case the memory block contains pointers." msgstr "" -#: library/ctypes.rst:2123 +#: library/ctypes.rst:2161 msgid "" "Common methods of ctypes data types, these are all class methods (to be " "exact, they are methods of the :term:`metaclass`):" msgstr "" -#: library/ctypes.rst:2128 +#: library/ctypes.rst:2166 msgid "" "This method returns a ctypes instance that shares the buffer of the *source* " "object. The *source* object must support the writeable buffer interface. " "The optional *offset* parameter specifies an offset into the source buffer " -"in bytes; the default is zero. If the source buffer is not large enough a :" -"exc:`ValueError` is raised." +"in bytes; the default is zero. If the source buffer is not large enough " +"a :exc:`ValueError` is raised." msgstr "" -#: library/ctypes.rst:2144 +#: library/ctypes.rst:2182 msgid "" "Raises an :ref:`auditing event ` ``ctypes.cdata/buffer`` with " "arguments ``pointer``, ``size``, ``offset``." msgstr "" -#: library/ctypes.rst:2138 +#: library/ctypes.rst:2176 msgid "" "This method creates a ctypes instance, copying the buffer from the *source* " "object buffer which must be readable. The optional *offset* parameter " @@ -2208,65 +3100,60 @@ msgid "" "If the source buffer is not large enough a :exc:`ValueError` is raised." msgstr "" -#: library/ctypes.rst:2148 +#: library/ctypes.rst:2186 msgid "" "This method returns a ctypes type instance using the memory specified by " "*address* which must be an integer." msgstr "" -#: library/ctypes.rst:2151 +#: library/ctypes.rst:2191 msgid "" -"Raises an :ref:`auditing event ` ``ctypes.cdata`` with argument " +"This method, and others that indirectly call this method, raises " +"an :ref:`auditing event ` ``ctypes.cdata`` with argument " "``address``." msgstr "" -#: library/ctypes.rst:2153 -msgid "" -"This method, and others that indirectly call this method, raises an :ref:" -"`auditing event ` ``ctypes.cdata`` with argument ``address``." -msgstr "" - -#: library/ctypes.rst:2159 +#: library/ctypes.rst:2197 msgid "" "This method adapts *obj* to a ctypes type. It is called with the actual " "object used in a foreign function call when the type is present in the " -"foreign function's :attr:`~_FuncPtr.argtypes` tuple; it must return an " +"foreign function's :attr:`~_CFuncPtr.argtypes` tuple; it must return an " "object that can be used as a function call parameter." msgstr "" -#: library/ctypes.rst:2164 +#: library/ctypes.rst:2202 msgid "" "All ctypes data types have a default implementation of this classmethod that " "normally returns *obj* if that is an instance of the type. Some types " "accept other objects as well." msgstr "" -#: library/ctypes.rst:2170 +#: library/ctypes.rst:2208 msgid "" "This method returns a ctypes type instance exported by a shared library. " "*name* is the name of the symbol that exports the data, *library* is the " "loaded shared library." msgstr "" -#: library/ctypes.rst:2174 +#: library/ctypes.rst:2212 msgid "Common instance variables of ctypes data types:" msgstr "" -#: library/ctypes.rst:2178 +#: library/ctypes.rst:2216 msgid "" "Sometimes ctypes data instances do not own the memory block they contain, " -"instead they share part of the memory block of a base object. The :attr:" -"`_b_base_` read-only member is the root ctypes object that owns the memory " -"block." +"instead they share part of the memory block of a base object. " +"The :attr:`_b_base_` read-only member is the root ctypes object that owns " +"the memory block." msgstr "" -#: library/ctypes.rst:2185 +#: library/ctypes.rst:2223 msgid "" "This read-only variable is true when the ctypes data instance has allocated " "the memory block itself, false otherwise." msgstr "" -#: library/ctypes.rst:2190 +#: library/ctypes.rst:2228 msgid "" "This member is either ``None`` or a dictionary containing Python objects " "that need to be kept alive so that the memory block contents is kept valid. " @@ -2274,20 +3161,20 @@ msgid "" "dictionary." msgstr "" -#: library/ctypes.rst:2203 +#: library/ctypes.rst:2241 msgid "" "This non-public class is the base class of all fundamental ctypes data " "types. It is mentioned here because it contains the common attributes of the " -"fundamental ctypes data types. :class:`_SimpleCData` is a subclass of :" -"class:`_CData`, so it inherits their methods and attributes. ctypes data " +"fundamental ctypes data types. :class:`_SimpleCData` is a subclass " +"of :class:`_CData`, so it inherits their methods and attributes. ctypes data " "types that are not and do not contain pointers can now be pickled." msgstr "" -#: library/ctypes.rst:2209 +#: library/ctypes.rst:2247 msgid "Instances have a single attribute:" msgstr "" -#: library/ctypes.rst:2213 +#: library/ctypes.rst:2251 msgid "" "This attribute contains the actual value of the instance. For integer and " "pointer types, it is an integer, for character types, it is a single " @@ -2295,7 +3182,7 @@ msgid "" "bytes object or string." msgstr "" -#: library/ctypes.rst:2218 +#: library/ctypes.rst:2256 msgid "" "When the ``value`` attribute is retrieved from a ctypes instance, usually a " "new object is returned each time. :mod:`ctypes` does *not* implement " @@ -2303,17 +3190,17 @@ msgid "" "true for all other ctypes object instances." msgstr "" -#: library/ctypes.rst:2224 +#: library/ctypes.rst:2262 msgid "" "Fundamental data types, when returned as foreign function call results, or, " "for example, by retrieving structure field members or array items, are " "transparently converted to native Python types. In other words, if a " -"foreign function has a :attr:`~_FuncPtr.restype` of :class:`c_char_p`, you " +"foreign function has a :attr:`~_CFuncPtr.restype` of :class:`c_char_p`, you " "will always receive a Python bytes object, *not* a :class:`c_char_p` " "instance." msgstr "" -#: library/ctypes.rst:2232 +#: library/ctypes.rst:2270 msgid "" "Subclasses of fundamental data types do *not* inherit this behavior. So, if " "a foreign functions :attr:`!restype` is a subclass of :class:`c_void_p`, you " @@ -2321,25 +3208,25 @@ msgid "" "you can get the value of the pointer by accessing the ``value`` attribute." msgstr "" -#: library/ctypes.rst:2237 +#: library/ctypes.rst:2275 msgid "These are the fundamental ctypes data types:" msgstr "" -#: library/ctypes.rst:2241 +#: library/ctypes.rst:2279 msgid "" "Represents the C :c:expr:`signed char` datatype, and interprets the value as " "small integer. The constructor accepts an optional integer initializer; no " "overflow checking is done." msgstr "" -#: library/ctypes.rst:2248 +#: library/ctypes.rst:2286 msgid "" "Represents the C :c:expr:`char` datatype, and interprets the value as a " "single character. The constructor accepts an optional string initializer, " "the length of the string must be exactly one character." msgstr "" -#: library/ctypes.rst:2255 +#: library/ctypes.rst:2293 msgid "" "Represents the C :c:expr:`char *` datatype when it points to a zero-" "terminated string. For a general character pointer that may also point to " @@ -2347,259 +3234,268 @@ msgid "" "integer address, or a bytes object." msgstr "" -#: library/ctypes.rst:2263 +#: library/ctypes.rst:2301 msgid "" "Represents the C :c:expr:`double` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: library/ctypes.rst:2269 +#: library/ctypes.rst:2307 msgid "" "Represents the C :c:expr:`long double` datatype. The constructor accepts an " "optional float initializer. On platforms where ``sizeof(long double) == " "sizeof(double)`` it is an alias to :class:`c_double`." msgstr "" -#: library/ctypes.rst:2275 +#: library/ctypes.rst:2313 msgid "" "Represents the C :c:expr:`float` datatype. The constructor accepts an " "optional float initializer." msgstr "" -#: library/ctypes.rst:2281 +#: library/ctypes.rst:2319 msgid "" "Represents the C :c:expr:`signed int` datatype. The constructor accepts an " "optional integer initializer; no overflow checking is done. On platforms " "where ``sizeof(int) == sizeof(long)`` it is an alias to :class:`c_long`." msgstr "" -#: library/ctypes.rst:2288 +#: library/ctypes.rst:2326 msgid "" -"Represents the C 8-bit :c:expr:`signed int` datatype. Usually an alias for :" -"class:`c_byte`." +"Represents the C 8-bit :c:expr:`signed int` datatype. Usually an alias " +"for :class:`c_byte`." msgstr "" -#: library/ctypes.rst:2294 +#: library/ctypes.rst:2332 msgid "" "Represents the C 16-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_short`." msgstr "" -#: library/ctypes.rst:2300 +#: library/ctypes.rst:2338 msgid "" "Represents the C 32-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_int`." msgstr "" -#: library/ctypes.rst:2306 +#: library/ctypes.rst:2344 msgid "" "Represents the C 64-bit :c:expr:`signed int` datatype. Usually an alias " "for :class:`c_longlong`." msgstr "" -#: library/ctypes.rst:2312 +#: library/ctypes.rst:2350 msgid "" "Represents the C :c:expr:`signed long` datatype. The constructor accepts an " "optional integer initializer; no overflow checking is done." msgstr "" -#: library/ctypes.rst:2318 +#: library/ctypes.rst:2356 msgid "" "Represents the C :c:expr:`signed long long` datatype. The constructor " "accepts an optional integer initializer; no overflow checking is done." msgstr "" -#: library/ctypes.rst:2324 +#: library/ctypes.rst:2362 msgid "" "Represents the C :c:expr:`signed short` datatype. The constructor accepts " "an optional integer initializer; no overflow checking is done." msgstr "" -#: library/ctypes.rst:2330 +#: library/ctypes.rst:2368 msgid "Represents the C :c:type:`size_t` datatype." msgstr "" -#: library/ctypes.rst:2335 +#: library/ctypes.rst:2373 msgid "Represents the C :c:type:`ssize_t` datatype." msgstr "" -#: library/ctypes.rst:2342 +#: library/ctypes.rst:2380 msgid "Represents the C :c:type:`time_t` datatype." msgstr "" -#: library/ctypes.rst:2349 +#: library/ctypes.rst:2387 msgid "" "Represents the C :c:expr:`unsigned char` datatype, it interprets the value " "as small integer. The constructor accepts an optional integer initializer; " "no overflow checking is done." msgstr "" -#: library/ctypes.rst:2356 +#: library/ctypes.rst:2394 msgid "" "Represents the C :c:expr:`unsigned int` datatype. The constructor accepts " "an optional integer initializer; no overflow checking is done. On platforms " "where ``sizeof(int) == sizeof(long)`` it is an alias for :class:`c_ulong`." msgstr "" -#: library/ctypes.rst:2363 +#: library/ctypes.rst:2401 msgid "" "Represents the C 8-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ubyte`." msgstr "" -#: library/ctypes.rst:2369 +#: library/ctypes.rst:2407 msgid "" "Represents the C 16-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ushort`." msgstr "" -#: library/ctypes.rst:2375 +#: library/ctypes.rst:2413 msgid "" "Represents the C 32-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_uint`." msgstr "" -#: library/ctypes.rst:2381 +#: library/ctypes.rst:2419 msgid "" "Represents the C 64-bit :c:expr:`unsigned int` datatype. Usually an alias " "for :class:`c_ulonglong`." msgstr "" -#: library/ctypes.rst:2387 +#: library/ctypes.rst:2425 msgid "" "Represents the C :c:expr:`unsigned long` datatype. The constructor accepts " "an optional integer initializer; no overflow checking is done." msgstr "" -#: library/ctypes.rst:2393 +#: library/ctypes.rst:2431 msgid "" "Represents the C :c:expr:`unsigned long long` datatype. The constructor " "accepts an optional integer initializer; no overflow checking is done." msgstr "" -#: library/ctypes.rst:2399 +#: library/ctypes.rst:2437 msgid "" "Represents the C :c:expr:`unsigned short` datatype. The constructor accepts " "an optional integer initializer; no overflow checking is done." msgstr "" -#: library/ctypes.rst:2405 +#: library/ctypes.rst:2443 msgid "" "Represents the C :c:expr:`void *` type. The value is represented as " "integer. The constructor accepts an optional integer initializer." msgstr "" -#: library/ctypes.rst:2411 +#: library/ctypes.rst:2449 msgid "" "Represents the C :c:type:`wchar_t` datatype, and interprets the value as a " "single character unicode string. The constructor accepts an optional string " "initializer, the length of the string must be exactly one character." msgstr "" -#: library/ctypes.rst:2418 +#: library/ctypes.rst:2456 msgid "" "Represents the C :c:expr:`wchar_t *` datatype, which must be a pointer to a " "zero-terminated wide character string. The constructor accepts an integer " "address, or a string." msgstr "" -#: library/ctypes.rst:2425 +#: library/ctypes.rst:2463 msgid "" "Represent the C :c:expr:`bool` datatype (more accurately, :c:expr:`_Bool` " "from C99). Its value can be ``True`` or ``False``, and the constructor " "accepts any object that has a truth value." msgstr "" -#: library/ctypes.rst:2432 +#: library/ctypes.rst:2470 msgid "" -"Windows only: Represents a :c:type:`!HRESULT` value, which contains success " -"or error information for a function or method call." +"Represents a :c:type:`!HRESULT` value, which contains success or error " +"information for a function or method call." msgstr "" -#: library/ctypes.rst:2438 +#: library/ctypes.rst:2478 msgid "" "Represents the C :c:expr:`PyObject *` datatype. Calling this without an " "argument creates a ``NULL`` :c:expr:`PyObject *` pointer." msgstr "" -#: library/ctypes.rst:2441 +#: library/ctypes.rst:2481 msgid "" "The :mod:`!ctypes.wintypes` module provides quite some other Windows " -"specific data types, for example :c:type:`!HWND`, :c:type:`!WPARAM`, or :c:" -"type:`!DWORD`. Some useful structures like :c:type:`!MSG` or :c:type:`!RECT` " -"are also defined." +"specific data types, for example :c:type:`!HWND`, :c:type:`!WPARAM`, " +"or :c:type:`!DWORD`. Some useful structures like :c:type:`!MSG` or :c:type:`!" +"RECT` are also defined." msgstr "" -#: library/ctypes.rst:2449 +#: library/ctypes.rst:2489 msgid "Structured data types" msgstr "" -#: library/ctypes.rst:2454 +#: library/ctypes.rst:2494 msgid "Abstract base class for unions in native byte order." msgstr "" -#: library/ctypes.rst:2459 +#: library/ctypes.rst:2499 msgid "Abstract base class for unions in *big endian* byte order." msgstr "" -#: library/ctypes.rst:2465 +#: library/ctypes.rst:2505 msgid "Abstract base class for unions in *little endian* byte order." msgstr "" -#: library/ctypes.rst:2471 +#: library/ctypes.rst:2511 msgid "Abstract base class for structures in *big endian* byte order." msgstr "" -#: library/ctypes.rst:2476 +#: library/ctypes.rst:2516 msgid "Abstract base class for structures in *little endian* byte order." msgstr "" -#: library/ctypes.rst:2478 +#: library/ctypes.rst:2518 msgid "" "Structures and unions with non-native byte order cannot contain pointer type " "fields, or any other data types containing pointer type fields." msgstr "" -#: library/ctypes.rst:2484 +#: library/ctypes.rst:2524 msgid "Abstract base class for structures in *native* byte order." msgstr "" -#: library/ctypes.rst:2486 +#: library/ctypes.rst:2526 msgid "" "Concrete structure and union types must be created by subclassing one of " -"these types, and at least define a :attr:`_fields_` class variable. :mod:" -"`ctypes` will create :term:`descriptor`\\s which allow reading and writing " -"the fields by direct attribute accesses. These are the" +"these types, and at least define a :attr:`_fields_` class " +"variable. :mod:`ctypes` will create :term:`descriptor`\\s which allow " +"reading and writing the fields by direct attribute accesses. These are the" msgstr "" -#: library/ctypes.rst:2494 +#: library/ctypes.rst:2534 msgid "" "A sequence defining the structure fields. The items must be 2-tuples or 3-" "tuples. The first item is the name of the field, the second item specifies " "the type of the field; it can be any ctypes data type." msgstr "" -#: library/ctypes.rst:2498 +#: library/ctypes.rst:2538 msgid "" "For integer type fields like :class:`c_int`, a third optional item can be " "given. It must be a small positive integer defining the bit width of the " "field." msgstr "" -#: library/ctypes.rst:2502 +#: library/ctypes.rst:2542 msgid "" "Field names must be unique within one structure or union. This is not " "checked, only one field can be accessed when names are repeated." msgstr "" -#: library/ctypes.rst:2505 +#: library/ctypes.rst:2545 msgid "" "It is possible to define the :attr:`_fields_` class variable *after* the " "class statement that defines the Structure subclass, this allows creating " "data types that directly or indirectly reference themselves::" msgstr "" -#: library/ctypes.rst:2515 +#: library/ctypes.rst:2549 +msgid "" +"class List(Structure):\n" +" pass\n" +"List._fields_ = [(\"pnext\", POINTER(List)),\n" +" ...\n" +" ]" +msgstr "" + +#: library/ctypes.rst:2555 msgid "" "The :attr:`_fields_` class variable must, however, be defined before the " "type is first used (an instance is created, :func:`sizeof` is called on it, " @@ -2607,41 +3503,54 @@ msgid "" "raise an AttributeError." msgstr "" -#: library/ctypes.rst:2520 +#: library/ctypes.rst:2560 msgid "" "It is possible to define sub-subclasses of structure types, they inherit the " "fields of the base class plus the :attr:`_fields_` defined in the sub-" "subclass, if any." msgstr "" -#: library/ctypes.rst:2527 +#: library/ctypes.rst:2567 msgid "" "An optional small integer that allows overriding the alignment of structure " -"fields in the instance. :attr:`_pack_` must already be defined when :attr:" -"`_fields_` is assigned, otherwise it will have no effect. Setting this " -"attribute to 0 is the same as not setting it at all." +"fields in the instance. :attr:`_pack_` must already be defined " +"when :attr:`_fields_` is assigned, otherwise it will have no effect. Setting " +"this attribute to 0 is the same as not setting it at all." msgstr "" -#: library/ctypes.rst:2535 +#: library/ctypes.rst:2575 msgid "" -"An optional sequence that lists the names of unnamed (anonymous) fields. :" -"attr:`_anonymous_` must be already defined when :attr:`_fields_` is " +"An optional sequence that lists the names of unnamed (anonymous) " +"fields. :attr:`_anonymous_` must be already defined when :attr:`_fields_` is " "assigned, otherwise it will have no effect." msgstr "" -#: library/ctypes.rst:2539 +#: library/ctypes.rst:2579 msgid "" -"The fields listed in this variable must be structure or union type fields. :" -"mod:`ctypes` will create descriptors in the structure type that allows " -"accessing the nested fields directly, without the need to create the " +"The fields listed in this variable must be structure or union type " +"fields. :mod:`ctypes` will create descriptors in the structure type that " +"allows accessing the nested fields directly, without the need to create the " "structure or union field." msgstr "" -#: library/ctypes.rst:2544 +#: library/ctypes.rst:2584 msgid "Here is an example type (Windows)::" msgstr "" -#: library/ctypes.rst:2557 +#: library/ctypes.rst:2586 +msgid "" +"class _U(Union):\n" +" _fields_ = [(\"lptdesc\", POINTER(TYPEDESC)),\n" +" (\"lpadesc\", POINTER(ARRAYDESC)),\n" +" (\"hreftype\", HREFTYPE)]\n" +"\n" +"class TYPEDESC(Structure):\n" +" _anonymous_ = (\"u\",)\n" +" _fields_ = [(\"u\", _U),\n" +" (\"vt\", VARTYPE)]" +msgstr "" + +#: library/ctypes.rst:2597 msgid "" "The ``TYPEDESC`` structure describes a COM data type, the ``vt`` field " "specifies which one of the union fields is valid. Since the ``u`` field is " @@ -2651,15 +3560,23 @@ msgid "" "temporary union instance::" msgstr "" -#: library/ctypes.rst:2569 +#: library/ctypes.rst:2604 +msgid "" +"td = TYPEDESC()\n" +"td.vt = VT_PTR\n" +"td.lptdesc = POINTER(some_type)\n" +"td.u.lptdesc = POINTER(some_type)" +msgstr "" + +#: library/ctypes.rst:2609 msgid "" "It is possible to define sub-subclasses of structures, they inherit the " -"fields of the base class. If the subclass definition has a separate :attr:" -"`_fields_` variable, the fields specified in this are appended to the fields " -"of the base class." +"fields of the base class. If the subclass definition has a " +"separate :attr:`_fields_` variable, the fields specified in this are " +"appended to the fields of the base class." msgstr "" -#: library/ctypes.rst:2574 +#: library/ctypes.rst:2614 msgid "" "Structure and union constructors accept both positional and keyword " "arguments. Positional arguments are used to initialize member fields in the " @@ -2669,65 +3586,65 @@ msgid "" "names not present in :attr:`_fields_`." msgstr "" -#: library/ctypes.rst:2585 +#: library/ctypes.rst:2625 msgid "Arrays and pointers" msgstr "" -#: library/ctypes.rst:2589 +#: library/ctypes.rst:2629 msgid "Abstract base class for arrays." msgstr "" -#: library/ctypes.rst:2591 +#: library/ctypes.rst:2631 msgid "" -"The recommended way to create concrete array types is by multiplying any :" -"mod:`ctypes` data type with a non-negative integer. Alternatively, you can " -"subclass this type and define :attr:`_length_` and :attr:`_type_` class " +"The recommended way to create concrete array types is by multiplying " +"any :mod:`ctypes` data type with a non-negative integer. Alternatively, you " +"can subclass this type and define :attr:`_length_` and :attr:`_type_` class " "variables. Array elements can be read and written using standard subscript " "and slice accesses; for slice reads, the resulting object is *not* itself " "an :class:`Array`." msgstr "" -#: library/ctypes.rst:2601 +#: library/ctypes.rst:2641 msgid "" "A positive integer specifying the number of elements in the array. Out-of-" -"range subscripts result in an :exc:`IndexError`. Will be returned by :func:" -"`len`." +"range subscripts result in an :exc:`IndexError`. Will be returned " +"by :func:`len`." msgstr "" -#: library/ctypes.rst:2608 +#: library/ctypes.rst:2648 msgid "Specifies the type of each element in the array." msgstr "" -#: library/ctypes.rst:2611 +#: library/ctypes.rst:2651 msgid "" "Array subclass constructors accept positional arguments, used to initialize " "the elements in order." msgstr "" -#: library/ctypes.rst:2617 +#: library/ctypes.rst:2657 msgid "Private, abstract base class for pointers." msgstr "" -#: library/ctypes.rst:2619 +#: library/ctypes.rst:2659 msgid "" "Concrete pointer types are created by calling :func:`POINTER` with the type " "that will be pointed to; this is done automatically by :func:`pointer`." msgstr "" -#: library/ctypes.rst:2623 +#: library/ctypes.rst:2663 msgid "" "If a pointer points to an array, its elements can be read and written using " -"standard subscript and slice accesses. Pointer objects have no size, so :" -"func:`len` will raise :exc:`TypeError`. Negative subscripts will read from " -"the memory *before* the pointer (as in C), and out-of-range subscripts will " -"probably crash with an access violation (if you're lucky)." +"standard subscript and slice accesses. Pointer objects have no size, " +"so :func:`len` will raise :exc:`TypeError`. Negative subscripts will read " +"from the memory *before* the pointer (as in C), and out-of-range subscripts " +"will probably crash with an access violation (if you're lucky)." msgstr "" -#: library/ctypes.rst:2633 +#: library/ctypes.rst:2673 msgid "Specifies the type pointed to." msgstr "" -#: library/ctypes.rst:2637 +#: library/ctypes.rst:2677 msgid "" "Returns the object to which to pointer points. Assigning to this attribute " "changes the pointer to point to the assigned object." diff --git a/library/curses.ascii.po b/library/curses.ascii.po index 0b8b5f8a..58aa9d14 100644 --- a/library/curses.ascii.po +++ b/library/curses.ascii.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/curses.ascii.rst:2 -msgid ":mod:`curses.ascii` --- Utilities for ASCII characters" +msgid ":mod:`!curses.ascii` --- Utilities for ASCII characters" msgstr "" #: library/curses.ascii.rst:10 @@ -253,8 +254,8 @@ msgstr "" #: library/curses.ascii.rst:168 msgid "" -"Checks for an ASCII hexadecimal digit. This is equivalent to ``c in string." -"hexdigits``." +"Checks for an ASCII hexadecimal digit. This is equivalent to ``c in " +"string.hexdigits``." msgstr "" #: library/curses.ascii.rst:174 @@ -268,8 +269,8 @@ msgstr "" #: library/curses.ascii.rst:181 msgid "" "These functions accept either integers or single-character strings; when the " -"argument is a string, it is first converted using the built-in function :" -"func:`ord`." +"argument is a string, it is first converted using the built-in " +"function :func:`ord`." msgstr "" #: library/curses.ascii.rst:184 diff --git a/library/curses.panel.po b/library/curses.panel.po index 11c4acfb..72921606 100644 --- a/library/curses.panel.po +++ b/library/curses.panel.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/curses.panel.rst:2 -msgid ":mod:`curses.panel` --- A panel stack extension for curses" +msgid ":mod:`!curses.panel` --- A panel stack extension for curses" msgstr "" #: library/curses.panel.rst:11 diff --git a/library/curses.po b/library/curses.po index 2e17e551..512db972 100644 --- a/library/curses.po +++ b/library/curses.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/curses.rst:2 -msgid ":mod:`curses` --- Terminal handling for character-cell displays" +msgid ":mod:`!curses` --- Terminal handling for character-cell displays" msgstr "" #: library/curses.rst:12 @@ -50,7 +51,7 @@ msgid "" "as a Unicode string or a byte string." msgstr "" -#: library/curses.rst:35 +#: library/curses.rst:34 msgid "Module :mod:`curses.ascii`" msgstr "" @@ -60,7 +61,7 @@ msgid "" "settings." msgstr "" -#: library/curses.rst:38 +#: library/curses.rst:37 msgid "Module :mod:`curses.panel`" msgstr "" @@ -68,7 +69,7 @@ msgstr "" msgid "A panel stack extension that adds depth to curses windows." msgstr "" -#: library/curses.rst:41 +#: library/curses.rst:40 msgid "Module :mod:`curses.textpad`" msgstr "" @@ -78,7 +79,7 @@ msgid "" "bindings." msgstr "" -#: library/curses.rst:44 +#: library/curses.rst:43 msgid ":ref:`curses-howto`" msgstr "" @@ -152,9 +153,9 @@ msgstr "" msgid "" "Return the attribute value for displaying text in the specified color pair. " "Only the first 256 color pairs are supported. This attribute value can be " -"combined with :const:`A_STANDOUT`, :const:`A_REVERSE`, and the other :const:" -"`!A_\\*` attributes. :func:`pair_number` is the counterpart to this " -"function." +"combined with :const:`A_STANDOUT`, :const:`A_REVERSE`, and the " +"other :const:`!A_\\*` attributes. :func:`pair_number` is the counterpart to " +"this function." msgstr "" #: library/curses.rst:116 @@ -170,16 +171,16 @@ msgstr "" msgid "" "Save the current terminal mode as the \"program\" mode, the mode when the " "running program is using curses. (Its counterpart is the \"shell\" mode, " -"for when the program is not in curses.) Subsequent calls to :func:" -"`reset_prog_mode` will restore this mode." +"for when the program is not in curses.) Subsequent calls " +"to :func:`reset_prog_mode` will restore this mode." msgstr "" #: library/curses.rst:133 msgid "" "Save the current terminal mode as the \"shell\" mode, the mode when the " "running program is not using curses. (Its counterpart is the \"program\" " -"mode, when the program is using curses capabilities.) Subsequent calls to :" -"func:`reset_shell_mode` will restore this mode." +"mode, when the program is using curses capabilities.) Subsequent calls " +"to :func:`reset_shell_mode` will restore this mode." msgstr "" #: library/curses.rst:141 @@ -201,8 +202,8 @@ msgid "" "a window. The normal :meth:`~window.refresh` call is simply :meth:`!" "noutrefresh` followed by :func:`!doupdate`; if you have to update multiple " "windows, you can speed performance and perhaps reduce screen flicker by " -"issuing :meth:`!noutrefresh` calls on all windows, followed by a single :" -"func:`!doupdate`." +"issuing :meth:`!noutrefresh` calls on all windows, followed by a " +"single :func:`!doupdate`." msgstr "" #: library/curses.rst:161 @@ -255,10 +256,8 @@ msgid "" "coordinates. (*z* is currently unused.) *bstate* is an integer value whose " "bits will be set to indicate the type of event, and will be the bitwise OR " "of one or more of the following constants, where *n* is the button number " -"from 1 to 5: :const:`BUTTONn_PRESSED`, :const:`BUTTONn_RELEASED`, :const:" -"`BUTTONn_CLICKED`, :const:`BUTTONn_DOUBLE_CLICKED`, :const:" -"`BUTTONn_TRIPLE_CLICKED`, :const:`BUTTON_SHIFT`, :const:`BUTTON_CTRL`, :" -"const:`BUTTON_ALT`." +"from 1 to " +"5: :const:`BUTTONn_PRESSED`, :const:`BUTTONn_RELEASED`, :const:`BUTTONn_CLICKED`, :const:`BUTTONn_DOUBLE_CLICKED`, :const:`BUTTONn_TRIPLE_CLICKED`, :const:`BUTTON_SHIFT`, :const:`BUTTON_CTRL`, :const:`BUTTON_ALT`." msgstr "" #: library/curses.rst:1774 @@ -276,9 +275,9 @@ msgstr "" #: library/curses.rst:226 msgid "" -"Read window related data stored in the file by an earlier :func:`window." -"putwin` call. The routine then creates and initializes a new window using " -"that data, returning the new window object." +"Read window related data stored in the file by an " +"earlier :func:`window.putwin` call. The routine then creates and initializes " +"a new window using that data, returning the new window object." msgstr "" #: library/curses.rst:233 @@ -441,14 +440,14 @@ msgid "" "and is not necessarily associated with a particular part of the screen. " "Pads can be used when a large window is needed, and only a part of the " "window will be on the screen at one time. Automatic refreshes of pads (such " -"as from scrolling or echoing of input) do not occur. The :meth:`~window." -"refresh` and :meth:`~window.noutrefresh` methods of a pad require 6 " -"arguments to specify the part of the pad to be displayed and the location on " -"the screen to be used for the display. The arguments are *pminrow*, " -"*pmincol*, *sminrow*, *smincol*, *smaxrow*, *smaxcol*; the *p* arguments " -"refer to the upper left corner of the pad region to be displayed and the *s* " -"arguments define a clipping box on the screen within which the pad region is " -"to be displayed." +"as from scrolling or echoing of input) do not occur. " +"The :meth:`~window.refresh` and :meth:`~window.noutrefresh` methods of a pad " +"require 6 arguments to specify the part of the pad to be displayed and the " +"location on the screen to be used for the display. The arguments are " +"*pminrow*, *pmincol*, *sminrow*, *smincol*, *smaxrow*, *smaxcol*; the *p* " +"arguments refer to the upper left corner of the pad region to be displayed " +"and the *s* arguments define a clipping box on the screen within which the " +"pad region is to be displayed." msgstr "" #: library/curses.rst:394 @@ -511,15 +510,15 @@ msgstr "" #: library/curses.rst:449 msgid "" -"Return the number of the color-pair set by the attribute value *attr*. :func:" -"`color_pair` is the counterpart to this function." +"Return the number of the color-pair set by the attribute value " +"*attr*. :func:`color_pair` is the counterpart to this function." msgstr "" #: library/curses.rst:455 msgid "" "Equivalent to ``tputs(str, 1, putchar)``; emit the value of a specified " -"terminfo capability for the current terminal. Note that the output of :func:" -"`putp` always goes to standard output." +"terminfo capability for the current terminal. Note that the output " +"of :func:`putp` always goes to standard output." msgstr "" #: library/curses.rst:462 @@ -538,20 +537,20 @@ msgstr "" #: library/curses.rst:476 msgid "" -"Restore the terminal to \"program\" mode, as previously saved by :func:" -"`def_prog_mode`." +"Restore the terminal to \"program\" mode, as previously saved " +"by :func:`def_prog_mode`." msgstr "" #: library/curses.rst:482 msgid "" -"Restore the terminal to \"shell\" mode, as previously saved by :func:" -"`def_shell_mode`." +"Restore the terminal to \"shell\" mode, as previously saved " +"by :func:`def_shell_mode`." msgstr "" #: library/curses.rst:488 msgid "" -"Restore the state of the terminal modes to what it was at the last call to :" -"func:`savetty`." +"Restore the state of the terminal modes to what it was at the last call " +"to :func:`savetty`." msgstr "" #: library/curses.rst:494 @@ -573,8 +572,8 @@ msgstr "" #: library/curses.rst:511 msgid "" -"Save the current state of the terminal modes in a buffer, usable by :func:" -"`resetty`." +"Save the current state of the terminal modes in a buffer, usable " +"by :func:`resetty`." msgstr "" #: library/curses.rst:516 @@ -623,11 +622,11 @@ msgstr "" #: library/curses.rst:562 msgid "" ":func:`start_color` initializes eight basic colors (black, red, green, " -"yellow, blue, magenta, cyan, and white), and two global variables in the :" -"mod:`curses` module, :const:`COLORS` and :const:`COLOR_PAIRS`, containing " -"the maximum number of colors and color-pairs the terminal can support. It " -"also restores the colors on the terminal to the values they had when the " -"terminal was just turned on." +"yellow, blue, magenta, cyan, and white), and two global variables in " +"the :mod:`curses` module, :const:`COLORS` and :const:`COLOR_PAIRS`, " +"containing the maximum number of colors and color-pairs the terminal can " +"support. It also restores the colors on the terminal to the values they had " +"when the terminal was just turned on." msgstr "" #: library/curses.rst:571 @@ -1040,8 +1039,8 @@ msgstr "" #: library/curses.rst:893 msgid "" -"Add character *ch* with attribute *attr*, and immediately call :meth:" -"`refresh` on the window." +"Add character *ch* with attribute *attr*, and immediately " +"call :meth:`refresh` on the window." msgstr "" #: library/curses.rst:899 @@ -1069,7 +1068,7 @@ msgid "Clear the window." msgstr "" #: library/curses.rst:925 -msgid "Return a tuple ``(y, x)`` of co-ordinates of upper-left corner." +msgid "Return a tuple ``(y, x)`` of coordinates of upper-left corner." msgstr "" #: library/curses.rst:930 @@ -1205,15 +1204,15 @@ msgstr "" #: library/curses.rst:1071 msgid "" -"Return ``True`` if the specified line was modified since the last call to :" -"meth:`refresh`; otherwise return ``False``. Raise a :exc:`curses.error` " +"Return ``True`` if the specified line was modified since the last call " +"to :meth:`refresh`; otherwise return ``False``. Raise a :exc:`curses.error` " "exception if *line* is not valid for the given window." msgstr "" #: library/curses.rst:1078 msgid "" -"Return ``True`` if the specified window was modified since the last call to :" -"meth:`refresh`; otherwise return ``False``." +"Return ``True`` if the specified window was modified since the last call " +"to :meth:`refresh`; otherwise return ``False``." msgstr "" #: library/curses.rst:1084 @@ -1282,8 +1281,8 @@ msgstr "" #: library/curses.rst:1142 msgid "" -"To get fine-grained control over the copied region, the second form of :meth:" -"`overlay` can be used. *sminrow* and *smincol* are the upper-left " +"To get fine-grained control over the copied region, the second form " +"of :meth:`overlay` can be used. *sminrow* and *smincol* are the upper-left " "coordinates of the source window, and the other variables mark a rectangle " "in the destination window." msgstr "" @@ -1298,8 +1297,8 @@ msgstr "" #: library/curses.rst:1155 msgid "" -"To get fine-grained control over the copied region, the second form of :meth:" -"`overwrite` can be used. *sminrow* and *smincol* are the upper-left " +"To get fine-grained control over the copied region, the second form " +"of :meth:`overwrite` can be used. *sminrow* and *smincol* are the upper-left " "coordinates of the source window, the other variables mark a rectangle in " "the destination window." msgstr "" @@ -1318,8 +1317,8 @@ msgstr "" #: library/curses.rst:1175 msgid "" -"Touch the entire window, causing it to be completely redrawn on the next :" -"meth:`refresh` call." +"Touch the entire window, causing it to be completely redrawn on the " +"next :meth:`refresh` call." msgstr "" #: library/curses.rst:1181 @@ -1417,9 +1416,9 @@ msgid "" "Set blocking or non-blocking read behavior for the window. If *delay* is " "negative, blocking read is used (which will wait indefinitely for input). " "If *delay* is zero, then non-blocking read is used, and :meth:`getch` will " -"return ``-1`` if no input is waiting. If *delay* is positive, then :meth:" -"`getch` will block for *delay* milliseconds, and return ``-1`` if there is " -"still no input at the end of that time." +"return ``-1`` if no input is waiting. If *delay* is positive, " +"then :meth:`getch` will block for *delay* milliseconds, and return ``-1`` if " +"there is still no input at the end of that time." msgstr "" #: library/curses.rst:1284 @@ -1438,8 +1437,8 @@ msgstr "" #: library/curses.rst:1297 msgid "" -"Mark all lines in the window as unchanged since the last call to :meth:" -"`refresh`." +"Mark all lines in the window as unchanged since the last call " +"to :meth:`refresh`." msgstr "" #: library/curses.rst:1304 @@ -1458,8 +1457,8 @@ msgstr "" #: library/curses.rst:1316 msgid "" -"Some curses routines that return an integer, such as :meth:`~window." -"getch`, return :const:`ERR` upon failure." +"Some curses routines that return an integer, such " +"as :meth:`~window.getch`, return :const:`ERR` upon failure." msgstr "" #: library/curses.rst:1322 @@ -1499,15 +1498,15 @@ msgstr "" #: library/curses.rst:1355 msgid "" "The width of the screen, i.e., the number of columns. It is defined only " -"after the call to :func:`initscr`. Updated by :func:`update_lines_cols`, :" -"func:`resizeterm` and :func:`resize_term`." +"after the call to :func:`initscr`. Updated " +"by :func:`update_lines_cols`, :func:`resizeterm` and :func:`resize_term`." msgstr "" #: library/curses.rst:1362 msgid "" "The height of the screen, i.e., the number of lines. It is defined only " -"after the call to :func:`initscr`. Updated by :func:`update_lines_cols`, :" -"func:`resizeterm` and :func:`resize_term`." +"after the call to :func:`initscr`. Updated " +"by :func:`update_lines_cols`, :func:`resizeterm` and :func:`resize_term`." msgstr "" #: library/curses.rst:1368 @@ -2011,13 +2010,14 @@ msgstr "" #: library/curses.rst:1627 msgid "" "On VT100s and their software emulations, such as X terminal emulators, there " -"are normally at least four function keys (:const:`KEY_F1 `, :const:" -"`KEY_F2 `, :const:`KEY_F3 `, :const:`KEY_F4 `) " -"available, and the arrow keys mapped to :const:`KEY_UP`, :const:`KEY_DOWN`, :" -"const:`KEY_LEFT` and :const:`KEY_RIGHT` in the obvious way. If your machine " -"has a PC keyboard, it is safe to expect arrow keys and twelve function keys " -"(older PC keyboards may have only ten function keys); also, the following " -"keypad mappings are standard:" +"are normally at least four function keys (:const:`KEY_F1 " +"`, :const:`KEY_F2 `, :const:`KEY_F3 " +"`, :const:`KEY_F4 `) available, and the arrow keys mapped " +"to :const:`KEY_UP`, :const:`KEY_DOWN`, :const:`KEY_LEFT` " +"and :const:`KEY_RIGHT` in the obvious way. If your machine has a PC " +"keyboard, it is safe to expect arrow keys and twelve function keys (older PC " +"keyboards may have only ten function keys); also, the following keypad " +"mappings are standard:" msgstr "" #: library/curses.rst:1636 @@ -2381,11 +2381,11 @@ msgstr "" #: library/curses.rst:1841 msgid "" -"Return a textbox widget object. The *win* argument should be a curses :ref:" -"`window ` object in which the textbox is to be " -"contained. The edit cursor of the textbox is initially located at the upper " -"left hand corner of the containing window, with coordinates ``(0, 0)``. The " -"instance's :attr:`stripspaces` flag is initially on." +"Return a textbox widget object. The *win* argument should be a " +"curses :ref:`window ` object in which the textbox is " +"to be contained. The edit cursor of the textbox is initially located at the " +"upper left hand corner of the containing window, with coordinates ``(0, " +"0)``. The instance's :attr:`stripspaces` flag is initially on." msgstr "" #: library/curses.rst:1847 @@ -2399,8 +2399,8 @@ msgid "" "*validator* is supplied, it must be a function. It will be called for each " "keystroke entered with the keystroke as a parameter; command dispatch is " "done on the result. This method returns the window contents as a string; " -"whether blanks in the window are included is affected by the :attr:" -"`stripspaces` attribute." +"whether blanks in the window are included is affected by " +"the :attr:`stripspaces` attribute." msgstr "" #: library/curses.rst:1863 diff --git a/library/custominterp.po b/library/custominterp.po index 12e32bb1..27794893 100644 --- a/library/custominterp.po +++ b/library/custominterp.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/dataclasses.po b/library/dataclasses.po index 10755897..67dc1a97 100644 --- a/library/dataclasses.po +++ b/library/dataclasses.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/dataclasses.rst:2 -msgid ":mod:`dataclasses` --- Data Classes" +msgid ":mod:`!dataclasses` --- Data Classes" msgstr "" #: library/dataclasses.rst:10 @@ -27,26 +28,49 @@ msgstr "" #: library/dataclasses.rst:14 msgid "" "This module provides a decorator and functions for automatically adding " -"generated :term:`special method`\\s such as :meth:`~object.__init__` and :" -"meth:`~object.__repr__` to user-defined classes. It was originally " -"described in :pep:`557`." +"generated :term:`special methods ` such " +"as :meth:`~object.__init__` and :meth:`~object.__repr__` to user-defined " +"classes. It was originally described in :pep:`557`." msgstr "" #: library/dataclasses.rst:19 msgid "" -"The member variables to use in these generated methods are defined using :" -"pep:`526` type annotations. For example, this code::" +"The member variables to use in these generated methods are defined " +"using :pep:`526` type annotations. For example, this code::" +msgstr "" + +#: library/dataclasses.rst:22 +msgid "" +"from dataclasses import dataclass\n" +"\n" +"@dataclass\n" +"class InventoryItem:\n" +" \"\"\"Class for keeping track of an item in inventory.\"\"\"\n" +" name: str\n" +" unit_price: float\n" +" quantity_on_hand: int = 0\n" +"\n" +" def total_cost(self) -> float:\n" +" return self.unit_price * self.quantity_on_hand" msgstr "" #: library/dataclasses.rst:34 +msgid "will add, among other things, a :meth:`!__init__` that looks like::" +msgstr "" + +#: library/dataclasses.rst:36 msgid "" -"will add, among other things, a :meth:`~object.__init__` that looks like::" +"def __init__(self, name: str, unit_price: float, quantity_on_hand: int = " +"0):\n" +" self.name = name\n" +" self.unit_price = unit_price\n" +" self.quantity_on_hand = quantity_on_hand" msgstr "" #: library/dataclasses.rst:41 msgid "" "Note that this method is automatically added to the class: it is not " -"directly specified in the ``InventoryItem`` definition shown above." +"directly specified in the :class:`!InventoryItem` definition shown above." msgstr "" #: library/dataclasses.rst:47 @@ -55,16 +79,17 @@ msgstr "" #: library/dataclasses.rst:51 msgid "" -"This function is a :term:`decorator` that is used to add generated :term:" -"`special method`\\s to classes, as described below." +"This function is a :term:`decorator` that is used to add " +"generated :term:`special methods ` to classes, as described " +"below." msgstr "" #: library/dataclasses.rst:54 msgid "" -"The :func:`dataclass` decorator examines the class to find ``field``\\s. A " +"The ``@dataclass`` decorator examines the class to find ``field``\\s. A " "``field`` is defined as a class variable that has a :term:`type annotation " -"`. With two exceptions described below, nothing in :" -"func:`dataclass` examines the type specified in the variable annotation." +"`. With two exceptions described below, nothing in " +"``@dataclass`` examines the type specified in the variable annotation." msgstr "" #: library/dataclasses.rst:60 @@ -75,7 +100,7 @@ msgstr "" #: library/dataclasses.rst:63 msgid "" -"The :func:`dataclass` decorator will add various \"dunder\" methods to the " +"The ``@dataclass`` decorator will add various \"dunder\" methods to the " "class, described below. If any of the added methods already exist in the " "class, the behavior depends on the parameter, as documented below. The " "decorator returns the same class that it is called on; no new class is " @@ -84,30 +109,46 @@ msgstr "" #: library/dataclasses.rst:69 msgid "" -"If :func:`dataclass` is used just as a simple decorator with no parameters, " -"it acts as if it has the default values documented in this signature. That " -"is, these three uses of :func:`dataclass` are equivalent::" +"If ``@dataclass`` is used just as a simple decorator with no parameters, it " +"acts as if it has the default values documented in this signature. That is, " +"these three uses of ``@dataclass`` are equivalent::" +msgstr "" + +#: library/dataclasses.rst:74 +msgid "" +"@dataclass\n" +"class C:\n" +" ...\n" +"\n" +"@dataclass()\n" +"class C:\n" +" ...\n" +"\n" +"@dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, " +"frozen=False,\n" +" match_args=True, kw_only=False, slots=False, weakref_slot=False)\n" +"class C:\n" +" ..." msgstr "" #: library/dataclasses.rst:87 -msgid "The parameters to :func:`dataclass` are:" +msgid "The parameters to ``@dataclass`` are:" msgstr "" #: library/dataclasses.rst:89 msgid "" -"``init``: If true (the default), a :meth:`~object.__init__` method will be " +"*init*: If true (the default), a :meth:`~object.__init__` method will be " "generated." msgstr "" #: library/dataclasses.rst:92 msgid "" -"If the class already defines :meth:`~object.__init__`, this parameter is " -"ignored." +"If the class already defines :meth:`!__init__`, this parameter is ignored." msgstr "" #: library/dataclasses.rst:95 msgid "" -"``repr``: If true (the default), a :meth:`~object.__repr__` method will be " +"*repr*: If true (the default), a :meth:`~object.__repr__` method will be " "generated. The generated repr string will have the class name and the name " "and repr of each field, in the order they are defined in the class. Fields " "that are marked as being excluded from the repr are not included. For " @@ -117,13 +158,12 @@ msgstr "" #: library/dataclasses.rst:102 msgid "" -"If the class already defines :meth:`~object.__repr__`, this parameter is " -"ignored." +"If the class already defines :meth:`!__repr__`, this parameter is ignored." msgstr "" #: library/dataclasses.rst:105 msgid "" -"``eq``: If true (the default), an :meth:`~object.__eq__` method will be " +"*eq*: If true (the default), an :meth:`~object.__eq__` method will be " "generated. This method compares the class as if it were a tuple of its " "fields, in order. Both instances in the comparison must be of the identical " "type." @@ -131,166 +171,202 @@ msgstr "" #: library/dataclasses.rst:110 msgid "" -"If the class already defines :meth:`~object.__eq__`, this parameter is " -"ignored." +"If the class already defines :meth:`!__eq__`, this parameter is ignored." msgstr "" #: library/dataclasses.rst:113 msgid "" -"``order``: If true (the default is ``False``), :meth:`~object.__lt__`, :meth:" -"`~object.__le__`, :meth:`~object.__gt__`, and :meth:`~object.__ge__` methods " -"will be generated. These compare the class as if it were a tuple of its " -"fields, in order. Both instances in the comparison must be of the identical " -"type. If ``order`` is true and ``eq`` is false, a :exc:`ValueError` is " -"raised." +"*order*: If true (the default is " +"``False``), :meth:`~object.__lt__`, :meth:`~object.__le__`, :meth:`~object.__gt__`, " +"and :meth:`~object.__ge__` methods will be generated. These compare the " +"class as if it were a tuple of its fields, in order. Both instances in the " +"comparison must be of the identical type. If *order* is true and *eq* is " +"false, a :exc:`ValueError` is raised." msgstr "" #: library/dataclasses.rst:120 msgid "" -"If the class already defines any of :meth:`~object.__lt__`, :meth:`~object." -"__le__`, :meth:`~object.__gt__`, or :meth:`~object.__ge__`, then :exc:" -"`TypeError` is raised." +"If the class already defines any of :meth:`!__lt__`, :meth:`!" +"__le__`, :meth:`!__gt__`, or :meth:`!__ge__`, then :exc:`TypeError` is " +"raised." msgstr "" #: library/dataclasses.rst:124 msgid "" -"``unsafe_hash``: If ``False`` (the default), a :meth:`~object.__hash__` " -"method is generated according to how ``eq`` and ``frozen`` are set." +"*unsafe_hash*: If ``False`` (the default), a :meth:`~object.__hash__` method " +"is generated according to how *eq* and *frozen* are set." msgstr "" #: library/dataclasses.rst:127 msgid "" -":meth:`~object.__hash__` is used by built-in :meth:`hash()`, and when " -"objects are added to hashed collections such as dictionaries and sets. " -"Having a :meth:`~object.__hash__` implies that instances of the class are " -"immutable. Mutability is a complicated property that depends on the " -"programmer's intent, the existence and behavior of :meth:`~object.__eq__`, " -"and the values of the ``eq`` and ``frozen`` flags in the :func:`dataclass` " -"decorator." +":meth:`!__hash__` is used by built-in :meth:`hash`, and when objects are " +"added to hashed collections such as dictionaries and sets. Having a :meth:`!" +"__hash__` implies that instances of the class are immutable. Mutability is a " +"complicated property that depends on the programmer's intent, the existence " +"and behavior of :meth:`!__eq__`, and the values of the *eq* and *frozen* " +"flags in the ``@dataclass`` decorator." msgstr "" #: library/dataclasses.rst:134 msgid "" -"By default, :func:`dataclass` will not implicitly add a :meth:`~object." -"__hash__` method unless it is safe to do so. Neither will it add or change " -"an existing explicitly defined :meth:`~object.__hash__` method. Setting the " -"class attribute ``__hash__ = None`` has a specific meaning to Python, as " -"described in the :meth:`~object.__hash__` documentation." +"By default, ``@dataclass`` will not implicitly add " +"a :meth:`~object.__hash__` method unless it is safe to do so. Neither will " +"it add or change an existing explicitly defined :meth:`!__hash__` method. " +"Setting the class attribute ``__hash__ = None`` has a specific meaning to " +"Python, as described in the :meth:`!__hash__` documentation." msgstr "" #: library/dataclasses.rst:140 msgid "" -"If :meth:`~object.__hash__` is not explicitly defined, or if it is set to " -"``None``, then :func:`dataclass` *may* add an implicit :meth:`~object." -"__hash__` method. Although not recommended, you can force :func:`dataclass` " -"to create a :meth:`~object.__hash__` method with ``unsafe_hash=True``. This " -"might be the case if your class is logically immutable but can nonetheless " -"be mutated. This is a specialized use case and should be considered " -"carefully." +"If :meth:`!__hash__` is not explicitly defined, or if it is set to ``None``, " +"then ``@dataclass`` *may* add an implicit :meth:`!__hash__` method. Although " +"not recommended, you can force ``@dataclass`` to create a :meth:`!__hash__` " +"method with ``unsafe_hash=True``. This might be the case if your class is " +"logically immutable but can still be mutated. This is a specialized use case " +"and should be considered carefully." msgstr "" #: library/dataclasses.rst:147 msgid "" -"Here are the rules governing implicit creation of a :meth:`~object.__hash__` " -"method. Note that you cannot both have an explicit :meth:`~object.__hash__` " -"method in your dataclass and set ``unsafe_hash=True``; this will result in " +"Here are the rules governing implicit creation of a :meth:`!__hash__` " +"method. Note that you cannot both have an explicit :meth:`!__hash__` method " +"in your dataclass and set ``unsafe_hash=True``; this will result in " "a :exc:`TypeError`." msgstr "" #: library/dataclasses.rst:152 msgid "" -"If ``eq`` and ``frozen`` are both true, by default :func:`dataclass` will " -"generate a :meth:`~object.__hash__` method for you. If ``eq`` is true and " -"``frozen`` is false, :meth:`~object.__hash__` will be set to ``None``, " -"marking it unhashable (which it is, since it is mutable). If ``eq`` is " -"false, :meth:`~object.__hash__` will be left untouched meaning the :meth:" -"`~object.__hash__` method of the superclass will be used (if the superclass " -"is :class:`object`, this means it will fall back to id-based hashing)." +"If *eq* and *frozen* are both true, by default ``@dataclass`` will generate " +"a :meth:`!__hash__` method for you. If *eq* is true and *frozen* is " +"false, :meth:`!__hash__` will be set to ``None``, marking it unhashable " +"(which it is, since it is mutable). If *eq* is false, :meth:`!__hash__` " +"will be left untouched meaning the :meth:`!__hash__` method of the " +"superclass will be used (if the superclass is :class:`object`, this means it " +"will fall back to id-based hashing)." msgstr "" #: library/dataclasses.rst:160 msgid "" -"``frozen``: If true (the default is ``False``), assigning to fields will " -"generate an exception. This emulates read-only frozen instances. If :meth:" -"`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the " -"class, then :exc:`TypeError` is raised. See the discussion below." +"*frozen*: If true (the default is ``False``), assigning to fields will " +"generate an exception. This emulates read-only frozen instances. " +"If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in " +"the class, then :exc:`TypeError` is raised. See the discussion below." msgstr "" #: library/dataclasses.rst:165 msgid "" -"``match_args``: If true (the default is ``True``), the ``__match_args__`` " -"tuple will be created from the list of parameters to the generated :meth:" -"`~object.__init__` method (even if :meth:`~object.__init__` is not " -"generated, see above). If false, or if ``__match_args__`` is already " -"defined in the class, then ``__match_args__`` will not be generated." +"*match_args*: If true (the default is ``True``), " +"the :attr:`~object.__match_args__` tuple will be created from the list of " +"parameters to the generated :meth:`~object.__init__` method (even if :meth:`!" +"__init__` is not generated, see above). If false, or if :attr:`!" +"__match_args__` is already defined in the class, then :attr:`!" +"__match_args__` will not be generated." msgstr "" #: library/dataclasses.rst:174 msgid "" -"``kw_only``: If true (the default value is ``False``), then all fields will " -"be marked as keyword-only. If a field is marked as keyword-only, then the " -"only effect is that the :meth:`~object.__init__` parameter generated from a " -"keyword-only field must be specified with a keyword when :meth:`~object." -"__init__` is called. There is no effect on any other aspect of " -"dataclasses. See the :term:`parameter` glossary entry for details. Also " -"see the :const:`KW_ONLY` section." +"*kw_only*: If true (the default value is ``False``), then all fields will be " +"marked as keyword-only. If a field is marked as keyword-only, then the only " +"effect is that the :meth:`~object.__init__` parameter generated from a " +"keyword-only field must be specified with a keyword when :meth:`!__init__` " +"is called. There is no effect on any other aspect of dataclasses. See " +"the :term:`parameter` glossary entry for details. Also see " +"the :const:`KW_ONLY` section." msgstr "" #: library/dataclasses.rst:185 msgid "" -"``slots``: If true (the default is ``False``), :attr:`~object.__slots__` " +"*slots*: If true (the default is ``False``), :attr:`~object.__slots__` " "attribute will be generated and new class will be returned instead of the " -"original one. If :attr:`~object.__slots__` is already defined in the class, " +"original one. If :attr:`!__slots__` is already defined in the class, " "then :exc:`TypeError` is raised." msgstr "" -#: library/dataclasses.rst:192 +#: library/dataclasses.rst:191 +msgid "" +"Calling no-arg :func:`super` in dataclasses using ``slots=True`` will result " +"in the following exception being raised: ``TypeError: super(type, obj): obj " +"must be an instance or subtype of type``. The two-arg :func:`super` is a " +"valid workaround. See :gh:`90562` for full details." +msgstr "" + +#: library/dataclasses.rst:198 msgid "" -"If a field name is already included in the ``__slots__`` of a base class, it " -"will not be included in the generated ``__slots__`` to prevent :ref:" -"`overriding them `. Therefore, do not use " -"``__slots__`` to retrieve the field names of a dataclass. Use :func:`fields` " -"instead. To be able to determine inherited slots, base class ``__slots__`` " -"may be any iterable, but *not* an iterator." +"Passing parameters to a base class :meth:`~object.__init_subclass__` when " +"using ``slots=True`` will result in a :exc:`TypeError`. Either use " +"``__init_subclass__`` with no parameters or use default values as a " +"workaround. See :gh:`91126` for full details." msgstr "" -#: library/dataclasses.rst:202 +#: library/dataclasses.rst:206 msgid "" -"``weakref_slot``: If true (the default is ``False``), add a slot named " -"\"__weakref__\", which is required to make an instance weakref-able. It is " -"an error to specify ``weakref_slot=True`` without also specifying " -"``slots=True``." +"If a field name is already included in the :attr:`!__slots__` of a base " +"class, it will not be included in the generated :attr:`!__slots__` to " +"prevent :ref:`overriding them `. Therefore, do not " +"use :attr:`!__slots__` to retrieve the field names of a dataclass. " +"Use :func:`fields` instead. To be able to determine inherited slots, base " +"class :attr:`!__slots__` may be any iterable, but *not* an iterator." msgstr "" -#: library/dataclasses.rst:209 +#: library/dataclasses.rst:216 +msgid "" +"*weakref_slot*: If true (the default is ``False``), add a slot named " +"\"__weakref__\", which is required to make an instance :func:`weakref-able " +"`. It is an error to specify ``weakref_slot=True`` without also " +"specifying ``slots=True``." +msgstr "" + +#: library/dataclasses.rst:224 msgid "" "``field``\\s may optionally specify a default value, using normal Python " "syntax::" msgstr "" -#: library/dataclasses.rst:217 +#: library/dataclasses.rst:227 msgid "" -"In this example, both ``a`` and ``b`` will be included in the added :meth:" -"`~object.__init__` method, which will be defined as::" +"@dataclass\n" +"class C:\n" +" a: int # 'a' has no default value\n" +" b: int = 0 # assign a default value for 'b'" msgstr "" -#: library/dataclasses.rst:222 +#: library/dataclasses.rst:232 +msgid "" +"In this example, both :attr:`!a` and :attr:`!b` will be included in the " +"added :meth:`~object.__init__` method, which will be defined as::" +msgstr "" + +#: library/dataclasses.rst:235 +msgid "def __init__(self, a: int, b: int = 0):" +msgstr "" + +#: library/dataclasses.rst:237 msgid "" ":exc:`TypeError` will be raised if a field without a default value follows a " "field with a default value. This is true whether this occurs in a single " "class, or as a result of class inheritance." msgstr "" -#: library/dataclasses.rst:228 +#: library/dataclasses.rst:243 msgid "" "For common and simple use cases, no other functionality is required. There " "are, however, some dataclass features that require additional per-field " "information. To satisfy this need for additional information, you can " -"replace the default field value with a call to the provided :func:`field` " +"replace the default field value with a call to the provided :func:`!field` " "function. For example::" msgstr "" -#: library/dataclasses.rst:241 +#: library/dataclasses.rst:249 +msgid "" +"@dataclass\n" +"class C:\n" +" mylist: list[int] = field(default_factory=list)\n" +"\n" +"c = C()\n" +"c.mylist += [1, 2, 3]" +msgstr "" + +#: library/dataclasses.rst:256 msgid "" "As shown above, the :const:`MISSING` value is a sentinel object used to " "detect if some parameters are provided by the user. This sentinel is used " @@ -298,49 +374,48 @@ msgid "" "meaning. No code should directly use the :const:`MISSING` value." msgstr "" -#: library/dataclasses.rst:246 -msgid "The parameters to :func:`field` are:" +#: library/dataclasses.rst:261 +msgid "The parameters to :func:`!field` are:" msgstr "" -#: library/dataclasses.rst:248 +#: library/dataclasses.rst:263 msgid "" -"``default``: If provided, this will be the default value for this field. " -"This is needed because the :meth:`field` call itself replaces the normal " +"*default*: If provided, this will be the default value for this field. This " +"is needed because the :func:`!field` call itself replaces the normal " "position of the default value." msgstr "" -#: library/dataclasses.rst:252 +#: library/dataclasses.rst:267 msgid "" -"``default_factory``: If provided, it must be a zero-argument callable that " +"*default_factory*: If provided, it must be a zero-argument callable that " "will be called when a default value is needed for this field. Among other " "purposes, this can be used to specify fields with mutable default values, as " -"discussed below. It is an error to specify both ``default`` and " -"``default_factory``." +"discussed below. It is an error to specify both *default* and " +"*default_factory*." msgstr "" -#: library/dataclasses.rst:258 +#: library/dataclasses.rst:273 msgid "" -"``init``: If true (the default), this field is included as a parameter to " -"the generated :meth:`~object.__init__` method." +"*init*: If true (the default), this field is included as a parameter to the " +"generated :meth:`~object.__init__` method." msgstr "" -#: library/dataclasses.rst:261 +#: library/dataclasses.rst:276 msgid "" -"``repr``: If true (the default), this field is included in the string " -"returned by the generated :meth:`~object.__repr__` method." +"*repr*: If true (the default), this field is included in the string returned " +"by the generated :meth:`~object.__repr__` method." msgstr "" -#: library/dataclasses.rst:264 +#: library/dataclasses.rst:279 msgid "" -"``hash``: This can be a bool or ``None``. If true, this field is included " -"in the generated :meth:`~object.__hash__` method. If ``None`` (the " -"default), use the value of ``compare``: this would normally be the expected " -"behavior. A field should be considered in the hash if it's used for " -"comparisons. Setting this value to anything other than ``None`` is " -"discouraged." +"*hash*: This can be a bool or ``None``. If true, this field is included in " +"the generated :meth:`~object.__hash__` method. If ``None`` (the default), " +"use the value of *compare*: this would normally be the expected behavior. A " +"field should be considered in the hash if it's used for comparisons. " +"Setting this value to anything other than ``None`` is discouraged." msgstr "" -#: library/dataclasses.rst:271 +#: library/dataclasses.rst:286 msgid "" "One possible reason to set ``hash=False`` but ``compare=True`` would be if a " "field is expensive to compute a hash value for, that field is needed for " @@ -349,77 +424,88 @@ msgid "" "used for comparisons." msgstr "" -#: library/dataclasses.rst:277 +#: library/dataclasses.rst:292 msgid "" -"``compare``: If true (the default), this field is included in the generated " -"equality and comparison methods (:meth:`~object.__eq__`, :meth:`~object." -"__gt__`, et al.)." +"*compare*: If true (the default), this field is included in the generated " +"equality and comparison methods " +"(:meth:`~object.__eq__`, :meth:`~object.__gt__`, et al.)." msgstr "" -#: library/dataclasses.rst:281 +#: library/dataclasses.rst:296 msgid "" -"``metadata``: This can be a mapping or None. None is treated as an empty " -"dict. This value is wrapped in :func:`~types.MappingProxyType` to make it " -"read-only, and exposed on the :class:`Field` object. It is not used at all " -"by Data Classes, and is provided as a third-party extension mechanism. " -"Multiple third-parties can each have their own key, to use as a namespace in " -"the metadata." +"*metadata*: This can be a mapping or ``None``. ``None`` is treated as an " +"empty dict. This value is wrapped in :func:`~types.MappingProxyType` to " +"make it read-only, and exposed on the :class:`Field` object. It is not used " +"at all by Data Classes, and is provided as a third-party extension " +"mechanism. Multiple third-parties can each have their own key, to use as a " +"namespace in the metadata." msgstr "" -#: library/dataclasses.rst:289 +#: library/dataclasses.rst:304 msgid "" -"``kw_only``: If true, this field will be marked as keyword-only. This is " -"used when the generated :meth:`~object.__init__` method's parameters are " -"computed." +"*kw_only*: If true, this field will be marked as keyword-only. This is used " +"when the generated :meth:`~object.__init__` method's parameters are computed." msgstr "" -#: library/dataclasses.rst:295 +#: library/dataclasses.rst:310 msgid "" -"If the default value of a field is specified by a call to :func:`field()`, " +"If the default value of a field is specified by a call to :func:`!field`, " "then the class attribute for this field will be replaced by the specified " -"``default`` value. If no ``default`` is provided, then the class attribute " -"will be deleted. The intent is that after the :func:`dataclass` decorator " -"runs, the class attributes will all contain the default values for the " -"fields, just as if the default value itself were specified. For example, " -"after::" +"*default* value. If *default* is not provided, then the class attribute " +"will be deleted. The intent is that after the :func:`@dataclass " +"` decorator runs, the class attributes will all contain the " +"default values for the fields, just as if the default value itself were " +"specified. For example, after::" msgstr "" -#: library/dataclasses.rst:311 +#: library/dataclasses.rst:319 msgid "" -"The class attribute ``C.z`` will be ``10``, the class attribute ``C.t`` will " -"be ``20``, and the class attributes ``C.x`` and ``C.y`` will not be set." +"@dataclass\n" +"class C:\n" +" x: int\n" +" y: int = field(repr=False)\n" +" z: int = field(repr=False, default=10)\n" +" t: int = 20" msgstr "" -#: library/dataclasses.rst:317 +#: library/dataclasses.rst:326 msgid "" -":class:`Field` objects describe each defined field. These objects are " +"The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!" +"C.t` will be ``20``, and the class attributes :attr:`!C.x` and :attr:`!C.y` " +"will not be set." +msgstr "" + +#: library/dataclasses.rst:332 +msgid "" +":class:`!Field` objects describe each defined field. These objects are " "created internally, and are returned by the :func:`fields` module-level " -"method (see below). Users should never instantiate a :class:`Field` object " +"method (see below). Users should never instantiate a :class:`!Field` object " "directly. Its documented attributes are:" msgstr "" -#: library/dataclasses.rst:322 -msgid "``name``: The name of the field." +#: library/dataclasses.rst:337 +msgid ":attr:`!name`: The name of the field." msgstr "" -#: library/dataclasses.rst:323 -msgid "``type``: The type of the field." +#: library/dataclasses.rst:338 +msgid ":attr:`!type`: The type of the field." msgstr "" -#: library/dataclasses.rst:324 +#: library/dataclasses.rst:339 msgid "" -"``default``, ``default_factory``, ``init``, ``repr``, ``hash``, ``compare``, " -"``metadata``, and ``kw_only`` have the identical meaning and values as they " -"do in the :func:`field` function." +":attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!" +"repr`, :attr:`!hash`, :attr:`!compare`, :attr:`!metadata`, and :attr:`!" +"kw_only` have the identical meaning and values as they do in " +"the :func:`field` function." msgstr "" -#: library/dataclasses.rst:328 +#: library/dataclasses.rst:343 msgid "" "Other attributes may exist, but they are private and must not be inspected " "or relied on." msgstr "" -#: library/dataclasses.rst:333 +#: library/dataclasses.rst:348 msgid "" "Returns a tuple of :class:`Field` objects that define the fields for this " "dataclass. Accepts either a dataclass, or an instance of a dataclass. " @@ -427,298 +513,432 @@ msgid "" "not return pseudo-fields which are ``ClassVar`` or ``InitVar``." msgstr "" -#: library/dataclasses.rst:340 +#: library/dataclasses.rst:355 msgid "" -"Converts the dataclass ``obj`` to a dict (by using the factory function " -"``dict_factory``). Each dataclass is converted to a dict of its fields, as " +"Converts the dataclass *obj* to a dict (by using the factory function " +"*dict_factory*). Each dataclass is converted to a dict of its fields, as " "``name: value`` pairs. dataclasses, dicts, lists, and tuples are recursed " "into. Other objects are copied with :func:`copy.deepcopy`." msgstr "" -#: library/dataclasses.rst:346 -msgid "Example of using :func:`asdict` on nested dataclasses::" +#: library/dataclasses.rst:361 +msgid "Example of using :func:`!asdict` on nested dataclasses::" msgstr "" -#: library/dataclasses.rst:383 +#: library/dataclasses.rst:363 +msgid "" +"@dataclass\n" +"class Point:\n" +" x: int\n" +" y: int\n" +"\n" +"@dataclass\n" +"class C:\n" +" mylist: list[Point]\n" +"\n" +"p = Point(10, 20)\n" +"assert asdict(p) == {'x': 10, 'y': 20}\n" +"\n" +"c = C([Point(0, 0), Point(10, 4)])\n" +"assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}" +msgstr "" + +#: library/dataclasses.rst:398 msgid "To create a shallow copy, the following workaround may be used::" msgstr "" -#: library/dataclasses.rst:367 +#: library/dataclasses.rst:380 +msgid "{field.name: getattr(obj, field.name) for field in fields(obj)}" +msgstr "" + +#: library/dataclasses.rst:382 msgid "" -":func:`asdict` raises :exc:`TypeError` if ``obj`` is not a dataclass " -"instance." +":func:`!asdict` raises :exc:`TypeError` if *obj* is not a dataclass instance." msgstr "" -#: library/dataclasses.rst:372 +#: library/dataclasses.rst:387 msgid "" -"Converts the dataclass ``obj`` to a tuple (by using the factory function " -"``tuple_factory``). Each dataclass is converted to a tuple of its field " +"Converts the dataclass *obj* to a tuple (by using the factory function " +"*tuple_factory*). Each dataclass is converted to a tuple of its field " "values. dataclasses, dicts, lists, and tuples are recursed into. Other " "objects are copied with :func:`copy.deepcopy`." msgstr "" -#: library/dataclasses.rst:378 +#: library/dataclasses.rst:393 msgid "Continuing from the previous example::" msgstr "" -#: library/dataclasses.rst:387 +#: library/dataclasses.rst:395 +msgid "" +"assert astuple(p) == (10, 20)\n" +"assert astuple(c) == ([(0, 0), (10, 4)],)" +msgstr "" + +#: library/dataclasses.rst:400 +msgid "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))" +msgstr "" + +#: library/dataclasses.rst:402 msgid "" -":func:`astuple` raises :exc:`TypeError` if ``obj`` is not a dataclass " +":func:`!astuple` raises :exc:`TypeError` if *obj* is not a dataclass " "instance." msgstr "" -#: library/dataclasses.rst:392 +#: library/dataclasses.rst:407 msgid "" -"Creates a new dataclass with name ``cls_name``, fields as defined in " -"``fields``, base classes as given in ``bases``, and initialized with a " -"namespace as given in ``namespace``. ``fields`` is an iterable whose " -"elements are each either ``name``, ``(name, type)``, or ``(name, type, " -"Field)``. If just ``name`` is supplied, ``typing.Any`` is used for " -"``type``. The values of ``init``, ``repr``, ``eq``, ``order``, " -"``unsafe_hash``, ``frozen``, ``match_args``, ``kw_only``, ``slots``, and " -"``weakref_slot`` have the same meaning as they do in :func:`dataclass`." +"Creates a new dataclass with name *cls_name*, fields as defined in *fields*, " +"base classes as given in *bases*, and initialized with a namespace as given " +"in *namespace*. *fields* is an iterable whose elements are each either " +"``name``, ``(name, type)``, or ``(name, type, Field)``. If just ``name`` is " +"supplied, :data:`typing.Any` is used for ``type``. The values of *init*, " +"*repr*, *eq*, *order*, *unsafe_hash*, *frozen*, *match_args*, *kw_only*, " +"*slots*, and *weakref_slot* have the same meaning as they do " +"in :func:`@dataclass `." msgstr "" -#: library/dataclasses.rst:402 +#: library/dataclasses.rst:417 msgid "" -"If ``module`` is defined, the ``__module__`` attribute of the dataclass is " -"set to that value. By default, it is set to the module name of the caller." +"If *module* is defined, the :attr:`!__module__` attribute of the dataclass " +"is set to that value. By default, it is set to the module name of the caller." msgstr "" -#: library/dataclasses.rst:406 +#: library/dataclasses.rst:421 msgid "" "This function is not strictly required, because any Python mechanism for " -"creating a new class with ``__annotations__`` can then apply the :func:" -"`dataclass` function to convert that class to a dataclass. This function is " -"provided as a convenience. For example::" +"creating a new class with :attr:`!__annotations__` can then apply " +"the :func:`@dataclass ` function to convert that class to a " +"dataclass. This function is provided as a convenience. For example::" msgstr "" -#: library/dataclasses.rst:418 +#: library/dataclasses.rst:427 +msgid "" +"C = make_dataclass('C',\n" +" [('x', int),\n" +" 'y',\n" +" ('z', int, field(default=5))],\n" +" namespace={'add_one': lambda self: self.x + 1})" +msgstr "" + +#: library/dataclasses.rst:433 msgid "Is equivalent to::" msgstr "" -#: library/dataclasses.rst:431 +#: library/dataclasses.rst:435 +msgid "" +"@dataclass\n" +"class C:\n" +" x: int\n" +" y: 'typing.Any'\n" +" z: int = 5\n" +"\n" +" def add_one(self):\n" +" return self.x + 1" +msgstr "" + +#: library/dataclasses.rst:446 msgid "" -"Creates a new object of the same type as ``obj``, replacing fields with " -"values from ``changes``. If ``obj`` is not a Data Class, raises :exc:" -"`TypeError`. If values in ``changes`` do not specify fields, raises :exc:" -"`TypeError`." +"Creates a new object of the same type as *obj*, replacing fields with values " +"from *changes*. If *obj* is not a Data Class, raises :exc:`TypeError`. If " +"keys in *changes* are not field names of the given dataclass, " +"raises :exc:`TypeError`." msgstr "" -#: library/dataclasses.rst:436 +#: library/dataclasses.rst:451 msgid "" "The newly returned object is created by calling the :meth:`~object.__init__` " "method of the dataclass. This ensures that :meth:`__post_init__`, if " "present, is also called." msgstr "" -#: library/dataclasses.rst:440 +#: library/dataclasses.rst:455 msgid "" "Init-only variables without default values, if any exist, must be specified " -"on the call to :func:`replace` so that they can be passed to :meth:`~object." +"on the call to :func:`!replace` so that they can be passed to :meth:`!" "__init__` and :meth:`__post_init__`." msgstr "" -#: library/dataclasses.rst:444 +#: library/dataclasses.rst:459 msgid "" -"It is an error for ``changes`` to contain any fields that are defined as " +"It is an error for *changes* to contain any fields that are defined as " "having ``init=False``. A :exc:`ValueError` will be raised in this case." msgstr "" -#: library/dataclasses.rst:448 +#: library/dataclasses.rst:463 msgid "" -"Be forewarned about how ``init=False`` fields work during a call to :func:" -"`replace`. They are not copied from the source object, but rather are " +"Be forewarned about how ``init=False`` fields work during a call to :func:`!" +"replace`. They are not copied from the source object, but rather are " "initialized in :meth:`__post_init__`, if they're initialized at all. It is " "expected that ``init=False`` fields will be rarely and judiciously used. If " "they are used, it might be wise to have alternate class constructors, or " -"perhaps a custom ``replace()`` (or similarly named) method which handles " +"perhaps a custom :func:`!replace` (or similarly named) method which handles " "instance copying." msgstr "" -#: library/dataclasses.rst:459 +#: library/dataclasses.rst:474 msgid "" -"Return ``True`` if its parameter is a dataclass or an instance of one, " -"otherwise return ``False``." +"Return ``True`` if its parameter is a dataclass (including subclasses of a " +"dataclass) or an instance of one, otherwise return ``False``." msgstr "" -#: library/dataclasses.rst:462 +#: library/dataclasses.rst:477 msgid "" "If you need to know if a class is an instance of a dataclass (and not a " "dataclass itself), then add a further check for ``not isinstance(obj, " "type)``::" msgstr "" -#: library/dataclasses.rst:471 +#: library/dataclasses.rst:481 +msgid "" +"def is_dataclass_instance(obj):\n" +" return is_dataclass(obj) and not isinstance(obj, type)" +msgstr "" + +#: library/dataclasses.rst:486 msgid "A sentinel value signifying a missing default or default_factory." msgstr "" -#: library/dataclasses.rst:475 +#: library/dataclasses.rst:490 msgid "" "A sentinel value used as a type annotation. Any fields after a pseudo-field " -"with the type of :const:`KW_ONLY` are marked as keyword-only fields. Note " -"that a pseudo-field of type :const:`KW_ONLY` is otherwise completely " +"with the type of :const:`!KW_ONLY` are marked as keyword-only fields. Note " +"that a pseudo-field of type :const:`!KW_ONLY` is otherwise completely " "ignored. This includes the name of such a field. By convention, a name of " -"``_`` is used for a :const:`KW_ONLY` field. Keyword-only fields signify :" -"meth:`~object.__init__` parameters that must be specified as keywords when " -"the class is instantiated." +"``_`` is used for a :const:`!KW_ONLY` field. Keyword-only fields " +"signify :meth:`~object.__init__` parameters that must be specified as " +"keywords when the class is instantiated." msgstr "" -#: library/dataclasses.rst:484 +#: library/dataclasses.rst:499 msgid "" "In this example, the fields ``y`` and ``z`` will be marked as keyword-only " "fields::" msgstr "" -#: library/dataclasses.rst:495 +#: library/dataclasses.rst:501 +msgid "" +"@dataclass\n" +"class Point:\n" +" x: float\n" +" _: KW_ONLY\n" +" y: float\n" +" z: float\n" +"\n" +"p = Point(0, y=1.5, z=2.0)" +msgstr "" + +#: library/dataclasses.rst:510 msgid "" "In a single dataclass, it is an error to specify more than one field whose " -"type is :const:`KW_ONLY`." +"type is :const:`!KW_ONLY`." msgstr "" -#: library/dataclasses.rst:502 +#: library/dataclasses.rst:517 msgid "" -"Raised when an implicitly defined :meth:`~object.__setattr__` or :meth:" -"`~object.__delattr__` is called on a dataclass which was defined with " -"``frozen=True``. It is a subclass of :exc:`AttributeError`." +"Raised when an implicitly defined :meth:`~object.__setattr__` " +"or :meth:`~object.__delattr__` is called on a dataclass which was defined " +"with ``frozen=True``. It is a subclass of :exc:`AttributeError`." msgstr "" -#: library/dataclasses.rst:509 +#: library/dataclasses.rst:524 msgid "Post-init processing" msgstr "" -#: library/dataclasses.rst:513 +#: library/dataclasses.rst:528 msgid "" -"When defined on the class, it will be called by the generated :meth:`~object." -"__init__`, normally as ``self.__post_init__()``. However, if any ``InitVar`` " -"fields are defined, they will also be passed to :meth:`__post_init__` in the " -"order they were defined in the class. If no :meth:`~object.__init__` method " -"is generated, then :meth:`__post_init__` will not automatically be called." +"When defined on the class, it will be called by the " +"generated :meth:`~object.__init__`, normally as :meth:`!self.__post_init__`. " +"However, if any ``InitVar`` fields are defined, they will also be passed " +"to :meth:`!__post_init__` in the order they were defined in the class. If " +"no :meth:`!__init__` method is generated, then :meth:`!__post_init__` will " +"not automatically be called." msgstr "" -#: library/dataclasses.rst:520 +#: library/dataclasses.rst:535 msgid "" "Among other uses, this allows for initializing field values that depend on " "one or more other fields. For example::" msgstr "" -#: library/dataclasses.rst:532 +#: library/dataclasses.rst:538 +msgid "" +"@dataclass\n" +"class C:\n" +" a: float\n" +" b: float\n" +" c: float = field(init=False)\n" +"\n" +" def __post_init__(self):\n" +" self.c = self.a + self.b" +msgstr "" + +#: library/dataclasses.rst:547 msgid "" -"The :meth:`~object.__init__` method generated by :func:`dataclass` does not " -"call base class :meth:`~object.__init__` methods. If the base class has an :" -"meth:`~object.__init__` method that has to be called, it is common to call " -"this method in a :meth:`__post_init__` method::" +"The :meth:`~object.__init__` method generated by :func:`@dataclass " +"` does not call base class :meth:`!__init__` methods. If the base " +"class has an :meth:`!__init__` method that has to be called, it is common to " +"call this method in a :meth:`__post_init__` method::" msgstr "" -#: library/dataclasses.rst:549 +#: library/dataclasses.rst:552 msgid "" -"Note, however, that in general the dataclass-generated :meth:`~object." -"__init__` methods don't need to be called, since the derived dataclass will " -"take care of initializing all fields of any base class that is a dataclass " -"itself." +"class Rectangle:\n" +" def __init__(self, height, width):\n" +" self.height = height\n" +" self.width = width\n" +"\n" +"@dataclass\n" +"class Square(Rectangle):\n" +" side: float\n" +"\n" +" def __post_init__(self):\n" +" super().__init__(self.side, self.side)" msgstr "" -#: library/dataclasses.rst:553 +#: library/dataclasses.rst:564 msgid "" -"See the section below on init-only variables for ways to pass parameters to :" -"meth:`__post_init__`. Also see the warning about how :func:`replace` " +"Note, however, that in general the dataclass-generated :meth:`!__init__` " +"methods don't need to be called, since the derived dataclass will take care " +"of initializing all fields of any base class that is a dataclass itself." +msgstr "" + +#: library/dataclasses.rst:568 +msgid "" +"See the section below on init-only variables for ways to pass parameters " +"to :meth:`!__post_init__`. Also see the warning about how :func:`replace` " "handles ``init=False`` fields." msgstr "" -#: library/dataclasses.rst:558 +#: library/dataclasses.rst:575 msgid "Class variables" msgstr "" -#: library/dataclasses.rst:560 +#: library/dataclasses.rst:577 msgid "" -"One of the few places where :func:`dataclass` actually inspects the type of " -"a field is to determine if a field is a class variable as defined in :pep:" -"`526`. It does this by checking if the type of the field is ``typing." -"ClassVar``. If a field is a ``ClassVar``, it is excluded from consideration " -"as a field and is ignored by the dataclass mechanisms. Such ``ClassVar`` " -"pseudo-fields are not returned by the module-level :func:`fields` function." +"One of the few places where :func:`@dataclass ` actually inspects " +"the type of a field is to determine if a field is a class variable as " +"defined in :pep:`526`. It does this by checking if the type of the field " +"is :data:`typing.ClassVar`. If a field is a ``ClassVar``, it is excluded " +"from consideration as a field and is ignored by the dataclass mechanisms. " +"Such ``ClassVar`` pseudo-fields are not returned by the module-" +"level :func:`fields` function." msgstr "" -#: library/dataclasses.rst:569 +#: library/dataclasses.rst:588 msgid "Init-only variables" msgstr "" -#: library/dataclasses.rst:571 +#: library/dataclasses.rst:590 msgid "" -"Another place where :func:`dataclass` inspects a type annotation is to " -"determine if a field is an init-only variable. It does this by seeing if " -"the type of a field is of type ``dataclasses.InitVar``. If a field is an " -"``InitVar``, it is considered a pseudo-field called an init-only field. As " -"it is not a true field, it is not returned by the module-level :func:" -"`fields` function. Init-only fields are added as parameters to the " -"generated :meth:`~object.__init__` method, and are passed to the optional :" -"meth:`__post_init__` method. They are not otherwise used by dataclasses." +"Another place where :func:`@dataclass ` inspects a type " +"annotation is to determine if a field is an init-only variable. It does " +"this by seeing if the type of a field is of type ``dataclasses.InitVar``. " +"If a field is an ``InitVar``, it is considered a pseudo-field called an init-" +"only field. As it is not a true field, it is not returned by the module-" +"level :func:`fields` function. Init-only fields are added as parameters to " +"the generated :meth:`~object.__init__` method, and are passed to the " +"optional :meth:`__post_init__` method. They are not otherwise used by " +"dataclasses." msgstr "" -#: library/dataclasses.rst:581 +#: library/dataclasses.rst:600 msgid "" "For example, suppose a field will be initialized from a database, if a value " "is not provided when creating the class::" msgstr "" -#: library/dataclasses.rst:596 +#: library/dataclasses.rst:603 msgid "" -"In this case, :func:`fields` will return :class:`Field` objects for ``i`` " -"and ``j``, but not for ``database``." +"@dataclass\n" +"class C:\n" +" i: int\n" +" j: int | None = None\n" +" database: InitVar[DatabaseType | None] = None\n" +"\n" +" def __post_init__(self, database):\n" +" if self.j is None and database is not None:\n" +" self.j = database.lookup('j')\n" +"\n" +"c = C(10, database=my_database)" msgstr "" -#: library/dataclasses.rst:600 +#: library/dataclasses.rst:615 +msgid "" +"In this case, :func:`fields` will return :class:`Field` objects for :attr:`!" +"i` and :attr:`!j`, but not for :attr:`!database`." +msgstr "" + +#: library/dataclasses.rst:621 msgid "Frozen instances" msgstr "" -#: library/dataclasses.rst:602 +#: library/dataclasses.rst:623 msgid "" "It is not possible to create truly immutable Python objects. However, by " -"passing ``frozen=True`` to the :meth:`dataclass` decorator you can emulate " -"immutability. In that case, dataclasses will add :meth:`~object." -"__setattr__` and :meth:`~object.__delattr__` methods to the class. These " -"methods will raise a :exc:`FrozenInstanceError` when invoked." +"passing ``frozen=True`` to the :func:`@dataclass ` decorator you " +"can emulate immutability. In that case, dataclasses will " +"add :meth:`~object.__setattr__` and :meth:`~object.__delattr__` methods to " +"the class. These methods will raise a :exc:`FrozenInstanceError` when " +"invoked." msgstr "" -#: library/dataclasses.rst:608 +#: library/dataclasses.rst:629 msgid "" -"There is a tiny performance penalty when using ``frozen=True``: :meth:" -"`~object.__init__` cannot use simple assignment to initialize fields, and " -"must use :meth:`!object.__setattr__`." +"There is a tiny performance penalty when using " +"``frozen=True``: :meth:`~object.__init__` cannot use simple assignment to " +"initialize fields, and must use :meth:`!object.__setattr__`." msgstr "" -#: library/dataclasses.rst:613 +#: library/dataclasses.rst:638 msgid "Inheritance" msgstr "" -#: library/dataclasses.rst:615 +#: library/dataclasses.rst:640 msgid "" -"When the dataclass is being created by the :meth:`dataclass` decorator, it " -"looks through all of the class's base classes in reverse MRO (that is, " -"starting at :class:`object`) and, for each dataclass that it finds, adds the " -"fields from that base class to an ordered mapping of fields. After all of " -"the base class fields are added, it adds its own fields to the ordered " -"mapping. All of the generated methods will use this combined, calculated " -"ordered mapping of fields. Because the fields are in insertion order, " -"derived classes override base classes. An example::" +"When the dataclass is being created by the :func:`@dataclass ` " +"decorator, it looks through all of the class's base classes in reverse MRO " +"(that is, starting at :class:`object`) and, for each dataclass that it " +"finds, adds the fields from that base class to an ordered mapping of fields. " +"After all of the base class fields are added, it adds its own fields to the " +"ordered mapping. All of the generated methods will use this combined, " +"calculated ordered mapping of fields. Because the fields are in insertion " +"order, derived classes override base classes. An example::" msgstr "" -#: library/dataclasses.rst:635 +#: library/dataclasses.rst:650 msgid "" -"The final list of fields is, in order, ``x``, ``y``, ``z``. The final type " -"of ``x`` is ``int``, as specified in class ``C``." +"@dataclass\n" +"class Base:\n" +" x: Any = 15.0\n" +" y: int = 0\n" +"\n" +"@dataclass\n" +"class C(Base):\n" +" z: int = 10\n" +" x: int = 15" msgstr "" -#: library/dataclasses.rst:638 +#: library/dataclasses.rst:660 msgid "" -"The generated :meth:`~object.__init__` method for ``C`` will look like::" +"The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. " +"The final type of :attr:`!x` is :class:`int`, as specified in class :class:`!" +"C`." msgstr "" -#: library/dataclasses.rst:643 -msgid "Re-ordering of keyword-only parameters in :meth:`~object.__init__`" +#: library/dataclasses.rst:663 +msgid "" +"The generated :meth:`~object.__init__` method for :class:`!C` will look " +"like::" +msgstr "" + +#: library/dataclasses.rst:665 +msgid "def __init__(self, x: int = 15, y: int = 0, z: int = 10):" msgstr "" -#: library/dataclasses.rst:645 +#: library/dataclasses.rst:668 +msgid "Re-ordering of keyword-only parameters in :meth:`!__init__`" +msgstr "" + +#: library/dataclasses.rst:670 msgid "" "After the parameters needed for :meth:`~object.__init__` are computed, any " "keyword-only parameters are moved to come after all regular (non-keyword-" @@ -726,135 +946,235 @@ msgid "" "implemented in Python: they must come after non-keyword-only parameters." msgstr "" -#: library/dataclasses.rst:651 +#: library/dataclasses.rst:676 msgid "" -"In this example, ``Base.y``, ``Base.w``, and ``D.t`` are keyword-only " -"fields, and ``Base.x`` and ``D.z`` are regular fields::" +"In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are " +"keyword-only fields, and :attr:`!Base.x` and :attr:`!D.z` are regular " +"fields::" msgstr "" -#: library/dataclasses.rst:666 +#: library/dataclasses.rst:679 msgid "" -"The generated :meth:`~object.__init__` method for ``D`` will look like::" +"@dataclass\n" +"class Base:\n" +" x: Any = 15.0\n" +" _: KW_ONLY\n" +" y: int = 0\n" +" w: int = 1\n" +"\n" +"@dataclass\n" +"class D(Base):\n" +" z: int = 10\n" +" t: int = field(kw_only=True, default=0)" msgstr "" -#: library/dataclasses.rst:670 +#: library/dataclasses.rst:691 +msgid "The generated :meth:`!__init__` method for :class:`!D` will look like::" +msgstr "" + +#: library/dataclasses.rst:693 +msgid "" +"def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " +"int = 0):" +msgstr "" + +#: library/dataclasses.rst:695 msgid "" "Note that the parameters have been re-ordered from how they appear in the " "list of fields: parameters derived from regular fields are followed by " "parameters derived from keyword-only fields." msgstr "" -#: library/dataclasses.rst:674 +#: library/dataclasses.rst:699 msgid "" "The relative ordering of keyword-only parameters is maintained in the re-" -"ordered :meth:`~object.__init__` parameter list." +"ordered :meth:`!__init__` parameter list." msgstr "" -#: library/dataclasses.rst:679 +#: library/dataclasses.rst:704 msgid "Default factory functions" msgstr "" -#: library/dataclasses.rst:681 +#: library/dataclasses.rst:706 msgid "" -"If a :func:`field` specifies a ``default_factory``, it is called with zero " +"If a :func:`field` specifies a *default_factory*, it is called with zero " "arguments when a default value for the field is needed. For example, to " "create a new instance of a list, use::" msgstr "" -#: library/dataclasses.rst:687 +#: library/dataclasses.rst:710 +msgid "mylist: list = field(default_factory=list)" +msgstr "" + +#: library/dataclasses.rst:712 msgid "" "If a field is excluded from :meth:`~object.__init__` (using ``init=False``) " -"and the field also specifies ``default_factory``, then the default factory " -"function will always be called from the generated :meth:`~object.__init__` " +"and the field also specifies *default_factory*, then the default factory " +"function will always be called from the generated :meth:`!__init__` " "function. This happens because there is no other way to give the field an " "initial value." msgstr "" -#: library/dataclasses.rst:694 +#: library/dataclasses.rst:719 msgid "Mutable default values" msgstr "" -#: library/dataclasses.rst:696 +#: library/dataclasses.rst:721 msgid "" "Python stores default member variable values in class attributes. Consider " "this example, not using dataclasses::" msgstr "" -#: library/dataclasses.rst:711 +#: library/dataclasses.rst:724 +msgid "" +"class C:\n" +" x = []\n" +" def add(self, element):\n" +" self.x.append(element)\n" +"\n" +"o1 = C()\n" +"o2 = C()\n" +"o1.add(1)\n" +"o2.add(2)\n" +"assert o1.x == [1, 2]\n" +"assert o1.x is o2.x" +msgstr "" + +#: library/dataclasses.rst:736 msgid "" -"Note that the two instances of class ``C`` share the same class variable " -"``x``, as expected." +"Note that the two instances of class :class:`!C` share the same class " +"variable :attr:`!x`, as expected." msgstr "" -#: library/dataclasses.rst:714 +#: library/dataclasses.rst:739 msgid "Using dataclasses, *if* this code was valid::" msgstr "" -#: library/dataclasses.rst:722 +#: library/dataclasses.rst:741 +msgid "" +"@dataclass\n" +"class D:\n" +" x: list = [] # This code raises ValueError\n" +" def add(self, element):\n" +" self.x.append(element)" +msgstr "" + +#: library/dataclasses.rst:747 msgid "it would generate code similar to::" msgstr "" -#: library/dataclasses.rst:733 +#: library/dataclasses.rst:749 +msgid "" +"class D:\n" +" x = []\n" +" def __init__(self, x=x):\n" +" self.x = x\n" +" def add(self, element):\n" +" self.x.append(element)\n" +"\n" +"assert D().x is D().x" +msgstr "" + +#: library/dataclasses.rst:758 msgid "" -"This has the same issue as the original example using class ``C``. That is, " -"two instances of class ``D`` that do not specify a value for ``x`` when " -"creating a class instance will share the same copy of ``x``. Because " -"dataclasses just use normal Python class creation they also share this " -"behavior. There is no general way for Data Classes to detect this " -"condition. Instead, the :func:`dataclass` decorator will raise a :exc:" -"`ValueError` if it detects an unhashable default parameter. The assumption " -"is that if a value is unhashable, it is mutable. This is a partial " -"solution, but it does protect against many common errors." +"This has the same issue as the original example using class :class:`!C`. " +"That is, two instances of class :class:`!D` that do not specify a value " +"for :attr:`!x` when creating a class instance will share the same copy " +"of :attr:`!x`. Because dataclasses just use normal Python class creation " +"they also share this behavior. There is no general way for Data Classes to " +"detect this condition. Instead, the :func:`@dataclass ` " +"decorator will raise a :exc:`ValueError` if it detects an unhashable default " +"parameter. The assumption is that if a value is unhashable, it is mutable. " +"This is a partial solution, but it does protect against many common errors." msgstr "" -#: library/dataclasses.rst:744 +#: library/dataclasses.rst:769 msgid "" "Using default factory functions is a way to create new instances of mutable " "types as default values for fields::" msgstr "" -#: library/dataclasses.rst:753 +#: library/dataclasses.rst:772 msgid "" -"Instead of looking for and disallowing objects of type ``list``, ``dict``, " -"or ``set``, unhashable objects are now not allowed as default values. " -"Unhashability is used to approximate mutability." +"@dataclass\n" +"class D:\n" +" x: list = field(default_factory=list)\n" +"\n" +"assert D().x is not D().x" msgstr "" -#: library/dataclasses.rst:760 +#: library/dataclasses.rst:778 +msgid "" +"Instead of looking for and disallowing objects of " +"type :class:`list`, :class:`dict`, or :class:`set`, unhashable objects are " +"now not allowed as default values. Unhashability is used to approximate " +"mutability." +msgstr "" + +#: library/dataclasses.rst:785 msgid "Descriptor-typed fields" msgstr "" -#: library/dataclasses.rst:762 +#: library/dataclasses.rst:787 msgid "" "Fields that are assigned :ref:`descriptor objects ` as their " "default value have the following special behaviors:" msgstr "" -#: library/dataclasses.rst:765 +#: library/dataclasses.rst:790 +msgid "" +"The value for the field passed to the dataclass's :meth:`~object.__init__` " +"method is passed to the descriptor's :meth:`~object.__set__` method rather " +"than overwriting the descriptor object." +msgstr "" + +#: library/dataclasses.rst:794 msgid "" -"The value for the field passed to the dataclass's ``__init__`` method is " -"passed to the descriptor's ``__set__`` method rather than overwriting the " -"descriptor object." +"Similarly, when getting or setting the field, the " +"descriptor's :meth:`~object.__get__` or :meth:`!__set__` method is called " +"rather than returning or overwriting the descriptor object." msgstr "" -#: library/dataclasses.rst:768 +#: library/dataclasses.rst:798 msgid "" -"Similarly, when getting or setting the field, the descriptor's ``__get__`` " -"or ``__set__`` method is called rather than returning or overwriting the " -"descriptor object." +"To determine whether a field contains a default value, :func:`@dataclass " +"` will call the descriptor's :meth:`!__get__` method using its " +"class access form: ``descriptor.__get__(obj=None, type=cls)``. If the " +"descriptor returns a value in this case, it will be used as the field's " +"default. On the other hand, if the descriptor raises :exc:`AttributeError` " +"in this situation, no default value will be provided for the field." msgstr "" -#: library/dataclasses.rst:771 +#: library/dataclasses.rst:808 msgid "" -"To determine whether a field contains a default value, ``dataclasses`` will " -"call the descriptor's ``__get__`` method using its class access form (i.e. " -"``descriptor.__get__(obj=None, type=cls)``. If the descriptor returns a " -"value in this case, it will be used as the field's default. On the other " -"hand, if the descriptor raises :exc:`AttributeError` in this situation, no " -"default value will be provided for the field." +"class IntConversionDescriptor:\n" +" def __init__(self, *, default):\n" +" self._default = default\n" +"\n" +" def __set_name__(self, owner, name):\n" +" self._name = \"_\" + name\n" +"\n" +" def __get__(self, obj, type):\n" +" if obj is None:\n" +" return self._default\n" +"\n" +" return getattr(obj, self._name, self._default)\n" +"\n" +" def __set__(self, obj, value):\n" +" setattr(obj, self._name, int(value))\n" +"\n" +"@dataclass\n" +"class InventoryItem:\n" +" quantity_on_hand: IntConversionDescriptor = " +"IntConversionDescriptor(default=100)\n" +"\n" +"i = InventoryItem()\n" +"print(i.quantity_on_hand) # 100\n" +"i.quantity_on_hand = 2.5 # calls __set__ with 2.5\n" +"print(i.quantity_on_hand) # 2" msgstr "" -#: library/dataclasses.rst:806 +#: library/dataclasses.rst:833 msgid "" "Note that if a field is annotated with a descriptor type, but is not " "assigned a descriptor object as its default value, the field will act like a " diff --git a/library/datatypes.po b/library/datatypes.po index 7f48de77..51a8c7a9 100644 --- a/library/datatypes.po +++ b/library/datatypes.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -29,10 +30,11 @@ msgstr "" #: library/datatypes.rst:11 msgid "" -"Python also provides some built-in data types, in particular, :class:" -"`dict`, :class:`list`, :class:`set` and :class:`frozenset`, and :class:" -"`tuple`. The :class:`str` class is used to hold Unicode strings, and the :" -"class:`bytes` and :class:`bytearray` classes are used to hold binary data." +"Python also provides some built-in data types, in " +"particular, :class:`dict`, :class:`list`, :class:`set` " +"and :class:`frozenset`, and :class:`tuple`. The :class:`str` class is used " +"to hold Unicode strings, and the :class:`bytes` and :class:`bytearray` " +"classes are used to hold binary data." msgstr "" #: library/datatypes.rst:17 diff --git a/library/datetime.po b/library/datetime.po index addc0c4e..44e44a8b 100644 --- a/library/datetime.po +++ b/library/datetime.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/datetime.rst:2 -msgid ":mod:`datetime` --- Basic date and time types" +msgid ":mod:`!datetime` --- Basic date and time types" msgstr "" #: library/datetime.rst:11 @@ -40,7 +41,7 @@ msgstr "" msgid "Skip to :ref:`the format codes `." msgstr "" -#: library/datetime.rst:29 +#: library/datetime.rst:28 msgid "Module :mod:`calendar`" msgstr "" @@ -48,7 +49,7 @@ msgstr "" msgid "General calendar related functions." msgstr "" -#: library/datetime.rst:32 +#: library/datetime.rst:31 msgid "Module :mod:`time`" msgstr "" @@ -56,7 +57,7 @@ msgstr "" msgid "Time access and conversions." msgstr "" -#: library/datetime.rst:35 +#: library/datetime.rst:34 msgid "Module :mod:`zoneinfo`" msgstr "" @@ -64,7 +65,7 @@ msgstr "" msgid "Concrete time zones representing the IANA time zone database." msgstr "" -#: library/datetime.rst:38 +#: library/datetime.rst:37 msgid "Package `dateutil `_" msgstr "" @@ -72,15 +73,15 @@ msgstr "" msgid "Third-party library with expanded time zone and parsing support." msgstr "" -#: library/datetime.rst:42 -msgid "Package `DateType `_" +#: library/datetime.rst:40 +msgid "Package :pypi:`DateType`" msgstr "" #: library/datetime.rst:41 msgid "" -"Third-party library that introduces distinct static types to e.g. allow :" -"term:`static type checkers ` to differentiate between " -"naive and aware datetimes." +"Third-party library that introduces distinct static types to e.g. " +"allow :term:`static type checkers ` to differentiate " +"between naive and aware datetimes." msgstr "" #: library/datetime.rst:48 @@ -90,7 +91,7 @@ msgstr "" #: library/datetime.rst:50 msgid "" "Date and time objects may be categorized as \"aware\" or \"naive\" depending " -"on whether or not they include timezone information." +"on whether or not they include time zone information." msgstr "" #: library/datetime.rst:53 @@ -107,7 +108,7 @@ msgid "" "A **naive** object does not contain enough information to unambiguously " "locate itself relative to other date/time objects. Whether a naive object " "represents Coordinated Universal Time (UTC), local time, or time in some " -"other timezone is purely up to the program, just like it is up to the " +"other time zone is purely up to the program, just like it is up to the " "program whether a particular number represents metres, miles, or mass. Naive " "objects are easy to understand and to work with, at the cost of ignoring " "some aspects of reality." @@ -115,20 +116,20 @@ msgstr "" #: library/datetime.rst:66 msgid "" -"For applications requiring aware objects, :class:`.datetime` and :class:`." -"time` objects have an optional time zone information attribute, :attr:`!" -"tzinfo`, that can be set to an instance of a subclass of the abstract :class:" -"`tzinfo` class. These :class:`tzinfo` objects capture information about the " -"offset from UTC time, the time zone name, and whether daylight saving time " -"is in effect." +"For applications requiring aware objects, :class:`.datetime` " +"and :class:`.time` objects have an optional time zone information " +"attribute, :attr:`!tzinfo`, that can be set to an instance of a subclass of " +"the abstract :class:`tzinfo` class. These :class:`tzinfo` objects capture " +"information about the offset from UTC time, the time zone name, and whether " +"daylight saving time is in effect." msgstr "" #: library/datetime.rst:72 msgid "" "Only one concrete :class:`tzinfo` class, the :class:`timezone` class, is " -"supplied by the :mod:`!datetime` module. The :class:`timezone` class can " -"represent simple timezones with fixed offsets from UTC, such as UTC itself " -"or North American EST and EDT timezones. Supporting timezones at deeper " +"supplied by the :mod:`!datetime` module. The :class:`!timezone` class can " +"represent simple time zones with fixed offsets from UTC, such as UTC itself " +"or North American EST and EDT time zones. Supporting time zones at deeper " "levels of detail is up to the application. The rules for time adjustment " "across the world are more political than rational, change frequently, and " "there is no standard suitable for every application aside from UTC." @@ -145,17 +146,17 @@ msgstr "" #: library/datetime.rst:87 msgid "" "The smallest year number allowed in a :class:`date` or :class:`.datetime` " -"object. :const:`MINYEAR` is ``1``." +"object. :const:`MINYEAR` is 1." msgstr "" #: library/datetime.rst:93 msgid "" "The largest year number allowed in a :class:`date` or :class:`.datetime` " -"object. :const:`MAXYEAR` is ``9999``." +"object. :const:`MAXYEAR` is 9999." msgstr "" #: library/datetime.rst:98 -msgid "Alias for the UTC timezone singleton :attr:`datetime.timezone.utc`." +msgid "Alias for the UTC time zone singleton :attr:`datetime.timezone.utc`." msgstr "" #: library/datetime.rst:103 @@ -165,29 +166,30 @@ msgstr "" #: library/datetime.rst:108 msgid "" "An idealized naive date, assuming the current Gregorian calendar always was, " -"and always will be, in effect. Attributes: :attr:`year`, :attr:`month`, and :" -"attr:`day`." +"and always will be, in effect. Attributes: :attr:`year`, :attr:`month`, " +"and :attr:`day`." msgstr "" #: library/datetime.rst:116 msgid "" "An idealized time, independent of any particular day, assuming that every " "day has exactly 24\\*60\\*60 seconds. (There is no notion of \"leap " -"seconds\" here.) Attributes: :attr:`hour`, :attr:`minute`, :attr:`second`, :" -"attr:`microsecond`, and :attr:`.tzinfo`." +"seconds\" here.) " +"Attributes: :attr:`hour`, :attr:`minute`, :attr:`second`, :attr:`microsecond`, " +"and :attr:`.tzinfo`." msgstr "" #: library/datetime.rst:125 msgid "" -"A combination of a date and a time. Attributes: :attr:`year`, :attr:" -"`month`, :attr:`day`, :attr:`hour`, :attr:`minute`, :attr:`second`, :attr:" -"`microsecond`, and :attr:`.tzinfo`." +"A combination of a date and a time. " +"Attributes: :attr:`year`, :attr:`month`, :attr:`day`, :attr:`hour`, :attr:`minute`, :attr:`second`, :attr:`microsecond`, " +"and :attr:`.tzinfo`." msgstr "" #: library/datetime.rst:133 msgid "" -"A duration expressing the difference between two :class:`.datetime` or :" -"class:`date` instances to microsecond resolution." +"A duration expressing the difference between two :class:`.datetime` " +"or :class:`date` instances to microsecond resolution." msgstr "" #: library/datetime.rst:140 @@ -212,6 +214,17 @@ msgstr "" msgid "Subclass relationships::" msgstr "" +#: library/datetime.rst:157 +msgid "" +"object\n" +" timedelta\n" +" tzinfo\n" +" timezone\n" +" time\n" +" date\n" +" datetime" +msgstr "" + #: library/datetime.rst:166 msgid "Common Properties" msgstr "" @@ -248,7 +261,8 @@ msgid "" msgstr "" #: library/datetime.rst:183 -msgid "A :class:`.datetime` object *d* is aware if both of the following hold:" +msgid "" +"A :class:`.datetime` object ``d`` is aware if both of the following hold:" msgstr "" #: library/datetime.rst:185 @@ -260,11 +274,11 @@ msgid "``d.tzinfo.utcoffset(d)`` does not return ``None``" msgstr "" #: library/datetime.rst:188 -msgid "Otherwise, *d* is naive." +msgid "Otherwise, ``d`` is naive." msgstr "" #: library/datetime.rst:190 -msgid "A :class:`.time` object *t* is aware if both of the following hold:" +msgid "A :class:`.time` object ``t`` is aware if both of the following hold:" msgstr "" #: library/datetime.rst:192 @@ -276,7 +290,7 @@ msgid "``t.tzinfo.utcoffset(None)`` does not return ``None``." msgstr "" #: library/datetime.rst:195 -msgid "Otherwise, *t* is naive." +msgid "Otherwise, ``t`` is naive." msgstr "" #: library/datetime.rst:197 @@ -297,8 +311,8 @@ msgstr "" #: library/datetime.rst:210 msgid "" -"All arguments are optional and default to ``0``. Arguments may be integers " -"or floats, and may be positive or negative." +"All arguments are optional and default to 0. Arguments may be integers or " +"floats, and may be positive or negative." msgstr "" #: library/datetime.rst:213 @@ -348,6 +362,23 @@ msgid "" "resulting attributes::" msgstr "" +#: library/datetime.rst:232 +msgid "" +">>> from datetime import timedelta\n" +">>> delta = timedelta(\n" +"... days=50,\n" +"... seconds=27,\n" +"... microseconds=10,\n" +"... milliseconds=29000,\n" +"... minutes=5,\n" +"... hours=8,\n" +"... weeks=2\n" +"... )\n" +">>> # Only days, seconds, and microseconds remain\n" +">>> delta\n" +"datetime.timedelta(days=64, seconds=29156, microseconds=10)" +msgstr "" + #: library/datetime.rst:246 msgid "" "If any argument is a float and there are fractional microseconds, the " @@ -359,8 +390,8 @@ msgstr "" #: library/datetime.rst:253 msgid "" -"If the normalized value of days lies outside the indicated range, :exc:" -"`OverflowError` is raised." +"If the normalized value of days lies outside the indicated " +"range, :exc:`OverflowError` is raised." msgstr "" #: library/datetime.rst:256 @@ -369,7 +400,15 @@ msgid "" "example::" msgstr "" -#: library/datetime.rst:546 library/datetime.rst:1696 library/datetime.rst:2298 +#: library/datetime.rst:259 +msgid "" +">>> from datetime import timedelta\n" +">>> d = timedelta(microseconds=-1)\n" +">>> (d.days, d.seconds, d.microseconds)\n" +"(-1, 86399, 999999)" +msgstr "" + +#: library/datetime.rst:566 library/datetime.rst:1720 library/datetime.rst:2322 msgid "Class attributes:" msgstr "" @@ -391,457 +430,504 @@ msgstr "" #: library/datetime.rst:283 msgid "" -"Note that, because of normalization, ``timedelta.max`` > ``-timedelta.min``. " -"``-timedelta.max`` is not representable as a :class:`timedelta` object." +"Note that, because of normalization, ``timedelta.max`` is greater than ``-" +"timedelta.min``. ``-timedelta.max`` is not representable as " +"a :class:`timedelta` object." msgstr "" -#: library/datetime.rst:564 library/datetime.rst:1716 +#: library/datetime.rst:584 library/datetime.rst:1740 msgid "Instance attributes (read-only):" msgstr "" -#: library/datetime.rst:289 -msgid "Attribute" -msgstr "" - -#: library/datetime.rst:289 -msgid "Value" -msgstr "" - #: library/datetime.rst:291 -msgid "``days``" +msgid "Between -999,999,999 and 999,999,999 inclusive." msgstr "" -#: library/datetime.rst:291 -msgid "Between -999999999 and 999999999 inclusive" +#: library/datetime.rst:296 +msgid "Between 0 and 86,399 inclusive." msgstr "" -#: library/datetime.rst:293 -msgid "``seconds``" -msgstr "" - -#: library/datetime.rst:293 -msgid "Between 0 and 86399 inclusive" +#: library/datetime.rst:300 +msgid "" +"It is a somewhat common bug for code to unintentionally use this attribute " +"when it is actually intended to get a :meth:`~timedelta.total_seconds` value " +"instead:" msgstr "" -#: library/datetime.rst:295 -msgid "``microseconds``" +#: library/datetime.rst:304 +msgid "" +">>> from datetime import timedelta\n" +">>> duration = timedelta(seconds=11235813)\n" +">>> duration.days, duration.seconds\n" +"(130, 3813)\n" +">>> duration.total_seconds()\n" +"11235813.0" msgstr "" -#: library/datetime.rst:295 -msgid "Between 0 and 999999 inclusive" +#: library/datetime.rst:315 +msgid "Between 0 and 999,999 inclusive." msgstr "" -#: library/datetime.rst:581 library/datetime.rst:1138 +#: library/datetime.rst:601 library/datetime.rst:1162 msgid "Supported operations:" msgstr "" -#: library/datetime.rst:584 library/datetime.rst:1141 +#: library/datetime.rst:604 library/datetime.rst:1165 msgid "Operation" msgstr "" -#: library/datetime.rst:584 library/datetime.rst:1141 +#: library/datetime.rst:604 library/datetime.rst:1165 msgid "Result" msgstr "" -#: library/datetime.rst:305 +#: library/datetime.rst:325 msgid "``t1 = t2 + t3``" msgstr "" -#: library/datetime.rst:305 +#: library/datetime.rst:325 msgid "" -"Sum of *t2* and *t3*. Afterwards *t1*-*t2* == *t3* and *t1*-*t3* == *t2* are " -"true. (1)" +"Sum of ``t2`` and ``t3``. Afterwards ``t1 - t2 == t3`` and ``t1 - t3 == t2`` " +"are true. (1)" msgstr "" -#: library/datetime.rst:308 +#: library/datetime.rst:329 msgid "``t1 = t2 - t3``" msgstr "" -#: library/datetime.rst:308 +#: library/datetime.rst:329 msgid "" -"Difference of *t2* and *t3*. Afterwards *t1* == *t2* - *t3* and *t2* == *t1* " -"+ *t3* are true. (1)(6)" +"Difference of ``t2`` and ``t3``. Afterwards ``t1 == t2 - t3`` and ``t2 == " +"t1 + t3`` are true. (1)(6)" msgstr "" -#: library/datetime.rst:312 +#: library/datetime.rst:333 msgid "``t1 = t2 * i or t1 = i * t2``" msgstr "" -#: library/datetime.rst:312 +#: library/datetime.rst:333 msgid "" -"Delta multiplied by an integer. Afterwards *t1* // i == *t2* is true, " +"Delta multiplied by an integer. Afterwards ``t1 // i == t2`` is true, " "provided ``i != 0``." msgstr "" -#: library/datetime.rst:316 -msgid "In general, *t1* \\* i == *t1* \\* (i-1) + *t1* is true. (1)" +#: library/datetime.rst:337 +msgid "In general, ``t1 * i == t1 * (i-1) + t1`` is true. (1)" msgstr "" -#: library/datetime.rst:319 +#: library/datetime.rst:340 msgid "``t1 = t2 * f or t1 = f * t2``" msgstr "" -#: library/datetime.rst:319 +#: library/datetime.rst:340 msgid "" "Delta multiplied by a float. The result is rounded to the nearest multiple " "of timedelta.resolution using round-half-to-even." msgstr "" -#: library/datetime.rst:323 +#: library/datetime.rst:344 msgid "``f = t2 / t3``" msgstr "" -#: library/datetime.rst:323 +#: library/datetime.rst:344 msgid "" -"Division (3) of overall duration *t2* by interval unit *t3*. Returns a :" -"class:`float` object." +"Division (3) of overall duration ``t2`` by interval unit ``t3``. Returns " +"a :class:`float` object." msgstr "" -#: library/datetime.rst:327 +#: library/datetime.rst:348 msgid "``t1 = t2 / f or t1 = t2 / i``" msgstr "" -#: library/datetime.rst:327 +#: library/datetime.rst:348 msgid "" "Delta divided by a float or an int. The result is rounded to the nearest " "multiple of timedelta.resolution using round-half-to-even." msgstr "" -#: library/datetime.rst:331 +#: library/datetime.rst:352 msgid "``t1 = t2 // i`` or ``t1 = t2 // t3``" msgstr "" -#: library/datetime.rst:331 +#: library/datetime.rst:352 msgid "" "The floor is computed and the remainder (if any) is thrown away. In the " "second case, an integer is returned. (3)" msgstr "" -#: library/datetime.rst:335 +#: library/datetime.rst:356 msgid "``t1 = t2 % t3``" msgstr "" -#: library/datetime.rst:335 +#: library/datetime.rst:356 msgid "The remainder is computed as a :class:`timedelta` object. (3)" msgstr "" -#: library/datetime.rst:338 +#: library/datetime.rst:359 msgid "``q, r = divmod(t1, t2)``" msgstr "" -#: library/datetime.rst:338 +#: library/datetime.rst:359 msgid "" "Computes the quotient and the remainder: ``q = t1 // t2`` (3) and ``r = t1 % " -"t2``. q is an integer and r is a :class:`timedelta` object." +"t2``. ``q`` is an integer and ``r`` is a :class:`timedelta` object." msgstr "" -#: library/datetime.rst:343 +#: library/datetime.rst:364 msgid "``+t1``" msgstr "" -#: library/datetime.rst:343 +#: library/datetime.rst:364 msgid "Returns a :class:`timedelta` object with the same value. (2)" msgstr "" -#: library/datetime.rst:346 +#: library/datetime.rst:367 msgid "``-t1``" msgstr "" -#: library/datetime.rst:346 +#: library/datetime.rst:367 msgid "" -"equivalent to :class:`timedelta`\\ (-*t1.days*, -*t1.seconds*, -*t1." -"microseconds*), and to *t1*\\* -1. (1)(4)" +"Equivalent to ``timedelta(-t1.days, -t1.seconds, -t1.microseconds)``, and to " +"``t1 * -1``. (1)(4)" msgstr "" -#: library/datetime.rst:351 +#: library/datetime.rst:371 msgid "``abs(t)``" msgstr "" -#: library/datetime.rst:351 +#: library/datetime.rst:371 msgid "" -"equivalent to +\\ *t* when ``t.days >= 0``, and to -*t* when ``t.days < 0``. " -"(2)" +"Equivalent to ``+t`` when ``t.days >= 0``, and to ``-t`` when ``t.days < " +"0``. (2)" msgstr "" -#: library/datetime.rst:354 +#: library/datetime.rst:374 msgid "``str(t)``" msgstr "" -#: library/datetime.rst:354 +#: library/datetime.rst:374 msgid "" "Returns a string in the form ``[D day[s], ][H]H:MM:SS[.UUUUUU]``, where D is " "negative for negative ``t``. (5)" msgstr "" -#: library/datetime.rst:358 +#: library/datetime.rst:378 msgid "``repr(t)``" msgstr "" -#: library/datetime.rst:358 +#: library/datetime.rst:378 msgid "" "Returns a string representation of the :class:`timedelta` object as a " "constructor call with canonical attribute values." msgstr "" -#: library/datetime.rst:603 library/datetime.rst:2529 +#: library/datetime.rst:623 library/datetime.rst:2553 msgid "Notes:" msgstr "" -#: library/datetime.rst:367 +#: library/datetime.rst:387 msgid "This is exact but may overflow." msgstr "" -#: library/datetime.rst:370 +#: library/datetime.rst:390 msgid "This is exact and cannot overflow." msgstr "" -#: library/datetime.rst:373 -msgid "Division by 0 raises :exc:`ZeroDivisionError`." +#: library/datetime.rst:393 +msgid "Division by zero raises :exc:`ZeroDivisionError`." msgstr "" -#: library/datetime.rst:376 -msgid "-*timedelta.max* is not representable as a :class:`timedelta` object." +#: library/datetime.rst:396 +msgid "``-timedelta.max`` is not representable as a :class:`timedelta` object." msgstr "" -#: library/datetime.rst:379 +#: library/datetime.rst:399 msgid "" "String representations of :class:`timedelta` objects are normalized " "similarly to their internal representation. This leads to somewhat unusual " "results for negative timedeltas. For example::" msgstr "" -#: library/datetime.rst:389 +#: library/datetime.rst:403 +msgid "" +">>> timedelta(hours=-5)\n" +"datetime.timedelta(days=-1, seconds=68400)\n" +">>> print(_)\n" +"-1 day, 19:00:00" +msgstr "" + +#: library/datetime.rst:409 msgid "" "The expression ``t2 - t3`` will always be equal to the expression ``t2 + (-" "t3)`` except when t3 is equal to ``timedelta.max``; in that case the former " "will produce a result while the latter will overflow." msgstr "" -#: library/datetime.rst:393 +#: library/datetime.rst:413 msgid "" "In addition to the operations listed above, :class:`timedelta` objects " -"support certain additions and subtractions with :class:`date` and :class:`." -"datetime` objects (see below)." +"support certain additions and subtractions with :class:`date` " +"and :class:`.datetime` objects (see below)." msgstr "" -#: library/datetime.rst:397 +#: library/datetime.rst:417 msgid "" -"Floor division and true division of a :class:`timedelta` object by another :" -"class:`timedelta` object are now supported, as are remainder operations and " -"the :func:`divmod` function. True division and multiplication of a :class:" -"`timedelta` object by a :class:`float` object are now supported." +"Floor division and true division of a :class:`timedelta` object by " +"another :class:`timedelta` object are now supported, as are remainder " +"operations and the :func:`divmod` function. True division and multiplication " +"of a :class:`timedelta` object by a :class:`float` object are now supported." msgstr "" -#: library/datetime.rst:403 +#: library/datetime.rst:423 msgid ":class:`timedelta` objects support equality and order comparisons." msgstr "" -#: library/datetime.rst:405 +#: library/datetime.rst:425 msgid "" "In Boolean contexts, a :class:`timedelta` object is considered to be true if " "and only if it isn't equal to ``timedelta(0)``." msgstr "" -#: library/datetime.rst:629 library/datetime.rst:1823 +#: library/datetime.rst:649 library/datetime.rst:1847 msgid "Instance methods:" msgstr "" -#: library/datetime.rst:412 +#: library/datetime.rst:432 msgid "" "Return the total number of seconds contained in the duration. Equivalent to " "``td / timedelta(seconds=1)``. For interval units other than seconds, use " "the division form directly (e.g. ``td / timedelta(microseconds=1)``)." msgstr "" -#: library/datetime.rst:416 +#: library/datetime.rst:436 msgid "" "Note that for very large time intervals (greater than 270 years on most " "platforms) this method will lose microsecond accuracy." msgstr "" -#: library/datetime.rst:422 +#: library/datetime.rst:442 msgid "Examples of usage: :class:`timedelta`" msgstr "" -#: library/datetime.rst:424 +#: library/datetime.rst:444 msgid "An additional example of normalization::" msgstr "" -#: library/datetime.rst:436 +#: library/datetime.rst:446 +msgid "" +">>> # Components of another_year add up to exactly 365 days\n" +">>> from datetime import timedelta\n" +">>> year = timedelta(days=365)\n" +">>> another_year = timedelta(weeks=40, days=84, hours=23,\n" +"... minutes=50, seconds=600)\n" +">>> year == another_year\n" +"True\n" +">>> year.total_seconds()\n" +"31536000.0" +msgstr "" + +#: library/datetime.rst:456 msgid "Examples of :class:`timedelta` arithmetic::" msgstr "" -#: library/datetime.rst:455 +#: library/datetime.rst:458 +msgid "" +">>> from datetime import timedelta\n" +">>> year = timedelta(days=365)\n" +">>> ten_years = 10 * year\n" +">>> ten_years\n" +"datetime.timedelta(days=3650)\n" +">>> ten_years.days // 365\n" +"10\n" +">>> nine_years = ten_years - year\n" +">>> nine_years\n" +"datetime.timedelta(days=3285)\n" +">>> three_years = nine_years // 3\n" +">>> three_years, three_years.days // 365\n" +"(datetime.timedelta(days=1095), 3)" +msgstr "" + +#: library/datetime.rst:475 msgid ":class:`date` Objects" msgstr "" -#: library/datetime.rst:457 +#: library/datetime.rst:477 msgid "" "A :class:`date` object represents a date (year, month and day) in an " "idealized calendar, the current Gregorian calendar indefinitely extended in " "both directions." msgstr "" -#: library/datetime.rst:461 +#: library/datetime.rst:481 msgid "" "January 1 of year 1 is called day number 1, January 2 of year 1 is called " "day number 2, and so on. [#]_" msgstr "" -#: library/datetime.rst:466 +#: library/datetime.rst:486 msgid "" "All arguments are required. Arguments must be integers, in the following " "ranges:" msgstr "" -#: library/datetime.rst:469 +#: library/datetime.rst:489 msgid "``MINYEAR <= year <= MAXYEAR``" msgstr "" -#: library/datetime.rst:470 +#: library/datetime.rst:490 msgid "``1 <= month <= 12``" msgstr "" -#: library/datetime.rst:471 +#: library/datetime.rst:491 msgid "``1 <= day <= number of days in the given month and year``" msgstr "" -#: library/datetime.rst:844 +#: library/datetime.rst:864 msgid "" "If an argument outside those ranges is given, :exc:`ValueError` is raised." msgstr "" -#: library/datetime.rst:849 +#: library/datetime.rst:869 msgid "Other constructors, all class methods:" msgstr "" -#: library/datetime.rst:480 +#: library/datetime.rst:500 msgid "Return the current local date." msgstr "" -#: library/datetime.rst:482 +#: library/datetime.rst:502 msgid "This is equivalent to ``date.fromtimestamp(time.time())``." msgstr "" -#: library/datetime.rst:486 +#: library/datetime.rst:506 msgid "" "Return the local date corresponding to the POSIX timestamp, such as is " "returned by :func:`time.time`." msgstr "" -#: library/datetime.rst:489 +#: library/datetime.rst:509 msgid "" "This may raise :exc:`OverflowError`, if the timestamp is out of the range of " -"values supported by the platform C :c:func:`localtime` function, and :exc:" -"`OSError` on :c:func:`localtime` failure. It's common for this to be " -"restricted to years from 1970 through 2038. Note that on non-POSIX systems " -"that include leap seconds in their notion of a timestamp, leap seconds are " -"ignored by :meth:`fromtimestamp`." +"values supported by the platform C :c:func:`localtime` function, " +"and :exc:`OSError` on :c:func:`localtime` failure. It's common for this to " +"be restricted to years from 1970 through 2038. Note that on non-POSIX " +"systems that include leap seconds in their notion of a timestamp, leap " +"seconds are ignored by :meth:`fromtimestamp`." msgstr "" -#: library/datetime.rst:496 +#: library/datetime.rst:516 msgid "" "Raise :exc:`OverflowError` instead of :exc:`ValueError` if the timestamp is " "out of the range of values supported by the platform C :c:func:`localtime` " -"function. Raise :exc:`OSError` instead of :exc:`ValueError` on :c:func:" -"`localtime` failure." +"function. Raise :exc:`OSError` instead of :exc:`ValueError` " +"on :c:func:`localtime` failure." msgstr "" -#: library/datetime.rst:505 +#: library/datetime.rst:525 msgid "" "Return the date corresponding to the proleptic Gregorian ordinal, where " "January 1 of year 1 has ordinal 1." msgstr "" -#: library/datetime.rst:508 +#: library/datetime.rst:528 msgid "" ":exc:`ValueError` is raised unless ``1 <= ordinal <= date.max.toordinal()``. " -"For any date *d*, ``date.fromordinal(d.toordinal()) == d``." +"For any date ``d``, ``date.fromordinal(d.toordinal()) == d``." msgstr "" -#: library/datetime.rst:515 +#: library/datetime.rst:535 msgid "" "Return a :class:`date` corresponding to a *date_string* given in any valid " "ISO 8601 format, with the following exceptions:" msgstr "" -#: library/datetime.rst:1005 +#: library/datetime.rst:1029 msgid "" "Reduced precision dates are not currently supported (``YYYY-MM``, ``YYYY``)." msgstr "" -#: library/datetime.rst:1007 +#: library/datetime.rst:1031 msgid "" "Extended date representations are not currently supported (``±YYYYYY-MM-" "DD``)." msgstr "" -#: library/datetime.rst:1009 +#: library/datetime.rst:1033 msgid "Ordinal dates are not currently supported (``YYYY-OOO``)." msgstr "" -#: library/datetime.rst:1011 library/datetime.rst:1452 +#: library/datetime.rst:1035 library/datetime.rst:1476 msgid "Examples::" msgstr "" -#: library/datetime.rst:535 +#: library/datetime.rst:546 +msgid "" +">>> from datetime import date\n" +">>> date.fromisoformat('2019-12-04')\n" +"datetime.date(2019, 12, 4)\n" +">>> date.fromisoformat('20191204')\n" +"datetime.date(2019, 12, 4)\n" +">>> date.fromisoformat('2021-W01-1')\n" +"datetime.date(2021, 1, 4)" +msgstr "" + +#: library/datetime.rst:555 msgid "Previously, this method only supported the format ``YYYY-MM-DD``." msgstr "" -#: library/datetime.rst:540 +#: library/datetime.rst:560 msgid "" "Return a :class:`date` corresponding to the ISO calendar date specified by " -"year, week and day. This is the inverse of the function :meth:`date." -"isocalendar`." +"year, week and day. This is the inverse of the " +"function :meth:`date.isocalendar`." msgstr "" -#: library/datetime.rst:550 +#: library/datetime.rst:570 msgid "The earliest representable date, ``date(MINYEAR, 1, 1)``." msgstr "" -#: library/datetime.rst:555 +#: library/datetime.rst:575 msgid "The latest representable date, ``date(MAXYEAR, 12, 31)``." msgstr "" -#: library/datetime.rst:560 +#: library/datetime.rst:580 msgid "" "The smallest possible difference between non-equal date objects, " "``timedelta(days=1)``." msgstr "" -#: library/datetime.rst:1089 +#: library/datetime.rst:1113 msgid "Between :const:`MINYEAR` and :const:`MAXYEAR` inclusive." msgstr "" -#: library/datetime.rst:1094 +#: library/datetime.rst:1118 msgid "Between 1 and 12 inclusive." msgstr "" -#: library/datetime.rst:1099 +#: library/datetime.rst:1123 msgid "Between 1 and the number of days in the given month of the given year." msgstr "" -#: library/datetime.rst:586 +#: library/datetime.rst:606 msgid "``date2 = date1 + timedelta``" msgstr "" -#: library/datetime.rst:586 -msgid "*date2* will be ``timedelta.days`` days after *date1*. (1)" +#: library/datetime.rst:606 +msgid "``date2`` will be ``timedelta.days`` days after ``date1``. (1)" msgstr "" -#: library/datetime.rst:589 +#: library/datetime.rst:609 msgid "``date2 = date1 - timedelta``" msgstr "" -#: library/datetime.rst:589 -msgid "Computes *date2* such that ``date2 + timedelta == date1``. (2)" +#: library/datetime.rst:609 +msgid "Computes ``date2`` such that ``date2 + timedelta == date1``. (2)" msgstr "" -#: library/datetime.rst:592 +#: library/datetime.rst:612 msgid "``timedelta = date1 - date2``" msgstr "" -#: library/datetime.rst:1147 +#: library/datetime.rst:1171 msgid "\\(3)" msgstr "" @@ -853,7 +939,7 @@ msgstr "" msgid "``date1 != date2``" msgstr "" -#: library/datetime.rst:1149 +#: library/datetime.rst:1173 msgid "Equality comparison. (4)" msgstr "" @@ -873,108 +959,121 @@ msgstr "" msgid "``date1 >= date2``" msgstr "" -#: library/datetime.rst:1152 +#: library/datetime.rst:1176 msgid "Order comparison. (5)" msgstr "" -#: library/datetime.rst:606 +#: library/datetime.rst:626 msgid "" "*date2* is moved forward in time if ``timedelta.days > 0``, or backward if " "``timedelta.days < 0``. Afterward ``date2 - date1 == timedelta.days``. " -"``timedelta.seconds`` and ``timedelta.microseconds`` are ignored. :exc:" -"`OverflowError` is raised if ``date2.year`` would be smaller than :const:" -"`MINYEAR` or larger than :const:`MAXYEAR`." +"``timedelta.seconds`` and ``timedelta.microseconds`` are " +"ignored. :exc:`OverflowError` is raised if ``date2.year`` would be smaller " +"than :const:`MINYEAR` or larger than :const:`MAXYEAR`." msgstr "" -#: library/datetime.rst:613 +#: library/datetime.rst:633 msgid "``timedelta.seconds`` and ``timedelta.microseconds`` are ignored." msgstr "" -#: library/datetime.rst:616 +#: library/datetime.rst:636 msgid "" -"This is exact, and cannot overflow. timedelta.seconds and timedelta." -"microseconds are 0, and date2 + timedelta == date1 after." +"This is exact, and cannot overflow. ``timedelta.seconds`` and " +"``timedelta.microseconds`` are 0, and ``date2 + timedelta == date1`` after." msgstr "" -#: library/datetime.rst:620 +#: library/datetime.rst:640 msgid ":class:`date` objects are equal if they represent the same date." msgstr "" -#: library/datetime.rst:623 +#: library/datetime.rst:643 msgid "" "*date1* is considered less than *date2* when *date1* precedes *date2* in " "time. In other words, ``date1 < date2`` if and only if ``date1.toordinal() < " "date2.toordinal()``." msgstr "" -#: library/datetime.rst:627 +#: library/datetime.rst:647 msgid "" "In Boolean contexts, all :class:`date` objects are considered to be true." msgstr "" -#: library/datetime.rst:633 +#: library/datetime.rst:653 msgid "" "Return a date with the same value, except for those parameters given new " "values by whichever keyword arguments are specified." msgstr "" -#: library/datetime.rst:1866 +#: library/datetime.rst:1890 msgid "Example::" msgstr "" -#: library/datetime.rst:1337 +#: library/datetime.rst:658 +msgid "" +">>> from datetime import date\n" +">>> d = date(2002, 12, 31)\n" +">>> d.replace(day=26)\n" +"datetime.date(2002, 12, 26)" +msgstr "" + +#: library/datetime.rst:1361 msgid "" -"Return a :class:`time.struct_time` such as returned by :func:`time." -"localtime`." +"Return a :class:`time.struct_time` such as returned " +"by :func:`time.localtime`." msgstr "" -#: library/datetime.rst:648 +#: library/datetime.rst:668 msgid "The hours, minutes and seconds are 0, and the DST flag is -1." msgstr "" -#: library/datetime.rst:1339 +#: library/datetime.rst:1363 msgid "``d.timetuple()`` is equivalent to::" msgstr "" -#: library/datetime.rst:654 +#: library/datetime.rst:672 +msgid "" +"time.struct_time((d.year, d.month, d.day, 0, 0, 0, d.weekday(), yday, -1))" +msgstr "" + +#: library/datetime.rst:674 msgid "" "where ``yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1`` is the " -"day number within the current year starting with ``1`` for January 1st." +"day number within the current year starting with 1 for January 1st." msgstr "" -#: library/datetime.rst:660 +#: library/datetime.rst:680 msgid "" "Return the proleptic Gregorian ordinal of the date, where January 1 of year " -"1 has ordinal 1. For any :class:`date` object *d*, ``date.fromordinal(d." -"toordinal()) == d``." +"1 has ordinal 1. For any :class:`date` object ``d``, " +"``date.fromordinal(d.toordinal()) == d``." msgstr "" -#: library/datetime.rst:667 +#: library/datetime.rst:687 msgid "" "Return the day of the week as an integer, where Monday is 0 and Sunday is 6. " -"For example, ``date(2002, 12, 4).weekday() == 2``, a Wednesday. See also :" -"meth:`isoweekday`." +"For example, ``date(2002, 12, 4).weekday() == 2``, a Wednesday. See " +"also :meth:`isoweekday`." msgstr "" -#: library/datetime.rst:674 +#: library/datetime.rst:694 msgid "" "Return the day of the week as an integer, where Monday is 1 and Sunday is 7. " -"For example, ``date(2002, 12, 4).isoweekday() == 3``, a Wednesday. See also :" -"meth:`weekday`, :meth:`isocalendar`." +"For example, ``date(2002, 12, 4).isoweekday() == 3``, a Wednesday. See " +"also :meth:`weekday`, :meth:`isocalendar`." msgstr "" -#: library/datetime.rst:681 +#: library/datetime.rst:701 msgid "" "Return a :term:`named tuple` object with three components: ``year``, " "``week`` and ``weekday``." msgstr "" -#: library/datetime.rst:684 +#: library/datetime.rst:704 msgid "" "The ISO calendar is a widely used variant of the Gregorian calendar. [#]_" msgstr "" -#: library/datetime.rst:686 +#: library/datetime.rst:706 msgid "" "The ISO year consists of 52 or 53 full weeks, and where a week starts on a " "Monday and ends on a Sunday. The first week of an ISO year is the first " @@ -983,49 +1082,76 @@ msgid "" "Gregorian year." msgstr "" -#: library/datetime.rst:691 +#: library/datetime.rst:711 msgid "" "For example, 2004 begins on a Thursday, so the first week of ISO year 2004 " "begins on Monday, 29 Dec 2003 and ends on Sunday, 4 Jan 2004::" msgstr "" -#: library/datetime.rst:700 +#: library/datetime.rst:714 +msgid "" +">>> from datetime import date\n" +">>> date(2003, 12, 29).isocalendar()\n" +"datetime.IsoCalendarDate(year=2004, week=1, weekday=1)\n" +">>> date(2004, 1, 4).isocalendar()\n" +"datetime.IsoCalendarDate(year=2004, week=1, weekday=7)" +msgstr "" + +#: library/datetime.rst:720 msgid "Result changed from a tuple to a :term:`named tuple`." msgstr "" -#: library/datetime.rst:705 +#: library/datetime.rst:725 msgid "" "Return a string representing the date in ISO 8601 format, ``YYYY-MM-DD``::" msgstr "" -#: library/datetime.rst:713 -msgid "For a date *d*, ``str(d)`` is equivalent to ``d.isoformat()``." +#: library/datetime.rst:727 +msgid "" +">>> from datetime import date\n" +">>> date(2002, 12, 4).isoformat()\n" +"'2002-12-04'" +msgstr "" + +#: library/datetime.rst:733 +msgid "For a date ``d``, ``str(d)`` is equivalent to ``d.isoformat()``." msgstr "" -#: library/datetime.rst:718 +#: library/datetime.rst:738 msgid "Return a string representing the date::" msgstr "" -#: library/datetime.rst:1523 +#: library/datetime.rst:740 +msgid "" +">>> from datetime import date\n" +">>> date(2002, 12, 4).ctime()\n" +"'Wed Dec 4 00:00:00 2002'" +msgstr "" + +#: library/datetime.rst:1547 msgid "``d.ctime()`` is equivalent to::" msgstr "" -#: library/datetime.rst:728 +#: library/datetime.rst:1549 +msgid "time.ctime(time.mktime(d.timetuple()))" +msgstr "" + +#: library/datetime.rst:748 msgid "" -"on platforms where the native C :c:func:`ctime` function (which :func:`time." -"ctime` invokes, but which :meth:`date.ctime` does not invoke) conforms to " -"the C standard." +"on platforms where the native C :c:func:`ctime` function " +"(which :func:`time.ctime` invokes, but which :meth:`date.ctime` does not " +"invoke) conforms to the C standard." msgstr "" -#: library/datetime.rst:735 +#: library/datetime.rst:755 msgid "" "Return a string representing the date, controlled by an explicit format " "string. Format codes referring to hours, minutes or seconds will see 0 " -"values. See also :ref:`strftime-strptime-behavior` and :meth:`date." -"isoformat`." +"values. See also :ref:`strftime-strptime-behavior` " +"and :meth:`date.isoformat`." msgstr "" -#: library/datetime.rst:742 +#: library/datetime.rst:762 msgid "" "Same as :meth:`.date.strftime`. This makes it possible to specify a format " "string for a :class:`.date` object in :ref:`formatted string literals >> import time\n" +">>> from datetime import date\n" +">>> today = date.today()\n" +">>> today\n" +"datetime.date(2007, 12, 5)\n" +">>> today == date.fromtimestamp(time.time())\n" +"True\n" +">>> my_birthday = date(today.year, 6, 24)\n" +">>> if my_birthday < today:\n" +"... my_birthday = my_birthday.replace(year=today.year + 1)\n" +"...\n" +">>> my_birthday\n" +"datetime.date(2008, 6, 24)\n" +">>> time_to_birthday = abs(my_birthday - today)\n" +">>> time_to_birthday.days\n" +"202" +msgstr "" + +#: library/datetime.rst:789 msgid "More examples of working with :class:`date`:" msgstr "" -#: library/datetime.rst:818 +#: library/datetime.rst:791 +msgid "" +">>> from datetime import date\n" +">>> d = date.fromordinal(730920) # 730920th day after 1. 1. 0001\n" +">>> d\n" +"datetime.date(2002, 3, 11)\n" +"\n" +">>> # Methods related to formatting string output\n" +">>> d.isoformat()\n" +"'2002-03-11'\n" +">>> d.strftime(\"%d/%m/%y\")\n" +"'11/03/02'\n" +">>> d.strftime(\"%A %d. %B %Y\")\n" +"'Monday 11. March 2002'\n" +">>> d.ctime()\n" +"'Mon Mar 11 00:00:00 2002'\n" +">>> 'The {1} is {0:%d}, the {2} is {0:%B}.'.format(d, \"day\", \"month\")\n" +"'The day is 11, the month is March.'\n" +"\n" +">>> # Methods for to extracting 'components' under different calendars\n" +">>> t = d.timetuple()\n" +">>> for i in t: \n" +"... print(i)\n" +"2002 # year\n" +"3 # month\n" +"11 # day\n" +"0\n" +"0\n" +"0\n" +"0 # weekday (0 = Monday)\n" +"70 # 70th day in the year\n" +"-1\n" +">>> ic = d.isocalendar()\n" +">>> for i in ic: \n" +"... print(i)\n" +"2002 # ISO year\n" +"11 # ISO week number\n" +"1 # ISO day number ( 1 = Monday )\n" +"\n" +">>> # A date object is immutable; all operations produce a new object\n" +">>> d.replace(year=2005)\n" +"datetime.date(2005, 3, 11)" +msgstr "" + +#: library/datetime.rst:838 msgid ":class:`.datetime` Objects" msgstr "" -#: library/datetime.rst:820 +#: library/datetime.rst:840 msgid "" "A :class:`.datetime` object is a single object containing all the " "information from a :class:`date` object and a :class:`.time` object." msgstr "" -#: library/datetime.rst:823 +#: library/datetime.rst:843 msgid "" "Like a :class:`date` object, :class:`.datetime` assumes the current " "Gregorian calendar extended in both directions; like a :class:`.time` " @@ -1063,105 +1253,116 @@ msgid "" "every day." msgstr "" -#: library/datetime.rst:827 +#: library/datetime.rst:847 msgid "Constructor:" msgstr "" -#: library/datetime.rst:831 +#: library/datetime.rst:851 msgid "" "The *year*, *month* and *day* arguments are required. *tzinfo* may be " "``None``, or an instance of a :class:`tzinfo` subclass. The remaining " "arguments must be integers in the following ranges:" msgstr "" -#: library/datetime.rst:835 +#: library/datetime.rst:855 msgid "``MINYEAR <= year <= MAXYEAR``," msgstr "" -#: library/datetime.rst:836 +#: library/datetime.rst:856 msgid "``1 <= month <= 12``," msgstr "" -#: library/datetime.rst:837 +#: library/datetime.rst:857 msgid "``1 <= day <= number of days in the given month and year``," msgstr "" -#: library/datetime.rst:1687 +#: library/datetime.rst:1711 msgid "``0 <= hour < 24``," msgstr "" -#: library/datetime.rst:1688 +#: library/datetime.rst:1712 msgid "``0 <= minute < 60``," msgstr "" -#: library/datetime.rst:1689 +#: library/datetime.rst:1713 msgid "``0 <= second < 60``," msgstr "" -#: library/datetime.rst:1690 +#: library/datetime.rst:1714 msgid "``0 <= microsecond < 1000000``," msgstr "" -#: library/datetime.rst:1691 +#: library/datetime.rst:1715 msgid "``fold in [0, 1]``." msgstr "" -#: library/datetime.rst:1258 library/datetime.rst:1833 +#: library/datetime.rst:1282 library/datetime.rst:1857 msgid "Added the *fold* parameter." msgstr "" -#: library/datetime.rst:853 -msgid "Return the current local datetime, with :attr:`.tzinfo` ``None``." +#: library/datetime.rst:873 +msgid "Return the current local date and time, with :attr:`.tzinfo` ``None``." msgstr "" -#: library/datetime.rst:855 +#: library/datetime.rst:875 msgid "Equivalent to::" msgstr "" -#: library/datetime.rst:859 +#: library/datetime.rst:877 +msgid "datetime.fromtimestamp(time.time())" +msgstr "" + +#: library/datetime.rst:879 msgid "See also :meth:`now`, :meth:`fromtimestamp`." msgstr "" -#: library/datetime.rst:861 +#: library/datetime.rst:881 msgid "" "This method is functionally equivalent to :meth:`now`, but without a ``tz`` " "parameter." msgstr "" -#: library/datetime.rst:866 +#: library/datetime.rst:886 msgid "Return the current local date and time." msgstr "" -#: library/datetime.rst:868 +#: library/datetime.rst:888 msgid "" -"If optional argument *tz* is ``None`` or not specified, this is like :meth:" -"`today`, but, if possible, supplies more precision than can be gotten from " -"going through a :func:`time.time` timestamp (for example, this may be " -"possible on platforms supplying the C :c:func:`gettimeofday` function)." +"If optional argument *tz* is ``None`` or not specified, this is " +"like :meth:`today`, but, if possible, supplies more precision than can be " +"gotten from going through a :func:`time.time` timestamp (for example, this " +"may be possible on platforms supplying the C :c:func:`gettimeofday` " +"function)." msgstr "" -#: library/datetime.rst:874 +#: library/datetime.rst:894 msgid "" "If *tz* is not ``None``, it must be an instance of a :class:`tzinfo` " "subclass, and the current date and time are converted to *tz*’s time zone." msgstr "" -#: library/datetime.rst:877 +#: library/datetime.rst:897 msgid "This function is preferred over :meth:`today` and :meth:`utcnow`." msgstr "" -#: library/datetime.rst:882 +#: library/datetime.rst:901 +msgid "" +"Subsequent calls to :meth:`!datetime.now` may return the same instant " +"depending on the precision of the underlying clock." +msgstr "" + +#: library/datetime.rst:906 msgid "Return the current UTC date and time, with :attr:`.tzinfo` ``None``." msgstr "" -#: library/datetime.rst:884 +#: library/datetime.rst:908 msgid "" "This is like :meth:`now`, but returns the current UTC date and time, as a " "naive :class:`.datetime` object. An aware current UTC datetime can be " "obtained by calling ``datetime.now(timezone.utc)``. See also :meth:`now`." msgstr "" -#: library/datetime.rst:890 +#: library/datetime.rst:914 msgid "" "Because naive ``datetime`` objects are treated by many ``datetime`` methods " "as local times, it is preferred to use aware datetimes to represent times in " @@ -1169,11 +1370,11 @@ msgid "" "current time in UTC is by calling ``datetime.now(timezone.utc)``." msgstr "" -#: library/datetime.rst:897 -msgid "Use :meth:`datetime.now` with :attr:`UTC` instead." +#: library/datetime.rst:921 +msgid "Use :meth:`datetime.now` with :const:`UTC` instead." msgstr "" -#: library/datetime.rst:902 +#: library/datetime.rst:926 msgid "" "Return the local date and time corresponding to the POSIX timestamp, such as " "is returned by :func:`time.time`. If optional argument *tz* is ``None`` or " @@ -1181,68 +1382,77 @@ msgid "" "time, and the returned :class:`.datetime` object is naive." msgstr "" -#: library/datetime.rst:907 +#: library/datetime.rst:931 msgid "" "If *tz* is not ``None``, it must be an instance of a :class:`tzinfo` " "subclass, and the timestamp is converted to *tz*’s time zone." msgstr "" -#: library/datetime.rst:910 +#: library/datetime.rst:934 msgid "" ":meth:`fromtimestamp` may raise :exc:`OverflowError`, if the timestamp is " "out of the range of values supported by the platform C :c:func:`localtime` " -"or :c:func:`gmtime` functions, and :exc:`OSError` on :c:func:`localtime` or :" -"c:func:`gmtime` failure. It's common for this to be restricted to years in " -"1970 through 2038. Note that on non-POSIX systems that include leap seconds " -"in their notion of a timestamp, leap seconds are ignored by :meth:" -"`fromtimestamp`, and then it's possible to have two timestamps differing by " -"a second that yield identical :class:`.datetime` objects. This method is " -"preferred over :meth:`utcfromtimestamp`." +"or :c:func:`gmtime` functions, and :exc:`OSError` on :c:func:`localtime` " +"or :c:func:`gmtime` failure. It's common for this to be restricted to years " +"in 1970 through 2038. Note that on non-POSIX systems that include leap " +"seconds in their notion of a timestamp, leap seconds are ignored " +"by :meth:`fromtimestamp`, and then it's possible to have two timestamps " +"differing by a second that yield identical :class:`.datetime` objects. This " +"method is preferred over :meth:`utcfromtimestamp`." msgstr "" -#: library/datetime.rst:921 +#: library/datetime.rst:945 msgid "" "Raise :exc:`OverflowError` instead of :exc:`ValueError` if the timestamp is " "out of the range of values supported by the platform C :c:func:`localtime` " -"or :c:func:`gmtime` functions. Raise :exc:`OSError` instead of :exc:" -"`ValueError` on :c:func:`localtime` or :c:func:`gmtime` failure." +"or :c:func:`gmtime` functions. Raise :exc:`OSError` instead " +"of :exc:`ValueError` on :c:func:`localtime` or :c:func:`gmtime` failure." msgstr "" -#: library/datetime.rst:928 +#: library/datetime.rst:952 msgid ":meth:`fromtimestamp` may return instances with :attr:`.fold` set to 1." msgstr "" -#: library/datetime.rst:933 +#: library/datetime.rst:957 msgid "" "Return the UTC :class:`.datetime` corresponding to the POSIX timestamp, " "with :attr:`.tzinfo` ``None``. (The resulting object is naive.)" msgstr "" -#: library/datetime.rst:936 +#: library/datetime.rst:960 msgid "" "This may raise :exc:`OverflowError`, if the timestamp is out of the range of " -"values supported by the platform C :c:func:`gmtime` function, and :exc:" -"`OSError` on :c:func:`gmtime` failure. It's common for this to be restricted " -"to years in 1970 through 2038." +"values supported by the platform C :c:func:`gmtime` function, " +"and :exc:`OSError` on :c:func:`gmtime` failure. It's common for this to be " +"restricted to years in 1970 through 2038." msgstr "" -#: library/datetime.rst:941 +#: library/datetime.rst:965 msgid "To get an aware :class:`.datetime` object, call :meth:`fromtimestamp`::" msgstr "" -#: library/datetime.rst:945 +#: library/datetime.rst:967 +msgid "datetime.fromtimestamp(timestamp, timezone.utc)" +msgstr "" + +#: library/datetime.rst:969 msgid "" "On the POSIX compliant platforms, it is equivalent to the following " "expression::" msgstr "" -#: library/datetime.rst:950 +#: library/datetime.rst:972 msgid "" -"except the latter formula always supports the full years range: between :" -"const:`MINYEAR` and :const:`MAXYEAR` inclusive." +"datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(seconds=timestamp)" msgstr "" -#: library/datetime.rst:955 +#: library/datetime.rst:974 +msgid "" +"except the latter formula always supports the full years range: " +"between :const:`MINYEAR` and :const:`MAXYEAR` inclusive." +msgstr "" + +#: library/datetime.rst:979 msgid "" "Because naive ``datetime`` objects are treated by many ``datetime`` methods " "as local times, it is preferred to use aware datetimes to represent times in " @@ -1251,19 +1461,19 @@ msgid "" "tz=timezone.utc)``." msgstr "" -#: library/datetime.rst:961 +#: library/datetime.rst:985 msgid "" "Raise :exc:`OverflowError` instead of :exc:`ValueError` if the timestamp is " "out of the range of values supported by the platform C :c:func:`gmtime` " -"function. Raise :exc:`OSError` instead of :exc:`ValueError` on :c:func:" -"`gmtime` failure." +"function. Raise :exc:`OSError` instead of :exc:`ValueError` " +"on :c:func:`gmtime` failure." msgstr "" -#: library/datetime.rst:969 -msgid "Use :meth:`datetime.fromtimestamp` with :attr:`UTC` instead." +#: library/datetime.rst:993 +msgid "Use :meth:`datetime.fromtimestamp` with :const:`UTC` instead." msgstr "" -#: library/datetime.rst:974 +#: library/datetime.rst:998 msgid "" "Return the :class:`.datetime` corresponding to the proleptic Gregorian " "ordinal, where January 1 of year 1 has ordinal 1. :exc:`ValueError` is " @@ -1272,142 +1482,172 @@ msgid "" "is ``None``." msgstr "" -#: library/datetime.rst:982 +#: library/datetime.rst:1006 msgid "" "Return a new :class:`.datetime` object whose date components are equal to " "the given :class:`date` object's, and whose time components are equal to the " "given :class:`.time` object's. If the *tzinfo* argument is provided, its " "value is used to set the :attr:`.tzinfo` attribute of the result, otherwise " "the :attr:`~.time.tzinfo` attribute of the *time* argument is used. If the " -"*date* argument is a :class:`.datetime` object, its time components and :" -"attr:`.tzinfo` attributes are ignored." +"*date* argument is a :class:`.datetime` object, its time components " +"and :attr:`.tzinfo` attributes are ignored." msgstr "" -#: library/datetime.rst:990 +#: library/datetime.rst:1014 msgid "" -"For any :class:`.datetime` object *d*, ``d == datetime.combine(d.date(), d." -"time(), d.tzinfo)``." +"For any :class:`.datetime` object ``d``, ``d == datetime.combine(d.date(), " +"d.time(), d.tzinfo)``." msgstr "" -#: library/datetime.rst:993 +#: library/datetime.rst:1017 msgid "Added the *tzinfo* argument." msgstr "" -#: library/datetime.rst:999 +#: library/datetime.rst:1023 msgid "" "Return a :class:`.datetime` corresponding to a *date_string* in any valid " "ISO 8601 format, with the following exceptions:" msgstr "" -#: library/datetime.rst:1787 +#: library/datetime.rst:1811 msgid "Time zone offsets may have fractional seconds." msgstr "" -#: library/datetime.rst:1003 +#: library/datetime.rst:1027 msgid "The ``T`` separator may be replaced by any single unicode character." msgstr "" -#: library/datetime.rst:1792 +#: library/datetime.rst:1816 msgid "Fractional hours and minutes are not supported." msgstr "" -#: library/datetime.rst:1035 +#: library/datetime.rst:1037 +msgid "" +">>> from datetime import datetime\n" +">>> datetime.fromisoformat('2011-11-04')\n" +"datetime.datetime(2011, 11, 4, 0, 0)\n" +">>> datetime.fromisoformat('20111104')\n" +"datetime.datetime(2011, 11, 4, 0, 0)\n" +">>> datetime.fromisoformat('2011-11-04T00:05:23')\n" +"datetime.datetime(2011, 11, 4, 0, 5, 23)\n" +">>> datetime.fromisoformat('2011-11-04T00:05:23Z')\n" +"datetime.datetime(2011, 11, 4, 0, 5, 23, tzinfo=datetime.timezone.utc)\n" +">>> datetime.fromisoformat('20111104T000523')\n" +"datetime.datetime(2011, 11, 4, 0, 5, 23)\n" +">>> datetime.fromisoformat('2011-W01-2T00:05:23.283')\n" +"datetime.datetime(2011, 1, 4, 0, 5, 23, 283000)\n" +">>> datetime.fromisoformat('2011-11-04 00:05:23.283')\n" +"datetime.datetime(2011, 11, 4, 0, 5, 23, 283000)\n" +">>> datetime.fromisoformat('2011-11-04 00:05:23.283+00:00')\n" +"datetime.datetime(2011, 11, 4, 0, 5, 23, 283000, " +"tzinfo=datetime.timezone.utc)\n" +">>> datetime.fromisoformat('2011-11-04T00:05:23+04:00') \n" +"datetime.datetime(2011, 11, 4, 0, 5, 23,\n" +" tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))" +msgstr "" + +#: library/datetime.rst:1059 msgid "" -"Previously, this method only supported formats that could be emitted by :" -"meth:`date.isoformat()` or :meth:`datetime.isoformat()`." +"Previously, this method only supported formats that could be emitted " +"by :meth:`date.isoformat` or :meth:`datetime.isoformat`." msgstr "" -#: library/datetime.rst:1042 +#: library/datetime.rst:1066 msgid "" "Return a :class:`.datetime` corresponding to the ISO calendar date specified " "by year, week and day. The non-date components of the datetime are populated " -"with their normal default values. This is the inverse of the function :meth:" -"`datetime.isocalendar`." +"with their normal default values. This is the inverse of the " +"function :meth:`datetime.isocalendar`." msgstr "" -#: library/datetime.rst:1051 +#: library/datetime.rst:1075 msgid "" "Return a :class:`.datetime` corresponding to *date_string*, parsed according " "to *format*." msgstr "" -#: library/datetime.rst:1054 +#: library/datetime.rst:1078 msgid "" -"If *format* does not contain microseconds or timezone information, this is " +"If *format* does not contain microseconds or time zone information, this is " "equivalent to::" msgstr "" -#: library/datetime.rst:1058 +#: library/datetime.rst:2533 +msgid "datetime(*(time.strptime(date_string, format)[0:6]))" +msgstr "" + +#: library/datetime.rst:1082 msgid "" ":exc:`ValueError` is raised if the date_string and format can't be parsed " "by :func:`time.strptime` or if it returns a value which isn't a time tuple. " -"See also :ref:`strftime-strptime-behavior` and :meth:`datetime." -"fromisoformat`." +"See also :ref:`strftime-strptime-behavior` " +"and :meth:`datetime.fromisoformat`." msgstr "" -#: library/datetime.rst:1069 +#: library/datetime.rst:1093 msgid "" "The earliest representable :class:`.datetime`, ``datetime(MINYEAR, 1, 1, " "tzinfo=None)``." msgstr "" -#: library/datetime.rst:1075 +#: library/datetime.rst:1099 msgid "" "The latest representable :class:`.datetime`, ``datetime(MAXYEAR, 12, 31, 23, " "59, 59, 999999, tzinfo=None)``." msgstr "" -#: library/datetime.rst:1081 +#: library/datetime.rst:1105 msgid "" "The smallest possible difference between non-equal :class:`.datetime` " "objects, ``timedelta(microseconds=1)``." msgstr "" -#: library/datetime.rst:1720 +#: library/datetime.rst:1744 msgid "In ``range(24)``." msgstr "" -#: library/datetime.rst:1114 library/datetime.rst:1730 +#: library/datetime.rst:1138 library/datetime.rst:1754 msgid "In ``range(60)``." msgstr "" -#: library/datetime.rst:1735 +#: library/datetime.rst:1759 msgid "In ``range(1000000)``." msgstr "" -#: library/datetime.rst:1124 +#: library/datetime.rst:1148 msgid "" "The object passed as the *tzinfo* argument to the :class:`.datetime` " "constructor, or ``None`` if none was passed." msgstr "" -#: library/datetime.rst:1746 +#: library/datetime.rst:1770 msgid "" "In ``[0, 1]``. Used to disambiguate wall times during a repeated interval. " "(A repeated interval occurs when clocks are rolled back at the end of " "daylight saving time or when the UTC offset for the current zone is " -"decreased for political reasons.) The value 0 (1) represents the earlier " -"(later) of the two moments with the same wall time representation." +"decreased for political reasons.) The values 0 and 1 represent, " +"respectively, the earlier and later of the two moments with the same wall " +"time representation." msgstr "" -#: library/datetime.rst:1143 +#: library/datetime.rst:1167 msgid "``datetime2 = datetime1 + timedelta``" msgstr "" -#: library/datetime.rst:2356 library/datetime.rst:2373 -#: library/datetime.rst:2438 library/datetime.rst:2447 +#: library/datetime.rst:2380 library/datetime.rst:2397 +#: library/datetime.rst:2462 library/datetime.rst:2471 msgid "\\(1)" msgstr "" -#: library/datetime.rst:1145 +#: library/datetime.rst:1169 msgid "``datetime2 = datetime1 - timedelta``" msgstr "" -#: library/datetime.rst:2389 +#: library/datetime.rst:2413 msgid "\\(2)" msgstr "" -#: library/datetime.rst:1147 +#: library/datetime.rst:1171 msgid "``timedelta = datetime1 - datetime2``" msgstr "" @@ -1435,63 +1675,64 @@ msgstr "" msgid "``datetime1 >= datetime2``" msgstr "" -#: library/datetime.rst:1159 +#: library/datetime.rst:1183 msgid "" -"datetime2 is a duration of timedelta removed from datetime1, moving forward " -"in time if ``timedelta.days`` > 0, or backward if ``timedelta.days`` < 0. " -"The result has the same :attr:`~.datetime.tzinfo` attribute as the input " -"datetime, and datetime2 - datetime1 == timedelta after. :exc:`OverflowError` " -"is raised if datetime2.year would be smaller than :const:`MINYEAR` or larger " -"than :const:`MAXYEAR`. Note that no time zone adjustments are done even if " -"the input is an aware object." +"``datetime2`` is a duration of ``timedelta`` removed from ``datetime1``, " +"moving forward in time if ``timedelta.days > 0``, or backward if " +"``timedelta.days < 0``. The result has the same :attr:`~.datetime.tzinfo` " +"attribute as the input datetime, and ``datetime2 - datetime1 == timedelta`` " +"after. :exc:`OverflowError` is raised if ``datetime2.year`` would be smaller " +"than :const:`MINYEAR` or larger than :const:`MAXYEAR`. Note that no time " +"zone adjustments are done even if the input is an aware object." msgstr "" -#: library/datetime.rst:1168 +#: library/datetime.rst:1192 msgid "" -"Computes the datetime2 such that datetime2 + timedelta == datetime1. As for " -"addition, the result has the same :attr:`~.datetime.tzinfo` attribute as the " -"input datetime, and no time zone adjustments are done even if the input is " -"aware." +"Computes the ``datetime2`` such that ``datetime2 + timedelta == datetime1``. " +"As for addition, the result has the same :attr:`~.datetime.tzinfo` attribute " +"as the input datetime, and no time zone adjustments are done even if the " +"input is aware." msgstr "" -#: library/datetime.rst:1173 +#: library/datetime.rst:1197 msgid "" "Subtraction of a :class:`.datetime` from a :class:`.datetime` is defined " "only if both operands are naive, or if both are aware. If one is aware and " "the other is naive, :exc:`TypeError` is raised." msgstr "" -#: library/datetime.rst:1177 +#: library/datetime.rst:1201 msgid "" -"If both are naive, or both are aware and have the same :attr:`~.datetime." -"tzinfo` attribute, the :attr:`~.datetime.tzinfo` attributes are ignored, and " -"the result is a :class:`timedelta` object *t* such that ``datetime2 + t == " -"datetime1``. No time zone adjustments are done in this case." +"If both are naive, or both are aware and have the " +"same :attr:`~.datetime.tzinfo` attribute, the :attr:`~.datetime.tzinfo` " +"attributes are ignored, and the result is a :class:`timedelta` object ``t`` " +"such that ``datetime2 + t == datetime1``. No time zone adjustments are done " +"in this case." msgstr "" -#: library/datetime.rst:1182 +#: library/datetime.rst:1206 msgid "" "If both are aware and have different :attr:`~.datetime.tzinfo` attributes, " -"``a-b`` acts as if *a* and *b* were first converted to naive UTC datetimes. " -"The result is ``(a.replace(tzinfo=None) - a.utcoffset()) - (b." -"replace(tzinfo=None) - b.utcoffset())`` except that the implementation never " -"overflows." +"``a-b`` acts as if ``a`` and ``b`` were first converted to naive UTC " +"datetimes. The result is ``(a.replace(tzinfo=None) - a.utcoffset()) - " +"(b.replace(tzinfo=None) - b.utcoffset())`` except that the implementation " +"never overflows." msgstr "" -#: library/datetime.rst:1188 +#: library/datetime.rst:1212 msgid "" ":class:`.datetime` objects are equal if they represent the same date and " "time, taking into account the time zone." msgstr "" -#: library/datetime.rst:1191 +#: library/datetime.rst:1215 msgid "" "Naive and aware :class:`!datetime` objects are never equal. :class:`!" "datetime` objects are never equal to :class:`date` objects that are not " "also :class:`!datetime` instances, even if they represent the same date." msgstr "" -#: library/datetime.rst:1196 +#: library/datetime.rst:1220 msgid "" "If both comparands are aware, and have the same :attr:`!tzinfo` attribute, " "the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and " @@ -1502,20 +1743,20 @@ msgid "" "interval are never equal to :class:`!datetime` instances in other time zone." msgstr "" -#: library/datetime.rst:1206 +#: library/datetime.rst:1230 msgid "" "*datetime1* is considered less than *datetime2* when *datetime1* precedes " "*datetime2* in time, taking into account the time zone." msgstr "" -#: library/datetime.rst:1209 +#: library/datetime.rst:1233 msgid "" "Order comparison between naive and aware :class:`.datetime` objects, as well " "as a :class:`!datetime` object and a :class:`!date` object that is not also " "a :class:`!datetime` instance, raises :exc:`TypeError`." msgstr "" -#: library/datetime.rst:1213 +#: library/datetime.rst:1237 msgid "" "If both comparands are aware, and have the same :attr:`!tzinfo` attribute, " "the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and " @@ -1525,33 +1766,33 @@ msgid "" "implementation never overflows." msgstr "" -#: library/datetime.rst:1220 +#: library/datetime.rst:1244 msgid "" "Equality comparisons between aware and naive :class:`.datetime` instances " "don't raise :exc:`TypeError`." msgstr "" -#: library/datetime.rst:1228 +#: library/datetime.rst:1252 msgid "Return :class:`date` object with same year, month and day." msgstr "" -#: library/datetime.rst:1233 +#: library/datetime.rst:1257 msgid "" "Return :class:`.time` object with same hour, minute, second, microsecond and " "fold. :attr:`.tzinfo` is ``None``. See also method :meth:`timetz`." msgstr "" -#: library/datetime.rst:1245 +#: library/datetime.rst:1269 msgid "The fold value is copied to the returned :class:`.time` object." msgstr "" -#: library/datetime.rst:1242 +#: library/datetime.rst:1266 msgid "" "Return :class:`.time` object with same hour, minute, second, microsecond, " "fold, and tzinfo attributes. See also method :meth:`time`." msgstr "" -#: library/datetime.rst:1253 +#: library/datetime.rst:1277 msgid "" "Return a datetime with the same attributes, except for those attributes " "given new values by whichever keyword arguments are specified. Note that " @@ -1559,394 +1800,592 @@ msgid "" "datetime with no conversion of date and time data." msgstr "" -#: library/datetime.rst:1264 +#: library/datetime.rst:1288 msgid "" "Return a :class:`.datetime` object with new :attr:`.tzinfo` attribute *tz*, " "adjusting the date and time data so the result is the same UTC time as " "*self*, but in *tz*'s local time." msgstr "" -#: library/datetime.rst:1268 +#: library/datetime.rst:1292 msgid "" "If provided, *tz* must be an instance of a :class:`tzinfo` subclass, and " "its :meth:`utcoffset` and :meth:`dst` methods must not return ``None``. If " -"*self* is naive, it is presumed to represent time in the system timezone." +"*self* is naive, it is presumed to represent time in the system time zone." msgstr "" -#: library/datetime.rst:1272 +#: library/datetime.rst:1296 msgid "" -"If called without arguments (or with ``tz=None``) the system local timezone " -"is assumed for the target timezone. The ``.tzinfo`` attribute of the " +"If called without arguments (or with ``tz=None``) the system local time zone " +"is assumed for the target time zone. The ``.tzinfo`` attribute of the " "converted datetime instance will be set to an instance of :class:`timezone` " "with the zone name and offset obtained from the OS." msgstr "" -#: library/datetime.rst:1277 +#: library/datetime.rst:1301 msgid "" "If ``self.tzinfo`` is *tz*, ``self.astimezone(tz)`` is equal to *self*: no " "adjustment of date or time data is performed. Else the result is local time " -"in the timezone *tz*, representing the same UTC time as *self*: after " +"in the time zone *tz*, representing the same UTC time as *self*: after " "``astz = dt.astimezone(tz)``, ``astz - astz.utcoffset()`` will have the same " "date and time data as ``dt - dt.utcoffset()``." msgstr "" -#: library/datetime.rst:1283 +#: library/datetime.rst:1307 msgid "" -"If you merely want to attach a time zone object *tz* to a datetime *dt* " -"without adjustment of date and time data, use ``dt.replace(tzinfo=tz)``. If " -"you merely want to remove the time zone object from an aware datetime *dt* " -"without conversion of date and time data, use ``dt.replace(tzinfo=None)``." +"If you merely want to attach a :class:`timezone` object *tz* to a datetime " +"*dt* without adjustment of date and time data, use " +"``dt.replace(tzinfo=tz)``. If you merely want to remove the :class:`!" +"timezone` object from an aware datetime *dt* without conversion of date and " +"time data, use ``dt.replace(tzinfo=None)``." msgstr "" -#: library/datetime.rst:1288 +#: library/datetime.rst:1312 msgid "" -"Note that the default :meth:`tzinfo.fromutc` method can be overridden in a :" -"class:`tzinfo` subclass to affect the result returned by :meth:`astimezone`. " -"Ignoring error cases, :meth:`astimezone` acts like::" +"Note that the default :meth:`tzinfo.fromutc` method can be overridden in " +"a :class:`tzinfo` subclass to affect the result returned " +"by :meth:`astimezone`. Ignoring error cases, :meth:`astimezone` acts like::" msgstr "" -#: library/datetime.rst:1300 +#: library/datetime.rst:1316 +msgid "" +"def astimezone(self, tz):\n" +" if self.tzinfo is tz:\n" +" return self\n" +" # Convert self to UTC, and attach the new timezone object.\n" +" utc = (self - self.utcoffset()).replace(tzinfo=tz)\n" +" # Convert from UTC to tz's local time.\n" +" return tz.fromutc(utc)" +msgstr "" + +#: library/datetime.rst:1324 msgid "*tz* now can be omitted." msgstr "" -#: library/datetime.rst:1303 +#: library/datetime.rst:1327 msgid "" "The :meth:`astimezone` method can now be called on naive instances that are " "presumed to represent system local time." msgstr "" -#: library/datetime.rst:1310 +#: library/datetime.rst:1334 msgid "" -"If :attr:`.tzinfo` is ``None``, returns ``None``, else returns ``self.tzinfo." -"utcoffset(self)``, and raises an exception if the latter doesn't return " -"``None`` or a :class:`timedelta` object with magnitude less than one day." +"If :attr:`.tzinfo` is ``None``, returns ``None``, else returns " +"``self.tzinfo.utcoffset(self)``, and raises an exception if the latter " +"doesn't return ``None`` or a :class:`timedelta` object with magnitude less " +"than one day." msgstr "" -#: library/datetime.rst:1906 library/datetime.rst:2258 -#: library/datetime.rst:2582 +#: library/datetime.rst:1930 library/datetime.rst:2282 +#: library/datetime.rst:2606 msgid "The UTC offset is not restricted to a whole number of minutes." msgstr "" -#: library/datetime.rst:1320 +#: library/datetime.rst:1344 msgid "" -"If :attr:`.tzinfo` is ``None``, returns ``None``, else returns ``self.tzinfo." -"dst(self)``, and raises an exception if the latter doesn't return ``None`` " -"or a :class:`timedelta` object with magnitude less than one day." +"If :attr:`.tzinfo` is ``None``, returns ``None``, else returns " +"``self.tzinfo.dst(self)``, and raises an exception if the latter doesn't " +"return ``None`` or a :class:`timedelta` object with magnitude less than one " +"day." msgstr "" -#: library/datetime.rst:1916 library/datetime.rst:2067 +#: library/datetime.rst:1940 library/datetime.rst:2091 msgid "The DST offset is not restricted to a whole number of minutes." msgstr "" -#: library/datetime.rst:1330 +#: library/datetime.rst:1354 msgid "" -"If :attr:`.tzinfo` is ``None``, returns ``None``, else returns ``self.tzinfo." -"tzname(self)``, raises an exception if the latter doesn't return ``None`` or " -"a string object," +"If :attr:`.tzinfo` is ``None``, returns ``None``, else returns " +"``self.tzinfo.tzname(self)``, raises an exception if the latter doesn't " +"return ``None`` or a string object," msgstr "" -#: library/datetime.rst:1345 +#: library/datetime.rst:1365 +msgid "" +"time.struct_time((d.year, d.month, d.day,\n" +" d.hour, d.minute, d.second,\n" +" d.weekday(), yday, dst))" +msgstr "" + +#: library/datetime.rst:1369 msgid "" "where ``yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1`` is the " -"day number within the current year starting with ``1`` for January 1st. The :" -"attr:`~time.struct_time.tm_isdst` flag of the result is set according to " -"the :meth:`dst` method: :attr:`.tzinfo` is ``None`` or :meth:`dst` returns " -"``None``, :attr:`!tm_isdst` is set to ``-1``; else if :meth:`dst` returns a " -"non-zero value, :attr:`!tm_isdst` is set to ``1``; else :attr:`!tm_isdst` is " -"set to ``0``." +"day number within the current year starting with 1 for January 1st. " +"The :attr:`~time.struct_time.tm_isdst` flag of the result is set according " +"to the :meth:`dst` method: :attr:`.tzinfo` is ``None`` or :meth:`dst` " +"returns ``None``, :attr:`!tm_isdst` is set to ``-1``; else if :meth:`dst` " +"returns a non-zero value, :attr:`!tm_isdst` is set to 1; else :attr:`!" +"tm_isdst` is set to 0." msgstr "" -#: library/datetime.rst:1356 +#: library/datetime.rst:1380 msgid "" -"If :class:`.datetime` instance *d* is naive, this is the same as ``d." -"timetuple()`` except that :attr:`~.time.struct_time.tm_isdst` is forced to 0 " -"regardless of what ``d.dst()`` returns. DST is never in effect for a UTC " -"time." +"If :class:`.datetime` instance ``d`` is naive, this is the same as " +"``d.timetuple()`` except that :attr:`~.time.struct_time.tm_isdst` is forced " +"to 0 regardless of what ``d.dst()`` returns. DST is never in effect for a " +"UTC time." msgstr "" -#: library/datetime.rst:1360 +#: library/datetime.rst:1384 msgid "" -"If *d* is aware, *d* is normalized to UTC time, by subtracting ``d." -"utcoffset()``, and a :class:`time.struct_time` for the normalized time is " -"returned. :attr:`!tm_isdst` is forced to 0. Note that an :exc:" -"`OverflowError` may be raised if *d*.year was ``MINYEAR`` or ``MAXYEAR`` and " -"UTC adjustment spills over a year boundary." +"If ``d`` is aware, ``d`` is normalized to UTC time, by subtracting " +"``d.utcoffset()``, and a :class:`time.struct_time` for the normalized time " +"is returned. :attr:`!tm_isdst` is forced to 0. Note that " +"an :exc:`OverflowError` may be raised if ``d.year`` was ``MINYEAR`` or " +"``MAXYEAR`` and UTC adjustment spills over a year boundary." msgstr "" -#: library/datetime.rst:1369 +#: library/datetime.rst:1393 msgid "" "Because naive ``datetime`` objects are treated by many ``datetime`` methods " "as local times, it is preferred to use aware datetimes to represent times in " "UTC; as a result, using :meth:`datetime.utctimetuple` may give misleading " -"results. If you have a naive ``datetime`` representing UTC, use ``datetime." -"replace(tzinfo=timezone.utc)`` to make it aware, at which point you can use :" -"meth:`.datetime.timetuple`." +"results. If you have a naive ``datetime`` representing UTC, use " +"``datetime.replace(tzinfo=timezone.utc)`` to make it aware, at which point " +"you can use :meth:`.datetime.timetuple`." msgstr "" -#: library/datetime.rst:1378 +#: library/datetime.rst:1402 msgid "" -"Return the proleptic Gregorian ordinal of the date. The same as ``self." -"date().toordinal()``." +"Return the proleptic Gregorian ordinal of the date. The same as " +"``self.date().toordinal()``." msgstr "" -#: library/datetime.rst:1383 +#: library/datetime.rst:1407 msgid "" "Return POSIX timestamp corresponding to the :class:`.datetime` instance. The " -"return value is a :class:`float` similar to that returned by :func:`time." -"time`." +"return value is a :class:`float` similar to that returned " +"by :func:`time.time`." msgstr "" -#: library/datetime.rst:1387 +#: library/datetime.rst:1411 msgid "" "Naive :class:`.datetime` instances are assumed to represent local time and " "this method relies on the platform C :c:func:`mktime` function to perform " "the conversion. Since :class:`.datetime` supports wider range of values " -"than :c:func:`mktime` on many platforms, this method may raise :exc:" -"`OverflowError` or :exc:`OSError` for times far in the past or far in the " -"future." +"than :c:func:`mktime` on many platforms, this method may " +"raise :exc:`OverflowError` or :exc:`OSError` for times far in the past or " +"far in the future." msgstr "" -#: library/datetime.rst:1394 +#: library/datetime.rst:1418 msgid "" "For aware :class:`.datetime` instances, the return value is computed as::" msgstr "" -#: library/datetime.rst:1401 +#: library/datetime.rst:1421 +msgid "(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()" +msgstr "" + +#: library/datetime.rst:1425 msgid "" "The :meth:`timestamp` method uses the :attr:`.fold` attribute to " "disambiguate the times during a repeated interval." msgstr "" -#: library/datetime.rst:1407 +#: library/datetime.rst:1431 msgid "" -"There is no method to obtain the POSIX timestamp directly from a naive :" -"class:`.datetime` instance representing UTC time. If your application uses " -"this convention and your system timezone is not set to UTC, you can obtain " -"the POSIX timestamp by supplying ``tzinfo=timezone.utc``::" +"There is no method to obtain the POSIX timestamp directly from a " +"naive :class:`.datetime` instance representing UTC time. If your application " +"uses this convention and your system time zone is not set to UTC, you can " +"obtain the POSIX timestamp by supplying ``tzinfo=timezone.utc``::" +msgstr "" + +#: library/datetime.rst:1437 +msgid "timestamp = dt.replace(tzinfo=timezone.utc).timestamp()" msgstr "" -#: library/datetime.rst:1415 +#: library/datetime.rst:1439 msgid "or by calculating the timestamp directly::" msgstr "" -#: library/datetime.rst:1421 +#: library/datetime.rst:1441 +msgid "timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)" +msgstr "" + +#: library/datetime.rst:1445 msgid "" "Return the day of the week as an integer, where Monday is 0 and Sunday is 6. " "The same as ``self.date().weekday()``. See also :meth:`isoweekday`." msgstr "" -#: library/datetime.rst:1427 +#: library/datetime.rst:1451 msgid "" "Return the day of the week as an integer, where Monday is 1 and Sunday is 7. " -"The same as ``self.date().isoweekday()``. See also :meth:`weekday`, :meth:" -"`isocalendar`." +"The same as ``self.date().isoweekday()``. See " +"also :meth:`weekday`, :meth:`isocalendar`." msgstr "" -#: library/datetime.rst:1434 +#: library/datetime.rst:1458 msgid "" "Return a :term:`named tuple` with three components: ``year``, ``week`` and " "``weekday``. The same as ``self.date().isocalendar()``." msgstr "" -#: library/datetime.rst:1440 +#: library/datetime.rst:1464 msgid "Return a string representing the date and time in ISO 8601 format:" msgstr "" -#: library/datetime.rst:1442 +#: library/datetime.rst:1466 msgid "``YYYY-MM-DDTHH:MM:SS.ffffff``, if :attr:`microsecond` is not 0" msgstr "" -#: library/datetime.rst:1443 +#: library/datetime.rst:1467 msgid "``YYYY-MM-DDTHH:MM:SS``, if :attr:`microsecond` is 0" msgstr "" -#: library/datetime.rst:1445 +#: library/datetime.rst:1469 msgid "" "If :meth:`utcoffset` does not return ``None``, a string is appended, giving " "the UTC offset:" msgstr "" -#: library/datetime.rst:1448 +#: library/datetime.rst:1472 msgid "" "``YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` " "is not 0" msgstr "" -#: library/datetime.rst:1450 +#: library/datetime.rst:1474 msgid "" "``YYYY-MM-DDTHH:MM:SS+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` is 0" msgstr "" -#: library/datetime.rst:1460 +#: library/datetime.rst:1478 +msgid "" +">>> from datetime import datetime, timezone\n" +">>> datetime(2019, 5, 18, 15, 17, 8, 132263).isoformat()\n" +"'2019-05-18T15:17:08.132263'\n" +">>> datetime(2019, 5, 18, 15, 17, tzinfo=timezone.utc).isoformat()\n" +"'2019-05-18T15:17:00+00:00'" +msgstr "" + +#: library/datetime.rst:1484 msgid "" "The optional argument *sep* (default ``'T'``) is a one-character separator, " "placed between the date and time portions of the result. For example::" msgstr "" -#: library/datetime.rst:1846 +#: library/datetime.rst:1487 +msgid "" +">>> from datetime import tzinfo, timedelta, datetime\n" +">>> class TZ(tzinfo):\n" +"... \"\"\"A time zone with an arbitrary, constant -06:39 offset.\"\"\"\n" +"... def utcoffset(self, dt):\n" +"... return timedelta(hours=-6, minutes=-39)\n" +"...\n" +">>> datetime(2002, 12, 25, tzinfo=TZ()).isoformat(' ')\n" +"'2002-12-25 00:00:00-06:39'\n" +">>> datetime(2009, 11, 27, microsecond=100, tzinfo=TZ()).isoformat()\n" +"'2009-11-27T00:00:00.000100-06:39'" +msgstr "" + +#: library/datetime.rst:1870 msgid "" "The optional argument *timespec* specifies the number of additional " "components of the time to include (the default is ``'auto'``). It can be one " "of the following:" msgstr "" -#: library/datetime.rst:1850 +#: library/datetime.rst:1874 msgid "" "``'auto'``: Same as ``'seconds'`` if :attr:`microsecond` is 0, same as " "``'microseconds'`` otherwise." msgstr "" -#: library/datetime.rst:1852 +#: library/datetime.rst:1876 msgid "``'hours'``: Include the :attr:`hour` in the two-digit ``HH`` format." msgstr "" -#: library/datetime.rst:1853 +#: library/datetime.rst:1877 msgid "" "``'minutes'``: Include :attr:`hour` and :attr:`minute` in ``HH:MM`` format." msgstr "" -#: library/datetime.rst:1854 +#: library/datetime.rst:1878 msgid "" "``'seconds'``: Include :attr:`hour`, :attr:`minute`, and :attr:`second` in " "``HH:MM:SS`` format." msgstr "" -#: library/datetime.rst:1856 +#: library/datetime.rst:1880 msgid "" "``'milliseconds'``: Include full time, but truncate fractional second part " "to milliseconds. ``HH:MM:SS.sss`` format." msgstr "" -#: library/datetime.rst:1858 +#: library/datetime.rst:1882 msgid "``'microseconds'``: Include full time in ``HH:MM:SS.ffffff`` format." msgstr "" -#: library/datetime.rst:1862 +#: library/datetime.rst:1886 msgid "Excluded time components are truncated, not rounded." msgstr "" -#: library/datetime.rst:1492 +#: library/datetime.rst:1516 msgid ":exc:`ValueError` will be raised on an invalid *timespec* argument::" msgstr "" -#: library/datetime.rst:1877 +#: library/datetime.rst:1519 +msgid "" +">>> from datetime import datetime\n" +">>> datetime.now().isoformat(timespec='minutes') \n" +"'2002-12-25T00:00'\n" +">>> dt = datetime(2015, 1, 1, 12, 30, 59, 0)\n" +">>> dt.isoformat(timespec='microseconds')\n" +"'2015-01-01T12:30:59.000000'" +msgstr "" + +#: library/datetime.rst:1901 msgid "Added the *timespec* parameter." msgstr "" -#: library/datetime.rst:1508 +#: library/datetime.rst:1532 msgid "" -"For a :class:`.datetime` instance *d*, ``str(d)`` is equivalent to ``d." -"isoformat(' ')``." +"For a :class:`.datetime` instance ``d``, ``str(d)`` is equivalent to " +"``d.isoformat(' ')``." msgstr "" -#: library/datetime.rst:1514 +#: library/datetime.rst:1538 msgid "Return a string representing the date and time::" msgstr "" -#: library/datetime.rst:1520 +#: library/datetime.rst:1540 +msgid "" +">>> from datetime import datetime\n" +">>> datetime(2002, 12, 4, 20, 30, 40).ctime()\n" +"'Wed Dec 4 20:30:40 2002'" +msgstr "" + +#: library/datetime.rst:1544 msgid "" "The output string will *not* include time zone information, regardless of " "whether the input is aware or naive." msgstr "" -#: library/datetime.rst:1527 +#: library/datetime.rst:1551 msgid "" -"on platforms where the native C :c:func:`ctime` function (which :func:`time." -"ctime` invokes, but which :meth:`datetime.ctime` does not invoke) conforms " -"to the C standard." +"on platforms where the native C :c:func:`ctime` function " +"(which :func:`time.ctime` invokes, but which :meth:`datetime.ctime` does not " +"invoke) conforms to the C standard." msgstr "" -#: library/datetime.rst:1534 +#: library/datetime.rst:1558 msgid "" "Return a string representing the date and time, controlled by an explicit " -"format string. See also :ref:`strftime-strptime-behavior` and :meth:" -"`datetime.isoformat`." +"format string. See also :ref:`strftime-strptime-behavior` " +"and :meth:`datetime.isoformat`." msgstr "" -#: library/datetime.rst:1541 +#: library/datetime.rst:1565 msgid "" "Same as :meth:`.datetime.strftime`. This makes it possible to specify a " "format string for a :class:`.datetime` object in :ref:`formatted string " -"literals ` and when using :meth:`str.format`. See also :ref:" -"`strftime-strptime-behavior` and :meth:`datetime.isoformat`." +"literals ` and when using :meth:`str.format`. See " +"also :ref:`strftime-strptime-behavior` and :meth:`datetime.isoformat`." msgstr "" -#: library/datetime.rst:1548 +#: library/datetime.rst:1572 msgid "Examples of Usage: :class:`.datetime`" msgstr "" -#: library/datetime.rst:1550 +#: library/datetime.rst:1574 msgid "Examples of working with :class:`.datetime` objects:" msgstr "" -#: library/datetime.rst:1603 +#: library/datetime.rst:1576 +msgid "" +">>> from datetime import datetime, date, time, timezone\n" +"\n" +">>> # Using datetime.combine()\n" +">>> d = date(2005, 7, 14)\n" +">>> t = time(12, 30)\n" +">>> datetime.combine(d, t)\n" +"datetime.datetime(2005, 7, 14, 12, 30)\n" +"\n" +">>> # Using datetime.now()\n" +">>> datetime.now() \n" +"datetime.datetime(2007, 12, 6, 16, 29, 43, 79043) # GMT +1\n" +">>> datetime.now(timezone.utc) \n" +"datetime.datetime(2007, 12, 6, 15, 29, 43, 79060, " +"tzinfo=datetime.timezone.utc)\n" +"\n" +">>> # Using datetime.strptime()\n" +">>> dt = datetime.strptime(\"21/11/06 16:30\", \"%d/%m/%y %H:%M\")\n" +">>> dt\n" +"datetime.datetime(2006, 11, 21, 16, 30)\n" +"\n" +">>> # Using datetime.timetuple() to get tuple of all attributes\n" +">>> tt = dt.timetuple()\n" +">>> for it in tt: \n" +"... print(it)\n" +"...\n" +"2006 # year\n" +"11 # month\n" +"21 # day\n" +"16 # hour\n" +"30 # minute\n" +"0 # second\n" +"1 # weekday (0 = Monday)\n" +"325 # number of days since 1st January\n" +"-1 # dst - method tzinfo.dst() returned None\n" +"\n" +">>> # Date in ISO format\n" +">>> ic = dt.isocalendar()\n" +">>> for it in ic: \n" +"... print(it)\n" +"...\n" +"2006 # ISO year\n" +"47 # ISO week\n" +"2 # ISO weekday\n" +"\n" +">>> # Formatting a datetime\n" +">>> dt.strftime(\"%A, %d. %B %Y %I:%M%p\")\n" +"'Tuesday, 21. November 2006 04:30PM'\n" +">>> 'The {1} is {0:%d}, the {2} is {0:%B}, the {3} is {0:%I:" +"%M%p}.'.format(dt, \"day\", \"month\", \"time\")\n" +"'The day is 21, the month is November, the time is 04:30PM.'" +msgstr "" + +#: library/datetime.rst:1627 msgid "" "The example below defines a :class:`tzinfo` subclass capturing time zone " "information for Kabul, Afghanistan, which used +4 UTC until 1945 and then " "+4:30 UTC thereafter::" msgstr "" -#: library/datetime.rst:1650 +#: library/datetime.rst:1631 +msgid "" +"from datetime import timedelta, datetime, tzinfo, timezone\n" +"\n" +"class KabulTz(tzinfo):\n" +" # Kabul used +4 until 1945, when they moved to +4:30\n" +" UTC_MOVE_DATE = datetime(1944, 12, 31, 20, tzinfo=timezone.utc)\n" +"\n" +" def utcoffset(self, dt):\n" +" if dt.year < 1945:\n" +" return timedelta(hours=4)\n" +" elif (1945, 1, 1, 0, 0) <= dt.timetuple()[:5] < (1945, 1, 1, 0, " +"30):\n" +" # An ambiguous (\"imaginary\") half-hour range representing\n" +" # a 'fold' in time due to the shift from +4 to +4:30.\n" +" # If dt falls in the imaginary range, use fold to decide how\n" +" # to resolve. See PEP495.\n" +" return timedelta(hours=4, minutes=(30 if dt.fold else 0))\n" +" else:\n" +" return timedelta(hours=4, minutes=30)\n" +"\n" +" def fromutc(self, dt):\n" +" # Follow same validations as in datetime.tzinfo\n" +" if not isinstance(dt, datetime):\n" +" raise TypeError(\"fromutc() requires a datetime argument\")\n" +" if dt.tzinfo is not self:\n" +" raise ValueError(\"dt.tzinfo is not self\")\n" +"\n" +" # A custom implementation is required for fromutc as\n" +" # the input to this function is a datetime with utc values\n" +" # but with a tzinfo set to self.\n" +" # See datetime.astimezone or fromtimestamp.\n" +" if dt.replace(tzinfo=timezone.utc) >= self.UTC_MOVE_DATE:\n" +" return dt + timedelta(hours=4, minutes=30)\n" +" else:\n" +" return dt + timedelta(hours=4)\n" +"\n" +" def dst(self, dt):\n" +" # Kabul does not observe daylight saving time.\n" +" return timedelta(0)\n" +"\n" +" def tzname(self, dt):\n" +" if dt >= self.UTC_MOVE_DATE:\n" +" return \"+04:30\"\n" +" return \"+04\"" +msgstr "" + +#: library/datetime.rst:1674 msgid "Usage of ``KabulTz`` from above::" msgstr "" #: library/datetime.rst:1676 +msgid "" +">>> tz1 = KabulTz()\n" +"\n" +">>> # Datetime before the change\n" +">>> dt1 = datetime(1900, 11, 21, 16, 30, tzinfo=tz1)\n" +">>> print(dt1.utcoffset())\n" +"4:00:00\n" +"\n" +">>> # Datetime after the change\n" +">>> dt2 = datetime(2006, 6, 14, 13, 0, tzinfo=tz1)\n" +">>> print(dt2.utcoffset())\n" +"4:30:00\n" +"\n" +">>> # Convert datetime to another time zone\n" +">>> dt3 = dt2.astimezone(timezone.utc)\n" +">>> dt3\n" +"datetime.datetime(2006, 6, 14, 8, 30, tzinfo=datetime.timezone.utc)\n" +">>> dt2\n" +"datetime.datetime(2006, 6, 14, 13, 0, tzinfo=KabulTz())\n" +">>> dt2 == dt3\n" +"True" +msgstr "" + +#: library/datetime.rst:1700 msgid ":class:`.time` Objects" msgstr "" -#: library/datetime.rst:1678 +#: library/datetime.rst:1702 msgid "" "A :class:`.time` object represents a (local) time of day, independent of any " "particular day, and subject to adjustment via a :class:`tzinfo` object." msgstr "" -#: library/datetime.rst:1683 +#: library/datetime.rst:1707 msgid "" -"All arguments are optional. *tzinfo* may be ``None``, or an instance of a :" -"class:`tzinfo` subclass. The remaining arguments must be integers in the " +"All arguments are optional. *tzinfo* may be ``None``, or an instance of " +"a :class:`tzinfo` subclass. The remaining arguments must be integers in the " "following ranges:" msgstr "" -#: library/datetime.rst:1693 +#: library/datetime.rst:1717 msgid "" "If an argument outside those ranges is given, :exc:`ValueError` is raised. " -"All default to ``0`` except *tzinfo*, which defaults to :const:`None`." +"All default to 0 except *tzinfo*, which defaults to ``None``." msgstr "" -#: library/datetime.rst:1701 +#: library/datetime.rst:1725 msgid "The earliest representable :class:`.time`, ``time(0, 0, 0, 0)``." msgstr "" -#: library/datetime.rst:1706 +#: library/datetime.rst:1730 msgid "The latest representable :class:`.time`, ``time(23, 59, 59, 999999)``." msgstr "" -#: library/datetime.rst:1711 +#: library/datetime.rst:1735 msgid "" "The smallest possible difference between non-equal :class:`.time` objects, " -"``timedelta(microseconds=1)``, although note that arithmetic on :class:`." -"time` objects is not supported." +"``timedelta(microseconds=1)``, although note that arithmetic " +"on :class:`.time` objects is not supported." msgstr "" -#: library/datetime.rst:1740 +#: library/datetime.rst:1764 msgid "" "The object passed as the tzinfo argument to the :class:`.time` constructor, " "or ``None`` if none was passed." msgstr "" -#: library/datetime.rst:1754 +#: library/datetime.rst:1778 msgid "" -":class:`.time` objects support equality and order comparisons, where *a* is " -"considered less than *b* when *a* precedes *b* in time." +":class:`.time` objects support equality and order comparisons, where ``a`` " +"is considered less than ``b`` when ``a`` precedes ``b`` in time." msgstr "" -#: library/datetime.rst:1757 +#: library/datetime.rst:1781 msgid "" "Naive and aware :class:`!time` objects are never equal. Order comparison " "between naive and aware :class:`!time` objects raises :exc:`TypeError`." msgstr "" -#: library/datetime.rst:1761 +#: library/datetime.rst:1785 msgid "" "If both comparands are aware, and have the same :attr:`~.time.tzinfo` " "attribute, the :attr:`!tzinfo` and :attr:`!fold` attributes are ignored and " @@ -1955,18 +2394,18 @@ msgid "" "subtracting their UTC offsets (obtained from ``self.utcoffset()``)." msgstr "" -#: library/datetime.rst:1767 +#: library/datetime.rst:1791 msgid "" "Equality comparisons between aware and naive :class:`.time` instances don't " "raise :exc:`TypeError`." msgstr "" -#: library/datetime.rst:1771 +#: library/datetime.rst:1795 msgid "" "In Boolean contexts, a :class:`.time` object is always considered to be true." msgstr "" -#: library/datetime.rst:1773 +#: library/datetime.rst:1797 msgid "" "Before Python 3.5, a :class:`.time` object was considered to be false if it " "represented midnight in UTC. This behavior was considered obscure and error-" @@ -1974,39 +2413,61 @@ msgid "" "details." msgstr "" -#: library/datetime.rst:1780 +#: library/datetime.rst:1804 msgid "Other constructor:" msgstr "" -#: library/datetime.rst:1784 +#: library/datetime.rst:1808 msgid "" "Return a :class:`.time` corresponding to a *time_string* in any valid ISO " "8601 format, with the following exceptions:" msgstr "" -#: library/datetime.rst:1788 +#: library/datetime.rst:1812 msgid "" "The leading ``T``, normally required in cases where there may be ambiguity " "between a date and a time, is not required." msgstr "" -#: library/datetime.rst:1790 +#: library/datetime.rst:1814 msgid "" "Fractional seconds may have any number of digits (anything beyond 6 will be " "truncated)." msgstr "" -#: library/datetime.rst:1794 +#: library/datetime.rst:1818 msgid "Examples:" msgstr "" -#: library/datetime.rst:1818 +#: library/datetime.rst:1820 +msgid "" +">>> from datetime import time\n" +">>> time.fromisoformat('04:23:01')\n" +"datetime.time(4, 23, 1)\n" +">>> time.fromisoformat('T04:23:01')\n" +"datetime.time(4, 23, 1)\n" +">>> time.fromisoformat('T042301')\n" +"datetime.time(4, 23, 1)\n" +">>> time.fromisoformat('04:23:01.000384')\n" +"datetime.time(4, 23, 1, 384)\n" +">>> time.fromisoformat('04:23:01,000384')\n" +"datetime.time(4, 23, 1, 384)\n" +">>> time.fromisoformat('04:23:01+04:00')\n" +"datetime.time(4, 23, 1, " +"tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))\n" +">>> time.fromisoformat('04:23:01Z')\n" +"datetime.time(4, 23, 1, tzinfo=datetime.timezone.utc)\n" +">>> time.fromisoformat('04:23:01+00:00')\n" +"datetime.time(4, 23, 1, tzinfo=datetime.timezone.utc)" +msgstr "" + +#: library/datetime.rst:1842 msgid "" -"Previously, this method only supported formats that could be emitted by :" -"meth:`time.isoformat()`." +"Previously, this method only supported formats that could be emitted " +"by :meth:`time.isoformat`." msgstr "" -#: library/datetime.rst:1828 +#: library/datetime.rst:1852 msgid "" "Return a :class:`.time` with the same value, except for those attributes " "given new values by whichever keyword arguments are specified. Note that " @@ -2014,46 +2475,59 @@ msgid "" "aware :class:`.time`, without conversion of the time data." msgstr "" -#: library/datetime.rst:1839 +#: library/datetime.rst:1863 msgid "Return a string representing the time in ISO 8601 format, one of:" msgstr "" -#: library/datetime.rst:1841 +#: library/datetime.rst:1865 msgid "``HH:MM:SS.ffffff``, if :attr:`microsecond` is not 0" msgstr "" -#: library/datetime.rst:1842 +#: library/datetime.rst:1866 msgid "``HH:MM:SS``, if :attr:`microsecond` is 0" msgstr "" -#: library/datetime.rst:1843 +#: library/datetime.rst:1867 msgid "" "``HH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``, if :meth:`utcoffset` does not " "return ``None``" msgstr "" -#: library/datetime.rst:1844 +#: library/datetime.rst:1868 msgid "" -"``HH:MM:SS+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` is 0 and :meth:" -"`utcoffset` does not return ``None``" +"``HH:MM:SS+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` is 0 " +"and :meth:`utcoffset` does not return ``None``" msgstr "" -#: library/datetime.rst:1864 +#: library/datetime.rst:1888 msgid ":exc:`ValueError` will be raised on an invalid *timespec* argument." msgstr "" -#: library/datetime.rst:1883 -msgid "For a time *t*, ``str(t)`` is equivalent to ``t.isoformat()``." +#: library/datetime.rst:1892 +msgid "" +">>> from datetime import time\n" +">>> time(hour=12, minute=34, second=56, " +"microsecond=123456).isoformat(timespec='minutes')\n" +"'12:34'\n" +">>> dt = time(hour=12, minute=34, second=56, microsecond=0)\n" +">>> dt.isoformat(timespec='microseconds')\n" +"'12:34:56.000000'\n" +">>> dt.isoformat(timespec='auto')\n" +"'12:34:56'" msgstr "" -#: library/datetime.rst:1888 +#: library/datetime.rst:1907 +msgid "For a time ``t``, ``str(t)`` is equivalent to ``t.isoformat()``." +msgstr "" + +#: library/datetime.rst:1912 msgid "" "Return a string representing the time, controlled by an explicit format " -"string. See also :ref:`strftime-strptime-behavior` and :meth:`time." -"isoformat`." +"string. See also :ref:`strftime-strptime-behavior` " +"and :meth:`time.isoformat`." msgstr "" -#: library/datetime.rst:1894 +#: library/datetime.rst:1918 msgid "" "Same as :meth:`.time.strftime`. This makes it possible to specify a format " "string for a :class:`.time` object in :ref:`formatted string literals >> from datetime import time, tzinfo, timedelta\n" +">>> class TZ1(tzinfo):\n" +"... def utcoffset(self, dt):\n" +"... return timedelta(hours=1)\n" +"... def dst(self, dt):\n" +"... return timedelta(0)\n" +"... def tzname(self,dt):\n" +"... return \"+01:00\"\n" +"... def __repr__(self):\n" +"... return f\"{self.__class__.__name__}()\"\n" +"...\n" +">>> t = time(12, 10, 30, tzinfo=TZ1())\n" +">>> t\n" +"datetime.time(12, 10, 30, tzinfo=TZ1())\n" +">>> t.isoformat()\n" +"'12:10:30+01:00'\n" +">>> t.dst()\n" +"datetime.timedelta(0)\n" +">>> t.tzname()\n" +"'+01:00'\n" +">>> t.strftime(\"%H:%M:%S %Z\")\n" +"'12:10:30 +01:00'\n" +">>> 'The {} is {:%H:%M}.'.format(\"time\", t)\n" +"'The time is 12:10.'" +msgstr "" + +#: library/datetime.rst:1983 msgid ":class:`tzinfo` Objects" msgstr "" -#: library/datetime.rst:1963 +#: library/datetime.rst:1987 msgid "" "This is an abstract base class, meaning that this class should not be " "instantiated directly. Define a subclass of :class:`tzinfo` to capture " "information about a particular time zone." msgstr "" -#: library/datetime.rst:1967 +#: library/datetime.rst:1991 msgid "" "An instance of (a concrete subclass of) :class:`tzinfo` can be passed to the " "constructors for :class:`.datetime` and :class:`.time` objects. The latter " -"objects view their attributes as being in local time, and the :class:" -"`tzinfo` object supports methods revealing offset of local time from UTC, " -"the name of the time zone, and DST offset, all relative to a date or time " -"object passed to them." +"objects view their attributes as being in local time, and " +"the :class:`tzinfo` object supports methods revealing offset of local time " +"from UTC, the name of the time zone, and DST offset, all relative to a date " +"or time object passed to them." msgstr "" -#: library/datetime.rst:1973 +#: library/datetime.rst:1997 msgid "" "You need to derive a concrete subclass, and (at least) supply " -"implementations of the standard :class:`tzinfo` methods needed by the :class:" -"`.datetime` methods you use. The :mod:`!datetime` module provides :class:" -"`timezone`, a simple concrete subclass of :class:`tzinfo` which can " -"represent timezones with fixed offset from UTC such as UTC itself or North " -"American EST and EDT." +"implementations of the standard :class:`tzinfo` methods needed by " +"the :class:`.datetime` methods you use. The :mod:`!datetime` module " +"provides :class:`timezone`, a simple concrete subclass of :class:`tzinfo` " +"which can represent time zones with fixed offset from UTC such as UTC itself " +"or North American EST and EDT." msgstr "" -#: library/datetime.rst:1980 +#: library/datetime.rst:2004 msgid "" -"Special requirement for pickling: A :class:`tzinfo` subclass must have an :" -"meth:`~object.__init__` method that can be called with no arguments, " +"Special requirement for pickling: A :class:`tzinfo` subclass must have " +"an :meth:`~object.__init__` method that can be called with no arguments, " "otherwise it can be pickled but possibly not unpickled again. This is a " "technical requirement that may be relaxed in the future." msgstr "" -#: library/datetime.rst:1986 +#: library/datetime.rst:2010 msgid "" "A concrete subclass of :class:`tzinfo` may need to implement the following " -"methods. Exactly which methods are needed depends on the uses made of aware :" -"mod:`!datetime` objects. If in doubt, simply implement all of them." +"methods. Exactly which methods are needed depends on the uses made of " +"aware :mod:`!datetime` objects. If in doubt, simply implement all of them." msgstr "" -#: library/datetime.rst:1993 +#: library/datetime.rst:2017 msgid "" "Return offset of local time from UTC, as a :class:`timedelta` object that is " "positive east of UTC. If local time is west of UTC, this should be negative." msgstr "" -#: library/datetime.rst:1996 +#: library/datetime.rst:2020 msgid "" -"This represents the *total* offset from UTC; for example, if a :class:" -"`tzinfo` object represents both time zone and DST adjustments, :meth:" -"`utcoffset` should return their sum. If the UTC offset isn't known, return " -"``None``. Else the value returned must be a :class:`timedelta` object " -"strictly between ``-timedelta(hours=24)`` and ``timedelta(hours=24)`` (the " -"magnitude of the offset must be less than one day). Most implementations of :" -"meth:`utcoffset` will probably look like one of these two::" +"This represents the *total* offset from UTC; for example, if " +"a :class:`tzinfo` object represents both time zone and DST " +"adjustments, :meth:`utcoffset` should return their sum. If the UTC offset " +"isn't known, return ``None``. Else the value returned must be " +"a :class:`timedelta` object strictly between ``-timedelta(hours=24)`` and " +"``timedelta(hours=24)`` (the magnitude of the offset must be less than one " +"day). Most implementations of :meth:`utcoffset` will probably look like one " +"of these two::" msgstr "" -#: library/datetime.rst:2007 +#: library/datetime.rst:2028 +msgid "" +"return CONSTANT # fixed-offset class\n" +"return CONSTANT + self.dst(dt) # daylight-aware class" +msgstr "" + +#: library/datetime.rst:2031 msgid "" "If :meth:`utcoffset` does not return ``None``, :meth:`dst` should not return " "``None`` either." msgstr "" -#: library/datetime.rst:2010 +#: library/datetime.rst:2034 msgid "" -"The default implementation of :meth:`utcoffset` raises :exc:" -"`NotImplementedError`." +"The default implementation of :meth:`utcoffset` " +"raises :exc:`NotImplementedError`." msgstr "" -#: library/datetime.rst:2019 +#: library/datetime.rst:2043 msgid "" "Return the daylight saving time (DST) adjustment, as a :class:`timedelta` " "object or ``None`` if DST information isn't known." msgstr "" -#: library/datetime.rst:2023 +#: library/datetime.rst:2047 msgid "" "Return ``timedelta(0)`` if DST is not in effect. If DST is in effect, return " "the offset as a :class:`timedelta` object (see :meth:`utcoffset` for " "details). Note that DST offset, if applicable, has already been added to the " -"UTC offset returned by :meth:`utcoffset`, so there's no need to consult :" -"meth:`dst` unless you're interested in obtaining DST info separately. For " -"example, :meth:`datetime.timetuple` calls its :attr:`~.datetime.tzinfo` " -"attribute's :meth:`dst` method to determine how the :attr:`~time.struct_time." -"tm_isdst` flag should be set, and :meth:`tzinfo.fromutc` calls :meth:`dst` " -"to account for DST changes when crossing time zones." +"UTC offset returned by :meth:`utcoffset`, so there's no need to " +"consult :meth:`dst` unless you're interested in obtaining DST info " +"separately. For example, :meth:`datetime.timetuple` calls " +"its :attr:`~.datetime.tzinfo` attribute's :meth:`dst` method to determine " +"how the :attr:`~time.struct_time.tm_isdst` flag should be set, " +"and :meth:`tzinfo.fromutc` calls :meth:`dst` to account for DST changes when " +"crossing time zones." msgstr "" -#: library/datetime.rst:2033 +#: library/datetime.rst:2057 msgid "" "An instance *tz* of a :class:`tzinfo` subclass that models both standard and " "daylight times must be consistent in this sense:" msgstr "" -#: library/datetime.rst:2036 +#: library/datetime.rst:2060 msgid "``tz.utcoffset(dt) - tz.dst(dt)``" msgstr "" -#: library/datetime.rst:2038 +#: library/datetime.rst:2062 msgid "" -"must return the same result for every :class:`.datetime` *dt* with ``dt." -"tzinfo == tz`` For sane :class:`tzinfo` subclasses, this expression yields " -"the time zone's \"standard offset\", which should not depend on the date or " -"the time, but only on geographic location. The implementation of :meth:" -"`datetime.astimezone` relies on this, but cannot detect violations; it's the " -"programmer's responsibility to ensure it. If a :class:`tzinfo` subclass " -"cannot guarantee this, it may be able to override the default implementation " -"of :meth:`tzinfo.fromutc` to work correctly with :meth:`~.datetime." -"astimezone` regardless." +"must return the same result for every :class:`.datetime` *dt* with " +"``dt.tzinfo == tz``. For sane :class:`tzinfo` subclasses, this expression " +"yields the time zone's \"standard offset\", which should not depend on the " +"date or the time, but only on geographic location. The implementation " +"of :meth:`datetime.astimezone` relies on this, but cannot detect violations; " +"it's the programmer's responsibility to ensure it. If a :class:`tzinfo` " +"subclass cannot guarantee this, it may be able to override the default " +"implementation of :meth:`tzinfo.fromutc` to work correctly " +"with :meth:`~.datetime.astimezone` regardless." msgstr "" -#: library/datetime.rst:2047 +#: library/datetime.rst:2071 msgid "" "Most implementations of :meth:`dst` will probably look like one of these " "two::" msgstr "" -#: library/datetime.rst:2053 +#: library/datetime.rst:2073 +msgid "" +"def dst(self, dt):\n" +" # a fixed-offset class: doesn't account for DST\n" +" return timedelta(0)" +msgstr "" + +#: library/datetime.rst:2077 msgid "or::" msgstr "" -#: library/datetime.rst:2065 +#: library/datetime.rst:2079 +msgid "" +"def dst(self, dt):\n" +" # Code to set dston and dstoff to the time zone's DST\n" +" # transition times based on the input dt.year, and expressed\n" +" # in standard local time.\n" +"\n" +" if dston <= dt.replace(tzinfo=None) < dstoff:\n" +" return timedelta(hours=1)\n" +" else:\n" +" return timedelta(0)" +msgstr "" + +#: library/datetime.rst:2089 msgid "" "The default implementation of :meth:`dst` raises :exc:`NotImplementedError`." msgstr "" -#: library/datetime.rst:2073 +#: library/datetime.rst:2097 msgid "" "Return the time zone name corresponding to the :class:`.datetime` object " "*dt*, as a string. Nothing about string names is defined by the :mod:`!" "datetime` module, and there's no requirement that it mean anything in " -"particular. For example, \"GMT\", \"UTC\", \"-500\", \"-5:00\", \"EDT\", " -"\"US/Eastern\", \"America/New York\" are all valid replies. Return ``None`` " -"if a string name isn't known. Note that this is a method rather than a fixed " -"string primarily because some :class:`tzinfo` subclasses will wish to return " -"different names depending on the specific value of *dt* passed, especially " -"if the :class:`tzinfo` class is accounting for daylight time." +"particular. For example, ``\"GMT\"``, ``\"UTC\"``, ``\"-500\"``, " +"``\"-5:00\"``, ``\"EDT\"``, ``\"US/Eastern\"``, ``\"America/New York\"`` are " +"all valid replies. Return ``None`` if a string name isn't known. Note that " +"this is a method rather than a fixed string primarily because " +"some :class:`tzinfo` subclasses will wish to return different names " +"depending on the specific value of *dt* passed, especially if " +"the :class:`tzinfo` class is accounting for daylight time." msgstr "" -#: library/datetime.rst:2083 +#: library/datetime.rst:2107 msgid "" -"The default implementation of :meth:`tzname` raises :exc:" -"`NotImplementedError`." +"The default implementation of :meth:`tzname` " +"raises :exc:`NotImplementedError`." msgstr "" -#: library/datetime.rst:2086 +#: library/datetime.rst:2110 msgid "" "These methods are called by a :class:`.datetime` or :class:`.time` object, " "in response to their methods of the same names. A :class:`.datetime` object " "passes itself as the argument, and a :class:`.time` object passes ``None`` " "as the argument. A :class:`tzinfo` subclass's methods should therefore be " -"prepared to accept a *dt* argument of ``None``, or of class :class:`." -"datetime`." +"prepared to accept a *dt* argument of ``None``, or of " +"class :class:`.datetime`." msgstr "" -#: library/datetime.rst:2092 +#: library/datetime.rst:2116 msgid "" "When ``None`` is passed, it's up to the class designer to decide the best " "response. For example, returning ``None`` is appropriate if the class wishes " @@ -2260,68 +2793,277 @@ msgid "" "offset, as there is no other convention for discovering the standard offset." msgstr "" -#: library/datetime.rst:2098 +#: library/datetime.rst:2122 msgid "" -"When a :class:`.datetime` object is passed in response to a :class:`." -"datetime` method, ``dt.tzinfo`` is the same object as *self*. :class:" -"`tzinfo` methods can rely on this, unless user code calls :class:`tzinfo` " -"methods directly. The intent is that the :class:`tzinfo` methods interpret " -"*dt* as being in local time, and not need worry about objects in other " -"timezones." +"When a :class:`.datetime` object is passed in response to " +"a :class:`.datetime` method, ``dt.tzinfo`` is the same object as " +"*self*. :class:`tzinfo` methods can rely on this, unless user code " +"calls :class:`tzinfo` methods directly. The intent is that " +"the :class:`tzinfo` methods interpret *dt* as being in local time, and not " +"need worry about objects in other time zones." msgstr "" -#: library/datetime.rst:2104 +#: library/datetime.rst:2128 msgid "" "There is one more :class:`tzinfo` method that a subclass may wish to " "override:" msgstr "" -#: library/datetime.rst:2109 +#: library/datetime.rst:2133 msgid "" -"This is called from the default :class:`datetime.astimezone()` " -"implementation. When called from that, ``dt.tzinfo`` is *self*, and *dt*'s " -"date and time data are to be viewed as expressing a UTC time. The purpose " +"This is called from the default :meth:`datetime.astimezone` implementation. " +"When called from that, ``dt.tzinfo`` is *self*, and *dt*'s date and time " +"data are to be viewed as expressing a UTC time. The purpose " "of :meth:`fromutc` is to adjust the date and time data, returning an " "equivalent datetime in *self*'s local time." msgstr "" -#: library/datetime.rst:2115 +#: library/datetime.rst:2139 msgid "" -"Most :class:`tzinfo` subclasses should be able to inherit the default :meth:" -"`fromutc` implementation without problems. It's strong enough to handle " -"fixed-offset time zones, and time zones accounting for both standard and " -"daylight time, and the latter even if the DST transition times differ in " -"different years. An example of a time zone the default :meth:`fromutc` " -"implementation may not handle correctly in all cases is one where the " -"standard offset (from UTC) depends on the specific date and time passed, " -"which can happen for political reasons. The default implementations of :meth:" -"`~.datetime.astimezone` and :meth:`fromutc` may not produce the result you " -"want if the result is one of the hours straddling the moment the standard " -"offset changes." +"Most :class:`tzinfo` subclasses should be able to inherit the " +"default :meth:`fromutc` implementation without problems. It's strong enough " +"to handle fixed-offset time zones, and time zones accounting for both " +"standard and daylight time, and the latter even if the DST transition times " +"differ in different years. An example of a time zone the " +"default :meth:`fromutc` implementation may not handle correctly in all cases " +"is one where the standard offset (from UTC) depends on the specific date and " +"time passed, which can happen for political reasons. The default " +"implementations of :meth:`~.datetime.astimezone` and :meth:`fromutc` may not " +"produce the result you want if the result is one of the hours straddling the " +"moment the standard offset changes." msgstr "" -#: library/datetime.rst:2126 +#: library/datetime.rst:2150 msgid "" "Skipping code for error cases, the default :meth:`fromutc` implementation " "acts like::" msgstr "" -#: library/datetime.rst:2144 -msgid "" -"In the following :download:`tzinfo_examples.py <../includes/tzinfo_examples." -"py>` file there are some examples of :class:`tzinfo` classes:" -msgstr "" - -#: library/datetime.rst:2150 -msgid "" -"Note that there are unavoidable subtleties twice per year in a :class:" -"`tzinfo` subclass accounting for both standard and daylight time, at the DST " -"transition points. For concreteness, consider US Eastern (UTC -0500), where " -"EDT begins the minute after 1:59 (EST) on the second Sunday in March, and " -"ends the minute after 1:59 (EDT) on the first Sunday in November::" -msgstr "" - -#: library/datetime.rst:2164 +#: library/datetime.rst:2153 +msgid "" +"def fromutc(self, dt):\n" +" # raise ValueError error if dt.tzinfo is not self\n" +" dtoff = dt.utcoffset()\n" +" dtdst = dt.dst()\n" +" # raise ValueError if dtoff is None or dtdst is None\n" +" delta = dtoff - dtdst # this is self's standard offset\n" +" if delta:\n" +" dt += delta # convert to standard local time\n" +" dtdst = dt.dst()\n" +" # raise ValueError if dtdst is None\n" +" if dtdst:\n" +" return dt + dtdst\n" +" else:\n" +" return dt" +msgstr "" + +#: library/datetime.rst:2168 +msgid "" +"In the following :download:`tzinfo_examples.py <../includes/" +"tzinfo_examples.py>` file there are some examples of :class:`tzinfo` classes:" +msgstr "" + +#: library/datetime.rst:2172 +msgid "" +"from datetime import tzinfo, timedelta, datetime\n" +"\n" +"ZERO = timedelta(0)\n" +"HOUR = timedelta(hours=1)\n" +"SECOND = timedelta(seconds=1)\n" +"\n" +"# A class capturing the platform's idea of local time.\n" +"# (May result in wrong values on historical times in\n" +"# timezones where UTC offset and/or the DST rules had\n" +"# changed in the past.)\n" +"import time as _time\n" +"\n" +"STDOFFSET = timedelta(seconds = -_time.timezone)\n" +"if _time.daylight:\n" +" DSTOFFSET = timedelta(seconds = -_time.altzone)\n" +"else:\n" +" DSTOFFSET = STDOFFSET\n" +"\n" +"DSTDIFF = DSTOFFSET - STDOFFSET\n" +"\n" +"class LocalTimezone(tzinfo):\n" +"\n" +" def fromutc(self, dt):\n" +" assert dt.tzinfo is self\n" +" stamp = (dt - datetime(1970, 1, 1, tzinfo=self)) // SECOND\n" +" args = _time.localtime(stamp)[:6]\n" +" dst_diff = DSTDIFF // SECOND\n" +" # Detect fold\n" +" fold = (args == _time.localtime(stamp - dst_diff))\n" +" return datetime(*args, microsecond=dt.microsecond,\n" +" tzinfo=self, fold=fold)\n" +"\n" +" def utcoffset(self, dt):\n" +" if self._isdst(dt):\n" +" return DSTOFFSET\n" +" else:\n" +" return STDOFFSET\n" +"\n" +" def dst(self, dt):\n" +" if self._isdst(dt):\n" +" return DSTDIFF\n" +" else:\n" +" return ZERO\n" +"\n" +" def tzname(self, dt):\n" +" return _time.tzname[self._isdst(dt)]\n" +"\n" +" def _isdst(self, dt):\n" +" tt = (dt.year, dt.month, dt.day,\n" +" dt.hour, dt.minute, dt.second,\n" +" dt.weekday(), 0, 0)\n" +" stamp = _time.mktime(tt)\n" +" tt = _time.localtime(stamp)\n" +" return tt.tm_isdst > 0\n" +"\n" +"Local = LocalTimezone()\n" +"\n" +"\n" +"# A complete implementation of current DST rules for major US time zones.\n" +"\n" +"def first_sunday_on_or_after(dt):\n" +" days_to_go = 6 - dt.weekday()\n" +" if days_to_go:\n" +" dt += timedelta(days_to_go)\n" +" return dt\n" +"\n" +"\n" +"# US DST Rules\n" +"#\n" +"# This is a simplified (i.e., wrong for a few cases) set of rules for US\n" +"# DST start and end times. For a complete and up-to-date set of DST rules\n" +"# and timezone definitions, visit the Olson Database (or try pytz):\n" +"# http://www.twinsun.com/tz/tz-link.htm\n" +"# https://sourceforge.net/projects/pytz/ (might not be up-to-date)\n" +"#\n" +"# In the US, since 2007, DST starts at 2am (standard time) on the second\n" +"# Sunday in March, which is the first Sunday on or after Mar 8.\n" +"DSTSTART_2007 = datetime(1, 3, 8, 2)\n" +"# and ends at 2am (DST time) on the first Sunday of Nov.\n" +"DSTEND_2007 = datetime(1, 11, 1, 2)\n" +"# From 1987 to 2006, DST used to start at 2am (standard time) on the first\n" +"# Sunday in April and to end at 2am (DST time) on the last\n" +"# Sunday of October, which is the first Sunday on or after Oct 25.\n" +"DSTSTART_1987_2006 = datetime(1, 4, 1, 2)\n" +"DSTEND_1987_2006 = datetime(1, 10, 25, 2)\n" +"# From 1967 to 1986, DST used to start at 2am (standard time) on the last\n" +"# Sunday in April (the one on or after April 24) and to end at 2am (DST " +"time)\n" +"# on the last Sunday of October, which is the first Sunday\n" +"# on or after Oct 25.\n" +"DSTSTART_1967_1986 = datetime(1, 4, 24, 2)\n" +"DSTEND_1967_1986 = DSTEND_1987_2006\n" +"\n" +"def us_dst_range(year):\n" +" # Find start and end times for US DST. For years before 1967, return\n" +" # start = end for no DST.\n" +" if 2006 < year:\n" +" dststart, dstend = DSTSTART_2007, DSTEND_2007\n" +" elif 1986 < year < 2007:\n" +" dststart, dstend = DSTSTART_1987_2006, DSTEND_1987_2006\n" +" elif 1966 < year < 1987:\n" +" dststart, dstend = DSTSTART_1967_1986, DSTEND_1967_1986\n" +" else:\n" +" return (datetime(year, 1, 1), ) * 2\n" +"\n" +" start = first_sunday_on_or_after(dststart.replace(year=year))\n" +" end = first_sunday_on_or_after(dstend.replace(year=year))\n" +" return start, end\n" +"\n" +"\n" +"class USTimeZone(tzinfo):\n" +"\n" +" def __init__(self, hours, reprname, stdname, dstname):\n" +" self.stdoffset = timedelta(hours=hours)\n" +" self.reprname = reprname\n" +" self.stdname = stdname\n" +" self.dstname = dstname\n" +"\n" +" def __repr__(self):\n" +" return self.reprname\n" +"\n" +" def tzname(self, dt):\n" +" if self.dst(dt):\n" +" return self.dstname\n" +" else:\n" +" return self.stdname\n" +"\n" +" def utcoffset(self, dt):\n" +" return self.stdoffset + self.dst(dt)\n" +"\n" +" def dst(self, dt):\n" +" if dt is None or dt.tzinfo is None:\n" +" # An exception may be sensible here, in one or both cases.\n" +" # It depends on how you want to treat them. The default\n" +" # fromutc() implementation (called by the default astimezone()\n" +" # implementation) passes a datetime with dt.tzinfo is self.\n" +" return ZERO\n" +" assert dt.tzinfo is self\n" +" start, end = us_dst_range(dt.year)\n" +" # Can't compare naive to aware objects, so strip the timezone from\n" +" # dt first.\n" +" dt = dt.replace(tzinfo=None)\n" +" if start + HOUR <= dt < end - HOUR:\n" +" # DST is in effect.\n" +" return HOUR\n" +" if end - HOUR <= dt < end:\n" +" # Fold (an ambiguous hour): use dt.fold to disambiguate.\n" +" return ZERO if dt.fold else HOUR\n" +" if start <= dt < start + HOUR:\n" +" # Gap (a non-existent hour): reverse the fold rule.\n" +" return HOUR if dt.fold else ZERO\n" +" # DST is off.\n" +" return ZERO\n" +"\n" +" def fromutc(self, dt):\n" +" assert dt.tzinfo is self\n" +" start, end = us_dst_range(dt.year)\n" +" start = start.replace(tzinfo=self)\n" +" end = end.replace(tzinfo=self)\n" +" std_time = dt + self.stdoffset\n" +" dst_time = std_time + HOUR\n" +" if end <= dst_time < end + HOUR:\n" +" # Repeated hour\n" +" return std_time.replace(fold=1)\n" +" if std_time < start or dst_time >= end:\n" +" # Standard time\n" +" return std_time\n" +" if start <= std_time < end - HOUR:\n" +" # Daylight saving time\n" +" return dst_time\n" +"\n" +"\n" +"Eastern = USTimeZone(-5, \"Eastern\", \"EST\", \"EDT\")\n" +"Central = USTimeZone(-6, \"Central\", \"CST\", \"CDT\")\n" +"Mountain = USTimeZone(-7, \"Mountain\", \"MST\", \"MDT\")\n" +"Pacific = USTimeZone(-8, \"Pacific\", \"PST\", \"PDT\")\n" +msgstr "" + +#: library/datetime.rst:2174 +msgid "" +"Note that there are unavoidable subtleties twice per year in " +"a :class:`tzinfo` subclass accounting for both standard and daylight time, " +"at the DST transition points. For concreteness, consider US Eastern (UTC " +"-0500), where EDT begins the minute after 1:59 (EST) on the second Sunday in " +"March, and ends the minute after 1:59 (EDT) on the first Sunday in November::" +msgstr "" + +#: library/datetime.rst:2180 +msgid "" +" UTC 3:MM 4:MM 5:MM 6:MM 7:MM 8:MM\n" +" EST 22:MM 23:MM 0:MM 1:MM 2:MM 3:MM\n" +" EDT 23:MM 0:MM 1:MM 2:MM 3:MM 4:MM\n" +"\n" +"start 22:MM 23:MM 0:MM 1:MM 3:MM 4:MM\n" +"\n" +" end 23:MM 0:MM 1:MM 1:MM 2:MM 3:MM" +msgstr "" + +#: library/datetime.rst:2188 msgid "" "When DST starts (the \"start\" line), the local wall clock leaps from 1:59 " "to 3:00. A wall time of the form 2:MM doesn't really make sense on that day, " @@ -2330,7 +3072,23 @@ msgid "" "get::" msgstr "" -#: library/datetime.rst:2183 +#: library/datetime.rst:2193 +msgid "" +">>> from datetime import datetime, timezone\n" +">>> from tzinfo_examples import HOUR, Eastern\n" +">>> u0 = datetime(2016, 3, 13, 5, tzinfo=timezone.utc)\n" +">>> for i in range(4):\n" +"... u = u0 + i*HOUR\n" +"... t = u.astimezone(Eastern)\n" +"... print(u.time(), 'UTC =', t.time(), t.tzname())\n" +"...\n" +"05:00:00 UTC = 00:00:00 EST\n" +"06:00:00 UTC = 01:00:00 EST\n" +"07:00:00 UTC = 03:00:00 EDT\n" +"08:00:00 UTC = 04:00:00 EDT" +msgstr "" + +#: library/datetime.rst:2207 msgid "" "When DST ends (the \"end\" line), there's a potentially worse problem: " "there's an hour that can't be spelled unambiguously in local wall time: the " @@ -2345,44 +3103,58 @@ msgid "" "Fall back transition of 2016, we get::" msgstr "" -#: library/datetime.rst:2205 +#: library/datetime.rst:2218 +msgid "" +">>> u0 = datetime(2016, 11, 6, 4, tzinfo=timezone.utc)\n" +">>> for i in range(4):\n" +"... u = u0 + i*HOUR\n" +"... t = u.astimezone(Eastern)\n" +"... print(u.time(), 'UTC =', t.time(), t.tzname(), t.fold)\n" +"...\n" +"04:00:00 UTC = 00:00:00 EDT 0\n" +"05:00:00 UTC = 01:00:00 EDT 0\n" +"06:00:00 UTC = 01:00:00 EST 1\n" +"07:00:00 UTC = 02:00:00 EST 0" +msgstr "" + +#: library/datetime.rst:2229 msgid "" "Note that the :class:`.datetime` instances that differ only by the value of " "the :attr:`~.datetime.fold` attribute are considered equal in comparisons." msgstr "" -#: library/datetime.rst:2208 +#: library/datetime.rst:2232 msgid "" "Applications that can't bear wall-time ambiguities should explicitly check " -"the value of the :attr:`~.datetime.fold` attribute or avoid using hybrid :" -"class:`tzinfo` subclasses; there are no ambiguities when using :class:" -"`timezone`, or any other fixed-offset :class:`tzinfo` subclass (such as a " -"class representing only EST (fixed offset -5 hours), or only EDT (fixed " -"offset -4 hours))." +"the value of the :attr:`~.datetime.fold` attribute or avoid using " +"hybrid :class:`tzinfo` subclasses; there are no ambiguities when " +"using :class:`timezone`, or any other fixed-offset :class:`tzinfo` subclass " +"(such as a class representing only EST (fixed offset -5 hours), or only EDT " +"(fixed offset -4 hours))." msgstr "" -#: library/datetime.rst:2222 +#: library/datetime.rst:2240 msgid ":mod:`zoneinfo`" msgstr "" -#: library/datetime.rst:2217 +#: library/datetime.rst:2241 msgid "" "The :mod:`!datetime` module has a basic :class:`timezone` class (for " "handling arbitrary fixed offsets from UTC) and its :attr:`timezone.utc` " -"attribute (a UTC timezone instance)." +"attribute (a UTC :class:`!timezone` instance)." msgstr "" -#: library/datetime.rst:2221 +#: library/datetime.rst:2245 msgid "" -"``zoneinfo`` brings the *IANA timezone database* (also known as the Olson " +"``zoneinfo`` brings the *IANA time zone database* (also known as the Olson " "database) to Python, and its usage is recommended." msgstr "" -#: library/datetime.rst:2228 -msgid "`IANA timezone database `_" +#: library/datetime.rst:2248 +msgid "`IANA time zone database `_" msgstr "" -#: library/datetime.rst:2225 +#: library/datetime.rst:2249 msgid "" "The Time Zone Database (often called tz, tzdata or zoneinfo) contains code " "and data that represent the history of local time for many representative " @@ -2391,24 +3163,24 @@ msgid "" "saving rules." msgstr "" -#: library/datetime.rst:2235 +#: library/datetime.rst:2259 msgid ":class:`timezone` Objects" msgstr "" -#: library/datetime.rst:2237 +#: library/datetime.rst:2261 msgid "" "The :class:`timezone` class is a subclass of :class:`tzinfo`, each instance " -"of which represents a timezone defined by a fixed offset from UTC." +"of which represents a time zone defined by a fixed offset from UTC." msgstr "" -#: library/datetime.rst:2241 +#: library/datetime.rst:2265 msgid "" -"Objects of this class cannot be used to represent timezone information in " +"Objects of this class cannot be used to represent time zone information in " "the locations where different offsets are used in different days of the year " "or where historical changes have been made to civil time." msgstr "" -#: library/datetime.rst:2248 +#: library/datetime.rst:2272 msgid "" "The *offset* argument must be specified as a :class:`timedelta` object " "representing the difference between the local time and UTC. It must be " @@ -2416,25 +3188,25 @@ msgid "" "otherwise :exc:`ValueError` is raised." msgstr "" -#: library/datetime.rst:2253 +#: library/datetime.rst:2277 msgid "" "The *name* argument is optional. If specified it must be a string that will " "be used as the value returned by the :meth:`datetime.tzname` method." msgstr "" -#: library/datetime.rst:2275 +#: library/datetime.rst:2299 msgid "" "Return the fixed value specified when the :class:`timezone` instance is " "constructed." msgstr "" -#: library/datetime.rst:2267 +#: library/datetime.rst:2291 msgid "" "The *dt* argument is ignored. The return value is a :class:`timedelta` " "instance equal to the difference between the local time and UTC." msgstr "" -#: library/datetime.rst:2278 +#: library/datetime.rst:2302 msgid "" "If *name* is not provided in the constructor, the name returned by " "``tzname(dt)`` is generated from the value of the ``offset`` as follows. If " @@ -2443,145 +3215,154 @@ msgid "" "are two digits of ``offset.hours`` and ``offset.minutes`` respectively." msgstr "" -#: library/datetime.rst:2284 +#: library/datetime.rst:2308 msgid "" "Name generated from ``offset=timedelta(0)`` is now plain ``'UTC'``, not " "``'UTC+00:00'``." msgstr "" -#: library/datetime.rst:2291 +#: library/datetime.rst:2315 msgid "Always returns ``None``." msgstr "" -#: library/datetime.rst:2295 +#: library/datetime.rst:2319 msgid "" -"Return ``dt + offset``. The *dt* argument must be an aware :class:`." -"datetime` instance, with ``tzinfo`` set to ``self``." +"Return ``dt + offset``. The *dt* argument must be an " +"aware :class:`.datetime` instance, with ``tzinfo`` set to ``self``." msgstr "" -#: library/datetime.rst:2302 -msgid "The UTC timezone, ``timezone(timedelta(0))``." +#: library/datetime.rst:2326 +msgid "The UTC time zone, ``timezone(timedelta(0))``." msgstr "" -#: library/datetime.rst:2311 +#: library/datetime.rst:2335 msgid ":meth:`~.datetime.strftime` and :meth:`~.datetime.strptime` Behavior" msgstr "" -#: library/datetime.rst:2313 +#: library/datetime.rst:2337 msgid "" ":class:`date`, :class:`.datetime`, and :class:`.time` objects all support a " "``strftime(format)`` method, to create a string representing the time under " "the control of an explicit format string." msgstr "" -#: library/datetime.rst:2317 +#: library/datetime.rst:2341 msgid "" -"Conversely, the :meth:`datetime.strptime` class method creates a :class:`." -"datetime` object from a string representing a date and time and a " +"Conversely, the :meth:`datetime.strptime` class method creates " +"a :class:`.datetime` object from a string representing a date and time and a " "corresponding format string." msgstr "" -#: library/datetime.rst:2321 +#: library/datetime.rst:2345 msgid "" -"The table below provides a high-level comparison of :meth:`~.datetime." -"strftime` versus :meth:`~.datetime.strptime`:" +"The table below provides a high-level comparison " +"of :meth:`~.datetime.strftime` versus :meth:`~.datetime.strptime`:" msgstr "" -#: library/datetime.rst:2325 +#: library/datetime.rst:2349 msgid "``strftime``" msgstr "" -#: library/datetime.rst:2325 +#: library/datetime.rst:2349 msgid "``strptime``" msgstr "" -#: library/datetime.rst:2327 +#: library/datetime.rst:2351 msgid "Usage" msgstr "" -#: library/datetime.rst:2327 +#: library/datetime.rst:2351 msgid "Convert object to a string according to a given format" msgstr "" -#: library/datetime.rst:2327 +#: library/datetime.rst:2351 msgid "" "Parse a string into a :class:`.datetime` object given a corresponding format" msgstr "" -#: library/datetime.rst:2329 +#: library/datetime.rst:2353 msgid "Type of method" msgstr "" -#: library/datetime.rst:2329 +#: library/datetime.rst:2353 msgid "Instance method" msgstr "" -#: library/datetime.rst:2329 +#: library/datetime.rst:2353 msgid "Class method" msgstr "" -#: library/datetime.rst:2331 +#: library/datetime.rst:2355 msgid "Method of" msgstr "" -#: library/datetime.rst:2331 +#: library/datetime.rst:2355 msgid ":class:`date`; :class:`.datetime`; :class:`.time`" msgstr "" -#: library/datetime.rst:2331 +#: library/datetime.rst:2355 msgid ":class:`.datetime`" msgstr "" -#: library/datetime.rst:2333 +#: library/datetime.rst:2357 msgid "Signature" msgstr "" -#: library/datetime.rst:2333 +#: library/datetime.rst:2357 msgid "``strftime(format)``" msgstr "" -#: library/datetime.rst:2333 +#: library/datetime.rst:2357 msgid "``strptime(date_string, format)``" msgstr "" -#: library/datetime.rst:2340 +#: library/datetime.rst:2364 msgid "" ":meth:`~.datetime.strftime` and :meth:`~.datetime.strptime` Format Codes" msgstr "" -#: library/datetime.rst:2342 +#: library/datetime.rst:2366 msgid "" "These methods accept format codes that can be used to parse and format " "dates::" msgstr "" -#: library/datetime.rst:2350 +#: library/datetime.rst:2368 +msgid "" +">>> datetime.strptime('31/01/22 23:59:59.999999',\n" +"... '%d/%m/%y %H:%M:%S.%f')\n" +"datetime.datetime(2022, 1, 31, 23, 59, 59, 999999)\n" +">>> _.strftime('%a %d %b %Y, %I:%M%p')\n" +"'Mon 31 Jan 2022, 11:59PM'" +msgstr "" + +#: library/datetime.rst:2374 msgid "" "The following is a list of all the format codes that the 1989 C standard " "requires, and these work on all platforms with a standard C implementation." msgstr "" -#: library/datetime.rst:2457 +#: library/datetime.rst:2481 msgid "Directive" msgstr "" -#: library/datetime.rst:2457 +#: library/datetime.rst:2481 msgid "Meaning" msgstr "" -#: library/datetime.rst:2457 +#: library/datetime.rst:2481 msgid "Example" msgstr "" -#: library/datetime.rst:2457 +#: library/datetime.rst:2481 msgid "Notes" msgstr "" -#: library/datetime.rst:2356 +#: library/datetime.rst:2380 msgid "``%a``" msgstr "" -#: library/datetime.rst:2356 +#: library/datetime.rst:2380 msgid "Weekday as locale's abbreviated name." msgstr "" @@ -2593,11 +3374,11 @@ msgstr "" msgid "So, Mo, ..., Sa (de_DE)" msgstr "" -#: library/datetime.rst:2361 +#: library/datetime.rst:2385 msgid "``%A``" msgstr "" -#: library/datetime.rst:2361 +#: library/datetime.rst:2385 msgid "Weekday as locale's full name." msgstr "" @@ -2609,40 +3390,40 @@ msgstr "" msgid "Sonntag, Montag, ..., Samstag (de_DE)" msgstr "" -#: library/datetime.rst:2366 +#: library/datetime.rst:2390 msgid "``%w``" msgstr "" -#: library/datetime.rst:2366 +#: library/datetime.rst:2390 msgid "Weekday as a decimal number, where 0 is Sunday and 6 is Saturday." msgstr "" -#: library/datetime.rst:2366 +#: library/datetime.rst:2390 msgid "0, 1, ..., 6" msgstr "" -#: library/datetime.rst:2370 +#: library/datetime.rst:2394 msgid "``%d``" msgstr "" -#: library/datetime.rst:2370 +#: library/datetime.rst:2394 msgid "Day of the month as a zero-padded decimal number." msgstr "" -#: library/datetime.rst:2370 +#: library/datetime.rst:2394 msgid "01, 02, ..., 31" msgstr "" -#: library/datetime.rst:2383 library/datetime.rst:2392 -#: library/datetime.rst:2401 library/datetime.rst:2419 +#: library/datetime.rst:2407 library/datetime.rst:2416 +#: library/datetime.rst:2425 library/datetime.rst:2443 msgid "\\(9)" msgstr "" -#: library/datetime.rst:2373 +#: library/datetime.rst:2397 msgid "``%b``" msgstr "" -#: library/datetime.rst:2373 +#: library/datetime.rst:2397 msgid "Month as locale's abbreviated name." msgstr "" @@ -2654,11 +3435,11 @@ msgstr "" msgid "Jan, Feb, ..., Dez (de_DE)" msgstr "" -#: library/datetime.rst:2378 +#: library/datetime.rst:2402 msgid "``%B``" msgstr "" -#: library/datetime.rst:2378 +#: library/datetime.rst:2402 msgid "Month as locale's full name." msgstr "" @@ -2670,67 +3451,67 @@ msgstr "" msgid "Januar, Februar, ..., Dezember (de_DE)" msgstr "" -#: library/datetime.rst:2383 +#: library/datetime.rst:2407 msgid "``%m``" msgstr "" -#: library/datetime.rst:2383 +#: library/datetime.rst:2407 msgid "Month as a zero-padded decimal number." msgstr "" -#: library/datetime.rst:2395 +#: library/datetime.rst:2419 msgid "01, 02, ..., 12" msgstr "" -#: library/datetime.rst:2386 +#: library/datetime.rst:2410 msgid "``%y``" msgstr "" -#: library/datetime.rst:2386 +#: library/datetime.rst:2410 msgid "Year without century as a zero-padded decimal number." msgstr "" -#: library/datetime.rst:2386 +#: library/datetime.rst:2410 msgid "00, 01, ..., 99" msgstr "" -#: library/datetime.rst:2389 +#: library/datetime.rst:2413 msgid "``%Y``" msgstr "" -#: library/datetime.rst:2389 +#: library/datetime.rst:2413 msgid "Year with century as a decimal number." msgstr "" -#: library/datetime.rst:2459 +#: library/datetime.rst:2483 msgid "0001, 0002, ..., 2013, 2014, ..., 9998, 9999" msgstr "" -#: library/datetime.rst:2392 +#: library/datetime.rst:2416 msgid "``%H``" msgstr "" -#: library/datetime.rst:2392 +#: library/datetime.rst:2416 msgid "Hour (24-hour clock) as a zero-padded decimal number." msgstr "" -#: library/datetime.rst:2392 +#: library/datetime.rst:2416 msgid "00, 01, ..., 23" msgstr "" -#: library/datetime.rst:2395 +#: library/datetime.rst:2419 msgid "``%I``" msgstr "" -#: library/datetime.rst:2395 +#: library/datetime.rst:2419 msgid "Hour (12-hour clock) as a zero-padded decimal number." msgstr "" -#: library/datetime.rst:2398 +#: library/datetime.rst:2422 msgid "``%p``" msgstr "" -#: library/datetime.rst:2398 +#: library/datetime.rst:2422 msgid "Locale's equivalent of either AM or PM." msgstr "" @@ -2742,127 +3523,127 @@ msgstr "" msgid "am, pm (de_DE)" msgstr "" -#: library/datetime.rst:2398 +#: library/datetime.rst:2422 msgid "\\(1), \\(3)" msgstr "" -#: library/datetime.rst:2401 +#: library/datetime.rst:2425 msgid "``%M``" msgstr "" -#: library/datetime.rst:2401 +#: library/datetime.rst:2425 msgid "Minute as a zero-padded decimal number." msgstr "" -#: library/datetime.rst:2404 +#: library/datetime.rst:2428 msgid "00, 01, ..., 59" msgstr "" -#: library/datetime.rst:2404 +#: library/datetime.rst:2428 msgid "``%S``" msgstr "" -#: library/datetime.rst:2404 +#: library/datetime.rst:2428 msgid "Second as a zero-padded decimal number." msgstr "" -#: library/datetime.rst:2404 +#: library/datetime.rst:2428 msgid "\\(4), \\(9)" msgstr "" -#: library/datetime.rst:2407 +#: library/datetime.rst:2431 msgid "``%f``" msgstr "" -#: library/datetime.rst:2407 +#: library/datetime.rst:2431 msgid "Microsecond as a decimal number, zero-padded to 6 digits." msgstr "" -#: library/datetime.rst:2407 +#: library/datetime.rst:2431 msgid "000000, 000001, ..., 999999" msgstr "" -#: library/datetime.rst:2407 +#: library/datetime.rst:2431 msgid "\\(5)" msgstr "" -#: library/datetime.rst:2580 +#: library/datetime.rst:2594 msgid "``%z``" msgstr "" -#: library/datetime.rst:2411 +#: library/datetime.rst:2435 msgid "" "UTC offset in the form ``±HHMM[SS[.ffffff]]`` (empty string if the object is " "naive)." msgstr "" -#: library/datetime.rst:2411 +#: library/datetime.rst:2435 msgid "(empty), +0000, -0400, +1030, +063415, -030712.345216" msgstr "" -#: library/datetime.rst:2416 library/datetime.rst:2473 +#: library/datetime.rst:2440 library/datetime.rst:2497 msgid "\\(6)" msgstr "" -#: library/datetime.rst:2608 +#: library/datetime.rst:2620 msgid "``%Z``" msgstr "" -#: library/datetime.rst:2416 +#: library/datetime.rst:2440 msgid "Time zone name (empty string if the object is naive)." msgstr "" -#: library/datetime.rst:2416 +#: library/datetime.rst:2440 msgid "(empty), UTC, GMT" msgstr "" -#: library/datetime.rst:2419 +#: library/datetime.rst:2443 msgid "``%j``" msgstr "" -#: library/datetime.rst:2419 +#: library/datetime.rst:2443 msgid "Day of the year as a zero-padded decimal number." msgstr "" -#: library/datetime.rst:2419 +#: library/datetime.rst:2443 msgid "001, 002, ..., 366" msgstr "" -#: library/datetime.rst:2422 +#: library/datetime.rst:2446 msgid "``%U``" msgstr "" -#: library/datetime.rst:2422 +#: library/datetime.rst:2446 msgid "" "Week number of the year (Sunday as the first day of the week) as a zero-" "padded decimal number. All days in a new year preceding the first Sunday are " "considered to be in week 0." msgstr "" -#: library/datetime.rst:2430 +#: library/datetime.rst:2454 msgid "00, 01, ..., 53" msgstr "" -#: library/datetime.rst:2430 +#: library/datetime.rst:2454 msgid "\\(7), \\(9)" msgstr "" -#: library/datetime.rst:2430 +#: library/datetime.rst:2454 msgid "``%W``" msgstr "" -#: library/datetime.rst:2430 +#: library/datetime.rst:2454 msgid "" "Week number of the year (Monday as the first day of the week) as a zero-" "padded decimal number. All days in a new year preceding the first Monday are " "considered to be in week 0." msgstr "" -#: library/datetime.rst:2438 +#: library/datetime.rst:2462 msgid "``%c``" msgstr "" -#: library/datetime.rst:2438 +#: library/datetime.rst:2462 msgid "Locale's appropriate date and time representation." msgstr "" @@ -2874,11 +3655,11 @@ msgstr "" msgid "Di 16 Aug 21:30:00 1988 (de_DE)" msgstr "" -#: library/datetime.rst:2443 +#: library/datetime.rst:2467 msgid "``%x``" msgstr "" -#: library/datetime.rst:2443 +#: library/datetime.rst:2467 msgid "Locale's appropriate date representation." msgstr "" @@ -2894,11 +3675,11 @@ msgstr "" msgid "16.08.1988 (de_DE)" msgstr "" -#: library/datetime.rst:2447 +#: library/datetime.rst:2471 msgid "``%X``" msgstr "" -#: library/datetime.rst:2447 +#: library/datetime.rst:2471 msgid "Locale's appropriate time representation." msgstr "" @@ -2910,92 +3691,92 @@ msgstr "" msgid "21:30:00 (de_DE)" msgstr "" -#: library/datetime.rst:2450 +#: library/datetime.rst:2474 msgid "``%%``" msgstr "" -#: library/datetime.rst:2450 +#: library/datetime.rst:2474 msgid "A literal ``'%'`` character." msgstr "" -#: library/datetime.rst:2450 +#: library/datetime.rst:2474 msgid "%" msgstr "" -#: library/datetime.rst:2453 +#: library/datetime.rst:2477 msgid "" "Several additional directives not required by the C89 standard are included " "for convenience. These parameters all correspond to ISO 8601 date values." msgstr "" -#: library/datetime.rst:2459 +#: library/datetime.rst:2483 msgid "``%G``" msgstr "" -#: library/datetime.rst:2459 +#: library/datetime.rst:2483 msgid "" "ISO 8601 year with century representing the year that contains the greater " "part of the ISO week (``%V``)." msgstr "" -#: library/datetime.rst:2459 +#: library/datetime.rst:2483 msgid "\\(8)" msgstr "" -#: library/datetime.rst:2464 +#: library/datetime.rst:2488 msgid "``%u``" msgstr "" -#: library/datetime.rst:2464 +#: library/datetime.rst:2488 msgid "ISO 8601 weekday as a decimal number where 1 is Monday." msgstr "" -#: library/datetime.rst:2464 +#: library/datetime.rst:2488 msgid "1, 2, ..., 7" msgstr "" -#: library/datetime.rst:2467 +#: library/datetime.rst:2491 msgid "``%V``" msgstr "" -#: library/datetime.rst:2467 +#: library/datetime.rst:2491 msgid "" "ISO 8601 week as a decimal number with Monday as the first day of the week. " "Week 01 is the week containing Jan 4." msgstr "" -#: library/datetime.rst:2467 +#: library/datetime.rst:2491 msgid "01, 02, ..., 53" msgstr "" -#: library/datetime.rst:2467 +#: library/datetime.rst:2491 msgid "\\(8), \\(9)" msgstr "" -#: library/datetime.rst:2594 +#: library/datetime.rst:2616 msgid "``%:z``" msgstr "" -#: library/datetime.rst:2473 +#: library/datetime.rst:2497 msgid "" "UTC offset in the form ``±HH:MM[:SS[.ffffff]]`` (empty string if the object " "is naive)." msgstr "" -#: library/datetime.rst:2473 +#: library/datetime.rst:2497 msgid "(empty), +00:00, -04:00, +10:30, +06:34:15, -03:07:12.345216" msgstr "" -#: library/datetime.rst:2479 +#: library/datetime.rst:2503 msgid "" -"These may not be available on all platforms when used with the :meth:`~." -"datetime.strftime` method. The ISO 8601 year and ISO 8601 week directives " -"are not interchangeable with the year and week number directives above. " -"Calling :meth:`~.datetime.strptime` with incomplete or ambiguous ISO 8601 " -"directives will raise a :exc:`ValueError`." +"These may not be available on all platforms when used with " +"the :meth:`~.datetime.strftime` method. The ISO 8601 year and ISO 8601 week " +"directives are not interchangeable with the year and week number directives " +"above. Calling :meth:`~.datetime.strptime` with incomplete or ambiguous ISO " +"8601 directives will raise a :exc:`ValueError`." msgstr "" -#: library/datetime.rst:2484 +#: library/datetime.rst:2508 msgid "" "The full set of format codes supported varies across platforms, because " "Python calls the platform C library's :c:func:`strftime` function, and " @@ -3005,68 +3786,67 @@ msgid "" "unsupported format specifiers." msgstr "" -#: library/datetime.rst:2490 +#: library/datetime.rst:2514 msgid "``%G``, ``%u`` and ``%V`` were added." msgstr "" -#: library/datetime.rst:2493 +#: library/datetime.rst:2517 msgid "``%:z`` was added." msgstr "" -#: library/datetime.rst:2497 +#: library/datetime.rst:2521 msgid "Technical Detail" msgstr "" -#: library/datetime.rst:2499 +#: library/datetime.rst:2523 msgid "" "Broadly speaking, ``d.strftime(fmt)`` acts like the :mod:`time` module's " -"``time.strftime(fmt, d.timetuple())`` although not all objects support a :" -"meth:`~date.timetuple` method." +"``time.strftime(fmt, d.timetuple())`` although not all objects support " +"a :meth:`~date.timetuple` method." msgstr "" -#: library/datetime.rst:2503 +#: library/datetime.rst:2527 msgid "" "For the :meth:`.datetime.strptime` class method, the default value is " "``1900-01-01T00:00:00.000``: any components not specified in the format " "string will be pulled from the default value. [#]_" msgstr "" -#: library/datetime.rst:2507 +#: library/datetime.rst:2531 msgid "Using ``datetime.strptime(date_string, format)`` is equivalent to::" msgstr "" -#: library/datetime.rst:2511 +#: library/datetime.rst:2535 msgid "" -"except when the format includes sub-second components or timezone offset " +"except when the format includes sub-second components or time zone offset " "information, which are supported in ``datetime.strptime`` but are discarded " "by ``time.strptime``." msgstr "" -#: library/datetime.rst:2515 +#: library/datetime.rst:2539 msgid "" "For :class:`.time` objects, the format codes for year, month, and day should " "not be used, as :class:`!time` objects have no such values. If they're used " -"anyway, ``1900`` is substituted for the year, and ``1`` for the month and " -"day." +"anyway, 1900 is substituted for the year, and 1 for the month and day." msgstr "" -#: library/datetime.rst:2519 +#: library/datetime.rst:2543 msgid "" "For :class:`date` objects, the format codes for hours, minutes, seconds, and " "microseconds should not be used, as :class:`date` objects have no such " -"values. If they're used anyway, ``0`` is substituted for them." +"values. If they're used anyway, 0 is substituted for them." msgstr "" -#: library/datetime.rst:2523 +#: library/datetime.rst:2547 msgid "" "For the same reason, handling of format strings containing Unicode code " "points that can't be represented in the charset of the current locale is " "also platform-dependent. On some platforms such code points are preserved " -"intact in the output, while on others ``strftime`` may raise :exc:" -"`UnicodeError` or return an empty string instead." +"intact in the output, while on others ``strftime`` may " +"raise :exc:`UnicodeError` or return an empty string instead." msgstr "" -#: library/datetime.rst:2532 +#: library/datetime.rst:2556 msgid "" "Because the format depends on the current locale, care should be taken when " "making assumptions about the output value. Field orderings will vary (for " @@ -3074,38 +3854,38 @@ msgid "" "contain non-ASCII characters." msgstr "" -#: library/datetime.rst:2538 +#: library/datetime.rst:2562 msgid "" "The :meth:`~.datetime.strptime` method can parse years in the full [1, 9999] " "range, but years < 1000 must be zero-filled to 4-digit width." msgstr "" -#: library/datetime.rst:2541 +#: library/datetime.rst:2565 msgid "" "In previous versions, :meth:`~.datetime.strftime` method was restricted to " "years >= 1900." msgstr "" -#: library/datetime.rst:2545 +#: library/datetime.rst:2569 msgid "" "In version 3.2, :meth:`~.datetime.strftime` method was restricted to years " ">= 1000." msgstr "" -#: library/datetime.rst:2550 +#: library/datetime.rst:2574 msgid "" "When used with the :meth:`~.datetime.strptime` method, the ``%p`` directive " "only affects the output hour field if the ``%I`` directive is used to parse " "the hour." msgstr "" -#: library/datetime.rst:2554 +#: library/datetime.rst:2578 msgid "" "Unlike the :mod:`time` module, the :mod:`!datetime` module does not support " "leap seconds." msgstr "" -#: library/datetime.rst:2558 +#: library/datetime.rst:2582 msgid "" "When used with the :meth:`~.datetime.strptime` method, the ``%f`` directive " "accepts from one to six digits and zero pads on the right. ``%f`` is an " @@ -3113,17 +3893,17 @@ msgid "" "separately in datetime objects, and therefore always available)." msgstr "" -#: library/datetime.rst:2565 +#: library/datetime.rst:2589 msgid "" "For a naive object, the ``%z``, ``%:z`` and ``%Z`` format codes are replaced " "by empty strings." msgstr "" -#: library/datetime.rst:2568 +#: library/datetime.rst:2592 msgid "For an aware object:" msgstr "" -#: library/datetime.rst:2571 +#: library/datetime.rst:2595 msgid "" ":meth:`~.datetime.utcoffset` is transformed into a string of the form " "``±HHMM[SS[.ffffff]]``, where ``HH`` is a 2-digit string giving the number " @@ -3132,12 +3912,12 @@ msgid "" "seconds and ``ffffff`` is a 6-digit string giving the number of UTC offset " "microseconds. The ``ffffff`` part is omitted when the offset is a whole " "number of seconds and both the ``ffffff`` and the ``SS`` part is omitted " -"when the offset is a whole number of minutes. For example, if :meth:`~." -"datetime.utcoffset` returns ``timedelta(hours=-3, minutes=-30)``, ``%z`` is " -"replaced with the string ``'-0330'``." +"when the offset is a whole number of minutes. For example, " +"if :meth:`~.datetime.utcoffset` returns ``timedelta(hours=-3, " +"minutes=-30)``, ``%z`` is replaced with the string ``'-0330'``." msgstr "" -#: library/datetime.rst:2585 +#: library/datetime.rst:2609 msgid "" "When the ``%z`` directive is provided to the :meth:`~.datetime.strptime` " "method, the UTC offsets can have a colon as a separator between hours, " @@ -3146,61 +3926,61 @@ msgid "" "``'+00:00'``." msgstr "" -#: library/datetime.rst:2593 +#: library/datetime.rst:2617 msgid "" "Behaves exactly as ``%z``, but has a colon separator added between hours, " "minutes and seconds." msgstr "" -#: library/datetime.rst:2597 +#: library/datetime.rst:2621 msgid "" -"In :meth:`~.datetime.strftime`, ``%Z`` is replaced by an empty string if :" -"meth:`~.datetime.tzname` returns ``None``; otherwise ``%Z`` is replaced by " -"the returned value, which must be a string." +"In :meth:`~.datetime.strftime`, ``%Z`` is replaced by an empty string " +"if :meth:`~.datetime.tzname` returns ``None``; otherwise ``%Z`` is replaced " +"by the returned value, which must be a string." msgstr "" -#: library/datetime.rst:2601 +#: library/datetime.rst:2625 msgid ":meth:`~.datetime.strptime` only accepts certain values for ``%Z``:" msgstr "" -#: library/datetime.rst:2603 +#: library/datetime.rst:2627 msgid "any value in ``time.tzname`` for your machine's locale" msgstr "" -#: library/datetime.rst:2604 +#: library/datetime.rst:2628 msgid "the hard-coded values ``UTC`` and ``GMT``" msgstr "" -#: library/datetime.rst:2606 +#: library/datetime.rst:2630 msgid "" "So someone living in Japan may have ``JST``, ``UTC``, and ``GMT`` as valid " "values, but probably not ``EST``. It will raise ``ValueError`` for invalid " "values." msgstr "" -#: library/datetime.rst:2610 +#: library/datetime.rst:2634 msgid "" "When the ``%z`` directive is provided to the :meth:`~.datetime.strptime` " "method, an aware :class:`.datetime` object will be produced. The ``tzinfo`` " "of the result will be set to a :class:`timezone` instance." msgstr "" -#: library/datetime.rst:2616 +#: library/datetime.rst:2640 msgid "" "When used with the :meth:`~.datetime.strptime` method, ``%U`` and ``%W`` are " "only used in calculations when the day of the week and the calendar year " "(``%Y``) are specified." msgstr "" -#: library/datetime.rst:2621 +#: library/datetime.rst:2645 msgid "" "Similar to ``%U`` and ``%W``, ``%V`` is only used in calculations when the " -"day of the week and the ISO year (``%G``) are specified in a :meth:`~." -"datetime.strptime` format string. Also note that ``%G`` and ``%Y`` are not " -"interchangeable." +"day of the week and the ISO year (``%G``) are specified in " +"a :meth:`~.datetime.strptime` format string. Also note that ``%G`` and " +"``%Y`` are not interchangeable." msgstr "" -#: library/datetime.rst:2627 +#: library/datetime.rst:2651 msgid "" "When used with the :meth:`~.datetime.strptime` method, the leading zero is " "optional for formats ``%d``, ``%m``, ``%H``, ``%I``, ``%M``, ``%S``, " @@ -3208,15 +3988,15 @@ msgid "" "zero." msgstr "" -#: library/datetime.rst:2632 +#: library/datetime.rst:2656 msgid "Footnotes" msgstr "" -#: library/datetime.rst:2633 +#: library/datetime.rst:2657 msgid "If, that is, we ignore the effects of Relativity" msgstr "" -#: library/datetime.rst:2635 +#: library/datetime.rst:2659 msgid "" "This matches the definition of the \"proleptic Gregorian\" calendar in " "Dershowitz and Reingold's book *Calendrical Calculations*, where it's the " @@ -3225,23 +4005,23 @@ msgid "" "systems." msgstr "" -#: library/datetime.rst:2641 +#: library/datetime.rst:2665 msgid "" "See R. H. van Gent's `guide to the mathematics of the ISO 8601 calendar " "`_ for a good explanation." msgstr "" -#: library/datetime.rst:2645 +#: library/datetime.rst:2669 msgid "" -"Passing ``datetime.strptime('Feb 29', '%b %d')`` will fail since ``1900`` is " -"not a leap year." +"Passing ``datetime.strptime('Feb 29', '%b %d')`` will fail since 1900 is not " +"a leap year." msgstr "" -#: library/datetime.rst:2305 +#: library/datetime.rst:2329 msgid "% (percent)" msgstr "" -#: library/datetime.rst:2305 +#: library/datetime.rst:2329 msgid "datetime format" msgstr "" diff --git a/library/dbm.po b/library/dbm.po index 7583e714..6afcd8b1 100644 --- a/library/dbm.po +++ b/library/dbm.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/dbm.rst:2 -msgid ":mod:`dbm` --- Interfaces to Unix \"databases\"" +msgid ":mod:`!dbm` --- Interfaces to Unix \"databases\"" msgstr "" #: library/dbm.rst:7 @@ -26,11 +27,11 @@ msgstr "" #: library/dbm.rst:11 msgid "" -":mod:`dbm` is a generic interface to variants of the DBM database --- :mod:" -"`dbm.gnu` or :mod:`dbm.ndbm`. If none of these modules is installed, the " -"slow-but-simple implementation in module :mod:`dbm.dumb` will be used. " -"There is a `third party interface `_ to the Oracle Berkeley DB." +":mod:`dbm` is a generic interface to variants of the DBM database " +"--- :mod:`dbm.gnu` or :mod:`dbm.ndbm`. If none of these modules is " +"installed, the slow-but-simple implementation in module :mod:`dbm.dumb` will " +"be used. There is a `third party interface `_ to the Oracle Berkeley DB." msgstr "" #: library/dbm.rst:20 @@ -80,10 +81,10 @@ msgstr "" #: library/dbm.rst:63 msgid "" -"The database file to open. If the database file already exists, the :func:" -"`whichdb` function is used to determine its type and the appropriate module " -"is used; if it does not exist, the first submodule listed above that can be " -"imported is used." +"The database file to open. If the database file already exists, " +"the :func:`whichdb` function is used to determine its type and the " +"appropriate module is used; if it does not exist, the first submodule listed " +"above that can be imported is used." msgstr "" #: library/dbm.rst:174 @@ -131,8 +132,8 @@ msgstr "" msgid "" "The object returned by :func:`~dbm.open` supports the same basic " "functionality as a :class:`dict`; keys and their corresponding values can be " -"stored, retrieved, and deleted, and the :keyword:`in` operator and the :meth:" -"`!keys` method are available, as well as :meth:`!get` and :meth:`!" +"stored, retrieved, and deleted, and the :keyword:`in` operator and " +"the :meth:`!keys` method are available, as well as :meth:`!get` and :meth:`!" "setdefault` methods." msgstr "" @@ -151,8 +152,8 @@ msgstr "" #: library/dbm.rst:95 msgid "" -":meth:`!get` and :meth:`!setdefault` methods are now available for all :mod:" -"`dbm` backends." +":meth:`!get` and :meth:`!setdefault` methods are now available for " +"all :mod:`dbm` backends." msgstr "" #: library/dbm.rst:99 @@ -173,6 +174,33 @@ msgid "" "then prints out the contents of the database::" msgstr "" +#: library/dbm.rst:110 +msgid "" +"import dbm\n" +"\n" +"# Open database, creating it if necessary.\n" +"with dbm.open('cache', 'c') as db:\n" +"\n" +" # Record some values\n" +" db[b'hello'] = b'there'\n" +" db['www.python.org'] = 'Python Website'\n" +" db['www.cnn.com'] = 'Cable News Network'\n" +"\n" +" # Note that the keys are considered bytes now.\n" +" assert db[b'www.python.org'] == b'Python Website'\n" +" # Notice how the value is now in bytes.\n" +" assert db['www.cnn.com'] == b'Cable News Network'\n" +"\n" +" # Often-used methods of the dict interface work too.\n" +" print(db.get('python.org', b'not present'))\n" +"\n" +" # Storing a non-string key or value will raise an exception (most\n" +" # likely a TypeError).\n" +" db['www.yahoo.com'] = 4\n" +"\n" +"# db is automatically closed when leaving the with statement." +msgstr "" + #: library/dbm.rst:137 msgid "Module :mod:`shelve`" msgstr "" @@ -208,9 +236,9 @@ msgstr "" #: library/dbm.rst:166 msgid "" -"Raised on :mod:`dbm.gnu`-specific errors, such as I/O errors. :exc:" -"`KeyError` is raised for general mapping errors like specifying an incorrect " -"key." +"Raised on :mod:`dbm.gnu`-specific errors, such as I/O " +"errors. :exc:`KeyError` is raised for general mapping errors like specifying " +"an incorrect key." msgstr "" #: library/dbm.rst:172 @@ -273,9 +301,9 @@ msgstr "" #: library/dbm.rst:209 msgid "" -":class:`!gdbm` objects behave similar to :term:`mappings `, but :" -"meth:`!items` and :meth:`!values` methods are not supported. The following " -"methods are also provided:" +":class:`!gdbm` objects behave similar to :term:`mappings `, " +"but :meth:`!items` and :meth:`!values` methods are not supported. The " +"following methods are also provided:" msgstr "" #: library/dbm.rst:215 @@ -293,13 +321,21 @@ msgid "" "memory that contains them all::" msgstr "" +#: library/dbm.rst:226 +msgid "" +"k = db.firstkey()\n" +"while k is not None:\n" +" print(k)\n" +" k = db.nextkey(k)" +msgstr "" + #: library/dbm.rst:233 msgid "" "If you have carried out a lot of deletions and would like to shrink the " -"space used by the GDBM file, this routine will reorganize the database. :" -"class:`!gdbm` objects will not shorten the length of a database file except " -"by using this reorganization; otherwise, deleted file space will be kept and " -"reused as new (key, value) pairs are added." +"space used by the GDBM file, this routine will reorganize the " +"database. :class:`!gdbm` objects will not shorten the length of a database " +"file except by using this reorganization; otherwise, deleted file space will " +"be kept and reused as new (key, value) pairs are added." msgstr "" #: library/dbm.rst:241 @@ -337,9 +373,9 @@ msgstr "" #: library/dbm.rst:279 msgid "" -"Raised on :mod:`dbm.ndbm`-specific errors, such as I/O errors. :exc:" -"`KeyError` is raised for general mapping errors like specifying an incorrect " -"key." +"Raised on :mod:`dbm.ndbm`-specific errors, such as I/O " +"errors. :exc:`KeyError` is raised for general mapping errors like specifying " +"an incorrect key." msgstr "" #: library/dbm.rst:285 @@ -358,9 +394,9 @@ msgstr "" #: library/dbm.rst:306 msgid "" -":class:`!ndbm` objects behave similar to :term:`mappings `, but :" -"meth:`!items` and :meth:`!values` methods are not supported. The following " -"methods are also provided:" +":class:`!ndbm` objects behave similar to :term:`mappings `, " +"but :meth:`!items` and :meth:`!values` methods are not supported. The " +"following methods are also provided:" msgstr "" #: library/dbm.rst:310 @@ -381,10 +417,10 @@ msgstr "" #: library/dbm.rst:330 msgid "" -"The :mod:`dbm.dumb` module is intended as a last resort fallback for the :" -"mod:`dbm` module when a more robust module is not available. The :mod:`dbm." -"dumb` module is not written for speed and is not nearly as heavily used as " -"the other database modules." +"The :mod:`dbm.dumb` module is intended as a last resort fallback for " +"the :mod:`dbm` module when a more robust module is not available. " +"The :mod:`dbm.dumb` module is not written for speed and is not nearly as " +"heavily used as the other database modules." msgstr "" #: library/dbm.rst:337 @@ -400,9 +436,9 @@ msgstr "" #: library/dbm.rst:346 msgid "" -"Raised on :mod:`dbm.dumb`-specific errors, such as I/O errors. :exc:" -"`KeyError` is raised for general mapping errors like specifying an incorrect " -"key." +"Raised on :mod:`dbm.dumb`-specific errors, such as I/O " +"errors. :exc:`KeyError` is raised for general mapping errors like " +"specifying an incorrect key." msgstr "" #: library/dbm.rst:352 @@ -415,8 +451,8 @@ msgstr "" #: library/dbm.rst:357 msgid "" "The basename of the database file (without extensions). A new database " -"creates the following files: - :file:`{filename}.dat` - :file:`{filename}." -"dir`" +"creates the following files: - :file:`{filename}.dat` " +"- :file:`{filename}.dir`" msgstr "" #: library/dbm.rst:358 @@ -467,14 +503,15 @@ msgstr "" #: library/dbm.rst:389 msgid "" -"In addition to the methods provided by the :class:`collections.abc." -"MutableMapping` class, the following methods are provided:" +"In addition to the methods provided by " +"the :class:`collections.abc.MutableMapping` class, the following methods are " +"provided:" msgstr "" #: library/dbm.rst:395 msgid "" "Synchronize the on-disk directory and data files. This method is called by " -"the :meth:`Shelve.sync` method." +"the :meth:`shelve.Shelf.sync` method." msgstr "" #: library/dbm.rst:400 diff --git a/library/debug.po b/library/debug.po index 53800b2d..4571b907 100644 --- a/library/debug.po +++ b/library/debug.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/decimal.po b/library/decimal.po index dc70e6b1..4f9ae3aa 100644 --- a/library/decimal.po +++ b/library/decimal.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/decimal.rst:2 -msgid ":mod:`decimal` --- Decimal fixed point and floating point arithmetic" +msgid ":mod:`!decimal` --- Decimal fixed-point and floating-point arithmetic" msgstr "" #: library/decimal.rst:15 @@ -27,8 +28,8 @@ msgstr "" #: library/decimal.rst:33 msgid "" "The :mod:`decimal` module provides support for fast correctly rounded " -"decimal floating point arithmetic. It offers several advantages over the :" -"class:`float` datatype:" +"decimal floating-point arithmetic. It offers several advantages over " +"the :class:`float` datatype:" msgstr "" #: library/decimal.rst:37 @@ -113,9 +114,9 @@ msgid "" "The context for arithmetic is an environment specifying precision, rounding " "rules, limits on exponents, flags indicating the results of operations, and " "trap enablers which determine whether signals are treated as exceptions. " -"Rounding options include :const:`ROUND_CEILING`, :const:`ROUND_DOWN`, :const:" -"`ROUND_FLOOR`, :const:`ROUND_HALF_DOWN`, :const:`ROUND_HALF_EVEN`, :const:" -"`ROUND_HALF_UP`, :const:`ROUND_UP`, and :const:`ROUND_05UP`." +"Rounding options " +"include :const:`ROUND_CEILING`, :const:`ROUND_DOWN`, :const:`ROUND_FLOOR`, :const:`ROUND_HALF_DOWN`, :const:`ROUND_HALF_EVEN`, :const:`ROUND_HALF_UP`, :const:`ROUND_UP`, " +"and :const:`ROUND_05UP`." msgstr "" #: library/decimal.rst:101 @@ -123,10 +124,9 @@ msgid "" "Signals are groups of exceptional conditions arising during the course of " "computation. Depending on the needs of the application, signals may be " "ignored, considered as informational, or treated as exceptions. The signals " -"in the decimal module are: :const:`Clamped`, :const:`InvalidOperation`, :" -"const:`DivisionByZero`, :const:`Inexact`, :const:`Rounded`, :const:" -"`Subnormal`, :const:`Overflow`, :const:`Underflow` and :const:" -"`FloatOperation`." +"in the decimal module " +"are: :const:`Clamped`, :const:`InvalidOperation`, :const:`DivisionByZero`, :const:`Inexact`, :const:`Rounded`, :const:`Subnormal`, :const:`Overflow`, :const:`Underflow` " +"and :const:`FloatOperation`." msgstr "" #: library/decimal.rst:108 @@ -154,6 +154,17 @@ msgid "" "values for precision, rounding, or enabled traps::" msgstr "" +#: library/decimal.rst:131 +msgid "" +">>> from decimal import *\n" +">>> getcontext()\n" +"Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,\n" +" capitals=1, clamp=0, flags=[], traps=[Overflow, DivisionByZero,\n" +" InvalidOperation])\n" +"\n" +">>> getcontext().prec = 7 # Set a new precision" +msgstr "" + #: library/decimal.rst:139 msgid "" "Decimal instances can be constructed from integers, strings, floats, or " @@ -163,6 +174,27 @@ msgid "" "negative ``Infinity``, and ``-0``::" msgstr "" +#: library/decimal.rst:145 +msgid "" +">>> getcontext().prec = 28\n" +">>> Decimal(10)\n" +"Decimal('10')\n" +">>> Decimal('3.14')\n" +"Decimal('3.14')\n" +">>> Decimal(3.14)\n" +"Decimal('3.140000000000000124344978758017532527446746826171875')\n" +">>> Decimal((0, (3, 1, 4), -2))\n" +"Decimal('3.14')\n" +">>> Decimal(str(2.0 ** 0.5))\n" +"Decimal('1.4142135623730951')\n" +">>> Decimal(2) ** Decimal('0.5')\n" +"Decimal('1.414213562373095048801688724')\n" +">>> Decimal('NaN')\n" +"Decimal('NaN')\n" +">>> Decimal('-Infinity')\n" +"Decimal('-Infinity')" +msgstr "" + #: library/decimal.rst:163 msgid "" "If the :exc:`FloatOperation` signal is trapped, accidental mixing of " @@ -170,6 +202,22 @@ msgid "" "exception::" msgstr "" +#: library/decimal.rst:167 +msgid "" +">>> c = getcontext()\n" +">>> c.traps[FloatOperation] = True\n" +">>> Decimal(3.14)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"decimal.FloatOperation: []\n" +">>> Decimal('3.5') < 3.7\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"decimal.FloatOperation: []\n" +">>> Decimal('3.5') == 3.5\n" +"True" +msgstr "" + #: library/decimal.rst:182 msgid "" "The significance of a new Decimal is determined solely by the number of " @@ -177,16 +225,67 @@ msgid "" "arithmetic operations." msgstr "" +#: library/decimal.rst:186 +msgid "" +">>> getcontext().prec = 6\n" +">>> Decimal('3.0')\n" +"Decimal('3.0')\n" +">>> Decimal('3.1415926535')\n" +"Decimal('3.1415926535')\n" +">>> Decimal('3.1415926535') + Decimal('2.7182818285')\n" +"Decimal('5.85987')\n" +">>> getcontext().rounding = ROUND_UP\n" +">>> Decimal('3.1415926535') + Decimal('2.7182818285')\n" +"Decimal('5.85988')" +msgstr "" + #: library/decimal.rst:199 msgid "" "If the internal limits of the C version are exceeded, constructing a decimal " "raises :class:`InvalidOperation`::" msgstr "" +#: library/decimal.rst:202 +msgid "" +">>> Decimal(\"1e9999999999999999999\")\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"decimal.InvalidOperation: []" +msgstr "" + #: library/decimal.rst:209 msgid "" "Decimals interact well with much of the rest of Python. Here is a small " -"decimal floating point flying circus:" +"decimal floating-point flying circus:" +msgstr "" + +#: library/decimal.rst:212 +msgid "" +">>> data = list(map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split()))\n" +">>> max(data)\n" +"Decimal('9.25')\n" +">>> min(data)\n" +"Decimal('0.03')\n" +">>> sorted(data)\n" +"[Decimal('0.03'), Decimal('1.00'), Decimal('1.34'), Decimal('1.87'),\n" +" Decimal('2.35'), Decimal('3.45'), Decimal('9.25')]\n" +">>> sum(data)\n" +"Decimal('19.29')\n" +">>> a,b,c = data[:3]\n" +">>> str(a)\n" +"'1.34'\n" +">>> float(a)\n" +"1.34\n" +">>> round(a, 1)\n" +"Decimal('1.3')\n" +">>> int(a)\n" +"1\n" +">>> a * 5\n" +"Decimal('6.70')\n" +">>> a * b\n" +"Decimal('2.5058')\n" +">>> c % a\n" +"Decimal('0.77')" msgstr "" #: library/decimal.rst:241 @@ -210,16 +309,40 @@ msgstr "" #: library/decimal.rst:266 msgid "" "For more advanced work, it may be useful to create alternate contexts using " -"the Context() constructor. To make an alternate active, use the :func:" -"`setcontext` function." +"the Context() constructor. To make an alternate active, use " +"the :func:`setcontext` function." msgstr "" #: library/decimal.rst:270 msgid "" "In accordance with the standard, the :mod:`decimal` module provides two " -"ready to use standard contexts, :const:`BasicContext` and :const:" -"`ExtendedContext`. The former is especially useful for debugging because " -"many of the traps are enabled:" +"ready to use standard contexts, :const:`BasicContext` " +"and :const:`ExtendedContext`. The former is especially useful for debugging " +"because many of the traps are enabled:" +msgstr "" + +#: library/decimal.rst:275 +msgid "" +">>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN)\n" +">>> setcontext(myothercontext)\n" +">>> Decimal(1) / Decimal(7)\n" +"Decimal('0.142857142857142857142857142857142857142857142857142857142857')\n" +"\n" +">>> ExtendedContext\n" +"Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,\n" +" capitals=1, clamp=0, flags=[], traps=[])\n" +">>> setcontext(ExtendedContext)\n" +">>> Decimal(1) / Decimal(7)\n" +"Decimal('0.142857143')\n" +">>> Decimal(42) / Decimal(0)\n" +"Decimal('Infinity')\n" +"\n" +">>> setcontext(BasicContext)\n" +">>> Decimal(42) / Decimal(0)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in -toplevel-\n" +" Decimal(42) / Decimal(0)\n" +"DivisionByZero: x / 0" msgstr "" #: library/decimal.rst:299 @@ -230,6 +353,17 @@ msgid "" "computations by using the :meth:`~Context.clear_flags` method. ::" msgstr "" +#: library/decimal.rst:304 +msgid "" +">>> setcontext(ExtendedContext)\n" +">>> getcontext().clear_flags()\n" +">>> Decimal(355) / Decimal(113)\n" +"Decimal('3.14159292')\n" +">>> getcontext()\n" +"Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,\n" +" capitals=1, clamp=0, flags=[Inexact, Rounded], traps=[])" +msgstr "" + #: library/decimal.rst:312 msgid "" "The *flags* entry shows that the rational approximation to pi was rounded " @@ -243,6 +377,19 @@ msgid "" "attribute of a context:" msgstr "" +#: library/decimal.rst:319 +msgid "" +">>> setcontext(ExtendedContext)\n" +">>> Decimal(1) / Decimal(0)\n" +"Decimal('Infinity')\n" +">>> getcontext().traps[DivisionByZero] = 1\n" +">>> Decimal(1) / Decimal(0)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in -toplevel-\n" +" Decimal(1) / Decimal(0)\n" +"DivisionByZero: x / 0" +msgstr "" + #: library/decimal.rst:331 msgid "" "Most programs adjust the current context only once, at the beginning of the " @@ -262,11 +409,26 @@ msgstr "" #: library/decimal.rst:350 msgid "" -"*value* can be an integer, string, tuple, :class:`float`, or another :class:" -"`Decimal` object. If no *value* is given, returns ``Decimal('0')``. If " -"*value* is a string, it should conform to the decimal numeric string syntax " -"after leading and trailing whitespace characters, as well as underscores " -"throughout, are removed::" +"*value* can be an integer, string, tuple, :class:`float`, or " +"another :class:`Decimal` object. If no *value* is given, returns " +"``Decimal('0')``. If *value* is a string, it should conform to the decimal " +"numeric string syntax after leading and trailing whitespace characters, as " +"well as underscores throughout, are removed::" +msgstr "" + +#: library/decimal.rst:355 +msgid "" +"sign ::= '+' | '-'\n" +"digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | " +"'9'\n" +"indicator ::= 'e' | 'E'\n" +"digits ::= digit [digit]...\n" +"decimal-part ::= digits '.' [digits] | ['.'] digits\n" +"exponent-part ::= indicator [sign] digits\n" +"infinity ::= 'Infinity' | 'Inf'\n" +"nan ::= 'NaN' [digits] | 'sNaN' [digits]\n" +"numeric-value ::= decimal-part [exponent-part] | infinity\n" +"numeric-string ::= [sign] numeric-value | [sign] nan" msgstr "" #: library/decimal.rst:366 @@ -287,7 +449,7 @@ msgstr "" #: library/decimal.rst:376 msgid "" -"If *value* is a :class:`float`, the binary floating point value is " +"If *value* is a :class:`float`, the binary floating-point value is " "losslessly converted to its exact decimal equivalent. This conversion can " "often require 53 or more digits of precision. For example, " "``Decimal(float('1.1'))`` converts to " @@ -334,12 +496,12 @@ msgstr "" #: library/decimal.rst:406 msgid "" -"Decimal floating point objects share many properties with the other built-in " +"Decimal floating-point objects share many properties with the other built-in " "numeric types such as :class:`float` and :class:`int`. All of the usual " "math operations and special methods apply. Likewise, decimal objects can be " "copied, pickled, printed, used as dictionary keys, used as set elements, " -"compared, sorted, and coerced to another type (such as :class:`float` or :" -"class:`int`)." +"compared, sorted, and coerced to another type (such as :class:`float` " +"or :class:`int`)." msgstr "" #: library/decimal.rst:413 @@ -350,6 +512,14 @@ msgid "" "*dividend* rather than the sign of the divisor::" msgstr "" +#: library/decimal.rst:418 +msgid "" +">>> (-7) % 4\n" +"1\n" +">>> Decimal(-7) % Decimal(4)\n" +"Decimal('-3')" +msgstr "" + #: library/decimal.rst:423 msgid "" "The integer division operator ``//`` behaves analogously, returning the " @@ -357,6 +527,14 @@ msgid "" "floor, so as to preserve the usual identity ``x == (x // y) * y + x % y``::" msgstr "" +#: library/decimal.rst:427 +msgid "" +">>> -7 // 4\n" +"-2\n" +">>> Decimal(-7) // Decimal(4)\n" +"Decimal('-1')" +msgstr "" + #: library/decimal.rst:432 msgid "" "The ``%`` and ``//`` operators implement the ``remainder`` and ``divide-" @@ -365,13 +543,13 @@ msgstr "" #: library/decimal.rst:436 msgid "" -"Decimal objects cannot generally be combined with floats or instances of :" -"class:`fractions.Fraction` in arithmetic operations: an attempt to add a :" -"class:`Decimal` to a :class:`float`, for example, will raise a :exc:" -"`TypeError`. However, it is possible to use Python's comparison operators " -"to compare a :class:`Decimal` instance ``x`` with another number ``y``. " -"This avoids confusing results when doing equality comparisons between " -"numbers of different types." +"Decimal objects cannot generally be combined with floats or instances " +"of :class:`fractions.Fraction` in arithmetic operations: an attempt to add " +"a :class:`Decimal` to a :class:`float`, for example, will raise " +"a :exc:`TypeError`. However, it is possible to use Python's comparison " +"operators to compare a :class:`Decimal` instance ``x`` with another number " +"``y``. This avoids confusing results when doing equality comparisons " +"between numbers of different types." msgstr "" #: library/decimal.rst:444 @@ -382,7 +560,7 @@ msgstr "" #: library/decimal.rst:448 msgid "" -"In addition to the standard numeric properties, decimal floating point " +"In addition to the standard numeric properties, decimal floating-point " "objects also have a number of specialized methods:" msgstr "" @@ -396,9 +574,15 @@ msgstr "" #: library/decimal.rst:461 msgid "" -"Return a pair ``(n, d)`` of integers that represent the given :class:" -"`Decimal` instance as a fraction, in lowest terms and with a positive " -"denominator::" +"Return a pair ``(n, d)`` of integers that represent the " +"given :class:`Decimal` instance as a fraction, in lowest terms and with a " +"positive denominator::" +msgstr "" + +#: library/decimal.rst:465 +msgid "" +">>> Decimal('-3.14').as_integer_ratio()\n" +"(-157, 50)" msgstr "" #: library/decimal.rst:468 @@ -426,6 +610,14 @@ msgid "" "Decimal instance, and if either operand is a NaN then the result is a NaN::" msgstr "" +#: library/decimal.rst:491 +msgid "" +"a or b is a NaN ==> Decimal('NaN')\n" +"a < b ==> Decimal('-1')\n" +"a == b ==> Decimal('0')\n" +"a > b ==> Decimal('1')" +msgstr "" + #: library/decimal.rst:498 msgid "" "This operation is identical to the :meth:`compare` method, except that all " @@ -463,8 +655,8 @@ msgstr "" msgid "" "Compare two operands using their abstract representation rather than their " "value as in :meth:`compare_total`, but ignoring the sign of each operand. " -"``x.compare_total_mag(y)`` is equivalent to ``x.copy_abs().compare_total(y." -"copy_abs())``." +"``x.compare_total_mag(y)`` is equivalent to " +"``x.copy_abs().compare_total(y.copy_abs())``." msgstr "" #: library/decimal.rst:537 @@ -500,8 +692,8 @@ msgstr "" #: library/decimal.rst:576 msgid "" -"Alternative constructor that only accepts instances of :class:`float` or :" -"class:`int`." +"Alternative constructor that only accepts instances of :class:`float` " +"or :class:`int`." msgstr "" #: library/decimal.rst:579 @@ -519,6 +711,18 @@ msgid "" "directly from a :class:`float`." msgstr "" +#: library/decimal.rst:588 +msgid "" +">>> Decimal.from_float(0.1)\n" +"Decimal('0.1000000000000000055511151231257827021181583404541015625')\n" +">>> Decimal.from_float(float('nan'))\n" +"Decimal('NaN')\n" +">>> Decimal.from_float(float('inf'))\n" +"Decimal('Infinity')\n" +">>> Decimal.from_float(float('-inf'))\n" +"Decimal('-Infinity')" +msgstr "" + #: library/decimal.rst:603 msgid "" "Fused multiply-add. Return self*other+third with no rounding of the " @@ -546,14 +750,14 @@ msgstr "" #: library/decimal.rst:627 msgid "" -"Return :const:`True` if the argument is a (quiet or signaling) NaN and :" -"const:`False` otherwise." +"Return :const:`True` if the argument is a (quiet or signaling) NaN " +"and :const:`False` otherwise." msgstr "" #: library/decimal.rst:632 msgid "" -"Return :const:`True` if the argument is a *normal* finite number. Return :" -"const:`False` if the argument is zero, subnormal, infinite or a NaN." +"Return :const:`True` if the argument is a *normal* finite number. " +"Return :const:`False` if the argument is zero, subnormal, infinite or a NaN." msgstr "" #: library/decimal.rst:637 @@ -582,8 +786,8 @@ msgstr "" #: library/decimal.rst:657 msgid "" -"Return :const:`True` if the argument is a (positive or negative) zero and :" -"const:`False` otherwise." +"Return :const:`True` if the argument is a (positive or negative) zero " +"and :const:`False` otherwise." msgstr "" #: library/decimal.rst:662 @@ -600,8 +804,8 @@ msgstr "" #: library/decimal.rst:672 msgid "" -"For a nonzero number, return the adjusted exponent of its operand as a :" -"class:`Decimal` instance. If the operand is a zero then ``Decimal('-" +"For a nonzero number, return the adjusted exponent of its operand as " +"a :class:`Decimal` instance. If the operand is a zero then ``Decimal('-" "Infinity')`` is returned and the :const:`DivisionByZero` flag is raised. If " "the operand is an infinity then ``Decimal('Infinity')`` is returned." msgstr "" @@ -794,8 +998,8 @@ msgstr "" #: library/decimal.rst:803 msgid "" -"An error is returned whenever the resulting exponent is greater than :attr:" -"`~Context.Emax` or less than :meth:`~Context.Etiny`." +"An error is returned whenever the resulting exponent is greater " +"than :attr:`~Context.Emax` or less than :meth:`~Context.Etiny`." msgstr "" #: library/decimal.rst:808 @@ -857,12 +1061,12 @@ msgstr "" msgid "Return the square root of the argument to full precision." msgstr "" -#: library/decimal.rst:1468 +#: library/decimal.rst:1510 msgid "" "Convert to a string, using engineering notation if an exponent is needed." msgstr "" -#: library/decimal.rst:1470 +#: library/decimal.rst:1512 msgid "" "Engineering notation has an exponent which is a multiple of 3. This can " "leave up to 3 digits to the left of the decimal place and may require the " @@ -890,56 +1094,117 @@ msgstr "" #: library/decimal.rst:896 msgid "" -"Round to the nearest integer without signaling :const:`Inexact` or :const:" -"`Rounded`. If given, applies *rounding*; otherwise, uses the rounding " -"method in either the supplied *context* or the current context." +"Round to the nearest integer without signaling :const:`Inexact` " +"or :const:`Rounded`. If given, applies *rounding*; otherwise, uses the " +"rounding method in either the supplied *context* or the current context." +msgstr "" + +#: library/decimal.rst:900 +msgid "Decimal numbers can be rounded using the :func:`.round` function:" +msgstr "" + +#: library/decimal.rst:905 +msgid "" +"If *ndigits* is not given or ``None``, returns the nearest :class:`int` to " +"*number*, rounding ties to even, and ignoring the rounding mode of " +"the :class:`Decimal` context. Raises :exc:`OverflowError` if *number* is an " +"infinity or :exc:`ValueError` if it is a (quiet or signaling) NaN." +msgstr "" + +#: library/decimal.rst:911 +msgid "" +"If *ndigits* is an :class:`int`, the context's rounding mode is respected " +"and a :class:`Decimal` representing *number* rounded to the nearest multiple " +"of ``Decimal('1E-ndigits')`` is returned; in this case, ``round(number, " +"ndigits)`` is equivalent to ``self.quantize(Decimal('1E-ndigits'))``. " +"Returns ``Decimal('NaN')`` if *number* is a quiet NaN. " +"Raises :class:`InvalidOperation` if *number* is an infinity, a signaling " +"NaN, or if the length of the coefficient after the quantize operation would " +"be greater than the current context's precision. In other words, for the " +"non-corner cases:" +msgstr "" + +#: library/decimal.rst:921 +msgid "" +"if *ndigits* is positive, return *number* rounded to *ndigits* decimal " +"places;" +msgstr "" + +#: library/decimal.rst:923 +msgid "if *ndigits* is zero, return *number* rounded to the nearest integer;" +msgstr "" + +#: library/decimal.rst:924 +msgid "" +"if *ndigits* is negative, return *number* rounded to the nearest multiple of " +"``10**abs(ndigits)``." +msgstr "" + +#: library/decimal.rst:927 +msgid "For example::" +msgstr "" + +#: library/decimal.rst:929 +msgid "" +">>> from decimal import Decimal, getcontext, ROUND_DOWN\n" +">>> getcontext().rounding = ROUND_DOWN\n" +">>> round(Decimal('3.75')) # context rounding ignored\n" +"4\n" +">>> round(Decimal('3.5')) # round-ties-to-even\n" +"4\n" +">>> round(Decimal('3.75'), 0) # uses the context rounding\n" +"Decimal('3')\n" +">>> round(Decimal('3.75'), 1)\n" +"Decimal('3.7')\n" +">>> round(Decimal('3.75'), -1)\n" +"Decimal('0E+1')" msgstr "" -#: library/decimal.rst:904 +#: library/decimal.rst:946 msgid "Logical operands" msgstr "" -#: library/decimal.rst:906 +#: library/decimal.rst:948 msgid "" -"The :meth:`~Decimal.logical_and`, :meth:`~Decimal.logical_invert`, :meth:" -"`~Decimal.logical_or`, and :meth:`~Decimal.logical_xor` methods expect their " -"arguments to be *logical operands*. A *logical operand* is a :class:" -"`Decimal` instance whose exponent and sign are both zero, and whose digits " -"are all either ``0`` or ``1``." +"The :meth:`~Decimal.logical_and`, :meth:`~Decimal.logical_invert`, :meth:`~Decimal.logical_or`, " +"and :meth:`~Decimal.logical_xor` methods expect their arguments to be " +"*logical operands*. A *logical operand* is a :class:`Decimal` instance " +"whose exponent and sign are both zero, and whose digits are all either ``0`` " +"or ``1``." msgstr "" -#: library/decimal.rst:918 +#: library/decimal.rst:960 msgid "Context objects" msgstr "" -#: library/decimal.rst:920 +#: library/decimal.rst:962 msgid "" "Contexts are environments for arithmetic operations. They govern precision, " "set rules for rounding, determine which signals are treated as exceptions, " "and limit the range for exponents." msgstr "" -#: library/decimal.rst:924 +#: library/decimal.rst:966 msgid "" "Each thread has its own current context which is accessed or changed using " "the :func:`getcontext` and :func:`setcontext` functions:" msgstr "" -#: library/decimal.rst:930 +#: library/decimal.rst:972 msgid "Return the current context for the active thread." msgstr "" -#: library/decimal.rst:935 +#: library/decimal.rst:977 msgid "Set the current context for the active thread to *c*." msgstr "" -#: library/decimal.rst:937 +#: library/decimal.rst:979 msgid "" "You can also use the :keyword:`with` statement and the :func:`localcontext` " "function to temporarily change the active context." msgstr "" -#: library/decimal.rst:942 +#: library/decimal.rst:984 msgid "" "Return a context manager that will set the current context for the active " "thread to a copy of *ctx* on entry to the with-statement and restore the " @@ -948,59 +1213,78 @@ msgid "" "used to set the attributes of the new context." msgstr "" -#: library/decimal.rst:948 +#: library/decimal.rst:990 msgid "" "For example, the following code sets the current decimal precision to 42 " "places, performs a calculation, and then automatically restores the previous " "context::" msgstr "" -#: library/decimal.rst:958 +#: library/decimal.rst:993 +msgid "" +"from decimal import localcontext\n" +"\n" +"with localcontext() as ctx:\n" +" ctx.prec = 42 # Perform a high precision calculation\n" +" s = calculate_something()\n" +"s = +s # Round the final result back to the default precision" +msgstr "" + +#: library/decimal.rst:1000 msgid "Using keyword arguments, the code would be the following::" msgstr "" -#: library/decimal.rst:966 +#: library/decimal.rst:1002 +msgid "" +"from decimal import localcontext\n" +"\n" +"with localcontext(prec=42) as ctx:\n" +" s = calculate_something()\n" +"s = +s" +msgstr "" + +#: library/decimal.rst:1008 msgid "" -"Raises :exc:`TypeError` if *kwargs* supplies an attribute that :class:" -"`Context` doesn't support. Raises either :exc:`TypeError` or :exc:" -"`ValueError` if *kwargs* supplies an invalid value for an attribute." +"Raises :exc:`TypeError` if *kwargs* supplies an attribute " +"that :class:`Context` doesn't support. Raises either :exc:`TypeError` " +"or :exc:`ValueError` if *kwargs* supplies an invalid value for an attribute." msgstr "" -#: library/decimal.rst:970 +#: library/decimal.rst:1012 msgid "" ":meth:`localcontext` now supports setting context attributes through the use " "of keyword arguments." msgstr "" -#: library/decimal.rst:973 +#: library/decimal.rst:1015 msgid "" "New contexts can also be created using the :class:`Context` constructor " "described below. In addition, the module provides three pre-made contexts:" msgstr "" -#: library/decimal.rst:979 +#: library/decimal.rst:1021 msgid "" "This is a standard context defined by the General Decimal Arithmetic " -"Specification. Precision is set to nine. Rounding is set to :const:" -"`ROUND_HALF_UP`. All flags are cleared. All traps are enabled (treated as " -"exceptions) except :const:`Inexact`, :const:`Rounded`, and :const:" -"`Subnormal`." +"Specification. Precision is set to nine. Rounding is set " +"to :const:`ROUND_HALF_UP`. All flags are cleared. All traps are enabled " +"(treated as exceptions) except :const:`Inexact`, :const:`Rounded`, " +"and :const:`Subnormal`." msgstr "" -#: library/decimal.rst:985 +#: library/decimal.rst:1027 msgid "" "Because many of the traps are enabled, this context is useful for debugging." msgstr "" -#: library/decimal.rst:990 +#: library/decimal.rst:1032 msgid "" "This is a standard context defined by the General Decimal Arithmetic " -"Specification. Precision is set to nine. Rounding is set to :const:" -"`ROUND_HALF_EVEN`. All flags are cleared. No traps are enabled (so that " -"exceptions are not raised during computations)." +"Specification. Precision is set to nine. Rounding is set " +"to :const:`ROUND_HALF_EVEN`. All flags are cleared. No traps are enabled " +"(so that exceptions are not raised during computations)." msgstr "" -#: library/decimal.rst:995 +#: library/decimal.rst:1037 msgid "" "Because the traps are disabled, this context is useful for applications that " "prefer to have result value of ``NaN`` or ``Infinity`` instead of raising " @@ -1008,7 +1292,7 @@ msgid "" "conditions that would otherwise halt the program." msgstr "" -#: library/decimal.rst:1003 +#: library/decimal.rst:1045 msgid "" "This context is used by the :class:`Context` constructor as a prototype for " "new contexts. Changing a field (such a precision) has the effect of " @@ -1016,7 +1300,7 @@ msgid "" "constructor." msgstr "" -#: library/decimal.rst:1007 +#: library/decimal.rst:1049 msgid "" "This context is most useful in multi-threaded environments. Changing one of " "the fields before threads are started has the effect of setting system-wide " @@ -1024,65 +1308,66 @@ msgid "" "as it would require thread synchronization to prevent race conditions." msgstr "" -#: library/decimal.rst:1012 +#: library/decimal.rst:1054 msgid "" "In single threaded environments, it is preferable to not use this context at " "all. Instead, simply create contexts explicitly as described below." msgstr "" -#: library/decimal.rst:1015 +#: library/decimal.rst:1057 msgid "" -"The default values are :attr:`Context.prec`\\ =\\ ``28``, :attr:`Context." -"rounding`\\ =\\ :const:`ROUND_HALF_EVEN`, and enabled traps for :class:" -"`Overflow`, :class:`InvalidOperation`, and :class:`DivisionByZero`." +"The default values are :attr:`Context.prec`\\ =\\ " +"``28``, :attr:`Context.rounding`\\ =\\ :const:`ROUND_HALF_EVEN`, and enabled " +"traps for :class:`Overflow`, :class:`InvalidOperation`, " +"and :class:`DivisionByZero`." msgstr "" -#: library/decimal.rst:1020 +#: library/decimal.rst:1062 msgid "" "In addition to the three supplied contexts, new contexts can be created with " "the :class:`Context` constructor." msgstr "" -#: library/decimal.rst:1026 +#: library/decimal.rst:1068 msgid "" "Creates a new context. If a field is not specified or is :const:`None`, the " "default values are copied from the :const:`DefaultContext`. If the *flags* " "field is not specified or is :const:`None`, all flags are cleared." msgstr "" -#: library/decimal.rst:1030 +#: library/decimal.rst:1072 msgid "" "*prec* is an integer in the range [``1``, :const:`MAX_PREC`] that sets the " "precision for arithmetic operations in the context." msgstr "" -#: library/decimal.rst:1033 +#: library/decimal.rst:1075 msgid "" "The *rounding* option is one of the constants listed in the section " "`Rounding Modes`_." msgstr "" -#: library/decimal.rst:1036 +#: library/decimal.rst:1078 msgid "" "The *traps* and *flags* fields list any signals to be set. Generally, new " "contexts should only set traps and leave the flags clear." msgstr "" -#: library/decimal.rst:1039 +#: library/decimal.rst:1081 msgid "" "The *Emin* and *Emax* fields are integers specifying the outer limits " "allowable for exponents. *Emin* must be in the range [:const:`MIN_EMIN`, " "``0``], *Emax* in the range [``0``, :const:`MAX_EMAX`]." msgstr "" -#: library/decimal.rst:1043 +#: library/decimal.rst:1085 msgid "" "The *capitals* field is either ``0`` or ``1`` (the default). If set to " "``1``, exponents are printed with a capital ``E``; otherwise, a lowercase " "``e`` is used: ``Decimal('6.02e+23')``." msgstr "" -#: library/decimal.rst:1047 +#: library/decimal.rst:1089 msgid "" "The *clamp* field is either ``0`` (the default) or ``1``. If set to ``1``, " "the exponent ``e`` of a :class:`Decimal` instance representable in this " @@ -1096,49 +1381,56 @@ msgid "" "For example::" msgstr "" -#: library/decimal.rst:1062 +#: library/decimal.rst:1101 +msgid "" +">>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')\n" +"Decimal('1.23000E+999')" +msgstr "" + +#: library/decimal.rst:1104 msgid "" "A *clamp* value of ``1`` allows compatibility with the fixed-width decimal " "interchange formats specified in IEEE 754." msgstr "" -#: library/decimal.rst:1065 +#: library/decimal.rst:1107 msgid "" "The :class:`Context` class defines several general purpose methods as well " "as a large number of methods for doing arithmetic directly in a given " "context. In addition, for each of the :class:`Decimal` methods described " -"above (with the exception of the :meth:`~Decimal.adjusted` and :meth:" -"`~Decimal.as_tuple` methods) there is a corresponding :class:`Context` " -"method. For example, for a :class:`Context` instance ``C`` and :class:" -"`Decimal` instance ``x``, ``C.exp(x)`` is equivalent to ``x." -"exp(context=C)``. Each :class:`Context` method accepts a Python integer (an " -"instance of :class:`int`) anywhere that a Decimal instance is accepted." +"above (with the exception of the :meth:`~Decimal.adjusted` " +"and :meth:`~Decimal.as_tuple` methods) there is a " +"corresponding :class:`Context` method. For example, for a :class:`Context` " +"instance ``C`` and :class:`Decimal` instance ``x``, ``C.exp(x)`` is " +"equivalent to ``x.exp(context=C)``. Each :class:`Context` method accepts a " +"Python integer (an instance of :class:`int`) anywhere that a Decimal " +"instance is accepted." msgstr "" -#: library/decimal.rst:1078 +#: library/decimal.rst:1120 msgid "Resets all of the flags to ``0``." msgstr "" -#: library/decimal.rst:1082 +#: library/decimal.rst:1124 msgid "Resets all of the traps to ``0``." msgstr "" -#: library/decimal.rst:1088 +#: library/decimal.rst:1130 msgid "Return a duplicate of the context." msgstr "" -#: library/decimal.rst:1092 +#: library/decimal.rst:1134 msgid "Return a copy of the Decimal instance num." msgstr "" -#: library/decimal.rst:1096 +#: library/decimal.rst:1138 msgid "" "Creates a new Decimal instance from *num* but using *self* as context. " "Unlike the :class:`Decimal` constructor, the context precision, rounding " "method, flags, and traps are applied to the conversion." msgstr "" -#: library/decimal.rst:1100 +#: library/decimal.rst:1142 msgid "" "This is useful because constants are often given to a greater precision than " "is needed by the application. Another benefit is that rounding immediately " @@ -1147,14 +1439,23 @@ msgid "" "sum can change the result:" msgstr "" -#: library/decimal.rst:1114 +#: library/decimal.rst:1148 +msgid "" +">>> getcontext().prec = 3\n" +">>> Decimal('3.4445') + Decimal('1.0023')\n" +"Decimal('4.45')\n" +">>> Decimal('3.4445') + Decimal(0) + Decimal('1.0023')\n" +"Decimal('4.44')" +msgstr "" + +#: library/decimal.rst:1156 msgid "" "This method implements the to-number operation of the IBM specification. If " "the argument is a string, no leading or trailing whitespace or underscores " "are permitted." msgstr "" -#: library/decimal.rst:1120 +#: library/decimal.rst:1162 msgid "" "Creates a new Decimal instance from a float *f* but rounding using *self* as " "the context. Unlike the :meth:`Decimal.from_float` class method, the " @@ -1162,18 +1463,30 @@ msgid "" "conversion." msgstr "" -#: library/decimal.rst:1140 +#: library/decimal.rst:1167 +msgid "" +">>> context = Context(prec=5, rounding=ROUND_DOWN)\n" +">>> context.create_decimal_from_float(math.pi)\n" +"Decimal('3.1415')\n" +">>> context = Context(prec=5, traps=[Inexact])\n" +">>> context.create_decimal_from_float(math.pi)\n" +"Traceback (most recent call last):\n" +" ...\n" +"decimal.Inexact: None" +msgstr "" + +#: library/decimal.rst:1182 msgid "" "Returns a value equal to ``Emin - prec + 1`` which is the minimum exponent " -"value for subnormal results. When underflow occurs, the exponent is set to :" -"const:`Etiny`." +"value for subnormal results. When underflow occurs, the exponent is set " +"to :const:`Etiny`." msgstr "" -#: library/decimal.rst:1146 +#: library/decimal.rst:1188 msgid "Returns a value equal to ``Emax - prec + 1``." msgstr "" -#: library/decimal.rst:1148 +#: library/decimal.rst:1190 msgid "" "The usual approach to working with decimals is to create :class:`Decimal` " "instances and then apply arithmetic operations which take place within the " @@ -1183,189 +1496,189 @@ msgid "" "recounted here." msgstr "" -#: library/decimal.rst:1158 +#: library/decimal.rst:1200 msgid "Returns the absolute value of *x*." msgstr "" -#: library/decimal.rst:1163 +#: library/decimal.rst:1205 msgid "Return the sum of *x* and *y*." msgstr "" -#: library/decimal.rst:1168 +#: library/decimal.rst:1210 msgid "Returns the same Decimal object *x*." msgstr "" -#: library/decimal.rst:1173 +#: library/decimal.rst:1215 msgid "Compares *x* and *y* numerically." msgstr "" -#: library/decimal.rst:1178 +#: library/decimal.rst:1220 msgid "Compares the values of the two operands numerically." msgstr "" -#: library/decimal.rst:1183 +#: library/decimal.rst:1225 msgid "Compares two operands using their abstract representation." msgstr "" -#: library/decimal.rst:1188 +#: library/decimal.rst:1230 msgid "" "Compares two operands using their abstract representation, ignoring sign." msgstr "" -#: library/decimal.rst:1193 +#: library/decimal.rst:1235 msgid "Returns a copy of *x* with the sign set to 0." msgstr "" -#: library/decimal.rst:1198 +#: library/decimal.rst:1240 msgid "Returns a copy of *x* with the sign inverted." msgstr "" -#: library/decimal.rst:1203 +#: library/decimal.rst:1245 msgid "Copies the sign from *y* to *x*." msgstr "" -#: library/decimal.rst:1208 +#: library/decimal.rst:1250 msgid "Return *x* divided by *y*." msgstr "" -#: library/decimal.rst:1213 +#: library/decimal.rst:1255 msgid "Return *x* divided by *y*, truncated to an integer." msgstr "" -#: library/decimal.rst:1218 +#: library/decimal.rst:1260 msgid "Divides two numbers and returns the integer part of the result." msgstr "" -#: library/decimal.rst:1223 +#: library/decimal.rst:1265 msgid "Returns ``e ** x``." msgstr "" -#: library/decimal.rst:1228 +#: library/decimal.rst:1270 msgid "Returns *x* multiplied by *y*, plus *z*." msgstr "" -#: library/decimal.rst:1233 +#: library/decimal.rst:1275 msgid "Returns ``True`` if *x* is canonical; otherwise returns ``False``." msgstr "" -#: library/decimal.rst:1238 +#: library/decimal.rst:1280 msgid "Returns ``True`` if *x* is finite; otherwise returns ``False``." msgstr "" -#: library/decimal.rst:1243 +#: library/decimal.rst:1285 msgid "Returns ``True`` if *x* is infinite; otherwise returns ``False``." msgstr "" -#: library/decimal.rst:1248 +#: library/decimal.rst:1290 msgid "Returns ``True`` if *x* is a qNaN or sNaN; otherwise returns ``False``." msgstr "" -#: library/decimal.rst:1253 +#: library/decimal.rst:1295 msgid "" "Returns ``True`` if *x* is a normal number; otherwise returns ``False``." msgstr "" -#: library/decimal.rst:1258 +#: library/decimal.rst:1300 msgid "Returns ``True`` if *x* is a quiet NaN; otherwise returns ``False``." msgstr "" -#: library/decimal.rst:1263 +#: library/decimal.rst:1305 msgid "Returns ``True`` if *x* is negative; otherwise returns ``False``." msgstr "" -#: library/decimal.rst:1268 +#: library/decimal.rst:1310 msgid "" "Returns ``True`` if *x* is a signaling NaN; otherwise returns ``False``." msgstr "" -#: library/decimal.rst:1273 +#: library/decimal.rst:1315 msgid "Returns ``True`` if *x* is subnormal; otherwise returns ``False``." msgstr "" -#: library/decimal.rst:1278 +#: library/decimal.rst:1320 msgid "Returns ``True`` if *x* is a zero; otherwise returns ``False``." msgstr "" -#: library/decimal.rst:1283 +#: library/decimal.rst:1325 msgid "Returns the natural (base e) logarithm of *x*." msgstr "" -#: library/decimal.rst:1288 +#: library/decimal.rst:1330 msgid "Returns the base 10 logarithm of *x*." msgstr "" -#: library/decimal.rst:1293 +#: library/decimal.rst:1335 msgid "Returns the exponent of the magnitude of the operand's MSD." msgstr "" -#: library/decimal.rst:1298 +#: library/decimal.rst:1340 msgid "Applies the logical operation *and* between each operand's digits." msgstr "" -#: library/decimal.rst:1303 +#: library/decimal.rst:1345 msgid "Invert all the digits in *x*." msgstr "" -#: library/decimal.rst:1308 +#: library/decimal.rst:1350 msgid "Applies the logical operation *or* between each operand's digits." msgstr "" -#: library/decimal.rst:1313 +#: library/decimal.rst:1355 msgid "Applies the logical operation *xor* between each operand's digits." msgstr "" -#: library/decimal.rst:1318 +#: library/decimal.rst:1360 msgid "Compares two values numerically and returns the maximum." msgstr "" -#: library/decimal.rst:1333 +#: library/decimal.rst:1375 msgid "Compares the values numerically with their sign ignored." msgstr "" -#: library/decimal.rst:1328 +#: library/decimal.rst:1370 msgid "Compares two values numerically and returns the minimum." msgstr "" -#: library/decimal.rst:1338 +#: library/decimal.rst:1380 msgid "Minus corresponds to the unary prefix minus operator in Python." msgstr "" -#: library/decimal.rst:1343 +#: library/decimal.rst:1385 msgid "Return the product of *x* and *y*." msgstr "" -#: library/decimal.rst:1348 +#: library/decimal.rst:1390 msgid "Returns the largest representable number smaller than *x*." msgstr "" -#: library/decimal.rst:1353 +#: library/decimal.rst:1395 msgid "Returns the smallest representable number larger than *x*." msgstr "" -#: library/decimal.rst:1358 +#: library/decimal.rst:1400 msgid "Returns the number closest to *x*, in direction towards *y*." msgstr "" -#: library/decimal.rst:1363 +#: library/decimal.rst:1405 msgid "Reduces *x* to its simplest form." msgstr "" -#: library/decimal.rst:1368 +#: library/decimal.rst:1410 msgid "Returns an indication of the class of *x*." msgstr "" -#: library/decimal.rst:1373 +#: library/decimal.rst:1415 msgid "" "Plus corresponds to the unary prefix plus operator in Python. This " "operation applies the context precision and rounding, so it is *not* an " "identity operation." msgstr "" -#: library/decimal.rst:1380 +#: library/decimal.rst:1422 msgid "Return ``x`` to the power of ``y``, reduced modulo ``modulo`` if given." msgstr "" -#: library/decimal.rst:1382 +#: library/decimal.rst:1424 msgid "" "With two arguments, compute ``x**y``. If ``x`` is negative then ``y`` must " "be integral. The result will be inexact unless ``y`` is integral and the " @@ -1374,42 +1687,42 @@ msgid "" "in the Python version." msgstr "" -#: library/decimal.rst:1388 +#: library/decimal.rst:1430 msgid "" "``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if " "``InvalidOperation`` is not trapped, then results in ``Decimal('NaN')``." msgstr "" -#: library/decimal.rst:1391 +#: library/decimal.rst:1433 msgid "" -"The C module computes :meth:`power` in terms of the correctly rounded :meth:" -"`exp` and :meth:`ln` functions. The result is well-defined but only \"almost " -"always correctly rounded\"." +"The C module computes :meth:`power` in terms of the correctly " +"rounded :meth:`exp` and :meth:`ln` functions. The result is well-defined but " +"only \"almost always correctly rounded\"." msgstr "" -#: library/decimal.rst:1396 +#: library/decimal.rst:1438 msgid "" "With three arguments, compute ``(x**y) % modulo``. For the three argument " "form, the following restrictions on the arguments hold:" msgstr "" -#: library/decimal.rst:1399 +#: library/decimal.rst:1441 msgid "all three arguments must be integral" msgstr "" -#: library/decimal.rst:1400 +#: library/decimal.rst:1442 msgid "``y`` must be nonnegative" msgstr "" -#: library/decimal.rst:1401 +#: library/decimal.rst:1443 msgid "at least one of ``x`` or ``y`` must be nonzero" msgstr "" -#: library/decimal.rst:1402 +#: library/decimal.rst:1444 msgid "``modulo`` must be nonzero and have at most 'precision' digits" msgstr "" -#: library/decimal.rst:1404 +#: library/decimal.rst:1446 msgid "" "The value resulting from ``Context.power(x, y, modulo)`` is equal to the " "value that would be obtained by computing ``(x**y) % modulo`` with unbounded " @@ -1418,110 +1731,110 @@ msgid "" "result is always exact." msgstr "" -#: library/decimal.rst:1414 +#: library/decimal.rst:1456 msgid "Returns a value equal to *x* (rounded), having the exponent of *y*." msgstr "" -#: library/decimal.rst:1419 +#: library/decimal.rst:1461 msgid "Just returns 10, as this is Decimal, :)" msgstr "" -#: library/decimal.rst:1424 +#: library/decimal.rst:1466 msgid "Returns the remainder from integer division." msgstr "" -#: library/decimal.rst:1426 +#: library/decimal.rst:1468 msgid "" "The sign of the result, if non-zero, is the same as that of the original " "dividend." msgstr "" -#: library/decimal.rst:1432 +#: library/decimal.rst:1474 msgid "" "Returns ``x - y * n``, where *n* is the integer nearest the exact value of " "``x / y`` (if the result is 0 then its sign will be the sign of *x*)." msgstr "" -#: library/decimal.rst:1438 +#: library/decimal.rst:1480 msgid "Returns a rotated copy of *x*, *y* times." msgstr "" -#: library/decimal.rst:1443 +#: library/decimal.rst:1485 msgid "Returns ``True`` if the two operands have the same exponent." msgstr "" -#: library/decimal.rst:1448 +#: library/decimal.rst:1490 msgid "Returns the first operand after adding the second value its exp." msgstr "" -#: library/decimal.rst:1453 +#: library/decimal.rst:1495 msgid "Returns a shifted copy of *x*, *y* times." msgstr "" -#: library/decimal.rst:1458 +#: library/decimal.rst:1500 msgid "Square root of a non-negative number to context precision." msgstr "" -#: library/decimal.rst:1463 +#: library/decimal.rst:1505 msgid "Return the difference between *x* and *y*." msgstr "" -#: library/decimal.rst:1477 +#: library/decimal.rst:1519 msgid "Rounds to an integer." msgstr "" -#: library/decimal.rst:1482 +#: library/decimal.rst:1524 msgid "Converts a number to a string using scientific notation." msgstr "" -#: library/decimal.rst:1489 +#: library/decimal.rst:1531 msgid "Constants" msgstr "" -#: library/decimal.rst:1491 +#: library/decimal.rst:1533 msgid "" "The constants in this section are only relevant for the C module. They are " "also included in the pure Python version for compatibility." msgstr "" -#: library/decimal.rst:1495 +#: library/decimal.rst:1537 msgid "32-bit" msgstr "" -#: library/decimal.rst:1495 +#: library/decimal.rst:1537 msgid "64-bit" msgstr "" -#: library/decimal.rst:1499 +#: library/decimal.rst:1541 msgid "``425000000``" msgstr "" -#: library/decimal.rst:1499 +#: library/decimal.rst:1541 msgid "``999999999999999999``" msgstr "" -#: library/decimal.rst:1501 +#: library/decimal.rst:1543 msgid "``-425000000``" msgstr "" -#: library/decimal.rst:1501 +#: library/decimal.rst:1543 msgid "``-999999999999999999``" msgstr "" -#: library/decimal.rst:1503 +#: library/decimal.rst:1545 msgid "``-849999999``" msgstr "" -#: library/decimal.rst:1503 +#: library/decimal.rst:1545 msgid "``-1999999999999999997``" msgstr "" -#: library/decimal.rst:1509 +#: library/decimal.rst:1551 msgid "" "The value is ``True``. Deprecated, because Python now always has threads." msgstr "" -#: library/decimal.rst:1515 +#: library/decimal.rst:1557 msgid "" "The default value is ``True``. If Python is :option:`configured using the --" "without-decimal-contextvar option <--without-decimal-contextvar>`, the C " @@ -1530,55 +1843,55 @@ msgid "" "scenarios." msgstr "" -#: library/decimal.rst:1524 +#: library/decimal.rst:1566 msgid "Rounding modes" msgstr "" -#: library/decimal.rst:1528 +#: library/decimal.rst:1570 msgid "Round towards ``Infinity``." msgstr "" -#: library/decimal.rst:1532 +#: library/decimal.rst:1574 msgid "Round towards zero." msgstr "" -#: library/decimal.rst:1536 +#: library/decimal.rst:1578 msgid "Round towards ``-Infinity``." msgstr "" -#: library/decimal.rst:1540 +#: library/decimal.rst:1582 msgid "Round to nearest with ties going towards zero." msgstr "" -#: library/decimal.rst:1544 +#: library/decimal.rst:1586 msgid "Round to nearest with ties going to nearest even integer." msgstr "" -#: library/decimal.rst:1548 +#: library/decimal.rst:1590 msgid "Round to nearest with ties going away from zero." msgstr "" -#: library/decimal.rst:1552 +#: library/decimal.rst:1594 msgid "Round away from zero." msgstr "" -#: library/decimal.rst:1556 +#: library/decimal.rst:1598 msgid "" "Round away from zero if last digit after rounding towards zero would have " "been 0 or 5; otherwise round towards zero." msgstr "" -#: library/decimal.rst:1563 +#: library/decimal.rst:1605 msgid "Signals" msgstr "" -#: library/decimal.rst:1565 +#: library/decimal.rst:1607 msgid "" "Signals represent conditions that arise during computation. Each corresponds " "to one context flag and one context trap enabler." msgstr "" -#: library/decimal.rst:1568 +#: library/decimal.rst:1610 msgid "" "The context flag is set whenever the condition is encountered. After the " "computation, flags may be checked for informational purposes (for instance, " @@ -1586,140 +1899,168 @@ msgid "" "sure to clear all flags before starting the next computation." msgstr "" -#: library/decimal.rst:1573 +#: library/decimal.rst:1615 msgid "" "If the context's trap enabler is set for the signal, then the condition " -"causes a Python exception to be raised. For example, if the :class:" -"`DivisionByZero` trap is set, then a :exc:`DivisionByZero` exception is " -"raised upon encountering the condition." +"causes a Python exception to be raised. For example, if " +"the :class:`DivisionByZero` trap is set, then a :exc:`DivisionByZero` " +"exception is raised upon encountering the condition." msgstr "" -#: library/decimal.rst:1581 +#: library/decimal.rst:1623 msgid "Altered an exponent to fit representation constraints." msgstr "" -#: library/decimal.rst:1583 +#: library/decimal.rst:1625 msgid "" -"Typically, clamping occurs when an exponent falls outside the context's :" -"attr:`~Context.Emin` and :attr:`~Context.Emax` limits. If possible, the " -"exponent is reduced to fit by adding zeros to the coefficient." +"Typically, clamping occurs when an exponent falls outside the " +"context's :attr:`~Context.Emin` and :attr:`~Context.Emax` limits. If " +"possible, the exponent is reduced to fit by adding zeros to the coefficient." msgstr "" -#: library/decimal.rst:1590 +#: library/decimal.rst:1632 msgid "Base class for other signals and a subclass of :exc:`ArithmeticError`." msgstr "" -#: library/decimal.rst:1595 +#: library/decimal.rst:1637 msgid "Signals the division of a non-infinite number by zero." msgstr "" -#: library/decimal.rst:1597 +#: library/decimal.rst:1639 msgid "" "Can occur with division, modulo division, or when raising a number to a " "negative power. If this signal is not trapped, returns ``Infinity`` or ``-" "Infinity`` with the sign determined by the inputs to the calculation." msgstr "" -#: library/decimal.rst:1604 +#: library/decimal.rst:1646 msgid "Indicates that rounding occurred and the result is not exact." msgstr "" -#: library/decimal.rst:1606 +#: library/decimal.rst:1648 msgid "" "Signals when non-zero digits were discarded during rounding. The rounded " "result is returned. The signal flag or trap is used to detect when results " "are inexact." msgstr "" -#: library/decimal.rst:1613 +#: library/decimal.rst:1655 msgid "An invalid operation was performed." msgstr "" -#: library/decimal.rst:1615 +#: library/decimal.rst:1657 msgid "" "Indicates that an operation was requested that does not make sense. If not " "trapped, returns ``NaN``. Possible causes include::" msgstr "" -#: library/decimal.rst:1631 +#: library/decimal.rst:1660 +msgid "" +"Infinity - Infinity\n" +"0 * Infinity\n" +"Infinity / Infinity\n" +"x % 0\n" +"Infinity % x\n" +"sqrt(-x) and x > 0\n" +"0 ** 0\n" +"x ** (non-integer)\n" +"x ** Infinity" +msgstr "" + +#: library/decimal.rst:1673 msgid "Numerical overflow." msgstr "" -#: library/decimal.rst:1633 +#: library/decimal.rst:1675 msgid "" "Indicates the exponent is larger than :attr:`Context.Emax` after rounding " "has occurred. If not trapped, the result depends on the rounding mode, " "either pulling inward to the largest representable finite number or rounding " -"outward to ``Infinity``. In either case, :class:`Inexact` and :class:" -"`Rounded` are also signaled." +"outward to ``Infinity``. In either case, :class:`Inexact` " +"and :class:`Rounded` are also signaled." msgstr "" -#: library/decimal.rst:1642 +#: library/decimal.rst:1684 msgid "Rounding occurred though possibly no information was lost." msgstr "" -#: library/decimal.rst:1644 +#: library/decimal.rst:1686 msgid "" "Signaled whenever rounding discards digits; even if those digits are zero " "(such as rounding ``5.00`` to ``5.0``). If not trapped, returns the result " "unchanged. This signal is used to detect loss of significant digits." msgstr "" -#: library/decimal.rst:1652 +#: library/decimal.rst:1694 msgid "Exponent was lower than :attr:`~Context.Emin` prior to rounding." msgstr "" -#: library/decimal.rst:1654 +#: library/decimal.rst:1696 msgid "" "Occurs when an operation result is subnormal (the exponent is too small). If " "not trapped, returns the result unchanged." msgstr "" -#: library/decimal.rst:1660 +#: library/decimal.rst:1702 msgid "Numerical underflow with result rounded to zero." msgstr "" -#: library/decimal.rst:1662 +#: library/decimal.rst:1704 msgid "" -"Occurs when a subnormal result is pushed to zero by rounding. :class:" -"`Inexact` and :class:`Subnormal` are also signaled." +"Occurs when a subnormal result is pushed to zero by " +"rounding. :class:`Inexact` and :class:`Subnormal` are also signaled." msgstr "" -#: library/decimal.rst:1668 +#: library/decimal.rst:1710 msgid "Enable stricter semantics for mixing floats and Decimals." msgstr "" -#: library/decimal.rst:1670 +#: library/decimal.rst:1712 msgid "" "If the signal is not trapped (default), mixing floats and Decimals is " -"permitted in the :class:`~decimal.Decimal` constructor, :meth:`~decimal." -"Context.create_decimal` and all comparison operators. Both conversion and " -"comparisons are exact. Any occurrence of a mixed operation is silently " -"recorded by setting :exc:`FloatOperation` in the context flags. Explicit " -"conversions with :meth:`~decimal.Decimal.from_float` or :meth:`~decimal." -"Context.create_decimal_from_float` do not set the flag." +"permitted in the :class:`~decimal.Decimal` " +"constructor, :meth:`~decimal.Context.create_decimal` and all comparison " +"operators. Both conversion and comparisons are exact. Any occurrence of a " +"mixed operation is silently recorded by setting :exc:`FloatOperation` in the " +"context flags. Explicit conversions with :meth:`~decimal.Decimal.from_float` " +"or :meth:`~decimal.Context.create_decimal_from_float` do not set the flag." msgstr "" -#: library/decimal.rst:1678 +#: library/decimal.rst:1720 msgid "" "Otherwise (the signal is trapped), only equality comparisons and explicit " -"conversions are silent. All other mixed operations raise :exc:" -"`FloatOperation`." +"conversions are silent. All other mixed operations " +"raise :exc:`FloatOperation`." msgstr "" -#: library/decimal.rst:1682 +#: library/decimal.rst:1724 msgid "The following table summarizes the hierarchy of signals::" msgstr "" -#: library/decimal.rst:1703 -msgid "Floating Point Notes" +#: library/decimal.rst:1726 +msgid "" +"exceptions.ArithmeticError(exceptions.Exception)\n" +" DecimalException\n" +" Clamped\n" +" DivisionByZero(DecimalException, exceptions.ZeroDivisionError)\n" +" Inexact\n" +" Overflow(Inexact, Rounded)\n" +" Underflow(Inexact, Rounded, Subnormal)\n" +" InvalidOperation\n" +" Rounded\n" +" Subnormal\n" +" FloatOperation(DecimalException, exceptions.TypeError)" msgstr "" -#: library/decimal.rst:1707 +#: library/decimal.rst:1745 +msgid "Floating-Point Notes" +msgstr "" + +#: library/decimal.rst:1749 msgid "Mitigating round-off error with increased precision" msgstr "" -#: library/decimal.rst:1709 +#: library/decimal.rst:1751 msgid "" "The use of decimal floating point eliminates decimal representation error " "(making it possible to represent ``0.1`` exactly); however, some operations " @@ -1727,33 +2068,68 @@ msgid "" "precision." msgstr "" -#: library/decimal.rst:1713 +#: library/decimal.rst:1755 msgid "" "The effects of round-off error can be amplified by the addition or " "subtraction of nearly offsetting quantities resulting in loss of " "significance. Knuth provides two instructive examples where rounded " -"floating point arithmetic with insufficient precision causes the breakdown " +"floating-point arithmetic with insufficient precision causes the breakdown " "of the associative and distributive properties of addition:" msgstr "" -#: library/decimal.rst:1737 +#: library/decimal.rst:1761 +msgid "" +"# Examples from Seminumerical Algorithms, Section 4.2.2.\n" +">>> from decimal import Decimal, getcontext\n" +">>> getcontext().prec = 8\n" +"\n" +">>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111')\n" +">>> (u + v) + w\n" +"Decimal('9.5111111')\n" +">>> u + (v + w)\n" +"Decimal('10')\n" +"\n" +">>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003')\n" +">>> (u*v) + (u*w)\n" +"Decimal('0.01')\n" +">>> u * (v+w)\n" +"Decimal('0.0060000')" +msgstr "" + +#: library/decimal.rst:1779 msgid "" "The :mod:`decimal` module makes it possible to restore the identities by " "expanding the precision sufficiently to avoid loss of significance:" msgstr "" -#: library/decimal.rst:1757 +#: library/decimal.rst:1782 +msgid "" +">>> getcontext().prec = 20\n" +">>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111')\n" +">>> (u + v) + w\n" +"Decimal('9.51111111')\n" +">>> u + (v + w)\n" +"Decimal('9.51111111')\n" +">>>\n" +">>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003')\n" +">>> (u*v) + (u*w)\n" +"Decimal('0.0060000')\n" +">>> u * (v+w)\n" +"Decimal('0.0060000')" +msgstr "" + +#: library/decimal.rst:1799 msgid "Special values" msgstr "" -#: library/decimal.rst:1759 +#: library/decimal.rst:1801 msgid "" "The number system for the :mod:`decimal` module provides special values " "including ``NaN``, ``sNaN``, ``-Infinity``, ``Infinity``, and two zeros, " "``+0`` and ``-0``." msgstr "" -#: library/decimal.rst:1763 +#: library/decimal.rst:1805 msgid "" "Infinities can be constructed directly with: ``Decimal('Infinity')``. Also, " "they can arise from dividing by zero when the :exc:`DivisionByZero` signal " @@ -1762,49 +2138,49 @@ msgid "" "representable number." msgstr "" -#: library/decimal.rst:1768 +#: library/decimal.rst:1810 msgid "" "The infinities are signed (affine) and can be used in arithmetic operations " "where they get treated as very large, indeterminate numbers. For instance, " "adding a constant to infinity gives another infinite result." msgstr "" -#: library/decimal.rst:1772 +#: library/decimal.rst:1814 msgid "" -"Some operations are indeterminate and return ``NaN``, or if the :exc:" -"`InvalidOperation` signal is trapped, raise an exception. For example, " -"``0/0`` returns ``NaN`` which means \"not a number\". This variety of " -"``NaN`` is quiet and, once created, will flow through other computations " +"Some operations are indeterminate and return ``NaN``, or if " +"the :exc:`InvalidOperation` signal is trapped, raise an exception. For " +"example, ``0/0`` returns ``NaN`` which means \"not a number\". This variety " +"of ``NaN`` is quiet and, once created, will flow through other computations " "always resulting in another ``NaN``. This behavior can be useful for a " "series of computations that occasionally have missing inputs --- it allows " "the calculation to proceed while flagging specific results as invalid." msgstr "" -#: library/decimal.rst:1780 +#: library/decimal.rst:1822 msgid "" "A variant is ``sNaN`` which signals rather than remaining quiet after every " "operation. This is a useful return value when an invalid result needs to " "interrupt a calculation for special handling." msgstr "" -#: library/decimal.rst:1784 +#: library/decimal.rst:1826 msgid "" "The behavior of Python's comparison operators can be a little surprising " "where a ``NaN`` is involved. A test for equality where one of the operands " "is a quiet or signaling ``NaN`` always returns :const:`False` (even when " "doing ``Decimal('NaN')==Decimal('NaN')``), while a test for inequality " "always returns :const:`True`. An attempt to compare two Decimals using any " -"of the ``<``, ``<=``, ``>`` or ``>=`` operators will raise the :exc:" -"`InvalidOperation` signal if either operand is a ``NaN``, and return :const:" -"`False` if this signal is not trapped. Note that the General Decimal " -"Arithmetic specification does not specify the behavior of direct " +"of the ``<``, ``<=``, ``>`` or ``>=`` operators will raise " +"the :exc:`InvalidOperation` signal if either operand is a ``NaN``, and " +"return :const:`False` if this signal is not trapped. Note that the General " +"Decimal Arithmetic specification does not specify the behavior of direct " "comparisons; these rules for comparisons involving a ``NaN`` were taken from " "the IEEE 854 standard (see Table 3 in section 5.7). To ensure strict " -"standards-compliance, use the :meth:`~Decimal.compare` and :meth:`~Decimal." -"compare_signal` methods instead." +"standards-compliance, use the :meth:`~Decimal.compare` " +"and :meth:`~Decimal.compare_signal` methods instead." msgstr "" -#: library/decimal.rst:1797 +#: library/decimal.rst:1839 msgid "" "The signed zeros can result from calculations that underflow. They keep the " "sign that would have resulted if the calculation had been carried out to " @@ -1812,20 +2188,20 @@ msgid "" "negative zeros are treated as equal and their sign is informational." msgstr "" -#: library/decimal.rst:1802 +#: library/decimal.rst:1844 msgid "" "In addition to the two signed zeros which are distinct yet equal, there are " "various representations of zero with differing precisions yet equivalent in " "value. This takes a bit of getting used to. For an eye accustomed to " -"normalized floating point representations, it is not immediately obvious " +"normalized floating-point representations, it is not immediately obvious " "that the following calculation returns a value equal to zero:" msgstr "" -#: library/decimal.rst:1817 +#: library/decimal.rst:1859 msgid "Working with threads" msgstr "" -#: library/decimal.rst:1819 +#: library/decimal.rst:1861 msgid "" "The :func:`getcontext` function accesses a different :class:`Context` object " "for each thread. Having separate thread contexts means that threads may " @@ -1833,20 +2209,20 @@ msgid "" "other threads." msgstr "" -#: library/decimal.rst:1823 +#: library/decimal.rst:1865 msgid "" "Likewise, the :func:`setcontext` function automatically assigns its target " "to the current thread." msgstr "" -#: library/decimal.rst:1826 +#: library/decimal.rst:1868 msgid "" -"If :func:`setcontext` has not been called before :func:`getcontext`, then :" -"func:`getcontext` will automatically create a new context for use in the " -"current thread." +"If :func:`setcontext` has not been called before :func:`getcontext`, " +"then :func:`getcontext` will automatically create a new context for use in " +"the current thread." msgstr "" -#: library/decimal.rst:1830 +#: library/decimal.rst:1872 msgid "" "The new context is copied from a prototype context called *DefaultContext*. " "To control the defaults so that each thread will use the same values " @@ -1855,51 +2231,216 @@ msgid "" "a race condition between threads calling :func:`getcontext`. For example::" msgstr "" -#: library/decimal.rst:1855 +#: library/decimal.rst:1878 +msgid "" +"# Set applicationwide defaults for all threads about to be launched\n" +"DefaultContext.prec = 12\n" +"DefaultContext.rounding = ROUND_DOWN\n" +"DefaultContext.traps = ExtendedContext.traps.copy()\n" +"DefaultContext.traps[InvalidOperation] = 1\n" +"setcontext(DefaultContext)\n" +"\n" +"# Afterwards, the threads can be started\n" +"t1.start()\n" +"t2.start()\n" +"t3.start()\n" +" . . ." +msgstr "" + +#: library/decimal.rst:1897 msgid "Recipes" msgstr "" -#: library/decimal.rst:1857 +#: library/decimal.rst:1899 msgid "" "Here are a few recipes that serve as utility functions and that demonstrate " "ways to work with the :class:`Decimal` class::" msgstr "" -#: library/decimal.rst:2012 +#: library/decimal.rst:1902 +msgid "" +"def moneyfmt(value, places=2, curr='', sep=',', dp='.',\n" +" pos='', neg='-', trailneg=''):\n" +" \"\"\"Convert Decimal to a money formatted string.\n" +"\n" +" places: required number of places after the decimal point\n" +" curr: optional currency symbol before the sign (may be blank)\n" +" sep: optional grouping separator (comma, period, space, or blank)\n" +" dp: decimal point indicator (comma or period)\n" +" only specify as blank when places is zero\n" +" pos: optional sign for positive numbers: '+', space or blank\n" +" neg: optional sign for negative numbers: '-', '(', space or blank\n" +" trailneg:optional trailing minus indicator: '-', ')', space or blank\n" +"\n" +" >>> d = Decimal('-1234567.8901')\n" +" >>> moneyfmt(d, curr='$')\n" +" '-$1,234,567.89'\n" +" >>> moneyfmt(d, places=0, sep='.', dp='', neg='', trailneg='-')\n" +" '1.234.568-'\n" +" >>> moneyfmt(d, curr='$', neg='(', trailneg=')')\n" +" '($1,234,567.89)'\n" +" >>> moneyfmt(Decimal(123456789), sep=' ')\n" +" '123 456 789.00'\n" +" >>> moneyfmt(Decimal('-0.02'), neg='<', trailneg='>')\n" +" '<0.02>'\n" +"\n" +" \"\"\"\n" +" q = Decimal(10) ** -places # 2 places --> '0.01'\n" +" sign, digits, exp = value.quantize(q).as_tuple()\n" +" result = []\n" +" digits = list(map(str, digits))\n" +" build, next = result.append, digits.pop\n" +" if sign:\n" +" build(trailneg)\n" +" for i in range(places):\n" +" build(next() if digits else '0')\n" +" if places:\n" +" build(dp)\n" +" if not digits:\n" +" build('0')\n" +" i = 0\n" +" while digits:\n" +" build(next())\n" +" i += 1\n" +" if i == 3 and digits:\n" +" i = 0\n" +" build(sep)\n" +" build(curr)\n" +" build(neg if sign else pos)\n" +" return ''.join(reversed(result))\n" +"\n" +"def pi():\n" +" \"\"\"Compute Pi to the current precision.\n" +"\n" +" >>> print(pi())\n" +" 3.141592653589793238462643383\n" +"\n" +" \"\"\"\n" +" getcontext().prec += 2 # extra digits for intermediate steps\n" +" three = Decimal(3) # substitute \"three=3.0\" for regular floats\n" +" lasts, t, s, n, na, d, da = 0, three, 3, 1, 0, 0, 24\n" +" while s != lasts:\n" +" lasts = s\n" +" n, na = n+na, na+8\n" +" d, da = d+da, da+32\n" +" t = (t * n) / d\n" +" s += t\n" +" getcontext().prec -= 2\n" +" return +s # unary plus applies the new precision\n" +"\n" +"def exp(x):\n" +" \"\"\"Return e raised to the power of x. Result type matches input " +"type.\n" +"\n" +" >>> print(exp(Decimal(1)))\n" +" 2.718281828459045235360287471\n" +" >>> print(exp(Decimal(2)))\n" +" 7.389056098930650227230427461\n" +" >>> print(exp(2.0))\n" +" 7.38905609893\n" +" >>> print(exp(2+0j))\n" +" (7.38905609893+0j)\n" +"\n" +" \"\"\"\n" +" getcontext().prec += 2\n" +" i, lasts, s, fact, num = 0, 0, 1, 1, 1\n" +" while s != lasts:\n" +" lasts = s\n" +" i += 1\n" +" fact *= i\n" +" num *= x\n" +" s += num / fact\n" +" getcontext().prec -= 2\n" +" return +s\n" +"\n" +"def cos(x):\n" +" \"\"\"Return the cosine of x as measured in radians.\n" +"\n" +" The Taylor series approximation works best for a small value of x.\n" +" For larger values, first compute x = x % (2 * pi).\n" +"\n" +" >>> print(cos(Decimal('0.5')))\n" +" 0.8775825618903727161162815826\n" +" >>> print(cos(0.5))\n" +" 0.87758256189\n" +" >>> print(cos(0.5+0j))\n" +" (0.87758256189+0j)\n" +"\n" +" \"\"\"\n" +" getcontext().prec += 2\n" +" i, lasts, s, fact, num, sign = 0, 0, 1, 1, 1, 1\n" +" while s != lasts:\n" +" lasts = s\n" +" i += 2\n" +" fact *= i * (i-1)\n" +" num *= x * x\n" +" sign *= -1\n" +" s += num / fact * sign\n" +" getcontext().prec -= 2\n" +" return +s\n" +"\n" +"def sin(x):\n" +" \"\"\"Return the sine of x as measured in radians.\n" +"\n" +" The Taylor series approximation works best for a small value of x.\n" +" For larger values, first compute x = x % (2 * pi).\n" +"\n" +" >>> print(sin(Decimal('0.5')))\n" +" 0.4794255386042030002732879352\n" +" >>> print(sin(0.5))\n" +" 0.479425538604\n" +" >>> print(sin(0.5+0j))\n" +" (0.479425538604+0j)\n" +"\n" +" \"\"\"\n" +" getcontext().prec += 2\n" +" i, lasts, s, fact, num, sign = 1, 0, x, 1, x, 1\n" +" while s != lasts:\n" +" lasts = s\n" +" i += 2\n" +" fact *= i * (i-1)\n" +" num *= x * x\n" +" sign *= -1\n" +" s += num / fact * sign\n" +" getcontext().prec -= 2\n" +" return +s" +msgstr "" + +#: library/decimal.rst:2054 msgid "Decimal FAQ" msgstr "" -#: library/decimal.rst:2014 +#: library/decimal.rst:2056 msgid "" "Q. It is cumbersome to type ``decimal.Decimal('1234.5')``. Is there a way " "to minimize typing when using the interactive interpreter?" msgstr "" -#: library/decimal.rst:2017 +#: library/decimal.rst:2059 msgid "A. Some users abbreviate the constructor to just a single letter:" msgstr "" -#: library/decimal.rst:2023 +#: library/decimal.rst:2065 msgid "" "Q. In a fixed-point application with two decimal places, some inputs have " "many places and need to be rounded. Others are not supposed to have excess " "digits and need to be validated. What methods should be used?" msgstr "" -#: library/decimal.rst:2027 +#: library/decimal.rst:2069 msgid "" "A. The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal " "places. If the :const:`Inexact` trap is set, it is also useful for " "validation:" msgstr "" -#: library/decimal.rst:2045 +#: library/decimal.rst:2087 msgid "" "Q. Once I have valid two place inputs, how do I maintain that invariant " "throughout an application?" msgstr "" -#: library/decimal.rst:2048 +#: library/decimal.rst:2090 msgid "" "A. Some operations like addition, subtraction, and multiplication by an " "integer will automatically preserve fixed point. Others operations, like " @@ -1907,13 +2448,13 @@ msgid "" "places and need to be followed-up with a :meth:`~Decimal.quantize` step:" msgstr "" -#: library/decimal.rst:2066 +#: library/decimal.rst:2108 msgid "" "In developing fixed-point applications, it is convenient to define functions " "to handle the :meth:`~Decimal.quantize` step:" msgstr "" -#: library/decimal.rst:2080 +#: library/decimal.rst:2122 msgid "" "Q. There are many ways to express the same value. The numbers ``200``, " "``200.000``, ``2E2``, and ``.02E+4`` all have the same value at various " @@ -1921,17 +2462,17 @@ msgid "" "canonical value?" msgstr "" -#: library/decimal.rst:2085 +#: library/decimal.rst:2127 msgid "" "A. The :meth:`~Decimal.normalize` method maps all equivalent values to a " "single representative:" msgstr "" -#: library/decimal.rst:2092 +#: library/decimal.rst:2134 msgid "Q. When does rounding occur in a computation?" msgstr "" -#: library/decimal.rst:2094 +#: library/decimal.rst:2136 msgid "" "A. It occurs *after* the computation. The philosophy of the decimal " "specification is that numbers are considered exact and are created " @@ -1941,13 +2482,27 @@ msgid "" "computation::" msgstr "" -#: library/decimal.rst:2112 +#: library/decimal.rst:2143 +msgid "" +">>> getcontext().prec = 5\n" +">>> pi = Decimal('3.1415926535') # More than 5 digits\n" +">>> pi # All digits are retained\n" +"Decimal('3.1415926535')\n" +">>> pi + 0 # Rounded after an addition\n" +"Decimal('3.1416')\n" +">>> pi - Decimal('0.00005') # Subtract unrounded numbers, then round\n" +"Decimal('3.1415')\n" +">>> pi + 0 - Decimal('0.00005'). # Intermediate values are rounded\n" +"Decimal('3.1416')" +msgstr "" + +#: library/decimal.rst:2154 msgid "" "Q. Some decimal values always print with exponential notation. Is there a " "way to get a non-exponential representation?" msgstr "" -#: library/decimal.rst:2115 +#: library/decimal.rst:2157 msgid "" "A. For some values, exponential notation is the only way to express the " "number of significant places in the coefficient. For example, expressing " @@ -1955,31 +2510,37 @@ msgid "" "original's two-place significance." msgstr "" -#: library/decimal.rst:2120 +#: library/decimal.rst:2162 msgid "" "If an application does not care about tracking significance, it is easy to " "remove the exponent and trailing zeroes, losing significance, but keeping " "the value unchanged:" msgstr "" -#: library/decimal.rst:2130 +#: library/decimal.rst:2172 msgid "Q. Is there a way to convert a regular float to a :class:`Decimal`?" msgstr "" -#: library/decimal.rst:2132 +#: library/decimal.rst:2174 msgid "" -"A. Yes, any binary floating point number can be exactly expressed as a " +"A. Yes, any binary floating-point number can be exactly expressed as a " "Decimal though an exact conversion may take more precision than intuition " "would suggest:" msgstr "" -#: library/decimal.rst:2141 +#: library/decimal.rst:2178 +msgid "" +">>> Decimal(math.pi)\n" +"Decimal('3.141592653589793115997963468544185161590576171875')" +msgstr "" + +#: library/decimal.rst:2183 msgid "" "Q. Within a complex calculation, how can I make sure that I haven't gotten a " "spurious result because of insufficient precision or rounding anomalies." msgstr "" -#: library/decimal.rst:2144 +#: library/decimal.rst:2186 msgid "" "A. The decimal module makes it easy to test results. A best practice is to " "re-run calculations using greater precision and with various rounding modes. " @@ -1987,14 +2548,14 @@ msgid "" "issues, ill-conditioned inputs, or a numerically unstable algorithm." msgstr "" -#: library/decimal.rst:2149 +#: library/decimal.rst:2191 msgid "" "Q. I noticed that context precision is applied to the results of operations " "but not to the inputs. Is there anything to watch out for when mixing " "values of different precisions?" msgstr "" -#: library/decimal.rst:2153 +#: library/decimal.rst:2195 msgid "" "A. Yes. The principle is that all values are considered to be exact and so " "is the arithmetic on those values. Only the results are rounded. The " @@ -2003,56 +2564,88 @@ msgid "" "haven't been rounded:" msgstr "" -#: library/decimal.rst:2166 +#: library/decimal.rst:2200 +msgid "" +">>> getcontext().prec = 3\n" +">>> Decimal('3.104') + Decimal('2.104')\n" +"Decimal('5.21')\n" +">>> Decimal('3.104') + Decimal('0.000') + Decimal('2.104')\n" +"Decimal('5.20')" +msgstr "" + +#: library/decimal.rst:2208 msgid "" "The solution is either to increase precision or to force rounding of inputs " "using the unary plus operation:" msgstr "" -#: library/decimal.rst:2175 +#: library/decimal.rst:2211 msgid "" -"Alternatively, inputs can be rounded upon creation using the :meth:`Context." -"create_decimal` method:" +">>> getcontext().prec = 3\n" +">>> +Decimal('1.23456789') # unary plus triggers rounding\n" +"Decimal('1.23')" msgstr "" -#: library/decimal.rst:2181 +#: library/decimal.rst:2217 +msgid "" +"Alternatively, inputs can be rounded upon creation using " +"the :meth:`Context.create_decimal` method:" +msgstr "" + +#: library/decimal.rst:2223 msgid "Q. Is the CPython implementation fast for large numbers?" msgstr "" -#: library/decimal.rst:2183 +#: library/decimal.rst:2225 msgid "" "A. Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of " -"the decimal module integrate the high speed `libmpdec `_ library for arbitrary precision " -"correctly rounded decimal floating point arithmetic [#]_. ``libmpdec`` uses " -"`Karatsuba multiplication `_ library for arbitrary " +"precision correctly rounded decimal floating-point arithmetic [#]_. " +"``libmpdec`` uses `Karatsuba multiplication `_ for medium-sized numbers and the `Number Theoretic " "Transform `_ for very " "large numbers." msgstr "" -#: library/decimal.rst:2193 +#: library/decimal.rst:2235 msgid "" -"The context must be adapted for exact arbitrary precision arithmetic. :attr:" -"`~Context.Emin` and :attr:`~Context.Emax` should always be set to the " -"maximum values, :attr:`~Context.clamp` should always be 0 (the default). " -"Setting :attr:`~Context.prec` requires some care." +"The context must be adapted for exact arbitrary precision " +"arithmetic. :attr:`~Context.Emin` and :attr:`~Context.Emax` should always be " +"set to the maximum values, :attr:`~Context.clamp` should always be 0 (the " +"default). Setting :attr:`~Context.prec` requires some care." msgstr "" -#: library/decimal.rst:2197 +#: library/decimal.rst:2239 msgid "" "The easiest approach for trying out bignum arithmetic is to use the maximum " "value for :attr:`~Context.prec` as well [#]_::" msgstr "" -#: library/decimal.rst:2206 +#: library/decimal.rst:2242 +msgid "" +">>> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN))\n" +">>> x = Decimal(2) ** 256\n" +">>> x / 128\n" +"Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312')" +msgstr "" + +#: library/decimal.rst:2248 msgid "" -"For inexact results, :attr:`MAX_PREC` is far too large on 64-bit platforms " +"For inexact results, :const:`MAX_PREC` is far too large on 64-bit platforms " "and the available memory will be insufficient::" msgstr "" -#: library/decimal.rst:2214 +#: library/decimal.rst:2251 +msgid "" +">>> Decimal(1) / 3\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"MemoryError" +msgstr "" + +#: library/decimal.rst:2256 msgid "" "On systems with overallocation (e.g. Linux), a more sophisticated approach " "is to adjust :attr:`~Context.prec` to the amount of available RAM. Suppose " @@ -2060,14 +2653,38 @@ msgid "" "of 500MB each::" msgstr "" -#: library/decimal.rst:2238 +#: library/decimal.rst:2260 +msgid "" +">>> import sys\n" +">>>\n" +">>> # Maximum number of digits for a single operand using 500MB in 8-byte " +"words\n" +">>> # with 19 digits per word (4-byte and 9 digits for the 32-bit build):\n" +">>> maxdigits = 19 * ((500 * 1024**2) // 8)\n" +">>>\n" +">>> # Check that this works:\n" +">>> c = Context(prec=maxdigits, Emax=MAX_EMAX, Emin=MIN_EMIN)\n" +">>> c.traps[Inexact] = True\n" +">>> setcontext(c)\n" +">>>\n" +">>> # Fill the available precision with nines:\n" +">>> x = Decimal(0).logical_invert() * 9\n" +">>> sys.getsizeof(x)\n" +"524288112\n" +">>> x + 2\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" decimal.Inexact: []" +msgstr "" + +#: library/decimal.rst:2280 msgid "" "In general (and especially on systems without overallocation), it is " "recommended to estimate even tighter bounds and set the :attr:`Inexact` trap " "if all calculations are expected to be exact." msgstr "" -#: library/decimal.rst:2247 +#: library/decimal.rst:2289 msgid "" "This approach now works for all exact results except for non-integer powers." msgstr "" diff --git a/library/development.po b/library/development.po index 5611a7a6..0b0378d6 100644 --- a/library/development.po +++ b/library/development.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/devmode.po b/library/devmode.po index 4e94c793..9482da52 100644 --- a/library/devmode.po +++ b/library/devmode.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -48,6 +49,11 @@ msgid "" "but with additional effects described below::" msgstr "" +#: library/devmode.rst:24 +msgid "" +"PYTHONMALLOC=debug PYTHONASYNCIODEBUG=1 python -W default -X faulthandler" +msgstr "" + #: library/devmode.rst:26 msgid "Effects of the Python Development Mode:" msgstr "" @@ -87,9 +93,9 @@ msgstr "" #: library/devmode.rst:41 msgid "" -"Use the :option:`-W error <-W>` command line option or set the :envvar:" -"`PYTHONWARNINGS` environment variable to ``error`` to treat warnings as " -"errors." +"Use the :option:`-W error <-W>` command line option or set " +"the :envvar:`PYTHONWARNINGS` environment variable to ``error`` to treat " +"warnings as errors." msgstr "" #: library/devmode.rst:45 @@ -132,9 +138,8 @@ msgstr "" #: library/devmode.rst:61 msgid "" "Call :func:`faulthandler.enable` at Python startup to install handlers for " -"the :const:`~signal.SIGSEGV`, :const:`~signal.SIGFPE`, :const:`~signal." -"SIGABRT`, :const:`~signal.SIGBUS` and :const:`~signal.SIGILL` signals to " -"dump the Python traceback on a crash." +"the :const:`~signal.SIGSEGV`, :const:`~signal.SIGFPE`, :const:`~signal.SIGABRT`, :const:`~signal.SIGBUS` " +"and :const:`~signal.SIGILL` signals to dump the Python traceback on a crash." msgstr "" #: library/devmode.rst:66 @@ -146,8 +151,9 @@ msgstr "" #: library/devmode.rst:70 msgid "" -"Enable :ref:`asyncio debug mode `. For example, :mod:" -"`asyncio` checks for coroutines that were not awaited and logs them." +"Enable :ref:`asyncio debug mode `. For " +"example, :mod:`asyncio` checks for coroutines that were not awaited and logs " +"them." msgstr "" #: library/devmode.rst:73 @@ -159,8 +165,8 @@ msgstr "" #: library/devmode.rst:76 msgid "" "Check the *encoding* and *errors* arguments for string encoding and decoding " -"operations. Examples: :func:`open`, :meth:`str.encode` and :meth:`bytes." -"decode`." +"operations. Examples: :func:`open`, :meth:`str.encode` " +"and :meth:`bytes.decode`." msgstr "" #: library/devmode.rst:80 @@ -185,17 +191,17 @@ msgid "" "The Python Development Mode does not enable the :mod:`tracemalloc` module by " "default, because the overhead cost (to performance and memory) would be too " "large. Enabling the :mod:`tracemalloc` module provides additional " -"information on the origin of some errors. For example, :exc:" -"`ResourceWarning` logs the traceback where the resource was allocated, and a " -"buffer overflow error logs the traceback where the memory block was " -"allocated." +"information on the origin of some errors. For " +"example, :exc:`ResourceWarning` logs the traceback where the resource was " +"allocated, and a buffer overflow error logs the traceback where the memory " +"block was allocated." msgstr "" #: library/devmode.rst:95 msgid "" "The Python Development Mode does not prevent the :option:`-O` command line " -"option from removing :keyword:`assert` statements nor from setting :const:" -"`__debug__` to ``False``." +"option from removing :keyword:`assert` statements nor from " +"setting :const:`__debug__` to ``False``." msgstr "" #: library/devmode.rst:99 @@ -224,29 +230,82 @@ msgid "" "in the command line::" msgstr "" +#: library/devmode.rst:116 +msgid "" +"import sys\n" +"\n" +"def main():\n" +" fp = open(sys.argv[1])\n" +" nlines = len(fp.readlines())\n" +" print(nlines)\n" +" # The file is closed implicitly\n" +"\n" +"if __name__ == \"__main__\":\n" +" main()" +msgstr "" + #: library/devmode.rst:127 msgid "" "The script does not close the file explicitly. By default, Python does not " "emit any warning. Example using README.txt, which has 269 lines:" msgstr "" +#: library/devmode.rst:130 +msgid "" +"$ python script.py README.txt\n" +"269" +msgstr "" + #: library/devmode.rst:135 msgid "" "Enabling the Python Development Mode displays a :exc:`ResourceWarning` " "warning:" msgstr "" +#: library/devmode.rst:137 +msgid "" +"$ python -X dev script.py README.txt\n" +"269\n" +"script.py:10: ResourceWarning: unclosed file <_io.TextIOWrapper " +"name='README.rst' mode='r' encoding='UTF-8'>\n" +" main()\n" +"ResourceWarning: Enable tracemalloc to get the object allocation traceback" +msgstr "" + #: library/devmode.rst:145 msgid "" "In addition, enabling :mod:`tracemalloc` shows the line where the file was " "opened:" msgstr "" +#: library/devmode.rst:148 +msgid "" +"$ python -X dev -X tracemalloc=5 script.py README.rst\n" +"269\n" +"script.py:10: ResourceWarning: unclosed file <_io.TextIOWrapper " +"name='README.rst' mode='r' encoding='UTF-8'>\n" +" main()\n" +"Object allocated at (most recent call last):\n" +" File \"script.py\", lineno 10\n" +" main()\n" +" File \"script.py\", lineno 4\n" +" fp = open(sys.argv[1])" +msgstr "" + #: library/devmode.rst:160 msgid "" "The fix is to close explicitly the file. Example using a context manager::" msgstr "" +#: library/devmode.rst:162 +msgid "" +"def main():\n" +" # Close the file explicitly when exiting the with block\n" +" with open(sys.argv[1]) as fp:\n" +" nlines = len(fp.readlines())\n" +" print(nlines)" +msgstr "" + #: library/devmode.rst:168 msgid "" "Not closing a resource explicitly can leave a resource open for way longer " @@ -263,23 +322,59 @@ msgstr "" msgid "Script displaying the first line of itself::" msgstr "" +#: library/devmode.rst:179 +msgid "" +"import os\n" +"\n" +"def main():\n" +" fp = open(__file__)\n" +" firstline = fp.readline()\n" +" print(firstline.rstrip())\n" +" os.close(fp.fileno())\n" +" # The file is closed implicitly\n" +"\n" +"main()" +msgstr "" + #: library/devmode.rst:190 msgid "By default, Python does not emit any warning:" msgstr "" +#: library/devmode.rst:192 +msgid "" +"$ python script.py\n" +"import os" +msgstr "" + #: library/devmode.rst:197 msgid "" "The Python Development Mode shows a :exc:`ResourceWarning` and logs a \"Bad " "file descriptor\" error when finalizing the file object:" msgstr "" +#: library/devmode.rst:200 +msgid "" +"$ python -X dev script.py\n" +"import os\n" +"script.py:10: ResourceWarning: unclosed file <_io.TextIOWrapper " +"name='script.py' mode='r' encoding='UTF-8'>\n" +" main()\n" +"ResourceWarning: Enable tracemalloc to get the object allocation traceback\n" +"Exception ignored in: <_io.TextIOWrapper name='script.py' mode='r' " +"encoding='UTF-8'>\n" +"Traceback (most recent call last):\n" +" File \"script.py\", line 10, in \n" +" main()\n" +"OSError: [Errno 9] Bad file descriptor" +msgstr "" + #: library/devmode.rst:213 msgid "" "``os.close(fp.fileno())`` closes the file descriptor. When the file object " "finalizer tries to close the file descriptor again, it fails with the ``Bad " "file descriptor`` error. A file descriptor must be closed only once. In the " -"worst case scenario, closing it twice can lead to a crash (see :issue:" -"`18748` for an example)." +"worst case scenario, closing it twice can lead to a crash " +"(see :issue:`18748` for an example)." msgstr "" #: library/devmode.rst:219 diff --git a/library/dialog.po b/library/dialog.po index ca40da54..b8e4999f 100644 --- a/library/dialog.po +++ b/library/dialog.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/difflib.po b/library/difflib.po index 7906fea9..9fac34d7 100644 --- a/library/difflib.po +++ b/library/difflib.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/difflib.rst:2 -msgid ":mod:`difflib` --- Helpers for computing deltas" +msgid ":mod:`!difflib` --- Helpers for computing deltas" msgstr "" #: library/difflib.rst:11 @@ -164,10 +165,10 @@ msgstr "" #: library/difflib.rst:105 msgid "" -"*linejunk* and *charjunk* are optional keyword arguments passed into :func:" -"`ndiff` (used by :class:`HtmlDiff` to generate the side by side HTML " -"differences). See :func:`ndiff` documentation for argument default values " -"and descriptions." +"*linejunk* and *charjunk* are optional keyword arguments passed " +"into :func:`ndiff` (used by :class:`HtmlDiff` to generate the side by side " +"HTML differences). See :func:`ndiff` documentation for argument default " +"values and descriptions." msgstr "" #: library/difflib.rst:109 @@ -221,8 +222,8 @@ msgstr "" #: library/difflib.rst:145 msgid "" -"The arguments for this method are the same as those for the :meth:" -"`make_file` method." +"The arguments for this method are the same as those for " +"the :meth:`make_file` method." msgstr "" #: library/difflib.rst:152 @@ -401,7 +402,7 @@ msgid "" "for parameter *charjunk* in :func:`ndiff`." msgstr "" -#: library/difflib.rst:355 +#: library/difflib.rst:354 msgid "" "`Pattern Matching: The Gestalt Approach `_" @@ -431,6 +432,10 @@ msgid "" "ignored. For example, pass::" msgstr "" +#: library/difflib.rst:375 +msgid "lambda x: x in \" \\t\"" +msgstr "" + #: library/difflib.rst:377 msgid "" "if you're comparing lines as sequences of characters, and don't want to " @@ -440,8 +445,8 @@ msgstr "" #: library/difflib.rst:380 msgid "" "The optional arguments *a* and *b* are sequences to be compared; both " -"default to empty strings. The elements of both sequences must be :term:" -"`hashable`." +"default to empty strings. The elements of both sequences must " +"be :term:`hashable`." msgstr "" #: library/difflib.rst:383 @@ -456,8 +461,8 @@ msgid "" "elements of *b* for which *isjunk* is ``True``; *bpopular* is the set of non-" "junk elements considered popular by the heuristic (if it is not disabled); " "*b2j* is a dict mapping the remaining elements of *b* to a list of positions " -"where they occur. All three are reset whenever *b* is reset with :meth:" -"`set_seqs` or :meth:`set_seq2`." +"where they occur. All three are reset whenever *b* is reset " +"with :meth:`set_seqs` or :meth:`set_seq2`." msgstr "" #: library/difflib.rst:396 @@ -540,8 +545,8 @@ msgstr "" #: library/difflib.rst:466 msgid "" "Return list of triples describing non-overlapping matching subsequences. " -"Each triple is of the form ``(i, j, n)``, and means that ``a[i:i+n] == b[j:" -"j+n]``. The triples are monotonically increasing in *i* and *j*." +"Each triple is of the form ``(i, j, n)``, and means that ``a[i:i+n] == " +"b[j:j+n]``. The triples are monotonically increasing in *i* and *j*." msgstr "" #: library/difflib.rst:471 @@ -553,6 +558,13 @@ msgid "" "triples always describe non-adjacent equal blocks." msgstr "" +#: library/difflib.rst:479 +msgid "" +">>> s = SequenceMatcher(None, \"abxcd\", \"abcd\")\n" +">>> s.get_matching_blocks()\n" +"[Match(a=0, b=0, size=2), Match(a=3, b=2, size=2), Match(a=5, b=4, size=0)]" +msgstr "" + #: library/difflib.rst:488 msgid "" "Return list of 5-tuples describing how to turn *a* into *b*. Each tuple is " @@ -607,6 +619,21 @@ msgstr "" msgid "For example::" msgstr "" +#: library/difflib.rst:514 +msgid "" +">>> a = \"qabxcd\"\n" +">>> b = \"abycdf\"\n" +">>> s = SequenceMatcher(None, a, b)\n" +">>> for tag, i1, i2, j1, j2 in s.get_opcodes():\n" +"... print('{:7} a[{}:{}] --> b[{}:{}] {!r:>8} --> {!r}'.format(\n" +"... tag, i1, i2, j1, j2, a[i1:i2], b[j1:j2]))\n" +"delete a[0:1] --> b[0:0] 'q' --> ''\n" +"equal a[1:3] --> b[0:2] 'ab' --> 'ab'\n" +"replace a[3:4] --> b[2:3] 'x' --> 'y'\n" +"equal a[4:6] --> b[3:5] 'cd' --> 'cd'\n" +"insert a[6:6] --> b[5:6] '' --> 'f'" +msgstr "" + #: library/difflib.rst:529 msgid "Return a :term:`generator` of groups with up to *n* lines of context." msgstr "" @@ -636,9 +663,10 @@ msgstr "" #: library/difflib.rst:547 msgid "" -"This is expensive to compute if :meth:`get_matching_blocks` or :meth:" -"`get_opcodes` hasn't already been called, in which case you may want to try :" -"meth:`quick_ratio` or :meth:`real_quick_ratio` first to get an upper bound." +"This is expensive to compute if :meth:`get_matching_blocks` " +"or :meth:`get_opcodes` hasn't already been called, in which case you may " +"want to try :meth:`quick_ratio` or :meth:`real_quick_ratio` first to get an " +"upper bound." msgstr "" #: library/difflib.rst:554 @@ -647,6 +675,14 @@ msgid "" "arguments. For instance::" msgstr "" +#: library/difflib.rst:557 +msgid "" +">>> SequenceMatcher(None, 'tide', 'diet').ratio()\n" +"0.25\n" +">>> SequenceMatcher(None, 'diet', 'tide').ratio()\n" +"0.5" +msgstr "" + #: library/difflib.rst:565 msgid "Return an upper bound on :meth:`ratio` relatively quickly." msgstr "" @@ -658,10 +694,10 @@ msgstr "" #: library/difflib.rst:573 msgid "" "The three methods that return the ratio of matching to total characters can " -"give different results due to differing levels of approximation, although :" -"meth:`~SequenceMatcher.quick_ratio` and :meth:`~SequenceMatcher." -"real_quick_ratio` are always at least as large as :meth:`~SequenceMatcher." -"ratio`:" +"give different results due to differing levels of approximation, " +"although :meth:`~SequenceMatcher.quick_ratio` " +"and :meth:`~SequenceMatcher.real_quick_ratio` are always at least as large " +"as :meth:`~SequenceMatcher.ratio`:" msgstr "" #: library/difflib.rst:590 @@ -675,28 +711,29 @@ msgstr "" #: library/difflib.rst:598 msgid "" ":meth:`~SequenceMatcher.ratio` returns a float in [0, 1], measuring the " -"similarity of the sequences. As a rule of thumb, a :meth:`~SequenceMatcher." -"ratio` value over 0.6 means the sequences are close matches:" +"similarity of the sequences. As a rule of thumb, " +"a :meth:`~SequenceMatcher.ratio` value over 0.6 means the sequences are " +"close matches:" msgstr "" #: library/difflib.rst:605 msgid "" -"If you're only interested in where the sequences match, :meth:" -"`~SequenceMatcher.get_matching_blocks` is handy:" +"If you're only interested in where the sequences " +"match, :meth:`~SequenceMatcher.get_matching_blocks` is handy:" msgstr "" #: library/difflib.rst:614 msgid "" -"Note that the last tuple returned by :meth:`~SequenceMatcher." -"get_matching_blocks` is always a dummy, ``(len(a), len(b), 0)``, and this is " -"the only case in which the last tuple element (number of elements matched) " -"is ``0``." +"Note that the last tuple returned " +"by :meth:`~SequenceMatcher.get_matching_blocks` is always a dummy, " +"``(len(a), len(b), 0)``, and this is the only case in which the last tuple " +"element (number of elements matched) is ``0``." msgstr "" #: library/difflib.rst:618 msgid "" -"If you want to know how to change the first sequence into the second, use :" -"meth:`~SequenceMatcher.get_opcodes`:" +"If you want to know how to change the first sequence into the second, " +"use :meth:`~SequenceMatcher.get_opcodes`:" msgstr "" #: library/difflib.rst:629 @@ -707,8 +744,9 @@ msgstr "" #: library/difflib.rst:633 msgid "" -"`Simple version control recipe `_ for a small application built with :class:`SequenceMatcher`." +"`Simple version control recipe `_ for a small application built " +"with :class:`SequenceMatcher`." msgstr "" #: library/difflib.rst:641 @@ -770,10 +808,10 @@ msgstr "" #: library/difflib.rst:679 msgid "" "Each sequence must contain individual single-line strings ending with " -"newlines. Such sequences can be obtained from the :meth:`~io.IOBase." -"readlines` method of file-like objects. The delta generated also consists " -"of newline-terminated strings, ready to be printed as-is via the :meth:`~io." -"IOBase.writelines` method of a file-like object." +"newlines. Such sequences can be obtained from " +"the :meth:`~io.IOBase.readlines` method of file-like objects. The delta " +"generated also consists of newline-terminated strings, ready to be printed " +"as-is via the :meth:`~io.IOBase.writelines` method of a file-like object." msgstr "" #: library/difflib.rst:690 @@ -820,6 +858,73 @@ msgid "" "This example shows how to use difflib to create a ``diff``-like utility." msgstr "" +#: library/difflib.rst:761 +msgid "" +"\"\"\" Command line interface to difflib.py providing diffs in four " +"formats:\n" +"\n" +"* ndiff: lists every line and highlights interline changes.\n" +"* context: highlights clusters of changes in a before/after format.\n" +"* unified: highlights clusters of changes in an inline format.\n" +"* html: generates side by side comparison with change highlights.\n" +"\n" +"\"\"\"\n" +"\n" +"import sys, os, difflib, argparse\n" +"from datetime import datetime, timezone\n" +"\n" +"def file_mtime(path):\n" +" t = datetime.fromtimestamp(os.stat(path).st_mtime,\n" +" timezone.utc)\n" +" return t.astimezone().isoformat()\n" +"\n" +"def main():\n" +"\n" +" parser = argparse.ArgumentParser()\n" +" parser.add_argument('-c', action='store_true', default=False,\n" +" help='Produce a context format diff (default)')\n" +" parser.add_argument('-u', action='store_true', default=False,\n" +" help='Produce a unified format diff')\n" +" parser.add_argument('-m', action='store_true', default=False,\n" +" help='Produce HTML side by side diff '\n" +" '(can use -c and -l in conjunction)')\n" +" parser.add_argument('-n', action='store_true', default=False,\n" +" help='Produce a ndiff format diff')\n" +" parser.add_argument('-l', '--lines', type=int, default=3,\n" +" help='Set number of context lines (default 3)')\n" +" parser.add_argument('fromfile')\n" +" parser.add_argument('tofile')\n" +" options = parser.parse_args()\n" +"\n" +" n = options.lines\n" +" fromfile = options.fromfile\n" +" tofile = options.tofile\n" +"\n" +" fromdate = file_mtime(fromfile)\n" +" todate = file_mtime(tofile)\n" +" with open(fromfile) as ff:\n" +" fromlines = ff.readlines()\n" +" with open(tofile) as tf:\n" +" tolines = tf.readlines()\n" +"\n" +" if options.u:\n" +" diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, " +"fromdate, todate, n=n)\n" +" elif options.n:\n" +" diff = difflib.ndiff(fromlines, tolines)\n" +" elif options.m:\n" +" diff = " +"difflib.HtmlDiff().make_file(fromlines,tolines,fromfile,tofile,context=options.c,numlines=n)\n" +" else:\n" +" diff = difflib.context_diff(fromlines, tolines, fromfile, tofile, " +"fromdate, todate, n=n)\n" +"\n" +" sys.stdout.writelines(diff)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +msgstr "" + #: library/difflib.rst:764 msgid "ndiff example" msgstr "" @@ -827,3 +932,120 @@ msgstr "" #: library/difflib.rst:766 msgid "This example shows how to use :func:`difflib.ndiff`." msgstr "" + +#: library/difflib.rst:768 +msgid "" +"\"\"\"ndiff [-q] file1 file2\n" +" or\n" +"ndiff (-r1 | -r2) < ndiff_output > file1_or_file2\n" +"\n" +"Print a human-friendly file difference report to stdout. Both inter-\n" +"and intra-line differences are noted. In the second form, recreate file1\n" +"(-r1) or file2 (-r2) on stdout, from an ndiff report on stdin.\n" +"\n" +"In the first form, if -q (\"quiet\") is not specified, the first two lines\n" +"of output are\n" +"\n" +"-: file1\n" +"+: file2\n" +"\n" +"Each remaining line begins with a two-letter code:\n" +"\n" +" \"- \" line unique to file1\n" +" \"+ \" line unique to file2\n" +" \" \" line common to both files\n" +" \"? \" line not present in either input file\n" +"\n" +"Lines beginning with \"? \" attempt to guide the eye to intraline\n" +"differences, and were not present in either input file. These lines can be\n" +"confusing if the source files contain tab characters.\n" +"\n" +"The first file can be recovered by retaining only lines that begin with\n" +"\" \" or \"- \", and deleting those 2-character prefixes; use ndiff with " +"-r1.\n" +"\n" +"The second file can be recovered similarly, but by retaining only \" \" " +"and\n" +"\"+ \" lines; use ndiff with -r2; or, on Unix, the second file can be\n" +"recovered by piping the output through\n" +"\n" +" sed -n '/^[+ ] /s/^..//p'\n" +"\"\"\"\n" +"\n" +"__version__ = 1, 7, 0\n" +"\n" +"import difflib, sys\n" +"\n" +"def fail(msg):\n" +" out = sys.stderr.write\n" +" out(msg + \"\\n\\n\")\n" +" out(__doc__)\n" +" return 0\n" +"\n" +"# open a file & return the file object; gripe and return 0 if it\n" +"# couldn't be opened\n" +"def fopen(fname):\n" +" try:\n" +" return open(fname)\n" +" except IOError as detail:\n" +" return fail(\"couldn't open \" + fname + \": \" + str(detail))\n" +"\n" +"# open two files & spray the diff to stdout; return false iff a problem\n" +"def fcompare(f1name, f2name):\n" +" f1 = fopen(f1name)\n" +" f2 = fopen(f2name)\n" +" if not f1 or not f2:\n" +" return 0\n" +"\n" +" a = f1.readlines(); f1.close()\n" +" b = f2.readlines(); f2.close()\n" +" for line in difflib.ndiff(a, b):\n" +" print(line, end=' ')\n" +"\n" +" return 1\n" +"\n" +"# crack args (sys.argv[1:] is normal) & compare;\n" +"# return false iff a problem\n" +"\n" +"def main(args):\n" +" import getopt\n" +" try:\n" +" opts, args = getopt.getopt(args, \"qr:\")\n" +" except getopt.error as detail:\n" +" return fail(str(detail))\n" +" noisy = 1\n" +" qseen = rseen = 0\n" +" for opt, val in opts:\n" +" if opt == \"-q\":\n" +" qseen = 1\n" +" noisy = 0\n" +" elif opt == \"-r\":\n" +" rseen = 1\n" +" whichfile = val\n" +" if qseen and rseen:\n" +" return fail(\"can't specify both -q and -r\")\n" +" if rseen:\n" +" if args:\n" +" return fail(\"no args allowed with -r option\")\n" +" if whichfile in (\"1\", \"2\"):\n" +" restore(whichfile)\n" +" return 1\n" +" return fail(\"-r value must be 1 or 2\")\n" +" if len(args) != 2:\n" +" return fail(\"need 2 filename args\")\n" +" f1name, f2name = args\n" +" if noisy:\n" +" print('-:', f1name)\n" +" print('+:', f2name)\n" +" return fcompare(f1name, f2name)\n" +"\n" +"# read ndiff output from stdin, and print file1 (which=='1') or\n" +"# file2 (which=='2') to stdout\n" +"\n" +"def restore(which):\n" +" restored = difflib.restore(sys.stdin.readlines(), which)\n" +" sys.stdout.writelines(restored)\n" +"\n" +"if __name__ == '__main__':\n" +" main(sys.argv[1:])\n" +msgstr "" diff --git a/library/dis.po b/library/dis.po index 795f2b72..f593f4ab 100644 --- a/library/dis.po +++ b/library/dis.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/dis.rst:2 -msgid ":mod:`dis` --- Disassembler for Python bytecode" +msgid ":mod:`!dis` --- Disassembler for Python bytecode" msgstr "" #: library/dis.rst:7 @@ -56,17 +57,17 @@ msgstr "" msgid "" "Some instructions are accompanied by one or more inline cache entries, which " "take the form of :opcode:`CACHE` instructions. These instructions are hidden " -"by default, but can be shown by passing ``show_caches=True`` to any :mod:" -"`dis` utility. Furthermore, the interpreter now adapts the bytecode to " -"specialize it for different runtime conditions. The adaptive bytecode can be " -"shown by passing ``adaptive=True``." +"by default, but can be shown by passing ``show_caches=True`` to " +"any :mod:`dis` utility. Furthermore, the interpreter now adapts the bytecode " +"to specialize it for different runtime conditions. The adaptive bytecode can " +"be shown by passing ``adaptive=True``." msgstr "" #: library/dis.rst:45 msgid "" "The argument of a jump is the offset of the target instruction relative to " -"the instruction that appears immediately after the jump instruction's :" -"opcode:`CACHE` entries." +"the instruction that appears immediately after the jump " +"instruction's :opcode:`CACHE` entries." msgstr "" #: library/dis.rst:50 @@ -80,12 +81,29 @@ msgstr "" msgid "Example: Given the function :func:`!myfunc`::" msgstr "" +#: library/dis.rst:56 +msgid "" +"def myfunc(alist):\n" +" return len(alist)" +msgstr "" + #: library/dis.rst:59 msgid "" "the following command can be used to display the disassembly of :func:`!" "myfunc`:" msgstr "" +#: library/dis.rst:62 +msgid "" +">>> dis.dis(myfunc)\n" +" 2 0 RESUME 0\n" +"\n" +" 3 2 LOAD_GLOBAL 1 (NULL + len)\n" +" 12 LOAD_FAST 0 (alist)\n" +" 14 CALL 1\n" +" 22 RETURN_VALUE" +msgstr "" + #: library/dis.rst:72 msgid "(The \"2\" is a line number)." msgstr "" @@ -98,6 +116,10 @@ msgstr "" msgid "The :mod:`dis` module can be invoked as a script from the command line:" msgstr "" +#: library/dis.rst:81 +msgid "python -m dis [-h] [infile]" +msgstr "" + #: library/dis.rst:85 msgid "The following options are accepted:" msgstr "" @@ -119,9 +141,9 @@ msgstr "" #: library/dis.rst:101 msgid "" -"The bytecode analysis API allows pieces of Python code to be wrapped in a :" -"class:`Bytecode` object that provides easy access to details of the compiled " -"code." +"The bytecode analysis API allows pieces of Python code to be wrapped in " +"a :class:`Bytecode` object that provides easy access to details of the " +"compiled code." msgstr "" #: library/dis.rst:108 @@ -181,8 +203,8 @@ msgstr "" #: library/dis.rst:146 msgid "" -"Return a formatted view of the bytecode operations (the same as printed by :" -"func:`dis.dis`, but returned as a multi-line string)." +"Return a formatted view of the bytecode operations (the same as printed " +"by :func:`dis.dis`, but returned as a multi-line string)." msgstr "" #: library/dis.rst:151 @@ -203,6 +225,19 @@ msgstr "" msgid "Example:" msgstr "" +#: library/dis.rst:162 +msgid "" +">>> bytecode = dis.Bytecode(myfunc)\n" +">>> for instr in bytecode:\n" +"... print(instr.opname)\n" +"...\n" +"RESUME\n" +"LOAD_GLOBAL\n" +"LOAD_FAST\n" +"CALL\n" +"RETURN_VALUE" +msgstr "" + #: library/dis.rst:176 msgid "Analysis functions" msgstr "" @@ -356,10 +391,10 @@ msgstr "" #: library/dis.rst:319 msgid "" -"This generator function uses the :meth:`~codeobject.co_lines` method of the :" -"ref:`code object ` *code* to find the offsets which are starts " -"of lines in the source code. They are generated as ``(offset, lineno)`` " -"pairs." +"This generator function uses the :meth:`~codeobject.co_lines` method of " +"the :ref:`code object ` *code* to find the offsets which are " +"starts of lines in the source code. They are generated as ``(offset, " +"lineno)`` pairs." msgstr "" #: library/dis.rst:324 @@ -368,8 +403,8 @@ msgstr "" #: library/dis.rst:327 msgid "" -"The :pep:`626` :meth:`~codeobject.co_lines` method is used instead of the :" -"attr:`~codeobject.co_firstlineno` and :attr:`~codeobject.co_lnotab` " +"The :pep:`626` :meth:`~codeobject.co_lines` method is used instead of " +"the :attr:`~codeobject.co_firstlineno` and :attr:`~codeobject.co_lnotab` " "attributes of the :ref:`code object `." msgstr "" @@ -486,6 +521,10 @@ msgstr "" msgid "Removes the top-of-stack item::" msgstr "" +#: library/dis.rst:451 +msgid "STACK.pop()" +msgstr "" + #: library/dis.rst:456 msgid "" "Removes the top two values from the stack. Equivalent to ``POP_TOP``; " @@ -502,10 +541,20 @@ msgid "" "original location::" msgstr "" +#: library/dis.rst:476 +msgid "" +"assert i > 0\n" +"STACK.append(STACK[-i])" +msgstr "" + #: library/dis.rst:484 msgid "Swap the top of the stack with the i-th element::" msgstr "" +#: library/dis.rst:486 +msgid "STACK[-i], STACK[-1] = STACK[-1], STACK[-i]" +msgstr "" + #: library/dis.rst:493 msgid "" "Rather than being an actual instruction, this opcode is used to mark extra " @@ -584,12 +633,58 @@ msgid "" "*op*)::" msgstr "" +#: library/dis.rst:558 +msgid "" +"rhs = STACK.pop()\n" +"lhs = STACK.pop()\n" +"STACK.append(lhs op rhs)" +msgstr "" + #: library/dis.rst:576 library/dis.rst:594 library/dis.rst:694 -#: library/dis.rst:714 library/dis.rst:945 library/dis.rst:1057 -#: library/dis.rst:1069 +#: library/dis.rst:714 library/dis.rst:946 library/dis.rst:1062 +#: library/dis.rst:1074 msgid "Implements::" msgstr "" +#: library/dis.rst:569 +msgid "" +"key = STACK.pop()\n" +"container = STACK.pop()\n" +"STACK.append(container[key])" +msgstr "" + +#: library/dis.rst:578 +msgid "" +"key = STACK.pop()\n" +"container = STACK.pop()\n" +"value = STACK.pop()\n" +"container[key] = value" +msgstr "" + +#: library/dis.rst:588 +msgid "" +"key = STACK.pop()\n" +"container = STACK.pop()\n" +"del container[key]" +msgstr "" + +#: library/dis.rst:596 +msgid "" +"end = STACK.pop()\n" +"start = STACK.pop()\n" +"container = STACK.pop()\n" +"STACK.append(container[start:end])" +msgstr "" + +#: library/dis.rst:608 +msgid "" +"end = STACK.pop()\n" +"start = STACK.pop()\n" +"container = STACK.pop()\n" +"values = STACK.pop()\n" +"container[start:end] = value" +msgstr "" + #: library/dis.rst:617 msgid "**Coroutine opcodes**" msgstr "" @@ -649,10 +744,10 @@ msgstr "" #: library/dis.rst:671 msgid "" -"Handles an exception raised during a :meth:`~generator.throw` or :meth:" -"`~generator.close` call through the current frame. If ``STACK[-1]`` is an " -"instance of :exc:`StopIteration`, pop three values from the stack and push " -"its ``value`` member. Otherwise, re-raise ``STACK[-1]``." +"Handles an exception raised during a :meth:`~generator.throw` " +"or :meth:`~generator.close` call through the current frame. If " +"``STACK[-1]`` is an instance of :exc:`StopIteration`, pop three values from " +"the stack and push its ``value`` member. Otherwise, re-raise ``STACK[-1]``." msgstr "" #: library/dis.rst:681 @@ -661,18 +756,41 @@ msgid "" "``__aexit__`` and result of ``__aenter__()`` to the stack::" msgstr "" +#: library/dis.rst:684 +msgid "STACK.extend((__aexit__, __aenter__())" +msgstr "" + #: library/dis.rst:690 msgid "**Miscellaneous opcodes**" msgstr "" +#: library/dis.rst:696 +msgid "" +"item = STACK.pop()\n" +"set.add(STACK[-i], item)" +msgstr "" + #: library/dis.rst:699 msgid "Used to implement set comprehensions." msgstr "" +#: library/dis.rst:706 +msgid "" +"item = STACK.pop()\n" +"list.append(STACK[-i], item)" +msgstr "" + #: library/dis.rst:709 msgid "Used to implement list comprehensions." msgstr "" +#: library/dis.rst:716 +msgid "" +"value = STACK.pop()\n" +"key = STACK.pop()\n" +"dict.__setitem__(STACK[-i], key, value)" +msgstr "" + #: library/dis.rst:720 msgid "Used to implement dict comprehensions." msgstr "" @@ -685,10 +803,10 @@ msgstr "" #: library/dis.rst:727 msgid "" -"For all of the :opcode:`SET_ADD`, :opcode:`LIST_APPEND` and :opcode:" -"`MAP_ADD` instructions, while the added value or key/value pair is popped " -"off, the container object remains on the stack so that it is available for " -"further iterations of the loop." +"For all of the :opcode:`SET_ADD`, :opcode:`LIST_APPEND` " +"and :opcode:`MAP_ADD` instructions, while the added value or key/value pair " +"is popped off, the container object remains on the stack so that it is " +"available for further iterations of the loop." msgstr "" #: library/dis.rst:735 @@ -729,8 +847,8 @@ msgstr "" #: library/dis.rst:775 msgid "" "Re-raises the exception currently on top of the stack. If oparg is non-zero, " -"pops an additional value from the stack which is used to set :attr:`~frame." -"f_lasti` of the current frame." +"pops an additional value from the stack which is used to " +"set :attr:`~frame.f_lasti` of the current frame." msgstr "" #: library/dis.rst:786 @@ -791,16 +909,18 @@ msgstr "" msgid "" "This opcode performs several operations before a with block starts. First, " "it loads :meth:`~object.__exit__` from the context manager and pushes it " -"onto the stack for later use by :opcode:`WITH_EXCEPT_START`. Then, :meth:" -"`~object.__enter__` is called. Finally, the result of calling the " -"``__enter__()`` method is pushed onto the stack." +"onto the stack for later use by :opcode:`WITH_EXCEPT_START`. " +"Then, :meth:`~object.__enter__` is called. Finally, the result of calling " +"the ``__enter__()`` method is pushed onto the stack." msgstr "" #: library/dis.rst:853 -msgid "Perform ``STACK.append(len(STACK[-1]))``." +msgid "" +"Perform ``STACK.append(len(STACK[-1]))``. Used in :keyword:`match` " +"statements where comparison with structure of pattern is needed." msgstr "" -#: library/dis.rst:860 +#: library/dis.rst:861 msgid "" "If ``STACK[-1]`` is an instance of :class:`collections.abc.Mapping` (or, " "more technically: if it has the :c:macro:`Py_TPFLAGS_MAPPING` flag set in " @@ -808,7 +928,7 @@ msgid "" "Otherwise, push ``False``." msgstr "" -#: library/dis.rst:870 +#: library/dis.rst:871 msgid "" "If ``STACK[-1]`` is an instance of :class:`collections.abc.Sequence` and is " "*not* an instance of :class:`str`/:class:`bytes`/:class:`bytearray` (or, " @@ -817,40 +937,48 @@ msgid "" "Otherwise, push ``False``." msgstr "" -#: library/dis.rst:880 +#: library/dis.rst:881 msgid "" "``STACK[-1]`` is a tuple of mapping keys, and ``STACK[-2]`` is the match " -"subject. If ``STACK[-2]`` contains all of the keys in ``STACK[-1]``, push a :" -"class:`tuple` containing the corresponding values. Otherwise, push ``None``." +"subject. If ``STACK[-2]`` contains all of the keys in ``STACK[-1]``, push " +"a :class:`tuple` containing the corresponding values. Otherwise, push " +"``None``." msgstr "" -#: library/dis.rst:1513 +#: library/dis.rst:1521 msgid "" "Previously, this instruction also pushed a boolean value indicating success " "(``True``) or failure (``False``)." msgstr "" -#: library/dis.rst:893 +#: library/dis.rst:894 msgid "" "Implements ``name = STACK.pop()``. *namei* is the index of *name* in the " "attribute :attr:`~codeobject.co_names` of the :ref:`code object `. The compiler tries to use :opcode:`STORE_FAST` or :opcode:" -"`STORE_GLOBAL` if possible." +"objects>`. The compiler tries to use :opcode:`STORE_FAST` " +"or :opcode:`STORE_GLOBAL` if possible." msgstr "" -#: library/dis.rst:900 +#: library/dis.rst:901 msgid "" -"Implements ``del name``, where *namei* is the index into :attr:`~codeobject." -"co_names` attribute of the :ref:`code object `." +"Implements ``del name``, where *namei* is the index " +"into :attr:`~codeobject.co_names` attribute of the :ref:`code object `." msgstr "" -#: library/dis.rst:906 +#: library/dis.rst:907 msgid "" "Unpacks ``STACK[-1]`` into *count* individual values, which are put onto the " "stack right-to-left. Require there to be exactly *count* values.::" msgstr "" -#: library/dis.rst:915 +#: library/dis.rst:910 +msgid "" +"assert(len(STACK[-1]) == count)\n" +"STACK.extend(STACK.pop()[:-count-1:-1])" +msgstr "" + +#: library/dis.rst:916 msgid "" "Implements assignment with a starred target: Unpacks an iterable in " "``STACK[-1]`` into individual values, where the total number of values can " @@ -858,11 +986,11 @@ msgid "" "will be a list of all leftover items." msgstr "" -#: library/dis.rst:920 +#: library/dis.rst:921 msgid "The number of values before and after the list value is limited to 255." msgstr "" -#: library/dis.rst:922 +#: library/dis.rst:923 msgid "" "The number of values before the list value is encoded in the argument of the " "opcode. The number of values after the list if any is encoded using an " @@ -871,50 +999,63 @@ msgid "" "list value, the high byte of *counts* the number of values after it." msgstr "" -#: library/dis.rst:928 +#: library/dis.rst:929 msgid "" "The extracted values are put onto the stack right-to-left, i.e. ``a, *b, c = " "d`` will be stored after execution as ``STACK.extend((a, b, c))``." msgstr "" -#: library/dis.rst:940 +#: library/dis.rst:937 +msgid "" +"obj = STACK.pop()\n" +"value = STACK.pop()\n" +"obj.name = value" +msgstr "" + +#: library/dis.rst:941 msgid "" -"where *namei* is the index of name in :attr:`~codeobject.co_names` of the :" -"ref:`code object `." +"where *namei* is the index of name in :attr:`~codeobject.co_names` of " +"the :ref:`code object `." msgstr "" -#: library/dis.rst:950 +#: library/dis.rst:948 msgid "" -"where *namei* is the index of name into :attr:`~codeobject.co_names` of the :" -"ref:`code object `." +"obj = STACK.pop()\n" +"del obj.name" msgstr "" -#: library/dis.rst:956 +#: library/dis.rst:951 +msgid "" +"where *namei* is the index of name into :attr:`~codeobject.co_names` of " +"the :ref:`code object `." +msgstr "" + +#: library/dis.rst:957 msgid "Works as :opcode:`STORE_NAME`, but stores the name as a global." msgstr "" -#: library/dis.rst:961 +#: library/dis.rst:962 msgid "Works as :opcode:`DELETE_NAME`, but deletes a global name." msgstr "" -#: library/dis.rst:966 +#: library/dis.rst:967 msgid "Pushes ``co_consts[consti]`` onto the stack." msgstr "" -#: library/dis.rst:971 +#: library/dis.rst:972 msgid "" "Pushes the value associated with ``co_names[namei]`` onto the stack. The " "name is looked up within the locals, then the globals, then the builtins." msgstr "" -#: library/dis.rst:977 +#: library/dis.rst:978 msgid "" "Pushes a reference to the locals dictionary onto the stack. This is used to " -"prepare namespace dictionaries for :opcode:`LOAD_FROM_DICT_OR_DEREF` and :" -"opcode:`LOAD_FROM_DICT_OR_GLOBALS`." +"prepare namespace dictionaries for :opcode:`LOAD_FROM_DICT_OR_DEREF` " +"and :opcode:`LOAD_FROM_DICT_OR_GLOBALS`." msgstr "" -#: library/dis.rst:986 +#: library/dis.rst:987 msgid "" "Pops a mapping off the stack and looks up the value for ``co_names[namei]``. " "If the name is not found there, looks it up in the globals and then the " @@ -923,69 +1064,98 @@ msgid "" "bodies." msgstr "" -#: library/dis.rst:997 +#: library/dis.rst:998 msgid "" "Creates a tuple consuming *count* items from the stack, and pushes the " -"resulting tuple onto the stack.::" +"resulting tuple onto the stack::" msgstr "" -#: library/dis.rst:1007 -msgid "Works as :opcode:`BUILD_TUPLE`, but creates a list." +#: library/dis.rst:1001 +msgid "" +"if count == 0:\n" +" value = ()\n" +"else:\n" +" value = tuple(STACK[-count:])\n" +" STACK = STACK[:-count]\n" +"\n" +"STACK.append(value)" msgstr "" #: library/dis.rst:1012 -msgid "Works as :opcode:`BUILD_TUPLE`, but creates a set." +msgid "Works as :opcode:`BUILD_TUPLE`, but creates a list." msgstr "" #: library/dis.rst:1017 +msgid "Works as :opcode:`BUILD_TUPLE`, but creates a set." +msgstr "" + +#: library/dis.rst:1022 msgid "" "Pushes a new dictionary object onto the stack. Pops ``2 * count`` items so " "that the dictionary holds *count* entries: ``{..., STACK[-4]: STACK[-3], " "STACK[-2]: STACK[-1]}``." msgstr "" -#: library/dis.rst:1021 +#: library/dis.rst:1026 msgid "" "The dictionary is created from stack items instead of creating an empty " "dictionary pre-sized to hold *count* items." msgstr "" -#: library/dis.rst:1028 +#: library/dis.rst:1033 msgid "" "The version of :opcode:`BUILD_MAP` specialized for constant keys. Pops the " "top element on the stack which contains a tuple of keys, then starting from " "``STACK[-2]``, pops *count* values to form values in the built dictionary." msgstr "" -#: library/dis.rst:1037 +#: library/dis.rst:1042 msgid "" "Concatenates *count* strings from the stack and pushes the resulting string " "onto the stack." msgstr "" -#: library/dis.rst:1050 +#: library/dis.rst:1052 +msgid "" +"seq = STACK.pop()\n" +"list.extend(STACK[-i], seq)" +msgstr "" + +#: library/dis.rst:1055 msgid "Used to build lists." msgstr "" -#: library/dis.rst:1062 +#: library/dis.rst:1064 +msgid "" +"seq = STACK.pop()\n" +"set.update(STACK[-i], seq)" +msgstr "" + +#: library/dis.rst:1067 msgid "Used to build sets." msgstr "" -#: library/dis.rst:1074 +#: library/dis.rst:1076 +msgid "" +"map = STACK.pop()\n" +"dict.update(STACK[-i], map)" +msgstr "" + +#: library/dis.rst:1079 msgid "Used to build dicts." msgstr "" -#: library/dis.rst:1081 +#: library/dis.rst:1086 msgid "Like :opcode:`DICT_UPDATE` but raises an exception for duplicate keys." msgstr "" -#: library/dis.rst:1088 +#: library/dis.rst:1093 msgid "" "If the low bit of ``namei`` is not set, this replaces ``STACK[-1]`` with " "``getattr(STACK[-1], co_names[namei>>1])``." msgstr "" -#: library/dis.rst:1091 +#: library/dis.rst:1096 msgid "" "If the low bit of ``namei`` is set, this will attempt to load a method named " "``co_names[namei>>1]`` from the ``STACK[-1]`` object. ``STACK[-1]`` is " @@ -996,129 +1166,135 @@ msgid "" "the object returned by the attribute lookup are pushed." msgstr "" -#: library/dis.rst:1099 +#: library/dis.rst:1104 msgid "" "If the low bit of ``namei`` is set, then a ``NULL`` or ``self`` is pushed to " "the stack before the attribute or unbound method respectively." msgstr "" -#: library/dis.rst:1106 +#: library/dis.rst:1111 msgid "" "This opcode implements :func:`super`, both in its zero-argument and two-" "argument forms (e.g. ``super().method()``, ``super().attr`` and ``super(cls, " "self).method()``, ``super(cls, self).attr``)." msgstr "" -#: library/dis.rst:1110 +#: library/dis.rst:1115 msgid "" "It pops three values from the stack (from top of stack down): - ``self``: " "the first argument to the current method - ``cls``: the class within which " "the current method was defined - the global ``super``" msgstr "" -#: library/dis.rst:1115 +#: library/dis.rst:1120 msgid "" "With respect to its argument, it works similarly to :opcode:`LOAD_ATTR`, " "except that ``namei`` is shifted left by 2 bits instead of 1." msgstr "" -#: library/dis.rst:1118 +#: library/dis.rst:1123 msgid "" -"The low bit of ``namei`` signals to attempt a method load, as with :opcode:" -"`LOAD_ATTR`, which results in pushing ``None`` and the loaded method. When " -"it is unset a single value is pushed to the stack." +"The low bit of ``namei`` signals to attempt a method load, as " +"with :opcode:`LOAD_ATTR`, which results in pushing ``NULL`` and the loaded " +"method. When it is unset a single value is pushed to the stack." msgstr "" -#: library/dis.rst:1122 +#: library/dis.rst:1127 msgid "" "The second-low bit of ``namei``, if set, means that this was a two-argument " "call to :func:`super` (unset means zero-argument)." msgstr "" -#: library/dis.rst:1130 +#: library/dis.rst:1135 msgid "" "Performs a Boolean operation. The operation name can be found in " -"``cmp_op[opname]``." +"``cmp_op[opname >> 4]``." +msgstr "" + +#: library/dis.rst:1138 +msgid "" +"The cmp_op index is now stored in the four-highest bits of oparg instead of " +"the four-lowest bits of oparg." msgstr "" -#: library/dis.rst:1136 +#: library/dis.rst:1144 msgid "Performs ``is`` comparison, or ``is not`` if ``invert`` is 1." msgstr "" -#: library/dis.rst:1143 +#: library/dis.rst:1151 msgid "Performs ``in`` comparison, or ``not in`` if ``invert`` is 1." msgstr "" -#: library/dis.rst:1150 +#: library/dis.rst:1158 msgid "" "Imports the module ``co_names[namei]``. ``STACK[-1]`` and ``STACK[-2]`` are " -"popped and provide the *fromlist* and *level* arguments of :func:" -"`__import__`. The module object is pushed onto the stack. The current " -"namespace is not affected: for a proper import statement, a subsequent :" -"opcode:`STORE_FAST` instruction modifies the namespace." +"popped and provide the *fromlist* and *level* arguments " +"of :func:`__import__`. The module object is pushed onto the stack. The " +"current namespace is not affected: for a proper import statement, a " +"subsequent :opcode:`STORE_FAST` instruction modifies the namespace." msgstr "" -#: library/dis.rst:1158 +#: library/dis.rst:1166 msgid "" "Loads the attribute ``co_names[namei]`` from the module found in " "``STACK[-1]``. The resulting object is pushed onto the stack, to be " "subsequently stored by a :opcode:`STORE_FAST` instruction." msgstr "" -#: library/dis.rst:1165 +#: library/dis.rst:1173 msgid "Increments bytecode counter by *delta*." msgstr "" -#: library/dis.rst:1170 +#: library/dis.rst:1178 msgid "Decrements bytecode counter by *delta*. Checks for interrupts." msgstr "" -#: library/dis.rst:1177 +#: library/dis.rst:1185 msgid "Decrements bytecode counter by *delta*. Does not check for interrupts." msgstr "" -#: library/dis.rst:1184 +#: library/dis.rst:1192 msgid "" "If ``STACK[-1]`` is true, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" -#: library/dis.rst:1200 +#: library/dis.rst:1208 msgid "" "The oparg is now a relative delta rather than an absolute target. This " "opcode is a pseudo-instruction, replaced in final bytecode by the directed " "versions (forward/backward)." msgstr "" -#: library/dis.rst:1205 library/dis.rst:1232 +#: library/dis.rst:1213 library/dis.rst:1240 msgid "This is no longer a pseudo-instruction." msgstr "" -#: library/dis.rst:1197 +#: library/dis.rst:1205 msgid "" "If ``STACK[-1]`` is false, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" -#: library/dis.rst:1210 +#: library/dis.rst:1218 msgid "" "If ``STACK[-1]`` is not ``None``, increments the bytecode counter by " "*delta*. ``STACK[-1]`` is popped." msgstr "" -#: library/dis.rst:1227 +#: library/dis.rst:1235 msgid "" "This opcode is a pseudo-instruction, replaced in final bytecode by the " "directed versions (forward/backward)." msgstr "" -#: library/dis.rst:1224 +#: library/dis.rst:1232 msgid "" "If ``STACK[-1]`` is ``None``, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" -#: library/dis.rst:1237 +#: library/dis.rst:1245 msgid "" "``STACK[-1]`` is an :term:`iterator`. Call its :meth:`~iterator.__next__` " "method. If this yields a new value, push it on the stack (leaving the " @@ -1126,184 +1302,184 @@ msgid "" "code counter is incremented by *delta*." msgstr "" -#: library/dis.rst:1242 +#: library/dis.rst:1250 msgid "Up until 3.11 the iterator was popped when it was exhausted." msgstr "" -#: library/dis.rst:1247 +#: library/dis.rst:1255 msgid "Loads the global named ``co_names[namei>>1]`` onto the stack." msgstr "" -#: library/dis.rst:1249 +#: library/dis.rst:1257 msgid "" "If the low bit of ``namei`` is set, then a ``NULL`` is pushed to the stack " "before the global variable." msgstr "" -#: library/dis.rst:1255 +#: library/dis.rst:1263 msgid "" "Pushes a reference to the local ``co_varnames[var_num]`` onto the stack." msgstr "" -#: library/dis.rst:1257 +#: library/dis.rst:1265 msgid "" "This opcode is now only used in situations where the local variable is " "guaranteed to be initialized. It cannot raise :exc:`UnboundLocalError`." msgstr "" -#: library/dis.rst:1263 +#: library/dis.rst:1271 msgid "" "Pushes a reference to the local ``co_varnames[var_num]`` onto the stack, " "raising an :exc:`UnboundLocalError` if the local variable has not been " "initialized." msgstr "" -#: library/dis.rst:1271 +#: library/dis.rst:1279 msgid "" "Pushes a reference to the local ``co_varnames[var_num]`` onto the stack (or " "pushes ``NULL`` onto the stack if the local variable has not been " "initialized) and sets ``co_varnames[var_num]`` to ``NULL``." msgstr "" -#: library/dis.rst:1279 +#: library/dis.rst:1287 msgid "Stores ``STACK.pop()`` into the local ``co_varnames[var_num]``." msgstr "" -#: library/dis.rst:1284 +#: library/dis.rst:1292 msgid "Deletes local ``co_varnames[var_num]``." msgstr "" -#: library/dis.rst:1289 +#: library/dis.rst:1297 msgid "" "Creates a new cell in slot ``i``. If that slot is nonempty then that value " "is stored into the new cell." msgstr "" -#: library/dis.rst:1297 +#: library/dis.rst:1305 msgid "" "Pushes a reference to the cell contained in slot ``i`` of the \"fast " "locals\" storage. The name of the variable is ``co_fastlocalnames[i]``." msgstr "" -#: library/dis.rst:1300 +#: library/dis.rst:1308 msgid "" "Note that ``LOAD_CLOSURE`` is effectively an alias for ``LOAD_FAST``. It " "exists to keep bytecode a little more readable." msgstr "" -#: library/dis.rst:1303 +#: library/dis.rst:1311 msgid "``i`` is no longer offset by the length of ``co_varnames``." msgstr "" -#: library/dis.rst:1309 +#: library/dis.rst:1317 msgid "" "Loads the cell contained in slot ``i`` of the \"fast locals\" storage. " "Pushes a reference to the object the cell contains on the stack." msgstr "" -#: library/dis.rst:1334 library/dis.rst:1345 +#: library/dis.rst:1342 library/dis.rst:1353 msgid "" "``i`` is no longer offset by the length of :attr:`~codeobject.co_varnames`." msgstr "" -#: library/dis.rst:1318 +#: library/dis.rst:1326 msgid "" "Pops a mapping off the stack and looks up the name associated with slot " "``i`` of the \"fast locals\" storage in this mapping. If the name is not " -"found there, loads it from the cell contained in slot ``i``, similar to :" -"opcode:`LOAD_DEREF`. This is used for loading free variables in class bodies " -"(which previously used :opcode:`!LOAD_CLASSDEREF`) and in :ref:`annotation " -"scopes ` within class bodies." +"found there, loads it from the cell contained in slot ``i``, similar " +"to :opcode:`LOAD_DEREF`. This is used for loading free variables in class " +"bodies (which previously used :opcode:`!LOAD_CLASSDEREF`) and " +"in :ref:`annotation scopes ` within class bodies." msgstr "" -#: library/dis.rst:1331 +#: library/dis.rst:1339 msgid "" "Stores ``STACK.pop()`` into the cell contained in slot ``i`` of the \"fast " "locals\" storage." msgstr "" -#: library/dis.rst:1340 +#: library/dis.rst:1348 msgid "" "Empties the cell contained in slot ``i`` of the \"fast locals\" storage. " "Used by the :keyword:`del` statement." msgstr "" -#: library/dis.rst:1351 +#: library/dis.rst:1359 msgid "" "Copies the ``n`` free variables from the closure into the frame. Removes the " "need for special code on the caller's side when calling closures." msgstr "" -#: library/dis.rst:1360 +#: library/dis.rst:1368 msgid "" "Raises an exception using one of the 3 forms of the ``raise`` statement, " "depending on the value of *argc*:" msgstr "" -#: library/dis.rst:1363 +#: library/dis.rst:1371 msgid "0: ``raise`` (re-raise previous exception)" msgstr "" -#: library/dis.rst:1364 +#: library/dis.rst:1372 msgid "" "1: ``raise STACK[-1]`` (raise exception instance or type at ``STACK[-1]``)" msgstr "" -#: library/dis.rst:1365 +#: library/dis.rst:1373 msgid "" "2: ``raise STACK[-2] from STACK[-1]`` (raise exception instance or type at " "``STACK[-2]`` with ``__cause__`` set to ``STACK[-1]``)" msgstr "" -#: library/dis.rst:1371 +#: library/dis.rst:1379 msgid "" "Calls a callable object with the number of arguments specified by ``argc``, " "including the named arguments specified by the preceding :opcode:`KW_NAMES`, " "if any. On the stack are (in ascending order), either:" msgstr "" -#: library/dis.rst:1376 +#: library/dis.rst:1384 msgid "NULL" msgstr "" -#: library/dis.rst:1383 +#: library/dis.rst:1391 msgid "The callable" msgstr "" -#: library/dis.rst:1378 +#: library/dis.rst:1386 msgid "The positional arguments" msgstr "" -#: library/dis.rst:1386 +#: library/dis.rst:1394 msgid "The named arguments" msgstr "" -#: library/dis.rst:1381 +#: library/dis.rst:1389 msgid "or:" msgstr "" -#: library/dis.rst:1384 +#: library/dis.rst:1392 msgid "``self``" msgstr "" -#: library/dis.rst:1385 +#: library/dis.rst:1393 msgid "The remaining positional arguments" msgstr "" -#: library/dis.rst:1388 +#: library/dis.rst:1396 msgid "" "``argc`` is the total of the positional and named arguments, excluding " "``self`` when a ``NULL`` is not present." msgstr "" -#: library/dis.rst:1391 +#: library/dis.rst:1399 msgid "" "``CALL`` pops all arguments and the callable object off the stack, calls the " "callable object with those arguments, and pushes the return value returned " "by the callable object." msgstr "" -#: library/dis.rst:1400 +#: library/dis.rst:1408 msgid "" "Calls a callable object with variable set of positional and keyword " "arguments. If the lowest bit of *flags* is set, the top of the stack " @@ -1315,70 +1491,85 @@ msgid "" "arguments, and pushes the return value returned by the callable object." msgstr "" -#: library/dis.rst:1415 +#: library/dis.rst:1423 msgid "" "Pushes a ``NULL`` to the stack. Used in the call sequence to match the " "``NULL`` pushed by :opcode:`LOAD_METHOD` for non-method calls." msgstr "" -#: library/dis.rst:1424 +#: library/dis.rst:1432 msgid "" "Prefixes :opcode:`CALL`. Stores a reference to ``co_consts[consti]`` into an " "internal variable for use by :opcode:`CALL`. ``co_consts[consti]`` must be a " "tuple of strings." msgstr "" -#: library/dis.rst:1433 +#: library/dis.rst:1441 msgid "" "Pushes a new function object on the stack. From bottom to top, the consumed " "stack must consist of values if the argument carries a specified flag value" msgstr "" -#: library/dis.rst:1436 +#: library/dis.rst:1444 msgid "" "``0x01`` a tuple of default values for positional-only and positional-or-" "keyword parameters in positional order" msgstr "" -#: library/dis.rst:1438 +#: library/dis.rst:1446 msgid "``0x02`` a dictionary of keyword-only parameters' default values" msgstr "" -#: library/dis.rst:1439 +#: library/dis.rst:1447 msgid "``0x04`` a tuple of strings containing parameters' annotations" msgstr "" -#: library/dis.rst:1440 +#: library/dis.rst:1448 msgid "``0x08`` a tuple containing cells for free variables, making a closure" msgstr "" -#: library/dis.rst:1441 +#: library/dis.rst:1449 msgid "the code associated with the function (at ``STACK[-1]``)" msgstr "" -#: library/dis.rst:1443 +#: library/dis.rst:1451 msgid "Flag value ``0x04`` is a tuple of strings instead of dictionary" msgstr "" -#: library/dis.rst:1446 +#: library/dis.rst:1454 msgid "Qualified name at ``STACK[-1]`` was removed." msgstr "" -#: library/dis.rst:1454 +#: library/dis.rst:1462 msgid "" "Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2, " "implements::" msgstr "" -#: library/dis.rst:1460 +#: library/dis.rst:1464 +msgid "" +"end = STACK.pop()\n" +"start = STACK.pop()\n" +"STACK.append(slice(start, end))" +msgstr "" + +#: library/dis.rst:1468 msgid "if it is 3, implements::" msgstr "" -#: library/dis.rst:1467 +#: library/dis.rst:1470 +msgid "" +"step = STACK.pop()\n" +"end = STACK.pop()\n" +"start = STACK.pop()\n" +"STACK.append(slice(start, end, step))" +msgstr "" + +#: library/dis.rst:1475 msgid "See the :func:`slice` built-in function for more information." msgstr "" -#: library/dis.rst:1472 +#: library/dis.rst:1480 msgid "" "Prefixes any opcode which has an argument too big to fit into the default " "one byte. *ext* holds an additional byte which act as higher bits in the " @@ -1386,54 +1577,54 @@ msgid "" "allowed, forming an argument from two-byte to four-byte." msgstr "" -#: library/dis.rst:1480 +#: library/dis.rst:1488 msgid "" "Used for implementing formatted literal strings (f-strings). Pops an " "optional *fmt_spec* from the stack, then a required *value*. *flags* is " "interpreted as follows:" msgstr "" -#: library/dis.rst:1484 +#: library/dis.rst:1492 msgid "``(flags & 0x03) == 0x00``: *value* is formatted as-is." msgstr "" -#: library/dis.rst:1485 +#: library/dis.rst:1493 msgid "" "``(flags & 0x03) == 0x01``: call :func:`str` on *value* before formatting it." msgstr "" -#: library/dis.rst:1487 +#: library/dis.rst:1495 msgid "" "``(flags & 0x03) == 0x02``: call :func:`repr` on *value* before formatting " "it." msgstr "" -#: library/dis.rst:1489 +#: library/dis.rst:1497 msgid "" "``(flags & 0x03) == 0x03``: call :func:`ascii` on *value* before formatting " "it." msgstr "" -#: library/dis.rst:1491 +#: library/dis.rst:1499 msgid "" "``(flags & 0x04) == 0x04``: pop *fmt_spec* from the stack and use it, else " "use an empty *fmt_spec*." msgstr "" -#: library/dis.rst:1494 +#: library/dis.rst:1502 msgid "" "Formatting is performed using :c:func:`PyObject_Format`. The result is " "pushed on the stack." msgstr "" -#: library/dis.rst:1502 +#: library/dis.rst:1510 msgid "" "``STACK[-1]`` is a tuple of keyword attribute names, ``STACK[-2]`` is the " "class being matched against, and ``STACK[-3]`` is the match subject. " "*count* is the number of positional sub-patterns." msgstr "" -#: library/dis.rst:1506 +#: library/dis.rst:1514 msgid "" "Pop ``STACK[-1]``, ``STACK[-2]``, and ``STACK[-3]``. If ``STACK[-3]`` is an " "instance of ``STACK[-2]`` and has the positional and keyword attributes " @@ -1441,257 +1632,265 @@ msgid "" "Otherwise, push ``None``." msgstr "" -#: library/dis.rst:1520 +#: library/dis.rst:1528 msgid "A no-op. Performs internal tracing, debugging and optimization checks." msgstr "" -#: library/dis.rst:1522 +#: library/dis.rst:1530 msgid "The ``where`` operand marks where the ``RESUME`` occurs:" msgstr "" -#: library/dis.rst:1524 +#: library/dis.rst:1532 msgid "" "``0`` The start of a function, which is neither a generator, coroutine nor " "an async generator" msgstr "" -#: library/dis.rst:1526 +#: library/dis.rst:1534 msgid "``1`` After a ``yield`` expression" msgstr "" -#: library/dis.rst:1527 +#: library/dis.rst:1535 msgid "``2`` After a ``yield from`` expression" msgstr "" -#: library/dis.rst:1528 +#: library/dis.rst:1536 msgid "``3`` After an ``await`` expression" msgstr "" -#: library/dis.rst:1535 +#: library/dis.rst:1543 msgid "" "Create a generator, coroutine, or async generator from the current frame. " "Used as first opcode of in code object for the above mentioned callables. " "Clear the current frame and return the newly created generator." msgstr "" -#: library/dis.rst:1544 +#: library/dis.rst:1552 msgid "" "Equivalent to ``STACK[-1] = STACK[-2].send(STACK[-1])``. Used in ``yield " "from`` and ``await`` statements." msgstr "" -#: library/dis.rst:1547 +#: library/dis.rst:1555 msgid "" "If the call raises :exc:`StopIteration`, pop the top value from the stack, " "push the exception's ``value`` attribute, and increment the bytecode counter " "by *delta*." msgstr "" -#: library/dis.rst:1556 +#: library/dis.rst:1564 msgid "" "This is not really an opcode. It identifies the dividing line between " "opcodes in the range [0,255] which don't use their argument and those that " "do (``< HAVE_ARGUMENT`` and ``>= HAVE_ARGUMENT``, respectively)." msgstr "" -#: library/dis.rst:1560 +#: library/dis.rst:1568 msgid "" "If your application uses pseudo instructions, use the :data:`hasarg` " "collection instead." msgstr "" -#: library/dis.rst:1563 +#: library/dis.rst:1571 msgid "" "Now every instruction has an argument, but opcodes ``< HAVE_ARGUMENT`` " "ignore it. Before, only opcodes ``>= HAVE_ARGUMENT`` had an argument." msgstr "" -#: library/dis.rst:1567 +#: library/dis.rst:1575 msgid "" "Pseudo instructions were added to the :mod:`dis` module, and for them it is " "not true that comparison with ``HAVE_ARGUMENT`` indicates whether they use " "their arg." msgstr "" -#: library/dis.rst:1575 +#: library/dis.rst:1583 msgid "" "Calls an intrinsic function with one argument. Passes ``STACK[-1]`` as the " "argument and sets ``STACK[-1]`` to the result. Used to implement " "functionality that is not performance critical." msgstr "" -#: library/dis.rst:1633 +#: library/dis.rst:1641 msgid "The operand determines which intrinsic function is called:" msgstr "" -#: library/dis.rst:1636 +#: library/dis.rst:1644 msgid "Operand" msgstr "" -#: library/dis.rst:1636 +#: library/dis.rst:1644 msgid "Description" msgstr "" -#: library/dis.rst:1584 +#: library/dis.rst:1592 msgid "``INTRINSIC_1_INVALID``" msgstr "" -#: library/dis.rst:1638 +#: library/dis.rst:1646 msgid "Not valid" msgstr "" -#: library/dis.rst:1586 +#: library/dis.rst:1594 msgid "``INTRINSIC_PRINT``" msgstr "" -#: library/dis.rst:1586 +#: library/dis.rst:1594 msgid "Prints the argument to standard out. Used in the REPL." msgstr "" -#: library/dis.rst:1589 +#: library/dis.rst:1597 msgid "``INTRINSIC_IMPORT_STAR``" msgstr "" -#: library/dis.rst:1589 +#: library/dis.rst:1597 msgid "Performs ``import *`` for the named module." msgstr "" -#: library/dis.rst:1592 +#: library/dis.rst:1600 msgid "``INTRINSIC_STOPITERATION_ERROR``" msgstr "" -#: library/dis.rst:1592 +#: library/dis.rst:1600 msgid "Extracts the return value from a ``StopIteration`` exception." msgstr "" -#: library/dis.rst:1595 +#: library/dis.rst:1603 msgid "``INTRINSIC_ASYNC_GEN_WRAP``" msgstr "" -#: library/dis.rst:1595 -msgid "Wraps an aync generator value" +#: library/dis.rst:1603 +msgid "Wraps an async generator value" msgstr "" -#: library/dis.rst:1597 +#: library/dis.rst:1605 msgid "``INTRINSIC_UNARY_POSITIVE``" msgstr "" -#: library/dis.rst:1597 +#: library/dis.rst:1605 msgid "Performs the unary ``+`` operation" msgstr "" -#: library/dis.rst:1600 +#: library/dis.rst:1608 msgid "``INTRINSIC_LIST_TO_TUPLE``" msgstr "" -#: library/dis.rst:1600 +#: library/dis.rst:1608 msgid "Converts a list to a tuple" msgstr "" -#: library/dis.rst:1602 +#: library/dis.rst:1610 msgid "``INTRINSIC_TYPEVAR``" msgstr "" -#: library/dis.rst:1602 +#: library/dis.rst:1610 msgid "Creates a :class:`typing.TypeVar`" msgstr "" -#: library/dis.rst:1604 +#: library/dis.rst:1612 msgid "``INTRINSIC_PARAMSPEC``" msgstr "" -#: library/dis.rst:1604 +#: library/dis.rst:1612 msgid "Creates a :class:`typing.ParamSpec`" msgstr "" -#: library/dis.rst:1607 +#: library/dis.rst:1615 msgid "``INTRINSIC_TYPEVARTUPLE``" msgstr "" -#: library/dis.rst:1607 +#: library/dis.rst:1615 msgid "Creates a :class:`typing.TypeVarTuple`" msgstr "" -#: library/dis.rst:1610 +#: library/dis.rst:1618 msgid "``INTRINSIC_SUBSCRIPT_GENERIC``" msgstr "" -#: library/dis.rst:1610 +#: library/dis.rst:1618 msgid "Returns :class:`typing.Generic` subscripted with the argument" msgstr "" -#: library/dis.rst:1613 +#: library/dis.rst:1621 msgid "``INTRINSIC_TYPEALIAS``" msgstr "" -#: library/dis.rst:1613 +#: library/dis.rst:1621 msgid "" "Creates a :class:`typing.TypeAliasType`; used in the :keyword:`type` " "statement. The argument is a tuple of the type alias's name, type " "parameters, and value." msgstr "" -#: library/dis.rst:1625 +#: library/dis.rst:1633 msgid "" "Calls an intrinsic function with two arguments. Used to implement " "functionality that is not performance critical::" msgstr "" -#: library/dis.rst:1638 +#: library/dis.rst:1636 +msgid "" +"arg2 = STACK.pop()\n" +"arg1 = STACK.pop()\n" +"result = intrinsic2(arg1, arg2)\n" +"STACK.push(result)" +msgstr "" + +#: library/dis.rst:1646 msgid "``INTRINSIC_2_INVALID``" msgstr "" -#: library/dis.rst:1640 +#: library/dis.rst:1648 msgid "``INTRINSIC_PREP_RERAISE_STAR``" msgstr "" -#: library/dis.rst:1640 +#: library/dis.rst:1648 msgid "Calculates the :exc:`ExceptionGroup` to raise from a ``try-except*``." msgstr "" -#: library/dis.rst:1644 +#: library/dis.rst:1652 msgid "``INTRINSIC_TYPEVAR_WITH_BOUND``" msgstr "" -#: library/dis.rst:1644 +#: library/dis.rst:1652 msgid "Creates a :class:`typing.TypeVar` with a bound." msgstr "" -#: library/dis.rst:1647 +#: library/dis.rst:1655 msgid "``INTRINSIC_TYPEVAR_WITH_CONSTRAINTS``" msgstr "" -#: library/dis.rst:1647 +#: library/dis.rst:1655 msgid "Creates a :class:`typing.TypeVar` with constraints." msgstr "" -#: library/dis.rst:1651 +#: library/dis.rst:1659 msgid "``INTRINSIC_SET_FUNCTION_TYPE_PARAMS``" msgstr "" -#: library/dis.rst:1651 +#: library/dis.rst:1659 msgid "Sets the ``__type_params__`` attribute of a function." msgstr "" -#: library/dis.rst:1658 +#: library/dis.rst:1666 msgid "**Pseudo-instructions**" msgstr "" -#: library/dis.rst:1660 +#: library/dis.rst:1668 msgid "" "These opcodes do not appear in Python bytecode. They are used by the " "compiler but are replaced by real opcodes or removed before bytecode is " "generated." msgstr "" -#: library/dis.rst:1665 +#: library/dis.rst:1673 msgid "" "Set up an exception handler for the following code block. If an exception " "occurs, the value stack level is restored to its current state and control " "is transferred to the exception handler at ``target``." msgstr "" -#: library/dis.rst:1672 +#: library/dis.rst:1680 msgid "" "Like ``SETUP_FINALLY``, but in case of an exception also pushes the last " "instruction (``lasti``) to the stack so that ``RERAISE`` can restore it. If " @@ -1700,76 +1899,77 @@ msgid "" "exception handler at ``target``." msgstr "" -#: library/dis.rst:1681 +#: library/dis.rst:1689 msgid "" "Like ``SETUP_CLEANUP``, but in case of an exception one more item is popped " "from the stack before control is transferred to the exception handler at " "``target``." msgstr "" -#: library/dis.rst:1685 +#: library/dis.rst:1693 msgid "" "This variant is used in :keyword:`with` and :keyword:`async with` " -"constructs, which push the return value of the context manager's :meth:" -"`~object.__enter__` or :meth:`~object.__aenter__` to the stack." +"constructs, which push the return value of the context " +"manager's :meth:`~object.__enter__` or :meth:`~object.__aenter__` to the " +"stack." msgstr "" -#: library/dis.rst:1692 +#: library/dis.rst:1700 msgid "" "Marks the end of the code block associated with the last ``SETUP_FINALLY``, " "``SETUP_CLEANUP`` or ``SETUP_WITH``." msgstr "" -#: library/dis.rst:1698 +#: library/dis.rst:1706 msgid "" "Undirected relative jump instructions which are replaced by their directed " "(forward/backward) counterparts by the assembler." msgstr "" -#: library/dis.rst:1703 +#: library/dis.rst:1711 msgid "" "Optimized unbound method lookup. Emitted as a ``LOAD_ATTR`` opcode with a " "flag set in the arg." msgstr "" -#: library/dis.rst:1710 +#: library/dis.rst:1718 msgid "Opcode collections" msgstr "" -#: library/dis.rst:1712 +#: library/dis.rst:1720 msgid "" "These collections are provided for automatic introspection of bytecode " "instructions:" msgstr "" -#: library/dis.rst:1715 +#: library/dis.rst:1723 msgid "" "The collections now contain pseudo instructions and instrumented " "instructions as well. These are opcodes with values ``>= MIN_PSEUDO_OPCODE`` " "and ``>= MIN_INSTRUMENTED_OPCODE``." msgstr "" -#: library/dis.rst:1722 +#: library/dis.rst:1730 msgid "Sequence of operation names, indexable using the bytecode." msgstr "" -#: library/dis.rst:1727 +#: library/dis.rst:1735 msgid "Dictionary mapping operation names to bytecodes." msgstr "" -#: library/dis.rst:1732 +#: library/dis.rst:1740 msgid "Sequence of all compare operation names." msgstr "" -#: library/dis.rst:1737 +#: library/dis.rst:1745 msgid "Sequence of bytecodes that use their argument." msgstr "" -#: library/dis.rst:1744 +#: library/dis.rst:1752 msgid "Sequence of bytecodes that access a constant." msgstr "" -#: library/dis.rst:1749 +#: library/dis.rst:1757 msgid "" "Sequence of bytecodes that access a free variable. 'free' in this context " "refers to names in the current scope that are referenced by inner scopes or " @@ -1777,34 +1977,34 @@ msgid "" "include references to global or builtin scopes." msgstr "" -#: library/dis.rst:1757 +#: library/dis.rst:1765 msgid "Sequence of bytecodes that access an attribute by name." msgstr "" -#: library/dis.rst:1762 +#: library/dis.rst:1770 msgid "Sequence of bytecodes that have a relative jump target." msgstr "" -#: library/dis.rst:1767 +#: library/dis.rst:1775 msgid "Sequence of bytecodes that have an absolute jump target." msgstr "" -#: library/dis.rst:1772 +#: library/dis.rst:1780 msgid "Sequence of bytecodes that access a local variable." msgstr "" -#: library/dis.rst:1777 +#: library/dis.rst:1785 msgid "Sequence of bytecodes of Boolean operations." msgstr "" -#: library/dis.rst:1781 +#: library/dis.rst:1789 msgid "Sequence of bytecodes that set an exception handler." msgstr "" -#: library/dis.rst:1452 +#: library/dis.rst:1460 msgid "built-in function" msgstr "" -#: library/dis.rst:1452 +#: library/dis.rst:1460 msgid "slice" msgstr "" diff --git a/library/distribution.po b/library/distribution.po index bf137b51..0317e139 100644 --- a/library/distribution.po +++ b/library/distribution.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/distutils.po b/library/distutils.po new file mode 100644 index 00000000..096470db --- /dev/null +++ b/library/distutils.po @@ -0,0 +1,36 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2001-2025, Python Software Foundation +# This file is distributed under the same license as the Python package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Python 3.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: library/distutils.rst:2 +msgid ":mod:`!distutils` --- Building and installing Python modules" +msgstr "" + +#: library/distutils.rst:10 +msgid "" +"This module is no longer part of the Python standard library. It " +"was :ref:`removed in Python 3.12 ` after " +"being deprecated in Python 3.10. The removal was decided in :pep:`632`, " +"which has `migration advice `_." +msgstr "" + +#: library/distutils.rst:16 +msgid "" +"The last version of Python that provided the :mod:`!distutils` module was " +"`Python 3.11 `_." +msgstr "" diff --git a/library/doctest.po b/library/doctest.po index 9ca1b699..8e54cede 100644 --- a/library/doctest.po +++ b/library/doctest.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/doctest.rst:2 -msgid ":mod:`doctest` --- Test interactive Python examples" +msgid ":mod:`!doctest` --- Test interactive Python examples" msgstr "" #: library/doctest.rst:12 @@ -55,12 +56,76 @@ msgstr "" msgid "Here's a complete but small example module::" msgstr "" +#: library/doctest.rst:33 +msgid "" +"\"\"\"\n" +"This is the \"example\" module.\n" +"\n" +"The example module supplies one function, factorial(). For example,\n" +"\n" +">>> factorial(5)\n" +"120\n" +"\"\"\"\n" +"\n" +"def factorial(n):\n" +" \"\"\"Return the factorial of n, an exact integer >= 0.\n" +"\n" +" >>> [factorial(n) for n in range(6)]\n" +" [1, 1, 2, 6, 24, 120]\n" +" >>> factorial(30)\n" +" 265252859812191058636308480000000\n" +" >>> factorial(-1)\n" +" Traceback (most recent call last):\n" +" ...\n" +" ValueError: n must be >= 0\n" +"\n" +" Factorials of floats are OK, but the float must be an exact integer:\n" +" >>> factorial(30.1)\n" +" Traceback (most recent call last):\n" +" ...\n" +" ValueError: n must be exact integer\n" +" >>> factorial(30.0)\n" +" 265252859812191058636308480000000\n" +"\n" +" It must also not be ridiculously large:\n" +" >>> factorial(1e100)\n" +" Traceback (most recent call last):\n" +" ...\n" +" OverflowError: n too large\n" +" \"\"\"\n" +"\n" +" import math\n" +" if not n >= 0:\n" +" raise ValueError(\"n must be >= 0\")\n" +" if math.floor(n) != n:\n" +" raise ValueError(\"n must be exact integer\")\n" +" if n+1 == n: # catch a value like 1e300\n" +" raise OverflowError(\"n too large\")\n" +" result = 1\n" +" factor = 2\n" +" while factor <= n:\n" +" result *= factor\n" +" factor += 1\n" +" return result\n" +"\n" +"\n" +"if __name__ == \"__main__\":\n" +" import doctest\n" +" doctest.testmod()" +msgstr "" + #: library/doctest.rst:88 msgid "" "If you run :file:`example.py` directly from the command line, :mod:`doctest` " "works its magic:" msgstr "" +#: library/doctest.rst:91 +msgid "" +"$ python example.py\n" +"$" +msgstr "" + #: library/doctest.rst:96 msgid "" "There's no output! That's normal, and it means all the examples worked. " @@ -68,17 +133,50 @@ msgid "" "it's trying, and prints a summary at the end:" msgstr "" +#: library/doctest.rst:100 +msgid "" +"$ python example.py -v\n" +"Trying:\n" +" factorial(5)\n" +"Expecting:\n" +" 120\n" +"ok\n" +"Trying:\n" +" [factorial(n) for n in range(6)]\n" +"Expecting:\n" +" [1, 1, 2, 6, 24, 120]\n" +"ok" +msgstr "" + #: library/doctest.rst:114 msgid "And so on, eventually ending with:" msgstr "" +#: library/doctest.rst:116 +msgid "" +"Trying:\n" +" factorial(1e100)\n" +"Expecting:\n" +" Traceback (most recent call last):\n" +" ...\n" +" OverflowError: n too large\n" +"ok\n" +"2 items passed all tests:\n" +" 1 tests in __main__\n" +" 8 tests in __main__.factorial\n" +"9 tests in 2 items.\n" +"9 passed and 0 failed.\n" +"Test passed.\n" +"$" +msgstr "" + #: library/doctest.rst:133 msgid "" -"That's all you need to know to start making productive use of :mod:" -"`doctest`! Jump in. The following sections provide full details. Note that " -"there are many examples of doctests in the standard Python test suite and " -"libraries. Especially useful examples can be found in the standard test " -"file :file:`Lib/test/test_doctest/test_doctest.py`." +"That's all you need to know to start making productive use " +"of :mod:`doctest`! Jump in. The following sections provide full details. " +"Note that there are many examples of doctests in the standard Python test " +"suite and libraries. Especially useful examples can be found in the standard " +"test file :file:`Lib/test/test_doctest/test_doctest.py`." msgstr "" #: library/doctest.rst:143 @@ -91,6 +189,13 @@ msgid "" "continue to do it) is to end each module :mod:`!M` with::" msgstr "" +#: library/doctest.rst:148 +msgid "" +"if __name__ == \"__main__\":\n" +" import doctest\n" +" doctest.testmod()" +msgstr "" + #: library/doctest.rst:152 msgid ":mod:`!doctest` then examines docstrings in module :mod:`!M`." msgstr "" @@ -101,6 +206,10 @@ msgid "" "executed and verified::" msgstr "" +#: library/doctest.rst:157 +msgid "python M.py" +msgstr "" + #: library/doctest.rst:159 msgid "" "This won't display anything unless an example fails, in which case the " @@ -113,6 +222,10 @@ msgstr "" msgid "Run it with the ``-v`` switch instead::" msgstr "" +#: library/doctest.rst:166 +msgid "python M.py -v" +msgstr "" + #: library/doctest.rst:168 msgid "" "and a detailed report of all examples tried is printed to standard output, " @@ -134,11 +247,15 @@ msgid "" "standard library and pass the module name(s) on the command line::" msgstr "" +#: library/doctest.rst:180 +msgid "python -m doctest -v example.py" +msgstr "" + #: library/doctest.rst:182 msgid "" -"This will import :file:`example.py` as a standalone module and run :func:" -"`testmod` on it. Note that this may not work correctly if the file is part " -"of a package and imports other submodules from that package." +"This will import :file:`example.py` as a standalone module and " +"run :func:`testmod` on it. Note that this may not work correctly if the " +"file is part of a package and imports other submodules from that package." msgstr "" #: library/doctest.rst:186 @@ -157,6 +274,12 @@ msgid "" "text file. This can be done with the :func:`testfile` function::" msgstr "" +#: library/doctest.rst:197 +msgid "" +"import doctest\n" +"doctest.testfile(\"example.txt\")" +msgstr "" + #: library/doctest.rst:200 msgid "" "That short script executes and verifies any interactive Python examples " @@ -165,18 +288,48 @@ msgid "" "Python program! For example, perhaps :file:`example.txt` contains this:" msgstr "" +#: library/doctest.rst:205 +msgid "" +"The ``example`` module\n" +"======================\n" +"\n" +"Using ``factorial``\n" +"-------------------\n" +"\n" +"This is an example text file in reStructuredText format. First import\n" +"``factorial`` from the ``example`` module:\n" +"\n" +" >>> from example import factorial\n" +"\n" +"Now use it:\n" +"\n" +" >>> factorial(6)\n" +" 120" +msgstr "" + #: library/doctest.rst:223 msgid "" "Running ``doctest.testfile(\"example.txt\")`` then finds the error in this " "documentation::" msgstr "" +#: library/doctest.rst:226 +msgid "" +"File \"./example.txt\", line 14, in example.txt\n" +"Failed example:\n" +" factorial(6)\n" +"Expected:\n" +" 120\n" +"Got:\n" +" 720" +msgstr "" + #: library/doctest.rst:234 msgid "" "As with :func:`testmod`, :func:`testfile` won't display anything unless an " "example fails. If an example does fail, then the failing example(s) and the " -"cause(s) of the failure(s) are printed to stdout, using the same format as :" -"func:`testmod`." +"cause(s) of the failure(s) are printed to stdout, using the same format " +"as :func:`testmod`." msgstr "" #: library/doctest.rst:239 @@ -200,6 +353,10 @@ msgid "" "standard library and pass the file name(s) on the command line::" msgstr "" +#: library/doctest.rst:251 +msgid "python -m doctest -v example.txt" +msgstr "" + #: library/doctest.rst:253 msgid "" "Because the file name does not end with :file:`.py`, :mod:`doctest` infers " @@ -243,22 +400,35 @@ msgid "" "the docstring. Doctest looks for a module-level variable called ``__test__`` " "and uses it to locate other tests. If ``M.__test__`` exists, it must be a " "dict, and each entry maps a (string) name to a function object, class " -"object, or string. Function and class object docstrings found from ``M." -"__test__`` are searched, and strings are treated as if they were " -"docstrings. In output, a key ``K`` in ``M.__test__`` appears with name ``M." -"__test__.K``." +"object, or string. Function and class object docstrings found from " +"``M.__test__`` are searched, and strings are treated as if they were " +"docstrings. In output, a key ``K`` in ``M.__test__`` appears with name " +"``M.__test__.K``." msgstr "" #: library/doctest.rst:289 msgid "For example, place this block of code at the top of :file:`example.py`:" msgstr "" +#: library/doctest.rst:291 +msgid "" +"__test__ = {\n" +" 'numbers': \"\"\"\n" +">>> factorial(6)\n" +"720\n" +"\n" +">>> [factorial(n) for n in range(6)]\n" +"[1, 1, 2, 6, 24, 120]\n" +"\"\"\"\n" +"}" +msgstr "" + #: library/doctest.rst:303 msgid "" "The value of ``example.__test__[\"numbers\"]`` will be treated as a " "docstring and all the tests inside it will be run. It is important to note " -"that the value can be mapped to a function, class object, or module; if so, :" -"mod:`!doctest` searches them recursively for docstrings, which are then " +"that the value can be mapped to a function, class object, or module; if " +"so, :mod:`!doctest` searches them recursively for docstrings, which are then " "scanned for tests." msgstr "" @@ -279,6 +449,25 @@ msgid "" "shell." msgstr "" +#: library/doctest.rst:323 +msgid "" +">>> # comments are ignored\n" +">>> x = 12\n" +">>> x\n" +"12\n" +">>> if x == 13:\n" +"... print(\"yes\")\n" +"... else:\n" +"... print(\"no\")\n" +"... print(\"NO\")\n" +"... print(\"NO!!!\")\n" +"...\n" +"no\n" +"NO\n" +"NO!!!\n" +">>>" +msgstr "" + #: library/doctest.rst:343 msgid "" "Any expected output must immediately follow the final ``'>>> '`` or ``'... " @@ -303,14 +492,14 @@ msgid "" "All hard tab characters are expanded to spaces, using 8-column tab stops. " "Tabs in output generated by the tested code are not modified. Because any " "hard tabs in the sample output *are* expanded, this means that if the code " -"output includes hard tabs, the only way the doctest can pass is if the :" -"const:`NORMALIZE_WHITESPACE` option or :ref:`directive ` " -"is in effect. Alternatively, the test can be rewritten to capture the output " -"and compare it to an expected value as part of the test. This handling of " -"tabs in the source was arrived at through trial and error, and has proven to " -"be the least error prone way of handling them. It is possible to use a " -"different algorithm for handling tabs by writing a custom :class:" -"`DocTestParser` class." +"output includes hard tabs, the only way the doctest can pass is if " +"the :const:`NORMALIZE_WHITESPACE` option or :ref:`directive ` is in effect. Alternatively, the test can be rewritten to " +"capture the output and compare it to an expected value as part of the test. " +"This handling of tabs in the source was arrived at through trial and error, " +"and has proven to be the least error prone way of handling them. It is " +"possible to use a different algorithm for handling tabs by writing a " +"custom :class:`DocTestParser` class." msgstr "" #: library/doctest.rst:366 @@ -326,6 +515,15 @@ msgid "" "preserve your backslashes exactly as you type them::" msgstr "" +#: library/doctest.rst:373 +msgid "" +">>> def f(x):\n" +"... r'''Backslashes in a raw docstring: m\\n'''\n" +"...\n" +">>> print(f.__doc__)\n" +"Backslashes in a raw docstring: m\\n" +msgstr "" + #: library/doctest.rst:379 msgid "" "Otherwise, the backslash will be interpreted as part of the string. For " @@ -334,10 +532,27 @@ msgid "" "use a raw string)::" msgstr "" +#: library/doctest.rst:383 +msgid "" +">>> def f(x):\n" +"... '''Backslashes in a raw docstring: m\\\\n'''\n" +"...\n" +">>> print(f.__doc__)\n" +"Backslashes in a raw docstring: m\\n" +msgstr "" + #: library/doctest.rst:389 msgid "The starting column doesn't matter::" msgstr "" +#: library/doctest.rst:391 +msgid "" +">>> assert \"Easy!\"\n" +" >>> import math\n" +" >>> math.floor(1.9)\n" +" 1" +msgstr "" + #: library/doctest.rst:396 msgid "" "and as many leading whitespace characters are stripped from the expected " @@ -382,10 +597,18 @@ msgstr "" msgid "Simple example::" msgstr "" +#: library/doctest.rst:430 +msgid "" +">>> [1, 2, 3].remove(42)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ValueError: list.remove(x): x not in list" +msgstr "" + #: library/doctest.rst:435 msgid "" -"That doctest succeeds if :exc:`ValueError` is raised, with the ``list." -"remove(x): x not in list`` detail as shown." +"That doctest succeeds if :exc:`ValueError` is raised, with the " +"``list.remove(x): x not in list`` detail as shown." msgstr "" #: library/doctest.rst:438 @@ -395,6 +618,12 @@ msgid "" "first line of the example::" msgstr "" +#: library/doctest.rst:442 +msgid "" +"Traceback (most recent call last):\n" +"Traceback (innermost last):" +msgstr "" + #: library/doctest.rst:445 msgid "" "The traceback header is followed by an optional traceback stack, whose " @@ -410,6 +639,16 @@ msgid "" "multi-line detail::" msgstr "" +#: library/doctest.rst:454 +msgid "" +">>> raise ValueError('multi\\n line\\ndetail')\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ValueError: multi\n" +" line\n" +"detail" +msgstr "" + #: library/doctest.rst:461 msgid "" "The last three lines (starting with :exc:`ValueError`) are compared against " @@ -423,13 +662,23 @@ msgid "" "as::" msgstr "" +#: library/doctest.rst:467 +msgid "" +">>> raise ValueError('multi\\n line\\ndetail')\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: multi\n" +" line\n" +"detail" +msgstr "" + #: library/doctest.rst:474 msgid "" "Note that tracebacks are treated very specially. In particular, in the " -"rewritten example, the use of ``...`` is independent of doctest's :const:" -"`ELLIPSIS` option. The ellipsis in that example could be left out, or could " -"just as well be three (or three hundred) commas or digits, or an indented " -"transcript of a Monty Python skit." +"rewritten example, the use of ``...`` is independent of " +"doctest's :const:`ELLIPSIS` option. The ellipsis in that example could be " +"left out, or could just as well be three (or three hundred) commas or " +"digits, or an indented transcript of a Monty Python skit." msgstr "" #: library/doctest.rst:480 @@ -464,8 +713,8 @@ msgstr "" #: library/doctest.rst:499 msgid "" -"The interactive shell omits the traceback header line for some :exc:" -"`SyntaxError`\\ s. But doctest uses the traceback header line to " +"The interactive shell omits the traceback header line for " +"some :exc:`SyntaxError`\\ s. But doctest uses the traceback header line to " "distinguish exceptions from non-exceptions. So in the rare case where you " "need to test a :exc:`SyntaxError` that omits the traceback header, you will " "need to manually add the traceback header line to your test example." @@ -477,6 +726,15 @@ msgid "" "markers and tildes::" msgstr "" +#: library/doctest.rst:510 +msgid "" +">>> 1 + None\n" +" File \"\", line 1\n" +" 1 + None\n" +" ~~^~~~~~\n" +"TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" +msgstr "" + #: library/doctest.rst:516 msgid "" "Since the lines showing the position of the error come before the exception " @@ -485,6 +743,15 @@ msgid "" "location::" msgstr "" +#: library/doctest.rst:520 +msgid "" +">>> 1 + None\n" +" File \"\", line 1\n" +" 1 + None\n" +" ^~~~~~~~\n" +"TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" +msgstr "" + #: library/doctest.rst:531 msgid "Option Flags" msgstr "" @@ -492,11 +759,11 @@ msgstr "" #: library/doctest.rst:533 msgid "" "A number of option flags control various aspects of doctest's behavior. " -"Symbolic names for the flags are supplied as module constants, which can be :" -"ref:`bitwise ORed ` together and passed to various functions. The " -"names can also be used in :ref:`doctest directives `, " -"and may be passed to the doctest command line interface via the ``-o`` " -"option." +"Symbolic names for the flags are supplied as module constants, which can " +"be :ref:`bitwise ORed ` together and passed to various functions. " +"The names can also be used in :ref:`doctest directives `, and may be passed to the doctest command line interface via " +"the ``-o`` option." msgstr "" #: library/doctest.rst:539 @@ -513,12 +780,12 @@ msgstr "" msgid "" "By default, if an expected output block contains just ``1``, an actual " "output block containing just ``1`` or just ``True`` is considered to be a " -"match, and similarly for ``0`` versus ``False``. When :const:" -"`DONT_ACCEPT_TRUE_FOR_1` is specified, neither substitution is allowed. The " -"default behavior caters to that Python changed the return type of many " -"functions from integer to boolean; doctests expecting \"little integer\" " -"output still work in these cases. This option will probably go away, but " -"not for several years." +"match, and similarly for ``0`` versus ``False``. " +"When :const:`DONT_ACCEPT_TRUE_FOR_1` is specified, neither substitution is " +"allowed. The default behavior caters to that Python changed the return type " +"of many functions from integer to boolean; doctests expecting \"little " +"integer\" output still work in these cases. This option will probably go " +"away, but not for several years." msgstr "" #: library/doctest.rst:560 @@ -526,8 +793,9 @@ msgid "" "By default, if an expected output block contains a line containing only the " "string ````, then that line will match a blank line in the actual " "output. Because a genuinely blank line delimits the expected output, this " -"is the only way to communicate that a blank line is expected. When :const:" -"`DONT_ACCEPT_BLANKLINE` is specified, this substitution is not allowed." +"is the only way to communicate that a blank line is expected. " +"When :const:`DONT_ACCEPT_BLANKLINE` is specified, this substitution is not " +"allowed." msgstr "" #: library/doctest.rst:569 @@ -559,11 +827,26 @@ msgstr "" #: library/doctest.rst:593 msgid "" "For example, an example expecting ``ValueError: 42`` will pass if the actual " -"exception raised is ``ValueError: 3*14``, but will fail if, say, a :exc:" -"`TypeError` is raised instead. It will also ignore any fully qualified name " -"included before the exception class, which can vary between implementations " -"and versions of Python and the code/libraries in use. Hence, all three of " -"these variations will work with the flag specified:" +"exception raised is ``ValueError: 3*14``, but will fail if, say, " +"a :exc:`TypeError` is raised instead. It will also ignore any fully " +"qualified name included before the exception class, which can vary between " +"implementations and versions of Python and the code/libraries in use. Hence, " +"all three of these variations will work with the flag specified:" +msgstr "" + +#: library/doctest.rst:601 +msgid "" +">>> raise Exception('message')\n" +"Traceback (most recent call last):\n" +"Exception: message\n" +"\n" +">>> raise Exception('message')\n" +"Traceback (most recent call last):\n" +"builtins.Exception: message\n" +"\n" +">>> raise Exception('message')\n" +"Traceback (most recent call last):\n" +"__main__.Exception: message" msgstr "" #: library/doctest.rst:615 @@ -661,10 +944,14 @@ msgstr "" #: library/doctest.rst:698 msgid "" "Create a new option flag with a given name, and return the new flag's " -"integer value. :func:`register_optionflag` can be used when subclassing :" -"class:`OutputChecker` or :class:`DocTestRunner` to create new options that " -"are supported by your subclasses. :func:`register_optionflag` should always " -"be called using the following idiom::" +"integer value. :func:`register_optionflag` can be used when " +"subclassing :class:`OutputChecker` or :class:`DocTestRunner` to create new " +"options that are supported by your subclasses. :func:`register_optionflag` " +"should always be called using the following idiom::" +msgstr "" + +#: library/doctest.rst:704 +msgid "MY_FLAG = register_optionflag('MY_FLAG')" msgstr "" #: library/doctest.rst:714 @@ -695,6 +982,13 @@ msgstr "" msgid "For example, this test passes:" msgstr "" +#: library/doctest.rst:736 +msgid "" +">>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE\n" +"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n" +"10, 11, 12, 13, 14, 15, 16, 17, 18, 19]" +msgstr "" + #: library/doctest.rst:743 msgid "" "Without the directive it would fail, both because the actual output doesn't " @@ -703,18 +997,37 @@ msgid "" "a directive to do so:" msgstr "" +#: library/doctest.rst:748 +msgid "" +">>> print(list(range(20))) # doctest: +ELLIPSIS\n" +"[0, 1, ..., 18, 19]" +msgstr "" + #: library/doctest.rst:754 msgid "" "Multiple directives can be used on a single physical line, separated by " "commas:" msgstr "" +#: library/doctest.rst:757 +msgid "" +">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" +"[0, 1, ..., 18, 19]" +msgstr "" + #: library/doctest.rst:763 msgid "" "If multiple directive comments are used for a single example, then they are " "combined:" msgstr "" +#: library/doctest.rst:766 +msgid "" +">>> print(list(range(20))) # doctest: +ELLIPSIS\n" +"... # doctest: +NORMALIZE_WHITESPACE\n" +"[0, 1, ..., 18, 19]" +msgstr "" + #: library/doctest.rst:773 msgid "" "As the previous example shows, you can add ``...`` lines to your example " @@ -722,6 +1035,13 @@ msgid "" "for a directive to comfortably fit on the same line:" msgstr "" +#: library/doctest.rst:777 +msgid "" +">>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40)))\n" +"... # doctest: +ELLIPSIS\n" +"[0, ..., 4, 10, ..., 19, 30, ..., 39]" +msgstr "" + #: library/doctest.rst:784 msgid "" "Note that since all options are disabled by default, and directives apply " @@ -746,14 +1066,33 @@ msgid "" "test like ::" msgstr "" +#: library/doctest.rst:802 +msgid "" +">>> foo()\n" +"{\"spam\", \"eggs\"}" +msgstr "" + #: library/doctest.rst:805 msgid "is vulnerable! One workaround is to do ::" msgstr "" +#: library/doctest.rst:807 +msgid "" +">>> foo() == {\"spam\", \"eggs\"}\n" +"True" +msgstr "" + #: library/doctest.rst:810 msgid "instead. Another is to do ::" msgstr "" +#: library/doctest.rst:812 +msgid "" +">>> d = sorted(foo())\n" +">>> d\n" +"['eggs', 'spam']" +msgstr "" + #: library/doctest.rst:816 msgid "There are others, but you get the idea." msgstr "" @@ -762,11 +1101,26 @@ msgstr "" msgid "Another bad idea is to print things that embed an object address, like" msgstr "" +#: library/doctest.rst:820 +msgid "" +">>> id(1.0) # certain to fail some of the time \n" +"7948648\n" +">>> class C: pass\n" +">>> C() # the default repr() for instances embeds an address \n" +"" +msgstr "" + #: library/doctest.rst:828 msgid "" "The :const:`ELLIPSIS` directive gives a nice approach for the last example:" msgstr "" +#: library/doctest.rst:830 +msgid "" +">>> C() # doctest: +ELLIPSIS\n" +"" +msgstr "" + #: library/doctest.rst:836 msgid "" "Floating-point numbers are also subject to small output variations across " @@ -774,12 +1128,28 @@ msgid "" "formatting, and C libraries vary widely in quality here. ::" msgstr "" +#: library/doctest.rst:840 +msgid "" +">>> 1./7 # risky\n" +"0.14285714285714285\n" +">>> print(1./7) # safer\n" +"0.142857142857\n" +">>> print(round(1./7, 6)) # much safer\n" +"0.142857" +msgstr "" + #: library/doctest.rst:847 msgid "" "Numbers of the form ``I/2.**J`` are safe across all platforms, and I often " "contrive doctest examples to produce numbers of that form::" msgstr "" +#: library/doctest.rst:850 +msgid "" +">>> 3./4 # utterly safe\n" +"0.75" +msgstr "" + #: library/doctest.rst:853 msgid "" "Simple fractions are also easier for people to understand, and that makes " @@ -925,10 +1295,10 @@ msgstr "" #: library/doctest.rst:947 msgid "" -"Also test examples reachable from dict ``m.__test__``, if it exists. ``m." -"__test__`` maps names (strings) to functions, classes and strings; function " -"and class docstrings are searched for examples; strings are searched " -"directly, as if they were docstrings." +"Also test examples reachable from dict ``m.__test__``, if it exists. " +"``m.__test__`` maps names (strings) to functions, classes and strings; " +"function and class docstrings are searched for examples; strings are " +"searched directly, as if they were docstrings." msgstr "" #: library/doctest.rst:952 @@ -950,11 +1320,11 @@ msgstr "" msgid "" "Optional argument *exclude_empty* defaults to false. If true, objects for " "which no doctests are found are excluded from consideration. The default is " -"a backward compatibility hack, so that code still using :meth:`doctest." -"master.summarize ` in conjunction with :func:" -"`testmod` continues to get output for objects with no tests. The " -"*exclude_empty* argument to the newer :class:`DocTestFinder` constructor " -"defaults to true." +"a backward compatibility hack, so that code still " +"using :meth:`doctest.master.summarize ` in " +"conjunction with :func:`testmod` continues to get output for objects with no " +"tests. The *exclude_empty* argument to the newer :class:`DocTestFinder` " +"constructor defaults to true." msgstr "" #: library/doctest.rst:967 @@ -1016,6 +1386,17 @@ msgid "" "your test module::" msgstr "" +#: library/doctest.rst:1003 +msgid "" +"import unittest\n" +"import doctest\n" +"import my_module_with_doctests\n" +"\n" +"def load_tests(loader, tests, ignore):\n" +" tests.addTests(doctest.DocTestSuite(my_module_with_doctests))\n" +" return tests" +msgstr "" + #: library/doctest.rst:1011 msgid "" "There are two main functions for creating :class:`unittest.TestSuite` " @@ -1024,16 +1405,16 @@ msgstr "" #: library/doctest.rst:1017 msgid "" -"Convert doctest tests from one or more text files to a :class:`unittest." -"TestSuite`." +"Convert doctest tests from one or more text files to " +"a :class:`unittest.TestSuite`." msgstr "" #: library/doctest.rst:1020 msgid "" "The returned :class:`unittest.TestSuite` is to be run by the unittest " "framework and runs the interactive examples in each file. If an example in " -"any file fails, then the synthesized unit test fails, and a :exc:" -"`failureException` exception is raised showing the name of the file " +"any file fails, then the synthesized unit test fails, and " +"a :exc:`failureException` exception is raised showing the name of the file " "containing the test and a (sometimes approximate) line number." msgstr "" @@ -1105,9 +1486,10 @@ msgstr "" #: library/doctest.rst:1066 msgid "" "Optional argument *optionflags* specifies the default doctest options for " -"the tests, created by or-ing together individual option flags. See section :" -"ref:`doctest-options`. See function :func:`set_unittest_reportflags` below " -"for a better way to set reporting options." +"the tests, created by or-ing together individual option flags. See " +"section :ref:`doctest-options`. See " +"function :func:`set_unittest_reportflags` below for a better way to set " +"reporting options." msgstr "" #: library/doctest.rst:1078 @@ -1166,9 +1548,9 @@ msgstr "" #: library/doctest.rst:1117 msgid "" -"When doctests which have been converted to unit tests by :func:" -"`DocFileSuite` or :func:`DocTestSuite` fail, this exception is raised " -"showing the name of the file containing the test and a (sometimes " +"When doctests which have been converted to unit tests " +"by :func:`DocFileSuite` or :func:`DocTestSuite` fail, this exception is " +"raised showing the name of the file containing the test and a (sometimes " "approximate) line number." msgstr "" @@ -1190,15 +1572,15 @@ msgstr "" #: library/doctest.rst:1131 msgid "" -"So both ways of creating a :class:`unittest.TestSuite` run instances of :" -"class:`!DocTestCase`. This is important for a subtle reason: when you run :" -"mod:`doctest` functions yourself, you can control the :mod:`doctest` options " -"in use directly, by passing option flags to :mod:`doctest` functions. " -"However, if you're writing a :mod:`unittest` framework, :mod:`unittest` " -"ultimately controls when and how tests get run. The framework author " -"typically wants to control :mod:`doctest` reporting options (perhaps, e.g., " -"specified by command line options), but there's no way to pass options " -"through :mod:`unittest` to :mod:`doctest` test runners." +"So both ways of creating a :class:`unittest.TestSuite` run instances " +"of :class:`!DocTestCase`. This is important for a subtle reason: when you " +"run :mod:`doctest` functions yourself, you can control the :mod:`doctest` " +"options in use directly, by passing option flags to :mod:`doctest` " +"functions. However, if you're writing a :mod:`unittest` " +"framework, :mod:`unittest` ultimately controls when and how tests get run. " +"The framework author typically wants to control :mod:`doctest` reporting " +"options (perhaps, e.g., specified by command line options), but there's no " +"way to pass options through :mod:`unittest` to :mod:`doctest` test runners." msgstr "" #: library/doctest.rst:1141 @@ -1221,14 +1603,14 @@ msgstr "" msgid "" "This is a module-global setting, and affects all future doctests run by " "module :mod:`unittest`: the :meth:`!runTest` method of :class:`!" -"DocTestCase` looks at the option flags specified for the test case when the :" -"class:`!DocTestCase` instance was constructed. If no reporting flags were " -"specified (which is the typical and expected case), :mod:`!doctest`'s :mod:" -"`unittest` reporting flags are :ref:`bitwise ORed ` into the option " -"flags, and the option flags so augmented are passed to the :class:" -"`DocTestRunner` instance created to run the doctest. If any reporting flags " -"were specified when the :class:`!DocTestCase` instance was constructed, :mod:" -"`!doctest`'s :mod:`unittest` reporting flags are ignored." +"DocTestCase` looks at the option flags specified for the test case when " +"the :class:`!DocTestCase` instance was constructed. If no reporting flags " +"were specified (which is the typical and expected case), :mod:`!" +"doctest`'s :mod:`unittest` reporting flags are :ref:`bitwise ORed ` " +"into the option flags, and the option flags so augmented are passed to " +"the :class:`DocTestRunner` instance created to run the doctest. If any " +"reporting flags were specified when the :class:`!DocTestCase` instance was " +"constructed, :mod:`!doctest`'s :mod:`unittest` reporting flags are ignored." msgstr "" #: library/doctest.rst:1163 @@ -1275,9 +1657,9 @@ msgstr "" #: library/doctest.rst:1189 msgid "" -":class:`DocTestFinder`: Finds all docstrings in a given module, and uses a :" -"class:`DocTestParser` to create a :class:`DocTest` from every docstring that " -"contains interactive examples." +":class:`DocTestFinder`: Finds all docstrings in a given module, and uses " +"a :class:`DocTestParser` to create a :class:`DocTest` from every docstring " +"that contains interactive examples." msgstr "" #: library/doctest.rst:1193 @@ -1304,6 +1686,18 @@ msgid "" "following diagram::" msgstr "" +#: library/doctest.rst:1205 +msgid "" +" list of:\n" +"+------+ +---------+\n" +"|module| --DocTestFinder-> | DocTest | --DocTestRunner-> results\n" +"+------+ | ^ +---------+ | ^ (printed)\n" +" | | | Example | | |\n" +" v | | ... | v |\n" +" DocTestParser | Example | OutputChecker\n" +" +---------+" +msgstr "" + #: library/doctest.rst:1218 msgid "DocTest Objects" msgstr "" @@ -1331,8 +1725,8 @@ msgstr "" msgid "" "The namespace (aka globals) that the examples should be run in. This is a " "dictionary mapping names to values. Any changes to the namespace made by " -"the examples (such as binding new variables) will be reflected in :attr:" -"`globs` after the test is run." +"the examples (such as binding new variables) will be reflected " +"in :attr:`globs` after the test is run." msgstr "" #: library/doctest.rst:1247 @@ -1397,9 +1791,9 @@ msgstr "" msgid "" "The exception message generated by the example, if the example is expected " "to generate an exception; or ``None`` if it is not expected to generate an " -"exception. This exception message is compared against the return value of :" -"func:`traceback.format_exception_only`. :attr:`exc_msg` ends with a newline " -"unless it's ``None``. The constructor adds a newline if needed." +"exception. This exception message is compared against the return value " +"of :func:`traceback.format_exception_only`. :attr:`exc_msg` ends with a " +"newline unless it's ``None``. The constructor adds a newline if needed." msgstr "" #: library/doctest.rst:1314 @@ -1456,8 +1850,9 @@ msgstr "" #: library/doctest.rst:1356 msgid "" -"If the optional argument *exclude_empty* is false, then :meth:`DocTestFinder." -"find` will include tests for objects with empty docstrings." +"If the optional argument *exclude_empty* is false, " +"then :meth:`DocTestFinder.find` will include tests for objects with empty " +"docstrings." msgstr "" #: library/doctest.rst:1360 @@ -1539,15 +1934,15 @@ msgstr "" #: library/doctest.rst:1417 msgid "" -"Extract all doctest examples from the given string, and collect them into a :" -"class:`DocTest` object." +"Extract all doctest examples from the given string, and collect them into " +"a :class:`DocTest` object." msgstr "" #: library/doctest.rst:1420 msgid "" -"*globs*, *name*, *filename*, and *lineno* are attributes for the new :class:" -"`DocTest` object. See the documentation for :class:`DocTest` for more " -"information." +"*globs*, *name*, *filename*, and *lineno* are attributes for the " +"new :class:`DocTest` object. See the documentation for :class:`DocTest` for " +"more information." msgstr "" #: library/doctest.rst:1427 @@ -1572,16 +1967,16 @@ msgstr "" #: library/doctest.rst:1448 msgid "" -"A processing class used to execute and verify the interactive examples in a :" -"class:`DocTest`." +"A processing class used to execute and verify the interactive examples in " +"a :class:`DocTest`." msgstr "" #: library/doctest.rst:1451 msgid "" -"The comparison between expected outputs and actual outputs is done by an :" -"class:`OutputChecker`. This comparison may be customized with a number of " -"option flags; see section :ref:`doctest-options` for more information. If " -"the option flags are insufficient, then the comparison may also be " +"The comparison between expected outputs and actual outputs is done by " +"an :class:`OutputChecker`. This comparison may be customized with a number " +"of option flags; see section :ref:`doctest-options` for more information. " +"If the option flags are insufficient, then the comparison may also be " "customized by passing a subclass of :class:`OutputChecker` to the " "constructor." msgstr "" @@ -1590,11 +1985,12 @@ msgstr "" msgid "" "The test runner's display output can be controlled in two ways. First, an " "output function can be passed to :meth:`run`; this function will be called " -"with strings that should be displayed. It defaults to ``sys.stdout." -"write``. If capturing the output is not sufficient, then the display output " -"can be also customized by subclassing DocTestRunner, and overriding the " -"methods :meth:`report_start`, :meth:`report_success`, :meth:" -"`report_unexpected_exception`, and :meth:`report_failure`." +"with strings that should be displayed. It defaults to " +"``sys.stdout.write``. If capturing the output is not sufficient, then the " +"display output can be also customized by subclassing DocTestRunner, and " +"overriding the " +"methods :meth:`report_start`, :meth:`report_success`, :meth:`report_unexpected_exception`, " +"and :meth:`report_failure`." msgstr "" #: library/doctest.rst:1465 @@ -1606,11 +2002,12 @@ msgstr "" #: library/doctest.rst:1469 msgid "" -"The optional keyword argument *verbose* controls the :class:" -"`DocTestRunner`'s verbosity. If *verbose* is ``True``, then information is " -"printed about each example, as it is run. If *verbose* is ``False``, then " -"only failures are printed. If *verbose* is unspecified, or ``None``, then " -"verbose output is used iff the command-line switch ``-v`` is used." +"The optional keyword argument *verbose* controls " +"the :class:`DocTestRunner`'s verbosity. If *verbose* is ``True``, then " +"information is printed about each example, as it is run. If *verbose* is " +"``False``, then only failures are printed. If *verbose* is unspecified, or " +"``None``, then verbose output is used iff the command-line switch ``-v`` is " +"used." msgstr "" #: library/doctest.rst:1475 @@ -1634,8 +2031,8 @@ msgstr "" #: library/doctest.rst:1489 msgid "" "*example* is the example about to be processed. *test* is the test " -"*containing example*. *out* is the output function that was passed to :meth:" -"`DocTestRunner.run`." +"*containing example*. *out* is the output function that was passed " +"to :meth:`DocTestRunner.run`." msgstr "" #: library/doctest.rst:1496 @@ -1669,9 +2066,9 @@ msgstr "" #: library/doctest.rst:1522 msgid "" "*example* is the example about to be processed. *exc_info* is a tuple " -"containing information about the unexpected exception (as returned by :func:" -"`sys.exc_info`). *test* is the test containing *example*. *out* is the " -"output function that was passed to :meth:`DocTestRunner.run`." +"containing information about the unexpected exception (as returned " +"by :func:`sys.exc_info`). *test* is the test containing *example*. *out* is " +"the output function that was passed to :meth:`DocTestRunner.run`." msgstr "" #: library/doctest.rst:1530 @@ -1698,8 +2095,8 @@ msgstr "" #: library/doctest.rst:1542 msgid "" "The output of each example is checked using the :class:`DocTestRunner`'s " -"output checker, and the results are formatted by the :meth:`!DocTestRunner." -"report_\\*` methods." +"output checker, and the results are formatted by the :meth:`!" +"DocTestRunner.report_\\*` methods." msgstr "" #: library/doctest.rst:1549 @@ -1723,10 +2120,10 @@ msgstr "" #: library/doctest.rst:1564 msgid "" "A class used to check the whether the actual output from a doctest example " -"matches the expected output. :class:`OutputChecker` defines two methods: :" -"meth:`check_output`, which compares a given pair of outputs, and returns " -"``True`` if they match; and :meth:`output_difference`, which returns a " -"string describing the differences between two outputs." +"matches the expected output. :class:`OutputChecker` defines two " +"methods: :meth:`check_output`, which compares a given pair of outputs, and " +"returns ``True`` if they match; and :meth:`output_difference`, which returns " +"a string describing the differences between two outputs." msgstr "" #: library/doctest.rst:1571 @@ -1738,8 +2135,8 @@ msgid "" "Return ``True`` iff the actual output from an example (*got*) matches the " "expected output (*want*). These strings are always considered to match if " "they are identical; but depending on what option flags the test runner is " -"using, several non-exact match types are also possible. See section :ref:" -"`doctest-options` for more information about option flags." +"using, several non-exact match types are also possible. See " +"section :ref:`doctest-options` for more information about option flags." msgstr "" #: library/doctest.rst:1584 @@ -1773,22 +2170,68 @@ msgstr "" #: library/doctest.rst:1604 msgid "" -"The :mod:`unittest` cases generated by :func:`DocTestSuite` support the :" -"meth:`debug` method defined by :class:`unittest.TestCase`." +"The :mod:`unittest` cases generated by :func:`DocTestSuite` support " +"the :meth:`debug` method defined by :class:`unittest.TestCase`." msgstr "" #: library/doctest.rst:1607 msgid "" "You can add a call to :func:`pdb.set_trace` in a doctest example, and you'll " "drop into the Python debugger when that line is executed. Then you can " -"inspect current values of variables, and so on. For example, suppose :file:" -"`a.py` contains just this module docstring::" +"inspect current values of variables, and so on. For example, " +"suppose :file:`a.py` contains just this module docstring::" +msgstr "" + +#: library/doctest.rst:1612 +msgid "" +"\"\"\"\n" +">>> def f(x):\n" +"... g(x*2)\n" +">>> def g(x):\n" +"... print(x+3)\n" +"... import pdb; pdb.set_trace()\n" +">>> f(3)\n" +"9\n" +"\"\"\"" msgstr "" #: library/doctest.rst:1622 msgid "Then an interactive Python session may look like this::" msgstr "" +#: library/doctest.rst:1624 +msgid "" +">>> import a, doctest\n" +">>> doctest.testmod(a)\n" +"--Return--\n" +"> (3)g()->None\n" +"-> import pdb; pdb.set_trace()\n" +"(Pdb) list\n" +" 1 def g(x):\n" +" 2 print(x+3)\n" +" 3 -> import pdb; pdb.set_trace()\n" +"[EOF]\n" +"(Pdb) p x\n" +"6\n" +"(Pdb) step\n" +"--Return--\n" +"> (2)f()->None\n" +"-> g(x*2)\n" +"(Pdb) list\n" +" 1 def f(x):\n" +" 2 -> g(x*2)\n" +"[EOF]\n" +"(Pdb) p x\n" +"3\n" +"(Pdb) step\n" +"--Return--\n" +"> (1)?()->None\n" +"-> f(3)\n" +"(Pdb) cont\n" +"(0, 3)\n" +">>>" +msgstr "" + #: library/doctest.rst:1655 msgid "" "Functions that convert doctests to Python code, and possibly run the " @@ -1807,10 +2250,34 @@ msgid "" "generated script is returned as a string. For example, ::" msgstr "" +#: library/doctest.rst:1668 +msgid "" +"import doctest\n" +"print(doctest.script_from_examples(r\"\"\"\n" +" Set x and y to 1 and 2.\n" +" >>> x, y = 1, 2\n" +"\n" +" Print their sum:\n" +" >>> print(x+y)\n" +" 3\n" +"\"\"\"))" +msgstr "" + #: library/doctest.rst:1678 msgid "displays::" msgstr "" +#: library/doctest.rst:1680 +msgid "" +"# Set x and y to 1 and 2.\n" +"x, y = 1, 2\n" +"#\n" +"# Print their sum:\n" +"print(x+y)\n" +"# Expected:\n" +"## 3" +msgstr "" + #: library/doctest.rst:1688 msgid "" "This function is used internally by other functions (see below), but can " @@ -1832,6 +2299,12 @@ msgid "" "module :file:`a.py` contains a top-level function :func:`!f`, then ::" msgstr "" +#: library/doctest.rst:1704 +msgid "" +"import a, doctest\n" +"print(doctest.testsource(a, \"a.f\"))" +msgstr "" + #: library/doctest.rst:1707 msgid "" "prints a script version of function :func:`!f`'s docstring, with doctests " @@ -1844,10 +2317,10 @@ msgstr "" #: library/doctest.rst:1715 msgid "" -"The *module* and *name* arguments are the same as for function :func:" -"`testsource` above. The synthesized Python script for the named object's " -"docstring is written to a temporary file, and then that file is run under " -"the control of the Python debugger, :mod:`pdb`." +"The *module* and *name* arguments are the same as for " +"function :func:`testsource` above. The synthesized Python script for the " +"named object's docstring is written to a temporary file, and then that file " +"is run under the control of the Python debugger, :mod:`pdb`." msgstr "" #: library/doctest.rst:1720 @@ -1861,8 +2334,8 @@ msgid "" "Optional argument *pm* controls whether post-mortem debugging is used. If " "*pm* has a true value, the script file is run directly, and the debugger " "gets involved only if the script terminates via raising an unhandled " -"exception. If it does, then post-mortem debugging is invoked, via :func:" -"`pdb.post_mortem`, passing the traceback object from the unhandled " +"exception. If it does, then post-mortem debugging is invoked, " +"via :func:`pdb.post_mortem`, passing the traceback object from the unhandled " "exception. If *pm* is not specified, or is false, the script is run under " "the debugger from the start, via passing an appropriate :func:`exec` call " "to :func:`pdb.run`." @@ -1902,11 +2375,11 @@ msgstr "" #: library/doctest.rst:1754 msgid "" "A subclass of :class:`DocTestRunner` that raises an exception as soon as a " -"failure is encountered. If an unexpected exception occurs, an :exc:" -"`UnexpectedException` exception is raised, containing the test, the example, " -"and the original exception. If the output doesn't match, then a :exc:" -"`DocTestFailure` exception is raised, containing the test, the example, and " -"the actual output." +"failure is encountered. If an unexpected exception occurs, " +"an :exc:`UnexpectedException` exception is raised, containing the test, the " +"example, and the original exception. If the output doesn't match, then " +"a :exc:`DocTestFailure` exception is raised, containing the test, the " +"example, and the actual output." msgstr "" #: library/doctest.rst:1761 @@ -2060,6 +2533,24 @@ msgid "" "example of such a test runner::" msgstr "" +#: library/doctest.rst:1880 +msgid "" +"if __name__ == '__main__':\n" +" import doctest\n" +" flags = doctest.REPORT_NDIFF|doctest.FAIL_FAST\n" +" if len(sys.argv) > 1:\n" +" name = sys.argv[1]\n" +" if name in globals():\n" +" obj = globals()[name]\n" +" else:\n" +" obj = __test__[name]\n" +" doctest.run_docstring_examples(obj, globals(), name=name,\n" +" optionflags=flags)\n" +" else:\n" +" fail, total = doctest.testmod(optionflags=flags)\n" +" print(\"{} failures out of {} tests\".format(fail, total))" +msgstr "" + #: library/doctest.rst:1897 msgid "Footnotes" msgstr "" diff --git a/library/email.charset.po b/library/email.charset.po index ade83a13..82de0e14 100644 --- a/library/email.charset.po +++ b/library/email.charset.po @@ -8,16 +8,18 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2025-01-27 01:00+0200\n" "Last-Translator: Marios Giannopoulos \n" "Language-Team: PyGreece \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.charset.rst:2 -msgid ":mod:`email.charset`: Representing character sets" +#, fuzzy +msgid ":mod:`!email.charset`: Representing character sets" msgstr ":mod:`email.charset`: Αναπαράσταση συνόλων χαρακτήρων" #: library/email.charset.rst:7 @@ -44,8 +46,8 @@ msgid "" "This module provides a class :class:`Charset` for representing character " "sets and character set conversions in email messages, as well as a character " "set registry and several convenience methods for manipulating this registry. " -"Instances of :class:`Charset` are used in several other modules within the :" -"mod:`email` package." +"Instances of :class:`Charset` are used in several other modules within " +"the :mod:`email` package." msgstr "" "Αυτό το module παρέχει την κλάση :class:`Charset` για την αναπαράσταση των " "συνόλων χαρακτήρων και των μετατροπών τους σε μηνύματα email, καθώς και ένα " @@ -135,15 +137,15 @@ msgid "" msgstr "" "Εάν το σύνολο χαρακτήρων πρέπει να κωδικοποιηθεί πριν χρησιμοποιηθεί σε " "κεφαλίδα email, αυτό το χαρακτηριστικό θα οριστεί σε ``charset.QP`` (για " -"quoted-printable), ``charset.BASE64`` (για κωδικοποίηση base64), ή ``charset." -"SHORTEST`` για την πιο σύντομη κωδικοποίηση από QP ή BASE64. Διαφορετικά, θα " -"είναι ``None``." +"quoted-printable), ``charset.BASE64`` (για κωδικοποίηση base64), ή " +"``charset.SHORTEST`` για την πιο σύντομη κωδικοποίηση από QP ή BASE64. " +"Διαφορετικά, θα είναι ``None``." #: library/email.charset.rst:69 msgid "" "Same as *header_encoding*, but describes the encoding for the mail message's " -"body, which indeed may be different than the header encoding. ``charset." -"SHORTEST`` is not allowed for *body_encoding*." +"body, which indeed may be different than the header encoding. " +"``charset.SHORTEST`` is not allowed for *body_encoding*." msgstr "" "Ίδιο με το *header_encoding*, αλλά περιγράφει την κωδικοποίηση για το σώμα " "του μηνύματος email, το οποίο μπορεί να είναι διαφορετικό από την " @@ -204,8 +206,9 @@ msgstr "" "Αυτή είναι είτε η συμβολοσειρά ``quoted-printable`` ή ``base64``, ανάλογα με " "την κωδικοποίηση που χρησιμοποιείται, είτε είναι μια συνάρτηση, οπότε πρέπει " "να καλέσετε τη συνάρτηση με ένα μόνο όρισμα, το αντικείμενο Message που " -"κωδικοποιείται. Η συνάρτηση θα πρέπει στη συνέχεια να ορίσει την κεφαλίδα :" -"mailheader:`Content-Transfer-Encoding` η ίδια, σε ότι είναι κατάλληλο." +"κωδικοποιείται. Η συνάρτηση θα πρέπει στη συνέχεια να ορίσει την " +"κεφαλίδα :mailheader:`Content-Transfer-Encoding` η ίδια, σε ότι είναι " +"κατάλληλο." #: library/email.charset.rst:108 msgid "" @@ -294,16 +297,16 @@ msgid "" "This method allows you to compare two :class:`Charset` instances for " "equality." msgstr "" -"Αυτή η μέθοδος σας επιτρέπει να συγκρίνετε δύο στιγμιότυπα της κλάσης :class:" -"`Charset` για ισότητα." +"Αυτή η μέθοδος σας επιτρέπει να συγκρίνετε δύο στιγμιότυπα της " +"κλάσης :class:`Charset` για ισότητα." #: library/email.charset.rst:164 msgid "" "This method allows you to compare two :class:`Charset` instances for " "inequality." msgstr "" -"Αυτή η μέθοδος σας επιτρέπει να συγκρίνετε δύο στιγμιότυπα της κλάσης :class:" -"`Charset` για ανισότητα." +"Αυτή η μέθοδος σας επιτρέπει να συγκρίνετε δύο στιγμιότυπα της " +"κλάσης :class:`Charset` για ανισότητα." #: library/email.charset.rst:167 msgid "" @@ -364,8 +367,8 @@ msgstr "" "Τόσο το *input_charset* όσο και το *output_charset* πρέπει να έχουν " "καταχωρίσεις Unicode codec στη χαρτογράφηση χαρακτήρων προς codec του " "module· χρησιμοποιήστε την συνάρτηση :func:`add_codec` για να προσθέσετε " -"codecs που το module δεν γνωρίζει. Δείτε την τεκμηρίωση του module :mod:" -"`codecs` για περισσότερες πληροφορίες." +"codecs που το module δεν γνωρίζει. Δείτε την τεκμηρίωση του " +"module :mod:`codecs` για περισσότερες πληροφορίες." #: library/email.charset.rst:194 msgid "" @@ -403,8 +406,8 @@ msgstr "" #: library/email.charset.rst:211 msgid "" "*charset* is the canonical name of a character set. *codecname* is the name " -"of a Python codec, as appropriate for the second argument to the :class:" -"`str`'s :meth:`~str.encode` method." +"of a Python codec, as appropriate for the second argument to " +"the :class:`str`'s :meth:`~str.encode` method." msgstr "" "Το *charset* είναι το κανονικό όνομα ενός συνόλου χαρακτήρων. Το *codecname* " "είναι το όνομα ενός κωδικοποιητή Python, ως κατάλληλο για το δεύτερο όρισμα " diff --git a/library/email.compat32-message.po b/library/email.compat32-message.po index 3ad63734..3762ba87 100644 --- a/library/email.compat32-message.po +++ b/library/email.compat32-message.po @@ -8,55 +8,56 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.compat32-message.rst:4 msgid "" -":mod:`email.message.Message`: Representing an email message using the :data:" -"`~email.policy.compat32` API" +":mod:`email.message.Message`: Representing an email message using " +"the :data:`~email.policy.compat32` API" msgstr "" -#: library/email.compat32-message.rst:12 +#: library/email.compat32-message.rst:13 msgid "" -"The :class:`Message` class is very similar to the :class:`~email.message." -"EmailMessage` class, without the methods added by that class, and with the " -"default behavior of certain other methods being slightly different. We also " -"document here some methods that, while supported by the :class:`~email." -"message.EmailMessage` class, are not recommended unless you are dealing with " -"legacy code." +"The :class:`Message` class is very similar to " +"the :class:`~email.message.EmailMessage` class, without the methods added by " +"that class, and with the default behavior of certain other methods being " +"slightly different. We also document here some methods that, while " +"supported by the :class:`~email.message.EmailMessage` class, are not " +"recommended unless you are dealing with legacy code." msgstr "" -#: library/email.compat32-message.rst:19 +#: library/email.compat32-message.rst:20 msgid "The philosophy and structure of the two classes is otherwise the same." msgstr "" -#: library/email.compat32-message.rst:21 +#: library/email.compat32-message.rst:22 msgid "" -"This document describes the behavior under the default (for :class:" -"`Message`) policy :attr:`~email.policy.Compat32`. If you are going to use " -"another policy, you should be using the :class:`~email.message.EmailMessage` " -"class instead." +"This document describes the behavior under the default " +"(for :class:`Message`) policy :attr:`~email.policy.Compat32`. If you are " +"going to use another policy, you should be using " +"the :class:`~email.message.EmailMessage` class instead." msgstr "" -#: library/email.compat32-message.rst:25 +#: library/email.compat32-message.rst:26 msgid "" -"An email message consists of *headers* and a *payload*. Headers must be :" -"rfc:`5322` style names and values, where the field name and value are " +"An email message consists of *headers* and a *payload*. Headers must " +"be :rfc:`5322` style names and values, where the field name and value are " "separated by a colon. The colon is not part of either the field name or the " "field value. The payload may be a simple text message, or a binary object, " "or a structured sequence of sub-messages each with their own set of headers " "and their own payload. The latter type of payload is indicated by the " -"message having a MIME type such as :mimetype:`multipart/\\*` or :mimetype:" -"`message/rfc822`." +"message having a MIME type such as :mimetype:`multipart/\\*` " +"or :mimetype:`message/rfc822`." msgstr "" -#: library/email.compat32-message.rst:34 +#: library/email.compat32-message.rst:35 msgid "" "The conceptual model provided by a :class:`Message` object is that of an " "ordered dictionary of headers with additional methods for accessing both " @@ -66,7 +67,7 @@ msgid "" "methods must be used to access them." msgstr "" -#: library/email.compat32-message.rst:41 +#: library/email.compat32-message.rst:42 msgid "" "The :class:`Message` pseudo-dictionary is indexed by the header names, which " "must be ASCII values. The values of the dictionary are strings that are " @@ -76,29 +77,29 @@ msgid "" "matched case-insensitively. There may also be a single envelope header, " "also known as the *Unix-From* header or the ``From_`` header. The *payload* " "is either a string or bytes, in the case of simple message objects, or a " -"list of :class:`Message` objects, for MIME container documents (e.g. :" -"mimetype:`multipart/\\*` and :mimetype:`message/rfc822`)." +"list of :class:`Message` objects, for MIME container documents " +"(e.g. :mimetype:`multipart/\\*` and :mimetype:`message/rfc822`)." msgstr "" -#: library/email.compat32-message.rst:52 +#: library/email.compat32-message.rst:53 msgid "Here are the methods of the :class:`Message` class:" msgstr "" -#: library/email.compat32-message.rst:57 +#: library/email.compat32-message.rst:58 msgid "" "If *policy* is specified (it must be an instance of a :mod:`~email.policy` " "class) use the rules it specifies to update and serialize the representation " -"of the message. If *policy* is not set, use the :class:`compat32 ` policy, which maintains backward compatibility with the " -"Python 3.2 version of the email package. For more information see the :mod:" -"`~email.policy` documentation." +"of the message. If *policy* is not set, use the :class:`compat32 " +"` policy, which maintains backward compatibility with " +"the Python 3.2 version of the email package. For more information see " +"the :mod:`~email.policy` documentation." msgstr "" -#: library/email.compat32-message.rst:64 +#: library/email.compat32-message.rst:65 msgid "The *policy* keyword argument was added." msgstr "" -#: library/email.compat32-message.rst:69 +#: library/email.compat32-message.rst:70 msgid "" "Return the entire message flattened as a string. When optional *unixfrom* " "is true, the envelope header is included in the returned string. *unixfrom* " @@ -111,42 +112,53 @@ msgid "" "*policy* will be passed to the ``Generator``." msgstr "" -#: library/email.compat32-message.rst:79 library/email.compat32-message.rst:121 +#: library/email.compat32-message.rst:80 library/email.compat32-message.rst:122 msgid "" "Flattening the message may trigger changes to the :class:`Message` if " "defaults need to be filled in to complete the transformation to a string " "(for example, MIME boundaries may be generated or modified)." msgstr "" -#: library/email.compat32-message.rst:83 +#: library/email.compat32-message.rst:84 msgid "" "Note that this method is provided as a convenience and may not always format " "the message the way you want. For example, by default it does not do the " "mangling of lines that begin with ``From`` that is required by the Unix mbox " -"format. For more flexibility, instantiate a :class:`~email.generator." -"Generator` instance and use its :meth:`~email.generator.Generator.flatten` " -"method directly. For example::" +"format. For more flexibility, instantiate " +"a :class:`~email.generator.Generator` instance and use " +"its :meth:`~email.generator.Generator.flatten` method directly. For " +"example::" msgstr "" -#: library/email.compat32-message.rst:97 +#: library/email.compat32-message.rst:91 +msgid "" +"from io import StringIO\n" +"from email.generator import Generator\n" +"fp = StringIO()\n" +"g = Generator(fp, mangle_from_=True, maxheaderlen=60)\n" +"g.flatten(msg)\n" +"text = fp.getvalue()" +msgstr "" + +#: library/email.compat32-message.rst:98 msgid "" "If the message object contains binary data that is not encoded according to " "RFC standards, the non-compliant data will be replaced by unicode \"unknown " -"character\" code points. (See also :meth:`.as_bytes` and :class:`~email." -"generator.BytesGenerator`.)" +"character\" code points. (See also :meth:`.as_bytes` " +"and :class:`~email.generator.BytesGenerator`.)" msgstr "" -#: library/email.compat32-message.rst:102 +#: library/email.compat32-message.rst:103 msgid "the *policy* keyword argument was added." msgstr "" -#: library/email.compat32-message.rst:107 +#: library/email.compat32-message.rst:108 msgid "" -"Equivalent to :meth:`.as_string()`. Allows ``str(msg)`` to produce a string " +"Equivalent to :meth:`.as_string`. Allows ``str(msg)`` to produce a string " "containing the formatted message." msgstr "" -#: library/email.compat32-message.rst:113 +#: library/email.compat32-message.rst:114 msgid "" "Return the entire message flattened as a bytes object. When optional " "*unixfrom* is true, the envelope header is included in the returned string. " @@ -156,45 +168,57 @@ msgid "" "specified *policy* will be passed to the ``BytesGenerator``." msgstr "" -#: library/email.compat32-message.rst:125 +#: library/email.compat32-message.rst:126 msgid "" "Note that this method is provided as a convenience and may not always format " "the message the way you want. For example, by default it does not do the " "mangling of lines that begin with ``From`` that is required by the Unix mbox " -"format. For more flexibility, instantiate a :class:`~email.generator." -"BytesGenerator` instance and use its :meth:`~email.generator.BytesGenerator." -"flatten` method directly. For example::" +"format. For more flexibility, instantiate " +"a :class:`~email.generator.BytesGenerator` instance and use " +"its :meth:`~email.generator.BytesGenerator.flatten` method directly. For " +"example::" msgstr "" -#: library/email.compat32-message.rst:145 +#: library/email.compat32-message.rst:134 msgid "" -"Equivalent to :meth:`.as_bytes()`. Allows ``bytes(msg)`` to produce a bytes " +"from io import BytesIO\n" +"from email.generator import BytesGenerator\n" +"fp = BytesIO()\n" +"g = BytesGenerator(fp, mangle_from_=True, maxheaderlen=60)\n" +"g.flatten(msg)\n" +"text = fp.getvalue()" +msgstr "" + +#: library/email.compat32-message.rst:146 +msgid "" +"Equivalent to :meth:`.as_bytes`. Allows ``bytes(msg)`` to produce a bytes " "object containing the formatted message." msgstr "" -#: library/email.compat32-message.rst:153 +#: library/email.compat32-message.rst:154 msgid "" -"Return ``True`` if the message's payload is a list of sub-\\ :class:" -"`Message` objects, otherwise return ``False``. When :meth:`is_multipart` " -"returns ``False``, the payload should be a string object (which might be a " -"CTE encoded binary payload). (Note that :meth:`is_multipart` returning " -"``True`` does not necessarily mean that \"msg.get_content_maintype() == " -"'multipart'\" will return the ``True``. For example, ``is_multipart`` will " -"return ``True`` when the :class:`Message` is of type ``message/rfc822``.)" +"Return ``True`` if the message's payload is a list of sub-" +"\\ :class:`Message` objects, otherwise return ``False``. " +"When :meth:`is_multipart` returns ``False``, the payload should be a string " +"object (which might be a CTE encoded binary payload). (Note " +"that :meth:`is_multipart` returning ``True`` does not necessarily mean that " +"\"msg.get_content_maintype() == 'multipart'\" will return the ``True``. For " +"example, ``is_multipart`` will return ``True`` when the :class:`Message` is " +"of type ``message/rfc822``.)" msgstr "" -#: library/email.compat32-message.rst:165 +#: library/email.compat32-message.rst:166 msgid "" "Set the message's envelope header to *unixfrom*, which should be a string." msgstr "" -#: library/email.compat32-message.rst:170 +#: library/email.compat32-message.rst:171 msgid "" "Return the message's envelope header. Defaults to ``None`` if the envelope " "header was never set." msgstr "" -#: library/email.compat32-message.rst:176 +#: library/email.compat32-message.rst:177 msgid "" "Add the given *payload* to the current payload, which must be ``None`` or a " "list of :class:`Message` objects before the call. After the call, the " @@ -203,14 +227,15 @@ msgid "" "instead." msgstr "" -#: library/email.compat32-message.rst:182 +#: library/email.compat32-message.rst:183 msgid "" "This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " -"class its functionality is replaced by :meth:`~email.message.EmailMessage." -"set_content` and the related ``make`` and ``add`` methods." +"class its functionality is replaced " +"by :meth:`~email.message.EmailMessage.set_content` and the related ``make`` " +"and ``add`` methods." msgstr "" -#: library/email.compat32-message.rst:190 +#: library/email.compat32-message.rst:191 msgid "" "Return the current payload, which will be a list of :class:`Message` objects " "when :meth:`is_multipart` is ``True``, or a string when :meth:`is_multipart` " @@ -218,17 +243,17 @@ msgid "" "modify the message's payload in place." msgstr "" -#: library/email.compat32-message.rst:195 +#: library/email.compat32-message.rst:196 msgid "" "With optional argument *i*, :meth:`get_payload` will return the *i*-th " "element of the payload, counting from zero, if :meth:`is_multipart` is " "``True``. An :exc:`IndexError` will be raised if *i* is less than 0 or " "greater than or equal to the number of items in the payload. If the payload " -"is a string (i.e. :meth:`is_multipart` is ``False``) and *i* is given, a :" -"exc:`TypeError` is raised." +"is a string (i.e. :meth:`is_multipart` is ``False``) and *i* is given, " +"a :exc:`TypeError` is raised." msgstr "" -#: library/email.compat32-message.rst:202 +#: library/email.compat32-message.rst:203 msgid "" "Optional *decode* is a flag indicating whether the payload should be decoded " "or not, according to the :mailheader:`Content-Transfer-Encoding` header. " @@ -244,111 +269,114 @@ msgid "" "or :class:`~email.errors.InvalidBase64CharactersDefect`, respectively)." msgstr "" -#: library/email.compat32-message.rst:216 +#: library/email.compat32-message.rst:217 msgid "" "When *decode* is ``False`` (the default) the body is returned as a string " "without decoding the :mailheader:`Content-Transfer-Encoding`. However, for " "a :mailheader:`Content-Transfer-Encoding` of 8bit, an attempt is made to " -"decode the original bytes using the ``charset`` specified by the :mailheader:" -"`Content-Type` header, using the ``replace`` error handler. If no " -"``charset`` is specified, or if the ``charset`` given is not recognized by " -"the email package, the body is decoded using the default ASCII charset." +"decode the original bytes using the ``charset`` specified by " +"the :mailheader:`Content-Type` header, using the ``replace`` error handler. " +"If no ``charset`` is specified, or if the ``charset`` given is not " +"recognized by the email package, the body is decoded using the default ASCII " +"charset." msgstr "" -#: library/email.compat32-message.rst:225 +#: library/email.compat32-message.rst:226 msgid "" "This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " -"class its functionality is replaced by :meth:`~email.message.EmailMessage." -"get_content` and :meth:`~email.message.EmailMessage.iter_parts`." +"class its functionality is replaced " +"by :meth:`~email.message.EmailMessage.get_content` " +"and :meth:`~email.message.EmailMessage.iter_parts`." msgstr "" -#: library/email.compat32-message.rst:233 +#: library/email.compat32-message.rst:234 msgid "" "Set the entire message object's payload to *payload*. It is the client's " "responsibility to ensure the payload invariants. Optional *charset* sets " "the message's default character set; see :meth:`set_charset` for details." msgstr "" -#: library/email.compat32-message.rst:237 +#: library/email.compat32-message.rst:238 msgid "" "This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " -"class its functionality is replaced by :meth:`~email.message.EmailMessage." -"set_content`." +"class its functionality is replaced " +"by :meth:`~email.message.EmailMessage.set_content`." msgstr "" -#: library/email.compat32-message.rst:244 +#: library/email.compat32-message.rst:245 msgid "" -"Set the character set of the payload to *charset*, which can either be a :" -"class:`~email.charset.Charset` instance (see :mod:`email.charset`), a string " -"naming a character set, or ``None``. If it is a string, it will be " +"Set the character set of the payload to *charset*, which can either be " +"a :class:`~email.charset.Charset` instance (see :mod:`email.charset`), a " +"string naming a character set, or ``None``. If it is a string, it will be " "converted to a :class:`~email.charset.Charset` instance. If *charset* is " -"``None``, the ``charset`` parameter will be removed from the :mailheader:" -"`Content-Type` header (the message will not be otherwise modified). " -"Anything else will generate a :exc:`TypeError`." +"``None``, the ``charset`` parameter will be removed from " +"the :mailheader:`Content-Type` header (the message will not be otherwise " +"modified). Anything else will generate a :exc:`TypeError`." msgstr "" -#: library/email.compat32-message.rst:252 +#: library/email.compat32-message.rst:253 msgid "" "If there is no existing :mailheader:`MIME-Version` header one will be " "added. If there is no existing :mailheader:`Content-Type` header, one will " -"be added with a value of :mimetype:`text/plain`. Whether the :mailheader:" -"`Content-Type` header already exists or not, its ``charset`` parameter will " -"be set to *charset.output_charset*. If *charset.input_charset* and " -"*charset.output_charset* differ, the payload will be re-encoded to the " -"*output_charset*. If there is no existing :mailheader:`Content-Transfer-" -"Encoding` header, then the payload will be transfer-encoded, if needed, " -"using the specified :class:`~email.charset.Charset`, and a header with the " -"appropriate value will be added. If a :mailheader:`Content-Transfer-" -"Encoding` header already exists, the payload is assumed to already be " -"correctly encoded using that :mailheader:`Content-Transfer-Encoding` and is " -"not modified." +"be added with a value of :mimetype:`text/plain`. Whether " +"the :mailheader:`Content-Type` header already exists or not, its ``charset`` " +"parameter will be set to *charset.output_charset*. If " +"*charset.input_charset* and *charset.output_charset* differ, the payload " +"will be re-encoded to the *output_charset*. If there is no " +"existing :mailheader:`Content-Transfer-Encoding` header, then the payload " +"will be transfer-encoded, if needed, using the " +"specified :class:`~email.charset.Charset`, and a header with the appropriate " +"value will be added. If a :mailheader:`Content-Transfer-Encoding` header " +"already exists, the payload is assumed to already be correctly encoded using " +"that :mailheader:`Content-Transfer-Encoding` and is not modified." msgstr "" -#: library/email.compat32-message.rst:266 +#: library/email.compat32-message.rst:267 msgid "" "This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " -"class its functionality is replaced by the *charset* parameter of the :meth:" -"`email.emailmessage.EmailMessage.set_content` method." +"class its functionality is replaced by the *charset* parameter of " +"the :meth:`email.emailmessage.EmailMessage.set_content` method." msgstr "" -#: library/email.compat32-message.rst:274 +#: library/email.compat32-message.rst:275 msgid "" "Return the :class:`~email.charset.Charset` instance associated with the " "message's payload." msgstr "" -#: library/email.compat32-message.rst:277 +#: library/email.compat32-message.rst:278 msgid "" "This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " "class it always returns ``None``." msgstr "" -#: library/email.compat32-message.rst:282 +#: library/email.compat32-message.rst:283 msgid "" "The following methods implement a mapping-like interface for accessing the " "message's :rfc:`2822` headers. Note that there are some semantic " "differences between these methods and a normal mapping (i.e. dictionary) " "interface. For example, in a dictionary there are no duplicate keys, but " "here there may be duplicate message headers. Also, in dictionaries there is " -"no guaranteed order to the keys returned by :meth:`keys`, but in a :class:" -"`Message` object, headers are always returned in the order they appeared in " -"the original message, or were added to the message later. Any header " -"deleted and then re-added are always appended to the end of the header list." +"no guaranteed order to the keys returned by :meth:`keys`, but in " +"a :class:`Message` object, headers are always returned in the order they " +"appeared in the original message, or were added to the message later. Any " +"header deleted and then re-added are always appended to the end of the " +"header list." msgstr "" -#: library/email.compat32-message.rst:292 +#: library/email.compat32-message.rst:293 msgid "" "These semantic differences are intentional and are biased toward maximal " "convenience." msgstr "" -#: library/email.compat32-message.rst:295 +#: library/email.compat32-message.rst:296 msgid "" "Note that in all cases, any envelope header present in the message is not " "included in the mapping interface." msgstr "" -#: library/email.compat32-message.rst:298 +#: library/email.compat32-message.rst:299 msgid "" "In a model generated from bytes, any header values that (in contravention of " "the RFCs) contain non-ASCII bytes will, when retrieved through this " @@ -356,25 +384,31 @@ msgid "" "charset of ``unknown-8bit``." msgstr "" -#: library/email.compat32-message.rst:306 +#: library/email.compat32-message.rst:307 msgid "Return the total number of headers, including duplicates." msgstr "" -#: library/email.compat32-message.rst:311 +#: library/email.compat32-message.rst:312 msgid "" "Return ``True`` if the message object has a field named *name*. Matching is " "done case-insensitively and *name* should not include the trailing colon. " "Used for the ``in`` operator, e.g.::" msgstr "" -#: library/email.compat32-message.rst:321 +#: library/email.compat32-message.rst:316 +msgid "" +"if 'message-id' in myMessage:\n" +" print('Message-ID:', myMessage['message-id'])" +msgstr "" + +#: library/email.compat32-message.rst:322 msgid "" "Return the value of the named header field. *name* should not include the " -"colon field separator. If the header is missing, ``None`` is returned; a :" -"exc:`KeyError` is never raised." +"colon field separator. If the header is missing, ``None`` is returned; " +"a :exc:`KeyError` is never raised." msgstr "" -#: library/email.compat32-message.rst:325 +#: library/email.compat32-message.rst:326 msgid "" "Note that if the named field appears more than once in the message's " "headers, exactly which of those field values will be returned is undefined. " @@ -382,59 +416,65 @@ msgid "" "headers." msgstr "" -#: library/email.compat32-message.rst:333 +#: library/email.compat32-message.rst:334 msgid "" "Add a header to the message with field name *name* and value *val*. The " "field is appended to the end of the message's existing fields." msgstr "" -#: library/email.compat32-message.rst:336 +#: library/email.compat32-message.rst:337 msgid "" "Note that this does *not* overwrite or delete any existing header with the " "same name. If you want to ensure that the new header is the only one " "present in the message with field name *name*, delete the field first, e.g.::" msgstr "" -#: library/email.compat32-message.rst:346 +#: library/email.compat32-message.rst:341 +msgid "" +"del msg['subject']\n" +"msg['subject'] = 'Python roolz!'" +msgstr "" + +#: library/email.compat32-message.rst:347 msgid "" "Delete all occurrences of the field with name *name* from the message's " "headers. No exception is raised if the named field isn't present in the " "headers." msgstr "" -#: library/email.compat32-message.rst:353 +#: library/email.compat32-message.rst:354 msgid "Return a list of all the message's header field names." msgstr "" -#: library/email.compat32-message.rst:358 +#: library/email.compat32-message.rst:359 msgid "Return a list of all the message's field values." msgstr "" -#: library/email.compat32-message.rst:363 +#: library/email.compat32-message.rst:364 msgid "" "Return a list of 2-tuples containing all the message's field headers and " "values." msgstr "" -#: library/email.compat32-message.rst:369 +#: library/email.compat32-message.rst:370 msgid "" -"Return the value of the named header field. This is identical to :meth:" -"`~object.__getitem__` except that optional *failobj* is returned if the " -"named header is missing (defaults to ``None``)." +"Return the value of the named header field. This is identical " +"to :meth:`~object.__getitem__` except that optional *failobj* is returned if " +"the named header is missing (defaults to ``None``)." msgstr "" -#: library/email.compat32-message.rst:373 +#: library/email.compat32-message.rst:374 msgid "Here are some additional useful methods:" msgstr "" -#: library/email.compat32-message.rst:378 +#: library/email.compat32-message.rst:379 msgid "" "Return a list of all the values for the field named *name*. If there are no " "such named headers in the message, *failobj* is returned (defaults to " "``None``)." msgstr "" -#: library/email.compat32-message.rst:385 +#: library/email.compat32-message.rst:386 msgid "" "Extended header setting. This method is similar to :meth:`__setitem__` " "except that additional header parameters can be provided as keyword " @@ -442,7 +482,7 @@ msgid "" "value for the header." msgstr "" -#: library/email.compat32-message.rst:390 +#: library/email.compat32-message.rst:391 msgid "" "For each item in the keyword argument dictionary *_params*, the key is taken " "as the parameter name, with underscores converted to dashes (since dashes " @@ -451,48 +491,67 @@ msgid "" "key will be added. If the value contains non-ASCII characters, it can be " "specified as a three tuple in the format ``(CHARSET, LANGUAGE, VALUE)``, " "where ``CHARSET`` is a string naming the charset to be used to encode the " -"value, ``LANGUAGE`` can usually be set to ``None`` or the empty string (see :" -"rfc:`2231` for other possibilities), and ``VALUE`` is the string value " +"value, ``LANGUAGE`` can usually be set to ``None`` or the empty string " +"(see :rfc:`2231` for other possibilities), and ``VALUE`` is the string value " "containing non-ASCII code points. If a three tuple is not passed and the " -"value contains non-ASCII characters, it is automatically encoded in :rfc:" -"`2231` format using a ``CHARSET`` of ``utf-8`` and a ``LANGUAGE`` of " +"value contains non-ASCII characters, it is automatically encoded " +"in :rfc:`2231` format using a ``CHARSET`` of ``utf-8`` and a ``LANGUAGE`` of " "``None``." msgstr "" -#: library/email.compat32-message.rst:404 +#: library/email.compat32-message.rst:405 msgid "Here's an example::" msgstr "" -#: library/email.compat32-message.rst:408 +#: library/email.compat32-message.rst:407 +msgid "msg.add_header('Content-Disposition', 'attachment', filename='bud.gif')" +msgstr "" + +#: library/email.compat32-message.rst:409 msgid "This will add a header that looks like ::" msgstr "" -#: library/email.compat32-message.rst:412 +#: library/email.compat32-message.rst:411 +msgid "Content-Disposition: attachment; filename=\"bud.gif\"" +msgstr "" + +#: library/email.compat32-message.rst:413 msgid "An example with non-ASCII characters::" msgstr "" -#: library/email.compat32-message.rst:417 +#: library/email.compat32-message.rst:415 +msgid "" +"msg.add_header('Content-Disposition', 'attachment',\n" +" filename=('iso-8859-1', '', 'Fußballer.ppt'))" +msgstr "" + +#: library/email.compat32-message.rst:418 msgid "Which produces ::" msgstr "" -#: library/email.compat32-message.rst:424 +#: library/email.compat32-message.rst:420 +msgid "" +"Content-Disposition: attachment; filename*=\"iso-8859-1''Fu%DFballer.ppt\"" +msgstr "" + +#: library/email.compat32-message.rst:425 msgid "" "Replace a header. Replace the first header found in the message that " "matches *_name*, retaining header order and field name case. If no matching " "header was found, a :exc:`KeyError` is raised." msgstr "" -#: library/email.compat32-message.rst:431 +#: library/email.compat32-message.rst:432 msgid "" "Return the message's content type. The returned string is coerced to lower " -"case of the form :mimetype:`maintype/subtype`. If there was no :mailheader:" -"`Content-Type` header in the message the default type as given by :meth:" -"`get_default_type` will be returned. Since according to :rfc:`2045`, " -"messages always have a default type, :meth:`get_content_type` will always " -"return a value." +"case of the form :mimetype:`maintype/subtype`. If there was " +"no :mailheader:`Content-Type` header in the message the default type as " +"given by :meth:`get_default_type` will be returned. Since according " +"to :rfc:`2045`, messages always have a default " +"type, :meth:`get_content_type` will always return a value." msgstr "" -#: library/email.compat32-message.rst:438 +#: library/email.compat32-message.rst:439 msgid "" ":rfc:`2045` defines a message's default type to be :mimetype:`text/plain` " "unless it appears inside a :mimetype:`multipart/digest` container, in which " @@ -501,59 +560,60 @@ msgid "" "the default type be :mimetype:`text/plain`." msgstr "" -#: library/email.compat32-message.rst:447 +#: library/email.compat32-message.rst:448 msgid "" "Return the message's main content type. This is the :mimetype:`maintype` " "part of the string returned by :meth:`get_content_type`." msgstr "" -#: library/email.compat32-message.rst:453 +#: library/email.compat32-message.rst:454 msgid "" "Return the message's sub-content type. This is the :mimetype:`subtype` part " "of the string returned by :meth:`get_content_type`." msgstr "" -#: library/email.compat32-message.rst:459 +#: library/email.compat32-message.rst:460 msgid "" "Return the default content type. Most messages have a default content type " -"of :mimetype:`text/plain`, except for messages that are subparts of :" -"mimetype:`multipart/digest` containers. Such subparts have a default " +"of :mimetype:`text/plain`, except for messages that are subparts " +"of :mimetype:`multipart/digest` containers. Such subparts have a default " "content type of :mimetype:`message/rfc822`." msgstr "" -#: library/email.compat32-message.rst:467 +#: library/email.compat32-message.rst:468 msgid "" "Set the default content type. *ctype* should either be :mimetype:`text/" "plain` or :mimetype:`message/rfc822`, although this is not enforced. The " "default content type is not stored in the :mailheader:`Content-Type` header." msgstr "" -#: library/email.compat32-message.rst:475 +#: library/email.compat32-message.rst:476 msgid "" "Return the message's :mailheader:`Content-Type` parameters, as a list. The " "elements of the returned list are 2-tuples of key/value pairs, as split on " "the ``'='`` sign. The left hand side of the ``'='`` is the key, while the " "right hand side is the value. If there is no ``'='`` sign in the parameter " -"the value is the empty string, otherwise the value is as described in :meth:" -"`get_param` and is unquoted if optional *unquote* is ``True`` (the default)." +"the value is the empty string, otherwise the value is as described " +"in :meth:`get_param` and is unquoted if optional *unquote* is ``True`` (the " +"default)." msgstr "" -#: library/email.compat32-message.rst:483 +#: library/email.compat32-message.rst:484 msgid "" -"Optional *failobj* is the object to return if there is no :mailheader:" -"`Content-Type` header. Optional *header* is the header to search instead " -"of :mailheader:`Content-Type`." +"Optional *failobj* is the object to return if there is " +"no :mailheader:`Content-Type` header. Optional *header* is the header to " +"search instead of :mailheader:`Content-Type`." msgstr "" -#: library/email.compat32-message.rst:487 -#: library/email.compat32-message.rst:525 +#: library/email.compat32-message.rst:488 +#: library/email.compat32-message.rst:526 msgid "" "This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " "class its functionality is replaced by the *params* property of the " "individual header objects returned by the header access methods." msgstr "" -#: library/email.compat32-message.rst:495 +#: library/email.compat32-message.rst:496 msgid "" "Return the value of the :mailheader:`Content-Type` header's parameter " "*param* as a string. If the message has no :mailheader:`Content-Type` " @@ -561,13 +621,13 @@ msgid "" "(defaults to ``None``)." msgstr "" -#: library/email.compat32-message.rst:500 +#: library/email.compat32-message.rst:501 msgid "" -"Optional *header* if given, specifies the message header to use instead of :" -"mailheader:`Content-Type`." +"Optional *header* if given, specifies the message header to use instead " +"of :mailheader:`Content-Type`." msgstr "" -#: library/email.compat32-message.rst:503 +#: library/email.compat32-message.rst:504 msgid "" "Parameter keys are always compared case insensitively. The return value can " "either be a string, or a 3-tuple if the parameter was :rfc:`2231` encoded. " @@ -577,23 +637,30 @@ msgid "" "``us-ascii`` charset. You can usually ignore ``LANGUAGE``." msgstr "" -#: library/email.compat32-message.rst:511 +#: library/email.compat32-message.rst:512 msgid "" -"If your application doesn't care whether the parameter was encoded as in :" -"rfc:`2231`, you can collapse the parameter value by calling :func:`email." -"utils.collapse_rfc2231_value`, passing in the return value from :meth:" -"`get_param`. This will return a suitably decoded Unicode string when the " -"value is a tuple, or the original string unquoted if it isn't. For example::" +"If your application doesn't care whether the parameter was encoded as " +"in :rfc:`2231`, you can collapse the parameter value by " +"calling :func:`email.utils.collapse_rfc2231_value`, passing in the return " +"value from :meth:`get_param`. This will return a suitably decoded Unicode " +"string when the value is a tuple, or the original string unquoted if it " +"isn't. For example::" msgstr "" -#: library/email.compat32-message.rst:521 +#: library/email.compat32-message.rst:519 +msgid "" +"rawparam = msg.get_param('foo')\n" +"param = email.utils.collapse_rfc2231_value(rawparam)" +msgstr "" + +#: library/email.compat32-message.rst:522 msgid "" "In any case, the parameter value (either the returned string, or the " "``VALUE`` item in the 3-tuple) is always unquoted, unless *unquote* is set " "to ``False``." msgstr "" -#: library/email.compat32-message.rst:534 +#: library/email.compat32-message.rst:535 msgid "" "Set a parameter in the :mailheader:`Content-Type` header. If the parameter " "already exists in the header, its value will be replaced with *value*. If " @@ -602,14 +669,14 @@ msgid "" "value will be appended as per :rfc:`2045`." msgstr "" -#: library/email.compat32-message.rst:540 +#: library/email.compat32-message.rst:541 msgid "" "Optional *header* specifies an alternative header to :mailheader:`Content-" "Type`, and all parameters will be quoted as necessary unless optional " "*requote* is ``False`` (the default is ``True``)." msgstr "" -#: library/email.compat32-message.rst:544 +#: library/email.compat32-message.rst:545 msgid "" "If optional *charset* is specified, the parameter will be encoded according " "to :rfc:`2231`. Optional *language* specifies the RFC 2231 language, " @@ -617,34 +684,34 @@ msgid "" "strings." msgstr "" -#: library/email.compat32-message.rst:549 +#: library/email.compat32-message.rst:550 msgid "" "If *replace* is ``False`` (the default) the header is moved to the end of " "the list of headers. If *replace* is ``True``, the header will be updated " "in place." msgstr "" -#: library/email.compat32-message.rst:553 +#: library/email.compat32-message.rst:554 msgid "``replace`` keyword was added." msgstr "" -#: library/email.compat32-message.rst:558 +#: library/email.compat32-message.rst:559 msgid "" "Remove the given parameter completely from the :mailheader:`Content-Type` " "header. The header will be re-written in place without the parameter or its " "value. All values will be quoted as necessary unless *requote* is ``False`` " -"(the default is ``True``). Optional *header* specifies an alternative to :" -"mailheader:`Content-Type`." +"(the default is ``True``). Optional *header* specifies an alternative " +"to :mailheader:`Content-Type`." msgstr "" -#: library/email.compat32-message.rst:567 +#: library/email.compat32-message.rst:568 msgid "" "Set the main type and subtype for the :mailheader:`Content-Type` header. " "*type* must be a string in the form :mimetype:`maintype/subtype`, otherwise " "a :exc:`ValueError` is raised." msgstr "" -#: library/email.compat32-message.rst:571 +#: library/email.compat32-message.rst:572 msgid "" "This method replaces the :mailheader:`Content-Type` header, keeping all the " "parameters in place. If *requote* is ``False``, this leaves the existing " @@ -652,20 +719,20 @@ msgid "" "default)." msgstr "" -#: library/email.compat32-message.rst:576 +#: library/email.compat32-message.rst:577 msgid "" -"An alternative header can be specified in the *header* argument. When the :" -"mailheader:`Content-Type` header is set a :mailheader:`MIME-Version` header " -"is also added." +"An alternative header can be specified in the *header* argument. When " +"the :mailheader:`Content-Type` header is set a :mailheader:`MIME-Version` " +"header is also added." msgstr "" -#: library/email.compat32-message.rst:580 +#: library/email.compat32-message.rst:581 msgid "" "This is a legacy method. On the :class:`~email.emailmessage.EmailMessage` " "class its functionality is replaced by the ``make_`` and ``add_`` methods." msgstr "" -#: library/email.compat32-message.rst:587 +#: library/email.compat32-message.rst:588 msgid "" "Return the value of the ``filename`` parameter of the :mailheader:`Content-" "Disposition` header of the message. If the header does not have a " @@ -675,7 +742,7 @@ msgid "" "always be unquoted as per :func:`email.utils.unquote`." msgstr "" -#: library/email.compat32-message.rst:598 +#: library/email.compat32-message.rst:599 msgid "" "Return the value of the ``boundary`` parameter of the :mailheader:`Content-" "Type` header of the message, or *failobj* if either the header is missing, " @@ -683,7 +750,7 @@ msgid "" "unquoted as per :func:`email.utils.unquote`." msgstr "" -#: library/email.compat32-message.rst:606 +#: library/email.compat32-message.rst:607 msgid "" "Set the ``boundary`` parameter of the :mailheader:`Content-Type` header to " "*boundary*. :meth:`set_boundary` will always quote *boundary* if " @@ -691,38 +758,38 @@ msgid "" "object has no :mailheader:`Content-Type` header." msgstr "" -#: library/email.compat32-message.rst:611 +#: library/email.compat32-message.rst:612 msgid "" -"Note that using this method is subtly different than deleting the old :" -"mailheader:`Content-Type` header and adding a new one with the new boundary " -"via :meth:`add_header`, because :meth:`set_boundary` preserves the order of " -"the :mailheader:`Content-Type` header in the list of headers. However, it " -"does *not* preserve any continuation lines which may have been present in " -"the original :mailheader:`Content-Type` header." +"Note that using this method is subtly different than deleting the " +"old :mailheader:`Content-Type` header and adding a new one with the new " +"boundary via :meth:`add_header`, because :meth:`set_boundary` preserves the " +"order of the :mailheader:`Content-Type` header in the list of headers. " +"However, it does *not* preserve any continuation lines which may have been " +"present in the original :mailheader:`Content-Type` header." msgstr "" -#: library/email.compat32-message.rst:621 +#: library/email.compat32-message.rst:622 msgid "" "Return the ``charset`` parameter of the :mailheader:`Content-Type` header, " "coerced to lower case. If there is no :mailheader:`Content-Type` header, or " "if that header has no ``charset`` parameter, *failobj* is returned." msgstr "" -#: library/email.compat32-message.rst:625 +#: library/email.compat32-message.rst:626 msgid "" -"Note that this method differs from :meth:`get_charset` which returns the :" -"class:`~email.charset.Charset` instance for the default encoding of the " +"Note that this method differs from :meth:`get_charset` which returns " +"the :class:`~email.charset.Charset` instance for the default encoding of the " "message body." msgstr "" -#: library/email.compat32-message.rst:631 +#: library/email.compat32-message.rst:632 msgid "" "Return a list containing the character set names in the message. If the " "message is a :mimetype:`multipart`, then the list will contain one element " "for each subpart in the payload, otherwise, it will be a list of length 1." msgstr "" -#: library/email.compat32-message.rst:635 +#: library/email.compat32-message.rst:636 msgid "" "Each item in the list will be a string which is the value of the ``charset`` " "parameter in the :mailheader:`Content-Type` header for the represented " @@ -731,15 +798,15 @@ msgid "" "then that item in the returned list will be *failobj*." msgstr "" -#: library/email.compat32-message.rst:645 +#: library/email.compat32-message.rst:646 msgid "" -"Return the lowercased value (without parameters) of the message's :" -"mailheader:`Content-Disposition` header if it has one, or ``None``. The " -"possible values for this method are *inline*, *attachment* or ``None`` if " -"the message follows :rfc:`2183`." +"Return the lowercased value (without parameters) of the " +"message's :mailheader:`Content-Disposition` header if it has one, or " +"``None``. The possible values for this method are *inline*, *attachment* or " +"``None`` if the message follows :rfc:`2183`." msgstr "" -#: library/email.compat32-message.rst:654 +#: library/email.compat32-message.rst:655 msgid "" "The :meth:`walk` method is an all-purpose generator which can be used to " "iterate over all the parts and subparts of a message object tree, in depth-" @@ -747,13 +814,26 @@ msgid "" "in a ``for`` loop; each iteration returns the next subpart." msgstr "" -#: library/email.compat32-message.rst:659 +#: library/email.compat32-message.rst:660 msgid "" "Here's an example that prints the MIME type of every part of a multipart " "message structure:" msgstr "" -#: library/email.compat32-message.rst:685 +#: library/email.compat32-message.rst:674 +msgid "" +">>> for part in msg.walk():\n" +"... print(part.get_content_type())\n" +"multipart/report\n" +"text/plain\n" +"message/delivery-status\n" +"text/plain\n" +"text/plain\n" +"message/rfc822\n" +"text/plain" +msgstr "" + +#: library/email.compat32-message.rst:686 msgid "" "``walk`` iterates over the subparts of any part where :meth:`is_multipart` " "returns ``True``, even though ``msg.get_content_maintype() == 'multipart'`` " @@ -761,21 +841,43 @@ msgid "" "``_structure`` debug helper function:" msgstr "" -#: library/email.compat32-message.rst:712 +#: library/email.compat32-message.rst:692 +msgid "" +">>> for part in msg.walk():\n" +"... print(part.get_content_maintype() == 'multipart',\n" +"... part.is_multipart())\n" +"True True\n" +"False False\n" +"False True\n" +"False False\n" +"False False\n" +"False True\n" +"False False\n" +">>> _structure(msg)\n" +"multipart/report\n" +" text/plain\n" +" message/delivery-status\n" +" text/plain\n" +" text/plain\n" +" message/rfc822\n" +" text/plain" +msgstr "" + +#: library/email.compat32-message.rst:713 msgid "" "Here the ``message`` parts are not ``multiparts``, but they do contain " "subparts. ``is_multipart()`` returns ``True`` and ``walk`` descends into the " "subparts." msgstr "" -#: library/email.compat32-message.rst:717 +#: library/email.compat32-message.rst:718 msgid "" ":class:`Message` objects can also optionally contain two instance " "attributes, which can be used when generating the plain text of a MIME " "message." msgstr "" -#: library/email.compat32-message.rst:723 +#: library/email.compat32-message.rst:724 msgid "" "The format of a MIME document allows for some text between the blank line " "following the headers, and the first multipart boundary string. Normally, " @@ -785,38 +887,40 @@ msgid "" "can become visible." msgstr "" -#: library/email.compat32-message.rst:730 +#: library/email.compat32-message.rst:731 msgid "" "The *preamble* attribute contains this leading extra-armor text for MIME " "documents. When the :class:`~email.parser.Parser` discovers some text after " "the headers but before the first boundary string, it assigns this text to " -"the message's *preamble* attribute. When the :class:`~email.generator." -"Generator` is writing out the plain text representation of a MIME message, " -"and it finds the message has a *preamble* attribute, it will write this text " -"in the area between the headers and the first boundary. See :mod:`email." -"parser` and :mod:`email.generator` for details." +"the message's *preamble* attribute. When " +"the :class:`~email.generator.Generator` is writing out the plain text " +"representation of a MIME message, and it finds the message has a *preamble* " +"attribute, it will write this text in the area between the headers and the " +"first boundary. See :mod:`email.parser` and :mod:`email.generator` for " +"details." msgstr "" -#: library/email.compat32-message.rst:740 +#: library/email.compat32-message.rst:741 msgid "" "Note that if the message object has no preamble, the *preamble* attribute " "will be ``None``." msgstr "" -#: library/email.compat32-message.rst:746 +#: library/email.compat32-message.rst:747 msgid "" "The *epilogue* attribute acts the same way as the *preamble* attribute, " "except that it contains text that appears between the last boundary and the " "end of the message." msgstr "" -#: library/email.compat32-message.rst:750 +#: library/email.compat32-message.rst:751 msgid "" -"You do not need to set the epilogue to the empty string in order for the :" -"class:`~email.generator.Generator` to print a newline at the end of the file." +"You do not need to set the epilogue to the empty string in order for " +"the :class:`~email.generator.Generator` to print a newline at the end of the " +"file." msgstr "" -#: library/email.compat32-message.rst:757 +#: library/email.compat32-message.rst:758 msgid "" "The *defects* attribute contains a list of all the problems found when " "parsing this message. See :mod:`email.errors` for a detailed description of " diff --git a/library/email.contentmanager.po b/library/email.contentmanager.po index b31f9b8d..b572b236 100644 --- a/library/email.contentmanager.po +++ b/library/email.contentmanager.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.contentmanager.rst:2 -msgid ":mod:`email.contentmanager`: Managing MIME Content" +msgid ":mod:`!email.contentmanager`: Managing MIME Content" msgstr "" #: library/email.contentmanager.rst:10 @@ -91,59 +92,60 @@ msgstr "" #: library/email.contentmanager.rst:59 msgid "" -"the type's fully qualified name (``typ.__module__ + '.' + typ." -"__qualname__``)." +"the type's fully qualified name (``typ.__module__ + '.' + " +"typ.__qualname__``)." msgstr "" #: library/email.contentmanager.rst:61 -msgid "the type's qualname (``typ.__qualname__``)" +msgid "the type's :attr:`qualname ` (``typ.__qualname__``)" msgstr "" #: library/email.contentmanager.rst:62 -msgid "the type's name (``typ.__name__``)." +msgid "the type's :attr:`name ` (``typ.__name__``)." msgstr "" #: library/email.contentmanager.rst:64 msgid "" "If none of the above match, repeat all of the checks above for each of the " -"types in the :term:`MRO` (``typ.__mro__``). Finally, if no other key yields " -"a handler, check for a handler for the key ``None``. If there is no handler " -"for ``None``, raise a :exc:`KeyError` for the fully qualified name of the " -"type." +"types in the :term:`MRO` (:attr:`typ.__mro__ `). Finally, if " +"no other key yields a handler, check for a handler for the key ``None``. If " +"there is no handler for ``None``, raise a :exc:`KeyError` for the fully " +"qualified name of the type." msgstr "" -#: library/email.contentmanager.rst:70 +#: library/email.contentmanager.rst:71 msgid "" "Also add a :mailheader:`MIME-Version` header if one is not present (see " "also :class:`.MIMEPart`)." msgstr "" -#: library/email.contentmanager.rst:76 +#: library/email.contentmanager.rst:77 msgid "" "Record the function *handler* as the handler for *key*. For the possible " "values of *key*, see :meth:`get_content`." msgstr "" -#: library/email.contentmanager.rst:82 +#: library/email.contentmanager.rst:83 msgid "" "Record *handler* as the function to call when an object of a type matching " "*typekey* is passed to :meth:`set_content`. For the possible values of " "*typekey*, see :meth:`set_content`." msgstr "" -#: library/email.contentmanager.rst:88 +#: library/email.contentmanager.rst:89 msgid "Content Manager Instances" msgstr "" -#: library/email.contentmanager.rst:90 +#: library/email.contentmanager.rst:91 msgid "" -"Currently the email package provides only one concrete content manager, :" -"data:`raw_data_manager`, although more may be added in the future. :data:" -"`raw_data_manager` is the :attr:`~email.policy.EmailPolicy.content_manager` " -"provided by :attr:`~email.policy.EmailPolicy` and its derivatives." +"Currently the email package provides only one concrete content " +"manager, :data:`raw_data_manager`, although more may be added in the " +"future. :data:`raw_data_manager` is " +"the :attr:`~email.policy.EmailPolicy.content_manager` provided " +"by :attr:`~email.policy.EmailPolicy` and its derivatives." msgstr "" -#: library/email.contentmanager.rst:99 +#: library/email.contentmanager.rst:100 msgid "" "This content manager provides only a minimum interface beyond that provided " "by :class:`~email.message.Message` itself: it deals only with text, raw " @@ -156,38 +158,38 @@ msgid "" "simplifying the creation of multipart messages." msgstr "" -#: library/email.contentmanager.rst:111 +#: library/email.contentmanager.rst:112 msgid "" -"Return the payload of the part as either a string (for ``text`` parts), an :" -"class:`~email.message.EmailMessage` object (for ``message/rfc822`` parts), " -"or a ``bytes`` object (for all other non-multipart types). Raise a :exc:" -"`KeyError` if called on a ``multipart``. If the part is a ``text`` part and " -"*errors* is specified, use it as the error handler when decoding the payload " -"to unicode. The default error handler is ``replace``." +"Return the payload of the part as either a string (for ``text`` parts), " +"an :class:`~email.message.EmailMessage` object (for ``message/rfc822`` " +"parts), or a ``bytes`` object (for all other non-multipart types). Raise " +"a :exc:`KeyError` if called on a ``multipart``. If the part is a ``text`` " +"part and *errors* is specified, use it as the error handler when decoding " +"the payload to unicode. The default error handler is ``replace``." msgstr "" -#: library/email.contentmanager.rst:130 +#: library/email.contentmanager.rst:131 msgid "Add headers and payload to *msg*:" msgstr "" -#: library/email.contentmanager.rst:132 +#: library/email.contentmanager.rst:133 msgid "" "Add a :mailheader:`Content-Type` header with a ``maintype/subtype`` value." msgstr "" -#: library/email.contentmanager.rst:135 +#: library/email.contentmanager.rst:136 msgid "" "For ``str``, set the MIME ``maintype`` to ``text``, and set the subtype to " "*subtype* if it is specified, or ``plain`` if it is not." msgstr "" -#: library/email.contentmanager.rst:137 +#: library/email.contentmanager.rst:138 msgid "" -"For ``bytes``, use the specified *maintype* and *subtype*, or raise a :exc:" -"`TypeError` if they are not specified." +"For ``bytes``, use the specified *maintype* and *subtype*, or raise " +"a :exc:`TypeError` if they are not specified." msgstr "" -#: library/email.contentmanager.rst:139 +#: library/email.contentmanager.rst:140 msgid "" "For :class:`~email.message.EmailMessage` objects, set the maintype to " "``message``, and set the subtype to *subtype* if it is specified or " @@ -195,7 +197,7 @@ msgid "" "(``bytes`` objects must be used to construct ``message/partial`` parts)." msgstr "" -#: library/email.contentmanager.rst:145 +#: library/email.contentmanager.rst:146 msgid "" "If *charset* is provided (which is valid only for ``str``), encode the " "string to bytes using the specified character set. The default is " @@ -203,7 +205,7 @@ msgid "" "charset name, use the standard charset instead." msgstr "" -#: library/email.contentmanager.rst:150 +#: library/email.contentmanager.rst:151 msgid "" "If *cte* is set, encode the payload using the specified content transfer " "encoding, and set the :mailheader:`Content-Transfer-Encoding` header to that " @@ -213,13 +215,22 @@ msgid "" "that contains non-ASCII values), raise a :exc:`ValueError`." msgstr "" -#: library/email.contentmanager.rst:158 +#: library/email.contentmanager.rst:159 msgid "" "For ``str`` objects, if *cte* is not set use heuristics to determine the " -"most compact encoding." +"most compact encoding. Prior to encoding, :meth:`str.splitlines` is used to " +"normalize all line boundaries, ensuring that each line of the payload is " +"terminated by the current policy's :data:`~email.policy.Policy.linesep` " +"property (even if the original string did not end with one)." msgstr "" -#: library/email.contentmanager.rst:160 +#: library/email.contentmanager.rst:165 +msgid "" +"For ``bytes`` objects, *cte* is taken to be base64 if not set, and the " +"aforementioned newline translation is not performed." +msgstr "" + +#: library/email.contentmanager.rst:167 msgid "" "For :class:`~email.message.EmailMessage`, per :rfc:`2046`, raise an error if " "a *cte* of ``quoted-printable`` or ``base64`` is requested for *subtype* " @@ -228,14 +239,14 @@ msgid "" "For all other values of *subtype*, use ``7bit``." msgstr "" -#: library/email.contentmanager.rst:167 +#: library/email.contentmanager.rst:174 msgid "" "A *cte* of ``binary`` does not actually work correctly yet. The " -"``EmailMessage`` object as modified by ``set_content`` is correct, but :" -"class:`~email.generator.BytesGenerator` does not serialize it correctly." +"``EmailMessage`` object as modified by ``set_content`` is correct, " +"but :class:`~email.generator.BytesGenerator` does not serialize it correctly." msgstr "" -#: library/email.contentmanager.rst:172 +#: library/email.contentmanager.rst:179 msgid "" "If *disposition* is set, use it as the value of the :mailheader:`Content-" "Disposition` header. If not specified, and *filename* is specified, add the " @@ -244,37 +255,37 @@ msgid "" "values for *disposition* are ``attachment`` and ``inline``." msgstr "" -#: library/email.contentmanager.rst:179 +#: library/email.contentmanager.rst:186 msgid "" "If *filename* is specified, use it as the value of the ``filename`` " "parameter of the :mailheader:`Content-Disposition` header." msgstr "" -#: library/email.contentmanager.rst:182 +#: library/email.contentmanager.rst:189 msgid "" "If *cid* is specified, add a :mailheader:`Content-ID` header with *cid* as " "its value." msgstr "" -#: library/email.contentmanager.rst:185 +#: library/email.contentmanager.rst:192 msgid "" "If *params* is specified, iterate its ``items`` method and use the resulting " -"``(key, value)`` pairs to set additional parameters on the :mailheader:" -"`Content-Type` header." +"``(key, value)`` pairs to set additional parameters on " +"the :mailheader:`Content-Type` header." msgstr "" -#: library/email.contentmanager.rst:189 +#: library/email.contentmanager.rst:196 msgid "" "If *headers* is specified and is a list of strings of the form ``headername: " "headervalue`` or a list of ``header`` objects (distinguished from strings by " "having a ``name`` attribute), add the headers to *msg*." msgstr "" -#: library/email.contentmanager.rst:196 +#: library/email.contentmanager.rst:203 msgid "Footnotes" msgstr "" -#: library/email.contentmanager.rst:197 +#: library/email.contentmanager.rst:204 msgid "" "Originally added in 3.4 as a :term:`provisional module `" msgstr "" diff --git a/library/email.encoders.po b/library/email.encoders.po index 59e12aaf..0b7ae650 100644 --- a/library/email.encoders.po +++ b/library/email.encoders.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.encoders.rst:2 -msgid ":mod:`email.encoders`: Encoders" +msgid ":mod:`!email.encoders`: Encoders" msgstr "" #: library/email.encoders.rst:7 @@ -27,8 +28,8 @@ msgstr "" #: library/email.encoders.rst:11 msgid "" "This module is part of the legacy (``Compat32``) email API. In the new API " -"the functionality is provided by the *cte* parameter of the :meth:`~email." -"message.EmailMessage.set_content` method." +"the functionality is provided by the *cte* parameter of " +"the :meth:`~email.message.EmailMessage.set_content` method." msgstr "" #: library/email.encoders.rst:15 @@ -49,27 +50,27 @@ msgstr "" msgid "" "When creating :class:`~email.message.Message` objects from scratch, you " "often need to encode the payloads for transport through compliant mail " -"servers. This is especially true for :mimetype:`image/\\*` and :mimetype:" -"`text/\\*` type messages containing binary data." +"servers. This is especially true for :mimetype:`image/\\*` " +"and :mimetype:`text/\\*` type messages containing binary data." msgstr "" #: library/email.encoders.rst:27 msgid "" -"The :mod:`email` package provides some convenient encoders in its :mod:" -"`~email.encoders` module. These encoders are actually used by the :class:" -"`~email.mime.audio.MIMEAudio` and :class:`~email.mime.image.MIMEImage` class " -"constructors to provide default encodings. All encoder functions take " -"exactly one argument, the message object to encode. They usually extract " -"the payload, encode it, and reset the payload to this newly encoded value. " -"They should also set the :mailheader:`Content-Transfer-Encoding` header as " -"appropriate." +"The :mod:`email` package provides some convenient encoders in " +"its :mod:`~email.encoders` module. These encoders are actually used by " +"the :class:`~email.mime.audio.MIMEAudio` " +"and :class:`~email.mime.image.MIMEImage` class constructors to provide " +"default encodings. All encoder functions take exactly one argument, the " +"message object to encode. They usually extract the payload, encode it, and " +"reset the payload to this newly encoded value. They should also set " +"the :mailheader:`Content-Transfer-Encoding` header as appropriate." msgstr "" #: library/email.encoders.rst:35 msgid "" "Note that these functions are not meaningful for a multipart message. They " -"must be applied to individual subparts instead, and will raise a :exc:" -"`TypeError` if passed a message whose type is multipart." +"must be applied to individual subparts instead, and will raise " +"a :exc:`TypeError` if passed a message whose type is multipart." msgstr "" #: library/email.encoders.rst:39 @@ -78,10 +79,10 @@ msgstr "" #: library/email.encoders.rst:44 msgid "" -"Encodes the payload into quoted-printable form and sets the :mailheader:" -"`Content-Transfer-Encoding` header to ``quoted-printable`` [#]_. This is a " -"good encoding to use when most of your payload is normal printable data, but " -"contains a few unprintable characters." +"Encodes the payload into quoted-printable form and sets " +"the :mailheader:`Content-Transfer-Encoding` header to ``quoted-printable`` " +"[#]_. This is a good encoding to use when most of your payload is normal " +"printable data, but contains a few unprintable characters." msgstr "" #: library/email.encoders.rst:52 @@ -95,9 +96,9 @@ msgstr "" #: library/email.encoders.rst:61 msgid "" -"This doesn't actually modify the message's payload, but it does set the :" -"mailheader:`Content-Transfer-Encoding` header to either ``7bit`` or ``8bit`` " -"as appropriate, based on the payload data." +"This doesn't actually modify the message's payload, but it does set " +"the :mailheader:`Content-Transfer-Encoding` header to either ``7bit`` or " +"``8bit`` as appropriate, based on the payload data." msgstr "" #: library/email.encoders.rst:68 diff --git a/library/email.errors.po b/library/email.errors.po index c27bb464..56310210 100644 --- a/library/email.errors.po +++ b/library/email.errors.po @@ -8,16 +8,18 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-12-14 01:00+0200\n" "Last-Translator: Marios Giannopoulos \n" "Language-Team: PyGreece \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.errors.rst:2 -msgid ":mod:`email.errors`: Exception and Defect classes" +#, fuzzy +msgid ":mod:`!email.errors`: Exception and Defect classes" msgstr ":mod:`email.errors`: Κλάσεις Εξαιρέσεων και Ελαττωμάτων" #: library/email.errors.rst:7 @@ -42,9 +44,10 @@ msgstr "" #: library/email.errors.rst:23 msgid "" -"This is the base class for exceptions raised by the :class:`~email.parser." -"Parser` class. It is derived from :exc:`MessageError`. This class is also " -"used internally by the parser used by :mod:`~email.headerregistry`." +"This is the base class for exceptions raised by " +"the :class:`~email.parser.Parser` class. It is derived " +"from :exc:`MessageError`. This class is also used internally by the parser " +"used by :mod:`~email.headerregistry`." msgstr "" "Αυτή είναι η βασική κλάση για τις εξαιρέσεις που γίνονται raise από την " "κλάση :class:`~email.parser.Parser`. Κληρονομεί από την :exc:`MessageError`. " @@ -54,23 +57,25 @@ msgstr "" #: library/email.errors.rst:31 msgid "" "Raised under some error conditions when parsing the :rfc:`5322` headers of a " -"message, this class is derived from :exc:`MessageParseError`. The :meth:" -"`~email.message.EmailMessage.set_boundary` method will raise this error if " -"the content type is unknown when the method is called. :class:`~email.header." -"Header` may raise this error for certain base64 decoding errors, and when an " -"attempt is made to create a header that appears to contain an embedded " -"header (that is, there is what is supposed to be a continuation line that " -"has no leading whitespace and looks like a header)." +"message, this class is derived from :exc:`MessageParseError`. " +"The :meth:`~email.message.EmailMessage.set_boundary` method will raise this " +"error if the content type is unknown when the method is " +"called. :class:`~email.header.Header` may raise this error for certain " +"base64 decoding errors, and when an attempt is made to create a header that " +"appears to contain an embedded header (that is, there is what is supposed to " +"be a continuation line that has no leading whitespace and looks like a " +"header)." msgstr "" "Γίνεται raise κάτω από ορισμένες συνθήκες σφάλματος κατά την ανάλυση των " -"κεφαλίδων :rfc:`5322` ενός μηνύματος, αυτή η κλάση προέρχεται από την :exc:" -"`MessageParseError`. Η μέθοδος :meth:`~email.message.EmailMessage." -"set_boundary` θα κάνει raise αυτό το σφάλμα αν ο τύπος περιεχομένου είναι " -"άγνωστος όταν καλείται η μέθοδος. Η :class:`~email.header.Header` μπορεί να " -"κάνει raise αυτό το σφάλμα για ορισμένα σφάλματα αποκωδικοποίησης base64, " -"καθώς και όταν επιχειρείται η δημιουργία μιας κεφαλίδας που φαίνεται να " -"περιέχει ενσωματωμένη κεφαλίδα (δηλαδή υπάρχει μια γραμμή συνέχειας που δεν " -"έχει προηγούμενο κενό διάστημα και μοιάζει με κεφαλίδα)." +"κεφαλίδων :rfc:`5322` ενός μηνύματος, αυτή η κλάση προέρχεται από " +"την :exc:`MessageParseError`. Η " +"μέθοδος :meth:`~email.message.EmailMessage.set_boundary` θα κάνει raise αυτό " +"το σφάλμα αν ο τύπος περιεχομένου είναι άγνωστος όταν καλείται η μέθοδος. " +"Η :class:`~email.header.Header` μπορεί να κάνει raise αυτό το σφάλμα για " +"ορισμένα σφάλματα αποκωδικοποίησης base64, καθώς και όταν επιχειρείται η " +"δημιουργία μιας κεφαλίδας που φαίνεται να περιέχει ενσωματωμένη κεφαλίδα " +"(δηλαδή υπάρχει μια γραμμή συνέχειας που δεν έχει προηγούμενο κενό διάστημα " +"και μοιάζει με κεφαλίδα)." #: library/email.errors.rst:43 msgid "Deprecated and no longer used." @@ -80,32 +85,39 @@ msgstr "Έχει καταργηθεί και δεν χρησιμοποιείτα msgid "" "Raised when a payload is added to a :class:`~email.message.Message` object " "using :meth:`add_payload`, but the payload is already a scalar and the " -"message's :mailheader:`Content-Type` main type is not either :mimetype:" -"`multipart` or missing. :exc:`MultipartConversionError` multiply inherits " -"from :exc:`MessageError` and the built-in :exc:`TypeError`." +"message's :mailheader:`Content-Type` main type is not " +"either :mimetype:`multipart` or missing. :exc:`MultipartConversionError` " +"multiply inherits from :exc:`MessageError` and the built-in :exc:`TypeError`." msgstr "" -"Γίνεται raise όταν προστεθεί ένα payload σε ένα αντικείμενο :class:`~email." -"message.Message` χρησιμοποιώντας τη μέθοδο :meth:`add_payload`, αλλά το " -"payload είναι ήδη scalar και ο κύριος τύπος του :mailheader:`Content-Type` " -"μηνύματος δεν είναι ούτε :mimetype:`multipart` ούτε απών. Η :exc:" -"`MultipartConversionError` κληρονομεί ταυτόχρονα από την :exc:`MessageError` " -"και την ενσωματωμένη :exc:`TypeError`." +"Γίνεται raise όταν προστεθεί ένα payload σε ένα " +"αντικείμενο :class:`~email.message.Message` χρησιμοποιώντας τη " +"μέθοδο :meth:`add_payload`, αλλά το payload είναι ήδη scalar και ο κύριος " +"τύπος του :mailheader:`Content-Type` μηνύματος δεν είναι " +"ούτε :mimetype:`multipart` ούτε απών. Η :exc:`MultipartConversionError` " +"κληρονομεί ταυτόχρονα από την :exc:`MessageError` και την " +"ενσωματωμένη :exc:`TypeError`." #: library/email.errors.rst:54 msgid "" "Since :meth:`Message.add_payload` is deprecated, this exception is rarely " -"raised in practice. However the exception may also be raised if the :meth:" -"`~email.message.Message.attach` method is called on an instance of a class " -"derived from :class:`~email.mime.nonmultipart.MIMENonMultipart` (e.g. :class:" -"`~email.mime.image.MIMEImage`)." +"raised in practice. However the exception may also be raised if " +"the :meth:`~email.message.Message.attach` method is called on an instance of " +"a class derived from :class:`~email.mime.nonmultipart.MIMENonMultipart` " +"(e.g. :class:`~email.mime.image.MIMEImage`)." msgstr "" "Επειδή η μέθοδος :meth:`Message.add_payload` έχει ξεπεραστεί, αυτή η " "εξαίρεση σπάνια εμφανίζεται στην πράξη. Ωστόσο, η εξαίρεση μπορεί επίσης να " "εμφανιστεί αν κληθεί η μέθοδος :meth:`~email.message.Message.attach` σε ένα " -"στιγμιότυπο μιας κλάσης που κληρονομεί από :class:`~email.mime.nonmultipart." -"MIMENonMultipart` (π.χ. :class:`~email.mime.image.MIMEImage`)." +"στιγμιότυπο μιας κλάσης που κληρονομεί " +"από :class:`~email.mime.nonmultipart.MIMENonMultipart` " +"(π.χ. :class:`~email.mime.image.MIMEImage`)." + +#: library/email.errors.rst:64 +msgid "" +"Raised when an error occurs when the :mod:`~email.generator` outputs headers." +msgstr "" -#: library/email.errors.rst:63 +#: library/email.errors.rst:70 msgid "" "This is the base class for all defects found when parsing email messages. It " "is derived from :exc:`ValueError`." @@ -113,7 +125,7 @@ msgstr "" "Αυτή είναι η βασική κλάση για όλα τα ελαττώματα που εντοπίζονται κατά την " "ανάλυση μηνυμάτων email. Είναι παράγωγη της :exc:`ValueError`." -#: library/email.errors.rst:68 +#: library/email.errors.rst:75 msgid "" "This is the base class for all defects found when parsing email headers. It " "is derived from :exc:`MessageDefect`." @@ -121,7 +133,7 @@ msgstr "" "Αυτή είναι η βασική κλάση για όλα τα ελαττώματα που εντοπίζονται κατά την " "ανάλυση των κεφαλίδων email. Είναι παράγωγο της :exc:`MessageDefect`." -#: library/email.errors.rst:71 +#: library/email.errors.rst:78 msgid "" "Here is the list of the defects that the :class:`~email.parser.FeedParser` " "can find while parsing messages. Note that the defects are added to the " @@ -130,21 +142,22 @@ msgid "" "nested message object would have a defect, but the containing messages would " "not." msgstr "" -"Ακολουθεί η λίστα με τα ελαττώματα που μπορεί να εντοπίσει η :class:`~email." -"parser.FeedParser` κατά την ανάλυση των μηνυμάτων. Σημειώστε ότι τα " -"ελαττώματα προστίθενται στο μήνυμα όπου βρέθηκε το πρόβλημα, οπότε για " -"παράδειγμα, εάν ένα μήνυμα που είναι ένθετο μέσα σε ένα :mimetype:`multipart/" -"alternative` είχε μια παραμορφωμένη κεφαλίδα, αυτό το ένθετο αντικείμενο " -"μηνύματος θα είχε ένα ελάττωμα, αλλά τα μηνύματα που το περιέχουν όχι." +"Ακολουθεί η λίστα με τα ελαττώματα που μπορεί να εντοπίσει " +"η :class:`~email.parser.FeedParser` κατά την ανάλυση των μηνυμάτων. " +"Σημειώστε ότι τα ελαττώματα προστίθενται στο μήνυμα όπου βρέθηκε το " +"πρόβλημα, οπότε για παράδειγμα, εάν ένα μήνυμα που είναι ένθετο μέσα σε " +"ένα :mimetype:`multipart/alternative` είχε μια παραμορφωμένη κεφαλίδα, αυτό " +"το ένθετο αντικείμενο μηνύματος θα είχε ένα ελάττωμα, αλλά τα μηνύματα που " +"το περιέχουν όχι." -#: library/email.errors.rst:77 +#: library/email.errors.rst:84 msgid "" "All defect classes are subclassed from :class:`email.errors.MessageDefect`." msgstr "" -"Όλες οι κλάσεις ελαττωμάτων είναι υποκλάσεις της :class:`email.errors." -"MessageDefect`." +"Όλες οι κλάσεις ελαττωμάτων είναι υποκλάσεις " +"της :class:`email.errors.MessageDefect`." -#: library/email.errors.rst:79 +#: library/email.errors.rst:86 msgid "" ":class:`NoBoundaryInMultipartDefect` -- A message claimed to be a multipart, " "but had no :mimetype:`boundary` parameter." @@ -152,15 +165,15 @@ msgstr "" ":class:`NoBoundaryInMultipartDefect` -- Ένα μήνυμα δήλωσε ότι είναι " "πολλαπλό, αλλά δεν είχε παράμετρο :mimetype:`boundary`." -#: library/email.errors.rst:82 +#: library/email.errors.rst:89 msgid "" -":class:`StartBoundaryNotFoundDefect` -- The start boundary claimed in the :" -"mailheader:`Content-Type` header was never found." +":class:`StartBoundaryNotFoundDefect` -- The start boundary claimed in " +"the :mailheader:`Content-Type` header was never found." msgstr "" ":class:`StartBoundaryNotFoundDefect` -- Το όριο εκκίνησης που αναφέρεται " "στην κεφαλίδα :mailheader:`Content-Type` δεν βρέθηκε ποτέ." -#: library/email.errors.rst:85 +#: library/email.errors.rst:92 msgid "" ":class:`CloseBoundaryNotFoundDefect` -- A start boundary was found, but no " "corresponding close boundary was ever found." @@ -168,7 +181,7 @@ msgstr "" ":class:`CloseBoundaryNotFoundDefect` -- Βρέθηκε ένα όριο εκκίνησης, αλλά δεν " "βρέθηκε ποτέ αντίστοιχο όριο κλεισίματος." -#: library/email.errors.rst:90 +#: library/email.errors.rst:97 msgid "" ":class:`FirstHeaderLineIsContinuationDefect` -- The message had a " "continuation line as its first header line." @@ -176,7 +189,7 @@ msgstr "" ":class:`FirstHeaderLineIsContinuationDefect` -- Το μήνυμα είχε μια γραμμή " "συνέχισης ως την πρώτη γραμμή κεφαλίδας." -#: library/email.errors.rst:93 +#: library/email.errors.rst:100 msgid "" ":class:`MisplacedEnvelopeHeaderDefect` - A \"Unix From\" header was found in " "the middle of a header block." @@ -184,7 +197,7 @@ msgstr "" ":class:`MisplacedEnvelopeHeaderDefect` - Βρέθηκε μια κεφαλίδα \"Unix From\" " "στη μέση ενός μπλοκ κεφαλίδων." -#: library/email.errors.rst:96 +#: library/email.errors.rst:103 msgid "" ":class:`MissingHeaderBodySeparatorDefect` - A line was found while parsing " "headers that had no leading white space but contained no ':'. Parsing " @@ -195,7 +208,7 @@ msgstr "" "ανάλυση συνεχίζεται στην περίπτωση που η γραμμή αντιπροσωπεύει την πρώτη " "γραμμή του σώματος." -#: library/email.errors.rst:102 +#: library/email.errors.rst:109 msgid "" ":class:`MalformedHeaderDefect` -- A header was found that was missing a " "colon, or was otherwise malformed." @@ -203,26 +216,27 @@ msgstr "" ":class:`MalformedHeaderDefect` -- Βρέθηκε μια κεφαλίδα που της έλειπε μια " "άνω τελεία, ή ήταν αλλιώς παραμορφωμένη." -#: library/email.errors.rst:105 +#: library/email.errors.rst:112 msgid "This defect has not been used for several Python versions." msgstr "" "Αυτό το σφάλμα δεν έχει χρησιμοποιηθεί εδώ και πολλές εκδόσεις της Python." -#: library/email.errors.rst:108 +#: library/email.errors.rst:115 msgid "" -":class:`MultipartInvariantViolationDefect` -- A message claimed to be a :" -"mimetype:`multipart`, but no subparts were found. Note that when a message " -"has this defect, its :meth:`~email.message.Message.is_multipart` method may " -"return ``False`` even though its content type claims to be :mimetype:" -"`multipart`." +":class:`MultipartInvariantViolationDefect` -- A message claimed to be " +"a :mimetype:`multipart`, but no subparts were found. Note that when a " +"message has this defect, its :meth:`~email.message.Message.is_multipart` " +"method may return ``False`` even though its content type claims to " +"be :mimetype:`multipart`." msgstr "" -":class:`MultipartInvariantViolationDefect` -- Ένα μήνυμα δήλωσε ότι είναι :" -"mimetype:`multipart`, αλλά δεν βρέθηκαν υπομέρη. Σημειώστε ότι όταν ένα " -"μήνυμα έχει αυτό το σφάλμα, η μέθοδος του :meth:`~email.message.Message." -"is_multipart` μπορεί να επιστρέψει ``False`` ακόμα κι αν ο τύπος " -"περιεχομένου του δηλώνει ότι είναι :mimetype:`multipart`." +":class:`MultipartInvariantViolationDefect` -- Ένα μήνυμα δήλωσε ότι " +"είναι :mimetype:`multipart`, αλλά δεν βρέθηκαν υπομέρη. Σημειώστε ότι όταν " +"ένα μήνυμα έχει αυτό το σφάλμα, η μέθοδος " +"του :meth:`~email.message.Message.is_multipart` μπορεί να επιστρέψει " +"``False`` ακόμα κι αν ο τύπος περιεχομένου του δηλώνει ότι " +"είναι :mimetype:`multipart`." -#: library/email.errors.rst:113 +#: library/email.errors.rst:120 msgid "" ":class:`InvalidBase64PaddingDefect` -- When decoding a block of base64 " "encoded bytes, the padding was not correct. Enough padding is added to " @@ -233,7 +247,7 @@ msgstr "" "αρκετό padding για να πραγματοποιηθεί η αποκωδικοποίηση, αλλά τα " "αποκωδικοποιημένα bytes που προκύπτουν μπορεί να είναι άκυρα." -#: library/email.errors.rst:117 +#: library/email.errors.rst:124 msgid "" ":class:`InvalidBase64CharactersDefect` -- When decoding a block of base64 " "encoded bytes, characters outside the base64 alphabet were encountered. The " @@ -244,7 +258,7 @@ msgstr "" "base64. Οι χαρακτήρες αγνοούνται, αλλά τα αποκωδικοποιημένα bytes που " "προκύπτουν μπορεί να είναι άκυρα." -#: library/email.errors.rst:121 +#: library/email.errors.rst:128 msgid "" ":class:`InvalidBase64LengthDefect` -- When decoding a block of base64 " "encoded bytes, the number of non-padding base64 characters was invalid (1 " @@ -255,7 +269,7 @@ msgstr "" "συμπλήρωμα ήταν άκυρος (1 παραπάνω από ένα πολλαπλάσιο του 4). Το " "κωδικοποιημένο μπλοκ διατηρήθηκε ως έχει." -#: library/email.errors.rst:125 +#: library/email.errors.rst:132 msgid "" ":class:`InvalidDateDefect` -- When decoding an invalid or unparsable date " "field. The original value is kept as-is." diff --git a/library/email.examples.po b/library/email.examples.po index 28139fd6..0e909d03 100644 --- a/library/email.examples.po +++ b/library/email.examples.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -32,30 +33,261 @@ msgid "" "content and the addresses may contain unicode characters):" msgstr "" +#: library/email.examples.rst:12 +msgid "" +"# Import smtplib for the actual sending function\n" +"import smtplib\n" +"\n" +"# Import the email modules we'll need\n" +"from email.message import EmailMessage\n" +"\n" +"# Open the plain text file whose name is in textfile for reading.\n" +"with open(textfile) as fp:\n" +" # Create a text/plain message\n" +" msg = EmailMessage()\n" +" msg.set_content(fp.read())\n" +"\n" +"# me == the sender's email address\n" +"# you == the recipient's email address\n" +"msg['Subject'] = f'The contents of {textfile}'\n" +"msg['From'] = me\n" +"msg['To'] = you\n" +"\n" +"# Send the message via our own SMTP server.\n" +"s = smtplib.SMTP('localhost')\n" +"s.send_message(msg)\n" +"s.quit()\n" +msgstr "" + #: library/email.examples.rst:15 msgid "" "Parsing :rfc:`822` headers can easily be done by the using the classes from " "the :mod:`~email.parser` module:" msgstr "" +#: library/email.examples.rst:18 +msgid "" +"# Import the email modules we'll need\n" +"#from email.parser import BytesParser\n" +"from email.parser import Parser\n" +"from email.policy import default\n" +"\n" +"# If the e-mail headers are in a file, uncomment these two lines:\n" +"# with open(messagefile, 'rb') as fp:\n" +"# headers = BytesParser(policy=default).parse(fp)\n" +"\n" +"# Or for parsing headers in a string (this is an uncommon operation), use:\n" +"headers = Parser(policy=default).parsestr(\n" +" 'From: Foo Bar \\n'\n" +" 'To: \\n'\n" +" 'Subject: Test message\\n'\n" +" '\\n'\n" +" 'Body would go here\\n')\n" +"\n" +"# Now the header items can be accessed as a dictionary:\n" +"print('To: {}'.format(headers['to']))\n" +"print('From: {}'.format(headers['from']))\n" +"print('Subject: {}'.format(headers['subject']))\n" +"\n" +"# You can also access the parts of the addresses:\n" +"print('Recipient username: {}'.format(headers['to'].addresses[0].username))\n" +"print('Sender name: {}'.format(headers['from'].addresses[0].display_name))\n" +msgstr "" + #: library/email.examples.rst:21 msgid "" "Here's an example of how to send a MIME message containing a bunch of family " "pictures that may be residing in a directory:" msgstr "" +#: library/email.examples.rst:24 +msgid "" +"# Import smtplib for the actual sending function.\n" +"import smtplib\n" +"\n" +"# Here are the email package modules we'll need.\n" +"from email.message import EmailMessage\n" +"\n" +"# Create the container email message.\n" +"msg = EmailMessage()\n" +"msg['Subject'] = 'Our family reunion'\n" +"# me == the sender's email address\n" +"# family = the list of all recipients' email addresses\n" +"msg['From'] = me\n" +"msg['To'] = ', '.join(family)\n" +"msg.preamble = 'You will not see this in a MIME-aware mail reader.\\n'\n" +"\n" +"# Open the files in binary mode. You can also omit the subtype\n" +"# if you want MIMEImage to guess it.\n" +"for file in pngfiles:\n" +" with open(file, 'rb') as fp:\n" +" img_data = fp.read()\n" +" msg.add_attachment(img_data, maintype='image',\n" +" subtype='png')\n" +"\n" +"# Send the email via our own SMTP server.\n" +"with smtplib.SMTP('localhost') as s:\n" +" s.send_message(msg)\n" +msgstr "" + #: library/email.examples.rst:27 msgid "" "Here's an example of how to send the entire contents of a directory as an " "email message: [1]_" msgstr "" +#: library/email.examples.rst:30 +msgid "" +"#!/usr/bin/env python3\n" +"\n" +"\"\"\"Send the contents of a directory as a MIME message.\"\"\"\n" +"\n" +"import os\n" +"import smtplib\n" +"# For guessing MIME type based on file name extension\n" +"import mimetypes\n" +"\n" +"from argparse import ArgumentParser\n" +"\n" +"from email.message import EmailMessage\n" +"from email.policy import SMTP\n" +"\n" +"\n" +"def main():\n" +" parser = ArgumentParser(description=\"\"\"\\\n" +"Send the contents of a directory as a MIME message.\n" +"Unless the -o option is given, the email is sent by forwarding to your " +"local\n" +"SMTP server, which then does the normal delivery process. Your local " +"machine\n" +"must be running an SMTP server.\n" +"\"\"\")\n" +" parser.add_argument('-d', '--directory',\n" +" help=\"\"\"Mail the contents of the specified " +"directory,\n" +" otherwise use the current directory. Only the " +"regular\n" +" files in the directory are sent, and we don't " +"recurse to\n" +" subdirectories.\"\"\")\n" +" parser.add_argument('-o', '--output',\n" +" metavar='FILE',\n" +" help=\"\"\"Print the composed message to FILE " +"instead of\n" +" sending the message to the SMTP server.\"\"\")\n" +" parser.add_argument('-s', '--sender', required=True,\n" +" help='The value of the From: header (required)')\n" +" parser.add_argument('-r', '--recipient', required=True,\n" +" action='append', metavar='RECIPIENT',\n" +" default=[], dest='recipients',\n" +" help='A To: header value (at least one required)')\n" +" args = parser.parse_args()\n" +" directory = args.directory\n" +" if not directory:\n" +" directory = '.'\n" +" # Create the message\n" +" msg = EmailMessage()\n" +" msg['Subject'] = f'Contents of directory {os.path.abspath(directory)}'\n" +" msg['To'] = ', '.join(args.recipients)\n" +" msg['From'] = args.sender\n" +" msg.preamble = 'You will not see this in a MIME-aware mail reader.\\n'\n" +"\n" +" for filename in os.listdir(directory):\n" +" path = os.path.join(directory, filename)\n" +" if not os.path.isfile(path):\n" +" continue\n" +" # Guess the content type based on the file's extension. Encoding\n" +" # will be ignored, although we should check for simple things like\n" +" # gzip'd or compressed files.\n" +" ctype, encoding = mimetypes.guess_type(path)\n" +" if ctype is None or encoding is not None:\n" +" # No guess could be made, or the file is encoded (compressed), " +"so\n" +" # use a generic bag-of-bits type.\n" +" ctype = 'application/octet-stream'\n" +" maintype, subtype = ctype.split('/', 1)\n" +" with open(path, 'rb') as fp:\n" +" msg.add_attachment(fp.read(),\n" +" maintype=maintype,\n" +" subtype=subtype,\n" +" filename=filename)\n" +" # Now send or store the message\n" +" if args.output:\n" +" with open(args.output, 'wb') as fp:\n" +" fp.write(msg.as_bytes(policy=SMTP))\n" +" else:\n" +" with smtplib.SMTP('localhost') as s:\n" +" s.send_message(msg)\n" +"\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +msgstr "" + #: library/email.examples.rst:33 msgid "" "Here's an example of how to unpack a MIME message like the one above, into a " "directory of files:" msgstr "" +#: library/email.examples.rst:36 +msgid "" +"#!/usr/bin/env python3\n" +"\n" +"\"\"\"Unpack a MIME message into a directory of files.\"\"\"\n" +"\n" +"import os\n" +"import email\n" +"import mimetypes\n" +"\n" +"from email.policy import default\n" +"\n" +"from argparse import ArgumentParser\n" +"\n" +"\n" +"def main():\n" +" parser = ArgumentParser(description=\"\"\"\\\n" +"Unpack a MIME message into a directory of files.\n" +"\"\"\")\n" +" parser.add_argument('-d', '--directory', required=True,\n" +" help=\"\"\"Unpack the MIME message into the named\n" +" directory, which will be created if it doesn't " +"already\n" +" exist.\"\"\")\n" +" parser.add_argument('msgfile')\n" +" args = parser.parse_args()\n" +"\n" +" with open(args.msgfile, 'rb') as fp:\n" +" msg = email.message_from_binary_file(fp, policy=default)\n" +"\n" +" try:\n" +" os.mkdir(args.directory)\n" +" except FileExistsError:\n" +" pass\n" +"\n" +" counter = 1\n" +" for part in msg.walk():\n" +" # multipart/* are just containers\n" +" if part.get_content_maintype() == 'multipart':\n" +" continue\n" +" # Applications should really sanitize the given filename so that an\n" +" # email message can't be used to overwrite important files\n" +" filename = part.get_filename()\n" +" if not filename:\n" +" ext = mimetypes.guess_extension(part.get_content_type())\n" +" if not ext:\n" +" # Use a generic bag-of-bits extension\n" +" ext = '.bin'\n" +" filename = f'part-{counter:03d}{ext}'\n" +" counter += 1\n" +" with open(os.path.join(args.directory, filename), 'wb') as fp:\n" +" fp.write(part.get_payload(decode=True))\n" +"\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" +msgstr "" + #: library/email.examples.rst:39 msgid "" "Here's an example of how to create an HTML message with an alternative plain " @@ -64,16 +296,182 @@ msgid "" "disk, as well as sending it." msgstr "" +#: library/email.examples.rst:44 +msgid "" +"#!/usr/bin/env python3\n" +"\n" +"import smtplib\n" +"\n" +"from email.message import EmailMessage\n" +"from email.headerregistry import Address\n" +"from email.utils import make_msgid\n" +"\n" +"# Create the base text message.\n" +"msg = EmailMessage()\n" +"msg['Subject'] = \"Ayons asperges pour le déjeuner\"\n" +"msg['From'] = Address(\"Pepé Le Pew\", \"pepe\", \"example.com\")\n" +"msg['To'] = (Address(\"Penelope Pussycat\", \"penelope\", \"example.com\"),\n" +" Address(\"Fabrette Pussycat\", \"fabrette\", \"example.com\"))\n" +"msg.set_content(\"\"\"\\\n" +"Salut!\n" +"\n" +"Cela ressemble à un excellent recipie[1] déjeuner.\n" +"\n" +"[1] http://www.yummly.com/recipe/Roasted-Asparagus-Epicurious-203718\n" +"\n" +"--Pepé\n" +"\"\"\")\n" +"\n" +"# Add the html version. This converts the message into a multipart/" +"alternative\n" +"# container, with the original text message as the first part and the new " +"html\n" +"# message as the second part.\n" +"asparagus_cid = make_msgid()\n" +"msg.add_alternative(\"\"\"\\\n" +"\n" +" \n" +" \n" +"

Salut!

\n" +"

Cela ressemble à un excellent\n" +" \n" +" recipie\n" +" déjeuner.\n" +"

\n" +" \n" +" \n" +"\n" +"\"\"\".format(asparagus_cid=asparagus_cid[1:-1]), subtype='html')\n" +"# note that we needed to peel the <> off the msgid for use in the html.\n" +"\n" +"# Now add the related image to the html part.\n" +"with open(\"roasted-asparagus.jpg\", 'rb') as img:\n" +" msg.get_payload()[1].add_related(img.read(), 'image', 'jpeg',\n" +" cid=asparagus_cid)\n" +"\n" +"# Make a local copy of what we are going to send.\n" +"with open('outgoing.msg', 'wb') as f:\n" +" f.write(bytes(msg))\n" +"\n" +"# Send the message via local SMTP server.\n" +"with smtplib.SMTP('localhost') as s:\n" +" s.send_message(msg)\n" +msgstr "" + #: library/email.examples.rst:47 msgid "" "If we were sent the message from the last example, here is one way we could " "process it:" msgstr "" +#: library/email.examples.rst:50 +msgid "" +"import os\n" +"import sys\n" +"import tempfile\n" +"import mimetypes\n" +"import webbrowser\n" +"\n" +"# Import the email modules we'll need\n" +"from email import policy\n" +"from email.parser import BytesParser\n" +"\n" +"\n" +"def magic_html_parser(html_text, partfiles):\n" +" \"\"\"Return safety-sanitized html linked to partfiles.\n" +"\n" +" Rewrite the href=\"cid:....\" attributes to point to the filenames in " +"partfiles.\n" +" Though not trivial, this should be possible using html.parser.\n" +" \"\"\"\n" +" raise NotImplementedError(\"Add the magic needed\")\n" +"\n" +"\n" +"# In a real program you'd get the filename from the arguments.\n" +"with open('outgoing.msg', 'rb') as fp:\n" +" msg = BytesParser(policy=policy.default).parse(fp)\n" +"\n" +"# Now the header items can be accessed as a dictionary, and any non-ASCII " +"will\n" +"# be converted to unicode:\n" +"print('To:', msg['to'])\n" +"print('From:', msg['from'])\n" +"print('Subject:', msg['subject'])\n" +"\n" +"# If we want to print a preview of the message content, we can extract " +"whatever\n" +"# the least formatted payload is and print the first three lines. Of " +"course,\n" +"# if the message has no plain text part printing the first three lines of " +"html\n" +"# is probably useless, but this is just a conceptual example.\n" +"simplest = msg.get_body(preferencelist=('plain', 'html'))\n" +"print()\n" +"print(''.join(simplest.get_content().splitlines(keepends=True)[:3]))\n" +"\n" +"ans = input(\"View full message?\")\n" +"if ans.lower()[0] == 'n':\n" +" sys.exit()\n" +"\n" +"# We can extract the richest alternative in order to display it:\n" +"richest = msg.get_body()\n" +"partfiles = {}\n" +"if richest['content-type'].maintype == 'text':\n" +" if richest['content-type'].subtype == 'plain':\n" +" for line in richest.get_content().splitlines():\n" +" print(line)\n" +" sys.exit()\n" +" elif richest['content-type'].subtype == 'html':\n" +" body = richest\n" +" else:\n" +" print(\"Don't know how to display {}" +"\".format(richest.get_content_type()))\n" +" sys.exit()\n" +"elif richest['content-type'].content_type == 'multipart/related':\n" +" body = richest.get_body(preferencelist=('html'))\n" +" for part in richest.iter_attachments():\n" +" fn = part.get_filename()\n" +" if fn:\n" +" extension = os.path.splitext(part.get_filename())[1]\n" +" else:\n" +" extension = mimetypes.guess_extension(part.get_content_type())\n" +" with tempfile.NamedTemporaryFile(suffix=extension, delete=False) as " +"f:\n" +" f.write(part.get_content())\n" +" # again strip the <> to go from email form of cid to html form.\n" +" partfiles[part['content-id'][1:-1]] = f.name\n" +"else:\n" +" print(\"Don't know how to display {}" +"\".format(richest.get_content_type()))\n" +" sys.exit()\n" +"with tempfile.NamedTemporaryFile(mode='w', delete=False) as f:\n" +" f.write(magic_html_parser(body.get_content(), partfiles))\n" +"webbrowser.open(f.name)\n" +"os.remove(f.name)\n" +"for fn in partfiles.values():\n" +" os.remove(fn)\n" +"\n" +"# Of course, there are lots of email messages that could break this simple\n" +"# minded program, but it will handle the most common ones.\n" +msgstr "" + #: library/email.examples.rst:52 msgid "Up to the prompt, the output from the above is:" msgstr "" +#: library/email.examples.rst:54 +msgid "" +"To: Penelope Pussycat , Fabrette Pussycat " +"\n" +"From: Pepé Le Pew \n" +"Subject: Ayons asperges pour le déjeuner\n" +"\n" +"Salut!\n" +"\n" +"Cela ressemble à un excellent recipie[1] déjeuner." +msgstr "" + #: library/email.examples.rst:66 msgid "Footnotes" msgstr "" diff --git a/library/email.generator.po b/library/email.generator.po index b655623c..91e35a34 100644 --- a/library/email.generator.po +++ b/library/email.generator.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.generator.rst:2 -msgid ":mod:`email.generator`: Generating MIME documents" +msgid ":mod:`!email.generator`: Generating MIME documents" msgstr "" #: library/email.generator.rst:7 @@ -28,10 +29,10 @@ msgstr "" msgid "" "One of the most common tasks is to generate the flat (serialized) version of " "the email message represented by a message object structure. You will need " -"to do this if you want to send your message via :meth:`smtplib.SMTP." -"sendmail` or the :mod:`nntplib` module, or print the message on the " -"console. Taking a message object structure and producing a serialized " -"representation is the job of the generator classes." +"to do this if you want to send your message " +"via :meth:`smtplib.SMTP.sendmail` or the :mod:`nntplib` module, or print the " +"message on the console. Taking a message object structure and producing a " +"serialized representation is the job of the generator classes." msgstr "" #: library/email.generator.rst:18 @@ -41,14 +42,14 @@ msgid "" "yourself. However the bundled generator knows how to generate most email in " "a standards-compliant way, should handle MIME and non-MIME email messages " "just fine, and is designed so that the bytes-oriented parsing and generation " -"operations are inverses, assuming the same non-transforming :mod:`~email." -"policy` is used for both. That is, parsing the serialized byte stream via " -"the :class:`~email.parser.BytesParser` class and then regenerating the " -"serialized byte stream using :class:`BytesGenerator` should produce output " -"identical to the input [#]_. (On the other hand, using the generator on an :" -"class:`~email.message.EmailMessage` constructed by program may result in " -"changes to the :class:`~email.message.EmailMessage` object as defaults are " -"filled in.)" +"operations are inverses, assuming the same non-" +"transforming :mod:`~email.policy` is used for both. That is, parsing the " +"serialized byte stream via the :class:`~email.parser.BytesParser` class and " +"then regenerating the serialized byte stream using :class:`BytesGenerator` " +"should produce output identical to the input [#]_. (On the other hand, " +"using the generator on an :class:`~email.message.EmailMessage` constructed " +"by program may result in changes to the :class:`~email.message.EmailMessage` " +"object as defaults are filled in.)" msgstr "" #: library/email.generator.rst:32 @@ -63,9 +64,9 @@ msgstr "" #: library/email.generator.rst:39 msgid "" -"To accommodate reproducible processing of SMIME-signed messages :class:" -"`Generator` disables header folding for message parts of type ``multipart/" -"signed`` and all subparts." +"To accommodate reproducible processing of SMIME-signed " +"messages :class:`Generator` disables header folding for message parts of " +"type ``multipart/signed`` and all subparts." msgstr "" #: library/email.generator.rst:47 @@ -82,11 +83,11 @@ msgid "" "any line in the body that starts with the exact string ``\"From \"``, that " "is ``From`` followed by a space at the beginning of a line. *mangle_from_* " "defaults to the value of the :attr:`~email.policy.Policy.mangle_from_` " -"setting of the *policy* (which is ``True`` for the :data:`~email.policy." -"compat32` policy and ``False`` for all others). *mangle_from_* is intended " -"for use when messages are stored in Unix mbox format (see :mod:`mailbox` and " -"`WHY THE CONTENT-LENGTH FORMAT IS BAD `_)." +"setting of the *policy* (which is ``True`` for " +"the :data:`~email.policy.compat32` policy and ``False`` for all others). " +"*mangle_from_* is intended for use when messages are stored in Unix mbox " +"format (see :mod:`mailbox` and `WHY THE CONTENT-LENGTH FORMAT IS BAD " +"`_)." msgstr "" #: library/email.generator.rst:163 @@ -100,10 +101,10 @@ msgstr "" #: library/email.generator.rst:168 msgid "" "If *policy* is specified, use that policy to control message generation. If " -"*policy* is ``None`` (the default), use the policy associated with the :" -"class:`~email.message.Message` or :class:`~email.message.EmailMessage` " -"object passed to ``flatten`` to control the message generation. See :mod:" -"`email.policy` for details on what *policy* controls." +"*policy* is ``None`` (the default), use the policy associated with " +"the :class:`~email.message.Message` or :class:`~email.message.EmailMessage` " +"object passed to ``flatten`` to control the message generation. " +"See :mod:`email.policy` for details on what *policy* controls." msgstr "" #: library/email.generator.rst:174 @@ -128,15 +129,15 @@ msgid "" "If the :mod:`~email.policy` option :attr:`~email.policy.Policy.cte_type` is " "``8bit`` (the default), copy any headers in the original parsed message that " "have not been modified to the output with any bytes with the high bit set " -"reproduced as in the original, and preserve the non-ASCII :mailheader:" -"`Content-Transfer-Encoding` of any body parts that have them. If " -"``cte_type`` is ``7bit``, convert the bytes with the high bit set as needed " -"using an ASCII-compatible :mailheader:`Content-Transfer-Encoding`. That is, " -"transform parts with non-ASCII :mailheader:`Content-Transfer-Encoding` (:" -"mailheader:`Content-Transfer-Encoding: 8bit`) to an ASCII compatible :" -"mailheader:`Content-Transfer-Encoding`, and encode RFC-invalid non-ASCII " -"bytes in headers using the MIME ``unknown-8bit`` character set, thus " -"rendering them RFC-compliant." +"reproduced as in the original, and preserve the non-" +"ASCII :mailheader:`Content-Transfer-Encoding` of any body parts that have " +"them. If ``cte_type`` is ``7bit``, convert the bytes with the high bit set " +"as needed using an ASCII-compatible :mailheader:`Content-Transfer-Encoding`. " +"That is, transform parts with non-ASCII :mailheader:`Content-Transfer-" +"Encoding` (:mailheader:`Content-Transfer-Encoding: 8bit`) to an ASCII " +"compatible :mailheader:`Content-Transfer-Encoding`, and encode RFC-invalid " +"non-ASCII bytes in headers using the MIME ``unknown-8bit`` character set, " +"thus rendering them RFC-compliant." msgstr "" #: library/email.generator.rst:104 library/email.generator.rst:197 @@ -164,28 +165,29 @@ msgstr "" #: library/email.generator.rst:125 msgid "" "Encode *s* using the ``ASCII`` codec and the ``surrogateescape`` error " -"handler, and pass it to the *write* method of the *outfp* passed to the :" -"class:`BytesGenerator`'s constructor." +"handler, and pass it to the *write* method of the *outfp* passed to " +"the :class:`BytesGenerator`'s constructor." msgstr "" #: library/email.generator.rst:130 msgid "" -"As a convenience, :class:`~email.message.EmailMessage` provides the methods :" -"meth:`~email.message.EmailMessage.as_bytes` and ``bytes(aMessage)`` (a.k.a. :" -"meth:`~email.message.EmailMessage.__bytes__`), which simplify the generation " -"of a serialized binary representation of a message object. For more detail, " -"see :mod:`email.message`." +"As a convenience, :class:`~email.message.EmailMessage` provides the " +"methods :meth:`~email.message.EmailMessage.as_bytes` and ``bytes(aMessage)`` " +"(a.k.a. :meth:`~email.message.EmailMessage.__bytes__`), which simplify the " +"generation of a serialized binary representation of a message object. For " +"more detail, see :mod:`email.message`." msgstr "" #: library/email.generator.rst:137 msgid "" "Because strings cannot represent binary data, the :class:`Generator` class " "must convert any binary data in any message it flattens to an ASCII " -"compatible format, by converting them to an ASCII compatible :mailheader:" -"`Content-Transfer_Encoding`. Using the terminology of the email RFCs, you " -"can think of this as :class:`Generator` serializing to an I/O stream that is " -"not \"8 bit clean\". In other words, most applications will want to be " -"using :class:`BytesGenerator`, and not :class:`Generator`." +"compatible format, by converting them to an ASCII " +"compatible :mailheader:`Content-Transfer_Encoding`. Using the terminology " +"of the email RFCs, you can think of this as :class:`Generator` serializing " +"to an I/O stream that is not \"8 bit clean\". In other words, most " +"applications will want to be using :class:`BytesGenerator`, and " +"not :class:`Generator`." msgstr "" #: library/email.generator.rst:148 @@ -208,12 +210,13 @@ msgid "" "If the :mod:`~email.policy` option :attr:`~email.policy.Policy.cte_type` is " "``8bit``, generate the message as if the option were set to ``7bit``. (This " "is required because strings cannot represent non-ASCII bytes.) Convert any " -"bytes with the high bit set as needed using an ASCII-compatible :mailheader:" -"`Content-Transfer-Encoding`. That is, transform parts with non-ASCII :" -"mailheader:`Content-Transfer-Encoding` (:mailheader:`Content-Transfer-" -"Encoding: 8bit`) to an ASCII compatible :mailheader:`Content-Transfer-" -"Encoding`, and encode RFC-invalid non-ASCII bytes in headers using the MIME " -"``unknown-8bit`` character set, thus rendering them RFC-compliant." +"bytes with the high bit set as needed using an ASCII-" +"compatible :mailheader:`Content-Transfer-Encoding`. That is, transform " +"parts with non-ASCII :mailheader:`Content-Transfer-Encoding` " +"(:mailheader:`Content-Transfer-Encoding: 8bit`) to an ASCII " +"compatible :mailheader:`Content-Transfer-Encoding`, and encode RFC-invalid " +"non-ASCII bytes in headers using the MIME ``unknown-8bit`` character set, " +"thus rendering them RFC-compliant." msgstr "" #: library/email.generator.rst:209 @@ -230,35 +233,36 @@ msgstr "" #: library/email.generator.rst:222 msgid "" -"Write *s* to the *write* method of the *outfp* passed to the :class:" -"`Generator`'s constructor. This provides just enough file-like API for :" -"class:`Generator` instances to be used in the :func:`print` function." +"Write *s* to the *write* method of the *outfp* passed to " +"the :class:`Generator`'s constructor. This provides just enough file-like " +"API for :class:`Generator` instances to be used in the :func:`print` " +"function." msgstr "" #: library/email.generator.rst:228 msgid "" -"As a convenience, :class:`~email.message.EmailMessage` provides the methods :" -"meth:`~email.message.EmailMessage.as_string` and ``str(aMessage)`` (a.k.a. :" -"meth:`~email.message.EmailMessage.__str__`), which simplify the generation " -"of a formatted string representation of a message object. For more detail, " -"see :mod:`email.message`." +"As a convenience, :class:`~email.message.EmailMessage` provides the " +"methods :meth:`~email.message.EmailMessage.as_string` and ``str(aMessage)`` " +"(a.k.a. :meth:`~email.message.EmailMessage.__str__`), which simplify the " +"generation of a formatted string representation of a message object. For " +"more detail, see :mod:`email.message`." msgstr "" #: library/email.generator.rst:235 msgid "" -"The :mod:`email.generator` module also provides a derived class, :class:" -"`DecodedGenerator`, which is like the :class:`Generator` base class, except " -"that non-\\ :mimetype:`text` parts are not serialized, but are instead " -"represented in the output stream by a string derived from a template filled " -"in with information about the part." +"The :mod:`email.generator` module also provides a derived " +"class, :class:`DecodedGenerator`, which is like the :class:`Generator` base " +"class, except that non-\\ :mimetype:`text` parts are not serialized, but are " +"instead represented in the output stream by a string derived from a template " +"filled in with information about the part." msgstr "" #: library/email.generator.rst:244 msgid "" "Act like :class:`Generator`, except that for any subpart of the message " -"passed to :meth:`Generator.flatten`, if the subpart is of main type :" -"mimetype:`text`, print the decoded payload of the subpart, and if the main " -"type is not :mimetype:`text`, instead of printing it fill in the string " +"passed to :meth:`Generator.flatten`, if the subpart is of main " +"type :mimetype:`text`, print the decoded payload of the subpart, and if the " +"main type is not :mimetype:`text`, instead of printing it fill in the string " "*fmt* using information from the part and print the resulting filled-in " "string." msgstr "" @@ -307,8 +311,8 @@ msgstr "" #: library/email.generator.rst:270 msgid "" -"Optional *_mangle_from_* and *maxheaderlen* are as with the :class:" -"`Generator` base class." +"Optional *_mangle_from_* and *maxheaderlen* are as with " +"the :class:`Generator` base class." msgstr "" #: library/email.generator.rst:275 @@ -319,10 +323,10 @@ msgstr "" msgid "" "This statement assumes that you use the appropriate setting for " "``unixfrom``, and that there are no :mod:`email.policy` settings calling for " -"automatic adjustments (for example, :attr:`~email.policy.EmailPolicy." -"refold_source` must be ``none``, which is *not* the default). It is also " -"not 100% true, since if the message does not conform to the RFC standards " -"occasionally information about the exact original text is lost during " -"parsing error recovery. It is a goal to fix these latter edge cases when " -"possible." +"automatic adjustments (for " +"example, :attr:`~email.policy.EmailPolicy.refold_source` must be ``none``, " +"which is *not* the default). It is also not 100% true, since if the message " +"does not conform to the RFC standards occasionally information about the " +"exact original text is lost during parsing error recovery. It is a goal to " +"fix these latter edge cases when possible." msgstr "" diff --git a/library/email.header.po b/library/email.header.po index f607a0e3..3b378b9f 100644 --- a/library/email.header.po +++ b/library/email.header.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.header.rst:2 -msgid ":mod:`email.header`: Internationalized headers" +msgid ":mod:`!email.header`: Internationalized headers" msgstr "" #: library/email.header.rst:7 @@ -56,19 +57,31 @@ msgid "" "used in email messages. The base standard still requires email messages to " "be transferred using only 7-bit ASCII characters, so a slew of RFCs have " "been written describing how to encode email containing non-ASCII characters " -"into :rfc:`2822`\\ -compliant format. These RFCs include :rfc:`2045`, :rfc:" -"`2046`, :rfc:`2047`, and :rfc:`2231`. The :mod:`email` package supports " -"these standards in its :mod:`email.header` and :mod:`email.charset` modules." +"into :rfc:`2822`\\ -compliant format. These RFCs " +"include :rfc:`2045`, :rfc:`2046`, :rfc:`2047`, and :rfc:`2231`. " +"The :mod:`email` package supports these standards in its :mod:`email.header` " +"and :mod:`email.charset` modules." msgstr "" #: library/email.header.rst:33 msgid "" "If you want to include non-ASCII characters in your email headers, say in " -"the :mailheader:`Subject` or :mailheader:`To` fields, you should use the :" -"class:`Header` class and assign the field in the :class:`~email.message." -"Message` object to an instance of :class:`Header` instead of using a string " -"for the header value. Import the :class:`Header` class from the :mod:`email." -"header` module. For example::" +"the :mailheader:`Subject` or :mailheader:`To` fields, you should use " +"the :class:`Header` class and assign the field in " +"the :class:`~email.message.Message` object to an instance of :class:`Header` " +"instead of using a string for the header value. Import the :class:`Header` " +"class from the :mod:`email.header` module. For example::" +msgstr "" + +#: library/email.header.rst:40 +msgid "" +">>> from email.message import Message\n" +">>> from email.header import Header\n" +">>> msg = Message()\n" +">>> h = Header('p\\xf6stal', 'iso-8859-1')\n" +">>> msg['Subject'] = h\n" +">>> msg.as_string()\n" +"'Subject: =?iso-8859-1?q?p=F6stal?=\\n\\n'" msgstr "" #: library/email.header.rst:50 @@ -76,9 +89,10 @@ msgid "" "Notice here how we wanted the :mailheader:`Subject` field to contain a non-" "ASCII character? We did this by creating a :class:`Header` instance and " "passing in the character set that the byte string was encoded in. When the " -"subsequent :class:`~email.message.Message` instance was flattened, the :" -"mailheader:`Subject` field was properly :rfc:`2047` encoded. MIME-aware " -"mail readers would show this header using the embedded ISO-8859-1 character." +"subsequent :class:`~email.message.Message` instance was flattened, " +"the :mailheader:`Subject` field was properly :rfc:`2047` encoded. MIME-" +"aware mail readers would show this header using the embedded ISO-8859-1 " +"character." msgstr "" #: library/email.header.rst:57 @@ -94,9 +108,9 @@ msgstr "" #: library/email.header.rst:65 msgid "" "Optional *s* is the initial header value. If ``None`` (the default), the " -"initial header value is not set. You can later append to the header with :" -"meth:`append` method calls. *s* may be an instance of :class:`bytes` or :" -"class:`str`, but see the :meth:`append` documentation for semantics." +"initial header value is not set. You can later append to the header " +"with :meth:`append` method calls. *s* may be an instance of :class:`bytes` " +"or :class:`str`, but see the :meth:`append` documentation for semantics." msgstr "" #: library/email.header.rst:70 @@ -114,7 +128,7 @@ msgid "" "The maximum line length can be specified explicitly via *maxlinelen*. For " "splitting the first line to a shorter value (to account for the field header " "which isn't included in *s*, e.g. :mailheader:`Subject`) pass in the name of " -"the field in *header_name*. The default *maxlinelen* is 76, and the default " +"the field in *header_name*. The default *maxlinelen* is 78, and the default " "value for *header_name* is ``None``, meaning it is not taken into account " "for the first line of a long, split header." msgstr "" @@ -161,9 +175,9 @@ msgstr "" #: library/email.header.rst:110 msgid "" -"In either case, when producing an :rfc:`2822`\\ -compliant header using :rfc:" -"`2047` rules, the string will be encoded using the output codec of the " -"charset. If the string cannot be encoded using the output codec, a " +"In either case, when producing an :rfc:`2822`\\ -compliant header " +"using :rfc:`2047` rules, the string will be encoded using the output codec " +"of the charset. If the string cannot be encoded using the output codec, a " "UnicodeError will be raised." msgstr "" @@ -265,10 +279,17 @@ msgstr "" msgid "Here's an example::" msgstr "" +#: library/email.header.rst:188 +msgid "" +">>> from email.header import decode_header\n" +">>> decode_header('=?iso-8859-1?q?p=F6stal?=')\n" +"[(b'p\\xf6stal', 'iso-8859-1')]" +msgstr "" + #: library/email.header.rst:195 msgid "" -"Create a :class:`Header` instance from a sequence of pairs as returned by :" -"func:`decode_header`." +"Create a :class:`Header` instance from a sequence of pairs as returned " +"by :func:`decode_header`." msgstr "" #: library/email.header.rst:198 @@ -280,7 +301,7 @@ msgstr "" #: library/email.header.rst:202 msgid "" -"This function takes one of those sequence of pairs and returns a :class:" -"`Header` instance. Optional *maxlinelen*, *header_name*, and " +"This function takes one of those sequence of pairs and returns " +"a :class:`Header` instance. Optional *maxlinelen*, *header_name*, and " "*continuation_ws* are as in the :class:`Header` constructor." msgstr "" diff --git a/library/email.headerregistry.po b/library/email.headerregistry.po index 6343fade..d3a37fab 100644 --- a/library/email.headerregistry.po +++ b/library/email.headerregistry.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.headerregistry.rst:2 -msgid ":mod:`email.headerregistry`: Custom Header Objects" +msgid ":mod:`!email.headerregistry`: Custom Header Objects" msgstr "" #: library/email.headerregistry.rst:10 @@ -31,42 +32,44 @@ msgstr "" #: library/email.headerregistry.rst:16 msgid "" "Headers are represented by customized subclasses of :class:`str`. The " -"particular class used to represent a given header is determined by the :attr:" -"`~email.policy.EmailPolicy.header_factory` of the :mod:`~email.policy` in " -"effect when the headers are created. This section documents the particular " -"``header_factory`` implemented by the email package for handling :RFC:`5322` " -"compliant email messages, which not only provides customized header objects " -"for various header types, but also provides an extension mechanism for " -"applications to add their own custom header types." +"particular class used to represent a given header is determined by " +"the :attr:`~email.policy.EmailPolicy.header_factory` of " +"the :mod:`~email.policy` in effect when the headers are created. This " +"section documents the particular ``header_factory`` implemented by the email " +"package for handling :RFC:`5322` compliant email messages, which not only " +"provides customized header objects for various header types, but also " +"provides an extension mechanism for applications to add their own custom " +"header types." msgstr "" #: library/email.headerregistry.rst:25 msgid "" -"When using any of the policy objects derived from :data:`~email.policy." -"EmailPolicy`, all headers are produced by :class:`.HeaderRegistry` and have :" -"class:`.BaseHeader` as their last base class. Each header class has an " -"additional base class that is determined by the type of the header. For " -"example, many headers have the class :class:`.UnstructuredHeader` as their " -"other base class. The specialized second class for a header is determined " -"by the name of the header, using a lookup table stored in the :class:`." -"HeaderRegistry`. All of this is managed transparently for the typical " -"application program, but interfaces are provided for modifying the default " -"behavior for use by more complex applications." +"When using any of the policy objects derived " +"from :data:`~email.policy.EmailPolicy`, all headers are produced " +"by :class:`.HeaderRegistry` and have :class:`.BaseHeader` as their last base " +"class. Each header class has an additional base class that is determined by " +"the type of the header. For example, many headers have the " +"class :class:`.UnstructuredHeader` as their other base class. The " +"specialized second class for a header is determined by the name of the " +"header, using a lookup table stored in the :class:`.HeaderRegistry`. All of " +"this is managed transparently for the typical application program, but " +"interfaces are provided for modifying the default behavior for use by more " +"complex applications." msgstr "" #: library/email.headerregistry.rst:36 msgid "" "The sections below first document the header base classes and their " -"attributes, followed by the API for modifying the behavior of :class:`." -"HeaderRegistry`, and finally the support classes used to represent the data " -"parsed from structured headers." +"attributes, followed by the API for modifying the behavior " +"of :class:`.HeaderRegistry`, and finally the support classes used to " +"represent the data parsed from structured headers." msgstr "" #: library/email.headerregistry.rst:44 msgid "" -"*name* and *value* are passed to ``BaseHeader`` from the :attr:`~email." -"policy.EmailPolicy.header_factory` call. The string value of any header " -"object is the *value* fully decoded to unicode." +"*name* and *value* are passed to ``BaseHeader`` from " +"the :attr:`~email.policy.EmailPolicy.header_factory` call. The string value " +"of any header object is the *value* fully decoded to unicode." msgstr "" #: library/email.headerregistry.rst:48 @@ -76,8 +79,9 @@ msgstr "" #: library/email.headerregistry.rst:53 msgid "" "The name of the header (the portion of the field before the ':'). This is " -"exactly the value passed in the :attr:`~email.policy.EmailPolicy." -"header_factory` call for *name*; that is, case is preserved." +"exactly the value passed in " +"the :attr:`~email.policy.EmailPolicy.header_factory` call for *name*; that " +"is, case is preserved." msgstr "" #: library/email.headerregistry.rst:61 @@ -106,11 +110,11 @@ msgstr "" #: library/email.headerregistry.rst:80 msgid "" "Return a string containing :attr:`~email.policy.Policy.linesep` characters " -"as required to correctly fold the header according to *policy*. A :attr:" -"`~email.policy.Policy.cte_type` of ``8bit`` will be treated as if it were " -"``7bit``, since headers may not contain arbitrary binary data. If :attr:" -"`~email.policy.EmailPolicy.utf8` is ``False``, non-ASCII data will be :rfc:" -"`2047` encoded." +"as required to correctly fold the header according to *policy*. " +"A :attr:`~email.policy.Policy.cte_type` of ``8bit`` will be treated as if it " +"were ``7bit``, since headers may not contain arbitrary binary data. " +"If :attr:`~email.policy.EmailPolicy.utf8` is ``False``, non-ASCII data will " +"be :rfc:`2047` encoded." msgstr "" #: library/email.headerregistry.rst:88 @@ -122,6 +126,10 @@ msgid "" "method is called as follows::" msgstr "" +#: library/email.headerregistry.rst:94 +msgid "parse(string, kwds)" +msgstr "" + #: library/email.headerregistry.rst:96 msgid "" "``kwds`` is a dictionary containing one pre-initialized key, ``defects``. " @@ -143,6 +151,13 @@ msgid "" "``BaseHeader`` itself. Such an ``init`` method should look like this::" msgstr "" +#: library/email.headerregistry.rst:110 +msgid "" +"def init(self, /, *args, **kw):\n" +" self._myattr = kw.pop('myattr')\n" +" super().init(*args, **kw)" +msgstr "" + #: library/email.headerregistry.rst:114 msgid "" "That is, anything extra that the specialized class puts in to the ``kwds`` " @@ -193,10 +208,11 @@ msgid "" "another, this attribute will contain a :class:`~datetime.datetime` instance " "representing that date. If the timezone of the input date is specified as " "``-0000`` (indicating it is in UTC but contains no information about the " -"source timezone), then :attr:`.datetime` will be a naive :class:`~datetime." -"datetime`. If a specific timezone offset is found (including ``+0000``), " -"then :attr:`.datetime` will contain an aware ``datetime`` that uses :class:" -"`datetime.timezone` to record the timezone offset." +"source timezone), then :attr:`.datetime` will be a " +"naive :class:`~datetime.datetime`. If a specific timezone offset is found " +"(including ``+0000``), then :attr:`.datetime` will contain an aware " +"``datetime`` that uses :class:`datetime.timezone` to record the timezone " +"offset." msgstr "" #: library/email.headerregistry.rst:160 @@ -205,6 +221,10 @@ msgid "" "``datetime`` according to the :rfc:`5322` rules; that is, it is set to::" msgstr "" +#: library/email.headerregistry.rst:163 +msgid "email.utils.format_datetime(self.datetime)" +msgstr "" + #: library/email.headerregistry.rst:165 msgid "" "When creating a ``DateHeader``, *value* may be :class:`~datetime.datetime` " @@ -212,12 +232,20 @@ msgid "" "does what one would expect::" msgstr "" +#: library/email.headerregistry.rst:169 +msgid "msg['Date'] = datetime(2011, 7, 15, 21)" +msgstr "" + #: library/email.headerregistry.rst:171 msgid "" "Because this is a naive ``datetime`` it will be interpreted as a UTC " "timestamp, and the resulting value will have a timezone of ``-0000``. Much " -"more useful is to use the :func:`~email.utils.localtime` function from the :" -"mod:`~email.utils` module::" +"more useful is to use the :func:`~email.utils.localtime` function from " +"the :mod:`~email.utils` module::" +msgstr "" + +#: library/email.headerregistry.rst:176 +msgid "msg['Date'] = utils.localtime()" msgstr "" #: library/email.headerregistry.rst:178 @@ -323,8 +351,8 @@ msgstr "" #: library/email.headerregistry.rst:275 msgid "" -"A :class:`ParameterizedMIMEHeader` class that handles the :mailheader:" -"`Content-Type` header." +"A :class:`ParameterizedMIMEHeader` class that handles " +"the :mailheader:`Content-Type` header." msgstr "" #: library/email.headerregistry.rst:280 @@ -333,8 +361,8 @@ msgstr "" #: library/email.headerregistry.rst:289 msgid "" -"A :class:`ParameterizedMIMEHeader` class that handles the :mailheader:" -"`Content-Disposition` header." +"A :class:`ParameterizedMIMEHeader` class that handles " +"the :mailheader:`Content-Disposition` header." msgstr "" #: library/email.headerregistry.rst:294 @@ -361,7 +389,7 @@ msgid "" "class. When *use_default_map* is ``True`` (the default), the standard " "mapping of header names to classes is copied in to the registry during " "initialization. *base_class* is always the last class in the generated " -"class's ``__bases__`` list." +"class's :class:`~type.__bases__` list." msgstr "" #: library/email.headerregistry.rst:322 @@ -537,14 +565,22 @@ msgid "" "address is::" msgstr "" +#: library/email.headerregistry.rst:380 +msgid "[display_name] " +msgstr "" + #: library/email.headerregistry.rst:382 msgid "or::" msgstr "" +#: library/email.headerregistry.rst:384 +msgid "username@domain" +msgstr "" + #: library/email.headerregistry.rst:386 msgid "" -"where each part must conform to specific syntax rules spelled out in :rfc:" -"`5322`." +"where each part must conform to specific syntax rules spelled out " +"in :rfc:`5322`." msgstr "" #: library/email.headerregistry.rst:389 @@ -580,8 +616,8 @@ msgstr "" #: library/email.headerregistry.rst:418 msgid "" -"The ``str`` value of the object is the address quoted according to :rfc:" -"`5322` rules, but with no Content Transfer Encoding of any non-ASCII " +"The ``str`` value of the object is the address quoted according " +"to :rfc:`5322` rules, but with no Content Transfer Encoding of any non-ASCII " "characters." msgstr "" @@ -598,6 +634,10 @@ msgid "" "address group is::" msgstr "" +#: library/email.headerregistry.rst:432 +msgid "display_name: [address-list];" +msgstr "" + #: library/email.headerregistry.rst:434 msgid "" "As a convenience for processing lists of addresses that consist of a mixture " diff --git a/library/email.iterators.po b/library/email.iterators.po index cb4a18d2..6a64302c 100644 --- a/library/email.iterators.po +++ b/library/email.iterators.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.iterators.rst:2 -msgid ":mod:`email.iterators`: Iterators" +msgid ":mod:`!email.iterators`: Iterators" msgstr "" #: library/email.iterators.rst:7 @@ -26,10 +27,10 @@ msgstr "" #: library/email.iterators.rst:11 msgid "" -"Iterating over a message object tree is fairly easy with the :meth:`Message." -"walk ` method. The :mod:`email.iterators` " -"module provides some useful higher level iterations over message object " -"trees." +"Iterating over a message object tree is fairly easy with " +"the :meth:`Message.walk ` method. " +"The :mod:`email.iterators` module provides some useful higher level " +"iterations over message object trees." msgstr "" #: library/email.iterators.rst:19 @@ -44,8 +45,8 @@ msgstr "" #: library/email.iterators.rst:26 msgid "" -"Optional *decode* is passed through to :meth:`Message.get_payload `." +"Optional *decode* is passed through to :meth:`Message.get_payload " +"`." msgstr "" #: library/email.iterators.rst:32 @@ -79,6 +80,27 @@ msgid "" "structure. For example:" msgstr "" +#: library/email.iterators.rst:57 +msgid "" +">>> msg = email.message_from_file(somefile)\n" +">>> _structure(msg)\n" +"multipart/mixed\n" +" text/plain\n" +" text/plain\n" +" multipart/digest\n" +" message/rfc822\n" +" text/plain\n" +" message/rfc822\n" +" text/plain\n" +" message/rfc822\n" +" text/plain\n" +" message/rfc822\n" +" text/plain\n" +" message/rfc822\n" +" text/plain\n" +" text/plain" +msgstr "" + #: library/email.iterators.rst:81 msgid "" "Optional *fp* is a file-like object to print the output to. It must be " diff --git a/library/email.message.po b/library/email.message.po index 71ab6f44..85e35474 100644 --- a/library/email.message.po +++ b/library/email.message.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.message.rst:2 -msgid ":mod:`email.message`: Representing an email message" +msgid ":mod:`!email.message`: Representing an email message" msgstr "" #: library/email.message.rst:10 @@ -68,7 +69,7 @@ msgid "" "names, which must be ASCII values. The values of the dictionary are strings " "with some extra methods. Headers are stored and returned in case-preserving " "form, but field names are matched case-insensitively. The keys are ordered, " -"but unlike a real dict, there can be duplicates. Addtional methods are " +"but unlike a real dict, there can be duplicates. Additional methods are " "provided for working with headers that have duplicate keys." msgstr "" @@ -83,25 +84,25 @@ msgstr "" #: library/email.message.rst:55 msgid "" "If *policy* is specified use the rules it specifies to update and serialize " -"the representation of the message. If *policy* is not set, use the :class:" -"`~email.policy.default` policy, which follows the rules of the email RFCs " -"except for line endings (instead of the RFC mandated ``\\r\\n``, it uses the " -"Python standard ``\\n`` line endings). For more information see the :mod:" -"`~email.policy` documentation." +"the representation of the message. If *policy* is not set, use " +"the :class:`~email.policy.default` policy, which follows the rules of the " +"email RFCs except for line endings (instead of the RFC mandated ``\\r\\n``, " +"it uses the Python standard ``\\n`` line endings). For more information see " +"the :mod:`~email.policy` documentation." msgstr "" #: library/email.message.rst:64 msgid "" "Return the entire message flattened as a string. When optional *unixfrom* " "is true, the envelope header is included in the returned string. *unixfrom* " -"defaults to ``False``. For backward compatibility with the base :class:" -"`~email.message.Message` class *maxheaderlen* is accepted, but defaults to " -"``None``, which means that by default the line length is controlled by the :" -"attr:`~email.policy.Policy.max_line_length` of the policy. The *policy* " -"argument may be used to override the default policy obtained from the " -"message instance. This can be used to control some of the formatting " -"produced by the method, since the specified *policy* will be passed to the :" -"class:`~email.generator.Generator`." +"defaults to ``False``. For backward compatibility with the " +"base :class:`~email.message.Message` class *maxheaderlen* is accepted, but " +"defaults to ``None``, which means that by default the line length is " +"controlled by the :attr:`~email.policy.Policy.max_line_length` of the " +"policy. The *policy* argument may be used to override the default policy " +"obtained from the message instance. This can be used to control some of the " +"formatting produced by the method, since the specified *policy* will be " +"passed to the :class:`~email.generator.Generator`." msgstr "" #: library/email.message.rst:114 @@ -117,8 +118,9 @@ msgid "" "useful way to serialize messages in your application, especially if you are " "dealing with multiple messages. See :class:`email.generator.Generator` for " "a more flexible API for serializing messages. Note also that this method is " -"restricted to producing messages serialized as \"7 bit clean\" when :attr:" -"`~email.policy.EmailPolicy.utf8` is ``False``, which is the default." +"restricted to producing messages serialized as \"7 bit clean\" " +"when :attr:`~email.policy.EmailPolicy.utf8` is ``False``, which is the " +"default." msgstr "" #: library/email.message.rst:88 @@ -138,8 +140,8 @@ msgstr "" #: library/email.message.rst:99 msgid "" "the method was changed to use ``utf8=True``, thus producing an :rfc:`6531`-" -"like message representation, instead of being a direct alias for :meth:" -"`as_string`." +"like message representation, instead of being a direct alias " +"for :meth:`as_string`." msgstr "" #: library/email.message.rst:106 @@ -149,8 +151,8 @@ msgid "" "*unixfrom* defaults to ``False``. The *policy* argument may be used to " "override the default policy obtained from the message instance. This can be " "used to control some of the formatting produced by the method, since the " -"specified *policy* will be passed to the :class:`~email.generator." -"BytesGenerator`." +"specified *policy* will be passed to " +"the :class:`~email.generator.BytesGenerator`." msgstr "" #: library/email.message.rst:118 @@ -163,20 +165,20 @@ msgstr "" #: library/email.message.rst:127 msgid "" -"Equivalent to :meth:`.as_bytes()`. Allows ``bytes(msg)`` to produce a bytes " +"Equivalent to :meth:`.as_bytes`. Allows ``bytes(msg)`` to produce a bytes " "object containing the serialized message." msgstr "" #: library/email.message.rst:133 msgid "" -"Return ``True`` if the message's payload is a list of sub-\\ :class:" -"`EmailMessage` objects, otherwise return ``False``. When :meth:" -"`is_multipart` returns ``False``, the payload should be a string object " -"(which might be a CTE encoded binary payload). Note that :meth:" -"`is_multipart` returning ``True`` does not necessarily mean that \"msg." -"get_content_maintype() == 'multipart'\" will return the ``True``. For " -"example, ``is_multipart`` will return ``True`` when the :class:" -"`EmailMessage` is of type ``message/rfc822``." +"Return ``True`` if the message's payload is a list of sub-" +"\\ :class:`EmailMessage` objects, otherwise return ``False``. " +"When :meth:`is_multipart` returns ``False``, the payload should be a string " +"object (which might be a CTE encoded binary payload). Note " +"that :meth:`is_multipart` returning ``True`` does not necessarily mean that " +"\"msg.get_content_maintype() == 'multipart'\" will return the ``True``. For " +"example, ``is_multipart`` will return ``True`` when " +"the :class:`EmailMessage` is of type ``message/rfc822``." msgstr "" #: library/email.message.rst:145 @@ -228,11 +230,17 @@ msgid "" "Used for the ``in`` operator. For example::" msgstr "" +#: library/email.message.rst:185 +msgid "" +"if 'message-id' in myMessage:\n" +" print('Message-ID:', myMessage['message-id'])" +msgstr "" + #: library/email.message.rst:191 msgid "" "Return the value of the named header field. *name* does not include the " -"colon field separator. If the header is missing, ``None`` is returned; a :" -"exc:`KeyError` is never raised." +"colon field separator. If the header is missing, ``None`` is returned; " +"a :exc:`KeyError` is never raised." msgstr "" #: library/email.message.rst:195 @@ -262,6 +270,12 @@ msgid "" "present in the message with field name *name*, delete the field first, e.g.::" msgstr "" +#: library/email.message.rst:213 +msgid "" +"del msg['subject']\n" +"msg['subject'] = 'Python roolz!'" +msgstr "" + #: library/email.message.rst:216 msgid "" "If the :mod:`policy ` defines certain headers to be unique (as " @@ -295,9 +309,9 @@ msgstr "" #: library/email.message.rst:249 msgid "" -"Return the value of the named header field. This is identical to :meth:" -"`~object.__getitem__` except that optional *failobj* is returned if the " -"named header is missing (*failobj* defaults to ``None``)." +"Return the value of the named header field. This is identical " +"to :meth:`~object.__getitem__` except that optional *failobj* is returned if " +"the named header is missing (*failobj* defaults to ``None``)." msgstr "" #: library/email.message.rst:254 @@ -345,14 +359,28 @@ msgstr "" msgid "Here is an example::" msgstr "" +#: library/email.message.rst:289 +msgid "msg.add_header('Content-Disposition', 'attachment', filename='bud.gif')" +msgstr "" + #: library/email.message.rst:291 msgid "This will add a header that looks like ::" msgstr "" +#: library/email.message.rst:293 +msgid "Content-Disposition: attachment; filename=\"bud.gif\"" +msgstr "" + #: library/email.message.rst:295 msgid "An example of the extended interface with non-ASCII characters::" msgstr "" +#: library/email.message.rst:297 +msgid "" +"msg.add_header('Content-Disposition', 'attachment',\n" +" filename=('iso-8859-1', '', 'Fußballer.ppt'))" +msgstr "" + #: library/email.message.rst:303 msgid "" "Replace a header. Replace the first header found in the message that " @@ -362,22 +390,22 @@ msgstr "" #: library/email.message.rst:311 msgid "" -"Return the message's content type, coerced to lower case of the form :" -"mimetype:`maintype/subtype`. If there is no :mailheader:`Content-Type` " -"header in the message return the value returned by :meth:" -"`get_default_type`. If the :mailheader:`Content-Type` header is invalid, " -"return ``text/plain``." +"Return the message's content type, coerced to lower case of the " +"form :mimetype:`maintype/subtype`. If there is no :mailheader:`Content-" +"Type` header in the message return the value returned " +"by :meth:`get_default_type`. If the :mailheader:`Content-Type` header is " +"invalid, return ``text/plain``." msgstr "" #: library/email.message.rst:317 msgid "" -"(According to :rfc:`2045`, messages always have a default type, :meth:" -"`get_content_type` will always return a value. :rfc:`2045` defines a " -"message's default type to be :mimetype:`text/plain` unless it appears inside " -"a :mimetype:`multipart/digest` container, in which case it would be :" -"mimetype:`message/rfc822`. If the :mailheader:`Content-Type` header has an " -"invalid type specification, :rfc:`2045` mandates that the default type be :" -"mimetype:`text/plain`.)" +"(According to :rfc:`2045`, messages always have a default " +"type, :meth:`get_content_type` will always return a value. :rfc:`2045` " +"defines a message's default type to be :mimetype:`text/plain` unless it " +"appears inside a :mimetype:`multipart/digest` container, in which case it " +"would be :mimetype:`message/rfc822`. If the :mailheader:`Content-Type` " +"header has an invalid type specification, :rfc:`2045` mandates that the " +"default type be :mimetype:`text/plain`.)" msgstr "" #: library/email.message.rst:328 @@ -395,8 +423,8 @@ msgstr "" #: library/email.message.rst:340 msgid "" "Return the default content type. Most messages have a default content type " -"of :mimetype:`text/plain`, except for messages that are subparts of :" -"mimetype:`multipart/digest` containers. Such subparts have a default " +"of :mimetype:`text/plain`, except for messages that are subparts " +"of :mimetype:`multipart/digest` containers. Such subparts have a default " "content type of :mimetype:`message/rfc822`." msgstr "" @@ -415,8 +443,8 @@ msgid "" "already exists in the header, replace its value with *value*. When *header* " "is ``Content-Type`` (the default) and the header does not yet exist in the " "message, add it, set its value to :mimetype:`text/plain`, and append the new " -"parameter value. Optional *header* specifies an alternative header to :" -"mailheader:`Content-Type`." +"parameter value. Optional *header* specifies an alternative header " +"to :mailheader:`Content-Type`." msgstr "" #: library/email.message.rst:366 @@ -444,9 +472,9 @@ msgstr "" #: library/email.message.rst:380 msgid "" -"Note that existing parameter values of headers may be accessed through the :" -"attr:`~email.headerregistry.ParameterizedMIMEHeader.params` attribute of the " -"header value (for example, ``msg['Content-Type'].params['charset']``)." +"Note that existing parameter values of headers may be accessed through " +"the :attr:`~email.headerregistry.ParameterizedMIMEHeader.params` attribute " +"of the header value (for example, ``msg['Content-Type'].params['charset']``)." msgstr "" #: library/email.message.rst:384 @@ -489,10 +517,10 @@ msgstr "" #: library/email.message.rst:424 msgid "" -"Note that using this method is subtly different from deleting the old :" -"mailheader:`Content-Type` header and adding a new one with the new boundary " -"via :meth:`add_header`, because :meth:`set_boundary` preserves the order of " -"the :mailheader:`Content-Type` header in the list of headers." +"Note that using this method is subtly different from deleting the " +"old :mailheader:`Content-Type` header and adding a new one with the new " +"boundary via :meth:`add_header`, because :meth:`set_boundary` preserves the " +"order of the :mailheader:`Content-Type` header in the list of headers." msgstr "" #: library/email.message.rst:433 @@ -526,16 +554,16 @@ msgstr "" #: library/email.message.rst:456 msgid "" -"is_attachment is now a method instead of a property, for consistency with :" -"meth:`~email.message.Message.is_multipart`." +"is_attachment is now a method instead of a property, for consistency " +"with :meth:`~email.message.Message.is_multipart`." msgstr "" #: library/email.message.rst:463 msgid "" -"Return the lowercased value (without parameters) of the message's :" -"mailheader:`Content-Disposition` header if it has one, or ``None``. The " -"possible values for this method are *inline*, *attachment* or ``None`` if " -"the message follows :rfc:`2183`." +"Return the lowercased value (without parameters) of the " +"message's :mailheader:`Content-Disposition` header if it has one, or " +"``None``. The possible values for this method are *inline*, *attachment* or " +"``None`` if the message follows :rfc:`2183`." msgstr "" #: library/email.message.rst:471 @@ -558,6 +586,19 @@ msgid "" "message structure:" msgstr "" +#: library/email.message.rst:491 +msgid "" +">>> for part in msg.walk():\n" +"... print(part.get_content_type())\n" +"multipart/report\n" +"text/plain\n" +"message/delivery-status\n" +"text/plain\n" +"text/plain\n" +"message/rfc822\n" +"text/plain" +msgstr "" + #: library/email.message.rst:503 msgid "" "``walk`` iterates over the subparts of any part where :meth:`is_multipart` " @@ -566,6 +607,29 @@ msgid "" "``_structure`` debug helper function:" msgstr "" +#: library/email.message.rst:509 +msgid "" +">>> from email.iterators import _structure\n" +">>> for part in msg.walk():\n" +"... print(part.get_content_maintype() == 'multipart',\n" +"... part.is_multipart())\n" +"True True\n" +"False False\n" +"False True\n" +"False False\n" +"False False\n" +"False True\n" +"False False\n" +">>> _structure(msg)\n" +"multipart/report\n" +" text/plain\n" +" message/delivery-status\n" +" text/plain\n" +" text/plain\n" +" message/rfc822\n" +" text/plain" +msgstr "" + #: library/email.message.rst:531 msgid "" "Here the ``message`` parts are not ``multiparts``, but they do contain " @@ -637,8 +701,8 @@ msgid "" "Return an iterator over all of the immediate sub-parts of the message that " "are not candidate \"body\" parts. That is, skip the first occurrence of " "each of ``text/plain``, ``text/html``, ``multipart/related``, or ``multipart/" -"alternative`` (unless they are explicitly marked as attachments via :" -"mailheader:`Content-Disposition: attachment`), and return all remaining " +"alternative`` (unless they are explicitly marked as attachments " +"via :mailheader:`Content-Disposition: attachment`), and return all remaining " "parts. When applied directly to a ``multipart/related``, return an iterator " "over the all the related parts except the root part (ie: the part pointed to " "by the ``start`` parameter, or the first part if there is no ``start`` " @@ -650,8 +714,8 @@ msgstr "" #: library/email.message.rst:593 msgid "" "Return an iterator over all of the immediate sub-parts of the message, which " -"will be empty for a non-``multipart``. (See also :meth:`~email.message." -"EmailMessage.walk`.)" +"will be empty for a non-``multipart``. (See " +"also :meth:`~email.message.EmailMessage.walk`.)" msgstr "" #: library/email.message.rst:600 @@ -695,50 +759,52 @@ msgstr "" #: library/email.message.rst:638 msgid "" "Convert a non-``multipart``, a ``multipart/related``, or a ``multipart-" -"alternative`` into a ``multipart/mixed``, moving any existing :mailheader:" -"`Content-` headers and payload into a (new) first part of the " -"``multipart``. If *boundary* is specified, use it as the boundary string in " -"the multipart, otherwise leave the boundary to be automatically created when " -"it is needed (for example, when the message is serialized)." +"alternative`` into a ``multipart/mixed``, moving any " +"existing :mailheader:`Content-` headers and payload into a (new) first part " +"of the ``multipart``. If *boundary* is specified, use it as the boundary " +"string in the multipart, otherwise leave the boundary to be automatically " +"created when it is needed (for example, when the message is serialized)." msgstr "" #: library/email.message.rst:648 msgid "" "If the message is a ``multipart/related``, create a new message object, pass " -"all of the arguments to its :meth:`set_content` method, and :meth:`~email." -"message.Message.attach` it to the ``multipart``. If the message is a non-" -"``multipart``, call :meth:`make_related` and then proceed as above. If the " -"message is any other type of ``multipart``, raise a :exc:`TypeError`. If " -"*content_manager* is not specified, use the ``content_manager`` specified by " -"the current :mod:`~email.policy`. If the added part has no :mailheader:" -"`Content-Disposition` header, add one with the value ``inline``." +"all of the arguments to its :meth:`set_content` method, " +"and :meth:`~email.message.Message.attach` it to the ``multipart``. If the " +"message is a non-``multipart``, call :meth:`make_related` and then proceed " +"as above. If the message is any other type of ``multipart``, raise " +"a :exc:`TypeError`. If *content_manager* is not specified, use the " +"``content_manager`` specified by the current :mod:`~email.policy`. If the " +"added part has no :mailheader:`Content-Disposition` header, add one with the " +"value ``inline``." msgstr "" #: library/email.message.rst:661 msgid "" "If the message is a ``multipart/alternative``, create a new message object, " -"pass all of the arguments to its :meth:`set_content` method, and :meth:" -"`~email.message.Message.attach` it to the ``multipart``. If the message is " -"a non-``multipart`` or ``multipart/related``, call :meth:`make_alternative` " -"and then proceed as above. If the message is any other type of " -"``multipart``, raise a :exc:`TypeError`. If *content_manager* is not " -"specified, use the ``content_manager`` specified by the current :mod:`~email." -"policy`." +"pass all of the arguments to its :meth:`set_content` method, " +"and :meth:`~email.message.Message.attach` it to the ``multipart``. If the " +"message is a non-``multipart`` or ``multipart/related``, " +"call :meth:`make_alternative` and then proceed as above. If the message is " +"any other type of ``multipart``, raise a :exc:`TypeError`. If " +"*content_manager* is not specified, use the ``content_manager`` specified by " +"the current :mod:`~email.policy`." msgstr "" #: library/email.message.rst:673 msgid "" "If the message is a ``multipart/mixed``, create a new message object, pass " -"all of the arguments to its :meth:`set_content` method, and :meth:`~email." -"message.Message.attach` it to the ``multipart``. If the message is a non-" -"``multipart``, ``multipart/related``, or ``multipart/alternative``, call :" -"meth:`make_mixed` and then proceed as above. If *content_manager* is not " -"specified, use the ``content_manager`` specified by the current :mod:`~email." -"policy`. If the added part has no :mailheader:`Content-Disposition` header, " -"add one with the value ``attachment``. This method can be used both for " -"explicit attachments (:mailheader:`Content-Disposition: attachment`) and " -"``inline`` attachments (:mailheader:`Content-Disposition: inline`), by " -"passing appropriate options to the ``content_manager``." +"all of the arguments to its :meth:`set_content` method, " +"and :meth:`~email.message.Message.attach` it to the ``multipart``. If the " +"message is a non-``multipart``, ``multipart/related``, or ``multipart/" +"alternative``, call :meth:`make_mixed` and then proceed as above. If " +"*content_manager* is not specified, use the ``content_manager`` specified by " +"the current :mod:`~email.policy`. If the added part has " +"no :mailheader:`Content-Disposition` header, add one with the value " +"``attachment``. This method can be used both for explicit attachments " +"(:mailheader:`Content-Disposition: attachment`) and ``inline`` attachments " +"(:mailheader:`Content-Disposition: inline`), by passing appropriate options " +"to the ``content_manager``." msgstr "" #: library/email.message.rst:689 @@ -770,11 +836,12 @@ msgid "" "The *preamble* attribute contains this leading extra-armor text for MIME " "documents. When the :class:`~email.parser.Parser` discovers some text after " "the headers but before the first boundary string, it assigns this text to " -"the message's *preamble* attribute. When the :class:`~email.generator." -"Generator` is writing out the plain text representation of a MIME message, " -"and it finds the message has a *preamble* attribute, it will write this text " -"in the area between the headers and the first boundary. See :mod:`email." -"parser` and :mod:`email.generator` for details." +"the message's *preamble* attribute. When " +"the :class:`~email.generator.Generator` is writing out the plain text " +"representation of a MIME message, and it finds the message has a *preamble* " +"attribute, it will write this text in the area between the headers and the " +"first boundary. See :mod:`email.parser` and :mod:`email.generator` for " +"details." msgstr "" #: library/email.message.rst:720 @@ -800,10 +867,10 @@ msgstr "" #: library/email.message.rst:741 msgid "" -"This class represents a subpart of a MIME message. It is identical to :" -"class:`EmailMessage`, except that no :mailheader:`MIME-Version` headers are " -"added when :meth:`~EmailMessage.set_content` is called, since sub-parts do " -"not need their own :mailheader:`MIME-Version` headers." +"This class represents a subpart of a MIME message. It is identical " +"to :class:`EmailMessage`, except that no :mailheader:`MIME-Version` headers " +"are added when :meth:`~EmailMessage.set_content` is called, since sub-parts " +"do not need their own :mailheader:`MIME-Version` headers." msgstr "" #: library/email.message.rst:748 diff --git a/library/email.mime.po b/library/email.mime.po index 1b1e56aa..a7d8b4ca 100644 --- a/library/email.mime.po +++ b/library/email.mime.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.mime.rst:2 -msgid ":mod:`email.mime`: Creating email and MIME objects from scratch" +msgid ":mod:`!email.mime`: Creating email and MIME objects from scratch" msgstr "" #: library/email.mime.rst:7 @@ -38,17 +39,18 @@ msgid "" "text to a parser, which parses the text and returns the root message " "object. However you can also build a complete message structure from " "scratch, or even individual :class:`~email.message.Message` objects by " -"hand. In fact, you can also take an existing structure and add new :class:" -"`~email.message.Message` objects, move them around, etc. This makes a very " -"convenient interface for slicing-and-dicing MIME messages." +"hand. In fact, you can also take an existing structure and add " +"new :class:`~email.message.Message` objects, move them around, etc. This " +"makes a very convenient interface for slicing-and-dicing MIME messages." msgstr "" #: library/email.mime.rst:24 msgid "" -"You can create a new object structure by creating :class:`~email.message." -"Message` instances, adding attachments and all the appropriate headers " -"manually. For MIME messages though, the :mod:`email` package provides some " -"convenient subclasses to make things easier." +"You can create a new object structure by " +"creating :class:`~email.message.Message` instances, adding attachments and " +"all the appropriate headers manually. For MIME messages though, " +"the :mod:`email` package provides some convenient subclasses to make things " +"easier." msgstr "" #: library/email.mime.rst:29 @@ -61,8 +63,8 @@ msgstr "" #: library/email.mime.rst:37 msgid "" -"This is the base class for all the MIME-specific subclasses of :class:" -"`~email.message.Message`. Ordinarily you won't create instances " +"This is the base class for all the MIME-specific subclasses " +"of :class:`~email.message.Message`. Ordinarily you won't create instances " "specifically of :class:`MIMEBase`, although you could. :class:`MIMEBase` is " "provided primarily as a convenient base class for more specific MIME-aware " "subclasses." @@ -70,17 +72,19 @@ msgstr "" #: library/email.mime.rst:43 msgid "" -"*_maintype* is the :mailheader:`Content-Type` major type (e.g. :mimetype:" -"`text` or :mimetype:`image`), and *_subtype* is the :mailheader:`Content-" -"Type` minor type (e.g. :mimetype:`plain` or :mimetype:`gif`). *_params* is " -"a parameter key/value dictionary and is passed directly to :meth:`Message." -"add_header `." +"*_maintype* is the :mailheader:`Content-Type` major type " +"(e.g. :mimetype:`text` or :mimetype:`image`), and *_subtype* is " +"the :mailheader:`Content-Type` minor type (e.g. :mimetype:`plain` " +"or :mimetype:`gif`). *_params* is a parameter key/value dictionary and is " +"passed directly to :meth:`Message.add_header " +"`." msgstr "" #: library/email.mime.rst:49 msgid "" -"If *policy* is specified, (defaults to the :class:`compat32 ` policy) it will be passed to :class:`~email.message.Message`." +"If *policy* is specified, (defaults to the :class:`compat32 " +"` policy) it will be passed " +"to :class:`~email.message.Message`." msgstr "" #: library/email.mime.rst:53 @@ -103,9 +107,10 @@ msgstr "" msgid "" "A subclass of :class:`~email.mime.base.MIMEBase`, this is an intermediate " "base class for MIME messages that are not :mimetype:`multipart`. The " -"primary purpose of this class is to prevent the use of the :meth:`~email." -"message.Message.attach` method, which only makes sense for :mimetype:" -"`multipart` messages. If :meth:`~email.message.Message.attach` is called, " +"primary purpose of this class is to prevent the use of " +"the :meth:`~email.message.Message.attach` method, which only makes sense " +"for :mimetype:`multipart` messages. " +"If :meth:`~email.message.Message.attach` is called, " "a :exc:`~email.errors.MultipartConversionError` exception is raised." msgstr "" @@ -118,9 +123,9 @@ msgid "" "A subclass of :class:`~email.mime.base.MIMEBase`, this is an intermediate " "base class for MIME messages that are :mimetype:`multipart`. Optional " "*_subtype* defaults to :mimetype:`mixed`, but can be used to specify the " -"subtype of the message. A :mailheader:`Content-Type` header of :mimetype:" -"`multipart/_subtype` will be added to the message object. A :mailheader:" -"`MIME-Version` header will also be added." +"subtype of the message. A :mailheader:`Content-Type` header " +"of :mimetype:`multipart/_subtype` will be added to the message object. " +"A :mailheader:`MIME-Version` header will also be added." msgstr "" #: library/email.mime.rst:89 @@ -134,15 +139,15 @@ msgstr "" msgid "" "*_subparts* is a sequence of initial subparts for the payload. It must be " "possible to convert this sequence to a list. You can always attach new " -"subparts to the message by using the :meth:`Message.attach ` method." +"subparts to the message by using the :meth:`Message.attach " +"` method." msgstr "" #: library/email.mime.rst:131 library/email.mime.rst:200 #: library/email.mime.rst:254 msgid "" -"Optional *policy* argument defaults to :class:`compat32 `." +"Optional *policy* argument defaults to :class:`compat32 " +"`." msgstr "" #: library/email.mime.rst:100 @@ -158,10 +163,10 @@ msgstr "" #: library/email.mime.rst:115 msgid "" -"A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, the :class:" -"`MIMEApplication` class is used to represent MIME message objects of major " -"type :mimetype:`application`. *_data* contains the bytes for the raw " -"application data. Optional *_subtype* specifies the MIME subtype and " +"A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, " +"the :class:`MIMEApplication` class is used to represent MIME message objects " +"of major type :mimetype:`application`. *_data* contains the bytes for the " +"raw application data. Optional *_subtype* specifies the MIME subtype and " "defaults to :mimetype:`octet-stream`." msgstr "" @@ -169,12 +174,13 @@ msgstr "" msgid "" "Optional *_encoder* is a callable (i.e. function) which will perform the " "actual encoding of the data for transport. This callable takes one " -"argument, which is the :class:`MIMEApplication` instance. It should use :" -"meth:`~email.message.Message.get_payload` and :meth:`~email.message.Message." -"set_payload` to change the payload to encoded form. It should also add any :" -"mailheader:`Content-Transfer-Encoding` or other headers to the message " -"object as necessary. The default encoding is base64. See the :mod:`email." -"encoders` module for a list of the built-in encoders." +"argument, which is the :class:`MIMEApplication` instance. It should " +"use :meth:`~email.message.Message.get_payload` " +"and :meth:`~email.message.Message.set_payload` to change the payload to " +"encoded form. It should also add any :mailheader:`Content-Transfer-" +"Encoding` or other headers to the message object as necessary. The default " +"encoding is base64. See the :mod:`email.encoders` module for a list of the " +"built-in encoders." msgstr "" #: library/email.mime.rst:167 @@ -187,26 +193,27 @@ msgstr "" #: library/email.mime.rst:146 msgid "" -"A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, the :class:" -"`MIMEAudio` class is used to create MIME message objects of major type :" -"mimetype:`audio`. *_audiodata* contains the bytes for the raw audio data. " -"If this data can be decoded as au, wav, aiff, or aifc, then the subtype will " -"be automatically included in the :mailheader:`Content-Type` header. " -"Otherwise you can explicitly specify the audio subtype via the *_subtype* " -"argument. If the minor type could not be guessed and *_subtype* was not " -"given, then :exc:`TypeError` is raised." +"A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, " +"the :class:`MIMEAudio` class is used to create MIME message objects of major " +"type :mimetype:`audio`. *_audiodata* contains the bytes for the raw audio " +"data. If this data can be decoded as au, wav, aiff, or aifc, then the " +"subtype will be automatically included in the :mailheader:`Content-Type` " +"header. Otherwise you can explicitly specify the audio subtype via the " +"*_subtype* argument. If the minor type could not be guessed and *_subtype* " +"was not given, then :exc:`TypeError` is raised." msgstr "" #: library/email.mime.rst:155 msgid "" "Optional *_encoder* is a callable (i.e. function) which will perform the " "actual encoding of the audio data for transport. This callable takes one " -"argument, which is the :class:`MIMEAudio` instance. It should use :meth:" -"`~email.message.Message.get_payload` and :meth:`~email.message.Message." -"set_payload` to change the payload to encoded form. It should also add any :" -"mailheader:`Content-Transfer-Encoding` or other headers to the message " -"object as necessary. The default encoding is base64. See the :mod:`email." -"encoders` module for a list of the built-in encoders." +"argument, which is the :class:`MIMEAudio` instance. It should " +"use :meth:`~email.message.Message.get_payload` " +"and :meth:`~email.message.Message.set_payload` to change the payload to " +"encoded form. It should also add any :mailheader:`Content-Transfer-" +"Encoding` or other headers to the message object as necessary. The default " +"encoding is base64. See the :mod:`email.encoders` module for a list of the " +"built-in encoders." msgstr "" #: library/email.mime.rst:178 @@ -215,33 +222,34 @@ msgstr "" #: library/email.mime.rst:180 msgid "" -"A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, the :class:" -"`MIMEImage` class is used to create MIME message objects of major type :" -"mimetype:`image`. *_imagedata* contains the bytes for the raw image data. " -"If this data type can be detected (jpeg, png, gif, tiff, rgb, pbm, pgm, ppm, " -"rast, xbm, bmp, webp, and exr attempted), then the subtype will be " +"A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, " +"the :class:`MIMEImage` class is used to create MIME message objects of major " +"type :mimetype:`image`. *_imagedata* contains the bytes for the raw image " +"data. If this data type can be detected (jpeg, png, gif, tiff, rgb, pbm, " +"pgm, ppm, rast, xbm, bmp, webp, and exr attempted), then the subtype will be " "automatically included in the :mailheader:`Content-Type` header. Otherwise " "you can explicitly specify the image subtype via the *_subtype* argument. If " -"the minor type could not be guessed and *_subtype* was not given, then :exc:" -"`TypeError` is raised." +"the minor type could not be guessed and *_subtype* was not given, " +"then :exc:`TypeError` is raised." msgstr "" #: library/email.mime.rst:190 msgid "" "Optional *_encoder* is a callable (i.e. function) which will perform the " "actual encoding of the image data for transport. This callable takes one " -"argument, which is the :class:`MIMEImage` instance. It should use :meth:" -"`~email.message.Message.get_payload` and :meth:`~email.message.Message." -"set_payload` to change the payload to encoded form. It should also add any :" -"mailheader:`Content-Transfer-Encoding` or other headers to the message " -"object as necessary. The default encoding is base64. See the :mod:`email." -"encoders` module for a list of the built-in encoders." +"argument, which is the :class:`MIMEImage` instance. It should " +"use :meth:`~email.message.Message.get_payload` " +"and :meth:`~email.message.Message.set_payload` to change the payload to " +"encoded form. It should also add any :mailheader:`Content-Transfer-" +"Encoding` or other headers to the message object as necessary. The default " +"encoding is base64. See the :mod:`email.encoders` module for a list of the " +"built-in encoders." msgstr "" #: library/email.mime.rst:202 msgid "" -"*_params* are passed straight through to the :class:`~email.mime.base." -"MIMEBase` constructor." +"*_params* are passed straight through to " +"the :class:`~email.mime.base.MIMEBase` constructor." msgstr "" #: library/email.mime.rst:212 @@ -250,17 +258,17 @@ msgstr "" #: library/email.mime.rst:214 msgid "" -"A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, the :class:" -"`MIMEMessage` class is used to create MIME objects of main type :mimetype:" -"`message`. *_msg* is used as the payload, and must be an instance of class :" -"class:`~email.message.Message` (or a subclass thereof), otherwise a :exc:" -"`TypeError` is raised." +"A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, " +"the :class:`MIMEMessage` class is used to create MIME objects of main " +"type :mimetype:`message`. *_msg* is used as the payload, and must be an " +"instance of class :class:`~email.message.Message` (or a subclass thereof), " +"otherwise a :exc:`TypeError` is raised." msgstr "" #: library/email.mime.rst:220 msgid "" -"Optional *_subtype* sets the subtype of the message; it defaults to :" -"mimetype:`rfc822`." +"Optional *_subtype* sets the subtype of the message; it defaults " +"to :mimetype:`rfc822`." msgstr "" #: library/email.mime.rst:232 @@ -269,15 +277,15 @@ msgstr "" #: library/email.mime.rst:234 msgid "" -"A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, the :class:" -"`MIMEText` class is used to create MIME objects of major type :mimetype:" -"`text`. *_text* is the string for the payload. *_subtype* is the minor type " -"and defaults to :mimetype:`plain`. *_charset* is the character set of the " -"text and is passed as an argument to the :class:`~email.mime.nonmultipart." -"MIMENonMultipart` constructor; it defaults to ``us-ascii`` if the string " -"contains only ``ascii`` code points, and ``utf-8`` otherwise. The " -"*_charset* parameter accepts either a string or a :class:`~email.charset." -"Charset` instance." +"A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, " +"the :class:`MIMEText` class is used to create MIME objects of major " +"type :mimetype:`text`. *_text* is the string for the payload. *_subtype* is " +"the minor type and defaults to :mimetype:`plain`. *_charset* is the " +"character set of the text and is passed as an argument to " +"the :class:`~email.mime.nonmultipart.MIMENonMultipart` constructor; it " +"defaults to ``us-ascii`` if the string contains only ``ascii`` code points, " +"and ``utf-8`` otherwise. The *_charset* parameter accepts either a string " +"or a :class:`~email.charset.Charset` instance." msgstr "" #: library/email.mime.rst:244 diff --git a/library/email.parser.po b/library/email.parser.po index f728a717..73aa1974 100644 --- a/library/email.parser.po +++ b/library/email.parser.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.parser.rst:2 -msgid ":mod:`email.parser`: Parsing email messages" +msgid ":mod:`!email.parser`: Parsing email messages" msgstr "" #: library/email.parser.rst:7 @@ -42,35 +43,35 @@ msgid "" "root :class:`~email.message.EmailMessage` instance of the object structure. " "For simple, non-MIME messages the payload of this root object will likely be " "a string containing the text of the message. For MIME messages, the root " -"object will return ``True`` from its :meth:`~email.message.EmailMessage." -"is_multipart` method, and the subparts can be accessed via the payload " -"manipulation methods, such as :meth:`~email.message.EmailMessage.get_body`, :" -"meth:`~email.message.EmailMessage.iter_parts`, and :meth:`~email.message." -"EmailMessage.walk`." +"object will return ``True`` from " +"its :meth:`~email.message.EmailMessage.is_multipart` method, and the " +"subparts can be accessed via the payload manipulation methods, such " +"as :meth:`~email.message.EmailMessage.get_body`, :meth:`~email.message.EmailMessage.iter_parts`, " +"and :meth:`~email.message.EmailMessage.walk`." msgstr "" #: library/email.parser.rst:30 msgid "" -"There are actually two parser interfaces available for use, the :class:" -"`Parser` API and the incremental :class:`FeedParser` API. The :class:" -"`Parser` API is most useful if you have the entire text of the message in " -"memory, or if the entire message lives in a file on the file system. :class:" -"`FeedParser` is more appropriate when you are reading the message from a " -"stream which might block waiting for more input (such as reading an email " -"message from a socket). The :class:`FeedParser` can consume and parse the " -"message incrementally, and only returns the root object when you close the " -"parser." +"There are actually two parser interfaces available for use, " +"the :class:`Parser` API and the incremental :class:`FeedParser` API. " +"The :class:`Parser` API is most useful if you have the entire text of the " +"message in memory, or if the entire message lives in a file on the file " +"system. :class:`FeedParser` is more appropriate when you are reading the " +"message from a stream which might block waiting for more input (such as " +"reading an email message from a socket). The :class:`FeedParser` can " +"consume and parse the message incrementally, and only returns the root " +"object when you close the parser." msgstr "" #: library/email.parser.rst:39 msgid "" "Note that the parser can be extended in limited ways, and of course you can " "implement your own parser completely from scratch. All of the logic that " -"connects the :mod:`email` package's bundled parser and the :class:`~email." -"message.EmailMessage` class is embodied in the :class:`~email.policy.Policy` " -"class, so a custom parser can create message object trees any way it finds " -"necessary by implementing custom versions of the appropriate :class:`!" -"Policy` methods." +"connects the :mod:`email` package's bundled parser and " +"the :class:`~email.message.EmailMessage` class is embodied in " +"the :class:`~email.policy.Policy` class, so a custom parser can create " +"message object trees any way it finds necessary by implementing custom " +"versions of the appropriate :class:`!Policy` methods." msgstr "" #: library/email.parser.rst:49 @@ -82,11 +83,11 @@ msgid "" "The :class:`BytesFeedParser`, imported from the :mod:`email.feedparser` " "module, provides an API that is conducive to incremental parsing of email " "messages, such as would be necessary when reading the text of an email " -"message from a source that can block (such as a socket). The :class:" -"`BytesFeedParser` can of course be used to parse an email message fully " -"contained in a :term:`bytes-like object`, string, or file, but the :class:" -"`BytesParser` API may be more convenient for such use cases. The semantics " -"and results of the two parser APIs are identical." +"message from a source that can block (such as a socket). " +"The :class:`BytesFeedParser` can of course be used to parse an email message " +"fully contained in a :term:`bytes-like object`, string, or file, but " +"the :class:`BytesParser` API may be more convenient for such use cases. The " +"semantics and results of the two parser APIs are identical." msgstr "" #: library/email.parser.rst:60 @@ -96,10 +97,10 @@ msgid "" "to retrieve the root message object. The :class:`BytesFeedParser` is " "extremely accurate when parsing standards-compliant messages, and it does a " "very good job of parsing non-compliant messages, providing information about " -"how a message was deemed broken. It will populate a message object's :attr:" -"`~email.message.EmailMessage.defects` attribute with a list of any problems " -"it found in a message. See the :mod:`email.errors` module for the list of " -"defects that it can find." +"how a message was deemed broken. It will populate a message " +"object's :attr:`~email.message.EmailMessage.defects` attribute with a list " +"of any problems it found in a message. See the :mod:`email.errors` module " +"for the list of defects that it can find." msgstr "" #: library/email.parser.rst:70 @@ -109,21 +110,21 @@ msgstr "" #: library/email.parser.rst:75 msgid "" "Create a :class:`BytesFeedParser` instance. Optional *_factory* is a no-" -"argument callable; if not specified use the :attr:`~email.policy.Policy." -"message_factory` from the *policy*. Call *_factory* whenever a new message " -"object is needed." +"argument callable; if not specified use " +"the :attr:`~email.policy.Policy.message_factory` from the *policy*. Call " +"*_factory* whenever a new message object is needed." msgstr "" #: library/email.parser.rst:80 msgid "" "If *policy* is specified use the rules it specifies to update the " -"representation of the message. If *policy* is not set, use the :class:" -"`compat32 ` policy, which maintains backward " -"compatibility with the Python 3.2 version of the email package and provides :" -"class:`~email.message.Message` as the default factory. All other policies " -"provide :class:`~email.message.EmailMessage` as the default *_factory*. For " -"more information on what else *policy* controls, see the :mod:`~email." -"policy` documentation." +"representation of the message. If *policy* is not set, use " +"the :class:`compat32 ` policy, which maintains " +"backward compatibility with the Python 3.2 version of the email package and " +"provides :class:`~email.message.Message` as the default factory. All other " +"policies provide :class:`~email.message.EmailMessage` as the default " +"*_factory*. For more information on what else *policy* controls, see " +"the :mod:`~email.policy` documentation." msgstr "" #: library/email.parser.rst:145 @@ -158,10 +159,10 @@ msgstr "" #: library/email.parser.rst:116 msgid "" -"Works like :class:`BytesFeedParser` except that the input to the :meth:" -"`~BytesFeedParser.feed` method must be a string. This is of limited " -"utility, since the only way for such a message to be valid is for it to " -"contain only ASCII text or, if :attr:`~email.policy.Policy.utf8` is " +"Works like :class:`BytesFeedParser` except that the input to " +"the :meth:`~BytesFeedParser.feed` method must be a string. This is of " +"limited utility, since the only way for such a message to be valid is for it " +"to contain only ASCII text or, if :attr:`~email.policy.Policy.utf8` is " "``True``, no binary attachments." msgstr "" @@ -174,13 +175,13 @@ msgid "" "The :class:`BytesParser` class, imported from the :mod:`email.parser` " "module, provides an API that can be used to parse a message when the " "complete contents of the message are available in a :term:`bytes-like " -"object` or file. The :mod:`email.parser` module also provides :class:" -"`Parser` for parsing strings, and header-only parsers, :class:" -"`BytesHeaderParser` and :class:`HeaderParser`, which can be used if you're " -"only interested in the headers of the message. :class:`BytesHeaderParser` " -"and :class:`HeaderParser` can be much faster in these situations, since they " -"do not attempt to parse the message body, instead setting the payload to the " -"raw body." +"object` or file. The :mod:`email.parser` module also " +"provides :class:`Parser` for parsing strings, and header-only " +"parsers, :class:`BytesHeaderParser` and :class:`HeaderParser`, which can be " +"used if you're only interested in the headers of the " +"message. :class:`BytesHeaderParser` and :class:`HeaderParser` can be much " +"faster in these situations, since they do not attempt to parse the message " +"body, instead setting the payload to the raw body." msgstr "" #: library/email.parser.rst:141 @@ -203,8 +204,8 @@ msgstr "" #: library/email.parser.rst:156 msgid "" "Read all the data from the binary file-like object *fp*, parse the resulting " -"bytes, and return the message object. *fp* must support both the :meth:`~io." -"IOBase.readline` and the :meth:`~io.IOBase.read` methods." +"bytes, and return the message object. *fp* must support both " +"the :meth:`~io.IOBase.readline` and the :meth:`~io.IOBase.read` methods." msgstr "" #: library/email.parser.rst:161 @@ -214,8 +215,8 @@ msgid "" "and header continuation lines, optionally preceded by an envelope header. " "The header block is terminated either by the end of the data or by a blank " "line. Following the header block is the body of the message (which may " -"contain MIME-encoded subparts, including subparts with a :mailheader:" -"`Content-Transfer-Encoding` of ``8bit``)." +"contain MIME-encoded subparts, including subparts with " +"a :mailheader:`Content-Transfer-Encoding` of ``8bit``)." msgstr "" #: library/email.parser.rst:169 @@ -228,9 +229,9 @@ msgstr "" #: library/email.parser.rst:176 msgid "" "Similar to the :meth:`parse` method, except it takes a :term:`bytes-like " -"object` instead of a file-like object. Calling this method on a :term:" -"`bytes-like object` is equivalent to wrapping *bytes* in a :class:`~io." -"BytesIO` instance first and calling :meth:`parse`." +"object` instead of a file-like object. Calling this method on " +"a :term:`bytes-like object` is equivalent to wrapping *bytes* in " +"a :class:`~io.BytesIO` instance first and calling :meth:`parse`." msgstr "" #: library/email.parser.rst:221 @@ -263,16 +264,16 @@ msgstr "" #: library/email.parser.rst:210 msgid "" -"Other than the text mode requirement, this method operates like :meth:" -"`BytesParser.parse`." +"Other than the text mode requirement, this method operates " +"like :meth:`BytesParser.parse`." msgstr "" #: library/email.parser.rst:216 msgid "" "Similar to the :meth:`parse` method, except it takes a string object instead " "of a file-like object. Calling this method on a string is equivalent to " -"wrapping *text* in a :class:`~io.StringIO` instance first and calling :meth:" -"`parse`." +"wrapping *text* in a :class:`~io.StringIO` instance first and " +"calling :meth:`parse`." msgstr "" #: library/email.parser.rst:226 @@ -323,6 +324,12 @@ msgid "" "interactive Python prompt::" msgstr "" +#: library/email.parser.rst:286 +msgid "" +">>> import email\n" +">>> msg = email.message_from_bytes(myBytes) " +msgstr "" + #: library/email.parser.rst:291 msgid "Additional notes" msgstr "" @@ -335,37 +342,39 @@ msgstr "" msgid "" "Most non-\\ :mimetype:`multipart` type messages are parsed as a single " "message object with a string payload. These objects will return ``False`` " -"for :meth:`~email.message.EmailMessage.is_multipart`, and :meth:`~email." -"message.EmailMessage.iter_parts` will yield an empty list." +"for :meth:`~email.message.EmailMessage.is_multipart`, " +"and :meth:`~email.message.EmailMessage.iter_parts` will yield an empty list." msgstr "" #: library/email.parser.rst:300 msgid "" "All :mimetype:`multipart` type messages will be parsed as a container " "message object with a list of sub-message objects for their payload. The " -"outer container message will return ``True`` for :meth:`~email.message." -"EmailMessage.is_multipart`, and :meth:`~email.message.EmailMessage." -"iter_parts` will yield a list of subparts." +"outer container message will return ``True`` " +"for :meth:`~email.message.EmailMessage.is_multipart`, " +"and :meth:`~email.message.EmailMessage.iter_parts` will yield a list of " +"subparts." msgstr "" #: library/email.parser.rst:306 msgid "" -"Most messages with a content type of :mimetype:`message/\\*` (such as :" -"mimetype:`message/delivery-status` and :mimetype:`message/rfc822`) will also " -"be parsed as container object containing a list payload of length 1. Their :" -"meth:`~email.message.EmailMessage.is_multipart` method will return ``True``. " -"The single element yielded by :meth:`~email.message.EmailMessage.iter_parts` " -"will be a sub-message object." +"Most messages with a content type of :mimetype:`message/\\*` (such " +"as :mimetype:`message/delivery-status` and :mimetype:`message/rfc822`) will " +"also be parsed as container object containing a list payload of length 1. " +"Their :meth:`~email.message.EmailMessage.is_multipart` method will return " +"``True``. The single element yielded " +"by :meth:`~email.message.EmailMessage.iter_parts` will be a sub-message " +"object." msgstr "" #: library/email.parser.rst:313 msgid "" "Some non-standards-compliant messages may not be internally consistent about " -"their :mimetype:`multipart`\\ -edness. Such messages may have a :mailheader:" -"`Content-Type` header of type :mimetype:`multipart`, but their :meth:`~email." -"message.EmailMessage.is_multipart` method may return ``False``. If such " -"messages were parsed with the :class:`~email.parser.FeedParser`, they will " -"have an instance of the :class:`~email.errors." -"MultipartInvariantViolationDefect` class in their *defects* attribute list. " -"See :mod:`email.errors` for details." +"their :mimetype:`multipart`\\ -edness. Such messages may have " +"a :mailheader:`Content-Type` header of type :mimetype:`multipart`, but " +"their :meth:`~email.message.EmailMessage.is_multipart` method may return " +"``False``. If such messages were parsed with " +"the :class:`~email.parser.FeedParser`, they will have an instance of " +"the :class:`~email.errors.MultipartInvariantViolationDefect` class in their " +"*defects* attribute list. See :mod:`email.errors` for details." msgstr "" diff --git a/library/email.po b/library/email.po index cefe872b..c5977b53 100644 --- a/library/email.po +++ b/library/email.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.rst:2 -msgid ":mod:`email` --- An email and MIME handling package" +msgid ":mod:`!email` --- An email and MIME handling package" msgstr "" #: library/email.rst:11 @@ -27,12 +28,12 @@ msgstr "" #: library/email.rst:15 msgid "" "The :mod:`email` package is a library for managing email messages. It is " -"specifically *not* designed to do any sending of email messages to SMTP (:" -"rfc:`2821`), NNTP, or other servers; those are functions of modules such as :" -"mod:`smtplib` and :mod:`nntplib`. The :mod:`email` package attempts to be " -"as RFC-compliant as possible, supporting :rfc:`5322` and :rfc:`6532`, as " -"well as such MIME-related RFCs as :rfc:`2045`, :rfc:`2046`, :rfc:`2047`, :" -"rfc:`2183`, and :rfc:`2231`." +"specifically *not* designed to do any sending of email messages to SMTP " +"(:rfc:`2821`), NNTP, or other servers; those are functions of modules such " +"as :mod:`smtplib` and :mod:`nntplib`. The :mod:`email` package attempts to " +"be as RFC-compliant as possible, supporting :rfc:`5322` and :rfc:`6532`, as " +"well as such MIME-related RFCs " +"as :rfc:`2045`, :rfc:`2046`, :rfc:`2047`, :rfc:`2183`, and :rfc:`2231`." msgstr "" #: library/email.rst:23 @@ -51,35 +52,35 @@ msgid "" "to construct a new email, or to add or remove email subcomponents that " "themselves use the same object model interface. That is, following the " "nature of email messages and their MIME subcomponents, the email object " -"model is a tree structure of objects that all provide the :class:`~email." -"message.EmailMessage` API." +"model is a tree structure of objects that all provide " +"the :class:`~email.message.EmailMessage` API." msgstr "" #: library/email.rst:37 msgid "" "The other two major components of the package are the :mod:`~email.parser` " "and the :mod:`~email.generator`. The parser takes the serialized version of " -"an email message (a stream of bytes) and converts it into a tree of :class:" -"`~email.message.EmailMessage` objects. The generator takes an :class:" -"`~email.message.EmailMessage` and turns it back into a serialized byte " -"stream. (The parser and generator also handle streams of text characters, " -"but this usage is discouraged as it is too easy to end up with messages that " -"are not valid in one way or another.)" +"an email message (a stream of bytes) and converts it into a tree " +"of :class:`~email.message.EmailMessage` objects. The generator takes " +"an :class:`~email.message.EmailMessage` and turns it back into a serialized " +"byte stream. (The parser and generator also handle streams of text " +"characters, but this usage is discouraged as it is too easy to end up with " +"messages that are not valid in one way or another.)" msgstr "" #: library/email.rst:46 msgid "" -"The control component is the :mod:`~email.policy` module. Every :class:" -"`~email.message.EmailMessage`, every :mod:`~email.generator`, and every :mod:" -"`~email.parser` has an associated :mod:`~email.policy` object that controls " -"its behavior. Usually an application only needs to specify the policy when " -"an :class:`~email.message.EmailMessage` is created, either by directly " -"instantiating an :class:`~email.message.EmailMessage` to create a new " -"email, or by parsing an input stream using a :mod:`~email.parser`. But the " -"policy can be changed when the message is serialized using a :mod:`~email." -"generator`. This allows, for example, a generic email message to be parsed " -"from disk, but to serialize it using standard SMTP settings when sending it " -"to an email server." +"The control component is the :mod:`~email.policy` module. " +"Every :class:`~email.message.EmailMessage`, every :mod:`~email.generator`, " +"and every :mod:`~email.parser` has an associated :mod:`~email.policy` object " +"that controls its behavior. Usually an application only needs to specify " +"the policy when an :class:`~email.message.EmailMessage` is created, either " +"by directly instantiating an :class:`~email.message.EmailMessage` to create " +"a new email, or by parsing an input stream using a :mod:`~email.parser`. " +"But the policy can be changed when the message is serialized using " +"a :mod:`~email.generator`. This allows, for example, a generic email message " +"to be parsed from disk, but to serialize it using standard SMTP settings " +"when sending it to an email server." msgstr "" #: library/email.rst:58 @@ -103,22 +104,22 @@ msgstr "" msgid "" "The following sections describe the functionality of the :mod:`email` " "package. We start with the :mod:`~email.message` object model, which is the " -"primary interface an application will use, and follow that with the :mod:" -"`~email.parser` and :mod:`~email.generator` components. Then we cover the :" -"mod:`~email.policy` controls, which completes the treatment of the main " -"components of the library." +"primary interface an application will use, and follow that with " +"the :mod:`~email.parser` and :mod:`~email.generator` components. Then we " +"cover the :mod:`~email.policy` controls, which completes the treatment of " +"the main components of the library." msgstr "" #: library/email.rst:78 msgid "" "The next three sections cover the exceptions the package may raise and the " "defects (non-compliance with the RFCs) that the :mod:`~email.parser` may " -"detect. Then we cover the :mod:`~email.headerregistry` and the :mod:`~email." -"contentmanager` sub-components, which provide tools for doing more detailed " -"manipulation of headers and payloads, respectively. Both of these " -"components contain features relevant to consuming and producing non-trivial " -"messages, but also document their extensibility APIs, which will be of " -"interest to advanced applications." +"detect. Then we cover the :mod:`~email.headerregistry` and " +"the :mod:`~email.contentmanager` sub-components, which provide tools for " +"doing more detailed manipulation of headers and payloads, respectively. " +"Both of these components contain features relevant to consuming and " +"producing non-trivial messages, but also document their extensibility APIs, " +"which will be of interest to advanced applications." msgstr "" #: library/email.rst:87 @@ -130,20 +131,22 @@ msgstr "" #: library/email.rst:90 msgid "" "The foregoing represent the modern (unicode friendly) API of the email " -"package. The remaining sections, starting with the :class:`~email.message." -"Message` class, cover the legacy :data:`~email.policy.compat32` API that " -"deals much more directly with the details of how email messages are " -"represented. The :data:`~email.policy.compat32` API does *not* hide the " -"details of the RFCs from the application, but for applications that need to " -"operate at that level, they can be useful tools. This documentation is also " -"relevant for applications that are still using the :mod:`~email.policy." -"compat32` API for backward compatibility reasons." +"package. The remaining sections, starting with " +"the :class:`~email.message.Message` class, cover the " +"legacy :data:`~email.policy.compat32` API that deals much more directly with " +"the details of how email messages are represented. " +"The :data:`~email.policy.compat32` API does *not* hide the details of the " +"RFCs from the application, but for applications that need to operate at that " +"level, they can be useful tools. This documentation is also relevant for " +"applications that are still using the :mod:`~email.policy.compat32` API for " +"backward compatibility reasons." msgstr "" #: library/email.rst:100 msgid "" -"Docs reorganized and rewritten to promote the new :class:`~email.message." -"EmailMessage`/:class:`~email.policy.EmailPolicy` API." +"Docs reorganized and rewritten to promote the " +"new :class:`~email.message.EmailMessage`/:class:`~email.policy.EmailPolicy` " +"API." msgstr "" #: library/email.rst:105 @@ -154,7 +157,7 @@ msgstr "" msgid "Legacy API:" msgstr "" -#: library/email.rst:136 +#: library/email.rst:135 msgid "Module :mod:`smtplib`" msgstr "" @@ -162,7 +165,7 @@ msgstr "" msgid "SMTP (Simple Mail Transport Protocol) client" msgstr "" -#: library/email.rst:139 +#: library/email.rst:138 msgid "Module :mod:`poplib`" msgstr "" @@ -170,7 +173,7 @@ msgstr "" msgid "POP (Post Office Protocol) client" msgstr "" -#: library/email.rst:142 +#: library/email.rst:141 msgid "Module :mod:`imaplib`" msgstr "" @@ -178,7 +181,7 @@ msgstr "" msgid "IMAP (Internet Message Access Protocol) client" msgstr "" -#: library/email.rst:145 +#: library/email.rst:144 msgid "Module :mod:`nntplib`" msgstr "" @@ -186,7 +189,7 @@ msgstr "" msgid "NNTP (Net News Transport Protocol) client" msgstr "" -#: library/email.rst:148 +#: library/email.rst:147 msgid "Module :mod:`mailbox`" msgstr "" diff --git a/library/email.policy.po b/library/email.policy.po index 1afa593e..388eea3a 100644 --- a/library/email.policy.po +++ b/library/email.policy.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.policy.rst:2 -msgid ":mod:`email.policy`: Policy Objects" +msgid ":mod:`!email.policy`: Policy Objects" msgstr "" #: library/email.policy.rst:12 @@ -48,40 +49,41 @@ msgstr "" #: library/email.policy.rst:31 msgid "" "A :class:`Policy` object encapsulates a set of attributes and methods that " -"control the behavior of various components of the email package during use. :" -"class:`Policy` instances can be passed to various classes and methods in the " -"email package to alter the default behavior. The settable values and their " -"defaults are described below." +"control the behavior of various components of the email package during " +"use. :class:`Policy` instances can be passed to various classes and methods " +"in the email package to alter the default behavior. The settable values and " +"their defaults are described below." msgstr "" #: library/email.policy.rst:37 msgid "" "There is a default policy used by all classes in the email package. For all " "of the :mod:`~email.parser` classes and the related convenience functions, " -"and for the :class:`~email.message.Message` class, this is the :class:" -"`Compat32` policy, via its corresponding pre-defined instance :const:" -"`compat32`. This policy provides for complete backward compatibility (in " -"some cases, including bug compatibility) with the pre-Python3.3 version of " -"the email package." +"and for the :class:`~email.message.Message` class, this is " +"the :class:`Compat32` policy, via its corresponding pre-defined " +"instance :const:`compat32`. This policy provides for complete backward " +"compatibility (in some cases, including bug compatibility) with the pre-" +"Python3.3 version of the email package." msgstr "" #: library/email.policy.rst:44 msgid "" -"This default value for the *policy* keyword to :class:`~email.message." -"EmailMessage` is the :class:`EmailPolicy` policy, via its pre-defined " -"instance :data:`~default`." +"This default value for the *policy* keyword " +"to :class:`~email.message.EmailMessage` is the :class:`EmailPolicy` policy, " +"via its pre-defined instance :data:`~default`." msgstr "" #: library/email.policy.rst:48 msgid "" -"When a :class:`~email.message.Message` or :class:`~email.message." -"EmailMessage` object is created, it acquires a policy. If the message is " -"created by a :mod:`~email.parser`, a policy passed to the parser will be the " -"policy used by the message it creates. If the message is created by the " -"program, then the policy can be specified when it is created. When a " -"message is passed to a :mod:`~email.generator`, the generator uses the " -"policy from the message by default, but you can also pass a specific policy " -"to the generator that will override the one stored on the message object." +"When a :class:`~email.message.Message` " +"or :class:`~email.message.EmailMessage` object is created, it acquires a " +"policy. If the message is created by a :mod:`~email.parser`, a policy " +"passed to the parser will be the policy used by the message it creates. If " +"the message is created by the program, then the policy can be specified when " +"it is created. When a message is passed to a :mod:`~email.generator`, the " +"generator uses the policy from the message by default, but you can also pass " +"a specific policy to the generator that will override the one stored on the " +"message object." msgstr "" #: library/email.policy.rst:57 @@ -108,8 +110,8 @@ msgstr "" #: library/email.policy.rst:72 msgid "" ":class:`Policy` instances are immutable, but they can be cloned, accepting " -"the same keyword arguments as the class constructor and returning a new :" -"class:`Policy` instance that is a copy of the original but with the " +"the same keyword arguments as the class constructor and returning a " +"new :class:`Policy` instance that is a copy of the original but with the " "specified attributes values changed." msgstr "" @@ -120,6 +122,22 @@ msgid "" "system:" msgstr "" +#: library/email.policy.rst:92 +msgid "" +">>> from email import message_from_binary_file\n" +">>> from email.generator import BytesGenerator\n" +">>> from email import policy\n" +">>> from subprocess import Popen, PIPE\n" +">>> with open('mymsg.txt', 'rb') as f:\n" +"... msg = message_from_binary_file(f, policy=policy.default)\n" +"...\n" +">>> p = Popen(['sendmail', msg['To'].addresses[0]], stdin=PIPE)\n" +">>> g = BytesGenerator(p.stdin, policy=msg.policy.clone(linesep='\\r\\n'))\n" +">>> g.flatten(msg)\n" +">>> p.stdin.close()\n" +">>> rc = p.wait()" +msgstr "" + #: library/email.policy.rst:114 msgid "" "Here we are telling :class:`~email.generator.BytesGenerator` to use the RFC " @@ -137,6 +155,14 @@ msgid "" "line separators for the platform on which it is running::" msgstr "" +#: library/email.policy.rst:125 +msgid "" +">>> import os\n" +">>> with open('converted.txt', 'wb') as f:\n" +"... f.write(msg.as_bytes(policy=msg.policy.clone(linesep=os.linesep)))\n" +"17" +msgstr "" + #: library/email.policy.rst:130 msgid "" "Policy objects can also be combined using the addition operator, producing a " @@ -144,12 +170,31 @@ msgid "" "the summed objects::" msgstr "" +#: library/email.policy.rst:134 +msgid "" +">>> compat_SMTP = policy.compat32.clone(linesep='\\r\\n')\n" +">>> compat_strict = policy.compat32.clone(raise_on_defect=True)\n" +">>> compat_strict_SMTP = compat_SMTP + compat_strict" +msgstr "" + #: library/email.policy.rst:138 msgid "" "This operation is not commutative; that is, the order in which the objects " "are added matters. To illustrate::" msgstr "" +#: library/email.policy.rst:141 +msgid "" +">>> policy100 = policy.compat32.clone(max_line_length=100)\n" +">>> policy80 = policy.compat32.clone(max_line_length=80)\n" +">>> apolicy = policy100 + policy80\n" +">>> apolicy.max_line_length\n" +"80\n" +">>> apolicy = policy80 + policy100\n" +">>> apolicy.max_line_length\n" +"100" +msgstr "" + #: library/email.policy.rst:153 msgid "" "This is the :term:`abstract base class` for all policy classes. It provides " @@ -226,9 +271,9 @@ msgstr "" #: library/email.policy.rst:209 msgid "" -"If :const:`True`, any defects encountered will be raised as errors. If :" -"const:`False` (the default), defects will be passed to the :meth:" -"`register_defect` method." +"If :const:`True`, any defects encountered will be raised as errors. " +"If :const:`False` (the default), defects will be passed to " +"the :meth:`register_defect` method." msgstr "" #: library/email.policy.rst:216 @@ -241,50 +286,66 @@ msgstr "" #: library/email.policy.rst:226 msgid "" "A factory function for constructing a new empty message object. Used by the " -"parser when building messages. Defaults to ``None``, in which case :class:" -"`~email.message.Message` is used." +"parser when building messages. Defaults to ``None``, in which " +"case :class:`~email.message.Message` is used." +msgstr "" + +#: library/email.policy.rst:235 +msgid "" +"If ``True`` (the default), the generator will " +"raise :exc:`~email.errors.HeaderWriteError` instead of writing a header that " +"is improperly folded or delimited, such that it would be parsed as multiple " +"headers or joined with adjacent data. Such headers can be generated by " +"custom header classes or bugs in the ``email`` module." msgstr "" -#: library/email.policy.rst:232 +#: library/email.policy.rst:242 +msgid "" +"As it's a security feature, this defaults to ``True`` even in " +"the :class:`~email.policy.Compat32` policy. For backwards compatible, but " +"unsafe, behavior, it must be set to ``False`` explicitly." +msgstr "" + +#: library/email.policy.rst:250 msgid "" "The following :class:`Policy` method is intended to be called by code using " "the email library to create policy instances with custom settings:" msgstr "" -#: library/email.policy.rst:238 +#: library/email.policy.rst:256 msgid "" "Return a new :class:`Policy` instance whose attributes have the same values " "as the current instance, except where those attributes are given new values " "by the keyword arguments." msgstr "" -#: library/email.policy.rst:243 +#: library/email.policy.rst:261 msgid "" "The remaining :class:`Policy` methods are called by the email package code, " "and are not intended to be called by an application using the email package. " "A custom policy must implement all of these methods." msgstr "" -#: library/email.policy.rst:250 +#: library/email.policy.rst:268 msgid "" "Handle a *defect* found on *obj*. When the email package calls this method, " -"*defect* will always be a subclass of :class:`~email.errors.Defect`." +"*defect* will always be a subclass of :class:`~email.errors.MessageDefect`." msgstr "" -#: library/email.policy.rst:254 +#: library/email.policy.rst:272 msgid "" "The default implementation checks the :attr:`raise_on_defect` flag. If it " "is ``True``, *defect* is raised as an exception. If it is ``False`` (the " "default), *obj* and *defect* are passed to :meth:`register_defect`." msgstr "" -#: library/email.policy.rst:261 +#: library/email.policy.rst:279 msgid "" "Register a *defect* on *obj*. In the email package, *defect* will always be " -"a subclass of :class:`~email.errors.Defect`." +"a subclass of :class:`~email.errors.MessageDefect`." msgstr "" -#: library/email.policy.rst:264 +#: library/email.policy.rst:282 msgid "" "The default implementation calls the ``append`` method of the ``defects`` " "attribute of *obj*. When the email package calls :attr:`handle_defect`, " @@ -294,19 +355,20 @@ msgid "" "defects in parsed messages will raise unexpected errors." msgstr "" -#: library/email.policy.rst:274 +#: library/email.policy.rst:292 msgid "Return the maximum allowed number of headers named *name*." msgstr "" -#: library/email.policy.rst:276 +#: library/email.policy.rst:294 msgid "" -"Called when a header is added to an :class:`~email.message.EmailMessage` or :" -"class:`~email.message.Message` object. If the returned value is not ``0`` " -"or ``None``, and there are already a number of headers with the name *name* " -"greater than or equal to the value returned, a :exc:`ValueError` is raised." +"Called when a header is added to an :class:`~email.message.EmailMessage` " +"or :class:`~email.message.Message` object. If the returned value is not " +"``0`` or ``None``, and there are already a number of headers with the name " +"*name* greater than or equal to the value returned, a :exc:`ValueError` is " +"raised." msgstr "" -#: library/email.policy.rst:282 +#: library/email.policy.rst:300 msgid "" "Because the default behavior of ``Message.__setitem__`` is to append the " "value to the list of headers, it is easy to create duplicate headers without " @@ -316,11 +378,11 @@ msgid "" "faithfully produce as many headers as exist in the message being parsed.)" msgstr "" -#: library/email.policy.rst:290 +#: library/email.policy.rst:308 msgid "The default implementation returns ``None`` for all header names." msgstr "" -#: library/email.policy.rst:295 +#: library/email.policy.rst:313 msgid "" "The email package calls this method with a list of strings, each string " "ending with the line separation characters found in the source being " @@ -330,7 +392,7 @@ msgid "" "the parsed header." msgstr "" -#: library/email.policy.rst:302 +#: library/email.policy.rst:320 msgid "" "If an implementation wishes to retain compatibility with the existing email " "package policies, *name* should be the case preserved name (all characters " @@ -339,15 +401,15 @@ msgid "" "stripped of leading whitespace." msgstr "" -#: library/email.policy.rst:308 +#: library/email.policy.rst:326 msgid "*sourcelines* may contain surrogateescaped binary data." msgstr "" -#: library/email.policy.rst:326 library/email.policy.rst:342 +#: library/email.policy.rst:344 library/email.policy.rst:360 msgid "There is no default implementation" msgstr "" -#: library/email.policy.rst:315 +#: library/email.policy.rst:333 msgid "" "The email package calls this method with the name and value provided by the " "application program when the application program is modifying a ``Message`` " @@ -356,14 +418,14 @@ msgid "" "``Message`` to represent the header." msgstr "" -#: library/email.policy.rst:321 +#: library/email.policy.rst:339 msgid "" "If an implementation wishes to retain compatibility with the existing email " "package policies, the *name* and *value* should be strings or string " "subclasses that do not change the content of the passed in arguments." msgstr "" -#: library/email.policy.rst:331 +#: library/email.policy.rst:349 msgid "" "The email package calls this method with the *name* and *value* currently " "stored in the ``Message`` when that header is requested by the application " @@ -374,48 +436,48 @@ msgid "" "returned to the application." msgstr "" -#: library/email.policy.rst:339 +#: library/email.policy.rst:357 msgid "" "*value* may contain surrogateescaped binary data. There should be no " "surrogateescaped binary data in the value returned by the method." msgstr "" -#: library/email.policy.rst:347 +#: library/email.policy.rst:365 msgid "" "The email package calls this method with the *name* and *value* currently " "stored in the ``Message`` for a given header. The method should return a " "string that represents that header \"folded\" correctly (according to the " -"policy settings) by composing the *name* with the *value* and inserting :" -"attr:`linesep` characters at the appropriate places. See :rfc:`5322` for a " -"discussion of the rules for folding email headers." +"policy settings) by composing the *name* with the *value* and " +"inserting :attr:`linesep` characters at the appropriate places. " +"See :rfc:`5322` for a discussion of the rules for folding email headers." msgstr "" -#: library/email.policy.rst:354 +#: library/email.policy.rst:372 msgid "" "*value* may contain surrogateescaped binary data. There should be no " "surrogateescaped binary data in the string returned by the method." msgstr "" -#: library/email.policy.rst:360 +#: library/email.policy.rst:378 msgid "" "The same as :meth:`fold`, except that the returned value should be a bytes " "object rather than a string." msgstr "" -#: library/email.policy.rst:363 +#: library/email.policy.rst:381 msgid "" "*value* may contain surrogateescaped binary data. These could be converted " "back into binary data in the returned bytes object." msgstr "" -#: library/email.policy.rst:370 +#: library/email.policy.rst:388 msgid "" "This concrete :class:`Policy` provides behavior that is intended to be fully " "compliant with the current email RFCs. These include (but are not limited " "to) :rfc:`5322`, :rfc:`2047`, and the current MIME RFCs." msgstr "" -#: library/email.policy.rst:374 +#: library/email.policy.rst:392 msgid "" "This policy adds new header parsing and folding algorithms. Instead of " "simple strings, headers are ``str`` subclasses with attributes that depend " @@ -423,23 +485,23 @@ msgid "" "implement :rfc:`2047` and :rfc:`5322`." msgstr "" -#: library/email.policy.rst:379 +#: library/email.policy.rst:397 msgid "" "The default value for the :attr:`~email.policy.Policy.message_factory` " "attribute is :class:`~email.message.EmailMessage`." msgstr "" -#: library/email.policy.rst:382 +#: library/email.policy.rst:400 msgid "" "In addition to the settable attributes listed above that apply to all " "policies, this policy adds the following additional attributes:" msgstr "" -#: library/email.policy.rst:385 +#: library/email.policy.rst:403 msgid "[1]_" msgstr "" -#: library/email.policy.rst:390 +#: library/email.policy.rst:408 msgid "" "If ``False``, follow :rfc:`5322`, supporting non-ASCII characters in headers " "by encoding them as \"encoded words\". If ``True``, follow :rfc:`6532` and " @@ -447,45 +509,45 @@ msgid "" "passed to SMTP servers that support the ``SMTPUTF8`` extension (:rfc:`6531`)." msgstr "" -#: library/email.policy.rst:399 +#: library/email.policy.rst:417 msgid "" -"If the value for a header in the ``Message`` object originated from a :mod:" -"`~email.parser` (as opposed to being set by a program), this attribute " -"indicates whether or not a generator should refold that value when " +"If the value for a header in the ``Message`` object originated from " +"a :mod:`~email.parser` (as opposed to being set by a program), this " +"attribute indicates whether or not a generator should refold that value when " "transforming the message back into serialized form. The possible values are:" msgstr "" -#: library/email.policy.rst:406 +#: library/email.policy.rst:424 msgid "``none``" msgstr "" -#: library/email.policy.rst:406 +#: library/email.policy.rst:424 msgid "all source values use original folding" msgstr "" -#: library/email.policy.rst:408 +#: library/email.policy.rst:426 msgid "``long``" msgstr "" -#: library/email.policy.rst:408 +#: library/email.policy.rst:426 msgid "" "source values that have any line that is longer than ``max_line_length`` " "will be refolded" msgstr "" -#: library/email.policy.rst:411 +#: library/email.policy.rst:429 msgid "``all``" msgstr "" -#: library/email.policy.rst:411 +#: library/email.policy.rst:429 msgid "all values are refolded." msgstr "" -#: library/email.policy.rst:414 +#: library/email.policy.rst:432 msgid "The default is ``long``." msgstr "" -#: library/email.policy.rst:419 +#: library/email.policy.rst:437 msgid "" "A callable that takes two arguments, ``name`` and ``value``, where ``name`` " "is a header field name and ``value`` is an unfolded header field value, and " @@ -496,31 +558,32 @@ msgid "" "custom parsing will be added in the future." msgstr "" -#: library/email.policy.rst:430 +#: library/email.policy.rst:448 msgid "" -"An object with at least two methods: get_content and set_content. When the :" -"meth:`~email.message.EmailMessage.get_content` or :meth:`~email.message." -"EmailMessage.set_content` method of an :class:`~email.message.EmailMessage` " -"object is called, it calls the corresponding method of this object, passing " -"it the message object as its first argument, and any arguments or keywords " -"that were passed to it as additional arguments. By default " -"``content_manager`` is set to :data:`~email.contentmanager.raw_data_manager`." +"An object with at least two methods: get_content and set_content. When " +"the :meth:`~email.message.EmailMessage.get_content` " +"or :meth:`~email.message.EmailMessage.set_content` method of " +"an :class:`~email.message.EmailMessage` object is called, it calls the " +"corresponding method of this object, passing it the message object as its " +"first argument, and any arguments or keywords that were passed to it as " +"additional arguments. By default ``content_manager`` is set " +"to :data:`~email.contentmanager.raw_data_manager`." msgstr "" -#: library/email.policy.rst:600 +#: library/email.policy.rst:618 msgid "" "The class provides the following concrete implementations of the abstract " "methods of :class:`Policy`:" msgstr "" -#: library/email.policy.rst:448 +#: library/email.policy.rst:466 msgid "" "Returns the value of the :attr:`~email.headerregistry.BaseHeader.max_count` " "attribute of the specialized class used to represent the header with the " "given name." msgstr "" -#: library/email.policy.rst:606 +#: library/email.policy.rst:624 msgid "" "The name is parsed as everything up to the '``:``' and returned unmodified. " "The value is determined by stripping leading whitespace off the remainder of " @@ -528,7 +591,7 @@ msgid "" "trailing carriage return or linefeed characters." msgstr "" -#: library/email.policy.rst:464 +#: library/email.policy.rst:482 msgid "" "The name is returned unchanged. If the input value has a ``name`` attribute " "and it matches *name* ignoring case, the value is returned unchanged. " @@ -537,7 +600,7 @@ msgid "" "``ValueError`` is raised if the input value contains CR or LF characters." msgstr "" -#: library/email.policy.rst:474 +#: library/email.policy.rst:492 msgid "" "If the value has a ``name`` attribute, it is returned to unmodified. " "Otherwise the *name*, and the *value* with any CR or LF characters removed, " @@ -546,7 +609,7 @@ msgid "" "character glyph." msgstr "" -#: library/email.policy.rst:483 +#: library/email.policy.rst:501 msgid "" "Header folding is controlled by the :attr:`refold_source` policy setting. A " "value is considered to be a 'source value' if and only if it does not have a " @@ -558,7 +621,7 @@ msgid "" "current policy." msgstr "" -#: library/email.policy.rst:492 +#: library/email.policy.rst:510 msgid "" "Source values are split into lines using :meth:`~str.splitlines`. If the " "value is not to be refolded, the lines are rejoined using the ``linesep`` " @@ -568,13 +631,13 @@ msgid "" "using the ``unknown-8bit`` charset." msgstr "" -#: library/email.policy.rst:502 +#: library/email.policy.rst:520 msgid "" "The same as :meth:`fold` if :attr:`~Policy.cte_type` is ``7bit``, except " "that the returned value is bytes." msgstr "" -#: library/email.policy.rst:505 +#: library/email.policy.rst:523 msgid "" "If :attr:`~Policy.cte_type` is ``8bit``, non-ASCII binary data is converted " "back into bytes. Headers with binary data are not refolded, regardless of " @@ -582,7 +645,7 @@ msgid "" "binary data consists of single byte characters or multibyte characters." msgstr "" -#: library/email.policy.rst:512 +#: library/email.policy.rst:530 msgid "" "The following instances of :class:`EmailPolicy` provide defaults suitable " "for specific application domains. Note that in the future the behavior of " @@ -590,114 +653,119 @@ msgid "" "conform even more closely to the RFCs relevant to their domains." msgstr "" -#: library/email.policy.rst:520 +#: library/email.policy.rst:538 msgid "" "An instance of ``EmailPolicy`` with all defaults unchanged. This policy " "uses the standard Python ``\\n`` line endings rather than the RFC-correct " "``\\r\\n``." msgstr "" -#: library/email.policy.rst:527 +#: library/email.policy.rst:545 msgid "" "Suitable for serializing messages in conformance with the email RFCs. Like " "``default``, but with ``linesep`` set to ``\\r\\n``, which is RFC compliant." msgstr "" -#: library/email.policy.rst:534 +#: library/email.policy.rst:552 msgid "" "The same as ``SMTP`` except that :attr:`~EmailPolicy.utf8` is ``True``. " "Useful for serializing messages to a message store without using encoded " "words in the headers. Should only be used for SMTP transmission if the " -"sender or recipient addresses have non-ASCII characters (the :meth:`smtplib." -"SMTP.send_message` method handles this automatically)." +"sender or recipient addresses have non-ASCII characters " +"(the :meth:`smtplib.SMTP.send_message` method handles this automatically)." msgstr "" -#: library/email.policy.rst:543 +#: library/email.policy.rst:561 msgid "" "Suitable for serializing headers with for use in HTTP traffic. Like " "``SMTP`` except that ``max_line_length`` is set to ``None`` (unlimited)." msgstr "" -#: library/email.policy.rst:549 +#: library/email.policy.rst:567 msgid "" "Convenience instance. The same as ``default`` except that " "``raise_on_defect`` is set to ``True``. This allows any policy to be made " "strict by writing::" msgstr "" -#: library/email.policy.rst:556 +#: library/email.policy.rst:571 +msgid "somepolicy + policy.strict" +msgstr "" + +#: library/email.policy.rst:574 msgid "" "With all of these :class:`EmailPolicies <.EmailPolicy>`, the effective API " "of the email package is changed from the Python 3.2 API in the following " "ways:" msgstr "" -#: library/email.policy.rst:559 +#: library/email.policy.rst:577 msgid "" "Setting a header on a :class:`~email.message.Message` results in that header " "being parsed and a header object created." msgstr "" -#: library/email.policy.rst:562 +#: library/email.policy.rst:580 msgid "" "Fetching a header value from a :class:`~email.message.Message` results in " "that header being parsed and a header object created and returned." msgstr "" -#: library/email.policy.rst:566 +#: library/email.policy.rst:584 msgid "" "Any header object, or any header that is refolded due to the policy " "settings, is folded using an algorithm that fully implements the RFC folding " "algorithms, including knowing where encoded words are required and allowed." msgstr "" -#: library/email.policy.rst:571 +#: library/email.policy.rst:589 msgid "" -"From the application view, this means that any header obtained through the :" -"class:`~email.message.EmailMessage` is a header object with extra " +"From the application view, this means that any header obtained through " +"the :class:`~email.message.EmailMessage` is a header object with extra " "attributes, whose string value is the fully decoded unicode value of the " "header. Likewise, a header may be assigned a new value, or a new header " "created, using a unicode string, and the policy will take care of converting " "the unicode string into the correct RFC encoded form." msgstr "" -#: library/email.policy.rst:578 +#: library/email.policy.rst:596 msgid "" -"The header objects and their attributes are described in :mod:`~email." -"headerregistry`." +"The header objects and their attributes are described " +"in :mod:`~email.headerregistry`." msgstr "" -#: library/email.policy.rst:585 +#: library/email.policy.rst:603 msgid "" "This concrete :class:`Policy` is the backward compatibility policy. It " -"replicates the behavior of the email package in Python 3.2. The :mod:" -"`~email.policy` module also defines an instance of this class, :const:" -"`compat32`, that is used as the default policy. Thus the default behavior " -"of the email package is to maintain compatibility with Python 3.2." +"replicates the behavior of the email package in Python 3.2. " +"The :mod:`~email.policy` module also defines an instance of this " +"class, :const:`compat32`, that is used as the default policy. Thus the " +"default behavior of the email package is to maintain compatibility with " +"Python 3.2." msgstr "" -#: library/email.policy.rst:591 +#: library/email.policy.rst:609 msgid "" -"The following attributes have values that are different from the :class:" -"`Policy` default:" +"The following attributes have values that are different from " +"the :class:`Policy` default:" msgstr "" -#: library/email.policy.rst:597 +#: library/email.policy.rst:615 msgid "The default is ``True``." msgstr "" -#: library/email.policy.rst:614 +#: library/email.policy.rst:632 msgid "The name and value are returned unmodified." msgstr "" -#: library/email.policy.rst:619 +#: library/email.policy.rst:637 msgid "" -"If the value contains binary data, it is converted into a :class:`~email." -"header.Header` object using the ``unknown-8bit`` charset. Otherwise it is " -"returned unmodified." +"If the value contains binary data, it is converted into " +"a :class:`~email.header.Header` object using the ``unknown-8bit`` charset. " +"Otherwise it is returned unmodified." msgstr "" -#: library/email.policy.rst:626 +#: library/email.policy.rst:644 msgid "" "Headers are folded using the :class:`~email.header.Header` folding " "algorithm, which preserves existing line breaks in the value, and wraps each " @@ -705,7 +773,7 @@ msgid "" "encoded using the ``unknown-8bit`` charset." msgstr "" -#: library/email.policy.rst:634 +#: library/email.policy.rst:652 msgid "" "Headers are folded using the :class:`~email.header.Header` folding " "algorithm, which preserves existing line breaks in the value, and wraps each " @@ -715,17 +783,17 @@ msgid "" "and any (RFC invalid) binary data it may contain." msgstr "" -#: library/email.policy.rst:644 +#: library/email.policy.rst:662 msgid "" "An instance of :class:`Compat32`, providing backward compatibility with the " "behavior of the email package in Python 3.2." msgstr "" -#: library/email.policy.rst:649 +#: library/email.policy.rst:667 msgid "Footnotes" msgstr "" -#: library/email.policy.rst:650 +#: library/email.policy.rst:668 msgid "" "Originally added in 3.3 as a :term:`provisional feature `." diff --git a/library/email.utils.po b/library/email.utils.po index f5ec04f8..26c28ece 100644 --- a/library/email.utils.po +++ b/library/email.utils.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/email.utils.rst:2 -msgid ":mod:`email.utils`: Miscellaneous utilities" +msgid ":mod:`!email.utils`: Miscellaneous utilities" msgstr "" #: library/email.utils.rst:7 @@ -33,26 +34,26 @@ msgstr "" #: library/email.utils.rst:16 msgid "" "Return local time as an aware datetime object. If called without arguments, " -"return current time. Otherwise *dt* argument should be a :class:`~datetime." -"datetime` instance, and it is converted to the local time zone according to " -"the system time zone database. If *dt* is naive (that is, ``dt.tzinfo`` is " -"``None``), it is assumed to be in local time. The *isdst* parameter is " -"ignored." +"return current time. Otherwise *dt* argument should be " +"a :class:`~datetime.datetime` instance, and it is converted to the local " +"time zone according to the system time zone database. If *dt* is naive " +"(that is, ``dt.tzinfo`` is ``None``), it is assumed to be in local time. " +"The *isdst* parameter is ignored." msgstr "" -#: library/email.utils.rst:26 +#: library/email.utils.rst:25 msgid "The *isdst* parameter." msgstr "" #: library/email.utils.rst:30 msgid "" -"Returns a string suitable for an :rfc:`2822`\\ -compliant :mailheader:" -"`Message-ID` header. Optional *idstring* if given, is a string used to " -"strengthen the uniqueness of the message id. Optional *domain* if given " -"provides the portion of the msgid after the '@'. The default is the local " -"hostname. It is not normally necessary to override this default, but may be " -"useful certain cases, such as a constructing distributed system that uses a " -"consistent domain name across multiple hosts." +"Returns a string suitable for an :rfc:`2822`\\ " +"-compliant :mailheader:`Message-ID` header. Optional *idstring* if given, " +"is a string used to strengthen the uniqueness of the message id. Optional " +"*domain* if given provides the portion of the msgid after the '@'. The " +"default is the local hostname. It is not normally necessary to override " +"this default, but may be useful certain cases, such as a constructing " +"distributed system that uses a consistent domain name across multiple hosts." msgstr "" #: library/email.utils.rst:38 @@ -88,46 +89,69 @@ msgid "" "unless the parse fails, in which case a 2-tuple of ``('', '')`` is returned." msgstr "" -#: library/email.utils.rst:71 +#: library/email.utils.rst:96 msgid "" -"The inverse of :meth:`parseaddr`, this takes a 2-tuple of the form " -"``(realname, email_address)`` and returns the string value suitable for a :" -"mailheader:`To` or :mailheader:`Cc` header. If the first element of *pair* " -"is false, then the second element is returned unmodified." +"If *strict* is true, use a strict parser which rejects malformed inputs." +msgstr "" + +#: library/email.utils.rst:108 +msgid "Add *strict* optional parameter and reject malformed inputs by default." msgstr "" #: library/email.utils.rst:76 msgid "" +"The inverse of :meth:`parseaddr`, this takes a 2-tuple of the form " +"``(realname, email_address)`` and returns the string value suitable for " +"a :mailheader:`To` or :mailheader:`Cc` header. If the first element of " +"*pair* is false, then the second element is returned unmodified." +msgstr "" + +#: library/email.utils.rst:81 +msgid "" "Optional *charset* is the character set that will be used in the :rfc:`2047` " "encoding of the ``realname`` if the ``realname`` contains non-ASCII " -"characters. Can be an instance of :class:`str` or a :class:`~email.charset." -"Charset`. Defaults to ``utf-8``." +"characters. Can be an instance of :class:`str` or " +"a :class:`~email.charset.Charset`. Defaults to ``utf-8``." msgstr "" -#: library/email.utils.rst:81 +#: library/email.utils.rst:86 msgid "Added the *charset* option." msgstr "" -#: library/email.utils.rst:87 +#: library/email.utils.rst:92 msgid "" "This method returns a list of 2-tuples of the form returned by " "``parseaddr()``. *fieldvalues* is a sequence of header field values as might " -"be returned by :meth:`Message.get_all `. " -"Here's a simple example that gets all the recipients of a message::" +"be returned by :meth:`Message.get_all `." +msgstr "" + +#: library/email.utils.rst:98 +msgid "Here's a simple example that gets all the recipients of a message::" +msgstr "" + +#: library/email.utils.rst:100 +msgid "" +"from email.utils import getaddresses\n" +"\n" +"tos = msg.get_all('to', [])\n" +"ccs = msg.get_all('cc', [])\n" +"resent_tos = msg.get_all('resent-to', [])\n" +"resent_ccs = msg.get_all('resent-cc', [])\n" +"all_recipients = getaddresses(tos + ccs + resent_tos + resent_ccs)" msgstr "" -#: library/email.utils.rst:103 +#: library/email.utils.rst:114 msgid "" "Attempts to parse a date according to the rules in :rfc:`2822`. however, " "some mailers don't follow that format as specified, so :func:`parsedate` " -"tries to guess correctly in such cases. *date* is a string containing an :" -"rfc:`2822` date, such as ``\"Mon, 20 Nov 1995 19:12:08 -0500\"``. If it " -"succeeds in parsing the date, :func:`parsedate` returns a 9-tuple that can " -"be passed directly to :func:`time.mktime`; otherwise ``None`` will be " +"tries to guess correctly in such cases. *date* is a string containing " +"an :rfc:`2822` date, such as ``\"Mon, 20 Nov 1995 19:12:08 -0500\"``. If " +"it succeeds in parsing the date, :func:`parsedate` returns a 9-tuple that " +"can be passed directly to :func:`time.mktime`; otherwise ``None`` will be " "returned. Note that indexes 6, 7, and 8 of the result tuple are not usable." msgstr "" -#: library/email.utils.rst:114 +#: library/email.utils.rst:125 msgid "" "Performs the same function as :func:`parsedate`, but returns either ``None`` " "or a 10-tuple; the first 9 elements make up a tuple that can be passed " @@ -138,39 +162,43 @@ msgid "" "the result tuple are not usable." msgstr "" -#: library/email.utils.rst:124 +#: library/email.utils.rst:135 msgid "" -"The inverse of :func:`format_datetime`. Performs the same function as :func:" -"`parsedate`, but on success returns a :mod:`~datetime.datetime`; otherwise " -"``ValueError`` is raised if *date* contains an invalid value such as an hour " -"greater than 23 or a timezone offset not between -24 and 24 hours. If the " -"input date has a timezone of ``-0000``, the ``datetime`` will be a naive " -"``datetime``, and if the date is conforming to the RFCs it will represent a " -"time in UTC but with no indication of the actual source timezone of the " -"message the date comes from. If the input date has any other valid timezone " -"offset, the ``datetime`` will be an aware ``datetime`` with the " +"The inverse of :func:`format_datetime`. Performs the same function " +"as :func:`parsedate`, but on success returns a :mod:`~datetime.datetime`; " +"otherwise ``ValueError`` is raised if *date* contains an invalid value such " +"as an hour greater than 23 or a timezone offset not between -24 and 24 " +"hours. If the input date has a timezone of ``-0000``, the ``datetime`` will " +"be a naive ``datetime``, and if the date is conforming to the RFCs it will " +"represent a time in UTC but with no indication of the actual source timezone " +"of the message the date comes from. If the input date has any other valid " +"timezone offset, the ``datetime`` will be an aware ``datetime`` with the " "corresponding a :class:`~datetime.timezone` :class:`~datetime.tzinfo`." msgstr "" -#: library/email.utils.rst:140 +#: library/email.utils.rst:151 msgid "" "Turn a 10-tuple as returned by :func:`parsedate_tz` into a UTC timestamp " "(seconds since the Epoch). If the timezone item in the tuple is ``None``, " "assume local time." msgstr "" -#: library/email.utils.rst:147 +#: library/email.utils.rst:158 msgid "Returns a date string as per :rfc:`2822`, e.g.::" msgstr "" -#: library/email.utils.rst:151 +#: library/email.utils.rst:160 +msgid "Fri, 09 Nov 2001 01:08:47 -0000" +msgstr "" + +#: library/email.utils.rst:162 msgid "" -"Optional *timeval* if given is a floating point time value as accepted by :" -"func:`time.gmtime` and :func:`time.localtime`, otherwise the current time is " -"used." +"Optional *timeval* if given is a floating-point time value as accepted " +"by :func:`time.gmtime` and :func:`time.localtime`, otherwise the current " +"time is used." msgstr "" -#: library/email.utils.rst:155 +#: library/email.utils.rst:166 msgid "" "Optional *localtime* is a flag that when ``True``, interprets *timeval*, and " "returns a date relative to the local timezone instead of UTC, properly " @@ -178,7 +206,7 @@ msgid "" "UTC is used." msgstr "" -#: library/email.utils.rst:160 +#: library/email.utils.rst:171 msgid "" "Optional *usegmt* is a flag that when ``True``, outputs a date string with " "the timezone as an ascii string ``GMT``, rather than a numeric ``-0000``. " @@ -186,7 +214,7 @@ msgid "" "*localtime* is ``False``. The default is ``False``." msgstr "" -#: library/email.utils.rst:168 +#: library/email.utils.rst:179 msgid "" "Like ``formatdate``, but the input is a :mod:`datetime` instance. If it is " "a naive datetime, it is assumed to be \"UTC with no information about the " @@ -198,11 +226,11 @@ msgid "" "date headers." msgstr "" -#: library/email.utils.rst:182 +#: library/email.utils.rst:193 msgid "Decode the string *s* according to :rfc:`2231`." msgstr "" -#: library/email.utils.rst:187 +#: library/email.utils.rst:198 msgid "" "Encode the string *s* according to :rfc:`2231`. Optional *charset* and " "*language*, if given is the character set name and language name to use. If " @@ -211,35 +239,35 @@ msgid "" "*language*." msgstr "" -#: library/email.utils.rst:195 +#: library/email.utils.rst:206 msgid "" -"When a header parameter is encoded in :rfc:`2231` format, :meth:`Message." -"get_param ` may return a 3-tuple containing " -"the character set, language, and value. :func:`collapse_rfc2231_value` " -"turns this into a unicode string. Optional *errors* is passed to the " -"*errors* argument of :class:`str`'s :func:`~str.encode` method; it defaults " -"to ``'replace'``. Optional *fallback_charset* specifies the character set " -"to use if the one in the :rfc:`2231` header is not known by Python; it " -"defaults to ``'us-ascii'``." +"When a header parameter is encoded in :rfc:`2231` " +"format, :meth:`Message.get_param ` may " +"return a 3-tuple containing the character set, language, and " +"value. :func:`collapse_rfc2231_value` turns this into a unicode string. " +"Optional *errors* is passed to the *errors* argument " +"of :class:`str`'s :func:`~str.encode` method; it defaults to ``'replace'``. " +"Optional *fallback_charset* specifies the character set to use if the one in " +"the :rfc:`2231` header is not known by Python; it defaults to ``'us-ascii'``." msgstr "" -#: library/email.utils.rst:204 +#: library/email.utils.rst:215 msgid "" "For convenience, if the *value* passed to :func:`collapse_rfc2231_value` is " "not a tuple, it should be a string and it is returned unquoted." msgstr "" -#: library/email.utils.rst:210 +#: library/email.utils.rst:221 msgid "" "Decode parameters list according to :rfc:`2231`. *params* is a sequence of " "2-tuples containing elements of the form ``(content-type, string-value)``." msgstr "" -#: library/email.utils.rst:215 +#: library/email.utils.rst:226 msgid "Footnotes" msgstr "" -#: library/email.utils.rst:216 +#: library/email.utils.rst:227 msgid "" "Note that the sign of the timezone offset is the opposite of the sign of the " "``time.timezone`` variable for the same timezone; the latter variable " diff --git a/library/ensurepip.po b/library/ensurepip.po index a3308ba3..6b932555 100644 --- a/library/ensurepip.po +++ b/library/ensurepip.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/ensurepip.rst:2 -msgid ":mod:`ensurepip` --- Bootstrapping the ``pip`` installer" +msgid ":mod:`!ensurepip` --- Bootstrapping the ``pip`` installer" msgstr "" #: library/ensurepip.rst:10 @@ -48,7 +49,7 @@ msgid "" "bootstrap ``pip`` are included as internal parts of the package." msgstr "" -#: library/ensurepip.rst:36 +#: library/ensurepip.rst:35 msgid ":ref:`installing-index`" msgstr "" @@ -65,7 +66,7 @@ msgid "The original rationale and specification for this module." msgstr "" #: includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." +msgid "Availability" msgstr "" #: includes/wasm-notavail.rst:5 @@ -88,6 +89,10 @@ msgstr "" msgid "The simplest possible invocation is::" msgstr "" +#: library/ensurepip.rst:50 +msgid "python -m ensurepip" +msgstr "" + #: library/ensurepip.rst:52 msgid "" "This invocation will install ``pip`` if it is not already installed, but " @@ -96,6 +101,10 @@ msgid "" "upgrade`` option::" msgstr "" +#: library/ensurepip.rst:57 +msgid "python -m ensurepip --upgrade" +msgstr "" + #: library/ensurepip.rst:59 msgid "" "By default, ``pip`` is installed into the current virtual environment (if " @@ -206,7 +215,7 @@ msgid "" "bootstrapping operation." msgstr "" -#: library/ensurepip.rst:136 +#: library/ensurepip.rst:125 msgid "" "Raises an :ref:`auditing event ` ``ensurepip.bootstrap`` with " "argument ``root``." @@ -214,8 +223,8 @@ msgstr "" #: library/ensurepip.rst:129 msgid "" -"The bootstrapping process has side effects on both ``sys.path`` and ``os." -"environ``. Invoking the command line interface in a subprocess instead " +"The bootstrapping process has side effects on both ``sys.path`` and " +"``os.environ``. Invoking the command line interface in a subprocess instead " "allows these side effects to be avoided." msgstr "" diff --git a/library/enum.po b/library/enum.po index 54427577..dc03ca1c 100644 --- a/library/enum.po +++ b/library/enum.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/enum.rst:2 -msgid ":mod:`enum` --- Support for enumerations" +msgid ":mod:`!enum` --- Support for enumerations" msgstr "" #: library/enum.rst:14 @@ -70,6 +71,20 @@ msgid "" "using function-call syntax::" msgstr "" +#: library/enum.rst:38 +msgid "" +">>> from enum import Enum\n" +"\n" +">>> # class syntax\n" +">>> class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 3\n" +"\n" +">>> # functional syntax\n" +">>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])" +msgstr "" + #: library/enum.rst:49 msgid "" "Even though we can use :keyword:`class` syntax to create Enums, Enums are " @@ -123,8 +138,8 @@ msgstr "" #: library/enum.rst:77 msgid "" -"Base class for creating enumerated constants that are also subclasses of :" -"class:`int`. (`Notes`_)" +"Base class for creating enumerated constants that are also subclasses " +"of :class:`int`. (`Notes`_)" msgstr "" #: library/enum.rst:80 @@ -133,8 +148,8 @@ msgstr "" #: library/enum.rst:82 msgid "" -"Base class for creating enumerated constants that are also subclasses of :" -"class:`str`. (`Notes`_)" +"Base class for creating enumerated constants that are also subclasses " +"of :class:`str`. (`Notes`_)" msgstr "" #: library/enum.rst:85 @@ -154,8 +169,9 @@ msgstr "" #: library/enum.rst:92 msgid "" "Base class for creating enumerated constants that can be combined using the " -"bitwise operators without losing their :class:`IntFlag` membership. :class:" -"`IntFlag` members are also subclasses of :class:`int`. (`Notes`_)" +"bitwise operators without losing their :class:`IntFlag` " +"membership. :class:`IntFlag` members are also subclasses of :class:`int`. " +"(`Notes`_)" msgstr "" #: library/enum.rst:96 @@ -196,9 +212,9 @@ msgstr "" #: library/enum.rst:115 msgid "" -"Instances are replaced with an appropriate value for Enum members. :class:" -"`StrEnum` defaults to the lower-cased version of the member name, while " -"other Enums default to 1 and increase from there." +"Instances are replaced with an appropriate value for Enum " +"members. :class:`StrEnum` defaults to the lower-cased version of the member " +"name, while other Enums default to 1 and increase from there." msgstr "" #: library/enum.rst:119 @@ -382,6 +398,15 @@ msgstr "" msgid "Returns ``True`` if member belongs to the ``cls``::" msgstr "" +#: library/enum.rst:198 +msgid "" +">>> some_var = Color.RED\n" +">>> some_var in Color\n" +"True\n" +">>> Color.RED.value in Color\n" +"True" +msgstr "" + #: library/enum.rst:206 msgid "" "Before Python 3.12, a ``TypeError`` is raised if a non-Enum-member is used " @@ -394,20 +419,46 @@ msgid "" "names of the members in *cls*::" msgstr "" +#: library/enum.rst:214 +msgid "" +">>> dir(Color)\n" +"['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', " +"'__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', " +"'__module__', '__name__', '__qualname__']" +msgstr "" + #: library/enum.rst:219 msgid "" -"Returns the Enum member in *cls* matching *name*, or raises a :exc:" -"`KeyError`::" +"Returns the Enum member in *cls* matching *name*, or raises " +"a :exc:`KeyError`::" +msgstr "" + +#: library/enum.rst:221 +msgid "" +">>> Color['BLUE']\n" +"" msgstr "" #: library/enum.rst:226 msgid "Returns each member in *cls* in definition order::" msgstr "" +#: library/enum.rst:228 +msgid "" +">>> list(Color)\n" +"[, , ]" +msgstr "" + #: library/enum.rst:233 msgid "Returns the number of member in *cls*::" msgstr "" +#: library/enum.rst:235 +msgid "" +">>> len(Color)\n" +"3" +msgstr "" + #: library/enum.rst:240 msgid "Returns a mapping of every enum name to its member, including aliases" msgstr "" @@ -416,6 +467,12 @@ msgstr "" msgid "Returns each member in *cls* in reverse definition order::" msgstr "" +#: library/enum.rst:246 +msgid "" +">>> list(reversed(Color))\n" +"[, , ]" +msgstr "" + #: library/enum.rst:251 msgid "Before 3.11 ``enum`` used ``EnumMeta`` type, which is kept as an alias." msgstr "" @@ -428,12 +485,24 @@ msgstr "" msgid "The name used to define the ``Enum`` member::" msgstr "" +#: library/enum.rst:262 +msgid "" +">>> Color.BLUE.name\n" +"'BLUE'" +msgstr "" + #: library/enum.rst:267 msgid "The value given to the ``Enum`` member::" msgstr "" +#: library/enum.rst:269 +msgid "" +">>> Color.RED.value\n" +"1" +msgstr "" + #: library/enum.rst:292 -msgid "Value of the member, can be set in :meth:`~object.__new__`." +msgid "Value of the member, can be set in :meth:`~Enum.__new__`." msgstr "" #: library/enum.rst:274 @@ -474,8 +543,8 @@ msgstr "" #: library/enum.rst:304 msgid "" "``_ignore_`` is a list of names that will not become members, and whose " -"names will also be removed from the completed enumeration. See :ref:" -"`TimePeriod ` for an example." +"names will also be removed from the completed enumeration. " +"See :ref:`TimePeriod ` for an example." msgstr "" #: library/enum.rst:310 @@ -484,6 +553,26 @@ msgid "" "public methods defined on *self.__class__*::" msgstr "" +#: library/enum.rst:313 +msgid "" +">>> from datetime import date\n" +">>> class Weekday(Enum):\n" +"... MONDAY = 1\n" +"... TUESDAY = 2\n" +"... WEDNESDAY = 3\n" +"... THURSDAY = 4\n" +"... FRIDAY = 5\n" +"... SATURDAY = 6\n" +"... SUNDAY = 7\n" +"... @classmethod\n" +"... def today(cls):\n" +"... print('today is %s' % cls(date.today().isoweekday()).name)\n" +"...\n" +">>> dir(Weekday.SATURDAY)\n" +"['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', " +"'today', 'value']" +msgstr "" + #: library/enum.rst:0 msgid "name" msgstr "" @@ -514,8 +603,22 @@ msgstr "" #: library/enum.rst:336 msgid "" -"A *staticmethod* that is used to determine the next value returned by :class:" -"`auto`::" +"A *staticmethod* that is used to determine the next value returned " +"by :class:`auto`::" +msgstr "" + +#: library/enum.rst:339 +msgid "" +">>> from enum import auto\n" +">>> class PowersOfThree(Enum):\n" +"... @staticmethod\n" +"... def _generate_next_value_(name, start, count, last_values):\n" +"... return 3 ** (count + 1)\n" +"... FIRST = auto()\n" +"... SECOND = auto()\n" +"...\n" +">>> PowersOfThree.SECOND.value\n" +"9" msgstr "" #: library/enum.rst:352 @@ -542,6 +645,26 @@ msgid "" "does nothing, but can be overridden to implement custom search behavior::" msgstr "" +#: library/enum.rst:371 +msgid "" +">>> from enum import StrEnum\n" +">>> class Build(StrEnum):\n" +"... DEBUG = auto()\n" +"... OPTIMIZED = auto()\n" +"... @classmethod\n" +"... def _missing_(cls, value):\n" +"... value = value.lower()\n" +"... for member in cls:\n" +"... if member.value == value:\n" +"... return member\n" +"... return None\n" +"...\n" +">>> Build.DEBUG.value\n" +"'debug'\n" +">>> Build('deBUG')\n" +"" +msgstr "" + #: library/enum.rst:390 msgid "" "By default, doesn't exist. If specified, either in the enum class " @@ -551,47 +674,87 @@ msgstr "" #: library/enum.rst:398 msgid "" -"results in the call ``int('1a', 16)`` and a value of ``17`` for the member." +"results in the call ``int('1a', 16)`` and a value of ``26`` for the member." msgstr "" -#: library/enum.rst:400 +#: library/enum.rst:402 msgid "" -"..note:: When writing a custom ``__new__``, do not use ``super().__new__`` --" -msgstr "" - -#: library/enum.rst:401 -msgid "call the appropriate ``__new__`` instead." +"When writing a custom ``__new__``, do not use ``super().__new__`` -- call " +"the appropriate ``__new__`` instead." msgstr "" -#: library/enum.rst:405 +#: library/enum.rst:407 msgid "" "Returns the string used for *repr()* calls. By default, returns the *Enum* " "name, member name, and value, but can be overridden::" msgstr "" -#: library/enum.rst:421 +#: library/enum.rst:410 +msgid "" +">>> class OtherStyle(Enum):\n" +"... ALTERNATE = auto()\n" +"... OTHER = auto()\n" +"... SOMETHING_ELSE = auto()\n" +"... def __repr__(self):\n" +"... cls_name = self.__class__.__name__\n" +"... return f'{cls_name}.{self.name}'\n" +"...\n" +">>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), " +"f\"{OtherStyle.ALTERNATE}\"\n" +"(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')" +msgstr "" + +#: library/enum.rst:423 msgid "" "Returns the string used for *str()* calls. By default, returns the *Enum* " "name and member name, but can be overridden::" msgstr "" -#: library/enum.rst:436 +#: library/enum.rst:426 +msgid "" +">>> class OtherStyle(Enum):\n" +"... ALTERNATE = auto()\n" +"... OTHER = auto()\n" +"... SOMETHING_ELSE = auto()\n" +"... def __str__(self):\n" +"... return f'{self.name}'\n" +"...\n" +">>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), " +"f\"{OtherStyle.ALTERNATE}\"\n" +"(, 'ALTERNATE', 'ALTERNATE')" +msgstr "" + +#: library/enum.rst:438 msgid "" "Returns the string used for *format()* and *f-string* calls. By default, " "returns :meth:`__str__` return value, but can be overridden::" msgstr "" -#: library/enum.rst:451 +#: library/enum.rst:441 +msgid "" +">>> class OtherStyle(Enum):\n" +"... ALTERNATE = auto()\n" +"... OTHER = auto()\n" +"... SOMETHING_ELSE = auto()\n" +"... def __format__(self, spec):\n" +"... return f'{self.name}'\n" +"...\n" +">>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), " +"f\"{OtherStyle.ALTERNATE}\"\n" +"(, 'OtherStyle.ALTERNATE', 'ALTERNATE')" +msgstr "" + +#: library/enum.rst:453 msgid "" "Using :class:`auto` with :class:`Enum` results in integers of increasing " "value, starting with ``1``." msgstr "" -#: library/enum.rst:454 +#: library/enum.rst:456 msgid "Added :ref:`enum-dataclass-support`" msgstr "" -#: library/enum.rst:459 +#: library/enum.rst:461 msgid "" "*IntEnum* is the same as *Enum*, but its members are also integers and can " "be used anywhere that an integer can be used. If any integer operation is " @@ -599,20 +762,20 @@ msgid "" "enumeration status." msgstr "" -#: library/enum.rst:480 +#: library/enum.rst:482 msgid "" "Using :class:`auto` with :class:`IntEnum` results in integers of increasing " "value, starting with ``1``." msgstr "" -#: library/enum.rst:483 +#: library/enum.rst:485 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` was " "already :meth:`!int.__format__` for that same reason." msgstr "" -#: library/enum.rst:490 +#: library/enum.rst:492 msgid "" "*StrEnum* is the same as *Enum*, but its members are also strings and can be " "used in most of the same places that a string can be used. The result of " @@ -620,7 +783,7 @@ msgid "" "the enumeration." msgstr "" -#: library/enum.rst:496 +#: library/enum.rst:498 msgid "" "There are places in the stdlib that check for an exact :class:`str` instead " "of a :class:`str` subclass (i.e. ``type(unknown) == str`` instead of " @@ -628,280 +791,448 @@ msgid "" "``str(StrEnum.member)``." msgstr "" -#: library/enum.rst:503 +#: library/enum.rst:505 msgid "" "Using :class:`auto` with :class:`StrEnum` results in the lower-cased member " "name as the value." msgstr "" -#: library/enum.rst:508 +#: library/enum.rst:510 msgid "" ":meth:`~object.__str__` is :meth:`!str.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` is " "likewise :meth:`!str.__format__` for that same reason." msgstr "" -#: library/enum.rst:516 +#: library/enum.rst:518 msgid "" "``Flag`` is the same as :class:`Enum`, but its members support the bitwise " "operators ``&`` (*AND*), ``|`` (*OR*), ``^`` (*XOR*), and ``~`` (*INVERT*); " -"the results of those operators are members of the enumeration." +"the results of those operations are (aliases of) members of the enumeration." msgstr "" -#: library/enum.rst:522 +#: library/enum.rst:524 msgid "Returns *True* if value is in self::" msgstr "" -#: library/enum.rst:543 +#: library/enum.rst:526 +msgid "" +">>> from enum import Flag, auto\n" +">>> class Color(Flag):\n" +"... RED = auto()\n" +"... GREEN = auto()\n" +"... BLUE = auto()\n" +"...\n" +">>> purple = Color.RED | Color.BLUE\n" +">>> white = Color.RED | Color.GREEN | Color.BLUE\n" +">>> Color.GREEN in purple\n" +"False\n" +">>> Color.GREEN in white\n" +"True\n" +">>> purple in white\n" +"True\n" +">>> white in purple\n" +"False" +msgstr "" + +#: library/enum.rst:545 msgid "Returns all contained non-alias members::" msgstr "" -#: library/enum.rst:554 +#: library/enum.rst:547 +msgid "" +">>> list(Color.RED)\n" +"[]\n" +">>> list(purple)\n" +"[, ]" +msgstr "" + +#: library/enum.rst:556 msgid "Returns number of members in flag::" msgstr "" -#: library/enum.rst:563 +#: library/enum.rst:558 +msgid "" +">>> len(Color.GREEN)\n" +"1\n" +">>> len(white)\n" +"3" +msgstr "" + +#: library/enum.rst:567 msgid "Returns *True* if any members in flag, *False* otherwise::" msgstr "" -#: library/enum.rst:575 +#: library/enum.rst:569 +msgid "" +">>> bool(Color.GREEN)\n" +"True\n" +">>> bool(white)\n" +"True\n" +">>> black = Color(0)\n" +">>> bool(black)\n" +"False" +msgstr "" + +#: library/enum.rst:579 msgid "Returns current flag binary or'ed with other::" msgstr "" -#: library/enum.rst:582 +#: library/enum.rst:581 +msgid "" +">>> Color.RED | Color.GREEN\n" +"" +msgstr "" + +#: library/enum.rst:586 msgid "Returns current flag binary and'ed with other::" msgstr "" -#: library/enum.rst:591 +#: library/enum.rst:588 +msgid "" +">>> purple & white\n" +"\n" +">>> purple & Color.GREEN\n" +"" +msgstr "" + +#: library/enum.rst:595 msgid "Returns current flag binary xor'ed with other::" msgstr "" -#: library/enum.rst:600 +#: library/enum.rst:597 +msgid "" +">>> purple ^ white\n" +"\n" +">>> purple ^ Color.GREEN\n" +"" +msgstr "" + +#: library/enum.rst:604 msgid "Returns all the flags in *type(self)* that are not in self::" msgstr "" -#: library/enum.rst:611 +#: library/enum.rst:606 +msgid "" +">>> ~white\n" +"\n" +">>> ~purple\n" +"\n" +">>> ~Color.RED\n" +"" +msgstr "" + +#: library/enum.rst:615 msgid "" "Function used to format any remaining unnamed numeric values. Default is " "the value's repr; common choices are :func:`hex` and :func:`oct`." msgstr "" -#: library/enum.rst:616 +#: library/enum.rst:620 msgid "" "Using :class:`auto` with :class:`Flag` results in integers that are powers " "of two, starting with ``1``." msgstr "" -#: library/enum.rst:619 +#: library/enum.rst:623 msgid "The *repr()* of zero-valued flags has changed. It is now::" msgstr "" -#: library/enum.rst:627 +#: library/enum.rst:631 msgid "" "*IntFlag* is the same as *Flag*, but its members are also integers and can " "be used anywhere that an integer can be used." msgstr "" -#: library/enum.rst:641 +#: library/enum.rst:645 msgid "" "If any integer operation is performed with an *IntFlag* member, the result " "is not an *IntFlag*::" msgstr "" -#: library/enum.rst:647 +#: library/enum.rst:648 +msgid "" +">>> Color.RED + 2\n" +"3" +msgstr "" + +#: library/enum.rst:651 msgid "If a *Flag* operation is performed with an *IntFlag* member and:" msgstr "" -#: library/enum.rst:649 +#: library/enum.rst:653 msgid "the result is a valid *IntFlag*: an *IntFlag* is returned" msgstr "" -#: library/enum.rst:650 +#: library/enum.rst:654 msgid "" "the result is not a valid *IntFlag*: the result depends on the " "*FlagBoundary* setting" msgstr "" -#: library/enum.rst:652 +#: library/enum.rst:656 msgid "The *repr()* of unnamed zero-valued flags has changed. It is now:" msgstr "" -#: library/enum.rst:659 +#: library/enum.rst:663 msgid "" "Using :class:`auto` with :class:`IntFlag` results in integers that are " "powers of two, starting with ``1``." msgstr "" -#: library/enum.rst:664 +#: library/enum.rst:668 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` " "was already :meth:`!int.__format__` for that same reason." msgstr "" -#: library/enum.rst:668 +#: library/enum.rst:672 msgid "" "Inversion of an :class:`!IntFlag` now returns a positive value that is the " "union of all flags not in the given flag, rather than a negative value. This " "matches the existing :class:`Flag` behavior." msgstr "" -#: library/enum.rst:674 +#: library/enum.rst:678 msgid "" ":class:`!ReprEnum` uses the :meth:`repr() ` of :class:`Enum`, " "but the :class:`str() ` of the mixed-in data type:" msgstr "" -#: library/enum.rst:677 +#: library/enum.rst:681 msgid ":meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`" msgstr "" -#: library/enum.rst:678 +#: library/enum.rst:682 msgid ":meth:`!str.__str__` for :class:`StrEnum`" msgstr "" -#: library/enum.rst:680 +#: library/enum.rst:684 msgid "" -"Inherit from :class:`!ReprEnum` to keep the :class:`str() ` / :func:" -"`format` of the mixed-in data type instead of using the :class:`Enum`-" -"default :meth:`str() `." +"Inherit from :class:`!ReprEnum` to keep the :class:`str() " +"` / :func:`format` of the mixed-in data type instead of using " +"the :class:`Enum`-default :meth:`str() `." msgstr "" -#: library/enum.rst:689 +#: library/enum.rst:693 msgid "" "*EnumCheck* contains the options used by the :func:`verify` decorator to " "ensure various constraints; failed constraints result in a :exc:`ValueError`." msgstr "" -#: library/enum.rst:694 +#: library/enum.rst:698 msgid "Ensure that each value has only one name::" msgstr "" -#: library/enum.rst:710 +#: library/enum.rst:700 +msgid "" +">>> from enum import Enum, verify, UNIQUE\n" +">>> @verify(UNIQUE)\n" +"... class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 3\n" +"... CRIMSON = 1\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: aliases found in : CRIMSON -> RED" +msgstr "" + +#: library/enum.rst:714 msgid "" "Ensure that there are no missing values between the lowest-valued member and " "the highest-valued member::" msgstr "" -#: library/enum.rst:725 +#: library/enum.rst:717 +msgid "" +">>> from enum import Enum, verify, CONTINUOUS\n" +">>> @verify(CONTINUOUS)\n" +"... class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 5\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: invalid enum 'Color': missing values 3, 4" +msgstr "" + +#: library/enum.rst:729 msgid "" "Ensure that any flag groups/masks contain only named flags -- useful when " "values are specified instead of being generated by :func:`auto`::" msgstr "" -#: library/enum.rst:742 +#: library/enum.rst:732 +msgid "" +">>> from enum import Flag, verify, NAMED_FLAGS\n" +">>> @verify(NAMED_FLAGS)\n" +"... class Color(Flag):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 4\n" +"... WHITE = 15\n" +"... NEON = 31\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: invalid Flag 'Color': aliases WHITE and NEON are missing " +"combined values of 0x18 [use enum.show_flag_values(value) for details]" +msgstr "" + +#: library/enum.rst:746 msgid "" "CONTINUOUS and NAMED_FLAGS are designed to work with integer-valued members." msgstr "" -#: library/enum.rst:748 +#: library/enum.rst:752 msgid "" "*FlagBoundary* controls how out-of-range values are handled in *Flag* and " "its subclasses." msgstr "" -#: library/enum.rst:753 +#: library/enum.rst:757 msgid "" "Out-of-range values cause a :exc:`ValueError` to be raised. This is the " "default for :class:`Flag`::" msgstr "" -#: library/enum.rst:771 +#: library/enum.rst:760 +msgid "" +">>> from enum import Flag, STRICT, auto\n" +">>> class StrictFlag(Flag, boundary=STRICT):\n" +"... RED = auto()\n" +"... GREEN = auto()\n" +"... BLUE = auto()\n" +"...\n" +">>> StrictFlag(2**2 + 2**4)\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: invalid value 20\n" +" given 0b0 10100\n" +" allowed 0b0 00111" +msgstr "" + +#: library/enum.rst:775 msgid "" "Out-of-range values have invalid values removed, leaving a valid *Flag* " "value::" msgstr "" -#: library/enum.rst:785 +#: library/enum.rst:778 +msgid "" +">>> from enum import Flag, CONFORM, auto\n" +">>> class ConformFlag(Flag, boundary=CONFORM):\n" +"... RED = auto()\n" +"... GREEN = auto()\n" +"... BLUE = auto()\n" +"...\n" +">>> ConformFlag(2**2 + 2**4)\n" +"" +msgstr "" + +#: library/enum.rst:789 msgid "" "Out-of-range values lose their *Flag* membership and revert to :class:`int`." msgstr "" -#: library/enum.rst:798 +#: library/enum.rst:802 msgid "" "Out-of-range values are kept, and the *Flag* membership is kept. This is the " "default for :class:`IntFlag`::" msgstr "" -#: library/enum.rst:815 +#: library/enum.rst:805 +msgid "" +">>> from enum import Flag, KEEP, auto\n" +">>> class KeepFlag(Flag, boundary=KEEP):\n" +"... RED = auto()\n" +"... GREEN = auto()\n" +"... BLUE = auto()\n" +"...\n" +">>> KeepFlag(2**2 + 2**4)\n" +"" +msgstr "" + +#: library/enum.rst:819 msgid "Supported ``__dunder__`` names" msgstr "" -#: library/enum.rst:817 +#: library/enum.rst:821 msgid "" ":attr:`~EnumType.__members__` is a read-only ordered mapping of " "``member_name``:``member`` items. It is only available on the class." msgstr "" -#: library/enum.rst:820 +#: library/enum.rst:824 msgid "" -":meth:`~object.__new__`, if specified, must create and return the enum " +":meth:`~Enum.__new__`, if specified, must create and return the enum " "members; it is also a very good idea to set the member's :attr:`!_value_` " "appropriately. Once all the members are created it is no longer used." msgstr "" -#: library/enum.rst:826 +#: library/enum.rst:830 msgid "Supported ``_sunder_`` names" msgstr "" -#: library/enum.rst:828 +#: library/enum.rst:832 msgid ":attr:`~Enum._name_` -- name of the member" msgstr "" -#: library/enum.rst:829 +#: library/enum.rst:833 msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr "" -#: library/enum.rst:830 +#: library/enum.rst:834 msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" -#: library/enum.rst:832 +#: library/enum.rst:836 msgid "" -":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a :" -"class:`str`, that will not be transformed into members, and will be removed " -"from the final class" +":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or " +"a :class:`str`, that will not be transformed into members, and will be " +"removed from the final class" msgstr "" -#: library/enum.rst:835 +#: library/enum.rst:839 msgid "" ":attr:`~Enum._order_` -- no longer used, kept for backward compatibility " "(class attribute, removed during class creation)" msgstr "" -#: library/enum.rst:837 +#: library/enum.rst:841 msgid "" ":meth:`~Enum._generate_next_value_` -- used to get an appropriate value for " "an enum member; may be overridden" msgstr "" -#: library/enum.rst:842 +#: library/enum.rst:846 msgid "" "For standard :class:`Enum` classes the next value chosen is the last value " "seen incremented by one." msgstr "" -#: library/enum.rst:845 +#: library/enum.rst:849 msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " "power-of-two, regardless of the last value seen." msgstr "" -#: library/enum.rst:848 +#: library/enum.rst:852 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "" -#: library/enum.rst:849 +#: library/enum.rst:853 msgid "``_ignore_``" msgstr "" -#: library/enum.rst:854 +#: library/enum.rst:858 msgid "Utilities and Decorators" msgstr "" -#: library/enum.rst:858 +#: library/enum.rst:862 msgid "" "*auto* can be used in place of a value. If used, the *Enum* machinery will " "call an *Enum*'s :meth:`~Enum._generate_next_value_` to get an appropriate " @@ -912,54 +1243,54 @@ msgid "" "manually specified values." msgstr "" -#: library/enum.rst:866 +#: library/enum.rst:870 msgid "" "*auto* instances are only resolved when at the top level of an assignment:" msgstr "" -#: library/enum.rst:868 +#: library/enum.rst:872 msgid "``FIRST = auto()`` will work (auto() is replaced with ``1``);" msgstr "" -#: library/enum.rst:869 +#: library/enum.rst:873 msgid "" "``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` " "is used to create the ``SECOND`` enum member;" msgstr "" -#: library/enum.rst:871 +#: library/enum.rst:875 msgid "" "``THREE = [auto(), -3]`` will *not* work (``, -3`` is used to " "create the ``THREE`` enum member)" msgstr "" -#: library/enum.rst:876 +#: library/enum.rst:880 msgid "" "In prior versions, ``auto()`` had to be the only thing on the assignment " "line to work properly." msgstr "" -#: library/enum.rst:879 +#: library/enum.rst:883 msgid "" "``_generate_next_value_`` can be overridden to customize the values used by " "*auto*." msgstr "" -#: library/enum.rst:882 +#: library/enum.rst:886 msgid "" "in 3.13 the default ``_generate_next_value_`` will always return the highest " "member value incremented by 1, and will fail if any member is an " "incompatible type." msgstr "" -#: library/enum.rst:888 +#: library/enum.rst:892 msgid "" "A decorator similar to the built-in *property*, but specifically for " "enumerations. It allows member attributes to have the same names as members " "themselves." msgstr "" -#: library/enum.rst:892 +#: library/enum.rst:896 msgid "" "the *property* and the member must be defined in separate classes; for " "example, the *value* and *name* attributes are defined in the *Enum* class, " @@ -967,29 +1298,44 @@ msgid "" "``name``." msgstr "" -#: library/enum.rst:901 +#: library/enum.rst:905 msgid "" "A :keyword:`class` decorator specifically for enumerations. It searches an " "enumeration's :attr:`~EnumType.__members__`, gathering any aliases it finds; " "if any are found :exc:`ValueError` is raised with the details::" msgstr "" -#: library/enum.rst:919 +#: library/enum.rst:909 msgid "" -"A :keyword:`class` decorator specifically for enumerations. Members from :" -"class:`EnumCheck` are used to specify which constraints should be checked on " -"the decorated enumeration." +">>> from enum import Enum, unique\n" +">>> @unique\n" +"... class Mistake(Enum):\n" +"... ONE = 1\n" +"... TWO = 2\n" +"... THREE = 3\n" +"... FOUR = 3\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: duplicate values found in : FOUR -> THREE" msgstr "" -#: library/enum.rst:927 +#: library/enum.rst:923 +msgid "" +"A :keyword:`class` decorator specifically for enumerations. Members " +"from :class:`EnumCheck` are used to specify which constraints should be " +"checked on the decorated enumeration." +msgstr "" + +#: library/enum.rst:931 msgid "A decorator for use in enums: its target will become a member." msgstr "" -#: library/enum.rst:933 +#: library/enum.rst:937 msgid "A decorator for use in enums: its target will not become a member." msgstr "" -#: library/enum.rst:939 +#: library/enum.rst:943 msgid "" "A decorator to change the :class:`str() ` and :func:`repr` of an enum " "to show its members as belonging to the module instead of its class. Should " @@ -997,40 +1343,54 @@ msgid "" "namespace (see :class:`re.RegexFlag` for an example)." msgstr "" -#: library/enum.rst:949 +#: library/enum.rst:953 msgid "Return a list of all power-of-two integers contained in a flag *value*." msgstr "" -#: library/enum.rst:956 +#: library/enum.rst:960 msgid "Notes" msgstr "" -#: library/enum.rst:958 +#: library/enum.rst:962 msgid ":class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag`" msgstr "" -#: library/enum.rst:960 +#: library/enum.rst:964 msgid "" "These three enum types are designed to be drop-in replacements for existing " "integer- and string-based values; as such, they have extra limitations:" msgstr "" -#: library/enum.rst:963 +#: library/enum.rst:967 msgid "``__str__`` uses the value and not the name of the enum member" msgstr "" -#: library/enum.rst:965 +#: library/enum.rst:969 msgid "" "``__format__``, because it uses ``__str__``, will also use the value of the " "enum member instead of its name" msgstr "" -#: library/enum.rst:968 +#: library/enum.rst:972 msgid "" "If you do not need/want those limitations, you can either create your own " "base class by mixing in the ``int`` or ``str`` type yourself::" msgstr "" #: library/enum.rst:975 +msgid "" +">>> from enum import Enum\n" +">>> class MyIntEnum(int, Enum):\n" +"... pass" +msgstr "" + +#: library/enum.rst:979 msgid "or you can reassign the appropriate :meth:`str`, etc., in your enum::" msgstr "" + +#: library/enum.rst:981 +msgid "" +">>> from enum import Enum, IntEnum\n" +">>> class MyIntEnum(IntEnum):\n" +"... __str__ = Enum.__str__" +msgstr "" diff --git a/library/errno.po b/library/errno.po index b1af7cea..05d7b8ef 100644 --- a/library/errno.po +++ b/library/errno.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/errno.rst:2 -msgid ":mod:`errno` --- Standard errno system symbols" +msgid ":mod:`!errno` --- Standard errno system symbols" msgstr "" #: library/errno.rst:9 @@ -37,8 +38,8 @@ msgstr "" #: library/errno.rst:21 msgid "" -"To translate a numeric error code to an error message, use :func:`os." -"strerror`." +"To translate a numeric error code to an error message, " +"use :func:`os.strerror`." msgstr "" #: library/errno.rst:23 @@ -50,26 +51,26 @@ msgstr "" #: library/errno.rst:30 msgid "" -"Operation not permitted. This error is mapped to the exception :exc:" -"`PermissionError`." +"Operation not permitted. This error is mapped to the " +"exception :exc:`PermissionError`." msgstr "" #: library/errno.rst:36 msgid "" -"No such file or directory. This error is mapped to the exception :exc:" -"`FileNotFoundError`." +"No such file or directory. This error is mapped to the " +"exception :exc:`FileNotFoundError`." msgstr "" #: library/errno.rst:42 msgid "" -"No such process. This error is mapped to the exception :exc:" -"`ProcessLookupError`." +"No such process. This error is mapped to the " +"exception :exc:`ProcessLookupError`." msgstr "" #: library/errno.rst:48 msgid "" -"Interrupted system call. This error is mapped to the exception :exc:" -"`InterruptedError`." +"Interrupted system call. This error is mapped to the " +"exception :exc:`InterruptedError`." msgstr "" #: library/errno.rst:54 @@ -94,8 +95,8 @@ msgstr "" #: library/errno.rst:79 msgid "" -"No child processes. This error is mapped to the exception :exc:" -"`ChildProcessError`." +"No child processes. This error is mapped to the " +"exception :exc:`ChildProcessError`." msgstr "" #: library/errno.rst:85 @@ -109,8 +110,8 @@ msgstr "" #: library/errno.rst:95 msgid "" -"Permission denied. This error is mapped to the exception :exc:" -"`PermissionError`." +"Permission denied. This error is mapped to the " +"exception :exc:`PermissionError`." msgstr "" #: library/errno.rst:101 @@ -140,14 +141,14 @@ msgstr "" #: library/errno.rst:132 msgid "" -"Not a directory. This error is mapped to the exception :exc:" -"`NotADirectoryError`." +"Not a directory. This error is mapped to the " +"exception :exc:`NotADirectoryError`." msgstr "" #: library/errno.rst:138 msgid "" -"Is a directory. This error is mapped to the exception :exc:" -"`IsADirectoryError`." +"Is a directory. This error is mapped to the " +"exception :exc:`IsADirectoryError`." msgstr "" #: library/errno.rst:144 @@ -229,8 +230,8 @@ msgstr "" #: library/errno.rst:240 msgid "" -"Operation would block. This error is mapped to the exception :exc:" -"`BlockingIOError`." +"Operation would block. This error is mapped to the " +"exception :exc:`BlockingIOError`." msgstr "" #: library/errno.rst:246 @@ -483,14 +484,14 @@ msgstr "" #: library/errno.rst:558 msgid "" -"Software caused connection abort. This error is mapped to the exception :exc:" -"`ConnectionAbortedError`." +"Software caused connection abort. This error is mapped to the " +"exception :exc:`ConnectionAbortedError`." msgstr "" #: library/errno.rst:564 msgid "" -"Connection reset by peer. This error is mapped to the exception :exc:" -"`ConnectionResetError`." +"Connection reset by peer. This error is mapped to the " +"exception :exc:`ConnectionResetError`." msgstr "" #: library/errno.rst:570 @@ -517,14 +518,14 @@ msgstr "" #: library/errno.rst:596 msgid "" -"Connection timed out. This error is mapped to the exception :exc:" -"`TimeoutError`." +"Connection timed out. This error is mapped to the " +"exception :exc:`TimeoutError`." msgstr "" #: library/errno.rst:602 msgid "" -"Connection refused. This error is mapped to the exception :exc:" -"`ConnectionRefusedError`." +"Connection refused. This error is mapped to the " +"exception :exc:`ConnectionRefusedError`." msgstr "" #: library/errno.rst:608 @@ -537,14 +538,14 @@ msgstr "" #: library/errno.rst:618 msgid "" -"Operation already in progress. This error is mapped to the exception :exc:" -"`BlockingIOError`." +"Operation already in progress. This error is mapped to the " +"exception :exc:`BlockingIOError`." msgstr "" #: library/errno.rst:624 msgid "" -"Operation now in progress. This error is mapped to the exception :exc:" -"`BlockingIOError`." +"Operation now in progress. This error is mapped to the " +"exception :exc:`BlockingIOError`." msgstr "" #: library/errno.rst:630 @@ -579,24 +580,128 @@ msgstr "" msgid "Interface output queue is full" msgstr "" -#: library/errno.rst:670 +#: library/errno.rst:671 +msgid "No medium found" +msgstr "" + +#: library/errno.rst:676 +msgid "Wrong medium type" +msgstr "" + +#: library/errno.rst:681 +msgid "Required key not available" +msgstr "" + +#: library/errno.rst:686 +msgid "Key has expired" +msgstr "" + +#: library/errno.rst:691 +msgid "Key has been revoked" +msgstr "" + +#: library/errno.rst:696 +msgid "Key was rejected by service" +msgstr "" + +#: library/errno.rst:701 +msgid "Operation not possible due to RF-kill" +msgstr "" + +#: library/errno.rst:706 +msgid "Locked lock was unmapped" +msgstr "" + +#: library/errno.rst:711 +msgid "Facility is not active" +msgstr "" + +#: library/errno.rst:716 +msgid "Authentication error" +msgstr "" + +#: library/errno.rst:723 +msgid "Bad CPU type in executable" +msgstr "" + +#: library/errno.rst:730 +msgid "Bad executable (or shared library)" +msgstr "" + +#: library/errno.rst:737 +msgid "Malformed Mach-o file" +msgstr "" + +#: library/errno.rst:744 +msgid "Device error" +msgstr "" + +#: library/errno.rst:751 +msgid "Inappropriate file type or format" +msgstr "" + +#: library/errno.rst:758 +msgid "Need authenticator" +msgstr "" + +#: library/errno.rst:765 +msgid "Attribute not found" +msgstr "" + +#: library/errno.rst:772 +msgid "Policy not found" +msgstr "" + +#: library/errno.rst:779 +msgid "Too many processes" +msgstr "" + +#: library/errno.rst:786 +msgid "Bad procedure for program" +msgstr "" + +#: library/errno.rst:793 +msgid "Program version wrong" +msgstr "" + +#: library/errno.rst:800 +msgid "RPC prog. not avail" +msgstr "" + +#: library/errno.rst:807 +msgid "Device power is off" +msgstr "" + +#: library/errno.rst:814 +msgid "RPC struct is bad" +msgstr "" + +#: library/errno.rst:821 +msgid "RPC version wrong" +msgstr "" + +#: library/errno.rst:828 +msgid "Shared library version mismatch" +msgstr "" + +#: library/errno.rst:835 msgid "" -"Capabilities insufficient. This error is mapped to the exception :exc:" -"`PermissionError`." +"Capabilities insufficient. This error is mapped to the " +"exception :exc:`PermissionError`." msgstr "" -#: library/errno.rst:673 -msgid ":ref:`Availability `: WASI, FreeBSD" +#: library/errno.rst:838 +msgid "Availability" msgstr "" -#: library/errno.rst:680 +#: library/errno.rst:845 msgid "Operation canceled" msgstr "" -#: library/errno.rst:687 +#: library/errno.rst:852 msgid "Owner died" msgstr "" -#: library/errno.rst:694 +#: library/errno.rst:859 msgid "State not recoverable" msgstr "" diff --git a/library/exceptions.po b/library/exceptions.po index 24081f98..2d71c8a2 100644 --- a/library/exceptions.po +++ b/library/exceptions.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -22,12 +23,13 @@ msgstr "" #: library/exceptions.rst:10 msgid "" -"In Python, all exceptions must be instances of a class that derives from :" -"class:`BaseException`. In a :keyword:`try` statement with an :keyword:" -"`except` clause that mentions a particular class, that clause also handles " -"any exception classes derived from that class (but not exception classes " -"from which *it* is derived). Two exception classes that are not related via " -"subclassing are never equivalent, even if they have the same name." +"In Python, all exceptions must be instances of a class that derives " +"from :class:`BaseException`. In a :keyword:`try` statement with " +"an :keyword:`except` clause that mentions a particular class, that clause " +"also handles any exception classes derived from that class (but not " +"exception classes from which *it* is derived). Two exception classes that " +"are not related via subclassing are never equivalent, even if they have the " +"same name." msgstr "" #: library/exceptions.rst:19 @@ -52,10 +54,10 @@ msgstr "" #: library/exceptions.rst:31 msgid "" "The built-in exception classes can be subclassed to define new exceptions; " -"programmers are encouraged to derive new exceptions from the :exc:" -"`Exception` class or one of its subclasses, and not from :exc:" -"`BaseException`. More information on defining exceptions is available in " -"the Python Tutorial under :ref:`tut-userexceptions`." +"programmers are encouraged to derive new exceptions from " +"the :exc:`Exception` class or one of its subclasses, and not " +"from :exc:`BaseException`. More information on defining exceptions is " +"available in the Python Tutorial under :ref:`tut-userexceptions`." msgstr "" #: library/exceptions.rst:39 @@ -72,9 +74,9 @@ msgstr "" msgid "" "When raising a new exception while another exception is already being " "handled, the new exception's :attr:`!__context__` attribute is automatically " -"set to the handled exception. An exception may be handled when an :keyword:" -"`except` or :keyword:`finally` clause, or a :keyword:`with` statement, is " -"used." +"set to the handled exception. An exception may be handled when " +"an :keyword:`except` or :keyword:`finally` clause, or a :keyword:`with` " +"statement, is used." msgstr "" #: library/exceptions.rst:59 @@ -83,6 +85,10 @@ msgid "" "by using :keyword:`!from` with :keyword:`raise`::" msgstr "" +#: library/exceptions.rst:63 +msgid "raise new_exc from original_exc" +msgstr "" + #: library/exceptions.rst:65 msgid "" "The expression following :keyword:`from` must be an exception or " @@ -125,12 +131,13 @@ msgstr "" #: library/exceptions.rst:95 msgid "" -"Most built-in exceptions are implemented in C for efficiency, see: :source:" -"`Objects/exceptions.c`. Some have custom memory layouts which makes it " -"impossible to create a subclass that inherits from multiple exception types. " -"The memory layout of a type is an implementation detail and might change " -"between Python versions, leading to new conflicts in the future. Therefore, " -"it's recommended to avoid subclassing multiple exception types altogether." +"Most built-in exceptions are implemented in C for efficiency, " +"see: :source:`Objects/exceptions.c`. Some have custom memory layouts which " +"makes it impossible to create a subclass that inherits from multiple " +"exception types. The memory layout of a type is an implementation detail and " +"might change between Python versions, leading to new conflicts in the " +"future. Therefore, it's recommended to avoid subclassing multiple exception " +"types altogether." msgstr "" #: library/exceptions.rst:105 @@ -146,9 +153,9 @@ msgstr "" #: library/exceptions.rst:111 msgid "" "The base class for all built-in exceptions. It is not meant to be directly " -"inherited by user-defined classes (for that, use :exc:`Exception`). If :" -"func:`str` is called on an instance of this class, the representation of the " -"argument(s) to the instance are returned, or the empty string when there " +"inherited by user-defined classes (for that, use :exc:`Exception`). " +"If :func:`str` is called on an instance of this class, the representation of " +"the argument(s) to the instance are returned, or the empty string when there " "were no arguments." msgstr "" @@ -172,6 +179,15 @@ msgid "" "it to propagate to the caller. ::" msgstr "" +#: library/exceptions.rst:135 +msgid "" +"try:\n" +" ...\n" +"except SomeException:\n" +" tb = sys.exception().__traceback__\n" +" raise OtherException(...).with_traceback(tb)" +msgstr "" + #: library/exceptions.rst:143 msgid "" "A writable field that holds the :ref:`traceback object ` " @@ -187,8 +203,9 @@ msgstr "" #: library/exceptions.rst:157 msgid "" -"A list of the notes of this exception, which were added with :meth:" -"`add_note`. This attribute is created when :meth:`add_note` is called." +"A list of the notes of this exception, which were added " +"with :meth:`add_note`. This attribute is created when :meth:`add_note` is " +"called." msgstr "" #: library/exceptions.rst:165 @@ -200,8 +217,8 @@ msgstr "" #: library/exceptions.rst:171 msgid "" "The base class for those built-in exceptions that are raised for various " -"arithmetic errors: :exc:`OverflowError`, :exc:`ZeroDivisionError`, :exc:" -"`FloatingPointError`." +"arithmetic " +"errors: :exc:`OverflowError`, :exc:`ZeroDivisionError`, :exc:`FloatingPointError`." msgstr "" #: library/exceptions.rst:178 @@ -251,8 +268,9 @@ msgstr "" #: library/exceptions.rst:217 msgid "" "Raised when the :func:`input` function hits an end-of-file condition (EOF) " -"without reading any data. (N.B.: the :meth:`io.IOBase.read` and :meth:`io." -"IOBase.readline` methods return an empty string when they hit EOF.)" +"without reading any data. (N.B.: the :meth:`io.IOBase.read` " +"and :meth:`io.IOBase.readline` methods return an empty string when they hit " +"EOF.)" msgstr "" #: library/exceptions.rst:224 @@ -261,10 +279,10 @@ msgstr "" #: library/exceptions.rst:229 msgid "" -"Raised when a :term:`generator` or :term:`coroutine` is closed; see :meth:" -"`generator.close` and :meth:`coroutine.close`. It directly inherits from :" -"exc:`BaseException` instead of :exc:`Exception` since it is technically not " -"an error." +"Raised when a :term:`generator` or :term:`coroutine` is closed; " +"see :meth:`generator.close` and :meth:`coroutine.close`. It directly " +"inherits from :exc:`BaseException` instead of :exc:`Exception` since it is " +"technically not an error." msgstr "" #: library/exceptions.rst:237 @@ -295,8 +313,8 @@ msgstr "" #: library/exceptions.rst:257 msgid "" "A subclass of :exc:`ImportError` which is raised by :keyword:`import` when a " -"module could not be located. It is also raised when ``None`` is found in :" -"data:`sys.modules`." +"module could not be located. It is also raised when ``None`` is found " +"in :data:`sys.modules`." msgstr "" #: library/exceptions.rst:266 @@ -314,9 +332,9 @@ msgstr "" #: library/exceptions.rst:282 msgid "" -"Raised when the user hits the interrupt key (normally :kbd:`Control-C` or :" -"kbd:`Delete`). During execution, a check for interrupts is made regularly. " -"The exception inherits from :exc:`BaseException` so as to not be " +"Raised when the user hits the interrupt key (normally :kbd:`Control-C` " +"or :kbd:`Delete`). During execution, a check for interrupts is made " +"regularly. The exception inherits from :exc:`BaseException` so as to not be " "accidentally caught by code that catches :exc:`Exception` and thus prevent " "the interpreter from exiting." msgstr "" @@ -335,10 +353,11 @@ msgid "" "Raised when an operation runs out of memory but the situation may still be " "rescued (by deleting some objects). The associated value is a string " "indicating what kind of (internal) operation ran out of memory. Note that " -"because of the underlying memory management architecture (C's :c:func:" -"`malloc` function), the interpreter may not always be able to completely " -"recover from this situation; it nevertheless raises an exception so that a " -"stack traceback can be printed, in case a run-away program was the cause." +"because of the underlying memory management architecture " +"(C's :c:func:`malloc` function), the interpreter may not always be able to " +"completely recover from this situation; it nevertheless raises an exception " +"so that a stack traceback can be printed, in case a run-away program was the " +"cause." msgstr "" #: library/exceptions.rst:311 @@ -384,26 +403,26 @@ msgstr "" #: library/exceptions.rst:347 msgid "" "This exception is raised when a system function returns a system-related " -"error, including I/O failures such as \"file not found\" or \"disk " -"full\" (not for illegal argument types or other incidental errors)." +"error, including I/O failures such as \"file not found\" or \"disk full\" " +"(not for illegal argument types or other incidental errors)." msgstr "" #: library/exceptions.rst:351 msgid "" "The second form of the constructor sets the corresponding attributes, " "described below. The attributes default to :const:`None` if not specified. " -"For backwards compatibility, if three arguments are passed, the :attr:" -"`~BaseException.args` attribute contains only a 2-tuple of the first two " -"constructor arguments." +"For backwards compatibility, if three arguments are passed, " +"the :attr:`~BaseException.args` attribute contains only a 2-tuple of the " +"first two constructor arguments." msgstr "" #: library/exceptions.rst:357 msgid "" "The constructor often actually returns a subclass of :exc:`OSError`, as " "described in `OS exceptions`_ below. The particular subclass depends on the " -"final :attr:`.errno` value. This behaviour only occurs when constructing :" -"exc:`OSError` directly or via an alias, and is not inherited when " -"subclassing." +"final :attr:`.errno` value. This behaviour only occurs when " +"constructing :exc:`OSError` directly or via an alias, and is not inherited " +"when subclassing." msgstr "" #: library/exceptions.rst:365 @@ -412,65 +431,65 @@ msgstr "" #: library/exceptions.rst:369 msgid "" -"Under Windows, this gives you the native Windows error code. The :attr:`." -"errno` attribute is then an approximate translation, in POSIX terms, of that " -"native error code." +"Under Windows, this gives you the native Windows error code. " +"The :attr:`.errno` attribute is then an approximate translation, in POSIX " +"terms, of that native error code." msgstr "" #: library/exceptions.rst:373 msgid "" -"Under Windows, if the *winerror* constructor argument is an integer, the :" -"attr:`.errno` attribute is determined from the Windows error code, and the " -"*errno* argument is ignored. On other platforms, the *winerror* argument is " -"ignored, and the :attr:`winerror` attribute does not exist." +"Under Windows, if the *winerror* constructor argument is an integer, " +"the :attr:`.errno` attribute is determined from the Windows error code, and " +"the *errno* argument is ignored. On other platforms, the *winerror* " +"argument is ignored, and the :attr:`winerror` attribute does not exist." msgstr "" #: library/exceptions.rst:381 msgid "" "The corresponding error message, as provided by the operating system. It is " -"formatted by the C functions :c:func:`perror` under POSIX, and :c:func:" -"`FormatMessage` under Windows." +"formatted by the C functions :c:func:`perror` under POSIX, " +"and :c:func:`FormatMessage` under Windows." msgstr "" #: library/exceptions.rst:389 msgid "" -"For exceptions that involve a file system path (such as :func:`open` or :" -"func:`os.unlink`), :attr:`filename` is the file name passed to the function. " -"For functions that involve two file system paths (such as :func:`os." -"rename`), :attr:`filename2` corresponds to the second file name passed to " -"the function." +"For exceptions that involve a file system path (such as :func:`open` " +"or :func:`os.unlink`), :attr:`filename` is the file name passed to the " +"function. For functions that involve two file system paths (such " +"as :func:`os.rename`), :attr:`filename2` corresponds to the second file name " +"passed to the function." msgstr "" #: library/exceptions.rst:396 msgid "" -":exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`, :exc:`socket." -"error`, :exc:`select.error` and :exc:`mmap.error` have been merged into :exc:" -"`OSError`, and the constructor may return a subclass." +":exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`, :exc:`socket.error`, :exc:`select.error` " +"and :exc:`mmap.error` have been merged into :exc:`OSError`, and the " +"constructor may return a subclass." msgstr "" #: library/exceptions.rst:402 msgid "" "The :attr:`filename` attribute is now the original file name passed to the " -"function, instead of the name encoded to or decoded from the :term:" -"`filesystem encoding and error handler`. Also, the *filename2* constructor " -"argument and attribute was added." +"function, instead of the name encoded to or decoded from " +"the :term:`filesystem encoding and error handler`. Also, the *filename2* " +"constructor argument and attribute was added." msgstr "" #: library/exceptions.rst:411 msgid "" "Raised when the result of an arithmetic operation is too large to be " -"represented. This cannot occur for integers (which would rather raise :exc:" -"`MemoryError` than give up). However, for historical reasons, OverflowError " -"is sometimes raised for integers that are outside a required range. " -"Because of the lack of standardization of floating point exception handling " -"in C, most floating point operations are not checked." +"represented. This cannot occur for integers (which would rather " +"raise :exc:`MemoryError` than give up). However, for historical reasons, " +"OverflowError is sometimes raised for integers that are outside a required " +"range. Because of the lack of standardization of floating-point exception " +"handling in C, most floating-point operations are not checked." msgstr "" #: library/exceptions.rst:421 msgid "" "This exception is derived from :exc:`RuntimeError`. It is raised when the " -"interpreter detects that the maximum recursion depth (see :func:`sys." -"getrecursionlimit`) is exceeded." +"interpreter detects that the maximum recursion depth " +"(see :func:`sys.getrecursionlimit`) is exceeded." msgstr "" #: library/exceptions.rst:425 @@ -479,9 +498,9 @@ msgstr "" #: library/exceptions.rst:431 msgid "" -"This exception is raised when a weak reference proxy, created by the :func:" -"`weakref.proxy` function, is used to access an attribute of the referent " -"after it has been garbage collected. For more information on weak " +"This exception is raised when a weak reference proxy, created by " +"the :func:`weakref.proxy` function, is used to access an attribute of the " +"referent after it has been garbage collected. For more information on weak " "references, see the :mod:`weakref` module." msgstr "" @@ -494,23 +513,24 @@ msgstr "" #: library/exceptions.rst:446 msgid "" -"Raised by built-in function :func:`next` and an :term:`iterator`\\'s :meth:" -"`~iterator.__next__` method to signal that there are no further items " -"produced by the iterator." +"Raised by built-in function :func:`next` and " +"an :term:`iterator`\\'s :meth:`~iterator.__next__` method to signal that " +"there are no further items produced by the iterator." msgstr "" #: library/exceptions.rst:452 msgid "" "The exception object has a single attribute :attr:`!value`, which is given " -"as an argument when constructing the exception, and defaults to :const:" -"`None`." +"as an argument when constructing the exception, and defaults " +"to :const:`None`." msgstr "" #: library/exceptions.rst:456 msgid "" -"When a :term:`generator` or :term:`coroutine` function returns, a new :exc:" -"`StopIteration` instance is raised, and the value returned by the function " -"is used as the :attr:`value` parameter to the constructor of the exception." +"When a :term:`generator` or :term:`coroutine` function returns, a " +"new :exc:`StopIteration` instance is raised, and the value returned by the " +"function is used as the :attr:`value` parameter to the constructor of the " +"exception." msgstr "" #: library/exceptions.rst:461 @@ -546,10 +566,10 @@ msgstr "" #: library/exceptions.rst:486 msgid "" -"Raised when the parser encounters a syntax error. This may occur in an :" -"keyword:`import` statement, in a call to the built-in functions :func:" -"`compile`, :func:`exec`, or :func:`eval`, or when reading the initial script " -"or standard input (also interactively)." +"Raised when the parser encounters a syntax error. This may occur in " +"an :keyword:`import` statement, in a call to the built-in " +"functions :func:`compile`, :func:`exec`, or :func:`eval`, or when reading " +"the initial script or standard input (also interactively)." msgstr "" #: library/exceptions.rst:492 @@ -618,33 +638,37 @@ msgstr "" msgid "" "Raised when the interpreter finds an internal error, but the situation does " "not look so serious to cause it to abandon all hope. The associated value is " -"a string indicating what went wrong (in low-level terms)." +"a string indicating what went wrong (in low-level terms). " +"In :term:`CPython`, this could be raised by incorrectly using Python's C " +"API, such as returning a ``NULL`` value without an exception set." msgstr "" -#: library/exceptions.rst:549 +#: library/exceptions.rst:551 msgid "" -"You should report this to the author or maintainer of your Python " -"interpreter. Be sure to report the version of the Python interpreter (``sys." -"version``; it is also printed at the start of an interactive Python " -"session), the exact error message (the exception's associated value) and if " -"possible the source of the program that triggered the error." +"If you're confident that this exception wasn't your fault, or the fault of a " +"package you're using, you should report this to the author or maintainer of " +"your Python interpreter. Be sure to report the version of the Python " +"interpreter (``sys.version``; it is also printed at the start of an " +"interactive Python session), the exact error message (the exception's " +"associated value) and if possible the source of the program that triggered " +"the error." msgstr "" -#: library/exceptions.rst:558 +#: library/exceptions.rst:562 msgid "" "This exception is raised by the :func:`sys.exit` function. It inherits " "from :exc:`BaseException` instead of :exc:`Exception` so that it is not " "accidentally caught by code that catches :exc:`Exception`. This allows the " "exception to properly propagate up and cause the interpreter to exit. When " "it is not handled, the Python interpreter exits; no stack traceback is " -"printed. The constructor accepts the same optional argument passed to :func:" -"`sys.exit`. If the value is an integer, it specifies the system exit status " -"(passed to C's :c:func:`exit` function); if it is ``None``, the exit status " -"is zero; if it has another type (such as a string), the object's value is " -"printed and the exit status is one." +"printed. The constructor accepts the same optional argument passed " +"to :func:`sys.exit`. If the value is an integer, it specifies the system " +"exit status (passed to C's :c:func:`exit` function); if it is ``None``, the " +"exit status is zero; if it has another type (such as a string), the object's " +"value is printed and the exit status is one." msgstr "" -#: library/exceptions.rst:569 +#: library/exceptions.rst:573 msgid "" "A call to :func:`sys.exit` is translated into an exception so that clean-up " "handlers (:keyword:`finally` clauses of :keyword:`try` statements) can be " @@ -654,20 +678,20 @@ msgid "" "child process after a call to :func:`os.fork`)." msgstr "" -#: library/exceptions.rst:578 +#: library/exceptions.rst:582 msgid "" "The exit status or error message that is passed to the constructor. " "(Defaults to ``None``.)" msgstr "" -#: library/exceptions.rst:584 +#: library/exceptions.rst:588 msgid "" "Raised when an operation or function is applied to an object of " "inappropriate type. The associated value is a string giving details about " "the type mismatch." msgstr "" -#: library/exceptions.rst:587 +#: library/exceptions.rst:591 msgid "" "This exception may be raised by user code to indicate that an attempted " "operation on an object is not supported, and is not meant to be. If an " @@ -675,343 +699,344 @@ msgid "" "implementation, :exc:`NotImplementedError` is the proper exception to raise." msgstr "" -#: library/exceptions.rst:592 +#: library/exceptions.rst:596 msgid "" -"Passing arguments of the wrong type (e.g. passing a :class:`list` when an :" -"class:`int` is expected) should result in a :exc:`TypeError`, but passing " -"arguments with the wrong value (e.g. a number outside expected boundaries) " -"should result in a :exc:`ValueError`." +"Passing arguments of the wrong type (e.g. passing a :class:`list` when " +"an :class:`int` is expected) should result in a :exc:`TypeError`, but " +"passing arguments with the wrong value (e.g. a number outside expected " +"boundaries) should result in a :exc:`ValueError`." msgstr "" -#: library/exceptions.rst:599 +#: library/exceptions.rst:603 msgid "" "Raised when a reference is made to a local variable in a function or method, " -"but no value has been bound to that variable. This is a subclass of :exc:" -"`NameError`." +"but no value has been bound to that variable. This is a subclass " +"of :exc:`NameError`." msgstr "" -#: library/exceptions.rst:606 +#: library/exceptions.rst:610 msgid "" "Raised when a Unicode-related encoding or decoding error occurs. It is a " "subclass of :exc:`ValueError`." msgstr "" -#: library/exceptions.rst:609 +#: library/exceptions.rst:613 msgid "" ":exc:`UnicodeError` has attributes that describe the encoding or decoding " "error. For example, ``err.object[err.start:err.end]`` gives the particular " "invalid input that the codec failed on." msgstr "" -#: library/exceptions.rst:615 +#: library/exceptions.rst:619 msgid "The name of the encoding that raised the error." msgstr "" -#: library/exceptions.rst:619 +#: library/exceptions.rst:623 msgid "A string describing the specific codec error." msgstr "" -#: library/exceptions.rst:623 +#: library/exceptions.rst:627 msgid "The object the codec was attempting to encode or decode." msgstr "" -#: library/exceptions.rst:627 +#: library/exceptions.rst:631 msgid "The first index of invalid data in :attr:`object`." msgstr "" -#: library/exceptions.rst:631 +#: library/exceptions.rst:635 msgid "The index after the last invalid data in :attr:`object`." msgstr "" -#: library/exceptions.rst:636 +#: library/exceptions.rst:640 msgid "" "Raised when a Unicode-related error occurs during encoding. It is a " "subclass of :exc:`UnicodeError`." msgstr "" -#: library/exceptions.rst:642 +#: library/exceptions.rst:646 msgid "" "Raised when a Unicode-related error occurs during decoding. It is a " "subclass of :exc:`UnicodeError`." msgstr "" -#: library/exceptions.rst:648 +#: library/exceptions.rst:652 msgid "" "Raised when a Unicode-related error occurs during translating. It is a " "subclass of :exc:`UnicodeError`." msgstr "" -#: library/exceptions.rst:654 +#: library/exceptions.rst:658 msgid "" "Raised when an operation or function receives an argument that has the right " "type but an inappropriate value, and the situation is not described by a " "more precise exception such as :exc:`IndexError`." msgstr "" -#: library/exceptions.rst:661 +#: library/exceptions.rst:665 msgid "" "Raised when the second argument of a division or modulo operation is zero. " "The associated value is a string indicating the type of the operands and the " "operation." msgstr "" -#: library/exceptions.rst:666 +#: library/exceptions.rst:670 msgid "" "The following exceptions are kept for compatibility with previous versions; " "starting from Python 3.3, they are aliases of :exc:`OSError`." msgstr "" -#: library/exceptions.rst:675 +#: library/exceptions.rst:679 msgid "Only available on Windows." msgstr "" -#: library/exceptions.rst:679 +#: library/exceptions.rst:683 msgid "OS exceptions" msgstr "" -#: library/exceptions.rst:681 +#: library/exceptions.rst:685 msgid "" "The following exceptions are subclasses of :exc:`OSError`, they get raised " "depending on the system error code." msgstr "" -#: library/exceptions.rst:686 +#: library/exceptions.rst:690 msgid "" "Raised when an operation would block on an object (e.g. socket) set for non-" -"blocking operation. Corresponds to :c:data:`errno` :py:const:`~errno." -"EAGAIN`, :py:const:`~errno.EALREADY`, :py:const:`~errno.EWOULDBLOCK` and :py:" -"const:`~errno.EINPROGRESS`." +"blocking operation. Corresponds " +"to :c:data:`errno` :py:const:`~errno.EAGAIN`, :py:const:`~errno.EALREADY`, :py:const:`~errno.EWOULDBLOCK` " +"and :py:const:`~errno.EINPROGRESS`." msgstr "" -#: library/exceptions.rst:691 +#: library/exceptions.rst:695 msgid "" "In addition to those of :exc:`OSError`, :exc:`BlockingIOError` can have one " "more attribute:" msgstr "" -#: library/exceptions.rst:696 +#: library/exceptions.rst:700 msgid "" "An integer containing the number of characters written to the stream before " "it blocked. This attribute is available when using the buffered I/O classes " "from the :mod:`io` module." msgstr "" -#: library/exceptions.rst:702 +#: library/exceptions.rst:706 msgid "" -"Raised when an operation on a child process failed. Corresponds to :c:data:" -"`errno` :py:const:`~errno.ECHILD`." +"Raised when an operation on a child process failed. Corresponds " +"to :c:data:`errno` :py:const:`~errno.ECHILD`." msgstr "" -#: library/exceptions.rst:707 +#: library/exceptions.rst:711 msgid "A base class for connection-related issues." msgstr "" -#: library/exceptions.rst:709 +#: library/exceptions.rst:713 msgid "" -"Subclasses are :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`, :exc:" -"`ConnectionRefusedError` and :exc:`ConnectionResetError`." +"Subclasses " +"are :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`, :exc:`ConnectionRefusedError` " +"and :exc:`ConnectionResetError`." msgstr "" -#: library/exceptions.rst:714 +#: library/exceptions.rst:718 msgid "" "A subclass of :exc:`ConnectionError`, raised when trying to write on a pipe " "while the other end has been closed, or trying to write on a socket which " -"has been shutdown for writing. Corresponds to :c:data:`errno` :py:const:" -"`~errno.EPIPE` and :py:const:`~errno.ESHUTDOWN`." +"has been shutdown for writing. Corresponds " +"to :c:data:`errno` :py:const:`~errno.EPIPE` and :py:const:`~errno.ESHUTDOWN`." msgstr "" -#: library/exceptions.rst:721 +#: library/exceptions.rst:725 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection attempt is " -"aborted by the peer. Corresponds to :c:data:`errno` :py:const:`~errno." -"ECONNABORTED`." +"aborted by the peer. Corresponds " +"to :c:data:`errno` :py:const:`~errno.ECONNABORTED`." msgstr "" -#: library/exceptions.rst:727 +#: library/exceptions.rst:731 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection attempt is " -"refused by the peer. Corresponds to :c:data:`errno` :py:const:`~errno." -"ECONNREFUSED`." +"refused by the peer. Corresponds " +"to :c:data:`errno` :py:const:`~errno.ECONNREFUSED`." msgstr "" -#: library/exceptions.rst:733 +#: library/exceptions.rst:737 msgid "" "A subclass of :exc:`ConnectionError`, raised when a connection is reset by " "the peer. Corresponds to :c:data:`errno` :py:const:`~errno.ECONNRESET`." msgstr "" -#: library/exceptions.rst:739 +#: library/exceptions.rst:743 msgid "" "Raised when trying to create a file or directory which already exists. " "Corresponds to :c:data:`errno` :py:const:`~errno.EEXIST`." msgstr "" -#: library/exceptions.rst:744 +#: library/exceptions.rst:748 msgid "" "Raised when a file or directory is requested but doesn't exist. Corresponds " "to :c:data:`errno` :py:const:`~errno.ENOENT`." msgstr "" -#: library/exceptions.rst:749 +#: library/exceptions.rst:753 msgid "" "Raised when a system call is interrupted by an incoming signal. Corresponds " "to :c:data:`errno` :py:const:`~errno.EINTR`." msgstr "" -#: library/exceptions.rst:752 +#: library/exceptions.rst:756 msgid "" "Python now retries system calls when a syscall is interrupted by a signal, " "except if the signal handler raises an exception (see :pep:`475` for the " "rationale), instead of raising :exc:`InterruptedError`." msgstr "" -#: library/exceptions.rst:759 +#: library/exceptions.rst:763 msgid "" "Raised when a file operation (such as :func:`os.remove`) is requested on a " "directory. Corresponds to :c:data:`errno` :py:const:`~errno.EISDIR`." msgstr "" -#: library/exceptions.rst:765 +#: library/exceptions.rst:769 msgid "" "Raised when a directory operation (such as :func:`os.listdir`) is requested " "on something which is not a directory. On most POSIX platforms, it may also " "be raised if an operation attempts to open or traverse a non-directory file " -"as if it were a directory. Corresponds to :c:data:`errno` :py:const:`~errno." -"ENOTDIR`." +"as if it were a directory. Corresponds " +"to :c:data:`errno` :py:const:`~errno.ENOTDIR`." msgstr "" -#: library/exceptions.rst:773 +#: library/exceptions.rst:777 msgid "" "Raised when trying to run an operation without the adequate access rights - " -"for example filesystem permissions. Corresponds to :c:data:`errno` :py:const:" -"`~errno.EACCES`, :py:const:`~errno.EPERM`, and :py:const:`~errno." -"ENOTCAPABLE`." +"for example filesystem permissions. Corresponds " +"to :c:data:`errno` :py:const:`~errno.EACCES`, :py:const:`~errno.EPERM`, " +"and :py:const:`~errno.ENOTCAPABLE`." msgstr "" -#: library/exceptions.rst:778 +#: library/exceptions.rst:782 msgid "" -"WASI's :py:const:`~errno.ENOTCAPABLE` is now mapped to :exc:" -"`PermissionError`." +"WASI's :py:const:`~errno.ENOTCAPABLE` is now mapped " +"to :exc:`PermissionError`." msgstr "" -#: library/exceptions.rst:784 +#: library/exceptions.rst:788 msgid "" -"Raised when a given process doesn't exist. Corresponds to :c:data:`errno` :" -"py:const:`~errno.ESRCH`." +"Raised when a given process doesn't exist. Corresponds " +"to :c:data:`errno` :py:const:`~errno.ESRCH`." msgstr "" -#: library/exceptions.rst:789 +#: library/exceptions.rst:793 msgid "" -"Raised when a system function timed out at the system level. Corresponds to :" -"c:data:`errno` :py:const:`~errno.ETIMEDOUT`." +"Raised when a system function timed out at the system level. Corresponds " +"to :c:data:`errno` :py:const:`~errno.ETIMEDOUT`." msgstr "" -#: library/exceptions.rst:792 +#: library/exceptions.rst:796 msgid "All the above :exc:`OSError` subclasses were added." msgstr "" -#: library/exceptions.rst:798 +#: library/exceptions.rst:802 msgid ":pep:`3151` - Reworking the OS and IO exception hierarchy" msgstr "" -#: library/exceptions.rst:804 +#: library/exceptions.rst:808 msgid "Warnings" msgstr "" -#: library/exceptions.rst:806 +#: library/exceptions.rst:810 msgid "" -"The following exceptions are used as warning categories; see the :ref:" -"`warning-categories` documentation for more details." +"The following exceptions are used as warning categories; see " +"the :ref:`warning-categories` documentation for more details." msgstr "" -#: library/exceptions.rst:811 +#: library/exceptions.rst:815 msgid "Base class for warning categories." msgstr "" -#: library/exceptions.rst:816 +#: library/exceptions.rst:820 msgid "Base class for warnings generated by user code." msgstr "" -#: library/exceptions.rst:821 +#: library/exceptions.rst:825 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for other Python developers." msgstr "" -#: library/exceptions.rst:824 +#: library/exceptions.rst:828 msgid "" -"Ignored by the default warning filters, except in the ``__main__`` module (:" -"pep:`565`). Enabling the :ref:`Python Development Mode ` shows this " -"warning." +"Ignored by the default warning filters, except in the ``__main__`` module " +"(:pep:`565`). Enabling the :ref:`Python Development Mode ` shows " +"this warning." msgstr "" -#: library/exceptions.rst:844 +#: library/exceptions.rst:848 msgid "The deprecation policy is described in :pep:`387`." msgstr "" -#: library/exceptions.rst:833 +#: library/exceptions.rst:837 msgid "" "Base class for warnings about features which are obsolete and expected to be " "deprecated in the future, but are not deprecated at the moment." msgstr "" -#: library/exceptions.rst:837 +#: library/exceptions.rst:841 msgid "" "This class is rarely used as emitting a warning about a possible upcoming " "deprecation is unusual, and :exc:`DeprecationWarning` is preferred for " "already active deprecations." msgstr "" -#: library/exceptions.rst:867 library/exceptions.rst:894 +#: library/exceptions.rst:871 library/exceptions.rst:898 msgid "" "Ignored by the default warning filters. Enabling the :ref:`Python " "Development Mode ` shows this warning." msgstr "" -#: library/exceptions.rst:849 +#: library/exceptions.rst:853 msgid "Base class for warnings about dubious syntax." msgstr "" -#: library/exceptions.rst:854 +#: library/exceptions.rst:858 msgid "Base class for warnings about dubious runtime behavior." msgstr "" -#: library/exceptions.rst:859 +#: library/exceptions.rst:863 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for end users of applications that are written in Python." msgstr "" -#: library/exceptions.rst:865 +#: library/exceptions.rst:869 msgid "Base class for warnings about probable mistakes in module imports." msgstr "" -#: library/exceptions.rst:873 +#: library/exceptions.rst:877 msgid "Base class for warnings related to Unicode." msgstr "" -#: library/exceptions.rst:878 +#: library/exceptions.rst:882 msgid "Base class for warnings related to encodings." msgstr "" -#: library/exceptions.rst:880 +#: library/exceptions.rst:884 msgid "See :ref:`io-encoding-warning` for details." msgstr "" -#: library/exceptions.rst:887 +#: library/exceptions.rst:891 msgid "" "Base class for warnings related to :class:`bytes` and :class:`bytearray`." msgstr "" -#: library/exceptions.rst:892 +#: library/exceptions.rst:896 msgid "Base class for warnings related to resource usage." msgstr "" -#: library/exceptions.rst:903 +#: library/exceptions.rst:907 msgid "Exception groups" msgstr "" -#: library/exceptions.rst:905 +#: library/exceptions.rst:909 msgid "" "The following are used when it is necessary to raise multiple unrelated " "exceptions. They are part of the exception hierarchy so they can be handled " @@ -1020,43 +1045,44 @@ msgid "" "based on the types of the contained exceptions." msgstr "" -#: library/exceptions.rst:914 +#: library/exceptions.rst:918 msgid "" "Both of these exception types wrap the exceptions in the sequence ``excs``. " "The ``msg`` parameter must be a string. The difference between the two " "classes is that :exc:`BaseExceptionGroup` extends :exc:`BaseException` and " -"it can wrap any exception, while :exc:`ExceptionGroup` extends :exc:" -"`Exception` and it can only wrap subclasses of :exc:`Exception`. This design " -"is so that ``except Exception`` catches an :exc:`ExceptionGroup` but not :" -"exc:`BaseExceptionGroup`." +"it can wrap any exception, while :exc:`ExceptionGroup` " +"extends :exc:`Exception` and it can only wrap subclasses " +"of :exc:`Exception`. This design is so that ``except Exception`` catches " +"an :exc:`ExceptionGroup` but not :exc:`BaseExceptionGroup`." msgstr "" -#: library/exceptions.rst:922 +#: library/exceptions.rst:926 msgid "" "The :exc:`BaseExceptionGroup` constructor returns an :exc:`ExceptionGroup` " -"rather than a :exc:`BaseExceptionGroup` if all contained exceptions are :exc:" -"`Exception` instances, so it can be used to make the selection automatic. " -"The :exc:`ExceptionGroup` constructor, on the other hand, raises a :exc:" -"`TypeError` if any contained exception is not an :exc:`Exception` subclass." +"rather than a :exc:`BaseExceptionGroup` if all contained exceptions " +"are :exc:`Exception` instances, so it can be used to make the selection " +"automatic. The :exc:`ExceptionGroup` constructor, on the other hand, raises " +"a :exc:`TypeError` if any contained exception is not an :exc:`Exception` " +"subclass." msgstr "" -#: library/exceptions.rst:931 +#: library/exceptions.rst:935 msgid "The ``msg`` argument to the constructor. This is a read-only attribute." msgstr "" -#: library/exceptions.rst:935 +#: library/exceptions.rst:939 msgid "" "A tuple of the exceptions in the ``excs`` sequence given to the constructor. " "This is a read-only attribute." msgstr "" -#: library/exceptions.rst:940 +#: library/exceptions.rst:944 msgid "" "Returns an exception group that contains only the exceptions from the " "current group that match *condition*, or ``None`` if the result is empty." msgstr "" -#: library/exceptions.rst:943 +#: library/exceptions.rst:947 msgid "" "The condition can be either a function that accepts an exception and returns " "true for those that should be in the subgroup, or it can be an exception " @@ -1064,52 +1090,82 @@ msgid "" "the same check that is used in an ``except`` clause." msgstr "" -#: library/exceptions.rst:948 +#: library/exceptions.rst:952 msgid "" "The nesting structure of the current exception is preserved in the result, " -"as are the values of its :attr:`message`, :attr:`~BaseException." -"__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException." -"__context__` and :attr:`~BaseException.__notes__` fields. Empty nested " -"groups are omitted from the result." +"as are the values of " +"its :attr:`message`, :attr:`~BaseException.__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException.__context__` " +"and :attr:`~BaseException.__notes__` fields. Empty nested groups are omitted " +"from the result." msgstr "" -#: library/exceptions.rst:955 +#: library/exceptions.rst:959 msgid "" "The condition is checked for all exceptions in the nested exception group, " "including the top-level and any nested exception groups. If the condition is " "true for such an exception group, it is included in the result in full." msgstr "" -#: library/exceptions.rst:961 +#: library/exceptions.rst:965 msgid "" "Like :meth:`subgroup`, but returns the pair ``(match, rest)`` where " "``match`` is ``subgroup(condition)`` and ``rest`` is the remaining non-" "matching part." msgstr "" -#: library/exceptions.rst:967 +#: library/exceptions.rst:971 msgid "" "Returns an exception group with the same :attr:`message`, but which wraps " "the exceptions in ``excs``." msgstr "" -#: library/exceptions.rst:970 +#: library/exceptions.rst:974 msgid "" -"This method is used by :meth:`subgroup` and :meth:`split`. A subclass needs " -"to override it in order to make :meth:`subgroup` and :meth:`split` return " +"This method is used by :meth:`subgroup` and :meth:`split`, which are used in " +"various contexts to break up an exception group. A subclass needs to " +"override it in order to make :meth:`subgroup` and :meth:`split` return " "instances of the subclass rather than :exc:`ExceptionGroup`." msgstr "" -#: library/exceptions.rst:975 -msgid "" -":meth:`subgroup` and :meth:`split` copy the :attr:`~BaseException." -"__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException." -"__context__` and :attr:`~BaseException.__notes__` fields from the original " -"exception group to the one returned by :meth:`derive`, so these fields do " -"not need to be updated by :meth:`derive`." -msgstr "" - -#: library/exceptions.rst:1008 +#: library/exceptions.rst:980 +msgid "" +":meth:`subgroup` and :meth:`split` copy " +"the :attr:`~BaseException.__traceback__`, :attr:`~BaseException.__cause__`, :attr:`~BaseException.__context__` " +"and :attr:`~BaseException.__notes__` fields from the original exception " +"group to the one returned by :meth:`derive`, so these fields do not need to " +"be updated by :meth:`derive`." +msgstr "" + +#: library/exceptions.rst:987 +msgid "" +">>> class MyGroup(ExceptionGroup):\n" +"... def derive(self, excs):\n" +"... return MyGroup(self.message, excs)\n" +"...\n" +">>> e = MyGroup(\"eg\", [ValueError(1), TypeError(2)])\n" +">>> e.add_note(\"a note\")\n" +">>> e.__context__ = Exception(\"context\")\n" +">>> e.__cause__ = Exception(\"cause\")\n" +">>> try:\n" +"... raise e\n" +"... except Exception as e:\n" +"... exc = e\n" +"...\n" +">>> match, rest = exc.split(ValueError)\n" +">>> exc, exc.__context__, exc.__cause__, exc.__notes__\n" +"(MyGroup('eg', [ValueError(1), TypeError(2)]), Exception('context'), " +"Exception('cause'), ['a note'])\n" +">>> match, match.__context__, match.__cause__, match.__notes__\n" +"(MyGroup('eg', [ValueError(1)]), Exception('context'), Exception('cause'), " +"['a note'])\n" +">>> rest, rest.__context__, rest.__cause__, rest.__notes__\n" +"(MyGroup('eg', [TypeError(2)]), Exception('context'), Exception('cause'), " +"['a note'])\n" +">>> exc.__traceback__ is match.__traceback__ is rest.__traceback__\n" +"True" +msgstr "" + +#: library/exceptions.rst:1013 msgid "" "Note that :exc:`BaseExceptionGroup` defines :meth:`~object.__new__`, so " "subclasses that need a different constructor signature need to override that " @@ -1118,21 +1174,104 @@ msgid "" "group's message from it. ::" msgstr "" -#: library/exceptions.rst:1023 +#: library/exceptions.rst:1019 +msgid "" +"class Errors(ExceptionGroup):\n" +" def __new__(cls, errors, exit_code):\n" +" self = super().__new__(Errors, f\"exit code: {exit_code}\", errors)\n" +" self.exit_code = exit_code\n" +" return self\n" +"\n" +" def derive(self, excs):\n" +" return Errors(excs, self.exit_code)" +msgstr "" + +#: library/exceptions.rst:1028 msgid "" "Like :exc:`ExceptionGroup`, any subclass of :exc:`BaseExceptionGroup` which " -"is also a subclass of :exc:`Exception` can only wrap instances of :exc:" -"`Exception`." +"is also a subclass of :exc:`Exception` can only wrap instances " +"of :exc:`Exception`." msgstr "" -#: library/exceptions.rst:1031 +#: library/exceptions.rst:1036 msgid "Exception hierarchy" msgstr "" -#: library/exceptions.rst:1033 +#: library/exceptions.rst:1038 msgid "The class hierarchy for built-in exceptions is:" msgstr "" +#: library/exceptions.rst:1040 +msgid "" +"BaseException\n" +" ├── BaseExceptionGroup\n" +" ├── GeneratorExit\n" +" ├── KeyboardInterrupt\n" +" ├── SystemExit\n" +" └── Exception\n" +" ├── ArithmeticError\n" +" │ ├── FloatingPointError\n" +" │ ├── OverflowError\n" +" │ └── ZeroDivisionError\n" +" ├── AssertionError\n" +" ├── AttributeError\n" +" ├── BufferError\n" +" ├── EOFError\n" +" ├── ExceptionGroup [BaseExceptionGroup]\n" +" ├── ImportError\n" +" │ └── ModuleNotFoundError\n" +" ├── LookupError\n" +" │ ├── IndexError\n" +" │ └── KeyError\n" +" ├── MemoryError\n" +" ├── NameError\n" +" │ └── UnboundLocalError\n" +" ├── OSError\n" +" │ ├── BlockingIOError\n" +" │ ├── ChildProcessError\n" +" │ ├── ConnectionError\n" +" │ │ ├── BrokenPipeError\n" +" │ │ ├── ConnectionAbortedError\n" +" │ │ ├── ConnectionRefusedError\n" +" │ │ └── ConnectionResetError\n" +" │ ├── FileExistsError\n" +" │ ├── FileNotFoundError\n" +" │ ├── InterruptedError\n" +" │ ├── IsADirectoryError\n" +" │ ├── NotADirectoryError\n" +" │ ├── PermissionError\n" +" │ ├── ProcessLookupError\n" +" │ └── TimeoutError\n" +" ├── ReferenceError\n" +" ├── RuntimeError\n" +" │ ├── NotImplementedError\n" +" │ └── RecursionError\n" +" ├── StopAsyncIteration\n" +" ├── StopIteration\n" +" ├── SyntaxError\n" +" │ └── IndentationError\n" +" │ └── TabError\n" +" ├── SystemError\n" +" ├── TypeError\n" +" ├── ValueError\n" +" │ └── UnicodeError\n" +" │ ├── UnicodeDecodeError\n" +" │ ├── UnicodeEncodeError\n" +" │ └── UnicodeTranslateError\n" +" └── Warning\n" +" ├── BytesWarning\n" +" ├── DeprecationWarning\n" +" ├── EncodingWarning\n" +" ├── FutureWarning\n" +" ├── ImportWarning\n" +" ├── PendingDeprecationWarning\n" +" ├── ResourceWarning\n" +" ├── RuntimeWarning\n" +" ├── SyntaxWarning\n" +" ├── UnicodeWarning\n" +" └── UserWarning\n" +msgstr "" + #: library/exceptions.rst:17 library/exceptions.rst:196 msgid "statement" msgstr "" diff --git a/library/faulthandler.po b/library/faulthandler.po index b004df08..659b2c1d 100644 --- a/library/faulthandler.po +++ b/library/faulthandler.po @@ -8,38 +8,39 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/faulthandler.rst:2 -msgid ":mod:`faulthandler` --- Dump the Python traceback" +msgid ":mod:`!faulthandler` --- Dump the Python traceback" msgstr "" #: library/faulthandler.rst:11 msgid "" "This module contains functions to dump Python tracebacks explicitly, on a " -"fault, after a timeout, or on a user signal. Call :func:`faulthandler." -"enable` to install fault handlers for the :const:`SIGSEGV`, :const:" -"`SIGFPE`, :const:`SIGABRT`, :const:`SIGBUS`, and :const:`SIGILL` signals. " -"You can also enable them at startup by setting the :envvar:" -"`PYTHONFAULTHANDLER` environment variable or by using the :option:`-X` " -"``faulthandler`` command line option." +"fault, after a timeout, or on a user signal. " +"Call :func:`faulthandler.enable` to install fault handlers for " +"the :const:`~signal.SIGSEGV`, :const:`~signal.SIGFPE`, :const:`~signal.SIGABRT`, :const:`~signal.SIGBUS`, " +"and :const:`~signal.SIGILL` signals. You can also enable them at startup by " +"setting the :envvar:`PYTHONFAULTHANDLER` environment variable or by using " +"the :option:`-X` ``faulthandler`` command line option." msgstr "" -#: library/faulthandler.rst:18 +#: library/faulthandler.rst:19 msgid "" "The fault handler is compatible with system fault handlers like Apport or " "the Windows fault handler. The module uses an alternative stack for signal " -"handlers if the :c:func:`sigaltstack` function is available. This allows it " +"handlers if the :c:func:`!sigaltstack` function is available. This allows it " "to dump the traceback even on a stack overflow." msgstr "" -#: library/faulthandler.rst:23 +#: library/faulthandler.rst:24 msgid "" "The fault handler is called on catastrophic cases and therefore can only use " "signal-safe functions (e.g. it cannot allocate memory on the heap). Because " @@ -47,191 +48,193 @@ msgid "" "tracebacks:" msgstr "" -#: library/faulthandler.rst:28 +#: library/faulthandler.rst:29 msgid "" "Only ASCII is supported. The ``backslashreplace`` error handler is used on " "encoding." msgstr "" -#: library/faulthandler.rst:30 +#: library/faulthandler.rst:31 msgid "Each string is limited to 500 characters." msgstr "" -#: library/faulthandler.rst:31 +#: library/faulthandler.rst:32 msgid "" "Only the filename, the function name and the line number are displayed. (no " "source code)" msgstr "" -#: library/faulthandler.rst:33 +#: library/faulthandler.rst:34 msgid "It is limited to 100 frames and 100 threads." msgstr "" -#: library/faulthandler.rst:34 +#: library/faulthandler.rst:35 msgid "The order is reversed: the most recent call is shown first." msgstr "" -#: library/faulthandler.rst:36 +#: library/faulthandler.rst:37 msgid "" "By default, the Python traceback is written to :data:`sys.stderr`. To see " "tracebacks, applications must be run in the terminal. A log file can " "alternatively be passed to :func:`faulthandler.enable`." msgstr "" -#: library/faulthandler.rst:40 +#: library/faulthandler.rst:41 msgid "" "The module is implemented in C, so tracebacks can be dumped on a crash or " "when Python is deadlocked." msgstr "" -#: library/faulthandler.rst:43 +#: library/faulthandler.rst:44 msgid "" -"The :ref:`Python Development Mode ` calls :func:`faulthandler." -"enable` at Python startup." +"The :ref:`Python Development Mode ` " +"calls :func:`faulthandler.enable` at Python startup." msgstr "" #: library/faulthandler.rst:49 msgid "Module :mod:`pdb`" msgstr "" -#: library/faulthandler.rst:49 +#: library/faulthandler.rst:50 msgid "Interactive source code debugger for Python programs." msgstr "" -#: library/faulthandler.rst:51 +#: library/faulthandler.rst:52 msgid "Module :mod:`traceback`" msgstr "" -#: library/faulthandler.rst:52 +#: library/faulthandler.rst:53 msgid "" "Standard interface to extract, format and print stack traces of Python " "programs." msgstr "" -#: library/faulthandler.rst:55 +#: library/faulthandler.rst:56 msgid "Dumping the traceback" msgstr "" -#: library/faulthandler.rst:59 +#: library/faulthandler.rst:60 msgid "" "Dump the tracebacks of all threads into *file*. If *all_threads* is " "``False``, dump only the current thread." msgstr "" -#: library/faulthandler.rst:62 +#: library/faulthandler.rst:63 msgid "" ":func:`traceback.print_tb`, which can be used to print a traceback object." msgstr "" -#: library/faulthandler.rst:82 library/faulthandler.rst:146 +#: library/faulthandler.rst:84 library/faulthandler.rst:148 msgid "Added support for passing file descriptor to this function." msgstr "" -#: library/faulthandler.rst:69 +#: library/faulthandler.rst:70 msgid "Fault handler state" msgstr "" -#: library/faulthandler.rst:73 +#: library/faulthandler.rst:74 msgid "" -"Enable the fault handler: install handlers for the :const:`SIGSEGV`, :const:" -"`SIGFPE`, :const:`SIGABRT`, :const:`SIGBUS` and :const:`SIGILL` signals to " -"dump the Python traceback. If *all_threads* is ``True``, produce tracebacks " -"for every running thread. Otherwise, dump only the current thread." +"Enable the fault handler: install handlers for " +"the :const:`~signal.SIGSEGV`, :const:`~signal.SIGFPE`, :const:`~signal.SIGABRT`, :const:`~signal.SIGBUS` " +"and :const:`~signal.SIGILL` signals to dump the Python traceback. If " +"*all_threads* is ``True``, produce tracebacks for every running thread. " +"Otherwise, dump only the current thread." msgstr "" -#: library/faulthandler.rst:79 +#: library/faulthandler.rst:81 msgid "" -"The *file* must be kept open until the fault handler is disabled: see :ref:" -"`issue with file descriptors `." +"The *file* must be kept open until the fault handler is disabled: " +"see :ref:`issue with file descriptors `." msgstr "" -#: library/faulthandler.rst:85 +#: library/faulthandler.rst:87 msgid "On Windows, a handler for Windows exception is also installed." msgstr "" -#: library/faulthandler.rst:88 +#: library/faulthandler.rst:90 msgid "" "The dump now mentions if a garbage collector collection is running if " "*all_threads* is true." msgstr "" -#: library/faulthandler.rst:94 +#: library/faulthandler.rst:96 msgid "" -"Disable the fault handler: uninstall the signal handlers installed by :func:" -"`enable`." +"Disable the fault handler: uninstall the signal handlers installed " +"by :func:`enable`." msgstr "" -#: library/faulthandler.rst:99 +#: library/faulthandler.rst:101 msgid "Check if the fault handler is enabled." msgstr "" -#: library/faulthandler.rst:103 +#: library/faulthandler.rst:105 msgid "Dumping the tracebacks after a timeout" msgstr "" -#: library/faulthandler.rst:107 +#: library/faulthandler.rst:109 msgid "" "Dump the tracebacks of all threads, after a timeout of *timeout* seconds, or " "every *timeout* seconds if *repeat* is ``True``. If *exit* is ``True``, " -"call :c:func:`_exit` with status=1 after dumping the tracebacks. (Note :c:" -"func:`_exit` exits the process immediately, which means it doesn't do any " -"cleanup like flushing file buffers.) If the function is called twice, the " -"new call replaces previous parameters and resets the timeout. The timer has " -"a sub-second resolution." +"call :c:func:`!_exit` with status=1 after dumping the tracebacks. " +"(Note :c:func:`!_exit` exits the process immediately, which means it doesn't " +"do any cleanup like flushing file buffers.) If the function is called twice, " +"the new call replaces previous parameters and resets the timeout. The timer " +"has a sub-second resolution." msgstr "" -#: library/faulthandler.rst:115 +#: library/faulthandler.rst:117 msgid "" -"The *file* must be kept open until the traceback is dumped or :func:" -"`cancel_dump_traceback_later` is called: see :ref:`issue with file " +"The *file* must be kept open until the traceback is dumped " +"or :func:`cancel_dump_traceback_later` is called: see :ref:`issue with file " "descriptors `." msgstr "" -#: library/faulthandler.rst:119 +#: library/faulthandler.rst:121 msgid "This function is implemented using a watchdog thread." msgstr "" -#: library/faulthandler.rst:124 +#: library/faulthandler.rst:126 msgid "This function is now always available." msgstr "" -#: library/faulthandler.rst:129 +#: library/faulthandler.rst:131 msgid "Cancel the last call to :func:`dump_traceback_later`." msgstr "" -#: library/faulthandler.rst:133 +#: library/faulthandler.rst:135 msgid "Dumping the traceback on a user signal" msgstr "" -#: library/faulthandler.rst:137 +#: library/faulthandler.rst:139 msgid "" "Register a user signal: install a handler for the *signum* signal to dump " "the traceback of all threads, or of the current thread if *all_threads* is " "``False``, into *file*. Call the previous handler if chain is ``True``." msgstr "" -#: library/faulthandler.rst:141 +#: library/faulthandler.rst:143 msgid "" -"The *file* must be kept open until the signal is unregistered by :func:" -"`unregister`: see :ref:`issue with file descriptors `." +"The *file* must be kept open until the signal is unregistered " +"by :func:`unregister`: see :ref:`issue with file descriptors `." msgstr "" -#: library/faulthandler.rst:155 +#: library/faulthandler.rst:157 msgid "Not available on Windows." msgstr "" -#: library/faulthandler.rst:151 +#: library/faulthandler.rst:153 msgid "" "Unregister a user signal: uninstall the handler of the *signum* signal " "installed by :func:`register`. Return ``True`` if the signal was registered, " "``False`` otherwise." msgstr "" -#: library/faulthandler.rst:161 +#: library/faulthandler.rst:163 msgid "Issue with file descriptors" msgstr "" -#: library/faulthandler.rst:163 +#: library/faulthandler.rst:165 msgid "" ":func:`enable`, :func:`dump_traceback_later` and :func:`register` keep the " "file descriptor of their *file* argument. If the file is closed and its file " @@ -240,12 +243,29 @@ msgid "" "Call these functions again each time that the file is replaced." msgstr "" -#: library/faulthandler.rst:171 +#: library/faulthandler.rst:173 msgid "Example" msgstr "" -#: library/faulthandler.rst:173 +#: library/faulthandler.rst:175 msgid "" "Example of a segmentation fault on Linux with and without enabling the fault " "handler:" msgstr "" + +#: library/faulthandler.rst:178 +msgid "" +"$ python -c \"import ctypes; ctypes.string_at(0)\"\n" +"Segmentation fault\n" +"\n" +"$ python -q -X faulthandler\n" +">>> import ctypes\n" +">>> ctypes.string_at(0)\n" +"Fatal Python error: Segmentation fault\n" +"\n" +"Current thread 0x00007fb899f39700 (most recent call first):\n" +" File \"/home/python/cpython/Lib/ctypes/__init__.py\", line 486 in " +"string_at\n" +" File \"\", line 1 in \n" +"Segmentation fault" +msgstr "" diff --git a/library/fcntl.po b/library/fcntl.po index 49f5aaa4..3cdd313c 100644 --- a/library/fcntl.po +++ b/library/fcntl.po @@ -8,37 +8,38 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/fcntl.rst:2 -msgid ":mod:`fcntl` --- The ``fcntl`` and ``ioctl`` system calls" +msgid ":mod:`!fcntl` --- The ``fcntl`` and ``ioctl`` system calls" msgstr "" #: library/fcntl.rst:16 msgid "" "This module performs file and I/O control on file descriptors. It is an " -"interface to the :c:func:`fcntl` and :c:func:`ioctl` Unix routines. See the :" -"manpage:`fcntl(2)` and :manpage:`ioctl(2)` Unix manual pages for full " +"interface to the :c:func:`fcntl` and :c:func:`ioctl` Unix routines. See " +"the :manpage:`fcntl(2)` and :manpage:`ioctl(2)` Unix manual pages for full " "details." msgstr "" #: library/fcntl.rst:21 -msgid ":ref:`Availability `: Unix, not Emscripten, not WASI." +msgid "Availability" msgstr "" #: library/fcntl.rst:23 msgid "" "All functions in this module take a file descriptor *fd* as their first " -"argument. This can be an integer file descriptor, such as returned by ``sys." -"stdin.fileno()``, or an :class:`io.IOBase` object, such as ``sys.stdin`` " -"itself, which provides a :meth:`~io.IOBase.fileno` that returns a genuine " -"file descriptor." +"argument. This can be an integer file descriptor, such as returned by " +"``sys.stdin.fileno()``, or an :class:`io.IOBase` object, such as " +"``sys.stdin`` itself, which provides a :meth:`~io.IOBase.fileno` that " +"returns a genuine file descriptor." msgstr "" #: library/fcntl.rst:29 @@ -94,17 +95,18 @@ msgid "" "a :meth:`~io.IOBase.fileno` method are accepted as well). The values used " "for *cmd* are operating system dependent, and are available as constants in " "the :mod:`fcntl` module, using the same names as used in the relevant C " -"header files. The argument *arg* can either be an integer value, or a :class:" -"`bytes` object. With an integer value, the return value of this function is " -"the integer return value of the C :c:func:`fcntl` call. When the argument " -"is bytes it represents a binary structure, e.g. created by :func:`struct." -"pack`. The binary data is copied to a buffer whose address is passed to the " -"C :c:func:`fcntl` call. The return value after a successful call is the " -"contents of the buffer, converted to a :class:`bytes` object. The length of " -"the returned object will be the same as the length of the *arg* argument. " -"This is limited to 1024 bytes. If the information returned in the buffer by " -"the operating system is larger than 1024 bytes, this is most likely to " -"result in a segmentation violation or a more subtle data corruption." +"header files. The argument *arg* can either be an integer value, or " +"a :class:`bytes` object. With an integer value, the return value of this " +"function is the integer return value of the C :c:func:`fcntl` call. When " +"the argument is bytes it represents a binary structure, e.g. created " +"by :func:`struct.pack`. The binary data is copied to a buffer whose address " +"is passed to the C :c:func:`fcntl` call. The return value after a " +"successful call is the contents of the buffer, converted to a :class:`bytes` " +"object. The length of the returned object will be the same as the length of " +"the *arg* argument. This is limited to 1024 bytes. If the information " +"returned in the buffer by the operating system is larger than 1024 bytes, " +"this is most likely to result in a segmentation violation or a more subtle " +"data corruption." msgstr "" #: library/fcntl.rst:83 @@ -178,6 +180,20 @@ msgstr "" msgid "An example::" msgstr "" +#: library/fcntl.rst:125 +msgid "" +">>> import array, fcntl, struct, termios, os\n" +">>> os.getpgrp()\n" +"13341\n" +">>> struct.unpack('h', fcntl.ioctl(0, termios.TIOCGPGRP, \" \"))[0]\n" +"13341\n" +">>> buf = array.array('h', [0])\n" +">>> fcntl.ioctl(0, termios.TIOCGPGRP, buf, 1)\n" +"0\n" +">>> buf\n" +"array('h', [13341])" +msgstr "" + #: library/fcntl.rst:136 msgid "" "Raises an :ref:`auditing event ` ``fcntl.ioctl`` with arguments " @@ -206,9 +222,9 @@ msgstr "" #: library/fcntl.rst:153 msgid "" "This is essentially a wrapper around the :func:`~fcntl.fcntl` locking calls. " -"*fd* is the file descriptor (file objects providing a :meth:`~io.IOBase." -"fileno` method are accepted as well) of the file to lock or unlock, and " -"*cmd* is one of the following values:" +"*fd* is the file descriptor (file objects providing " +"a :meth:`~io.IOBase.fileno` method are accepted as well) of the file to lock " +"or unlock, and *cmd* is one of the following values:" msgstr "" #: library/fcntl.rst:160 @@ -231,19 +247,19 @@ msgstr "" #: library/fcntl.rst:175 msgid "" -"If :const:`!LOCK_NB` is used and the lock cannot be acquired, an :exc:" -"`OSError` will be raised and the exception will have an *errno* attribute " -"set to :const:`~errno.EACCES` or :const:`~errno.EAGAIN` (depending on the " -"operating system; for portability, check for both values). On at least some " -"systems, :const:`!LOCK_EX` can only be used if the file descriptor refers to " -"a file opened for writing." +"If :const:`!LOCK_NB` is used and the lock cannot be acquired, " +"an :exc:`OSError` will be raised and the exception will have an *errno* " +"attribute set to :const:`~errno.EACCES` or :const:`~errno.EAGAIN` (depending " +"on the operating system; for portability, check for both values). On at " +"least some systems, :const:`!LOCK_EX` can only be used if the file " +"descriptor refers to a file opened for writing." msgstr "" #: library/fcntl.rst:182 msgid "" "*len* is the number of bytes to lock, *start* is the byte offset at which " -"the lock starts, relative to *whence*, and *whence* is as with :func:`io." -"IOBase.seek`, specifically:" +"the lock starts, relative to *whence*, and *whence* is as " +"with :func:`io.IOBase.seek`, specifically:" msgstr "" #: library/fcntl.rst:186 @@ -275,6 +291,17 @@ msgstr "" msgid "Examples (all on a SVR4 compliant system)::" msgstr "" +#: library/fcntl.rst:198 +msgid "" +"import struct, fcntl, os\n" +"\n" +"f = open(...)\n" +"rv = fcntl.fcntl(f, fcntl.F_SETFL, os.O_NDELAY)\n" +"\n" +"lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)\n" +"rv = fcntl.fcntl(f, fcntl.F_SETLKW, lockdata)" +msgstr "" + #: library/fcntl.rst:206 msgid "" "Note that in the first example the return value variable *rv* will hold an " @@ -283,7 +310,7 @@ msgid "" "therefore using the :func:`flock` call may be better." msgstr "" -#: library/fcntl.rst:217 +#: library/fcntl.rst:214 msgid "Module :mod:`os`" msgstr "" diff --git a/library/filecmp.po b/library/filecmp.po index 05263e55..18b0a064 100644 --- a/library/filecmp.po +++ b/library/filecmp.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/filecmp.rst:2 -msgid ":mod:`filecmp` --- File and Directory Comparisons" +msgid ":mod:`!filecmp` --- File and Directory Comparisons" msgstr "" #: library/filecmp.rst:9 @@ -85,8 +86,8 @@ msgstr "" #: library/filecmp.rst:51 msgid "" -"The *shallow* parameter has the same meaning and default value as for :func:" -"`filecmp.cmp`." +"The *shallow* parameter has the same meaning and default value as " +"for :func:`filecmp.cmp`." msgstr "" #: library/filecmp.rst:54 @@ -110,9 +111,9 @@ msgstr "" #: library/filecmp.rst:75 msgid "" "Construct a new directory comparison object, to compare the directories *a* " -"and *b*. *ignore* is a list of names to ignore, and defaults to :const:" -"`filecmp.DEFAULT_IGNORES`. *hide* is a list of names to hide, and defaults " -"to ``[os.curdir, os.pardir]``." +"and *b*. *ignore* is a list of names to ignore, and defaults " +"to :const:`filecmp.DEFAULT_IGNORES`. *hide* is a list of names to hide, and " +"defaults to ``[os.curdir, os.pardir]``." msgstr "" #: library/filecmp.rst:80 @@ -234,3 +235,17 @@ msgid "" "Here is a simplified example of using the ``subdirs`` attribute to search " "recursively through two directories to show common different files::" msgstr "" + +#: library/filecmp.rst:197 +msgid "" +">>> from filecmp import dircmp\n" +">>> def print_diff_files(dcmp):\n" +"... for name in dcmp.diff_files:\n" +"... print(\"diff_file %s found in %s and %s\" % (name, dcmp.left,\n" +"... dcmp.right))\n" +"... for sub_dcmp in dcmp.subdirs.values():\n" +"... print_diff_files(sub_dcmp)\n" +"...\n" +">>> dcmp = dircmp('dir1', 'dir2') \n" +">>> print_diff_files(dcmp) " +msgstr "" diff --git a/library/fileformats.po b/library/fileformats.po index 8cf2f58d..f3d100ba 100644 --- a/library/fileformats.po +++ b/library/fileformats.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/fileinput.po b/library/fileinput.po index 2b8d01f3..1642c58f 100644 --- a/library/fileinput.po +++ b/library/fileinput.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/fileinput.rst:2 -msgid ":mod:`fileinput` --- Iterate over lines from multiple input streams" +msgid ":mod:`!fileinput` --- Iterate over lines from multiple input streams" msgstr "" #: library/fileinput.rst:10 @@ -35,6 +36,13 @@ msgstr "" msgid "The typical use is::" msgstr "" +#: library/fileinput.rst:20 +msgid "" +"import fileinput\n" +"for line in fileinput.input(encoding=\"utf-8\"):\n" +" process(line)" +msgstr "" + #: library/fileinput.rst:24 msgid "" "This iterates over the lines of all files listed in ``sys.argv[1:]``, " @@ -48,9 +56,9 @@ msgstr "" #: library/fileinput.rst:30 msgid "" "All files are opened in text mode by default, but you can override this by " -"specifying the *mode* parameter in the call to :func:`.input` or :class:" -"`FileInput`. If an I/O error occurs during opening or reading a file, :exc:" -"`OSError` is raised." +"specifying the *mode* parameter in the call to :func:`.input` " +"or :class:`FileInput`. If an I/O error occurs during opening or reading a " +"file, :exc:`OSError` is raised." msgstr "" #: library/fileinput.rst:35 @@ -80,7 +88,7 @@ msgstr "" #: library/fileinput.rst:49 msgid "" "You can control how files are opened by providing an opening hook via the " -"*openhook* parameter to :func:`fileinput.input` or :class:`FileInput()`. The " +"*openhook* parameter to :func:`fileinput.input` or :func:`FileInput`. The " "hook must be a function that takes two arguments, *filename* and *mode*, and " "returns an accordingly opened file-like object. If *encoding* and/or " "*errors* are specified, they will be passed to the hook as additional " @@ -102,9 +110,17 @@ msgstr "" #: library/fileinput.rst:66 msgid "" -"The :class:`FileInput` instance can be used as a context manager in the :" -"keyword:`with` statement. In this example, *input* is closed after the :" -"keyword:`!with` statement is exited, even if an exception occurs::" +"The :class:`FileInput` instance can be used as a context manager in " +"the :keyword:`with` statement. In this example, *input* is closed after " +"the :keyword:`!with` statement is exited, even if an exception occurs::" +msgstr "" + +#: library/fileinput.rst:70 +msgid "" +"with fileinput.input(files=('spam.txt', 'eggs.txt'), encoding=\"utf-8\") as " +"f:\n" +" for line in f:\n" +" process(line)" msgstr "" #: library/fileinput.rst:170 @@ -121,8 +137,9 @@ msgstr "" #: library/fileinput.rst:84 msgid "" -"The following functions use the global state created by :func:`fileinput." -"input`; if there is no active state, :exc:`RuntimeError` is raised." +"The following functions use the global state created " +"by :func:`fileinput.input`; if there is no active state, :exc:`RuntimeError` " +"is raised." msgstr "" #: library/fileinput.rst:90 @@ -186,14 +203,13 @@ msgstr "" #: library/fileinput.rst:146 msgid "" -"Class :class:`FileInput` is the implementation; its methods :meth:" -"`filename`, :meth:`fileno`, :meth:`lineno`, :meth:`filelineno`, :meth:" -"`isfirstline`, :meth:`isstdin`, :meth:`nextfile` and :meth:`close` " -"correspond to the functions of the same name in the module. In addition it " -"is :term:`iterable` and has a :meth:`~io.TextIOBase.readline` method which " -"returns the next input line. The sequence must be accessed in strictly " -"sequential order; random access and :meth:`~io.TextIOBase.readline` cannot " -"be mixed." +"Class :class:`FileInput` is the implementation; its " +"methods :meth:`filename`, :meth:`fileno`, :meth:`lineno`, :meth:`filelineno`, :meth:`isfirstline`, :meth:`isstdin`, :meth:`nextfile` " +"and :meth:`close` correspond to the functions of the same name in the " +"module. In addition it is :term:`iterable` and has " +"a :meth:`~io.TextIOBase.readline` method which returns the next input line. " +"The sequence must be accessed in strictly sequential order; random access " +"and :meth:`~io.TextIOBase.readline` cannot be mixed." msgstr "" #: library/fileinput.rst:154 @@ -217,9 +233,15 @@ msgstr "" #: library/fileinput.rst:163 msgid "" -"A :class:`FileInput` instance can be used as a context manager in the :" -"keyword:`with` statement. In this example, *input* is closed after the :" -"keyword:`!with` statement is exited, even if an exception occurs::" +"A :class:`FileInput` instance can be used as a context manager in " +"the :keyword:`with` statement. In this example, *input* is closed after " +"the :keyword:`!with` statement is exited, even if an exception occurs::" +msgstr "" + +#: library/fileinput.rst:167 +msgid "" +"with FileInput(files=('spam.txt', 'eggs.txt')) as input:\n" +" process(input)" msgstr "" #: library/fileinput.rst:173 @@ -266,8 +288,8 @@ msgstr "" #: library/fileinput.rst:208 msgid "" -"Usage example: ``fi = fileinput.FileInput(openhook=fileinput." -"hook_compressed, encoding=\"utf-8\")``" +"Usage example: ``fi = " +"fileinput.FileInput(openhook=fileinput.hook_compressed, encoding=\"utf-8\")``" msgstr "" #: library/fileinput.rst:216 @@ -278,8 +300,9 @@ msgstr "" #: library/fileinput.rst:219 msgid "" -"Usage example: ``fi = fileinput.FileInput(openhook=fileinput." -"hook_encoded(\"utf-8\", \"surrogateescape\"))``" +"Usage example: ``fi = " +"fileinput.FileInput(openhook=fileinput.hook_encoded(\"utf-8\", " +"\"surrogateescape\"))``" msgstr "" #: library/fileinput.rst:223 @@ -288,6 +311,6 @@ msgstr "" #: library/fileinput.rst:226 msgid "" -"This function is deprecated since :func:`fileinput.input` and :class:" -"`FileInput` now have *encoding* and *errors* parameters." +"This function is deprecated since :func:`fileinput.input` " +"and :class:`FileInput` now have *encoding* and *errors* parameters." msgstr "" diff --git a/library/filesys.po b/library/filesys.po index 9cfcc3a3..2e02a746 100644 --- a/library/filesys.po +++ b/library/filesys.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -28,7 +29,7 @@ msgid "" "full list of modules in this chapter is:" msgstr "" -#: library/filesys.rst:31 +#: library/filesys.rst:29 msgid "Module :mod:`os`" msgstr "" @@ -38,7 +39,7 @@ msgid "" "lower level than Python :term:`file objects `." msgstr "" -#: library/filesys.rst:35 +#: library/filesys.rst:33 msgid "Module :mod:`io`" msgstr "" diff --git a/library/fnmatch.po b/library/fnmatch.po index 5c8984e6..c79917a2 100644 --- a/library/fnmatch.po +++ b/library/fnmatch.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/fnmatch.rst:2 -msgid ":mod:`fnmatch` --- Unix filename pattern matching" +msgid ":mod:`!fnmatch` --- Unix filename pattern matching" msgstr "" #: library/fnmatch.rst:7 @@ -80,63 +81,81 @@ msgstr "" #: library/fnmatch.rst:43 msgid "" "Note that the filename separator (``'/'`` on Unix) is *not* special to this " -"module. See module :mod:`glob` for pathname expansion (:mod:`glob` uses :" -"func:`.filter` to match pathname segments). Similarly, filenames starting " -"with a period are not special for this module, and are matched by the ``*`` " -"and ``?`` patterns." +"module. See module :mod:`glob` for pathname expansion (:mod:`glob` " +"uses :func:`.filter` to match pathname segments). Similarly, filenames " +"starting with a period are not special for this module, and are matched by " +"the ``*`` and ``?`` patterns." msgstr "" #: library/fnmatch.rst:49 msgid "" -"Also note that :func:`functools.lru_cache` with the *maxsize* of 32768 is " -"used to cache the compiled regex patterns in the following functions: :func:" -"`fnmatch`, :func:`fnmatchcase`, :func:`.filter`." +"Unless stated otherwise, \"filename string\" and \"pattern string\" either " +"refer to :class:`str` or ``ISO-8859-1`` encoded :class:`bytes` objects. Note " +"that the functions documented below do not allow to mix a :class:`!bytes` " +"pattern with a :class:`!str` filename, and vice-versa." msgstr "" -#: library/fnmatch.rst:55 +#: library/fnmatch.rst:54 +msgid "" +"Finally, note that :func:`functools.lru_cache` with a *maxsize* of 32768 is " +"used to cache the (typed) compiled regex patterns in the following " +"functions: :func:`fnmatch`, :func:`fnmatchcase`, :func:`.filter`." +msgstr "" + +#: library/fnmatch.rst:61 msgid "" "Test whether the filename string *name* matches the pattern string *pat*, " -"returning ``True`` or ``False``. Both parameters are case-normalized using :" -"func:`os.path.normcase`. :func:`fnmatchcase` can be used to perform a case-" -"sensitive comparison, regardless of whether that's standard for the " +"returning ``True`` or ``False``. Both parameters are case-normalized " +"using :func:`os.path.normcase`. :func:`fnmatchcase` can be used to perform a " +"case-sensitive comparison, regardless of whether that's standard for the " "operating system." msgstr "" -#: library/fnmatch.rst:61 +#: library/fnmatch.rst:67 msgid "" "This example will print all file names in the current directory with the " "extension ``.txt``::" msgstr "" -#: library/fnmatch.rst:74 +#: library/fnmatch.rst:70 +msgid "" +"import fnmatch\n" +"import os\n" +"\n" +"for file in os.listdir('.'):\n" +" if fnmatch.fnmatch(file, '*.txt'):\n" +" print(file)" +msgstr "" + +#: library/fnmatch.rst:80 msgid "" "Test whether the filename string *name* matches the pattern string *pat*, " "returning ``True`` or ``False``; the comparison is case-sensitive and does " "not apply :func:`os.path.normcase`." msgstr "" -#: library/fnmatch.rst:81 +#: library/fnmatch.rst:87 msgid "" -"Construct a list from those elements of the :term:`iterable` *names* that " -"match pattern *pat*. It is the same as ``[n for n in names if fnmatch(n, " -"pat)]``, but implemented more efficiently." +"Construct a list from those elements of the :term:`iterable` of filename " +"strings *names* that match the pattern string *pat*. It is the same as ``[n " +"for n in names if fnmatch(n, pat)]``, but implemented more efficiently." msgstr "" -#: library/fnmatch.rst:89 +#: library/fnmatch.rst:95 msgid "" "Return the shell-style pattern *pat* converted to a regular expression for " -"using with :func:`re.match`." +"using with :func:`re.match`. The pattern is expected to be a :class:`str`." msgstr "" -#: library/fnmatch.rst:92 +#: library/fnmatch.rst:98 msgid "Example:" msgstr "" -#: library/fnmatch.rst:106 +#: library/fnmatch.rst:112 msgid "Module :mod:`glob`" msgstr "" -#: library/fnmatch.rst:107 +#: library/fnmatch.rst:113 msgid "Unix shell-style path expansion." msgstr "" diff --git a/library/fractions.po b/library/fractions.po index 7ec41c75..0c7bd11f 100644 --- a/library/fractions.po +++ b/library/fractions.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/fractions.rst:2 -msgid ":mod:`fractions` --- Rational numbers" +msgid ":mod:`!fractions` --- Rational numbers" msgstr "" #: library/fractions.rst:10 @@ -41,48 +42,80 @@ msgid "" "of :class:`numbers.Rational` and returns a new :class:`Fraction` instance " "with value ``numerator/denominator``. If *denominator* is ``0``, it raises " "a :exc:`ZeroDivisionError`. The second version requires that " -"*other_fraction* is an instance of :class:`numbers.Rational` and returns a :" -"class:`Fraction` instance with the same value. The next two versions accept " -"either a :class:`float` or a :class:`decimal.Decimal` instance, and return " -"a :class:`Fraction` instance with exactly the same value. Note that due to " -"the usual issues with binary floating-point (see :ref:`tut-fp-issues`), the " -"argument to ``Fraction(1.1)`` is not exactly equal to 11/10, and so " -"``Fraction(1.1)`` does *not* return ``Fraction(11, 10)`` as one might " +"*other_fraction* is an instance of :class:`numbers.Rational` and returns " +"a :class:`Fraction` instance with the same value. The next two versions " +"accept either a :class:`float` or a :class:`decimal.Decimal` instance, and " +"return a :class:`Fraction` instance with exactly the same value. Note that " +"due to the usual issues with binary floating point (see :ref:`tut-fp-" +"issues`), the argument to ``Fraction(1.1)`` is not exactly equal to 11/10, " +"and so ``Fraction(1.1)`` does *not* return ``Fraction(11, 10)`` as one might " "expect. (But see the documentation for the :meth:`limit_denominator` method " "below.) The last version of the constructor expects a string or unicode " "instance. The usual form for this instance is::" msgstr "" +#: library/fractions.rst:41 +msgid "[sign] numerator ['/' denominator]" +msgstr "" + #: library/fractions.rst:43 msgid "" "where the optional ``sign`` may be either '+' or '-' and ``numerator`` and " "``denominator`` (if present) are strings of decimal digits (underscores may " "be used to delimit digits as with integral literals in code). In addition, " -"any string that represents a finite value and is accepted by the :class:" -"`float` constructor is also accepted by the :class:`Fraction` constructor. " -"In either form the input string may also have leading and/or trailing " -"whitespace. Here are some examples::" +"any string that represents a finite value and is accepted by " +"the :class:`float` constructor is also accepted by the :class:`Fraction` " +"constructor. In either form the input string may also have leading and/or " +"trailing whitespace. Here are some examples::" +msgstr "" + +#: library/fractions.rst:52 +msgid "" +">>> from fractions import Fraction\n" +">>> Fraction(16, -10)\n" +"Fraction(-8, 5)\n" +">>> Fraction(123)\n" +"Fraction(123, 1)\n" +">>> Fraction()\n" +"Fraction(0, 1)\n" +">>> Fraction('3/7')\n" +"Fraction(3, 7)\n" +">>> Fraction(' -3/7 ')\n" +"Fraction(-3, 7)\n" +">>> Fraction('1.414213 \\t\\n')\n" +"Fraction(1414213, 1000000)\n" +">>> Fraction('-.125')\n" +"Fraction(-1, 8)\n" +">>> Fraction('7e-6')\n" +"Fraction(7, 1000000)\n" +">>> Fraction(2.25)\n" +"Fraction(9, 4)\n" +">>> Fraction(1.1)\n" +"Fraction(2476979795053773, 2251799813685248)\n" +">>> from decimal import Decimal\n" +">>> Fraction(Decimal('1.1'))\n" +"Fraction(11, 10)" msgstr "" #: library/fractions.rst:78 msgid "" -"The :class:`Fraction` class inherits from the abstract base class :class:" -"`numbers.Rational`, and implements all of the methods and operations from " -"that class. :class:`Fraction` instances are :term:`hashable`, and should be " -"treated as immutable. In addition, :class:`Fraction` has the following " -"properties and methods:" +"The :class:`Fraction` class inherits from the abstract base " +"class :class:`numbers.Rational`, and implements all of the methods and " +"operations from that class. :class:`Fraction` instances " +"are :term:`hashable`, and should be treated as immutable. In " +"addition, :class:`Fraction` has the following properties and methods:" msgstr "" #: library/fractions.rst:84 msgid "" -"The :class:`Fraction` constructor now accepts :class:`float` and :class:" -"`decimal.Decimal` instances." +"The :class:`Fraction` constructor now accepts :class:`float` " +"and :class:`decimal.Decimal` instances." msgstr "" #: library/fractions.rst:88 msgid "" "The :func:`math.gcd` function is now used to normalize the *numerator* and " -"*denominator*. :func:`math.gcd` always return a :class:`int` type. " +"*denominator*. :func:`math.gcd` always returns an :class:`int` type. " "Previously, the GCD type depended on *numerator* and *denominator*." msgstr "" @@ -94,8 +127,8 @@ msgstr "" #: library/fractions.rst:97 msgid "" -":class:`Fraction` implements ``__int__`` now to satisfy ``typing." -"SupportsInt`` instance checks." +":class:`Fraction` implements ``__int__`` now to satisfy " +"``typing.SupportsInt`` instance checks." msgstr "" #: library/fractions.rst:101 @@ -130,9 +163,9 @@ msgstr "" #: library/fractions.rst:134 msgid "" -"Alternative constructor which only accepts instances of :class:`float` or :" -"class:`numbers.Integral`. Beware that ``Fraction.from_float(0.3)`` is not " -"the same value as ``Fraction(3, 10)``." +"Alternative constructor which only accepts instances of :class:`float` " +"or :class:`numbers.Integral`. Beware that ``Fraction.from_float(0.3)`` is " +"not the same value as ``Fraction(3, 10)``." msgstr "" #: library/fractions.rst:140 @@ -143,8 +176,8 @@ msgstr "" #: library/fractions.rst:146 msgid "" -"Alternative constructor which only accepts instances of :class:`decimal." -"Decimal` or :class:`numbers.Integral`." +"Alternative constructor which only accepts instances " +"of :class:`decimal.Decimal` or :class:`numbers.Integral`." msgstr "" #: library/fractions.rst:151 @@ -181,25 +214,39 @@ msgid "" "The first version returns the nearest :class:`int` to ``self``, rounding " "half to even. The second version rounds ``self`` to the nearest multiple of " "``Fraction(1, 10**ndigits)`` (logically, if ``ndigits`` is negative), again " -"rounding half toward even. This method can also be accessed through the :" -"func:`round` function." +"rounding half toward even. This method can also be accessed through " +"the :func:`round` function." msgstr "" #: library/fractions.rst:204 msgid "" "Provides support for float-style formatting of :class:`Fraction` instances " -"via the :meth:`str.format` method, the :func:`format` built-in function, or :" -"ref:`Formatted string literals `. The presentation types " +"via the :meth:`str.format` method, the :func:`format` built-in function, " +"or :ref:`Formatted string literals `. The presentation types " "``\"e\"``, ``\"E\"``, ``\"f\"``, ``\"F\"``, ``\"g\"``, ``\"G\"`` and ``\"%" -"\"`` are supported. For these presentation types, formatting for a :class:" -"`Fraction` object ``x`` follows the rules outlined for the :class:`float` " -"type in the :ref:`formatspec` section." +"\"`` are supported. For these presentation types, formatting for " +"a :class:`Fraction` object ``x`` follows the rules outlined for " +"the :class:`float` type in the :ref:`formatspec` section." msgstr "" #: library/fractions.rst:212 msgid "Here are some examples::" msgstr "" +#: library/fractions.rst:214 +msgid "" +">>> from fractions import Fraction\n" +">>> format(Fraction(1, 7), '.40g')\n" +"'0.1428571428571428571428571428571428571429'\n" +">>> format(Fraction('1234567.855'), '_.2f')\n" +"'1_234_567.86'\n" +">>> f\"{Fraction(355, 113):*>20.6e}\"\n" +"'********3.141593e+00'\n" +">>> old_price, new_price = 499, 672\n" +">>> \"{:.2%} price increase\".format(Fraction(new_price, old_price) - 1)\n" +"'34.67% price increase'" +msgstr "" + #: library/fractions.rst:228 msgid "Module :mod:`numbers`" msgstr "" diff --git a/library/frameworks.po b/library/frameworks.po index fe12d76d..8ee55958 100644 --- a/library/frameworks.po +++ b/library/frameworks.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/ftplib.po b/library/ftplib.po index 9ceaefca..8c1f4a24 100644 --- a/library/ftplib.po +++ b/library/ftplib.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/ftplib.rst:2 -msgid ":mod:`ftplib` --- FTP protocol client" +msgid ":mod:`!ftplib` --- FTP protocol client" msgstr "" #: library/ftplib.rst:7 @@ -26,12 +27,12 @@ msgstr "" #: library/ftplib.rst:15 msgid "" -"This module defines the class :class:`FTP` and a few related items. The :" -"class:`FTP` class implements the client side of the FTP protocol. You can " -"use this to write Python programs that perform a variety of automated FTP " -"jobs, such as mirroring other FTP servers. It is also used by the module :" -"mod:`urllib.request` to handle URLs that use FTP. For more information on " -"FTP (File Transfer Protocol), see internet :rfc:`959`." +"This module defines the class :class:`FTP` and a few related items. " +"The :class:`FTP` class implements the client side of the FTP protocol. You " +"can use this to write Python programs that perform a variety of automated " +"FTP jobs, such as mirroring other FTP servers. It is also used by the " +"module :mod:`urllib.request` to handle URLs that use FTP. For more " +"information on FTP (File Transfer Protocol), see internet :rfc:`959`." msgstr "" #: library/ftplib.rst:22 @@ -39,7 +40,7 @@ msgid "The default encoding is UTF-8, following :rfc:`2640`." msgstr "" #: includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." +msgid "Availability" msgstr "" #: includes/wasm-notavail.rst:5 @@ -53,6 +54,28 @@ msgstr "" msgid "Here's a sample session using the :mod:`ftplib` module::" msgstr "" +#: library/ftplib.rst:28 +msgid "" +">>> from ftplib import FTP\n" +">>> ftp = FTP('ftp.us.debian.org') # connect to host, default port\n" +">>> ftp.login() # user anonymous, passwd anonymous@\n" +"'230 Login successful.'\n" +">>> ftp.cwd('debian') # change into \"debian\" directory\n" +"'250 Directory successfully changed.'\n" +">>> ftp.retrlines('LIST') # list directory contents\n" +"-rw-rw-r-- 1 1176 1176 1063 Jun 15 10:18 README\n" +"...\n" +"drwxr-sr-x 5 1176 1176 4096 Dec 19 2000 pool\n" +"drwxr-sr-x 4 1176 1176 4096 Nov 17 2008 project\n" +"drwxr-xr-x 3 1176 1176 4096 Oct 10 2012 tools\n" +"'226 Directory send OK.'\n" +">>> with open('README', 'wb') as fp:\n" +">>> ftp.retrbinary('RETR README', fp.write)\n" +"'226 Transfer complete.'\n" +">>> ftp.quit()\n" +"'221 Goodbye.'" +msgstr "" + #: library/ftplib.rst:51 msgid "Reference" msgstr "" @@ -117,8 +140,8 @@ msgstr "" #: library/ftplib.rst:505 msgid "" -"If the *timeout* parameter is set to be zero, it will raise a :class:" -"`ValueError` to prevent the creation of a non-blocking socket. The " +"If the *timeout* parameter is set to be zero, it will raise " +"a :class:`ValueError` to prevent the creation of a non-blocking socket. The " "*encoding* parameter was added, and the default was changed from Latin-1 to " "UTF-8 to follow :rfc:`2640`." msgstr "" @@ -182,7 +205,7 @@ msgid "" "timeout setting)." msgstr "" -#: library/ftplib.rst:198 +#: library/ftplib.rst:187 msgid "" "Raises an :ref:`auditing event ` ``ftplib.connect`` with arguments " "``self``, ``host``, ``port``." @@ -219,7 +242,7 @@ msgid "" "Send a simple command string to the server and return the response string." msgstr "" -#: library/ftplib.rst:249 +#: library/ftplib.rst:238 msgid "" "Raises an :ref:`auditing event ` ``ftplib.sendcmd`` with arguments " "``self``, ``cmd``." @@ -236,8 +259,8 @@ msgstr "" msgid "Retrieve a file in binary transfer mode." msgstr "" -#: library/ftplib.rst:289 -msgid "An appropriate ``STOR`` command: :samp:`\"STOR {filename}\"`." +#: library/ftplib.rst:245 +msgid "An appropriate ``RETR`` command: :samp:`\"RETR {filename}\"`." msgstr "" #: library/ftplib.rst:248 @@ -281,11 +304,15 @@ msgstr "" msgid "Store a file in binary transfer mode." msgstr "" +#: library/ftplib.rst:289 +msgid "An appropriate ``STOR`` command: :samp:`\"STOR {filename}\"`." +msgstr "" + #: library/ftplib.rst:292 msgid "" -"A file object (opened in binary mode) which is read until EOF, using its :" -"meth:`~io.RawIOBase.read` method in blocks of size *blocksize* to provide " -"the data to be stored." +"A file object (opened in binary mode) which is read until EOF, using " +"its :meth:`~io.RawIOBase.read` method in blocks of size *blocksize* to " +"provide the data to be stored." msgstr "" #: library/ftplib.rst:298 @@ -343,14 +370,14 @@ msgstr "" #: library/ftplib.rst:354 msgid "" -"List a directory in a standardized format by using ``MLSD`` command (:rfc:" -"`3659`). If *path* is omitted the current directory is assumed. *facts* is " -"a list of strings representing the type of information desired (e.g. " -"``[\"type\", \"size\", \"perm\"]``). Return a generator object yielding a " -"tuple of two elements for every file found in path. First element is the " -"file name, the second one is a dictionary containing facts about the file " -"name. Content of this dictionary might be limited by the *facts* argument " -"but server is not guaranteed to return all requested facts." +"List a directory in a standardized format by using ``MLSD`` command " +"(:rfc:`3659`). If *path* is omitted the current directory is assumed. " +"*facts* is a list of strings representing the type of information desired " +"(e.g. ``[\"type\", \"size\", \"perm\"]``). Return a generator object " +"yielding a tuple of two elements for every file found in path. First " +"element is the file name, the second one is a dictionary containing facts " +"about the file name. Content of this dictionary might be limited by the " +"*facts* argument but server is not guaranteed to return all requested facts." msgstr "" #: library/ftplib.rst:368 @@ -434,15 +461,15 @@ msgstr "" #: library/ftplib.rst:452 msgid "" -"An :class:`FTP` subclass which adds TLS support to FTP as described in :rfc:" -"`4217`. Connect to port 21 implicitly securing the FTP control connection " -"before authenticating." +"An :class:`FTP` subclass which adds TLS support to FTP as described " +"in :rfc:`4217`. Connect to port 21 implicitly securing the FTP control " +"connection before authenticating." msgstr "" #: library/ftplib.rst:458 msgid "" -"The user must explicitly secure the data connection by calling the :meth:" -"`prot_p` method." +"The user must explicitly secure the data connection by calling " +"the :meth:`prot_p` method." msgstr "" #: library/ftplib.rst:476 @@ -464,8 +491,9 @@ msgstr "" #: library/ftplib.rst:500 msgid "" -"The class now supports hostname check with :attr:`ssl.SSLContext." -"check_hostname` and *Server Name Indication* (see :const:`ssl.HAS_SNI`)." +"The class now supports hostname check " +"with :attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* " +"(see :const:`ssl.HAS_SNI`)." msgstr "" #: library/ftplib.rst:511 @@ -476,6 +504,23 @@ msgstr "" msgid "Here's a sample session using the :class:`FTP_TLS` class::" msgstr "" +#: library/ftplib.rst:516 +msgid "" +">>> ftps = FTP_TLS('ftp.pureftpd.org')\n" +">>> ftps.login()\n" +"'230 Anonymous user logged in'\n" +">>> ftps.prot_p()\n" +"'200 Data protection level set to \"private\"'\n" +">>> ftps.nlst()\n" +"['6jack', 'OpenBSD', 'antilink', 'blogbench', 'bsdcam', 'clockspeed', " +"'djbdns-jedi', 'docs', 'eaccelerator-jedi', 'favicon.ico', 'francotone', " +"'fugu', 'ignore', 'libpuzzle', 'metalog', 'minidentd', 'misc', 'mysql-udf-" +"global-user-variables', 'php-jenkins-hash', 'php-skein-hash', 'php-webdav', " +"'phpaudit', 'phpbench', 'pincaster', 'ping', 'posto', 'pub', 'public', " +"'public_keys', 'pure-ftpd', 'qscan', 'qtc', 'sharedance', 'skycache', " +"'sound', 'tmp', 'ucarp']" +msgstr "" + #: library/ftplib.rst:524 msgid "" ":class:`!FTP_TLS` class inherits from :class:`FTP`, defining these " @@ -494,8 +539,9 @@ msgstr "" #: library/ftplib.rst:536 msgid "" -"The method now supports hostname check with :attr:`ssl.SSLContext." -"check_hostname` and *Server Name Indication* (see :const:`ssl.HAS_SNI`)." +"The method now supports hostname check " +"with :attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* " +"(see :const:`ssl.HAS_SNI`)." msgstr "" #: library/ftplib.rst:543 @@ -548,7 +594,7 @@ msgid "" "four exceptions listed above as well as :exc:`OSError` and :exc:`EOFError`." msgstr "" -#: library/ftplib.rst:597 +#: library/ftplib.rst:595 msgid "Module :mod:`netrc`" msgstr "" diff --git a/library/functional.po b/library/functional.po index e9b607d1..f0ca6b9e 100644 --- a/library/functional.po +++ b/library/functional.po @@ -8,10 +8,11 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/library/functions.po b/library/functions.po index c82c5d4f..c6f133db 100644 --- a/library/functions.po +++ b/library/functions.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: 2024-09-07 18:18+0300\n" "Last-Translator: Panagiotis Skias \n" "Language-Team: PyGreece \n" @@ -396,9 +396,10 @@ msgid ":func:`__import__`" msgstr ":func:`__import__`" #: library/functions.rst:59 +#, fuzzy msgid "" "Return the absolute value of a number. The argument may be an integer, a " -"floating point number, or an object implementing :meth:`~object.__abs__`. If " +"floating-point number, or an object implementing :meth:`~object.__abs__`. If " "the argument is a complex number, its magnitude is returned." msgstr "" "Επιστρέφει την απόλυτη τιμή ενός αριθμού. Το όρισμα μπορεί να είναι ένας " @@ -428,6 +429,15 @@ msgstr "" "Επιστρέφει ``True`` εάν όλα τα στοιχεία του *iterable* είναι true (ή εάν το " "iterable είναι κενό). Ισοδυναμεί με::" +#: library/functions.rst:79 +msgid "" +"def all(iterable):\n" +" for element in iterable:\n" +" if not element:\n" +" return False\n" +" return True" +msgstr "" + #: library/functions.rst:89 msgid "" "When awaited, return the next item from the given :term:`asynchronous " @@ -441,8 +451,8 @@ msgstr "" msgid "" "This is the async variant of the :func:`next` builtin, and behaves similarly." msgstr "" -"Αυτό είναι μια ασύγχρονη παραλλαγή της ενσωματωμένης συνάρτησης :func:" -"`next`, και συμπεριφέρεται παρόμοια." +"Αυτό είναι μια ασύγχρονη παραλλαγή της ενσωματωμένης " +"συνάρτησης :func:`next`, και συμπεριφέρεται παρόμοια." #: library/functions.rst:95 msgid "" @@ -454,8 +464,8 @@ msgstr "" "Αυτό καλεί την μέθοδο :meth:`~object.__anext__` του *async_iterator*, " "επιστρέφοντας ένα :term:`awaitable`. Αναμένοντας αυτό, επιστρέφει την " "επόμενη τιμή του iterator. Αν δίνεται το *default* (προεπιλογή), αυτό " -"επιστρέφεται εάν ο iterator έχει εξαντληθεί, αλλιώς γίνεται raise ένα :exc:" -"`StopAsyncIteration`." +"επιστρέφεται εάν ο iterator έχει εξαντληθεί, αλλιώς γίνεται raise " +"ένα :exc:`StopAsyncIteration`." #: library/functions.rst:104 msgid "" @@ -465,12 +475,21 @@ msgstr "" "Επιστρέφει ``True`` εάν οποιοδήποτε στοιχείο του *iterable* είναι αληθές. " "Εάν το iterable είναι κενό, επιστρέφει ``False``. Ισοδυναμεί με::" +#: library/functions.rst:107 +msgid "" +"def any(iterable):\n" +" for element in iterable:\n" +" if element:\n" +" return True\n" +" return False" +msgstr "" + #: library/functions.rst:116 msgid "" "As :func:`repr`, return a string containing a printable representation of an " -"object, but escape the non-ASCII characters in the string returned by :func:" -"`repr` using ``\\x``, ``\\u``, or ``\\U`` escapes. This generates a string " -"similar to that returned by :func:`repr` in Python 2." +"object, but escape the non-ASCII characters in the string returned " +"by :func:`repr` using ``\\x``, ``\\u``, or ``\\U`` escapes. This generates " +"a string similar to that returned by :func:`repr` in Python 2." msgstr "" "Όπως η :func:`repr`, επιστρέφει μια συμβολοσειρά που περιέχει μια εκτυπώσιμη " "απεικόνιση ενός αντικειμένου, αλλά αναιρεί τους μη-ASCII χαρακτήρες στη " @@ -487,8 +506,9 @@ msgid "" msgstr "" "Μετατροπή ενός ακέραιου αριθμού σε μια δυαδική συμβολοσειρά με πρόθεμα " "\"0b\". Το αποτέλεσμα είναι μια έγκυρη έκφραση Python. Εάν το *x* δεν είναι " -"αντικείμενο της Python :class:`int`, πρέπει να οριστεί μια μέθοδος :meth:" -"`~object.__index__` που επιστρέφει έναν ακέραιο αριθμό. Κάποια παραδείγματα:" +"αντικείμενο της Python :class:`int`, πρέπει να οριστεί μια " +"μέθοδος :meth:`~object.__index__` που επιστρέφει έναν ακέραιο αριθμό. Κάποια " +"παραδείγματα:" #: library/functions.rst:134 msgid "" @@ -498,36 +518,39 @@ msgstr "" "Εάν το πρόθεμα \"0b\" είναι επιθυμητό ή όχι, μπορείτε να χρησιμοποιήσετε " "έναν από τους παρακάτω τρόπους." -#: library/functions.rst:845 library/functions.rst:1163 +#: library/functions.rst:921 library/functions.rst:1260 msgid "See also :func:`format` for more information." msgstr "Δείτε επίσης τη :func:`format` για περισσότερες πληροφορίες." #: library/functions.rst:146 +#, fuzzy msgid "" -"Return a Boolean value, i.e. one of ``True`` or ``False``. *x* is converted " -"using the standard :ref:`truth testing procedure `. If *x* is false " -"or omitted, this returns ``False``; otherwise, it returns ``True``. The :" -"class:`bool` class is a subclass of :class:`int` (see :ref:`typesnumeric`). " -"It cannot be subclassed further. Its only instances are ``False`` and " -"``True`` (see :ref:`typebool`)." +"Return a Boolean value, i.e. one of ``True`` or ``False``. The argument is " +"converted using the standard :ref:`truth testing procedure `. If the " +"argument is false or omitted, this returns ``False``; otherwise, it returns " +"``True``. The :class:`bool` class is a subclass of :class:`int` " +"(see :ref:`typesnumeric`). It cannot be subclassed further. Its only " +"instances are ``False`` and ``True`` (see :ref:`typebool`)." msgstr "" "Επιστρέφετε μια δυαδική τιμή, π.χ. μία από τις τιμές ``True`` ή ``False``. " "Το *x* μετατρέπεται χρησιμοποιώντας την τυπική :ref:`truth testing procedure " "`. Εάν το *x* είναι ψευδές ή παραλειφθεί, αυτό επιστρέφει ``False``∙ " "διαφορετικά, επιστρέφει ``True``. Η κλάση :class:`bool` είναι μια υποκλάση " "της :class:`int` (βλ. :ref:`typesnumeric`). Δεν μπορεί να γίνει περαιτέρω " -"υποκλάση. Οι μόνες περιπτώσεις είναι ``False`` και ``True`` (βλ. :ref:" -"`typebool`)." +"υποκλάση. Οι μόνες περιπτώσεις είναι ``False`` και ``True`` " +"(βλ. :ref:`typebool`)." -#: library/functions.rst:710 library/functions.rst:934 -msgid "*x* is now a positional-only parameter." +#: library/functions.rst:786 +#, fuzzy +msgid "The parameter is now positional-only." msgstr "Το *x* είναι πλέον μόνο παράμετρος θέσης." -#: library/functions.rst:160 +#: library/functions.rst:161 +#, fuzzy msgid "" "This function drops you into the debugger at the call site. Specifically, " "it calls :func:`sys.breakpointhook`, passing ``args`` and ``kws`` straight " -"through. By default, ``sys.breakpointhook()`` calls :func:`pdb.set_trace()` " +"through. By default, ``sys.breakpointhook()`` calls :func:`pdb.set_trace` " "expecting no arguments. In this case, it is purely a convenience function " "so you don't have to explicitly import :mod:`pdb` or type as much code to " "enter the debugger. However, :func:`sys.breakpointhook` can be set to some " @@ -537,27 +560,27 @@ msgid "" msgstr "" "Αυτή η συνάρτηση μας μεταφέρει στο πρόγραμμα εντοπισμού σφαλμάτων στην " "τοποθεσία της κλήσης. Συγκεκριμένα, καλεί το :func:`sys.breakpointhook`, " -"περνώντας απευθείας τα ``args`` και ``kws``. Από προεπιλογή, το ``sys." -"breakpointhook()`` καλεί την :func:`pdb.set_trace()` χωρίς να περιμένει " -"ορίσματα. Σε αυτήν την περίπτωση, είναι καθαρά μια βολική συνάρτηση, " -"επομένως δεν χρειάζεται να εισάγετε ρητά το :mod:`pdb` ή να πληκτρολογήσετε " -"τόσο πολύ κώδικα. Ωστόσο η :func:`sys.breakpointhook` μπορεί να ρυθμιστεί " -"σε κάποια άλλη συνάρτηση και το :func:`breakpoint` θα το καλέσει αυτόματα, " -"επιτρέποντας σας να πέσετε στο πρόγραμμα εντοπισμού σφαλμάτων της επιλογής " -"σας. Εάν η :func:`sys.breakpointhook` δεν είναι προσβάσιμη, αυτή η συνάρτηση " -"θα κάνει raise το :exc:`RuntimeError`." - -#: library/functions.rst:172 -msgid "" -"By default, the behavior of :func:`breakpoint` can be changed with the :" -"envvar:`PYTHONBREAKPOINT` environment variable. See :func:`sys." -"breakpointhook` for usage details." +"περνώντας απευθείας τα ``args`` και ``kws``. Από προεπιλογή, το " +"``sys.breakpointhook()`` καλεί την :func:`pdb.set_trace()` χωρίς να " +"περιμένει ορίσματα. Σε αυτήν την περίπτωση, είναι καθαρά μια βολική " +"συνάρτηση, επομένως δεν χρειάζεται να εισάγετε ρητά το :mod:`pdb` ή να " +"πληκτρολογήσετε τόσο πολύ κώδικα. Ωστόσο η :func:`sys.breakpointhook` " +"μπορεί να ρυθμιστεί σε κάποια άλλη συνάρτηση και το :func:`breakpoint` θα το " +"καλέσει αυτόματα, επιτρέποντας σας να πέσετε στο πρόγραμμα εντοπισμού " +"σφαλμάτων της επιλογής σας. Εάν η :func:`sys.breakpointhook` δεν είναι " +"προσβάσιμη, αυτή η συνάρτηση θα κάνει raise το :exc:`RuntimeError`." + +#: library/functions.rst:173 +msgid "" +"By default, the behavior of :func:`breakpoint` can be changed with " +"the :envvar:`PYTHONBREAKPOINT` environment variable. " +"See :func:`sys.breakpointhook` for usage details." msgstr "" "Από προεπιλογή, η συμπεριφορά της :func:`breakpoint` μπορεί να αλλάξει με " -"την μεταβλητή περιβάλλοντος :envvar:`PYTHONBREAKPOINT`. Βλ. την :func:`sys." -"breakpointhook` για λεπτομέρειες χρήσης." +"την μεταβλητή περιβάλλοντος :envvar:`PYTHONBREAKPOINT`. Βλ. " +"την :func:`sys.breakpointhook` για λεπτομέρειες χρήσης." -#: library/functions.rst:176 +#: library/functions.rst:177 msgid "" "Note that this is not guaranteed if :func:`sys.breakpointhook` has been " "replaced." @@ -565,7 +588,7 @@ msgstr "" "Λάβετε υπόψη ότι αυτό δεν είναι εγγυημένο εάν η :func:`sys.breakpointhook` " "έχει αντικατασταθεί." -#: library/functions.rst:179 +#: library/functions.rst:180 msgid "" "Raises an :ref:`auditing event ` ``builtins.breakpoint`` with " "argument ``breakpointhook``." @@ -573,7 +596,7 @@ msgstr "" "Εγείρει ένα :ref:`auditing event ` ``builtins.breakpoint`` με " "όρισμα ``breakpointhook``." -#: library/functions.rst:189 +#: library/functions.rst:190 msgid "" "Return a new array of bytes. The :class:`bytearray` class is a mutable " "sequence of integers in the range 0 <= x < 256. It has most of the usual " @@ -586,7 +609,7 @@ msgstr "" "περιγράφονται στο :ref:`typesseq-mutable`, καθώς και τις περισσότερες " "μεθόδους που έχει ο τύπος :class:`bytes`, δείτε :ref:`bytes-methods`." -#: library/functions.rst:194 +#: library/functions.rst:195 msgid "" "The optional *source* parameter can be used to initialize the array in a few " "different ways:" @@ -594,7 +617,7 @@ msgstr "" "Η προαιρετική παράμετρος *source* μπορεί να χρησιμοποιηθεί για την " "αρχικοποίηση του πίνακα με μερικούς διαφορετικούς τρόπους:" -#: library/functions.rst:197 +#: library/functions.rst:198 msgid "" "If it is a *string*, you must also give the *encoding* (and optionally, " "*errors*) parameters; :func:`bytearray` then converts the string to bytes " @@ -604,7 +627,7 @@ msgstr "" "προαιρετικά, *errors*)∙ η :func:`bytearray` στη συνέχεια μετατρέπει τη " "συμβολοσειρά σε byte χρησιμοποιώντας :meth:`str.encode`." -#: library/functions.rst:201 +#: library/functions.rst:202 msgid "" "If it is an *integer*, the array will have that size and will be initialized " "with null bytes." @@ -612,7 +635,7 @@ msgstr "" "Εάν είναι *integer*, ο πίνακας θα έχει αυτό το μέγεθος και θα αρχικοποιηθεί " "με null bytes." -#: library/functions.rst:204 +#: library/functions.rst:205 msgid "" "If it is an object conforming to the :ref:`buffer interface " "`, a read-only buffer of the object will be used to " @@ -622,7 +645,7 @@ msgstr "" "`, θα χρησιμοποιηθεί μια προσωρινή μνήμη μόνο για ανάγνωση " "του αντικείμενου για την προετοιμασία του πίνακα με τα bytes." -#: library/functions.rst:207 +#: library/functions.rst:208 msgid "" "If it is an *iterable*, it must be an iterable of integers in the range ``0 " "<= x < 256``, which are used as the initial contents of the array." @@ -630,19 +653,19 @@ msgstr "" "Εάν είναι *iterable*, πρέπει να είναι ένας iterable ακεραίων στο εύρος ``0 " "<= x < 256``, οι οποίοι χρησιμοποιούνται ως αρχικά περιεχόμενα του πίνακα." -#: library/functions.rst:210 +#: library/functions.rst:211 msgid "Without an argument, an array of size 0 is created." msgstr "Χωρίς όρισμα δημιουργείται ένας πίνακας μεγέθους 0." -#: library/functions.rst:212 +#: library/functions.rst:213 msgid "See also :ref:`binaryseq` and :ref:`typebytearray`." msgstr "Βλ. επίσης :ref:`binaryseq` και :ref:`typebytearray`." -#: library/functions.rst:221 +#: library/functions.rst:222 msgid "" "Return a new \"bytes\" object which is an immutable sequence of integers in " -"the range ``0 <= x < 256``. :class:`bytes` is an immutable version of :" -"class:`bytearray` -- it has the same non-mutating methods and the same " +"the range ``0 <= x < 256``. :class:`bytes` is an immutable version " +"of :class:`bytearray` -- it has the same non-mutating methods and the same " "indexing and slicing behavior." msgstr "" "Επιστρέφεται ένα νέο αντικείμενο \"bytes\", που είναι μια αμετάβλητη " @@ -650,30 +673,31 @@ msgstr "" "αμετάβλητη έκδοση του :class:`bytearray` -- έχει τις ίδιες μεθόδους χωρίς " "μετάλλαξη και την ίδια συμπεριφορά ευρετηριοποίησης και τεμαχισμού." -#: library/functions.rst:226 +#: library/functions.rst:227 msgid "" "Accordingly, constructor arguments are interpreted as for :func:`bytearray`." msgstr "" "Συνεπώς, τα ορίσματα του constructor ερμηνεύονται ως :func:`bytearray`." -#: library/functions.rst:228 +#: library/functions.rst:229 msgid "Bytes objects can also be created with literals, see :ref:`strings`." msgstr "" -"Τα αντικείμενα bytes μπορούν επίσης να δημιουργηθούν με literals, βλέπε :ref:" -"`strings`." +"Τα αντικείμενα bytes μπορούν επίσης να δημιουργηθούν με literals, " +"βλέπε :ref:`strings`." -#: library/functions.rst:230 +#: library/functions.rst:231 msgid "See also :ref:`binaryseq`, :ref:`typebytes`, and :ref:`bytes-methods`." msgstr "" "Βλέπε επίσης :ref:`binaryseq`, :ref:`typebytes`, και :ref:`bytes-methods`." -#: library/functions.rst:235 +#: library/functions.rst:236 msgid "" -"Return :const:`True` if the *object* argument appears callable, :const:" -"`False` if not. If this returns ``True``, it is still possible that a call " -"fails, but if it is ``False``, calling *object* will never succeed. Note " -"that classes are callable (calling a class returns a new instance); " -"instances are callable if their class has a :meth:`~object.__call__` method." +"Return :const:`True` if the *object* argument appears " +"callable, :const:`False` if not. If this returns ``True``, it is still " +"possible that a call fails, but if it is ``False``, calling *object* will " +"never succeed. Note that classes are callable (calling a class returns a new " +"instance); instances are callable if their class has " +"a :meth:`~object.__call__` method." msgstr "" "Επιστρέφει :const:`True` εάν το όρισμα *object* εμφανίζεται ως callable, " "και :const:`False` εάν όχι. Εάν αυτό επιστρέψει ``True``, είναι ακόμα " @@ -682,7 +706,7 @@ msgstr "" "μιας κλάσης επιστρέφει ένα νέο instance). Τα instances μπορούν να κληθούν αν " "η κλάση τους έχει τη μέθοδο :meth:`~object.__call__`." -#: library/functions.rst:241 +#: library/functions.rst:242 msgid "" "This function was first removed in Python 3.0 and then brought back in " "Python 3.2." @@ -690,7 +714,7 @@ msgstr "" "Αυτή η συνάρτηση πρώτα αφαιρέθηκε στην Python 3.0 και στη συνέχεια επανήλθε " "στην Python 3.2." -#: library/functions.rst:248 +#: library/functions.rst:249 msgid "" "Return the string representing a character whose Unicode code point is the " "integer *i*. For example, ``chr(97)`` returns the string ``'a'``, while " @@ -701,7 +725,7 @@ msgstr "" "επιστρέφει τη συμβολοσειρά ``'a'``, ενώ το ``chr(8364)`` επιστρέφει τη " "συμβολοσειρά ``'€'``. Αυτό είναι το αντίστροφο του :func:`ord`." -#: library/functions.rst:252 +#: library/functions.rst:253 msgid "" "The valid range for the argument is from 0 through 1,114,111 (0x10FFFF in " "base 16). :exc:`ValueError` will be raised if *i* is outside that range." @@ -710,11 +734,11 @@ msgstr "" "16). Το :exc:`ValueError` θα γίνει raise εάν το *i* είναι εκτός αυτού του " "εύρους." -#: library/functions.rst:258 +#: library/functions.rst:259 msgid "Transform a method into a class method." msgstr "Μετατροπή μιας μεθόδου σε μέθοδο κλάσης." -#: library/functions.rst:260 +#: library/functions.rst:261 msgid "" "A class method receives the class as an implicit first argument, just like " "an instance method receives the instance. To declare a class method, use " @@ -724,15 +748,22 @@ msgstr "" "instance μέθοδος λαμβάνει το instance. Για να δηλώσετε μια μέθοδο κλάσης, " "χρησιμοποιήστε αυτό το ιδίωμα::" -#: library/functions.rst:268 +#: library/functions.rst:265 msgid "" -"The ``@classmethod`` form is a function :term:`decorator` -- see :ref:" -"`function` for details." +"class C:\n" +" @classmethod\n" +" def f(cls, arg1, arg2): ..." msgstr "" -"Η φόρμα ``@classmethod`` είναι μια συνάρτηση :term:`decorator` -- βλέπε :ref:" -"`function` για λεπτομέρειες." -#: library/functions.rst:271 +#: library/functions.rst:269 +msgid "" +"The ``@classmethod`` form is a function :term:`decorator` -- " +"see :ref:`function` for details." +msgstr "" +"Η φόρμα ``@classmethod`` είναι μια συνάρτηση :term:`decorator` -- " +"βλέπε :ref:`function` για λεπτομέρειες." + +#: library/functions.rst:272 msgid "" "A class method can be called either on the class (such as ``C.f()``) or on " "an instance (such as ``C().f()``). The instance is ignored except for its " @@ -744,7 +775,7 @@ msgstr "" "της. Εάν μια μέθοδος κλάσης καλείται για μια παραγόμενη κλάση, το " "αντικείμενο παραγόμενης κλάσης μεταβιβάζεται ως το υπονοούμενο πρώτο όρισμα." -#: library/functions.rst:276 +#: library/functions.rst:277 msgid "" "Class methods are different than C++ or Java static methods. If you want " "those, see :func:`staticmethod` in this section. For more information on " @@ -754,25 +785,27 @@ msgstr "" "ανατρέξτε στο :func:`staticmethod` σε αυτήν την ενότητα. Για περισσότερες " "πληροφορίες σχετικά με τις μεθόδους κλάσης, ανατρέξτε στο :ref:`types`." -#: library/functions.rst:280 +#: library/functions.rst:281 msgid "" -"Class methods can now wrap other :term:`descriptors ` such as :" -"func:`property`." +"Class methods can now wrap other :term:`descriptors ` such " +"as :func:`property`." msgstr "" "Οι μέθοδοι κλάσης μπορούν πλέον να αναδιπλώσουν άλλους :term:`descriptors " "` όπως η :func:`property`." -#: library/functions.rst:284 +#: library/functions.rst:285 +#, fuzzy msgid "" -"Class methods now inherit the method attributes (``__module__``, " -"``__name__``, ``__qualname__``, ``__doc__`` and ``__annotations__``) and " -"have a new ``__wrapped__`` attribute." +"Class methods now inherit the method attributes " +"(:attr:`~function.__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function.__doc__` " +"and :attr:`~function.__annotations__`) and have a new ``__wrapped__`` " +"attribute." msgstr "" "Οι μέθοδοι κλάσης κληρονομούν πλέον τα χαρακτηριστικά της μεθόδους " "(``__module__``, ``__name__``, ``__qualname__``, ``__doc__`` και " "``__annotations__``) και έχουν ένα νέο χαρακτηριστικό ``__wrapped__``." -#: library/functions.rst:289 +#: library/functions.rst:292 msgid "" "Class methods can no longer wrap other :term:`descriptors ` such " "as :func:`property`." @@ -780,7 +813,7 @@ msgstr "" "Οι μέθοδοι κλάσης δεν μπορούν πλέον να κάνουν wrap άλλους :term:`descriptors " "` όπως :func:`property`." -#: library/functions.rst:296 +#: library/functions.rst:299 msgid "" "Compile the *source* into a code or AST object. Code objects can be " "executed by :func:`exec` or :func:`eval`. *source* can either be a normal " @@ -790,10 +823,11 @@ msgstr "" "Μεταγλωττίστε το *source* σε έναν κώδικα ή αντικείμενο AST. Τα αντικείμενα " "κώδικα μπορούν να εκτελεστούν από :func:`exec` ή :func:`eval`. Η *source* " "μπορεί να είναι είτε μια κανονική συμβολοσειρά, μια συμβολοσειρά byte ή μια " -"συμβολοσειρά AST αντικείμενου. Ανατρέξτε στην τεκμηρίωση του module :mod:" -"`ast` για πληροφορίες σχετικά με τον τρόπο εργασίας με αντικείμενα AST." +"συμβολοσειρά AST αντικείμενου. Ανατρέξτε στην τεκμηρίωση του " +"module :mod:`ast` για πληροφορίες σχετικά με τον τρόπο εργασίας με " +"αντικείμενα AST." -#: library/functions.rst:301 +#: library/functions.rst:304 msgid "" "The *filename* argument should give the file from which the code was read; " "pass some recognizable value if it wasn't read from a file (``''`` " @@ -803,7 +837,7 @@ msgstr "" "κώδικας∙ να περάσει κάποια αναγνωρίσιμη τιμή εάν δεν διαβαστεί από ένα " "αρχείο (χρησιμοποιείται συνήθως ``''``)." -#: library/functions.rst:305 +#: library/functions.rst:308 msgid "" "The *mode* argument specifies what kind of code must be compiled; it can be " "``'exec'`` if *source* consists of a sequence of statements, ``'eval'`` if " @@ -818,49 +852,52 @@ msgstr "" "θα εκτυπωθούν δηλώσεις έκφρασης που αξιολογούνται σε κάτι διαφορετικό από " "``None``)." -#: library/functions.rst:311 -msgid "" -"The optional arguments *flags* and *dont_inherit* control which :ref:" -"`compiler options ` should be activated and which :ref:" -"`future features ` should be allowed. If neither is present (or both " -"are zero) the code is compiled with the same flags that affect the code that " -"is calling :func:`compile`. If the *flags* argument is given and " -"*dont_inherit* is not (or is zero) then the compiler options and the future " -"statements specified by the *flags* argument are used in addition to those " -"that would be used anyway. If *dont_inherit* is a non-zero integer then the " -"*flags* argument is it -- the flags (future features and compiler options) " -"in the surrounding code are ignored." -msgstr "" -"Τα προαιρετικά ορίσματα *flags* και *dont_inherit* ελέγχουν ποιες :ref:" -"`compiler options ` θα πρέπει να ενεργοποιηθούν και " -"ποιες :ref:`future features ` θα πρέπει να επιτρέπονται. Εάν δεν " -"υπάρχει καμία (ή και οι δύο είναι μηδέν) ο κώδικας μεταγλωττίζεται με τα " -"ίδια flags που επηρεάζουν τον κώδικα που καλεί :func:`compile`. Εάν το " -"όρισμα *flags* δίνεται και το *dont_inherit* δεν είναι (ή είναι μηδέν), τότε " -"οι επιλογές του μεταγλωττιστή και οι μελλοντικές δηλώσεις που καθορίζονται " -"από το όρισμα *flags* χρησιμοποιούνται ανεξάρτητα από αυτές που θα " -"χρησιμοποιούνταν ούτως ή άλλως. Εάν το *dont_inherit* είναι ένα μη μηδενικός " -"ακέραιος, τότε το όρισμα *flags* είναι αυτό -- οι σημαίες (μελλοντικές " -"δυνατότητες και επιλογές μεταγλωττιστή) στον περιβάλλοντα κώδικα αγνοούνται." - -#: library/functions.rst:322 +#: library/functions.rst:314 +msgid "" +"The optional arguments *flags* and *dont_inherit* control " +"which :ref:`compiler options ` should be activated and " +"which :ref:`future features ` should be allowed. If neither is " +"present (or both are zero) the code is compiled with the same flags that " +"affect the code that is calling :func:`compile`. If the *flags* argument is " +"given and *dont_inherit* is not (or is zero) then the compiler options and " +"the future statements specified by the *flags* argument are used in addition " +"to those that would be used anyway. If *dont_inherit* is a non-zero integer " +"then the *flags* argument is it -- the flags (future features and compiler " +"options) in the surrounding code are ignored." +msgstr "" +"Τα προαιρετικά ορίσματα *flags* και *dont_inherit* ελέγχουν " +"ποιες :ref:`compiler options ` θα πρέπει να " +"ενεργοποιηθούν και ποιες :ref:`future features ` θα πρέπει να " +"επιτρέπονται. Εάν δεν υπάρχει καμία (ή και οι δύο είναι μηδέν) ο κώδικας " +"μεταγλωττίζεται με τα ίδια flags που επηρεάζουν τον κώδικα που " +"καλεί :func:`compile`. Εάν το όρισμα *flags* δίνεται και το *dont_inherit* " +"δεν είναι (ή είναι μηδέν), τότε οι επιλογές του μεταγλωττιστή και οι " +"μελλοντικές δηλώσεις που καθορίζονται από το όρισμα *flags* χρησιμοποιούνται " +"ανεξάρτητα από αυτές που θα χρησιμοποιούνταν ούτως ή άλλως. Εάν το " +"*dont_inherit* είναι ένα μη μηδενικός ακέραιος, τότε το όρισμα *flags* είναι " +"αυτό -- οι σημαίες (μελλοντικές δυνατότητες και επιλογές μεταγλωττιστή) στον " +"περιβάλλοντα κώδικα αγνοούνται." + +#: library/functions.rst:325 msgid "" "Compiler options and future statements are specified by bits which can be " "bitwise ORed together to specify multiple options. The bitfield required to " -"specify a given future feature can be found as the :attr:`~__future__." -"_Feature.compiler_flag` attribute on the :class:`~__future__._Feature` " -"instance in the :mod:`__future__` module. :ref:`Compiler flags ` can be found in :mod:`ast` module, with ``PyCF_`` prefix." +"specify a given future feature can be found as " +"the :attr:`~__future__._Feature.compiler_flag` attribute on " +"the :class:`~__future__._Feature` instance in the :mod:`__future__` " +"module. :ref:`Compiler flags ` can be found " +"in :mod:`ast` module, with ``PyCF_`` prefix." msgstr "" "Οι επιλογές του μεταγλωττιστή και οι μελλοντικές εντολές καθορίζονται από " "bits που μπορούν να συνδυαστούν κατά bit ORed μαζί για να καθορίσουν πολλές " "επιλογές. Το πεδίο bit που απαιτείται για το καθορισμό ενός δεδομένου " -"μελλοντικού χαρακτηριστικού μπορεί να βρεθεί ως το χαρακτηριστικό :attr:" -"`~__future__.Το _Feature.compiler_flag` στο :class:`~__future__._Feature` " -"instance του module :mod:`__future__`. :ref:`Compiler flags ` μπορούν να βρεθούν στο module :mod:`ast`, με το πρόθεμα ``PyCF_``." +"μελλοντικού χαρακτηριστικού μπορεί να βρεθεί ως το " +"χαρακτηριστικό :attr:`~__future__.Το _Feature.compiler_flag` " +"στο :class:`~__future__._Feature` instance του " +"module :mod:`__future__`. :ref:`Compiler flags ` μπορούν " +"να βρεθούν στο module :mod:`ast`, με το πρόθεμα ``PyCF_``." -#: library/functions.rst:330 +#: library/functions.rst:333 msgid "" "The argument *optimize* specifies the optimization level of the compiler; " "the default value of ``-1`` selects the optimization level of the " @@ -875,7 +912,7 @@ msgstr "" "ισχυρισμοί καταργήθηκαν, το ``__debug__`` είναι ψευδές) ή ``2`` (οι " "συμβολοσειρές εγγραφών καταργήθηκαν επίσης)." -#: library/functions.rst:336 +#: library/functions.rst:339 msgid "" "This function raises :exc:`SyntaxError` if the compiled source is invalid, " "and :exc:`ValueError` if the source contains null bytes." @@ -884,23 +921,15 @@ msgstr "" "κώδικας είναι άκυρος, και το :exc:`ValueError` εάν ο κώδικας περιλαμβάνει " "null bytes." -#: library/functions.rst:339 +#: library/functions.rst:342 msgid "" -"If you want to parse Python code into its AST representation, see :func:`ast." -"parse`." +"If you want to parse Python code into its AST representation, " +"see :func:`ast.parse`." msgstr "" "Εάν θέλετε να αναλύσετε τον κώδικα Python στην αναπαράσταση του AST, δείτε " "το :func:`ast.parse`." -#: library/functions.rst:342 -msgid "" -"Raises an :ref:`auditing event ` ``compile`` with arguments " -"``source``, ``filename``." -msgstr "" -"Εγείρει ένα :ref:`auditing event ` ``compile`` με ορίσματα " -"``source``, ``filename``." - -#: library/functions.rst:344 +#: library/functions.rst:347 msgid "" "Raises an :ref:`auditing event ` ``compile`` with arguments " "``source`` and ``filename``. This event may also be raised by implicit " @@ -910,20 +939,20 @@ msgstr "" "``source`` και ``filename``. Αυτό το συμβάν μπορεί επίσης να προκύψει από " "έμμεση μεταγλώττιση." -#: library/functions.rst:350 +#: library/functions.rst:353 msgid "" "When compiling a string with multi-line code in ``'single'`` or ``'eval'`` " "mode, input must be terminated by at least one newline character. This is " -"to facilitate detection of incomplete and complete statements in the :mod:" -"`code` module." +"to facilitate detection of incomplete and complete statements in " +"the :mod:`code` module." msgstr "" "Κατά τη μεταγλώττιση μιας συμβολοσειράς με κωδικό πολλαπλών γραμμών στη " "λειτουργία ``'single'`` ή ``'eval'``, η είσοδος πρέπει να τερματίζεται με " "τουλάχιστον έναν χαρακτήρα νέας γραμμής. Αυτό γίνεται για να διευκολυνθεί ο " -"εντοπισμός μη ολοκληρωμένων και ολοκληρωμένων δηλώσεων στο module :mod:" -"`code`." +"εντοπισμός μη ολοκληρωμένων και ολοκληρωμένων δηλώσεων στο " +"module :mod:`code`." -#: library/functions.rst:357 +#: library/functions.rst:360 msgid "" "It is possible to crash the Python interpreter with a sufficiently large/" "complex string when compiling to an AST object due to stack depth " @@ -933,7 +962,7 @@ msgstr "" "σύνθετη συμβολοσειρά κατά τη μεταγλώττιση σε ένα αντικείμενο AST λόγω " "περιορισμών βάθους στοίβας στον μεταγλωττιστή AST της Python." -#: library/functions.rst:361 +#: library/functions.rst:364 msgid "" "Allowed use of Windows and Mac newlines. Also, input in ``'exec'`` mode " "does not have to end in a newline anymore. Added the *optimize* parameter." @@ -942,7 +971,7 @@ msgstr "" "λειτουργία ``'exec'`` δεν χρειάζεται πλέον να τελειώνει σε νέα γραμμή. " "Προστέθηκε η παράμετρος *optimize*." -#: library/functions.rst:365 +#: library/functions.rst:368 msgid "" "Previously, :exc:`TypeError` was raised when null bytes were encountered in " "*source*." @@ -950,7 +979,7 @@ msgstr "" "Προηγουμένως, το :exc:`TypeError` έγινε raise όταν null bytes συναντήθηκαν " "στο *source*." -#: library/functions.rst:369 +#: library/functions.rst:372 msgid "" "``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` can now be passed in flags to enable " "support for top-level ``await``, ``async for``, and ``async with``." @@ -959,68 +988,100 @@ msgstr "" "για να ενεργοποιηθεί η υποστήριξη για ``await``, ``async for``, και ``async " "with``." -#: library/functions.rst:377 -msgid "" -"Return a complex number with the value *real* + *imag*\\*1j or convert a " -"string or number to a complex number. If the first parameter is a string, " -"it will be interpreted as a complex number and the function must be called " -"without a second parameter. The second parameter can never be a string. " -"Each argument may be any numeric type (including complex). If *imag* is " -"omitted, it defaults to zero and the constructor serves as a numeric " -"conversion like :class:`int` and :class:`float`. If both arguments are " -"omitted, returns ``0j``." -msgstr "" -"Επιστρέφει έναν μιγαδικό αριθμό με τιμή *real* + *imag*\\*1j ή μετατρέπει " -"μια συμβολοσειρά ή έναν αριθμό σε μιγαδικό αριθμό. Εάν η πρώτη παράμετρος " -"είναι συμβολοσειρά, θα ερμηνευτεί ως μιγαδικός αριθμός και η συνάρτηση θα " -"πρέπει να καλεστεί χωρίς δεύτερη παράμετρος. Η δεύτερη παράμετρος δεν " -"μπορεί ποτέ να είναι μια συμβολοσειρά. Κάθε όρισμα μπορεί να είναι " -"οποιουδήποτε αριθμητικού τύπου (συμπεριλαμβανομένου του μιγαδικού). Εάν το " -"*imag* παραλειφθεί, είναι μηδέν από προεπιλογή, και ο constructor χρησιμεύει " -"ως αριθμητική μετατροπή όπως :class:`int` και :class:`float`. Εάν " -"παραληφθούν και τα δύο ορίσματα, επιστρέφει το ``0j``." +#: library/functions.rst:381 +msgid "" +"Convert a single string or number to a complex number, or create a complex " +"number from real and imaginary parts." +msgstr "" + +#: library/functions.rst:731 library/functions.rst:977 +#, fuzzy +msgid "Examples:" +msgstr "Παραδείγματα::" #: library/functions.rst:386 msgid "" -"For a general Python object ``x``, ``complex(x)`` delegates to ``x." -"__complex__()``. If :meth:`~object.__complex__` is not defined then it " -"falls back to :meth:`~object.__float__`. If :meth:`!__float__` is not " -"defined then it falls back to :meth:`~object.__index__`." +">>> complex('+1.23')\n" +"(1.23+0j)\n" +">>> complex('-4.5j')\n" +"-4.5j\n" +">>> complex('-1.23+4.5j')\n" +"(-1.23+4.5j)\n" +">>> complex('\\t( -1.23+4.5J )\\n')\n" +"(-1.23+4.5j)\n" +">>> complex('-Infinity+NaNj')\n" +"(-inf+nanj)\n" +">>> complex(1.23)\n" +"(1.23+0j)\n" +">>> complex(imag=-4.5)\n" +"-4.5j\n" +">>> complex(-1.23, 4.5)\n" +"(-1.23+4.5j)" +msgstr "" + +#: library/functions.rst:405 +msgid "" +"If the argument is a string, it must contain either a real part (in the same " +"format as for :func:`float`) or an imaginary part (in the same format but " +"with a ``'j'`` or ``'J'`` suffix), or both real and imaginary parts (the " +"sign of the imaginary part is mandatory in this case). The string can " +"optionally be surrounded by whitespaces and the round parentheses ``'('`` " +"and ``')'``, which are ignored. The string must not contain whitespace " +"between ``'+'``, ``'-'``, the ``'j'`` or ``'J'`` suffix, and the decimal " +"number. For example, ``complex('1+2j')`` is fine, but ``complex('1 + 2j')`` " +"raises :exc:`ValueError`. More precisely, the input must conform to " +"the :token:`~float:complexvalue` production rule in the following grammar, " +"after parentheses and leading and trailing whitespace characters are removed:" +msgstr "" + +#: library/functions.rst:424 +#, fuzzy +msgid "" +"If the argument is a number, the constructor serves as a numeric conversion " +"like :class:`int` and :class:`float`. For a general Python object ``x``, " +"``complex(x)`` delegates to ``x.__complex__()``. " +"If :meth:`~object.__complex__` is not defined then it falls back " +"to :meth:`~object.__float__`. If :meth:`!__float__` is not defined then it " +"falls back to :meth:`~object.__index__`." msgstr "" -"Για ένα γενικό αντικείμενο Python ``x``, ``complex(x)`` εκχωρεί στο ``x." -"__complex__()``. Εάν το :meth:`~object.__complex__` δεν έχει οριστεί, τότε " -"επιστρέφει στο :meth:`~object.__float__`. Εάν το :meth:`!__float__` δεν " -"έχει οριστεί , τότε επιστρέφει στο :meth:`~object.__index__`." +"Για ένα γενικό αντικείμενο Python ``x``, ``complex(x)`` εκχωρεί στο " +"``x.__complex__()``. Εάν το :meth:`~object.__complex__` δεν έχει οριστεί, " +"τότε επιστρέφει στο :meth:`~object.__float__`. Εάν το :meth:`!__float__` " +"δεν έχει οριστεί , τότε επιστρέφει στο :meth:`~object.__index__`." -#: library/functions.rst:393 +#: library/functions.rst:433 msgid "" -"When converting from a string, the string must not contain whitespace around " -"the central ``+`` or ``-`` operator. For example, ``complex('1+2j')`` is " -"fine, but ``complex('1 + 2j')`` raises :exc:`ValueError`." +"If two arguments are provided or keyword arguments are used, each argument " +"may be any numeric type (including complex). If both arguments are real " +"numbers, return a complex number with the real component *real* and the " +"imaginary component *imag*. If both arguments are complex numbers, return a " +"complex number with the real component ``real.real-imag.imag`` and the " +"imaginary component ``real.imag+imag.real``. If one of arguments is a real " +"number, only its real component is used in the above expressions." msgstr "" -"Κατά την μετατροπή από μια συμβολοσειρά, η συμβολοσειρά δεν πρέπει να " -"περιέχει κενό διάστημα γύρω από τον κεντρικό τελεστή ``+`` ή ``-``. Για " -"παράδειγμα, ``complex('1+2j')`` είναι εντάξει, αλλά το ``complex('1 + 2j')`` " -"κάνει raise την :exc:`ValueError`." -#: library/functions.rst:398 +#: library/functions.rst:443 +msgid "If all arguments are omitted, returns ``0j``." +msgstr "" + +#: library/functions.rst:445 msgid "The complex type is described in :ref:`typesnumeric`." msgstr "Ο μιγαδικός τύπος περιγράφεται στο :ref:`typesnumeric`." -#: library/functions.rst:707 library/functions.rst:931 +#: library/functions.rst:783 library/functions.rst:1026 msgid "Grouping digits with underscores as in code literals is allowed." msgstr "" "Επιτρέπεται η ομαδοποίηση ψηφίων με κάτω παύλες όπως στα literals του κώδικα." -#: library/functions.rst:403 +#: library/functions.rst:450 msgid "" -"Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` and :" -"meth:`~object.__float__` are not defined." +"Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` " +"and :meth:`~object.__float__` are not defined." msgstr "" -"Επιστρέφει πίσω στη :meth:`~object.__index__` εάν η :meth:`~object." -"__complex__` και η :meth:`~object.__float__` δεν ορίζονται." +"Επιστρέφει πίσω στη :meth:`~object.__index__` εάν " +"η :meth:`~object.__complex__` και η :meth:`~object.__float__` δεν ορίζονται." -#: library/functions.rst:410 +#: library/functions.rst:457 msgid "" "This is a relative of :func:`setattr`. The arguments are an object and a " "string. The string must be the name of one of the object's attributes. The " @@ -1032,11 +1093,11 @@ msgstr "" "και μια συμβολοσειρά. Η συμβολοσειρά πρέπει να είναι το όνομα ενός από τα " "χαρακτηριστικά του αντικειμένου. Η συνάρτηση διαγράφει το επώνυμο " "χαρακτηριστικό, υπό την προϋπόθεση ότι το αντικείμενο το επιτρέπει. Για " -"παράδειγμα, το ``delattr(x, 'foobar')`` είναι ισοδύναμο με το ``del x." -"foobar``. Το *name* δεν χρειάζεται να είναι αναγνωριστικό της Python (δείτε :" -"func:`setattr`)." +"παράδειγμα, το ``delattr(x, 'foobar')`` είναι ισοδύναμο με το ``del " +"x.foobar``. Το *name* δεν χρειάζεται να είναι αναγνωριστικό της Python " +"(δείτε :func:`setattr`)." -#: library/functions.rst:423 +#: library/functions.rst:470 msgid "" "Create a new dictionary. The :class:`dict` object is the dictionary class. " "See :class:`dict` and :ref:`typesmapping` for documentation about this class." @@ -1045,15 +1106,16 @@ msgstr "" "λεξικού. Δείτε το :class:`dict` και το :ref:`typesmapping` για τεκμηρίωση " "σχετικά με αυτή την κατηγορία." -#: library/functions.rst:426 +#: library/functions.rst:473 msgid "" -"For other containers see the built-in :class:`list`, :class:`set`, and :" -"class:`tuple` classes, as well as the :mod:`collections` module." +"For other containers see the built-in :class:`list`, :class:`set`, " +"and :class:`tuple` classes, as well as the :mod:`collections` module." msgstr "" -"Για άλλα containers, δείτε τις ενσωματωμένες κλάσεις :class:`list`, :class:" -"`set`, και :class:`tuple`, καθώς και το module :mod:`collections`." +"Για άλλα containers, δείτε τις ενσωματωμένες " +"κλάσεις :class:`list`, :class:`set`, και :class:`tuple`, καθώς και το " +"module :mod:`collections`." -#: library/functions.rst:433 +#: library/functions.rst:480 msgid "" "Without arguments, return the list of names in the current local scope. " "With an argument, attempt to return a list of valid attributes for that " @@ -1063,36 +1125,37 @@ msgstr "" "ένα όρισμα, προσπαθεί να επιστρέψει μια λίστα έγκυρων χαρακτηριστικών για " "αυτό το αντικείμενο." -#: library/functions.rst:436 +#: library/functions.rst:483 msgid "" "If the object has a method named :meth:`~object.__dir__`, this method will " "be called and must return the list of attributes. This allows objects that " -"implement a custom :func:`~object.__getattr__` or :func:`~object." -"__getattribute__` function to customize the way :func:`dir` reports their " -"attributes." +"implement a custom :func:`~object.__getattr__` " +"or :func:`~object.__getattribute__` function to customize the " +"way :func:`dir` reports their attributes." msgstr "" "Εάν το αντικείμενο έχει μία μέθοδο με το όνομα :meth:`~object.__dir__`, αυτή " "η μέθοδος θα καλείται και πρέπει να επιστρέψει μια λίστα από χαρακτηριστικά. " -"Αυτό επιτρέπει τα αντικείμενα που υλοποιούν μια εξατομικευμένη συνάρτηση :" -"func:`~object.__getattr__` or :func:`~object.__getattribute__` για την " -"προσαρμογή του τρόπου με τον οποίο η :func:`dir` αναφέρει τα χαρακτηριστικά." +"Αυτό επιτρέπει τα αντικείμενα που υλοποιούν μια εξατομικευμένη " +"συνάρτηση :func:`~object.__getattr__` or :func:`~object.__getattribute__` " +"για την προσαρμογή του τρόπου με τον οποίο η :func:`dir` αναφέρει τα " +"χαρακτηριστικά." -#: library/functions.rst:443 +#: library/functions.rst:490 msgid "" "If the object does not provide :meth:`~object.__dir__`, the function tries " "its best to gather information from the object's :attr:`~object.__dict__` " "attribute, if defined, and from its type object. The resulting list is not " -"necessarily complete and may be inaccurate when the object has a custom :" -"func:`~object.__getattr__`." +"necessarily complete and may be inaccurate when the object has a " +"custom :func:`~object.__getattr__`." msgstr "" "Εάν το αντικείμενο δεν παρέχει την :meth:`~object.__dir__`, η συνάρτηση " -"προσπαθεί να συλλέξει πληροφορίες από το χαρακτηριστικό :attr:`~object." -"__dict__` του αντικειμένου, εάν έχει οριστεί, και από το αντικείμενο του " -"τύπου του. Η λίστα που παράγεται ως αποτέλεσμα δεν είναι απαραίτητα πλήρης " -"και μπορεί να είναι ανακριβής όταν το αντικείμενο έχει εξατομικευμένη :func:" -"`~object.__getattr__`." +"προσπαθεί να συλλέξει πληροφορίες από το " +"χαρακτηριστικό :attr:`~object.__dict__` του αντικειμένου, εάν έχει οριστεί, " +"και από το αντικείμενο του τύπου του. Η λίστα που παράγεται ως αποτέλεσμα " +"δεν είναι απαραίτητα πλήρης και μπορεί να είναι ανακριβής όταν το " +"αντικείμενο έχει εξατομικευμένη :func:`~object.__getattr__`." -#: library/functions.rst:449 +#: library/functions.rst:496 msgid "" "The default :func:`dir` mechanism behaves differently with different types " "of objects, as it attempts to produce the most relevant, rather than " @@ -1102,7 +1165,7 @@ msgstr "" "διαφορετικούς τύπους αντικειμένων, καθώς προσπαθεί να παράγει τις πιο " "σχετικές και όχι τις πιο ολοκληρωμένες πληροφορίες:" -#: library/functions.rst:453 +#: library/functions.rst:500 msgid "" "If the object is a module object, the list contains the names of the " "module's attributes." @@ -1110,7 +1173,7 @@ msgstr "" "Εάν το αντικείμενο είναι module τύπου αντικειμένου, η λίστα περιέχει τα " "ονόματα των χαρακτηριστικών του module." -#: library/functions.rst:456 +#: library/functions.rst:503 msgid "" "If the object is a type or class object, the list contains the names of its " "attributes, and recursively of the attributes of its bases." @@ -1119,7 +1182,7 @@ msgstr "" "τα ονόματα των χαρακτηριστικών του, και αναδρομικά τα χαρακτηριστικά της " "βάσεώς του." -#: library/functions.rst:459 +#: library/functions.rst:506 msgid "" "Otherwise, the list contains the object's attributes' names, the names of " "its class's attributes, and recursively of the attributes of its class's " @@ -1129,11 +1192,11 @@ msgstr "" "αντικειμένου, τα ονόματα των χαρακτηριστικών της κλάσης, και αναδρομικά τα " "χαρακτηριστικά της κλάσης βάσεως της κλάσης." -#: library/functions.rst:463 +#: library/functions.rst:510 msgid "The resulting list is sorted alphabetically. For example:" msgstr "Η παραγόμενη λίστα είναι ταξινομημένη αλφαβητικά. Για παράδειγμα:" -#: library/functions.rst:483 +#: library/functions.rst:530 msgid "" "Because :func:`dir` is supplied primarily as a convenience for use at an " "interactive prompt, it tries to supply an interesting set of names more than " @@ -1149,16 +1212,17 @@ msgstr "" "μετακλάσης δεν βρίσκονται στη λίστα αποτελεσμάτων όταν το όρισμα είναι μια " "κλάση." -#: library/functions.rst:493 +#: library/functions.rst:540 +#, fuzzy msgid "" "Take two (non-complex) numbers as arguments and return a pair of numbers " "consisting of their quotient and remainder when using integer division. " "With mixed operand types, the rules for binary arithmetic operators apply. " -"For integers, the result is the same as ``(a // b, a % b)``. For floating " -"point numbers the result is ``(q, a % b)``, where *q* is usually ``math." -"floor(a / b)`` but may be 1 less than that. In any case ``q * b + a % b`` " -"is very close to *a*, if ``a % b`` is non-zero it has the same sign as *b*, " -"and ``0 <= abs(a % b) < abs(b)``." +"For integers, the result is the same as ``(a // b, a % b)``. For floating-" +"point numbers the result is ``(q, a % b)``, where *q* is usually " +"``math.floor(a / b)`` but may be 1 less than that. In any case ``q * b + a " +"% b`` is very close to *a*, if ``a % b`` is non-zero it has the same sign as " +"*b*, and ``0 <= abs(a % b) < abs(b)``." msgstr "" "Λαμβάνει δύο (μη μιγαδικούς) αριθμούς ως ορίσματα και επιστρέφει ένα ζεύγος " "αριθμών που αποτελείται από το πηλίκο και το υπόλοιπο τους όταν " @@ -1171,13 +1235,13 @@ msgstr "" "b`` δεν είναι μηδενικό, έχει το ίδιο πρόσημο όπως το *b*, και ``0 <= abs(a % " "b) < abs(b)``." -#: library/functions.rst:505 +#: library/functions.rst:552 msgid "" -"Return an enumerate object. *iterable* must be a sequence, an :term:" -"`iterator`, or some other object which supports iteration. The :meth:" -"`~iterator.__next__` method of the iterator returned by :func:`enumerate` " -"returns a tuple containing a count (from *start* which defaults to 0) and " -"the values obtained from iterating over *iterable*." +"Return an enumerate object. *iterable* must be a sequence, " +"an :term:`iterator`, or some other object which supports iteration. " +"The :meth:`~iterator.__next__` method of the iterator returned " +"by :func:`enumerate` returns a tuple containing a count (from *start* which " +"defaults to 0) and the values obtained from iterating over *iterable*." msgstr "" "Επιστρέφει ένα αντικείμενο απαρίθμησης. Το *iterable* πρέπει να είναι μια " "ακολουθία, ένα :term:`iterator`, ή κάποιο άλλο αντικείμενο που υποστηρίζει " @@ -1186,21 +1250,58 @@ msgstr "" "περιέχει μια καταμέτρηση (από το *start* που είναι με προεπιλογή στο 0) και " "τις τιμές που λαμβάνονται από την επανάληψη πάνω στο *iterable*." -#: library/functions.rst:517 +#: library/functions.rst:564 msgid "Equivalent to::" msgstr "Ισοδύναμο με::" -#: library/functions.rst:529 +#: library/functions.rst:566 msgid "" -"The arguments are a string and optional globals and locals. If provided, " -"*globals* must be a dictionary. If provided, *locals* can be any mapping " -"object." +"def enumerate(iterable, start=0):\n" +" n = start\n" +" for elem in iterable:\n" +" yield n, elem\n" +" n += 1" +msgstr "" + +#: library/functions.rst:0 +msgid "Parameters" +msgstr "" + +#: library/functions.rst:576 +msgid "A Python expression." +msgstr "" + +#: library/functions.rst:580 +msgid "The global namespace (default: ``None``)." +msgstr "" + +#: library/functions.rst:584 +msgid "The local namespace (default: ``None``)." msgstr "" -"Τα ορίσματα είναι μια συμβολοσειρά (string), και προαιρετικά globals και " -"locals. Εάν παρέχεται το *globals* πρέπει να είναι λεξικό. Εάν παρέχεται " -"το *locals* μπορεί να είναι οποιοδήποτε αντικείμενο χαρτογράφησης." -#: library/functions.rst:533 +#: library/functions.rst:0 +msgid "Returns" +msgstr "" + +#: library/functions.rst:588 +msgid "The result of the evaluated expression." +msgstr "" + +#: library/functions.rst:0 +msgid "raises" +msgstr "" + +#: library/functions.rst:589 +msgid "Syntax errors are reported as exceptions." +msgstr "" + +#: library/functions.rst:644 +msgid "" +"This function executes arbitrary code. Calling it with user-supplied input " +"may lead to security vulnerabilities." +msgstr "" + +#: library/functions.rst:596 msgid "" "The *expression* argument is parsed and evaluated as a Python expression " "(technically speaking, a condition list) using the *globals* and *locals* " @@ -1209,37 +1310,35 @@ msgid "" "reference to the dictionary of the built-in module :mod:`builtins` is " "inserted under that key before *expression* is parsed. That way you can " "control what builtins are available to the executed code by inserting your " -"own ``__builtins__`` dictionary into *globals* before passing it to :func:" -"`eval`. If the *locals* dictionary is omitted it defaults to the *globals* " -"dictionary. If both dictionaries are omitted, the expression is executed " -"with the *globals* and *locals* in the environment where :func:`eval` is " -"called. Note, *eval()* does not have access to the :term:`nested scopes " -"` (non-locals) in the enclosing environment." +"own ``__builtins__`` dictionary into *globals* before passing it " +"to :func:`eval`. If the *locals* dictionary is omitted it defaults to the " +"*globals* dictionary. If both dictionaries are omitted, the expression is " +"executed with the *globals* and *locals* in the environment " +"where :func:`eval` is called. Note, *eval()* does not have access to " +"the :term:`nested scopes ` (non-locals) in the enclosing " +"environment." msgstr "" "Το όρισμα *expression* αναλύεται και αξιολογείται ως μια έκφραση της Python " "(από τεχνικής άποψης, μια λίστα συνθηκών) χρησιμοποιώντας τα λεξικά " "(dictionaries) *globals* και *locals* ως global και local namespace. Εάν το " "λεξικό *globals* υπάρχει και δεν περιέχει μια τιμή για το κλειδί " -"``__builtins__``, μια αναφορά στο λεξικό του ενσωματωμένου module :mod:" -"`builtins` εισάγεται κάτω από αυτό το κλειδί πριν αναλυθεί το *expression*. " -"Με αυτόν τον τρόπο μπορείτε να ελέγξετε ποια από τα ενσωματωμένα στοιχεία " -"είναι διαθέσιμα για τον εκτελέσιμο κώδικα, εισάγοντας το δικό σας λεξικό " -"``__builtins__`` στο *globals* πριν διαβαστεί στη :func:`eval`. Εάν το " -"λεξικό *locals* παραλειφθεί, ορίζεται από προεπιλογή στο λεξικό *globals*. " -"Εάν παραληφθούν και τα δύο λεξικά, η έκφραση εκτελείται με τα *globals* και " -"*locals* στο περιβάλλον όπου καλείται η :func:`eval`. Σημείωση, το *eval()* " -"δεν έχει πρόσβαση στο :term:`nested scopes ` (μη τοπικά) στο " -"περιβάλλον που περικλείει." - -#: library/functions.rst:548 -msgid "" -"The return value is the result of the evaluated expression. Syntax errors " -"are reported as exceptions. Example:" -msgstr "" -"Η τιμή που επιστρέφεται είναι το αποτέλεσμα της αξιολογούμενης έκφρασης. Τα " -"σφάλματα σύνταξης αναφέρονται ως εξαιρέσεις. Παράδειγμα:" +"``__builtins__``, μια αναφορά στο λεξικό του ενσωματωμένου " +"module :mod:`builtins` εισάγεται κάτω από αυτό το κλειδί πριν αναλυθεί το " +"*expression*. Με αυτόν τον τρόπο μπορείτε να ελέγξετε ποια από τα " +"ενσωματωμένα στοιχεία είναι διαθέσιμα για τον εκτελέσιμο κώδικα, εισάγοντας " +"το δικό σας λεξικό ``__builtins__`` στο *globals* πριν διαβαστεί " +"στη :func:`eval`. Εάν το λεξικό *locals* παραλειφθεί, ορίζεται από " +"προεπιλογή στο λεξικό *globals*. Εάν παραληφθούν και τα δύο λεξικά, η " +"έκφραση εκτελείται με τα *globals* και *locals* στο περιβάλλον όπου καλείται " +"η :func:`eval`. Σημείωση, το *eval()* δεν έχει πρόσβαση στο :term:`nested " +"scopes ` (μη τοπικά) στο περιβάλλον που περικλείει." + +#: library/functions.rst:611 +#, fuzzy +msgid "Example:" +msgstr "Παράδειγμα::" -#: library/functions.rst:555 +#: library/functions.rst:617 msgid "" "This function can also be used to execute arbitrary code objects (such as " "those created by :func:`compile`). In this case, pass a code object instead " @@ -1253,19 +1352,20 @@ msgstr "" "ως το όρισμα *mode*, η επιστρεφόμενη τιμή του :func:`eval`\\'s θα είναι " "``None``." -#: library/functions.rst:560 +#: library/functions.rst:622 msgid "" "Hints: dynamic execution of statements is supported by the :func:`exec` " "function. The :func:`globals` and :func:`locals` functions return the " "current global and local dictionary, respectively, which may be useful to " "pass around for use by :func:`eval` or :func:`exec`." msgstr "" -"Συμβουλές: η δυναμική εκτέλεση εντολών υποστηρίζεται από την συνάρτηση :func:" -"`exec`. Οι συναρτήσεις :func:`globals` και :func:`locals` επιστρέφουν το " -"τρέχον global και local λεξικό, αντίστοιχα, το οποίο μπορεί να είναι χρήσιμο " -"για μεταβίβαση γύρω από τη χρήση από τις :func:`eval` ή :func:`exec`." +"Συμβουλές: η δυναμική εκτέλεση εντολών υποστηρίζεται από την " +"συνάρτηση :func:`exec`. Οι συναρτήσεις :func:`globals` και :func:`locals` " +"επιστρέφουν το τρέχον global και local λεξικό, αντίστοιχα, το οποίο μπορεί " +"να είναι χρήσιμο για μεταβίβαση γύρω από τη χρήση από τις :func:`eval` " +"ή :func:`exec`." -#: library/functions.rst:565 +#: library/functions.rst:627 msgid "" "If the given source is a string, then leading and trailing spaces and tabs " "are stripped." @@ -1273,7 +1373,7 @@ msgstr "" "Εάν η δεδομένη πηγή είναι μια συμβολοσειρά, τότε αφαιρούνται τα κενά και τα " "tabs που προηγούνται ή έπονται." -#: library/functions.rst:568 +#: library/functions.rst:630 msgid "" "See :func:`ast.literal_eval` for a function that can safely evaluate strings " "with expressions containing only literals." @@ -1281,15 +1381,7 @@ msgstr "" "Βλ. τη :func:`ast.literal_eval` για μια συνάρτηση που μπορεί με ασφάλεια να " "αξιολογήσει τις συμβολοσειρές με εκφράσεις που περιέχουν μόνο literals." -#: library/functions.rst:612 -msgid "" -"Raises an :ref:`auditing event ` ``exec`` with argument " -"``code_object``." -msgstr "" -"Κάνει raise ένα :ref:`auditing event ` ``exec`` με όρισμα " -"``code_object``." - -#: library/functions.rst:614 +#: library/functions.rst:635 library/functions.rst:685 msgid "" "Raises an :ref:`auditing event ` ``exec`` with the code object as " "the argument. Code compilation events may also be raised." @@ -1297,17 +1389,17 @@ msgstr "" "Κάνει raise ένα :ref:`auditing event ` ``exec`` με το αντικείμενο " "κώδικα ως όρισμα. Μπορεί επίσης να εμφανιστούν συμβάντα μεταγλώττισης κώδικα." -#: library/functions.rst:580 +#: library/functions.rst:647 msgid "" "This function supports dynamic execution of Python code. *object* must be " "either a string or a code object. If it is a string, the string is parsed " "as a suite of Python statements which is then executed (unless a syntax " "error occurs). [#]_ If it is a code object, it is simply executed. In all " "cases, the code that's executed is expected to be valid as file input (see " -"the section :ref:`file-input` in the Reference Manual). Be aware that the :" -"keyword:`nonlocal`, :keyword:`yield`, and :keyword:`return` statements may " -"not be used outside of function definitions even within the context of code " -"passed to the :func:`exec` function. The return value is ``None``." +"the section :ref:`file-input` in the Reference Manual). Be aware that " +"the :keyword:`nonlocal`, :keyword:`yield`, and :keyword:`return` statements " +"may not be used outside of function definitions even within the context of " +"code passed to the :func:`exec` function. The return value is ``None``." msgstr "" "Αυτή η συνάρτηση υποστηρίζει δυναμική εκτέλεση κώδικα Python. Το *object* " "πρέπει να είναι είτε μια συμβολοσειρά (string) είτε ένα αντικείμενο κώδικα. " @@ -1316,12 +1408,13 @@ msgstr "" "[#]_ Εάν πρόκειται για ένα αντικείμενο κώδικα, απλά εκτελείται. Σε όλες τις " "περιπτώσεις, ο κώδικας που εκτελείται αναμένεται να είναι έγκυρος ως είσοδος " "αρχείου (δείτε την ενότητα :ref:`file-input` στο Εγχειρίδιο Αναφοράς). " -"Λάβετε υπόψη ότι οι εντολές :keyword:`nonlocal`, :keyword:`yield`, και :" -"keyword:`return` δεν μπορούν να χρησιμοποιηθούν εκτός των ορισμών " -"συναρτήσεων, ακόμη και στο πλαίσιο του κώδικα που διαβιβάζεται στη :func:" -"`exec`. Η επιστρεφόμενη τιμή είναι ``None``." +"Λάβετε υπόψη ότι οι εντολές :keyword:`nonlocal`, :keyword:`yield`, " +"και :keyword:`return` δεν μπορούν να χρησιμοποιηθούν εκτός των ορισμών " +"συναρτήσεων, ακόμη και στο πλαίσιο του κώδικα που διαβιβάζεται " +"στη :func:`exec`. Η επιστρεφόμενη τιμή είναι ``None``." -#: library/functions.rst:591 +#: library/functions.rst:658 +#, fuzzy msgid "" "In all cases, if the optional parts are omitted, the code is executed in the " "current scope. If only *globals* is provided, it must be a dictionary (and " @@ -1329,9 +1422,7 @@ msgid "" "the local variables. If *globals* and *locals* are given, they are used for " "the global and local variables, respectively. If provided, *locals* can be " "any mapping object. Remember that at the module level, globals and locals " -"are the same dictionary. If exec gets two separate objects as *globals* and " -"*locals*, the code will be executed as if it were embedded in a class " -"definition." +"are the same dictionary." msgstr "" "Σε όλες τις περιπτώσεις, εάν παραληφθούν τα προαιρετικά μέρη, ο κώδικας " "εκτελείται στο τρέχον εύρος. Εάν παρέχεται μόνο *globals*, πρέπει να είναι " @@ -1342,22 +1433,29 @@ msgstr "" "ξεχωριστά αντικείμενα ως *globals* και *locals*, ο κώδικας θα εκτελεστεί σαν " "να ήταν ενσωματωμένος σε έναν ορισμό κλάσης." -#: library/functions.rst:601 +#: library/functions.rst:668 +msgid "" +"Most users should just pass a *globals* argument and never *locals*. If exec " +"gets two separate objects as *globals* and *locals*, the code will be " +"executed as if it were embedded in a class definition." +msgstr "" + +#: library/functions.rst:672 msgid "" "If the *globals* dictionary does not contain a value for the key " -"``__builtins__``, a reference to the dictionary of the built-in module :mod:" -"`builtins` is inserted under that key. That way you can control what " -"builtins are available to the executed code by inserting your own " +"``__builtins__``, a reference to the dictionary of the built-in " +"module :mod:`builtins` is inserted under that key. That way you can control " +"what builtins are available to the executed code by inserting your own " "``__builtins__`` dictionary into *globals* before passing it to :func:`exec`." msgstr "" "Εάν το λεξικό *globals* δεν περιέχει τιμή για το κλειδί ``__builtins__``, " "μια αναφορά στο λεξικό του ενσωματωμένου module :mod:`builtins` εισάγεται " "κάτω από αυτό το κλειδί. Με αυτόν τον τρόπο μπορεί να ελέγξετε τι " "ενσωματωμένα (built-ins) είναι διαθέσιμα στον εκτελέσιμο κώδικα εισάγοντας " -"το δικό σας ``__builtins__`` λεξικό στο *globals* πριν το διαβάσετε στο :" -"func:`exec`." +"το δικό σας ``__builtins__`` λεξικό στο *globals* πριν το διαβάσετε " +"στο :func:`exec`." -#: library/functions.rst:607 +#: library/functions.rst:678 msgid "" "The *closure* argument specifies a closure--a tuple of cellvars. It's only " "valid when the *object* is a code object containing free variables. The " @@ -1370,7 +1468,7 @@ msgstr "" "τον αριθμό των ελεύθερων μεταβλητών που αναφέρονται από το αντικείμενο " "κώδικα." -#: library/functions.rst:619 +#: library/functions.rst:690 msgid "" "The built-in functions :func:`globals` and :func:`locals` return the current " "global and local dictionary, respectively, which may be useful to pass " @@ -1380,24 +1478,24 @@ msgstr "" "το τρέχον global και local λεξικό, αντίστοιχα, που μπορεί να είναι χρήσιμο " "για χρήση ως δεύτερο και τρίτο όρισμα στο :func:`exec`." -#: library/functions.rst:625 +#: library/functions.rst:696 msgid "" "The default *locals* act as described for function :func:`locals` below: " "modifications to the default *locals* dictionary should not be attempted. " "Pass an explicit *locals* dictionary if you need to see effects of the code " "on *locals* after function :func:`exec` returns." msgstr "" -"Το προεπιλεγμένο *locals* ενεργεί όπως περιγράφεται για τη συνάρτηση :func:" -"`locals` παρακάτω: δεν πρέπει να επιχειρήσετε τροποποιήσεις στο " -"προεπιλεγμένο *locals* λεξικό. Περνάει ένα ρητό *locals* λεξικό εάν θέλετε " -"να δείτε τα αποτελέσματα του κώδικα στο *locals* με την επιστροφή της " +"Το προεπιλεγμένο *locals* ενεργεί όπως περιγράφεται για τη " +"συνάρτηση :func:`locals` παρακάτω: δεν πρέπει να επιχειρήσετε τροποποιήσεις " +"στο προεπιλεγμένο *locals* λεξικό. Περνάει ένα ρητό *locals* λεξικό εάν " +"θέλετε να δείτε τα αποτελέσματα του κώδικα στο *locals* με την επιστροφή της " "συνάρτησης :func:`exec`." -#: library/functions.rst:630 +#: library/functions.rst:701 msgid "Added the *closure* parameter." msgstr "Προστέθηκε η παράμετρος *closure*." -#: library/functions.rst:636 +#: library/functions.rst:707 msgid "" "Construct an iterator from those elements of *iterable* for which *function* " "is true. *iterable* may be either a sequence, a container which supports " @@ -1410,7 +1508,7 @@ msgstr "" "*function* είναι ``None``, η συνάρτηση ταυτότητας υποτίθεται, δηλαδή, όλα τα " "στοιχεία του *iterable* που είναι ψευδή αφαιρούνται." -#: library/functions.rst:642 +#: library/functions.rst:713 msgid "" "Note that ``filter(function, iterable)`` is equivalent to the generator " "expression ``(item for item in iterable if function(item))`` if function is " @@ -1422,7 +1520,7 @@ msgstr "" "η συνάρτηση δεν είναι ``None`` και ``(item for item in iterable if item)`` " "εάν η συνάρτηση είναι ``None``." -#: library/functions.rst:647 +#: library/functions.rst:718 msgid "" "See :func:`itertools.filterfalse` for the complementary function that " "returns elements of *iterable* for which *function* is false." @@ -1430,21 +1528,37 @@ msgstr "" "Βλ. :func:`itertools.filterfalse` για τη συμπληρωματική συνάρτηση που " "επιστρέφει στοιχεία του *iterable* για τα οποία η *function* είναι ψευδής." -#: library/functions.rst:657 -msgid "Return a floating point number constructed from a number or string *x*." +#: library/functions.rst:729 +#, fuzzy +msgid "Return a floating-point number constructed from a number or a string." msgstr "" "Επιστέφει έναν αριθμό κινητής υποδιαστολής που κατασκευάστηκε από έναν " "αριθμό ή μια συμβολοσειρά *x*." -#: library/functions.rst:659 +#: library/functions.rst:733 +msgid "" +">>> float('+1.23')\n" +"1.23\n" +">>> float(' -12345\\n')\n" +"-12345.0\n" +">>> float('1e-003')\n" +"0.001\n" +">>> float('+1E6')\n" +"1000000.0\n" +">>> float('-Infinity')\n" +"-inf" +msgstr "" + +#: library/functions.rst:746 +#, fuzzy msgid "" "If the argument is a string, it should contain a decimal number, optionally " "preceded by a sign, and optionally embedded in whitespace. The optional " "sign may be ``'+'`` or ``'-'``; a ``'+'`` sign has no effect on the value " "produced. The argument may also be a string representing a NaN (not-a-" -"number), or positive or negative infinity. More precisely, the input must " -"conform to the ``floatvalue`` production rule in the following grammar, " -"after leading and trailing whitespace characters are removed:" +"number), or positive or negative infinity. More precisely, the input must " +"conform to the :token:`~float:floatvalue` production rule in the following " +"grammar, after leading and trailing whitespace characters are removed:" msgstr "" "Εάν το όρισμα είναι συμβολοσειρά (string), θα πρέπει να περιέχει έναν " "δεκαδικό αριθμό, προαιρετικά πριν από ένα σύμβολο και προαιρετικά " @@ -1456,7 +1570,7 @@ msgstr "" "``floatvalue`` στην ακόλουθη γραμματική, αφού αφαιρεθούν οι χαρακτήρες κενού " "διαστήματος που έπονται και προηγούνται:" -#: library/functions.rst:678 +#: library/functions.rst:767 msgid "" "Case is not significant, so, for example, \"inf\", \"Inf\", \"INFINITY\", " "and \"iNfINity\" are all acceptable spellings for positive infinity." @@ -1465,10 +1579,11 @@ msgstr "" "\"Inf\", \"INFINITY\", και \"iNfINity\" είναι όλες αποδεκτές ορθογραφίες για " "το θετικό άπειρο." -#: library/functions.rst:681 +#: library/functions.rst:770 +#, fuzzy msgid "" -"Otherwise, if the argument is an integer or a floating point number, a " -"floating point number with the same value (within Python's floating point " +"Otherwise, if the argument is an integer or a floating-point number, a " +"floating-point number with the same value (within Python's floating-point " "precision) is returned. If the argument is outside the range of a Python " "float, an :exc:`OverflowError` will be raised." msgstr "" @@ -1477,29 +1592,25 @@ msgstr "" "ακρίβειας κινητής υποδιαστολής της Python). Εάν το όρισμα βρίσκεται εκτός " "του εύρους ενός float της Python θα γίνει raise ένα :exc:`OverflowError`." -#: library/functions.rst:686 +#: library/functions.rst:775 msgid "" -"For a general Python object ``x``, ``float(x)`` delegates to ``x." -"__float__()``. If :meth:`~object.__float__` is not defined then it falls " -"back to :meth:`~object.__index__`." +"For a general Python object ``x``, ``float(x)`` delegates to " +"``x.__float__()``. If :meth:`~object.__float__` is not defined then it " +"falls back to :meth:`~object.__index__`." msgstr "" -"Για ένα γενικό αντικείμενο Python ``x``, ``float(x)`` εκχωρεί στο ``x." -"__float__()``. Εάν το :meth:`~object.__float__` δεν έχει οριστεί, τότε " +"Για ένα γενικό αντικείμενο Python ``x``, ``float(x)`` εκχωρεί στο " +"``x.__float__()``. Εάν το :meth:`~object.__float__` δεν έχει οριστεί, τότε " "επιστρέφει στο :meth:`~object.__index__`." -#: library/functions.rst:690 +#: library/functions.rst:779 msgid "If no argument is given, ``0.0`` is returned." msgstr "Εάν δεν δοθεί όρισμα, επιστρέφεται το ``0.0``." -#: library/functions.rst:692 -msgid "Examples::" -msgstr "Παραδείγματα::" - -#: library/functions.rst:705 +#: library/functions.rst:781 msgid "The float type is described in :ref:`typesnumeric`." msgstr "Ο τύπος float περιγράφεται στο :ref:`typesnumeric`." -#: library/functions.rst:713 +#: library/functions.rst:789 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__float__` is not " "defined." @@ -1507,7 +1618,7 @@ msgstr "" "Επιστρέφει στο :meth:`~object.__index__` εάν το :meth:`~object.__float__` " "δεν έχει οριστεί." -#: library/functions.rst:723 +#: library/functions.rst:799 msgid "" "Convert a *value* to a \"formatted\" representation, as controlled by " "*format_spec*. The interpretation of *format_spec* will depend on the type " @@ -1517,10 +1628,10 @@ msgstr "" "Μετατρέπει ένα *value* σε μια αναπαράσταση \"formatted\", όπως ελέγχεται από " "το *format_spec*. Η ερμηνεία του *format_spec* θα εξαρτηθεί από τον τύπο " "του ορίσματος *value* ∙ ωστόσο υπάρχει μια τυπική σύνταξη μορφοποίησης που " -"χρησιμοποιείται από τους περισσότερους ενσωματωμένους τύπους: :ref:" -"`formatspec`." +"χρησιμοποιείται από τους περισσότερους ενσωματωμένους " +"τύπους: :ref:`formatspec`." -#: library/functions.rst:728 +#: library/functions.rst:804 msgid "" "The default *format_spec* is an empty string which usually gives the same " "effect as calling :func:`str(value) `." @@ -1528,23 +1639,24 @@ msgstr "" "Η προεπιλεγμένη *format_spec* είναι μια κενή συμβολοσειρά που συνήθως δίνει " "το ίδιο αποτέλεσμα με την κλήση του :func:`str(value) `." -#: library/functions.rst:731 +#: library/functions.rst:807 msgid "" -"A call to ``format(value, format_spec)`` is translated to ``type(value)." -"__format__(value, format_spec)`` which bypasses the instance dictionary when " -"searching for the value's :meth:`~object.__format__` method. A :exc:" -"`TypeError` exception is raised if the method search reaches :mod:`object` " -"and the *format_spec* is non-empty, or if either the *format_spec* or the " -"return value are not strings." +"A call to ``format(value, format_spec)`` is translated to " +"``type(value).__format__(value, format_spec)`` which bypasses the instance " +"dictionary when searching for the value's :meth:`~object.__format__` method. " +"A :exc:`TypeError` exception is raised if the method search " +"reaches :mod:`object` and the *format_spec* is non-empty, or if either the " +"*format_spec* or the return value are not strings." msgstr "" -"Μια κλήση στο ``format(value, format_spec)`` μεταφράζεται σε ``type(value)." -"__format__(value, format_spec)`` το οποίο παρακάμπτει το instance του " -"λεξικού κατά την αναζήτηση της τιμής της μεθόδου :meth:`~object.__format__`. " -"Μια εξαίρεση :exc:`TypeError` γίνεται raise εάν η αναζήτηση της μεθόδου " -"φτάσει στο :mod:`object` και το *format_spec* δεν είναι κενό ή εάν είτε το " -"*format_spec* είτε η τιμή επιστροφής δεν είναι συμβολοσειρές." +"Μια κλήση στο ``format(value, format_spec)`` μεταφράζεται σε " +"``type(value).__format__(value, format_spec)`` το οποίο παρακάμπτει το " +"instance του λεξικού κατά την αναζήτηση της τιμής της " +"μεθόδου :meth:`~object.__format__`. Μια εξαίρεση :exc:`TypeError` γίνεται " +"raise εάν η αναζήτηση της μεθόδου φτάσει στο :mod:`object` και το " +"*format_spec* δεν είναι κενό ή εάν είτε το *format_spec* είτε η τιμή " +"επιστροφής δεν είναι συμβολοσειρές." -#: library/functions.rst:738 +#: library/functions.rst:814 msgid "" "``object().__format__(format_spec)`` raises :exc:`TypeError` if " "*format_spec* is not an empty string." @@ -1552,27 +1664,28 @@ msgstr "" "Το ``object().__format__(format_spec)`` κάνει raise το :exc:`TypeError` εάν " "το *format_spec* δεν είναι κενή συμβολοσειρά." -#: library/functions.rst:747 +#: library/functions.rst:823 msgid "" "Return a new :class:`frozenset` object, optionally with elements taken from " -"*iterable*. ``frozenset`` is a built-in class. See :class:`frozenset` and :" -"ref:`types-set` for documentation about this class." +"*iterable*. ``frozenset`` is a built-in class. See :class:`frozenset` " +"and :ref:`types-set` for documentation about this class." msgstr "" "Επιστρέφει ένα νέο αντικείμενο :class:`frozenset`, προαιρετικά με στοιχεία " "που λαμβάνονται από το *iterable*. Το ``frozenset`` είναι μια ενσωματωμένη " "κλάση. Δείτε το :class:`frozenset` και το :ref:`types-set` για τεκμηρίωση " "αυτής της κλάσης." -#: library/functions.rst:751 +#: library/functions.rst:827 msgid "" -"For other containers see the built-in :class:`set`, :class:`list`, :class:" -"`tuple`, and :class:`dict` classes, as well as the :mod:`collections` module." +"For other containers see the built-" +"in :class:`set`, :class:`list`, :class:`tuple`, and :class:`dict` classes, " +"as well as the :mod:`collections` module." msgstr "" -"Για άλλα containers, ανατρέξτε στις ενσωματωμένες κλάσεις :class:`set`, :" -"class:`list`, :class:`tuple`, και :class:`dict`, καθώς και το module :mod:" -"`collections`." +"Για άλλα containers, ανατρέξτε στις ενσωματωμένες " +"κλάσεις :class:`set`, :class:`list`, :class:`tuple`, και :class:`dict`, " +"καθώς και το module :mod:`collections`." -#: library/functions.rst:759 +#: library/functions.rst:835 msgid "" "Return the value of the named attribute of *object*. *name* must be a " "string. If the string is the name of one of the object's attributes, the " @@ -1586,23 +1699,23 @@ msgstr "" "τα χαρακτηριστικά του αντικειμένου, το αποτέλεσμα είναι η τιμή αυτού του " "χαρακτηριστικού. Για παράδειγμα, ``getattr(x, 'foobar')`` είναι ισοδύναμο " "με το ``x.foobar``. Εάν το χαρακτηριστικό γνώρισμα δεν υπάρχει, το " -"*default* επιστρέφεται εάν παρέχεται, διαφορετικά γίνεται raise το :exc:" -"`AttributeError`. Το *name* δεν χρειάζεται να είναι αναγνωριστικό Python " -"(δείτε :func:`setattr`)." +"*default* επιστρέφεται εάν παρέχεται, διαφορετικά γίνεται raise " +"το :exc:`AttributeError`. Το *name* δεν χρειάζεται να είναι αναγνωριστικό " +"Python (δείτε :func:`setattr`)." -#: library/functions.rst:768 +#: library/functions.rst:844 msgid "" "Since :ref:`private name mangling ` happens at " "compilation time, one must manually mangle a private attribute's (attributes " -"with two leading underscores) name in order to retrieve it with :func:" -"`getattr`." +"with two leading underscores) name in order to retrieve it " +"with :func:`getattr`." msgstr "" "Δεδομένου ότι το :ref:`private name mangling ` " "συμβαίνει κατά τη στιγμή της μεταγλώττισης, πρέπει κανείς να παραμορφώνει " "χειροκίνητα το όνομα ενός ιδιωτικού χαρακτηριστικού (χαρακτηριστικά με δύο " "κορυφαίες υπογραμμίσεις) για να ανακτήσει με :func:`getattr`." -#: library/functions.rst:776 +#: library/functions.rst:852 msgid "" "Return the dictionary implementing the current module namespace. For code " "within functions, this is set when the function is defined and remains the " @@ -1612,7 +1725,7 @@ msgstr "" "κώδικα εντός συναρτήσεων, αυτό ορίζεται όταν ορίζεται η συνάρτηση και " "παραμένει το ίδιο ανεξάρτητη από το που καλείται η συνάρτηση." -#: library/functions.rst:783 +#: library/functions.rst:859 msgid "" "The arguments are an object and a string. The result is ``True`` if the " "string is the name of one of the object's attributes, ``False`` if not. " @@ -1622,10 +1735,10 @@ msgstr "" "Τα ορίσματα είναι ένα αντικείμενο και μια συμβολοσειρά (string). Το " "αποτέλεσμα είναι ``True`` εάν η συμβολοσειρά είναι το όνομα ενός από τα " "χαρακτηριστικά του αντικειμένου, ``False`` εάν όχι. (Αυτό υλοποιείται " -"καλώντας το ``getattr(object, name)`` και να δούμε αν γίνεται raise ένα :exc:" -"`AttributeError` ή όχι.)" +"καλώντας το ``getattr(object, name)`` και να δούμε αν γίνεται raise " +"ένα :exc:`AttributeError` ή όχι.)" -#: library/functions.rst:791 +#: library/functions.rst:867 msgid "" "Return the hash value of the object (if it has one). Hash values are " "integers. They are used to quickly compare dictionary keys during a " @@ -1638,16 +1751,17 @@ msgstr "" "αριθμητικές τιμές που συγκρίνονται ίσες έχουν την ίδια τιμή κατακερματισμού " "(ακόμα και αν είναι διαφορετικοί τύποι, όπως συμβαίνει για τα 1 και 1.0)." -#: library/functions.rst:798 +#: library/functions.rst:874 msgid "" -"For objects with custom :meth:`~object.__hash__` methods, note that :func:" -"`hash` truncates the return value based on the bit width of the host machine." +"For objects with custom :meth:`~object.__hash__` methods, note " +"that :func:`hash` truncates the return value based on the bit width of the " +"host machine." msgstr "" "Για αντικείμενα με προσαρμοσμένες μεθόδους :meth:`~object.__hash__`, " "σημειώστε ότι το :func:`hash` περικόπτει την τιμή επιστροφής με βάση το " "πλάτος bit του υπολογιστή." -#: library/functions.rst:805 +#: library/functions.rst:881 msgid "" "Invoke the built-in help system. (This function is intended for interactive " "use.) If no argument is given, the interactive help system starts on the " @@ -1665,7 +1779,7 @@ msgstr "" "είναι οποιοδήποτε άλλο είδος αντικειμένου, δημιουργείται μια σελίδα βοήθειας " "στο αντικείμενο." -#: library/functions.rst:812 +#: library/functions.rst:888 msgid "" "Note that if a slash(/) appears in the parameter list of a function when " "invoking :func:`help`, it means that the parameters prior to the slash are " @@ -1677,14 +1791,14 @@ msgstr "" "την κάθετο είναι μόνο θέσης. Για περισσότερες πληροφορίες, βλέπε :ref:`the " "FAQ entry on positional-only parameters `." -#: library/functions.rst:817 +#: library/functions.rst:893 msgid "" "This function is added to the built-in namespace by the :mod:`site` module." msgstr "" -"Αυτή η συνάρτηση προστίθεται στον ενσωματωμένο χώρο ονομάτων από το module :" -"mod:`site`." +"Αυτή η συνάρτηση προστίθεται στον ενσωματωμένο χώρο ονομάτων από το " +"module :mod:`site`." -#: library/functions.rst:819 +#: library/functions.rst:895 msgid "" "Changes to :mod:`pydoc` and :mod:`inspect` mean that the reported signatures " "for callables are now more comprehensive and consistent." @@ -1692,18 +1806,18 @@ msgstr "" "Οι αλλαγές σε :mod:`pydoc` και :mod:`inspect` σημαίνουν ότι οι αναφερόμενες " "υπογραφές για callables είναι πλέον πιο ολοκληρωμένες και συνεπείς." -#: library/functions.rst:826 +#: library/functions.rst:902 msgid "" "Convert an integer number to a lowercase hexadecimal string prefixed with " -"\"0x\". If *x* is not a Python :class:`int` object, it has to define an :" -"meth:`~object.__index__` method that returns an integer. Some examples:" +"\"0x\". If *x* is not a Python :class:`int` object, it has to define " +"an :meth:`~object.__index__` method that returns an integer. Some examples:" msgstr "" "Μετατροπή ενός ακεραίου αριθμού σε μια πεζή δεκαεξαδική συμβολοσειρά " -"(string) με πρόθεμα το \"0x\". Εάν το *x* δεν είναι αντικείμενο Python :" -"class:`int`, πρέπει να ορίσει μια μέθοδο :meth:`~object.__index__` που " -"επιστρέφει έναν ακέραιο αριθμό. Κάποια παραδείγματα:" +"(string) με πρόθεμα το \"0x\". Εάν το *x* δεν είναι αντικείμενο " +"Python :class:`int`, πρέπει να ορίσει μια μέθοδο :meth:`~object.__index__` " +"που επιστρέφει έναν ακέραιο αριθμό. Κάποια παραδείγματα:" -#: library/functions.rst:835 +#: library/functions.rst:911 msgid "" "If you want to convert an integer number to an uppercase or lower " "hexadecimal string with prefix or not, you can use either of the following " @@ -1713,7 +1827,7 @@ msgstr "" "δεκαεξαδική συμβολοσειρά (string) με πρόθεμα ή όχι, μπορείτε να " "χρησιμοποιήσετε έναν από τους παρακάτω τρόπους:" -#: library/functions.rst:847 +#: library/functions.rst:923 msgid "" "See also :func:`int` for converting a hexadecimal string to an integer using " "a base of 16." @@ -1721,15 +1835,15 @@ msgstr "" "Δείτε επίσης τη :func:`int` για τη μετατροπή μιας δεκαεξαδικής συμβολοσειράς " "σε ακέραιο χρησιμοποιώντας μια βάση του 16." -#: library/functions.rst:852 +#: library/functions.rst:928 msgid "" -"To obtain a hexadecimal string representation for a float, use the :meth:" -"`float.hex` method." +"To obtain a hexadecimal string representation for a float, use " +"the :meth:`float.hex` method." msgstr "" "Για να αποκτήσετε μια αναπαράσταση δεκαεξαδικής συμβολοσειράς για ένα float, " "χρησιμοποιήστε τη μέθοδο :meth:`float.hex`." -#: library/functions.rst:858 +#: library/functions.rst:934 msgid "" "Return the \"identity\" of an object. This is an integer which is " "guaranteed to be unique and constant for this object during its lifetime. " @@ -1741,11 +1855,11 @@ msgstr "" "αντικείμενο κατά τη διάρκεια της ζωής του. Δύο αντικείμενα με μη " "επικαλυπτόμενες διάρκειες ζωής μπορεί να έχουν την ίδια τιμή :func:`id`." -#: library/functions.rst:863 +#: library/functions.rst:939 msgid "This is the address of the object in memory." msgstr "Αυτό είναι η διεύθυνση του αντικειμένου στην μνήμη." -#: library/functions.rst:865 +#: library/functions.rst:941 msgid "" "Raises an :ref:`auditing event ` ``builtins.id`` with argument " "``id``." @@ -1753,7 +1867,7 @@ msgstr "" "Εγείρει ένα :ref:`auditing event ` ``builtins.id`` με όρισμα " "``id``." -#: library/functions.rst:871 +#: library/functions.rst:947 msgid "" "If the *prompt* argument is present, it is written to standard output " "without a trailing newline. The function then reads a line from input, " @@ -1763,10 +1877,18 @@ msgstr "" "Εάν υπάρχει το όρισμα *prompt*, γράφεται στην τυπική έξοδο χωρίς μια νέα " "γραμμή μετάδοσης. Στη συνέχεια, η συνάρτηση διαβάζει μια γραμμή από την " "είσοδο, τη μετατρέπει σε μια συμβολοσειρά (με την αφαίρεση μιας νέας " -"γραμμής) και την επιστρέφει. Όταν διαβάζεται το EOF, γίνεται raise η :exc:" -"`EOFError`. Παράδειγμα::" +"γραμμής) και την επιστρέφει. Όταν διαβάζεται το EOF, γίνεται raise " +"η :exc:`EOFError`. Παράδειγμα::" -#: library/functions.rst:881 +#: library/functions.rst:952 +msgid "" +">>> s = input('--> ') \n" +"--> Monty Python's Flying Circus\n" +">>> s \n" +"\"Monty Python's Flying Circus\"" +msgstr "" + +#: library/functions.rst:957 msgid "" "If the :mod:`readline` module was loaded, then :func:`input` will use it to " "provide elaborate line editing and history features." @@ -1775,15 +1897,7 @@ msgstr "" "χρησιμοποιήσει για να παρέχει περίπλοκες λειτουργίες επεξεργασίας γραμμής " "και ιστορικού." -#: library/functions.rst:884 -msgid "" -"Raises an :ref:`auditing event ` ``builtins.input`` with argument " -"``prompt``." -msgstr "" -"Κάνει raise ένα :ref:`auditing event ` ``builtins.input`` με " -"όρισμα ``prompt``." - -#: library/functions.rst:886 +#: library/functions.rst:962 msgid "" "Raises an :ref:`auditing event ` ``builtins.input`` with argument " "``prompt`` before reading input" @@ -1791,30 +1905,47 @@ msgstr "" "Κάνει raise ένα :ref:`auditing event ` ``builtins.input`` με " "όρισμα ``prompt`` προτού διαβάσει την είσοδο" -#: library/functions.rst:889 +#: library/functions.rst:967 msgid "" "Raises an :ref:`auditing event ` ``builtins.input/result`` with " -"argument ``result``." +"the result after successfully reading input." msgstr "" "Κάνει raise ένα :ref:`auditing event ` ``builtins.input/result`` " -"με όρισμα ``result``." +"με το αποτέλεσμα μετά την επιτυχή ανάγνωση των δεδομένων." -#: library/functions.rst:891 +#: library/functions.rst:974 +#, fuzzy msgid "" -"Raises an :ref:`auditing event ` ``builtins.input/result`` with " -"the result after successfully reading input." +"Return an integer object constructed from a number or a string, or return " +"``0`` if no arguments are given." msgstr "" -"Κάνει raise ένα :ref:`auditing event ` ``builtins.input/result`` " -"με το αποτέλεσμα μετά την επιτυχή ανάγνωση των δεδομένων." +"Επιστέφει έναν αριθμό κινητής υποδιαστολής που κατασκευάστηκε από έναν " +"αριθμό ή μια συμβολοσειρά *x*." -#: library/functions.rst:898 +#: library/functions.rst:979 msgid "" -"Return an integer object constructed from a number or string *x*, or return " -"``0`` if no arguments are given. If *x* defines :meth:`~object.__int__`, " -"``int(x)`` returns ``x.__int__()``. If *x* defines :meth:`~object." -"__index__`, it returns ``x.__index__()``. If *x* defines :meth:`~object." -"__trunc__`, it returns ``x.__trunc__()``. For floating point numbers, this " -"truncates towards zero." +">>> int(123.45)\n" +"123\n" +">>> int('123')\n" +"123\n" +">>> int(' -12_345\\n')\n" +"-12345\n" +">>> int('FACE', 16)\n" +"64206\n" +">>> int('0xface', 0)\n" +"64206\n" +">>> int('01110011', base=2)\n" +"115" +msgstr "" + +#: library/functions.rst:994 +#, fuzzy +msgid "" +"If the argument defines :meth:`~object.__int__`, ``int(x)`` returns " +"``x.__int__()``. If the argument defines :meth:`~object.__index__`, it " +"returns ``x.__index__()``. If the argument " +"defines :meth:`~object.__trunc__`, it returns ``x.__trunc__()``. For " +"floating-point numbers, this truncates towards zero." msgstr "" "Επιστρέφει ένα ακέραιο αντικείμενο που έχει δημιουργηθεί από έναν αριθμό ή " "συμβολοσειρά *x*, ή επιστρέφει ``0`` εάν δεν δίνονται ορίσματα. Εάν το *x* " @@ -1823,13 +1954,14 @@ msgstr "" "*x* ορίζει :meth:`~object.__trunc__`, επιστρέφει``x.__trunc__()``. Για " "αριθμούς κινητής υποδιαστολής, αυτό περικόπτεται προς το μηδέν." -#: library/functions.rst:905 +#: library/functions.rst:1000 +#, fuzzy msgid "" -"If *x* is not a number or if *base* is given, then *x* must be a string, :" -"class:`bytes`, or :class:`bytearray` instance representing an integer in " -"radix *base*. Optionally, the string can be preceded by ``+`` or ``-`` " -"(with no space in between), have leading zeros, be surrounded by whitespace, " -"and have single underscores interspersed between digits." +"If the argument is not a number or if *base* is given, then it must be a " +"string, :class:`bytes`, or :class:`bytearray` instance representing an " +"integer in radix *base*. Optionally, the string can be preceded by ``+`` or " +"``-`` (with no space in between), have leading zeros, be surrounded by " +"whitespace, and have single underscores interspersed between digits." msgstr "" "Εάν το *x* δεν είναι ένα αριθμός ή εάν το *base* δίνεται, τότε το *x* πρέπει " "να είναι μια συμβολοσειρά, η :class:`bytes`, ή :class:`bytearray` instances " @@ -1838,7 +1970,7 @@ msgstr "" "προηγούνται από δυναμικά, περιβάλλονται από κενό διάστημα και έχουν μονές " "κάτω παύλες μεταξύ των ψηφίων." -#: library/functions.rst:911 +#: library/functions.rst:1006 msgid "" "A base-n integer string contains digits, each representing a value from 0 to " "n-1. The values 0--9 can be represented by any Unicode decimal digit. The " @@ -1864,24 +1996,28 @@ msgstr "" "βάση 0 δεν επιτρέπει επίσης τα μηδενικά στην αρχή : ``int('010', 0)`` δεν " "είναι εφικτό, ενώ το ``int('010')`` και ``int('010', 8)`` είναι." -#: library/functions.rst:922 +#: library/functions.rst:1017 msgid "The integer type is described in :ref:`typesnumeric`." msgstr "Ο ακέραιος τύπος περιγράφεται στο :ref:`typesnumeric`." -#: library/functions.rst:924 +#: library/functions.rst:1019 msgid "" -"If *base* is not an instance of :class:`int` and the *base* object has a :" -"meth:`base.__index__ ` method, that method is called to " +"If *base* is not an instance of :class:`int` and the *base* object has " +"a :meth:`base.__index__ ` method, that method is called to " "obtain an integer for the base. Previous versions used :meth:`base.__int__ " "` instead of :meth:`base.__index__ `." msgstr "" "Εάν το *base* δεν είναι ένα instance της :class:`int` και το *base* " "αντικείμενο έχει μια μέθοδο :meth:`base.__index__ `, αυτή " "η μέθοδος καλείται για να αποκτήσει τον ακέραιο της βάσης. Προηγούμενες " -"εκδόσεις χρησιμοποιούσαν την :meth:`base.__int__ ` αντί της :" -"meth:`base.__index__ `." +"εκδόσεις χρησιμοποιούσαν την :meth:`base.__int__ ` αντί " +"της :meth:`base.__index__ `." + +#: library/functions.rst:1029 +msgid "The first parameter is now positional-only." +msgstr "" -#: library/functions.rst:937 +#: library/functions.rst:1032 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not " "defined." @@ -1889,28 +2025,29 @@ msgstr "" "Επιστρέφει πίσω στη :meth:`~object.__index__` αν η :meth:`~object.__int__` " "δεν έχει οριστεί." -#: library/functions.rst:940 +#: library/functions.rst:1035 msgid "The delegation to :meth:`~object.__trunc__` is deprecated." msgstr "Η ανάθεση στη :meth:`~object.__trunc__` έχει καταργηθεί." -#: library/functions.rst:943 +#: library/functions.rst:1038 +#, fuzzy msgid "" ":class:`int` string inputs and string representations can be limited to help " "avoid denial of service attacks. A :exc:`ValueError` is raised when the " -"limit is exceeded while converting a string *x* to an :class:`int` or when " -"converting an :class:`int` into a string would exceed the limit. See the :" -"ref:`integer string conversion length limitation ` " +"limit is exceeded while converting a string to an :class:`int` or when " +"converting an :class:`int` into a string would exceed the limit. See " +"the :ref:`integer string conversion length limitation ` " "documentation." msgstr "" "Οι είσοδοι συμβολοσειράς και οι αναπαραστάσεις συμβολοσειρών :class:`int` " -"μπορούν να περιοριστούν για να αποφευχθούν επιθέσεις άρνησης υπηρεσίας. Μια :" -"exc:`ValueError` γίνεται raise όταν γίνεται υπέρβαση του ορίου κατά τη " +"μπορούν να περιοριστούν για να αποφευχθούν επιθέσεις άρνησης υπηρεσίας. " +"Μια :exc:`ValueError` γίνεται raise όταν γίνεται υπέρβαση του ορίου κατά τη " "μετατροπή μιας συμβολοσειράς *x* σε μια :class:`int` ή κατά τη μετατροπή " "ενός :class:`int` σε μια συμβολοσειρά θα υπερβεί το όριο. Δείτε την " "τεκμηρίωση :ref:`integer string conversion length limitation " "`." -#: library/functions.rst:953 +#: library/functions.rst:1048 msgid "" "Return ``True`` if the *object* argument is an instance of the *classinfo* " "argument, or of a (direct, indirect, or :term:`virtual `) of *classinfo*. A class is considered a " -"subclass of itself. *classinfo* may be a tuple of class objects (or " -"recursively, other such tuples) or a :ref:`types-union`, in which case " +"Return ``True`` if *class* is a subclass (direct, indirect, " +"or :term:`virtual `) of *classinfo*. A class is " +"considered a subclass of itself. *classinfo* may be a tuple of class objects " +"(or recursively, other such tuples) or a :ref:`types-union`, in which case " "return ``True`` if *class* is a subclass of any entry in *classinfo*. In " "any other case, a :exc:`TypeError` exception is raised." msgstr "" -"Επιστρέφει ``True`` εάν η *class* είναι μια υποκλάση (άμεση, έμμεση, ή :term:" -"`virtual `) του *classinfo*. Μια κλάση θεωρείται " -"υποκλάση του εαυτού της. Το *classinfo* μπορεί να είναι μια πλειάδα (tuple) " -"αντικειμένων κλάσης (ή αναδρομικά, άλλες τέτοιες πλειάδες) ή μια :ref:`types-" -"union`, οπότε επιστρέφετε ``True`` εάν η *class* είναι υποκλάση οποιασδήποτε " -"καταχώρισης στο *classinfo*. Σε οποιαδήποτε άλλη περίπτωση, γίνεται raise " -"μια εξαίρεση :exc:`TypeError`." +"Επιστρέφει ``True`` εάν η *class* είναι μια υποκλάση (άμεση, έμμεση, " +"ή :term:`virtual `) του *classinfo*. Μια κλάση " +"θεωρείται υποκλάση του εαυτού της. Το *classinfo* μπορεί να είναι μια " +"πλειάδα (tuple) αντικειμένων κλάσης (ή αναδρομικά, άλλες τέτοιες πλειάδες) ή " +"μια :ref:`types-union`, οπότε επιστρέφετε ``True`` εάν η *class* είναι " +"υποκλάση οποιασδήποτε καταχώρισης στο *classinfo*. Σε οποιαδήποτε άλλη " +"περίπτωση, γίνεται raise μια εξαίρεση :exc:`TypeError`." -#: library/functions.rst:985 +#: library/functions.rst:1080 msgid "" "Return an :term:`iterator` object. The first argument is interpreted very " "differently depending on the presence of the second argument. Without a " -"second argument, *object* must be a collection object which supports the :" -"term:`iterable` protocol (the :meth:`~object.__iter__` method), or it must " -"support the sequence protocol (the :meth:`~object.__getitem__` method with " -"integer arguments starting at ``0``). If it does not support either of " +"second argument, *object* must be a collection object which supports " +"the :term:`iterable` protocol (the :meth:`~object.__iter__` method), or it " +"must support the sequence protocol (the :meth:`~object.__getitem__` method " +"with integer arguments starting at ``0``). If it does not support either of " "those protocols, :exc:`TypeError` is raised. If the second argument, " "*sentinel*, is given, then *object* must be a callable object. The iterator " "created in this case will call *object* with no arguments for each call to " @@ -1973,22 +2110,22 @@ msgstr "" "Επιστρέφετε ένα αντικείμενο :term:`iterator`. Το πρώτο όρισμα ερμηνεύεται " "πολύ διαφορετικά ανάλογα με την παρουσία του δεύτερου ορίσματος. Χωρίς " "δεύτερο όρισμα, το *object* πρέπει να είναι ένα αντικείμενο συλλογής που να " -"υποστηρίζει το πρωτόκολλο :term:`iterable` (η μέθοδος :meth:`~object." -"__iter__`), ή πρέπει να υποστηρίζει το πρωτόκολλο ακολουθίας (η μέθοδος :" -"meth:`~object.__getitem__` με ακέραια ορίσματα που ξεκινούν από ``0``). Εάν " -"δεν υποστηρίζει κανένα από αυτά τα πρωτόκολλα, γίνεται raise μια :exc:" -"`TypeError`. Εάν δοθεί το δεύτερο όρισμα *sentinel*, τότε το *object* πρέπει " -"να είναι ένα callable αντικείμενο. Ο iterator που δημιουργήθηκε σε αυτή την " -"περίπτωση θα καλέσει το *object* χωρίς ορίσματα για κάθε κλήση στη μέθοδο :" -"meth:`~iterator.__next__`∙ εάν η τιμή που επιστρέφετια είναι ίση με " -"*sentinel*, θα γίνει raise η :exc:`StopIteration`, διαφορετικά θα επιστραφεί " -"η τιμή." - -#: library/functions.rst:999 +"υποστηρίζει το πρωτόκολλο :term:`iterable` (η " +"μέθοδος :meth:`~object.__iter__`), ή πρέπει να υποστηρίζει το πρωτόκολλο " +"ακολουθίας (η μέθοδος :meth:`~object.__getitem__` με ακέραια ορίσματα που " +"ξεκινούν από ``0``). Εάν δεν υποστηρίζει κανένα από αυτά τα πρωτόκολλα, " +"γίνεται raise μια :exc:`TypeError`. Εάν δοθεί το δεύτερο όρισμα *sentinel*, " +"τότε το *object* πρέπει να είναι ένα callable αντικείμενο. Ο iterator που " +"δημιουργήθηκε σε αυτή την περίπτωση θα καλέσει το *object* χωρίς ορίσματα " +"για κάθε κλήση στη μέθοδο :meth:`~iterator.__next__`∙ εάν η τιμή που " +"επιστρέφετια είναι ίση με *sentinel*, θα γίνει raise η :exc:`StopIteration`, " +"διαφορετικά θα επιστραφεί η τιμή." + +#: library/functions.rst:1094 msgid "See also :ref:`typeiter`." msgstr "Δείτε επίσης :ref:`typeiter`." -#: library/functions.rst:1001 +#: library/functions.rst:1096 msgid "" "One useful application of the second form of :func:`iter` is to build a " "block-reader. For example, reading fixed-width blocks from a binary database " @@ -1998,7 +2135,15 @@ msgstr "" "ενός block-reader. Για παράδειγμα, η ανάγνωση μπλοκ σταθερού πλάτους από ένα " "δυαδικό αρχείο βάσης δεδομένων μέχρι να φτάσει στο τέλος του αρχείου::" -#: library/functions.rst:1013 +#: library/functions.rst:1100 +msgid "" +"from functools import partial\n" +"with open('mydata.db', 'rb') as f:\n" +" for block in iter(partial(f.read, 64), b''):\n" +" process_block(block)" +msgstr "" + +#: library/functions.rst:1108 msgid "" "Return the length (the number of items) of an object. The argument may be a " "sequence (such as a string, bytes, tuple, list, or range) or a collection " @@ -2009,15 +2154,15 @@ msgstr "" "πλειάδα, λίστα, ή εύρος) ή μια συλλογή (όπως ένα λεξικό, ένα σετ, ή ένα " "παγωμένο σετ)." -#: library/functions.rst:1019 +#: library/functions.rst:1114 msgid "" -"``len`` raises :exc:`OverflowError` on lengths larger than :data:`sys." -"maxsize`, such as :class:`range(2 ** 100) `." +"``len`` raises :exc:`OverflowError` on lengths larger " +"than :data:`sys.maxsize`, such as :class:`range(2 ** 100) `." msgstr "" "Το ``len`` κάνει raise μια :exc:`OverflowError` σε μήκη τα οποία είναι " "μεγαλύτερα από :data:`sys.maxsize`, όπως :class:`range(2 ** 100) `." -#: library/functions.rst:1028 +#: library/functions.rst:1123 msgid "" "Rather than being a function, :class:`list` is actually a mutable sequence " "type, as documented in :ref:`typesseq-list` and :ref:`typesseq`." @@ -2026,12 +2171,12 @@ msgstr "" "μεταβλητός τύπος ακολουθίας, όπως τεκμηριώνεται στα :ref:`typesseq-list` " "και :ref:`typesseq`." -#: library/functions.rst:1034 +#: library/functions.rst:1129 msgid "" "Update and return a dictionary representing the current local symbol table. " "Free variables are returned by :func:`locals` when it is called in function " -"blocks, but not in class blocks. Note that at the module level, :func:" -"`locals` and :func:`globals` are the same dictionary." +"blocks, but not in class blocks. Note that at the module " +"level, :func:`locals` and :func:`globals` are the same dictionary." msgstr "" "Ενημέρωση και επιστροφή ενός λεξικού που αντιπροσωπεύει τον τρέχοντα πίνακα " "τοπικών συμβόλων. Οι ελεύθερες μεταβλητές επιστρέφονται από :func:`locals` " @@ -2039,7 +2184,7 @@ msgstr "" "σε επίπεδο module, οι :func:`locals` και :func:`globals` είναι το ίδιο " "λεξικό." -#: library/functions.rst:1040 +#: library/functions.rst:1135 msgid "" "The contents of this dictionary should not be modified; changes may not " "affect the values of local and free variables used by the interpreter." @@ -2048,7 +2193,7 @@ msgstr "" "ενδέχεται να μην επηρεάσουν τις τιμές των τοπικών και ελεύθερων μεταβλητών " "που χρησιμοποιούνται από τον διερμηνέα." -#: library/functions.rst:1045 +#: library/functions.rst:1140 msgid "" "Return an iterator that applies *function* to every item of *iterable*, " "yielding the results. If additional *iterables* arguments are passed, " @@ -2065,7 +2210,7 @@ msgstr "" "όπου οι είσοδοι συνάρτησης είναι ήδη διατεταγμένες σε πλειάδες ορισμάτων, " "βλέπε :func:`itertools.starmap`\\." -#: library/functions.rst:1057 +#: library/functions.rst:1152 msgid "" "Return the largest item in an iterable or the largest of two or more " "arguments." @@ -2073,7 +2218,7 @@ msgstr "" "Επιστρέφει το μεγαλύτερο στοιχείο σε ένα iterable ή το μεγαλύτερο από δύο ή " "περισσότερα ορίσματα." -#: library/functions.rst:1060 +#: library/functions.rst:1155 msgid "" "If one positional argument is provided, it should be an :term:`iterable`. " "The largest item in the iterable is returned. If two or more positional " @@ -2083,51 +2228,51 @@ msgstr "" "Επιστρέφεται το μεγαλύτερο στοιχείο στο iterable. Εάν παρέχονται δύο ή " "περισσότερα ορίσματα θέσης, επιστρέφεται το μεγαλύτερο από τα ορίσματα θέσης." -#: library/functions.rst:1103 +#: library/functions.rst:1198 msgid "" "There are two optional keyword-only arguments. The *key* argument specifies " "a one-argument ordering function like that used for :meth:`list.sort`. The " "*default* argument specifies an object to return if the provided iterable is " -"empty. If the iterable is empty and *default* is not provided, a :exc:" -"`ValueError` is raised." +"empty. If the iterable is empty and *default* is not provided, " +"a :exc:`ValueError` is raised." msgstr "" "Υπάρχουν δύο προαιρετικά ορίσματα τύπου λέξη-κλειδί. Το όρισμα *key* " "καθορίζει μια συνάρτηση ταξινόμησης ενός ορίσματος όπως αυτή χρησιμοποιείται " "για το :meth:`list.sort`. Το όρισμα *default* καθορίζει ένα αντικείμενο που " "θα επιστρέψει εάν το iterable που παρέχεται είναι κενό. Εάν το iterable " -"είναι κενό και το *default* δεν παρέχεται, γίνεται raise μια :exc:" -"`ValueError`." +"είναι κενό και το *default* δεν παρέχεται, γίνεται raise " +"μια :exc:`ValueError`." -#: library/functions.rst:1071 +#: library/functions.rst:1166 msgid "" "If multiple items are maximal, the function returns the first one " "encountered. This is consistent with other sort-stability preserving tools " -"such as ``sorted(iterable, key=keyfunc, reverse=True)[0]`` and ``heapq." -"nlargest(1, iterable, key=keyfunc)``." +"such as ``sorted(iterable, key=keyfunc, reverse=True)[0]`` and " +"``heapq.nlargest(1, iterable, key=keyfunc)``." msgstr "" "Εάν πολλά στοιχεία είναι μέγιστα, η συνάρτηση επιστρέφει το πρώτο που " "συναντήθηκε. Αυτό είναι σύμφωνο με άλλα εργαλεία διατήρησης σταθερότητας " "ταξινόμησης όπως ``sorted(iterable, key=keyfunc, reverse=True)[0]`` και " "``heapq.nlargest(1, iterable, key=keyfunc)``." -#: library/functions.rst:1114 +#: library/functions.rst:1209 msgid "Added the *default* keyword-only parameter." msgstr "Προστέθηκε η παράμετρος μόνο λέξης-κλειδί *default*." -#: library/functions.rst:1117 +#: library/functions.rst:1212 msgid "The *key* can be ``None``." msgstr "Το *key* μπορεί να είναι ``None``." -#: library/functions.rst:1087 +#: library/functions.rst:1182 msgid "" -"Return a \"memory view\" object created from the given argument. See :ref:" -"`typememoryview` for more information." +"Return a \"memory view\" object created from the given argument. " +"See :ref:`typememoryview` for more information." msgstr "" "Επιστρέφει ένα αντικείμενο \"memory view\" που δημιουργήθηκε από το " "συγκεκριμένο όρισμα. Βλέπε :ref:`typememoryview` για περισσότερες " "λεπτομέρειες." -#: library/functions.rst:1095 +#: library/functions.rst:1190 msgid "" "Return the smallest item in an iterable or the smallest of two or more " "arguments." @@ -2135,7 +2280,7 @@ msgstr "" "Επιστρέφει το μικρότερο στοιχείο σε έναν iterable ή το μικρότερο από δύο ή " "περισσότερα ορίσματα." -#: library/functions.rst:1098 +#: library/functions.rst:1193 msgid "" "If one positional argument is provided, it should be an :term:`iterable`. " "The smallest item in the iterable is returned. If two or more positional " @@ -2145,7 +2290,7 @@ msgstr "" "Επιστρέφει το μικρότερο στοιχείο στον iterable. Εάν παρέχονται δύο ή " "περισσότερα ορίσματα θέσης, επιστρέφεται το μικρότερο από τα ορίσματα θέσης." -#: library/functions.rst:1109 +#: library/functions.rst:1204 msgid "" "If multiple items are minimal, the function returns the first one " "encountered. This is consistent with other sort-stability preserving tools " @@ -2154,39 +2299,43 @@ msgid "" msgstr "" "Εάν πολλά στοιχεία είναι ελάχιστα, η συνάρτηση επιστρέφει το πρώτο που " "συναντήθηκε. Αυτό είναι σύμφωνο με άλλα εργαλεία διατήρησης σταθερότητας " -"ταξινόμησης, όπως ``sorted(iterable, key=keyfunc)[0]`` και ``heapq." -"nsmallest(1, iterable, key=keyfunc)``." +"ταξινόμησης, όπως ``sorted(iterable, key=keyfunc)[0]`` και " +"``heapq.nsmallest(1, iterable, key=keyfunc)``." -#: library/functions.rst:1124 +#: library/functions.rst:1219 msgid "" -"Retrieve the next item from the :term:`iterator` by calling its :meth:" -"`~iterator.__next__` method. If *default* is given, it is returned if the " -"iterator is exhausted, otherwise :exc:`StopIteration` is raised." +"Retrieve the next item from the :term:`iterator` by calling " +"its :meth:`~iterator.__next__` method. If *default* is given, it is " +"returned if the iterator is exhausted, otherwise :exc:`StopIteration` is " +"raised." msgstr "" -"Ανάκτηση του επόμενου στοιχείο από το :term:`iterator` καλώντας τη μέθοδο :" -"meth:`~iterator.__next__`. Εάν δοθεί *default*, επιστρέφεται εάν ο iterator " -"έχει εξαντληθεί, διαφορετικά γίνεται raise μια :exc:`StopIteration`." +"Ανάκτηση του επόμενου στοιχείο από το :term:`iterator` καλώντας τη " +"μέθοδο :meth:`~iterator.__next__`. Εάν δοθεί *default*, επιστρέφεται εάν ο " +"iterator έχει εξαντληθεί, διαφορετικά γίνεται raise μια :exc:`StopIteration`." -#: library/functions.rst:1131 +#: library/functions.rst:1226 +#, fuzzy msgid "" -"Return a new featureless object. :class:`object` is a base for all classes. " -"It has methods that are common to all instances of Python classes. This " -"function does not accept any arguments." +"This is the ultimate base class of all other classes. It has methods that " +"are common to all instances of Python classes. When the constructor is " +"called, it returns a new featureless object. The constructor does not accept " +"any arguments." msgstr "" "Επιστρέφει ένα νέο αντικείμενο χωρίς χαρακτηριστικά. Το :class:`object` " "είναι μια βάση για όλες τις κλάσεις. Έχει μεθόδους που είναι κοινές σε όλες " "τις περιπτώσεις κλάσεων Python. Αυτή η συνάρτηση δεν δέχεται ορίσματα." -#: library/functions.rst:1137 +#: library/functions.rst:1233 +#, fuzzy msgid "" -":class:`object` does *not* have a :attr:`~object.__dict__`, so you can't " -"assign arbitrary attributes to an instance of the :class:`object` class." +":class:`object` instances do *not* have :attr:`~object.__dict__` attributes, " +"so you can't assign arbitrary attributes to an instance of :class:`object`." msgstr "" "Το :class:`object` *δεν* έχει :attr:`~object.__dict__` επομένως δεν μπορείτε " -"να εκχωρήσετε αυθαίρετα χαρακτηριστικά σε ένα instance της κλάσης :class:" -"`object`." +"να εκχωρήσετε αυθαίρετα χαρακτηριστικά σε ένα instance της " +"κλάσης :class:`object`." -#: library/functions.rst:1143 +#: library/functions.rst:1240 msgid "" "Convert an integer number to an octal string prefixed with \"0o\". The " "result is a valid Python expression. If *x* is not a Python :class:`int` " @@ -2195,10 +2344,11 @@ msgid "" msgstr "" "Μετατρέπει έναν ακέραιο αριθμό σε μια οκταδική συμβολοσειρά με πρόθεμα " "\"0o\". Το αποτέλεσμα είναι μια έγκυρη έκφραση Python. Εάν το *x* δεν είναι " -"ένα αντικείμενο Python :class:`int`, πρέπει να ορίσει μια μέθοδο :meth:" -"`~object.__index__` που επιστρέφει έναν ακέραιο αριθμό. Για παράδειγμα:" +"ένα αντικείμενο Python :class:`int`, πρέπει να ορίσει μια " +"μέθοδο :meth:`~object.__index__` που επιστρέφει έναν ακέραιο αριθμό. Για " +"παράδειγμα:" -#: library/functions.rst:1153 +#: library/functions.rst:1250 msgid "" "If you want to convert an integer number to an octal string either with the " "prefix \"0o\" or not, you can use either of the following ways." @@ -2207,17 +2357,17 @@ msgstr "" "με το πρόθεμα \"0o\" είτε όχι, μπορείτε να χρησιμοποιήσετε έναν από τους " "παρακάτω τρόπους." -#: library/functions.rst:1170 +#: library/functions.rst:1267 msgid "" "Open *file* and return a corresponding :term:`file object`. If the file " "cannot be opened, an :exc:`OSError` is raised. See :ref:`tut-files` for more " "examples of how to use this function." msgstr "" "Ανοίγει το *file* και επιστρέφει ένα αντίστοιχο :term:`file object`. Εάν το " -"αρχείο δεν μπορεί να ανοίξει, γίνεται raise μια :exc:`OSError`. Δείτε το :" -"ref:`tut-files` για περισσότερα παραδείγματα χρήσης αυτής της συνάρτησης." +"αρχείο δεν μπορεί να ανοίξει, γίνεται raise μια :exc:`OSError`. Δείτε " +"το :ref:`tut-files` για περισσότερα παραδείγματα χρήσης αυτής της συνάρτησης." -#: library/functions.rst:1174 +#: library/functions.rst:1271 msgid "" "*file* is a :term:`path-like object` giving the pathname (absolute or " "relative to the current working directory) of the file to be opened or an " @@ -2232,7 +2382,8 @@ msgstr "" "επιστρεφόμενο αντικείμενο I/O είναι κλειστό εκτός εάν *closefd* έχει οριστεί " "ως ``False``.)" -#: library/functions.rst:1180 +#: library/functions.rst:1277 +#, fuzzy msgid "" "*mode* is an optional string that specifies the mode in which the file is " "opened. It defaults to ``'r'`` which means open for reading in text mode. " @@ -2240,10 +2391,10 @@ msgid "" "already exists), ``'x'`` for exclusive creation, and ``'a'`` for appending " "(which on *some* Unix systems, means that *all* writes append to the end of " "the file regardless of the current seek position). In text mode, if " -"*encoding* is not specified the encoding used is platform-dependent: :func:" -"`locale.getencoding()` is called to get the current locale encoding. (For " -"reading and writing raw bytes use binary mode and leave *encoding* " -"unspecified.) The available modes are:" +"*encoding* is not specified the encoding used is platform-" +"dependent: :func:`locale.getencoding` is called to get the current locale " +"encoding. (For reading and writing raw bytes use binary mode and leave " +"*encoding* unspecified.) The available modes are:" msgstr "" "Το *mode* είναι μια προαιρετική συμβολοσειρά που καθορίζει τη λειτουργία " "στην οποία ανοίγει το αρχείο. Από προεπιλογή είναι ``'r'`` που σημαίνει " @@ -2259,72 +2410,72 @@ msgstr "" "λειτουργία και αφήνουν το *encoding* απροσδιόριστο.) Οι διαθέσιμες " "λειτουργίες είναι:" -#: library/functions.rst:1197 +#: library/functions.rst:1294 msgid "Character" msgstr "Χαρακτήρας" -#: library/functions.rst:1197 +#: library/functions.rst:1294 msgid "Meaning" msgstr "Έννοια" -#: library/functions.rst:1199 +#: library/functions.rst:1296 msgid "``'r'``" msgstr "``'r'``" -#: library/functions.rst:1199 +#: library/functions.rst:1296 msgid "open for reading (default)" msgstr "άνοιγμα για ανάγνωση (default)" -#: library/functions.rst:1200 +#: library/functions.rst:1297 msgid "``'w'``" msgstr "``'w'``" -#: library/functions.rst:1200 +#: library/functions.rst:1297 msgid "open for writing, truncating the file first" msgstr "άνοιγμα για εγγραφή, περικόπτοντας πρώτα το αρχείο" -#: library/functions.rst:1201 +#: library/functions.rst:1298 msgid "``'x'``" msgstr "``'x'``" -#: library/functions.rst:1201 +#: library/functions.rst:1298 msgid "open for exclusive creation, failing if the file already exists" msgstr "" "άνοιγμα για αποκλειστική δημιουργία, αποτυγχάνοντας εάν το αρχείο υπάρχει ήδη" -#: library/functions.rst:1202 +#: library/functions.rst:1299 msgid "``'a'``" msgstr "``'a'``" -#: library/functions.rst:1202 +#: library/functions.rst:1299 msgid "open for writing, appending to the end of file if it exists" msgstr "άνοιγμα για εγγραφή, προσαρτάται στο τέλος του αρχείου εάν υπάρχει" -#: library/functions.rst:1203 +#: library/functions.rst:1300 msgid "``'b'``" msgstr "``'b'``" -#: library/functions.rst:1347 +#: library/functions.rst:1444 msgid "binary mode" msgstr "δυαδική (binary) λειτουργία" -#: library/functions.rst:1204 +#: library/functions.rst:1301 msgid "``'t'``" msgstr "``'t'``" -#: library/functions.rst:1204 +#: library/functions.rst:1301 msgid "text mode (default)" msgstr "λειτουργία κειμένου (default)" -#: library/functions.rst:1205 +#: library/functions.rst:1302 msgid "``'+'``" msgstr "``'+'``" -#: library/functions.rst:1205 +#: library/functions.rst:1302 msgid "open for updating (reading and writing)" msgstr "άνοιγμα για ενημέρωση (ανάγνωση και εγγραφή)" -#: library/functions.rst:1208 +#: library/functions.rst:1305 msgid "" "The default mode is ``'r'`` (open for reading text, a synonym of ``'rt'``). " "Modes ``'w+'`` and ``'w+b'`` open and truncate the file. Modes ``'r+'`` and " @@ -2335,7 +2486,7 @@ msgstr "" "περικόβει το αρχείο. Οι λειτουργίες ``'r+'`` and ``'r+b'`` ανοίγουν το " "αρχείο χωρίς περικοπή." -#: library/functions.rst:1212 +#: library/functions.rst:1309 msgid "" "As mentioned in the :ref:`io-overview`, Python distinguishes between binary " "and text I/O. Files opened in binary mode (including ``'b'`` in the *mode* " @@ -2354,7 +2505,7 @@ msgstr "" "bytes έχουν πρώτα αποκωδικοποιηθεί χρησιμοποιώντας μια εξαρτώμενη από " "πλατφόρμα κωδικοποίηση ή χρήση της καθορισμένης *κωδικοποίησης* εάν δίνεται." -#: library/functions.rst:1222 +#: library/functions.rst:1319 msgid "" "Python doesn't depend on the underlying operating system's notion of text " "files; all the processing is done by Python itself, and is therefore " @@ -2364,7 +2515,7 @@ msgstr "" "λειτουργικού συστήματος∙ όλη η επεξεργασία γίνεται από την ίδια την Python " "και επομένως είναι ανεξάρτητη από την πλατφόρμα." -#: library/functions.rst:1226 +#: library/functions.rst:1323 msgid "" "*buffering* is an optional integer used to set the buffering policy. Pass 0 " "to switch buffering off (only allowed in binary mode), 1 to select line " @@ -2391,7 +2542,7 @@ msgstr "" "δίνεται όρισμα *buffering*, η προεπιλεγμένη πολιτική προσωρινής αποθήκευσης " "λειτουργεί ως εξής:" -#: library/functions.rst:1236 +#: library/functions.rst:1333 msgid "" "Binary files are buffered in fixed-size chunks; the size of the buffer is " "chosen using a heuristic trying to determine the underlying device's \"block " @@ -2404,18 +2555,18 @@ msgstr "" "και επανέρχεται σε :const:`io.DEFAULT_BUFFER_SIZE`. Σε πολλά συστήματα, η " "προσωρινή μνήμη θα έχει συνήθως μήκος 4096 ή 8192 bytes." -#: library/functions.rst:1241 +#: library/functions.rst:1338 msgid "" "\"Interactive\" text files (files for which :meth:`~io.IOBase.isatty` " "returns ``True``) use line buffering. Other text files use the policy " "described above for binary files." msgstr "" -"\"Interactive\" αρχεία κειμένου (αρχεία για τα οποία το :meth:`~io.IOBase." -"isatty` επιστρέφει ``True``) χρησιμοποιούν αποθήκευση γραμμής. Άλλα αρχεία " -"κειμένου χρησιμοποιούν την πολιτική που περιγράφεται παραπάνω για δυαδικά " -"αρχεία." +"\"Interactive\" αρχεία κειμένου (αρχεία για τα οποία " +"το :meth:`~io.IOBase.isatty` επιστρέφει ``True``) χρησιμοποιούν αποθήκευση " +"γραμμής. Άλλα αρχεία κειμένου χρησιμοποιούν την πολιτική που περιγράφεται " +"παραπάνω για δυαδικά αρχεία." -#: library/functions.rst:1245 +#: library/functions.rst:1342 msgid "" "*encoding* is the name of the encoding used to decode or encode the file. " "This should only be used in text mode. The default encoding is platform " @@ -2430,13 +2581,14 @@ msgstr "" "οποιοδήποτε :term:`text encoding` που υποστηρίζεται από την Python. Δείτε το " "module :mod:`codecs` για τη λίστα των υποστηριζόμενων κωδικοποιήσεων." -#: library/functions.rst:1251 +#: library/functions.rst:1348 msgid "" "*errors* is an optional string that specifies how encoding and decoding " "errors are to be handled—this cannot be used in binary mode. A variety of " "standard error handlers are available (listed under :ref:`error-handlers`), " -"though any error handling name that has been registered with :func:`codecs." -"register_error` is also valid. The standard names include:" +"though any error handling name that has been registered " +"with :func:`codecs.register_error` is also valid. The standard names " +"include:" msgstr "" "Το *errors* είναι μια προαιρετική συμβολοσειρά που καθορίζει τον τρόπο " "χειρισμού των σφαλμάτων κωδικοποίησης και αποκωδικοποίησης-αυτό δεν μπορεί " @@ -2446,7 +2598,7 @@ msgstr "" "το :func:`codecs.register_error` είναι επίσης έγκυρο. Τα τυπικά ονόματα " "περιλαμβάνουν:" -#: library/functions.rst:1259 +#: library/functions.rst:1356 msgid "" "``'strict'`` to raise a :exc:`ValueError` exception if there is an encoding " "error. The default value of ``None`` has the same effect." @@ -2455,7 +2607,7 @@ msgstr "" "σφάλμα κωδικοποίησης. Η προεπιλεγμένη τιμή του ``None`` έχει το ίδιο " "αποτέλεσμα." -#: library/functions.rst:1263 +#: library/functions.rst:1360 msgid "" "``'ignore'`` ignores errors. Note that ignoring encoding errors can lead to " "data loss." @@ -2463,7 +2615,7 @@ msgstr "" "Το ``'ignore'`` αγνοεί τα σφάλματα. Σημειώστε ότι η παράβλεψη σφαλμάτων " "κωδικοποίησης μπορεί να οδηγήσει σε απώλεια δεδομένων." -#: library/functions.rst:1266 +#: library/functions.rst:1363 msgid "" "``'replace'`` causes a replacement marker (such as ``'?'``) to be inserted " "where there is malformed data." @@ -2471,7 +2623,7 @@ msgstr "" "Το ``'replace'`` προκαλεί την εισαγωγή ενός δείκτη αντικατάστασης (όπως " "``'?'``) όταν υπάρχουν δεδομένα με λανθασμένη μορφή." -#: library/functions.rst:1269 +#: library/functions.rst:1366 msgid "" "``'surrogateescape'`` will represent any incorrect bytes as low surrogate " "code units ranging from U+DC80 to U+DCFF. These surrogate code units will " @@ -2486,7 +2638,7 @@ msgstr "" "εγγραφή δεδομένων. Αυτό είναι χρήσιμο για την επεξεργασία αρχείων σε " "άγνωστη κωδικοποίηση." -#: library/functions.rst:1276 +#: library/functions.rst:1373 msgid "" "``'xmlcharrefreplace'`` is only supported when writing to a file. Characters " "not supported by the encoding are replaced with the appropriate XML " @@ -2496,7 +2648,7 @@ msgstr "" "χαρακτήρες που δεν υποστηρίζονται από την κωδικοποίηση αντικαθίστανται με " "την κατάλληλη αναφορά χαρακτήρων XML :samp:`&#{nnn};`." -#: library/functions.rst:1280 +#: library/functions.rst:1377 msgid "" "``'backslashreplace'`` replaces malformed data by Python's backslashed " "escape sequences." @@ -2504,7 +2656,7 @@ msgstr "" "Το ``'backslashreplace'`` αντικαθιστά δεδομένα με λανθασμένη μορφή από τις " "ακολουθίες διαφυγής με ανάστροφης καθέτου Python." -#: library/functions.rst:1283 +#: library/functions.rst:1380 msgid "" "``'namereplace'`` (also only supported when writing) replaces unsupported " "characters with ``\\N{...}`` escape sequences." @@ -2512,7 +2664,7 @@ msgstr "" "Το ``'namereplace'`` (υποστηρίζεται επίσης μόνο κατά τη σύνταξη) αντικαθιστά " "τους μη υποστηριζόμενους χαρακτήρες με ακολουθίες διαφυγής ``\\N{...}``." -#: library/functions.rst:1291 +#: library/functions.rst:1388 msgid "" "*newline* determines how to parse newline characters from the stream. It can " "be ``None``, ``''``, ``'\\n'``, ``'\\r'``, and ``'\\r\\n'``. It works as " @@ -2522,7 +2674,7 @@ msgstr "" "ροή. Μπορεί να είναι και ``None``, ``''``, ``'\\n'``, ``'\\r'``, και " "``'\\r\\n'``. Λειτουργεί ως εξής:" -#: library/functions.rst:1295 +#: library/functions.rst:1392 msgid "" "When reading input from the stream, if *newline* is ``None``, universal " "newlines mode is enabled. Lines in the input can end in ``'\\n'``, " @@ -2542,13 +2694,13 @@ msgstr "" "δεδομένη συμβολοσειρά και η κατάληξη γραμμής επιστρέφεται στον καλούντα " "αμετάφραστη." -#: library/functions.rst:1303 +#: library/functions.rst:1400 msgid "" "When writing output to the stream, if *newline* is ``None``, any ``'\\n'`` " -"characters written are translated to the system default line separator, :" -"data:`os.linesep`. If *newline* is ``''`` or ``'\\n'``, no translation " -"takes place. If *newline* is any of the other legal values, any ``'\\n'`` " -"characters written are translated to the given string." +"characters written are translated to the system default line " +"separator, :data:`os.linesep`. If *newline* is ``''`` or ``'\\n'``, no " +"translation takes place. If *newline* is any of the other legal values, any " +"``'\\n'`` characters written are translated to the given string." msgstr "" "Κατά την εγγραφή εξόδου στη ροή, εάν το *newline* είναι ``None``, τυχόν " "χαρακτήρες ``'\\n'`` μεταφράζονται στο διαχωριστικό προεπιλεγμένων γραμμών " @@ -2557,7 +2709,7 @@ msgstr "" "από τις άλλες νόμιμες τιμές, γράφονται οποιοιδήποτε χαρακτήρες ``'\\n'`` " "μεταφράζονται στη δεδομένη συμβολοσειρά." -#: library/functions.rst:1309 +#: library/functions.rst:1406 msgid "" "If *closefd* is ``False`` and a file descriptor rather than a filename was " "given, the underlying file descriptor will be kept open when the file is " @@ -2570,7 +2722,7 @@ msgstr "" "*closefd* πρέπει να είναι ``True`` (η προεπιλογή)∙ διαφορετικά, θα προκύψει " "ένα σφάλμα." -#: library/functions.rst:1314 +#: library/functions.rst:1411 msgid "" "A custom opener can be used by passing a callable as *opener*. The " "underlying file descriptor for the file object is then obtained by calling " @@ -2585,67 +2737,83 @@ msgstr "" "αρχείου (περνώντας :mod:`os.open` ως *opener* έχει ως αποτέλεσμα " "λειτουργικότητας παρόμοια με το να περάσουμε το ``None``)." -#: library/functions.rst:1320 +#: library/functions.rst:1417 msgid "The newly created file is :ref:`non-inheritable `." msgstr "" "Το νέο δημιουργημένο αρχείο είναι :ref:`non-inheritable `." -#: library/functions.rst:1322 +#: library/functions.rst:1419 msgid "" -"The following example uses the :ref:`dir_fd ` parameter of the :func:" -"`os.open` function to open a file relative to a given directory::" +"The following example uses the :ref:`dir_fd ` parameter of " +"the :func:`os.open` function to open a file relative to a given directory::" msgstr "" "Το παρακάτω παράδειγμα χρησιμοποιεί την παράμετρο :ref:`dir_fd ` της " "συνάρτησης :func:`os.open` για να ανοίξει ένα αρχείο σε σχέση με έναν " "δεδομένο κατάλογο::" -#: library/functions.rst:1335 +#: library/functions.rst:1422 +msgid "" +">>> import os\n" +">>> dir_fd = os.open('somedir', os.O_RDONLY)\n" +">>> def opener(path, flags):\n" +"... return os.open(path, flags, dir_fd=dir_fd)\n" +"...\n" +">>> with open('spamspam.txt', 'w', opener=opener) as f:\n" +"... print('This will be written to somedir/spamspam.txt', file=f)\n" +"...\n" +">>> os.close(dir_fd) # don't leak a file descriptor" +msgstr "" + +#: library/functions.rst:1432 msgid "" "The type of :term:`file object` returned by the :func:`open` function " "depends on the mode. When :func:`open` is used to open a file in a text " -"mode (``'w'``, ``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a subclass of :" -"class:`io.TextIOBase` (specifically :class:`io.TextIOWrapper`). When used " -"to open a file in a binary mode with buffering, the returned class is a " +"mode (``'w'``, ``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a subclass " +"of :class:`io.TextIOBase` (specifically :class:`io.TextIOWrapper`). When " +"used to open a file in a binary mode with buffering, the returned class is a " "subclass of :class:`io.BufferedIOBase`. The exact class varies: in read " "binary mode, it returns an :class:`io.BufferedReader`; in write binary and " "append binary modes, it returns an :class:`io.BufferedWriter`, and in read/" "write mode, it returns an :class:`io.BufferedRandom`. When buffering is " -"disabled, the raw stream, a subclass of :class:`io.RawIOBase`, :class:`io." -"FileIO`, is returned." -msgstr "" -"Ο τύπος του :term:`file object` που επιστρέφεται από τη συνάρτηση :func:" -"`open` εξαρτάται από τη λειτουργία. Όταν το :func:`open` χρησιμοποιείται " -"για το άνοιγμα ενός αρχείου σε λειτουργία κειμένου (``'w'``, ``'r'``, " -"``'wt'``, ``'rt'``, κ.λπ.), επιστρέφει μια υποκλάση του :class:`io." -"TextIOBase` (specifically :class:`io.TextIOWrapper`). Όταν χρησιμοποιείται " -"για το άνοιγμα ενός αρχείου σε δυαδική λειτουργία με προσωρινή αποθήκευση, η " -"κλάση που επιστρέφεται είναι μια υποκλάση του :class:`io.BufferedIOBase`. Η " -"ακριβής κλάση ποικίλλει: σε λειτουργία δυαδικής ανάγνωσης, επιστρέφει ένα :" -"class:`io.BufferedReader` ∙ σε δυαδικές καταστάσεις εγγραφής και δυαδικής " -"προσθήκης, επιστρέφει ένα :class:`io.BufferedWriter`, και στη λειτουργία " -"ανάγνωσης/εγγραφής, επιστρέφει ένα :class:`io.BufferedRandom`. Όταν η " -"προσωρινή αποθήκευση είναι απενεργοποιημένη, επιστρέφεται, η ακατέργαστη " -"ροή , μια υποκλάση :class:`io.RawIOBase`, :class:`io.FileIO`." +"disabled, the raw stream, a subclass " +"of :class:`io.RawIOBase`, :class:`io.FileIO`, is returned." +msgstr "" +"Ο τύπος του :term:`file object` που επιστρέφεται από τη " +"συνάρτηση :func:`open` εξαρτάται από τη λειτουργία. Όταν το :func:`open` " +"χρησιμοποιείται για το άνοιγμα ενός αρχείου σε λειτουργία κειμένου (``'w'``, " +"``'r'``, ``'wt'``, ``'rt'``, κ.λπ.), επιστρέφει μια υποκλάση " +"του :class:`io.TextIOBase` (specifically :class:`io.TextIOWrapper`). Όταν " +"χρησιμοποιείται για το άνοιγμα ενός αρχείου σε δυαδική λειτουργία με " +"προσωρινή αποθήκευση, η κλάση που επιστρέφεται είναι μια υποκλάση " +"του :class:`io.BufferedIOBase`. Η ακριβής κλάση ποικίλλει: σε λειτουργία " +"δυαδικής ανάγνωσης, επιστρέφει ένα :class:`io.BufferedReader` ∙ σε δυαδικές " +"καταστάσεις εγγραφής και δυαδικής προσθήκης, επιστρέφει " +"ένα :class:`io.BufferedWriter`, και στη λειτουργία ανάγνωσης/εγγραφής, " +"επιστρέφει ένα :class:`io.BufferedRandom`. Όταν η προσωρινή αποθήκευση " +"είναι απενεργοποιημένη, επιστρέφεται, η ακατέργαστη ροή , μια " +"υποκλάση :class:`io.RawIOBase`, :class:`io.FileIO`." -#: library/functions.rst:1356 +#: library/functions.rst:1453 msgid "" "See also the file handling modules, such as :mod:`fileinput`, :mod:`io` " -"(where :func:`open` is declared), :mod:`os`, :mod:`os.path`, :mod:" -"`tempfile`, and :mod:`shutil`." +"(where :func:`open` is " +"declared), :mod:`os`, :mod:`os.path`, :mod:`tempfile`, and :mod:`shutil`." msgstr "" -"Δείτε επίσης τις ενότητες διαχείρισης αρχείων, όπως :mod:`fileinput`, :mod:" -"`io` (όπου ορίζεται η :func:`open`), :mod:`os`, :mod:`os.path`, :mod:" -"`tempfile`, και :mod:`shutil`." +"Δείτε επίσης τις ενότητες διαχείρισης αρχείων, " +"όπως :mod:`fileinput`, :mod:`io` (όπου ορίζεται " +"η :func:`open`), :mod:`os`, :mod:`os.path`, :mod:`tempfile`, " +"και :mod:`shutil`." -#: library/functions.rst:1360 +#: library/functions.rst:1457 +#, fuzzy msgid "" -"Raises an :ref:`auditing event ` ``open`` with arguments ``file``, " +"Raises an :ref:`auditing event ` ``open`` with arguments ``path``, " "``mode``, ``flags``." msgstr "" "Εγείρει ένα :ref:`auditing event ` ``open`` με ορίσματα ``file``, " "``mode``, ``flags``." -#: library/functions.rst:1362 +#: library/functions.rst:1459 msgid "" "The ``mode`` and ``flags`` arguments may have been modified or inferred from " "the original call." @@ -2653,21 +2821,21 @@ msgstr "" "Τα ορίσματα ``mode`` και ``flags`` μπορεί να έχουν τροποποιηθεί ή να έχουν " "συναχθεί από την αρχική κλήση." -#: library/functions.rst:1367 +#: library/functions.rst:1464 msgid "The *opener* parameter was added." msgstr "Προστέθηκε η παράμετρος *opener*." -#: library/functions.rst:1368 +#: library/functions.rst:1465 msgid "The ``'x'`` mode was added." msgstr "Προστέθηκε η λειτουργία ``'x'``." -#: library/functions.rst:1369 +#: library/functions.rst:1466 msgid ":exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`." msgstr "" -"Το :exc:`IOError` γινόταν raise παλιά, τώρα είναι ψευδώνυμο του :exc:" -"`OSError`." +"Το :exc:`IOError` γινόταν raise παλιά, τώρα είναι ψευδώνυμο " +"του :exc:`OSError`." -#: library/functions.rst:1370 +#: library/functions.rst:1467 msgid "" ":exc:`FileExistsError` is now raised if the file opened in exclusive " "creation mode (``'x'``) already exists." @@ -2675,44 +2843,44 @@ msgstr "" "Το :exc:`FileExistsError` γίνεται raise τώρα εάν το αρχείο που ανοίγει σε " "λειτουργία αποκλειστικής δημιουργίας (``'x'``) υπάρχει ήδη." -#: library/functions.rst:1375 +#: library/functions.rst:1472 msgid "The file is now non-inheritable." msgstr "Το αρχείο είναι πλέον μη κληρονομικό." -#: library/functions.rst:1379 +#: library/functions.rst:1476 msgid "" "If the system call is interrupted and the signal handler does not raise an " -"exception, the function now retries the system call instead of raising an :" -"exc:`InterruptedError` exception (see :pep:`475` for the rationale)." +"exception, the function now retries the system call instead of raising " +"an :exc:`InterruptedError` exception (see :pep:`475` for the rationale)." msgstr "" "Εάν η κλήση συστήματος διακοπεί και ο χειριστής σήματος δεν κάνει raise μια " "εξαίρεση, η συνάρτηση επαναλαμβάνει τώρα την κλήση συστήματος αντί να κάνει " "raise μια εξαίρεση :exc:`InterruptedError` (δείτε το :pep:`475` για το " "σκεπτικό)." -#: library/functions.rst:1382 +#: library/functions.rst:1479 msgid "The ``'namereplace'`` error handler was added." msgstr "Προστέθηκε το πρόγραμμα χειρισμού σφαλμάτων ``'namereplace'``." -#: library/functions.rst:1386 +#: library/functions.rst:1483 msgid "Support added to accept objects implementing :class:`os.PathLike`." msgstr "" -"Προστέθηκε υποστήριξη για την αποδοχή αντικειμένων που υλοποιούν :class:`os." -"PathLike`." +"Προστέθηκε υποστήριξη για την αποδοχή αντικειμένων που " +"υλοποιούν :class:`os.PathLike`." -#: library/functions.rst:1387 +#: library/functions.rst:1484 msgid "" -"On Windows, opening a console buffer may return a subclass of :class:`io." -"RawIOBase` other than :class:`io.FileIO`." +"On Windows, opening a console buffer may return a subclass " +"of :class:`io.RawIOBase` other than :class:`io.FileIO`." msgstr "" "Στα Windows, το άνοιγμα μιας προσωρινής μνήμης κονσόλας μπορεί να επιστρέψει " "μια υποκλάση του :class:`io.RawIOBase` εκτός από το :class:`io.FileIO`." -#: library/functions.rst:1390 +#: library/functions.rst:1487 msgid "The ``'U'`` mode has been removed." msgstr "Η λειτουργία ``'U'`` έχει αφαιρεθεί." -#: library/functions.rst:1395 +#: library/functions.rst:1492 msgid "" "Given a string representing one Unicode character, return an integer " "representing the Unicode code point of that character. For example, " @@ -2725,7 +2893,7 @@ msgstr "" "αριθμό ``97`` και ``ord('€')`` (σύμβολο του ευρώ) επιστρέφει ``8364``. Αυτό " "είναι το αντίστροφο του :func:`chr`." -#: library/functions.rst:1403 +#: library/functions.rst:1500 msgid "" "Return *base* to the power *exp*; if *mod* is present, return *base* to the " "power *exp*, modulo *mod* (computed more efficiently than ``pow(base, exp) % " @@ -2737,7 +2905,8 @@ msgstr "" "``pow(base, exp) % mod``). Η φόρμα δύο ορισμάτων ``pow(base, exp)`` " "ισοδυναμεί με τη χρήση του τελεστή δύναμης: ``base**exp``." -#: library/functions.rst:1408 +#: library/functions.rst:1505 +#, fuzzy msgid "" "The arguments must have numeric types. With mixed operand types, the " "coercion rules for binary arithmetic operators apply. For :class:`int` " @@ -2747,7 +2916,9 @@ msgid "" "2)`` returns ``100``, but ``pow(10, -2)`` returns ``0.01``. For a negative " "base of type :class:`int` or :class:`float` and a non-integral exponent, a " "complex result is delivered. For example, ``pow(-9, 0.5)`` returns a value " -"close to ``3j``." +"close to ``3j``. Whereas, for a negative base of type :class:`int` " +"or :class:`float` with an integral exponent, a float result is delivered. " +"For example, ``pow(-9, 2.0)`` returns ``81.0``." msgstr "" "Τα ορίσματα πρέπει να έχουνε αριθμητικούς τύπους. Με μεικτούς τύπους " "τελεστών, ισχύουν οι κανόνες εξαναγκασμού για δυαδικούς τελεστές " @@ -2760,7 +2931,7 @@ msgstr "" "έναν μη αναπόσπαστο εκθέτη, παραδίδεται ένα μιγαδικό αποτέλεσμα. Για " "παράδειγμα, ``pow(-9, 0.5)`` επιστρέφει μια τιμή κοντά στο ``3j``." -#: library/functions.rst:1418 +#: library/functions.rst:1517 msgid "" "For :class:`int` operands *base* and *exp*, if *mod* is present, *mod* must " "also be of integer type and *mod* must be nonzero. If *mod* is present and " @@ -2775,13 +2946,21 @@ msgstr "" "``pow(inv_base, -exp, mod)``, όπου το *inv_base* είναι αντίστροφο του *base* " "modulo *mod*." -#: library/functions.rst:1424 +#: library/functions.rst:1523 msgid "Here's an example of computing an inverse for ``38`` modulo ``97``::" msgstr "" "Ακολουθεί ένα παράδειγμα υπολογισμού ενός αντίστροφου για το ``38`` modulo " "``97``::" -#: library/functions.rst:1431 +#: library/functions.rst:1525 +msgid "" +">>> pow(38, -1, mod=97)\n" +"23\n" +">>> 23 * 38 % 97 == 1\n" +"True" +msgstr "" + +#: library/functions.rst:1530 msgid "" "For :class:`int` operands, the three-argument form of ``pow`` now allows the " "second argument to be negative, permitting computation of modular inverses." @@ -2790,14 +2969,14 @@ msgstr "" "τώρα το δεύτερο όρισμα να είναι αρνητικό, επιτρέποντας τον υπολογισμό των " "αρθρωτών αντίστροφων." -#: library/functions.rst:1436 +#: library/functions.rst:1535 msgid "" "Allow keyword arguments. Formerly, only positional arguments were supported." msgstr "" "Επιτρέπονται ορίσματα keyword. Παλαιότερα, υποστηρίζονταν μόνο ορίσματα " "θέσης." -#: library/functions.rst:1443 +#: library/functions.rst:1542 msgid "" "Print *objects* to the text stream *file*, separated by *sep* and followed " "by *end*. *sep*, *end*, *file*, and *flush*, if present, must be given as " @@ -2807,7 +2986,7 @@ msgstr "" "ακολουθούμενα από *end*. Τα *sep*, *end*, *file*, και *flush*, εάν υπάρχουν, " "πρέπει να δίνονται ως ορίσματα keyword." -#: library/functions.rst:1447 +#: library/functions.rst:1546 msgid "" "All non-keyword arguments are converted to strings like :func:`str` does and " "written to the stream, separated by *sep* and followed by *end*. Both *sep* " @@ -2815,14 +2994,14 @@ msgid "" "default values. If no *objects* are given, :func:`print` will just write " "*end*." msgstr "" -"Όλα τα μη keyword ορίσματα μετατρέπονται σε συμβολοσειρές όπως κάνει η :func:" -"`str` και γράφονται στη ροή, χωρισμένα με *sep* και ακολουθούνται από " -"*end*. Και τα δύο *sep* και *end* πρέπει να είναι συμβολοσειρές∙ μπορεί " +"Όλα τα μη keyword ορίσματα μετατρέπονται σε συμβολοσειρές όπως κάνει " +"η :func:`str` και γράφονται στη ροή, χωρισμένα με *sep* και ακολουθούνται " +"από *end*. Και τα δύο *sep* και *end* πρέπει να είναι συμβολοσειρές∙ μπορεί " "επίσης να είναι ``None``, που σημαίνει ότι θα χρησιμοποιηθούν οι " "προεπιλεγμένες τιμές. Εάν δεν δίνονται *αντικείμενα*, η :func:`print` θα " "γράψει απλά *end*." -#: library/functions.rst:1453 +#: library/functions.rst:1552 msgid "" "The *file* argument must be an object with a ``write(string)`` method; if it " "is not present or ``None``, :data:`sys.stdout` will be used. Since printed " @@ -2830,13 +3009,13 @@ msgid "" "binary mode file objects. For these, use ``file.write(...)`` instead." msgstr "" "Το όρισμα *file* πρέπει να είναι αντικείμενο με μια μέθοδο " -"``write(string)``∙ εάν δεν υπάρχει ή είναι ``None``, θα χρησιμοποιηθεί το :" -"data:`sys.stdout`. Επειδή τα τυπωμένα ορίσματα μετατρέπονται σε " +"``write(string)``∙ εάν δεν υπάρχει ή είναι ``None``, θα χρησιμοποιηθεί " +"το :data:`sys.stdout`. Επειδή τα τυπωμένα ορίσματα μετατρέπονται σε " "συμβολοσειρές κειμένου, η :func:`print` δεν μπορεί να χρησιμοποιηθεί με " "αντικείμενα αρχείου δυαδικής λειτουργίας. Για αυτά, χρησιμοποιούμε το " "``file.write(...)``." -#: library/functions.rst:1458 +#: library/functions.rst:1557 msgid "" "Output buffering is usually determined by *file*. However, if *flush* is " "true, the stream is forcibly flushed." @@ -2844,15 +3023,15 @@ msgstr "" "Η προσωρινή αποθήκευση εξόδου καθορίζεται συνήθως από το *αρχείο*. Ωστόσο, " "εάν το *flush* είναι αληθές, η ροή ξεπλένεται αναγκαστικά." -#: library/functions.rst:1462 +#: library/functions.rst:1561 msgid "Added the *flush* keyword argument." msgstr "Προστέθηκε το όρισμα keyword *flush*." -#: library/functions.rst:1468 +#: library/functions.rst:1567 msgid "Return a property attribute." msgstr "Επιστρέφει ένα χαρακτηριστικό ιδιότητας." -#: library/functions.rst:1470 +#: library/functions.rst:1569 msgid "" "*fget* is a function for getting an attribute value. *fset* is a function " "for setting an attribute value. *fdel* is a function for deleting an " @@ -2863,12 +3042,30 @@ msgstr "" "*fdel* είναι μια συνάρτηση για τη διαγραφή μιας τιμής χαρακτηριστικού. Και " "το *doc* δημιουργεί μια συμβολοσειρά εγγράφων για το χαρακτηριστικό." -#: library/functions.rst:1474 +#: library/functions.rst:1573 msgid "A typical use is to define a managed attribute ``x``::" msgstr "" "Μια τυπική χρήση είναι ο ορισμός ενός διαχειριζόμενου χαρακτηριστικού ``x``::" -#: library/functions.rst:1491 +#: library/functions.rst:1575 +msgid "" +"class C:\n" +" def __init__(self):\n" +" self._x = None\n" +"\n" +" def getx(self):\n" +" return self._x\n" +"\n" +" def setx(self, value):\n" +" self._x = value\n" +"\n" +" def delx(self):\n" +" del self._x\n" +"\n" +" x = property(getx, setx, delx, \"I'm the 'x' property.\")" +msgstr "" + +#: library/functions.rst:1590 msgid "" "If *c* is an instance of *C*, ``c.x`` will invoke the getter, ``c.x = " "value`` will invoke the setter, and ``del c.x`` the deleter." @@ -2876,19 +3073,31 @@ msgstr "" "Εάν το *c* είναι ένα instance του *C*, το ``c.x`` θα καλέσει τον λήπτη, το " "``c.x = value` θα καλέσει τον ρυθμιστή, και το ``del c.x`` τον διαγραφέα." -#: library/functions.rst:1494 +#: library/functions.rst:1593 msgid "" "If given, *doc* will be the docstring of the property attribute. Otherwise, " "the property will copy *fget*'s docstring (if it exists). This makes it " -"possible to create read-only properties easily using :func:`property` as a :" -"term:`decorator`::" +"possible to create read-only properties easily using :func:`property` as " +"a :term:`decorator`::" msgstr "" "Εάν δίνεται, το *doc* θα είναι το docstring του χαρακτηριστικού ιδιότητας. " "Διαφορετικά , η ιδιότητα θα αντιγράψει τη συμβολοσειρά του *fget* (εάν " "υπάρχει). Αυτό καθιστά δυνατή τη δημιουργία ιδιοτήτων μόνο για ανάγνωση, " "εύκολα χρησιμοποιώντας τη :func:`property` ως :term:`decorator`::" -#: library/functions.rst:1507 +#: library/functions.rst:1597 +msgid "" +"class Parrot:\n" +" def __init__(self):\n" +" self._voltage = 100000\n" +"\n" +" @property\n" +" def voltage(self):\n" +" \"\"\"Get the current voltage.\"\"\"\n" +" return self._voltage" +msgstr "" + +#: library/functions.rst:1606 msgid "" "The ``@property`` decorator turns the :meth:`!voltage` method into a " "\"getter\" for a read-only attribute with the same name, and it sets the " @@ -2898,7 +3107,7 @@ msgstr "" "\"getter\" για ένα χαρακτηριστικό μόνο για ανάγνωση με το ίδιο όνομα, και " "ορίζει τη συμβολοσειρά εγγράφων για *voltage* σε \"Get the current voltage.\"" -#: library/functions.rst:1515 +#: library/functions.rst:1614 msgid "" "A property object has ``getter``, ``setter``, and ``deleter`` methods usable " "as decorators that create a copy of the property with the corresponding " @@ -2910,7 +3119,27 @@ msgstr "" "ένα αντίγραφο της ιδιότητας με την αντίστοιχη συνάρτηση accessor που έχει " "οριστεί στον decorator. Αυτό εξηγείται καλύτερα με ένα παράδειγμα:" -#: library/functions.rst:1539 +#: library/functions.rst:1619 +msgid "" +"class C:\n" +" def __init__(self):\n" +" self._x = None\n" +"\n" +" @property\n" +" def x(self):\n" +" \"\"\"I'm the 'x' property.\"\"\"\n" +" return self._x\n" +"\n" +" @x.setter\n" +" def x(self, value):\n" +" self._x = value\n" +"\n" +" @x.deleter\n" +" def x(self):\n" +" del self._x" +msgstr "" + +#: library/functions.rst:1638 msgid "" "This code is exactly equivalent to the first example. Be sure to give the " "additional functions the same name as the original property (``x`` in this " @@ -2920,7 +3149,7 @@ msgstr "" "να δώσετε στις πρόσθετες συναρτήσεις το ίδιο όνομα με την αρχική ιδιότητα " "(``x`` σε αυτήν την περίπτωση.)" -#: library/functions.rst:1543 +#: library/functions.rst:1642 msgid "" "The returned property object also has the attributes ``fget``, ``fset``, and " "``fdel`` corresponding to the constructor arguments." @@ -2929,11 +3158,11 @@ msgstr "" "``fget``, ``fset``, και ``fdel`` που αντιστοιχούν στα ορίσματα του " "κατασκευαστή." -#: library/functions.rst:1546 +#: library/functions.rst:1645 msgid "The docstrings of property objects are now writeable." msgstr "Τα *docstrings* των αντικειμένων ιδιότητας είναι πλέον εγγράψιμες." -#: library/functions.rst:1555 +#: library/functions.rst:1654 msgid "" "Rather than being a function, :class:`range` is actually an immutable " "sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`." @@ -2942,7 +3171,7 @@ msgstr "" "αμετάβλητος τύπος ακολουθίας, όπως τεκμηριώνεται στα :ref:`typesseq-range` " "και :ref:`typesseq`." -#: library/functions.rst:1561 +#: library/functions.rst:1660 msgid "" "Return a string containing a printable representation of an object. For " "many types, this function makes an attempt to return a string that would " @@ -2961,28 +3190,40 @@ msgstr "" "συμβολοσειρά που περικλείεται σε αγκύλες που περιέχει το όνομα του τύπου του " "αντικειμένου μαζί με πρόσθετες πληροφορίες που συχνά περιλαμβάνουν το όνομα " "και τη διεύθυνση του αντικειμένου. Μια κλάση μπορεί να ελέγξει τι " -"επιστρέφει αυτή η συνάρτηση για τις οντότητες της ορίζοντας μια μέθοδο :meth:" -"`~object.__repr__`. Εάν η :func:`sys.displayhook` δεν είναι προσβάσιμη, αυτή " -"η συνάρτηση θα κάνει raise το :exc:`RuntimeError`." +"επιστρέφει αυτή η συνάρτηση για τις οντότητες της ορίζοντας μια " +"μέθοδο :meth:`~object.__repr__`. Εάν η :func:`sys.displayhook` δεν είναι " +"προσβάσιμη, αυτή η συνάρτηση θα κάνει raise το :exc:`RuntimeError`." -#: library/functions.rst:1572 +#: library/functions.rst:1671 msgid "This class has a custom representation that can be evaluated::" msgstr "" "Αυτή η κλάση έχει μια προσαρμοσμένη αναπαράσταση που μπορεί να αξιολογηθεί::" -#: library/functions.rst:1585 +#: library/functions.rst:1673 msgid "" -"Return a reverse :term:`iterator`. *seq* must be an object which has a :" -"meth:`~object.__reversed__` method or supports the sequence protocol (the :" -"meth:`~object.__len__` method and the :meth:`~object.__getitem__` method " -"with integer arguments starting at ``0``)." +"class Person:\n" +" def __init__(self, name, age):\n" +" self.name = name\n" +" self.age = age\n" +"\n" +" def __repr__(self):\n" +" return f\"Person('{self.name}', {self.age})\"" +msgstr "" + +#: library/functions.rst:1684 +msgid "" +"Return a reverse :term:`iterator`. *seq* must be an object which has " +"a :meth:`~object.__reversed__` method or supports the sequence protocol " +"(the :meth:`~object.__len__` method and the :meth:`~object.__getitem__` " +"method with integer arguments starting at ``0``)." msgstr "" "Επιστρέφει ένα αντίστροφο :term:`iterator`. Το *seq* πρέπει να είναι ένα " "αντικείμενο που έχει μια μέθοδο :meth:`~object.__reversed__` ή υποστηρίζει " -"το πρωτόκολλο ακολουθίας (η μέθοδος :meth:`~object.__len__` και η μέθοδος :" -"meth:`~object.__getitem__` με ακέραια ορίσματα που ξεκινούν από ``0``)." +"το πρωτόκολλο ακολουθίας (η μέθοδος :meth:`~object.__len__` και η " +"μέθοδος :meth:`~object.__getitem__` με ακέραια ορίσματα που ξεκινούν από " +"``0``)." -#: library/functions.rst:1593 +#: library/functions.rst:1692 msgid "" "Return *number* rounded to *ndigits* precision after the decimal point. If " "*ndigits* is omitted or is ``None``, it returns the nearest integer to its " @@ -2992,7 +3233,7 @@ msgstr "" "υποδιαστολή. Εάν το *ndigits* παραληφθεί ή είναι ``None``, επιστρέφει τον " "πλησιέστερο ακέραιο αριθμό στην είσοδό του." -#: library/functions.rst:1597 +#: library/functions.rst:1696 msgid "" "For the built-in types supporting :func:`round`, values are rounded to the " "closest multiple of 10 to the power minus *ndigits*; if two multiples are " @@ -3011,15 +3252,15 @@ msgstr "" "επιστρεφόμενη τιμή είναι ακέραιος εάν το *ndigits* παραλειφθεί ή είναι " "``None``. Διαφορετικά, η τιμή επιστροφής έχει τον ίδιο τύπο με το *number*." -#: library/functions.rst:1606 +#: library/functions.rst:1705 msgid "" -"For a general Python object ``number``, ``round`` delegates to ``number." -"__round__``." +"For a general Python object ``number``, ``round`` delegates to " +"``number.__round__``." msgstr "" -"Για ένα γενικό αντικείμενο Python ``number``, ``round`` εκχωρεί στο ``number." -"__round__``." +"Για ένα γενικό αντικείμενο Python ``number``, ``round`` εκχωρεί στο " +"``number.__round__``." -#: library/functions.rst:1611 +#: library/functions.rst:1710 msgid "" "The behavior of :func:`round` for floats can be surprising: for example, " "``round(2.675, 2)`` gives ``2.67`` instead of the expected ``2.68``. This is " @@ -3033,7 +3274,7 @@ msgstr "" "περισσότερα δεκαδικά κλάσματα δεν μπορούν να αναπαρασταθούν ακριβώς ως " "float. Δείτε το :ref:`tut-fp-issues` για περισσότερες πληροφορίες." -#: library/functions.rst:1623 +#: library/functions.rst:1722 msgid "" "Return a new :class:`set` object, optionally with elements taken from " "*iterable*. ``set`` is a built-in class. See :class:`set` and :ref:`types-" @@ -3043,17 +3284,17 @@ msgstr "" "λαμβάνονται από το *iterable*. Το ``set`` είναι μια ενσωματωμένη κλάση. " "Δείτε :class:`set` και :ref:`types-set` για τεκμηρίωση αυτής της κλάσης." -#: library/functions.rst:1627 +#: library/functions.rst:1726 msgid "" -"For other containers see the built-in :class:`frozenset`, :class:`list`, :" -"class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` " -"module." +"For other containers see the built-" +"in :class:`frozenset`, :class:`list`, :class:`tuple`, and :class:`dict` " +"classes, as well as the :mod:`collections` module." msgstr "" -"Για άλλα containers, δείτε τις ενσωματωμένες κλάσεις :class:`frozenset`, :" -"class:`list`, :class:`tuple`, και :class:`dict`, καθώς και το module :mod:" -"`collections`." +"Για άλλα containers, δείτε τις ενσωματωμένες " +"κλάσεις :class:`frozenset`, :class:`list`, :class:`tuple`, " +"και :class:`dict`, καθώς και το module :mod:`collections`." -#: library/functions.rst:1634 +#: library/functions.rst:1733 msgid "" "This is the counterpart of :func:`getattr`. The arguments are an object, a " "string, and an arbitrary value. The string may name an existing attribute " @@ -3068,22 +3309,22 @@ msgstr "" "επιτρέπει. Για παράδειγμα ``setattr(x, 'foobar', 123)`` ισοδυναμεί με το " "``x.foobar = 123``." -#: library/functions.rst:1640 +#: library/functions.rst:1739 msgid "" "*name* need not be a Python identifier as defined in :ref:`identifiers` " -"unless the object chooses to enforce that, for example in a custom :meth:" -"`~object.__getattribute__` or via :attr:`~object.__slots__`. An attribute " -"whose name is not an identifier will not be accessible using the dot " -"notation, but is accessible through :func:`getattr` etc.." -msgstr "" -"Το *name* δεν χρειάζεται να είναι αναγνωριστικό Python όπως ορίζεται στο :" -"ref:`identifiers` , εκτός εάν το αντικείμενο επιλέξει να το επιβάλει αυτό, " -"για παράδειγμα σε ένα προσαρμοσμένο :meth:`~object.__getattribute__` ή μέσω :" -"attr:`~object.__slots__`. Ένα χαρακτηριστικό του οποίου το όνομα δεν είναι " -"αναγνωριστικό δεν θα είναι προσβάσιμο χρησιμοποιώντας τη σημειογραφία, αλλά " -"είναι προσβάσιμο μέσω του :func:`getattr` κ.λπ.." +"unless the object chooses to enforce that, for example in a " +"custom :meth:`~object.__getattribute__` or via :attr:`~object.__slots__`. An " +"attribute whose name is not an identifier will not be accessible using the " +"dot notation, but is accessible through :func:`getattr` etc.." +msgstr "" +"Το *name* δεν χρειάζεται να είναι αναγνωριστικό Python όπως ορίζεται " +"στο :ref:`identifiers` , εκτός εάν το αντικείμενο επιλέξει να το επιβάλει " +"αυτό, για παράδειγμα σε ένα προσαρμοσμένο :meth:`~object.__getattribute__` ή " +"μέσω :attr:`~object.__slots__`. Ένα χαρακτηριστικό του οποίου το όνομα δεν " +"είναι αναγνωριστικό δεν θα είναι προσβάσιμο χρησιμοποιώντας τη σημειογραφία, " +"αλλά είναι προσβάσιμο μέσω του :func:`getattr` κ.λπ.." -#: library/functions.rst:1648 +#: library/functions.rst:1747 msgid "" "Since :ref:`private name mangling ` happens at " "compilation time, one must manually mangle a private attribute's (attributes " @@ -3094,7 +3335,7 @@ msgstr "" "μη αυτόματο τρόπο το όνομα ενός ιδιωτικού χαρακτηριστικού (χαρακτηριστικά με " "δύο προπορευόμενες κάτω παύλες) για να το ορίσει με :func:`setattr`." -#: library/functions.rst:1657 +#: library/functions.rst:1756 msgid "" "Return a :term:`slice` object representing the set of indices specified by " "``range(start, stop, step)``. The *start* and *step* arguments default to " @@ -3104,62 +3345,65 @@ msgstr "" "δεικτών που καθορίζονται από το ``range(start, stop, step)``. Τα ορίσματα " "*start* και *step* είναι από προεπιλογή ``None``." -#: library/functions.rst:1665 +#: library/functions.rst:1764 msgid "" "Slice objects have read-only data attributes :attr:`!start`, :attr:`!stop`, " "and :attr:`!step` which merely return the argument values (or their " "default). They have no other explicit functionality; however, they are used " "by NumPy and other third-party packages." msgstr "" -"Τα αντικείμενα τμημάτων έχουν χαρακτηριστικά δεδομένων μόνο για ανάγνωση :" -"attr:`!start`, :attr:`!stop`, και :attr:`!step` τα οποία απλώς επιστρέφουν " -"τις τιμές του ορίσματος (ή την προεπιλογή τους). Δεν έχουνε άλλη ρητή " -"λειτουργικότητα∙ ωστόσο, χρησιμοποιούνται από το NumPy και άλλα πακέτα " -"τρίτων." +"Τα αντικείμενα τμημάτων έχουν χαρακτηριστικά δεδομένων μόνο για " +"ανάγνωση :attr:`!start`, :attr:`!stop`, και :attr:`!step` τα οποία απλώς " +"επιστρέφουν τις τιμές του ορίσματος (ή την προεπιλογή τους). Δεν έχουνε " +"άλλη ρητή λειτουργικότητα∙ ωστόσο, χρησιμοποιούνται από το NumPy και άλλα " +"πακέτα τρίτων." -#: library/functions.rst:1670 +#: library/functions.rst:1769 msgid "" "Slice objects are also generated when extended indexing syntax is used. For " -"example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See :func:" -"`itertools.islice` for an alternate version that returns an :term:`iterator`." +"example: ``a[start:stop:step]`` or ``a[start:stop, i]``. " +"See :func:`itertools.islice` for an alternate version that returns " +"an :term:`iterator`." msgstr "" "Τα αντικείμενα slice δημιουργούνται επίσης όταν χρησιμοποιείται εκτεταμένη " -"σύνταξη ευρετηρίου. Για παράδειγμα: ``a[start:stop:step]`` ή ``a[start:" -"stop, i]``. Δείτε τη :func:`itertools.islice` για μια εναλλακτική έκδοση " -"που επιστρέφει ένα :term:`iterator`." +"σύνταξη ευρετηρίου. Για παράδειγμα: ``a[start:stop:step]`` ή " +"``a[start:stop, i]``. Δείτε τη :func:`itertools.islice` για μια εναλλακτική " +"έκδοση που επιστρέφει ένα :term:`iterator`." -#: library/functions.rst:1675 +#: library/functions.rst:1774 msgid "" -"Slice objects are now :term:`hashable` (provided :attr:`~slice.start`, :attr:" -"`~slice.stop`, and :attr:`~slice.step` are hashable)." +"Slice objects are now :term:`hashable` " +"(provided :attr:`~slice.start`, :attr:`~slice.stop`, and :attr:`~slice.step` " +"are hashable)." msgstr "" -"Τα αντικείμενα slice είναι πλέον :term:`hashable` (με την προϋπόθεση :attr:" -"`~slice.start`, :attr:`~slice.stop`, και :attr:`~slice.step` μπορούν να " -"κατακερματιστούν)." +"Τα αντικείμενα slice είναι πλέον :term:`hashable` (με την " +"προϋπόθεση :attr:`~slice.start`, :attr:`~slice.stop`, " +"και :attr:`~slice.step` μπορούν να κατακερματιστούν)." -#: library/functions.rst:1681 +#: library/functions.rst:1780 msgid "Return a new sorted list from the items in *iterable*." msgstr "Επιστρέφει μια νέα ταξινομημένη λίστα από τα στοιχεία στο *iterable*." -#: library/functions.rst:1683 +#: library/functions.rst:1782 msgid "" "Has two optional arguments which must be specified as keyword arguments." msgstr "" "Έχει δύο προαιρετικά ορίσματα που πρέπει να καθοριστούν ως ορίσματα λέξεων-" "κλειδιών." -#: library/functions.rst:1685 +#: library/functions.rst:1784 msgid "" "*key* specifies a function of one argument that is used to extract a " -"comparison key from each element in *iterable* (for example, ``key=str." -"lower``). The default value is ``None`` (compare the elements directly)." +"comparison key from each element in *iterable* (for example, " +"``key=str.lower``). The default value is ``None`` (compare the elements " +"directly)." msgstr "" "Το *key* καθορίζει μια συνάρτηση ενός ορίσματος που χρησιμοποιείται για την " "εξαγωγή ενός κλειδιού σύγκρισης από κάθε στοιχείο στο *iterable* (για " "παράδειγμα, ``key=str.lower``). Η προεπιλεγμένη τιμή είναι ``None`` " "(συγκρίνει τα στοιχεία απευθείας)." -#: library/functions.rst:1689 +#: library/functions.rst:1788 msgid "" "*reverse* is a boolean value. If set to ``True``, then the list elements " "are sorted as if each comparison were reversed." @@ -3167,7 +3411,7 @@ msgstr "" "Το *reverse* είναι μια δυαδική τιμή. Εάν οριστεί σε ``True``, τότε τα " "στοιχεία της λίστας ταξινομούνται σαν να είχε αντιστραφεί κάθε σύγκριση." -#: library/functions.rst:1692 +#: library/functions.rst:1791 msgid "" "Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a " "*key* function." @@ -3175,7 +3419,7 @@ msgstr "" "Χρησιμοποιήστε το :func:`functools.cmp_to_key` για να μετατρέψετε μια " "συνάρτηση *cmp* παλιού τύπου σε συνάρτηση *key*." -#: library/functions.rst:1695 +#: library/functions.rst:1794 msgid "" "The built-in :func:`sorted` function is guaranteed to be stable. A sort is " "stable if it guarantees not to change the relative order of elements that " @@ -3188,7 +3432,7 @@ msgstr "" "πολλαπλά περάσματα (για παράδειγμα, ταξινόμηση ανά τμήμα, μετά ανά " "μισθολογικό βαθμό)." -#: library/functions.rst:1700 +#: library/functions.rst:1799 msgid "" "The sort algorithm uses only ``<`` comparisons between items. While " "defining an :meth:`~object.__lt__` method will suffice for sorting, :PEP:`8` " @@ -3203,23 +3447,24 @@ msgstr "" "στοιχείων. Ενώ ο ορισμός μιας μεθόδου :meth:`~object.__lt__` αρκεί για την " "ταξινόμηση, το :PEP:`8` συνιστά και τις έξι :ref:`rich comparisons " "` που θα εφαρμοστούν. Αυτό θα βοηθήσει στην αποφυγή σφαλμάτων " -"κατά τη χρήση των ίδιων δεδομένων με άλλα εργαλεία διάταξης, όπως :func:" -"`max` που βασίζονται σε διαφορετική υποκείμενη μέθοδο. Η υλοποίηση και των " -"έξι συγκρίσεων βοηθά επίσης στην αποφυγή σύγχυσης για συγκρίσεις μικτού " -"τύπου που μπορούν να καλέσουν την ανακλώμενη μέθοδο :meth:`~object.__gt__`." +"κατά τη χρήση των ίδιων δεδομένων με άλλα εργαλεία διάταξης, " +"όπως :func:`max` που βασίζονται σε διαφορετική υποκείμενη μέθοδο. Η " +"υλοποίηση και των έξι συγκρίσεων βοηθά επίσης στην αποφυγή σύγχυσης για " +"συγκρίσεις μικτού τύπου που μπορούν να καλέσουν την ανακλώμενη " +"μέθοδο :meth:`~object.__gt__`." -#: library/functions.rst:1709 +#: library/functions.rst:1808 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." msgstr "" "Για παραδείγματα ταξινόμησης και ένα σύντομο σεμινάριο ταξινόμησης, " "ανατρέξτε στο :ref:`sortinghowto`." -#: library/functions.rst:1713 +#: library/functions.rst:1812 msgid "Transform a method into a static method." msgstr "Μετατροπή μιας μεθόδου σε στατική μέθοδο." -#: library/functions.rst:1715 +#: library/functions.rst:1814 msgid "" "A static method does not receive an implicit first argument. To declare a " "static method, use this idiom::" @@ -3227,25 +3472,34 @@ msgstr "" "Μια στατική μέθοδος δεν λαμβάνει ένα σιωπηρό πρώτο όρισμα. Για να δηλώσετε " "μια στατική μέθοδο, χρησιμοποιήστε αυτό το ιδίωμα::" -#: library/functions.rst:1722 +#: library/functions.rst:1817 +msgid "" +"class C:\n" +" @staticmethod\n" +" def f(arg1, arg2, argN): ..." +msgstr "" + +#: library/functions.rst:1821 msgid "" -"The ``@staticmethod`` form is a function :term:`decorator` -- see :ref:" -"`function` for details." +"The ``@staticmethod`` form is a function :term:`decorator` -- " +"see :ref:`function` for details." msgstr "" -"Η φόρμα ``@staticmethod`` είναι μια συνάρτηση :term:`decorator` -- δείτε :" -"ref:`function` για λεπτομέρειες." +"Η φόρμα ``@staticmethod`` είναι μια συνάρτηση :term:`decorator` -- " +"δείτε :ref:`function` για λεπτομέρειες." -#: library/functions.rst:1725 +#: library/functions.rst:1824 +#, fuzzy msgid "" "A static method can be called either on the class (such as ``C.f()``) or on " -"an instance (such as ``C().f()``). Moreover, they can be called as regular " -"functions (such as ``f()``)." +"an instance (such as ``C().f()``). Moreover, the static " +"method :term:`descriptor` is also callable, so it can be used in the class " +"definition (such as ``f()``)." msgstr "" "Μια στατική μέθοδος μπορεί να κληθεί είτε στην κλάση (όπως ``C.f()``) είτε " "σε ένα instance (όπως ``C().f()``). Επιπλέον, μπορούν να κληθούν ως " "κανονικές συναρτήσεις (όπως ``f()``)." -#: library/functions.rst:1729 +#: library/functions.rst:1829 msgid "" "Static methods in Python are similar to those found in Java or C++. Also, " "see :func:`classmethod` for a variant that is useful for creating alternate " @@ -3255,7 +3509,7 @@ msgstr "" "Java ή στη C++. Επίσης, ανατρέξτε στη :func:`classmethod` για μια παραλλαγή " "που είναι χρήσιμη για τη δημιουργία εναλλακτικών κατασκευαστών κλάσεων." -#: library/functions.rst:1733 +#: library/functions.rst:1833 msgid "" "Like all decorators, it is also possible to call ``staticmethod`` as a " "regular function and do something with its result. This is needed in some " @@ -3270,31 +3524,42 @@ msgstr "" "αυτόματη μετατροπή σε instance μέθοδο. Για αυτές τις περιπτώσεις, " "χρησιμοποιήστε αυτό το ιδίωμα::" -#: library/functions.rst:1745 +#: library/functions.rst:1839 +msgid "" +"def regular_function():\n" +" ...\n" +"\n" +"class C:\n" +" method = staticmethod(regular_function)" +msgstr "" + +#: library/functions.rst:1845 msgid "For more information on static methods, see :ref:`types`." msgstr "" -"Για περισσότερες πληροφορίες σχετικά με τις στατικές μεθόδους, δείτε το :ref:" -"`types`." +"Για περισσότερες πληροφορίες σχετικά με τις στατικές μεθόδους, δείτε " +"το :ref:`types`." -#: library/functions.rst:1747 +#: library/functions.rst:1847 +#, fuzzy msgid "" -"Static methods now inherit the method attributes (``__module__``, " -"``__name__``, ``__qualname__``, ``__doc__`` and ``__annotations__``), have a " -"new ``__wrapped__`` attribute, and are now callable as regular functions." +"Static methods now inherit the method attributes " +"(:attr:`~function.__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function.__doc__` " +"and :attr:`~function.__annotations__`), have a new ``__wrapped__`` " +"attribute, and are now callable as regular functions." msgstr "" "Οι στατικές μέθοδοι κληρονομούν πλέον τα χαρακτηριστικά της μεθόδου " "(``__module__``, ``__name__``, ``__qualname__``, ``__doc__`` και " "``__annotations__``), έχουν ένα νέο χαρακτηριστικό ``__wrapped__``, και " "μπορούν πλέον να καλούνται ως κανονικές λειτουργίες." -#: library/functions.rst:1762 +#: library/functions.rst:1863 msgid "" "Return a :class:`str` version of *object*. See :func:`str` for details." msgstr "" "Επιστρέφει μια έκδοση :class:`str` του *object*. Δείτε :func:`str` για " "λεπτομέρειες." -#: library/functions.rst:1764 +#: library/functions.rst:1865 msgid "" "``str`` is the built-in string :term:`class`. For general information about " "strings, see :ref:`textseq`." @@ -3302,7 +3567,7 @@ msgstr "" "Το ``str`` είναι η ενσωματωμένη συμβολοσειρά :term:`class`. Για γενικές " "πληροφορίες σχετικά με τις συμβολοσειρές, ανατρέξτε :ref:`textseq`." -#: library/functions.rst:1770 +#: library/functions.rst:1871 msgid "" "Sums *start* and the items of an *iterable* from left to right and returns " "the total. The *iterable*'s items are normally numbers, and the start value " @@ -3312,26 +3577,27 @@ msgstr "" "και επιστρέφει το σύνολο. Τα στοιχεία του *iterable* είναι συνήθως αριθμοί " "και η τιμή έναρξης δεν επιτρέπεται να είναι συμβολοσειρά." -#: library/functions.rst:1774 +#: library/functions.rst:1875 +#, fuzzy msgid "" "For some use cases, there are good alternatives to :func:`sum`. The " -"preferred, fast way to concatenate a sequence of strings is by calling ``''." -"join(sequence)``. To add floating point values with extended precision, " -"see :func:`math.fsum`\\. To concatenate a series of iterables, consider " -"using :func:`itertools.chain`." -msgstr "" -"Για ορισμένες περιπτώσεις χρήσης, υπάρχουν καλές εναλλακτικές λύσεις για το :" -"func:`sum`. Ο προτιμώμενος, γρήγορος τρόπος για να συνδέσετε μια ακολουθία " -"συμβολοσειρών είναι καλώντας ``''.join(sequence)``. Για να προσθέσετε τιμές " -"κινητής υποδιαστολής με εκτεταμένη ακρίβεια, δείτε :func:`math.fsum`\\. Για " -"να συνδυάσετε μια σειρά iterable, σκεφτείτε να χρησιμοποιήσετε το :func:" -"`itertools.chain`." - -#: library/functions.rst:1780 +"preferred, fast way to concatenate a sequence of strings is by calling " +"``''.join(sequence)``. To add floating-point values with extended " +"precision, see :func:`math.fsum`\\. To concatenate a series of iterables, " +"consider using :func:`itertools.chain`." +msgstr "" +"Για ορισμένες περιπτώσεις χρήσης, υπάρχουν καλές εναλλακτικές λύσεις για " +"το :func:`sum`. Ο προτιμώμενος, γρήγορος τρόπος για να συνδέσετε μια " +"ακολουθία συμβολοσειρών είναι καλώντας ``''.join(sequence)``. Για να " +"προσθέσετε τιμές κινητής υποδιαστολής με εκτεταμένη ακρίβεια, " +"δείτε :func:`math.fsum`\\. Για να συνδυάσετε μια σειρά iterable, σκεφτείτε " +"να χρησιμοποιήσετε το :func:`itertools.chain`." + +#: library/functions.rst:1881 msgid "The *start* parameter can be specified as a keyword argument." msgstr "Η παράμετρος *start* μπορεί να καθοριστεί ως όρισμα keyword." -#: library/functions.rst:1783 +#: library/functions.rst:1884 msgid "" "Summation of floats switched to an algorithm that gives higher accuracy on " "most builds." @@ -3339,7 +3605,7 @@ msgstr "" "Η άθροιση των floats άλλαξε σε έναν αλγόριθμο που δίνει μεγαλύτερη ακρίβεια " "στις περισσότερες κατασκευές." -#: library/functions.rst:1790 +#: library/functions.rst:1891 msgid "" "Return a proxy object that delegates method calls to a parent or sibling " "class of *type*. This is useful for accessing inherited methods that have " @@ -3349,7 +3615,7 @@ msgstr "" "μεθόδου σε μια γονική ή αδερφή κλάση *type*. Αυτό είναι χρήσιμο για την " "πρόσβαση σε μεταβιβασμένες μεθόδους που έχουν παρακαμφθεί σε μια κλάση." -#: library/functions.rst:1794 +#: library/functions.rst:1895 msgid "" "The *object_or_type* determines the :term:`method resolution order` to be " "searched. The search starts from the class right after the *type*." @@ -3357,29 +3623,31 @@ msgstr "" "Το *object_or_type* καθορίζει το :term:`method resolution order` που θα " "αναζητηθεί. Η αναζήτηση ξεκινά από την κλάση αμέσως μετά τον *type*." -#: library/functions.rst:1798 +#: library/functions.rst:1899 +#, fuzzy msgid "" -"For example, if :attr:`~class.__mro__` of *object_or_type* is ``D -> B -> C -" -"> A -> object`` and the value of *type* is ``B``, then :func:`super` " +"For example, if :attr:`~type.__mro__` of *object_or_type* is ``D -> B -> C " +"-> A -> object`` and the value of *type* is ``B``, then :func:`super` " "searches ``C -> A -> object``." msgstr "" "Για παράδειγμα, εάν :attr:`~class.__mro__` του *object_or_type* είναι ``D -> " -"B -> C -> A -> object`` και η τιμή του *type* είναι ``B``, τότε η :func:" -"`super` αναζητά ``C -> A -> object``." +"B -> C -> A -> object`` και η τιμή του *type* είναι ``B``, τότε " +"η :func:`super` αναζητά ``C -> A -> object``." -#: library/functions.rst:1802 +#: library/functions.rst:1903 +#, fuzzy msgid "" -"The :attr:`~class.__mro__` attribute of the *object_or_type* lists the " -"method resolution search order used by both :func:`getattr` and :func:" -"`super`. The attribute is dynamic and can change whenever the inheritance " -"hierarchy is updated." +"The :attr:`~type.__mro__` attribute of the class corresponding to " +"*object_or_type* lists the method resolution search order used by " +"both :func:`getattr` and :func:`super`. The attribute is dynamic and can " +"change whenever the inheritance hierarchy is updated." msgstr "" "¨Το χαρακτηριστικό :attr:`~class.__mro__` του *object_or_type* παραθέτει τη " -"σειρά αναζήτησης ανάλυσης μεθόδου που χρησιμοποιείται και από τις :func:" -"`getattr` και :func:`super`. Το χαρακτηριστικό είναι δυναμικό και μπορεί να " -"αλλάξει κάθε φορά που ενημερώνεται η ιεραρχία κληρονομικότητας." +"σειρά αναζήτησης ανάλυσης μεθόδου που χρησιμοποιείται και από " +"τις :func:`getattr` και :func:`super`. Το χαρακτηριστικό είναι δυναμικό και " +"μπορεί να αλλάξει κάθε φορά που ενημερώνεται η ιεραρχία κληρονομικότητας." -#: library/functions.rst:1807 +#: library/functions.rst:1908 msgid "" "If the second argument is omitted, the super object returned is unbound. If " "the second argument is an object, ``isinstance(obj, type)`` must be true. " @@ -3392,7 +3660,7 @@ msgstr "" "είναι ένας τύπος, το ``issubclass(type2, type)`` πρέπει να είναι αληθές " "(αυτό είναι χρήσιμο για μεθόδους κλάσης)." -#: library/functions.rst:1812 +#: library/functions.rst:1913 msgid "" "There are two typical use cases for *super*. In a class hierarchy with " "single inheritance, *super* can be used to refer to parent classes without " @@ -3405,7 +3673,7 @@ msgstr "" "έτσι τον κώδικα πιο διατηρήσιμο. Αυτή η χρήση είναι πολύ παράλληλη με τη " "χρήση του *super* σε άλλες γλώσσες προγραμματισμού." -#: library/functions.rst:1817 +#: library/functions.rst:1918 msgid "" "The second use case is to support cooperative multiple inheritance in a " "dynamic execution environment. This use case is unique to Python and is not " @@ -3429,13 +3697,21 @@ msgstr "" "διάταξη μπορεί να περιλαμβάνει αδερφικές κλάσεις πριν από τον χρόνο " "εκτέλεσης)." -#: library/functions.rst:1827 +#: library/functions.rst:1928 msgid "For both use cases, a typical superclass call looks like this::" msgstr "" "Και για τις δύο περιπτώσεις χρήσης, μια τυπική κλήση υπερκλάσης μοιάζει με " "αυτό::" -#: library/functions.rst:1834 +#: library/functions.rst:1930 +msgid "" +"class C(B):\n" +" def method(self, arg):\n" +" super().method(arg) # This does the same thing as:\n" +" # super(C, self).method(arg)" +msgstr "" + +#: library/functions.rst:1935 msgid "" "In addition to method lookups, :func:`super` also works for attribute " "lookups. One possible use case for this is calling :term:`descriptors " @@ -3445,7 +3721,7 @@ msgstr "" "αναζητήσεις χαρακτηριστικών. Μια πιθανή περίπτωση χρήσης για αυτό είναι η " "κλήση :term:`descriptors ` σε μια κλάση γονέα ή αδελφού." -#: library/functions.rst:1838 +#: library/functions.rst:1939 msgid "" "Note that :func:`super` is implemented as part of the binding process for " "explicit dotted attribute lookups such as ``super().__getitem__(name)``. It " @@ -3455,14 +3731,14 @@ msgid "" "using statements or operators such as ``super()[name]``." msgstr "" "Λάβετε υπόψη ότι το :func:`super` υλοποιείται ως μέρος της διαδικασίας " -"δέσμευσης για ρητές αναζητήσεις χαρακτηριστικών με κουκκίδες όπως ``super()." -"__getitem__(name)``. Το κάνει εφαρμόζοντας τη δικιά του μέθοδο :meth:" -"`~object.__getattribute__` για αναζήτηση κλάσεων με προβλέψιμη σειρά που " -"υποστηρίζει πολλαπλή κληρονομικότητα. Συνεπώς, η :func:`super` δεν έχει " -"οριστεί για σιωπηρές αναζητήσεις που χρησιμοποιούν δηλώσεις ή τελεστές όπως " -"``super()[name]``." +"δέσμευσης για ρητές αναζητήσεις χαρακτηριστικών με κουκκίδες όπως " +"``super().__getitem__(name)``. Το κάνει εφαρμόζοντας τη δικιά του " +"μέθοδο :meth:`~object.__getattribute__` για αναζήτηση κλάσεων με προβλέψιμη " +"σειρά που υποστηρίζει πολλαπλή κληρονομικότητα. Συνεπώς, η :func:`super` δεν " +"έχει οριστεί για σιωπηρές αναζητήσεις που χρησιμοποιούν δηλώσεις ή τελεστές " +"όπως ``super()[name]``." -#: library/functions.rst:1846 +#: library/functions.rst:1947 msgid "" "Also note that, aside from the zero argument form, :func:`super` is not " "limited to use inside methods. The two argument form specifies the " @@ -3471,25 +3747,25 @@ msgid "" "necessary details to correctly retrieve the class being defined, as well as " "accessing the current instance for ordinary methods." msgstr "" -"Λάβετε επίσης υπόψη ότι, εκτός από τη μορφή μηδενικού ορίσματος, η :func:" -"`super` δεν περιορίζεται στη χρήση μεθόδων εντός. Η φόρμα δύο ορισμάτων " -"καθορίζει ακριβώς τα ορίσματα και κάνει τις κατάλληλες αναφορές. Η φόρμα " -"μηδενικού ορίσματος λειτουργεί μόνο μέσα σε έναν ορισμό κλάσης, καθώς ο " -"μεταγλωττιστής συμπληρώνει τις απαραίτητες λεπτομέρειες για την σωστή " -"ανάκτηση της κλάσης που ορίζεται, καθώς και για την πρόσβαση στην τρέχουσα " -"παρουσία για συνηθισμένες μεθόδους." +"Λάβετε επίσης υπόψη ότι, εκτός από τη μορφή μηδενικού ορίσματος, " +"η :func:`super` δεν περιορίζεται στη χρήση μεθόδων εντός. Η φόρμα δύο " +"ορισμάτων καθορίζει ακριβώς τα ορίσματα και κάνει τις κατάλληλες αναφορές. " +"Η φόρμα μηδενικού ορίσματος λειτουργεί μόνο μέσα σε έναν ορισμό κλάσης, " +"καθώς ο μεταγλωττιστής συμπληρώνει τις απαραίτητες λεπτομέρειες για την " +"σωστή ανάκτηση της κλάσης που ορίζεται, καθώς και για την πρόσβαση στην " +"τρέχουσα παρουσία για συνηθισμένες μεθόδους." -#: library/functions.rst:1853 +#: library/functions.rst:1954 msgid "" -"For practical suggestions on how to design cooperative classes using :func:" -"`super`, see `guide to using super() `_." +"For practical suggestions on how to design cooperative classes " +"using :func:`super`, see `guide to using super() `_." msgstr "" "Για πρακτικές προτάσεις σχετικά με το πώς να σχεδιάσετε συνεργατικές τάξεις " "χρησιμοποιώντας το :func:`super`, ανατρέξτε `οδηγός χρήσης super() `_." -#: library/functions.rst:1863 +#: library/functions.rst:1964 msgid "" "Rather than being a function, :class:`tuple` is actually an immutable " "sequence type, as documented in :ref:`typesseq-tuple` and :ref:`typesseq`." @@ -3498,17 +3774,18 @@ msgstr "" "αμετάβλητος τύπος ακολουθίας, όπως τεκμηριώνεται στα :ref:`typesseq-tuple` " "και :ref:`typesseq`." -#: library/functions.rst:1872 +#: library/functions.rst:1973 +#, fuzzy msgid "" "With one argument, return the type of an *object*. The return value is a " -"type object and generally the same object as returned by :attr:`object." -"__class__ `." +"type object and generally the same object as returned " +"by :attr:`object.__class__`." msgstr "" "Με ένα όρισμα, επιστρέψτε τον τύπο ενός *object*. Η τιμή που επιστρέφεται " "είναι ένα αντικείμενο τύπου και γενικά το ίδιο αντικείμενο με αυτό που " "επιστρέφεται από το :attr:`object.__class__ `." -#: library/functions.rst:1876 +#: library/functions.rst:1977 msgid "" "The :func:`isinstance` built-in function is recommended for testing the type " "of an object, because it takes subclasses into account." @@ -3516,34 +3793,46 @@ msgstr "" "Η ενσωματωμένη συνάρτηση :func:`isinstance` συνίσταται για τη δοκιμή του " "τύπου ενός αντικειμένου, επειδή λαμβάνει υπόψη τις υποκλάσεις." -#: library/functions.rst:1880 +#: library/functions.rst:1980 +#, fuzzy msgid "" "With three arguments, return a new type object. This is essentially a " "dynamic form of the :keyword:`class` statement. The *name* string is the " -"class name and becomes the :attr:`~definition.__name__` attribute. The " -"*bases* tuple contains the base classes and becomes the :attr:`~class." -"__bases__` attribute; if empty, :class:`object`, the ultimate base of all " -"classes, is added. The *dict* dictionary contains attribute and method " -"definitions for the class body; it may be copied or wrapped before becoming " -"the :attr:`~object.__dict__` attribute. The following two statements create " -"identical :class:`type` objects:" +"class name and becomes the :attr:`~type.__name__` attribute. The *bases* " +"tuple contains the base classes and becomes the :attr:`~type.__bases__` " +"attribute; if empty, :class:`object`, the ultimate base of all classes, is " +"added. The *dict* dictionary contains attribute and method definitions for " +"the class body; it may be copied or wrapped before becoming " +"the :attr:`~type.__dict__` attribute. The following two statements create " +"identical :class:`!type` objects:" msgstr "" "Με τρία ορίσματα, επιστρέφει ένα αντικείμενο νέου τύπου. Αυτή είναι " "ουσιαστικά μια δυναμική μορφή της δήλωσης :keyword:`class`. Η συμβολοσειρά " -"*name* είναι το όνομα της κλάσης και γίνεται το χαρακτηριστικό :attr:" -"`~definition.__name__`. Η πλειάδα *bases* περιέχει τις βασικές κλάσεις και " -"γίνεται το χαρακτηριστικό :attr:`~class.__bases__` ∙ αν είναι κενό, " -"προστίθεται το :class:`object`, η τελική βάση όλων των κλάσεων. Το λεξικό " -"*dict* περιέχει ορισμούς χαρακτηριστικών και μεθόδων για το σώμα της κλάσης∙ " -"μπορεί να αντιγραφεί ή να προσαρμοστεί πριν γίνει το χαρακτηριστικό :attr:" -"`~object.__dict__`. Οι ακόλουθες δύο προτάσεις δημιουργούν πανομοιότυπα " -"αντικείμενα :class:`type`:" +"*name* είναι το όνομα της κλάσης και γίνεται το " +"χαρακτηριστικό :attr:`~definition.__name__`. Η πλειάδα *bases* περιέχει τις " +"βασικές κλάσεις και γίνεται το χαρακτηριστικό :attr:`~class.__bases__` ∙ αν " +"είναι κενό, προστίθεται το :class:`object`, η τελική βάση όλων των κλάσεων. " +"Το λεξικό *dict* περιέχει ορισμούς χαρακτηριστικών και μεθόδων για το σώμα " +"της κλάσης∙ μπορεί να αντιγραφεί ή να προσαρμοστεί πριν γίνει το " +"χαρακτηριστικό :attr:`~object.__dict__`. Οι ακόλουθες δύο προτάσεις " +"δημιουργούν πανομοιότυπα αντικείμενα :class:`type`:" -#: library/functions.rst:1895 -msgid "See also :ref:`bltin-type-objects`." +#: library/functions.rst:1995 +msgid "See also:" +msgstr "" + +#: library/functions.rst:1997 +msgid "" +":ref:`Documentation on attributes and methods on classes `." +msgstr "" + +#: library/functions.rst:1998 +#, fuzzy +msgid ":ref:`bltin-type-objects`" msgstr "Δείτε επίσης :ref:`bltin-type-objects`." -#: library/functions.rst:1897 +#: library/functions.rst:2000 msgid "" "Keyword arguments provided to the three argument form are passed to the " "appropriate metaclass machinery (usually :meth:`~object.__init_subclass__`) " @@ -3551,46 +3840,51 @@ msgid "" "would." msgstr "" "Τα ορίσματα λέξεων-κλειδιών που παρέχονται στη φόρμα τριών ορισμάτων " -"μεταβιβάζονται στον κατάλληλο μηχανισμό μετακλάσης (συνήθως :meth:`~object." -"__init_subclass__`) με τον ίδιο τρόπο που θα έκαναν οι λέξεις-κλειδιά στον " -"ορισμό μιας κλάσης (εκτός από το *metaclass*)." +"μεταβιβάζονται στον κατάλληλο μηχανισμό μετακλάσης " +"(συνήθως :meth:`~object.__init_subclass__`) με τον ίδιο τρόπο που θα έκαναν " +"οι λέξεις-κλειδιά στον ορισμό μιας κλάσης (εκτός από το *metaclass*)." -#: library/functions.rst:1902 +#: library/functions.rst:2005 msgid "See also :ref:`class-customization`." msgstr "Δείτε επίσης :ref:`class-customization`." -#: library/functions.rst:1904 +#: library/functions.rst:2007 +#, fuzzy msgid "" -"Subclasses of :class:`type` which don't override ``type.__new__`` may no " +"Subclasses of :class:`!type` which don't override ``type.__new__`` may no " "longer use the one-argument form to get the type of an object." msgstr "" "Οι υποκλάσης της :class:`type` που δεν αντικαθιστούν το ``type.__new__`` δεν " "μπορούν πλέον να χρησιμοποιούν τη φόρμα ενός επιχειρήματος για να λάβουν τον " "τύπο ενός αντικειμένου." -#: library/functions.rst:1911 +#: library/functions.rst:2014 +#, fuzzy msgid "" "Return the :attr:`~object.__dict__` attribute for a module, class, instance, " -"or any other object with a :attr:`~object.__dict__` attribute." +"or any other object with a :attr:`!__dict__` attribute." msgstr "" "Επιστρέφει το χαρακτηριστικό :attr:`~object.__dict__` για ένα module, κλάση, " -"instance, ή οποιοδήποτε άλλο αντικείμενο με ένα χαρακτηριστικό :attr:" -"`~object.__dict__`." +"instance, ή οποιοδήποτε άλλο αντικείμενο με ένα " +"χαρακτηριστικό :attr:`~object.__dict__`." -#: library/functions.rst:1914 +#: library/functions.rst:2017 +#, fuzzy msgid "" -"Objects such as modules and instances have an updateable :attr:`~object." -"__dict__` attribute; however, other objects may have write restrictions on " -"their :attr:`~object.__dict__` attributes (for example, classes use a :class:" -"`types.MappingProxyType` to prevent direct dictionary updates)." +"Objects such as modules and instances have an " +"updateable :attr:`~object.__dict__` attribute; however, other objects may " +"have write restrictions on their :attr:`!__dict__` attributes (for example, " +"classes use a :class:`types.MappingProxyType` to prevent direct dictionary " +"updates)." msgstr "" -"Αντικείμενα όπως modules και instances έχουν ένα χαρακτηριστικό :attr:" -"`~object.__dict__` με δυνατότητα ενημέρωσης∙ ωστόσο, άλλα αντικείμενα μπορεί " -"να έχουν περιορισμούς εγγραφής στα χαρακτηριστικά τους :attr:`~object." -"__dict__` (για παράδειγμα, οι κλάσεις χρησιμοποιούν ένα :class:`types." -"MappingProxyType` για την αποτροπή άμεσων ενημερώσεων λεξικού)." +"Αντικείμενα όπως modules και instances έχουν ένα " +"χαρακτηριστικό :attr:`~object.__dict__` με δυνατότητα ενημέρωσης∙ ωστόσο, " +"άλλα αντικείμενα μπορεί να έχουν περιορισμούς εγγραφής στα χαρακτηριστικά " +"τους :attr:`~object.__dict__` (για παράδειγμα, οι κλάσεις χρησιμοποιούν " +"ένα :class:`types.MappingProxyType` για την αποτροπή άμεσων ενημερώσεων " +"λεξικού)." -#: library/functions.rst:1919 +#: library/functions.rst:2022 msgid "" "Without an argument, :func:`vars` acts like :func:`locals`. Note, the " "locals dictionary is only useful for reads since updates to the locals " @@ -3600,7 +3894,7 @@ msgstr "" "Σημειώστε, ότι το λεξικό των τοπικών είναι χρήσιμο μόνο για ανάγνωση, καθώς " "οι ενημερώσεις στο λεξικό των τοπικών αγνοούνται." -#: library/functions.rst:1923 +#: library/functions.rst:2026 msgid "" "A :exc:`TypeError` exception is raised if an object is specified but it " "doesn't have a :attr:`~object.__dict__` attribute (for example, if its class " @@ -3611,7 +3905,7 @@ msgstr "" "παράδειγμα, εάν η κλάση του ορίζει το :attr:`~object.__slots__` " "χαρακτηριστικό)." -#: library/functions.rst:1929 +#: library/functions.rst:2032 msgid "" "Iterate over several iterables in parallel, producing tuples with an item " "from each one." @@ -3619,11 +3913,21 @@ msgstr "" "Επανάληψη σε πολλούς iterables παράλληλα, δημιουργώντας πλειάδες με ένα " "αντικείμενο από το καθένα." -#: library/functions.rst:1932 +#: library/functions.rst:2035 msgid "Example::" msgstr "Παράδειγμα::" -#: library/functions.rst:1941 +#: library/functions.rst:2037 +msgid "" +">>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):\n" +"... print(item)\n" +"...\n" +"(1, 'sugar')\n" +"(2, 'spice')\n" +"(3, 'everything nice')" +msgstr "" + +#: library/functions.rst:2044 msgid "" "More formally: :func:`zip` returns an iterator of tuples, where the *i*-th " "tuple contains the *i*-th element from each of the argument iterables." @@ -3632,27 +3936,27 @@ msgstr "" "πλειάδα περιέχει το *i*-ο στοιχείο από κάθε ένα από τους επαναλήψιμους " "ορισμάτων." -#: library/functions.rst:1944 +#: library/functions.rst:2047 msgid "" "Another way to think of :func:`zip` is that it turns rows into columns, and " -"columns into rows. This is similar to `transposing a matrix `_." +"columns into rows. This is similar to `transposing a matrix `_." msgstr "" "Ένας άλλος τρόπος για να σκεφτείτε τη :func:`zip` είναι ότι μετατρέπει τις " "γραμμές σε στήλες, και τις στήλες σε γραμμές. Αυτό είναι παρόμοιο με " "`μεταφορά μιας μήτρας `_." -#: library/functions.rst:1948 +#: library/functions.rst:2051 msgid "" ":func:`zip` is lazy: The elements won't be processed until the iterable is " -"iterated on, e.g. by a :keyword:`!for` loop or by wrapping in a :class:" -"`list`." +"iterated on, e.g. by a :keyword:`!for` loop or by wrapping in " +"a :class:`list`." msgstr "" "Το :func:`zip` είναι τεμπέλης: Τα στοιχεία δεν θα υποβληθούν σε επεξεργασία " "μέχρι να επαναληφθεί ο iterable, π.χ. με έναν βρόχο :keyword:`!for` ή με " "αναδίπλωση σε μια :class:`list`." -#: library/functions.rst:1952 +#: library/functions.rst:2055 msgid "" "One thing to consider is that the iterables passed to :func:`zip` could have " "different lengths; sometimes by design, and sometimes because of a bug in " @@ -3665,7 +3969,7 @@ msgstr "" "κώδικα που προετοίμασε αυτά τα iterables. Η Python προσφέρει τρεις " "διαφορετικές προσεγγίσεις για την αντιμετώπιση αυτού του ζητήματος::" -#: library/functions.rst:1957 +#: library/functions.rst:2060 msgid "" "By default, :func:`zip` stops when the shortest iterable is exhausted. It " "will ignore the remaining items in the longer iterables, cutting off the " @@ -3675,7 +3979,13 @@ msgstr "" "Αυτό θα αγνοήσει τα υπόλοιπα στοιχεία στους μεγαλύτερους iterables, κόβοντας " "το αποτέλεσμα στο μήκος του συντομότερου iterable::" -#: library/functions.rst:1964 +#: library/functions.rst:2064 +msgid "" +">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" +"[(0, 'fee'), (1, 'fi'), (2, 'fo')]" +msgstr "" + +#: library/functions.rst:2067 msgid "" ":func:`zip` is often used in cases where the iterables are assumed to be of " "equal length. In such cases, it's recommended to use the ``strict=True`` " @@ -3683,18 +3993,24 @@ msgid "" msgstr "" "Η :func:`zip` χρησιμοποιείται συχνά σε περιπτώσεις όπου τα iterables " "υποτίθεται ότι έχουν ίσο μήκος. Σε τέτοιες περιπτώσεις, συνίσταται η χρήση " -"της επιλογής ``strict=True``. Η έξοδος είναι ίδια με την κανονική :func:" -"`zip`::" +"της επιλογής ``strict=True``. Η έξοδος είναι ίδια με την " +"κανονική :func:`zip`::" -#: library/functions.rst:1971 +#: library/functions.rst:2071 +msgid "" +">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" +"[('a', 1), ('b', 2), ('c', 3)]" +msgstr "" + +#: library/functions.rst:2074 msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is exhausted before the others:" msgstr "" -"Σε αντίθεση με την προεπιλεγμένη συμπεριφορά, γίνεται raise ένα :exc:" -"`ValueError` εάν ένα iterable εξαντληθεί πριν από τα άλλα:" +"Σε αντίθεση με την προεπιλεγμένη συμπεριφορά, γίνεται raise " +"ένα :exc:`ValueError` εάν ένα iterable εξαντληθεί πριν από τα άλλα:" -#: library/functions.rst:1989 +#: library/functions.rst:2092 msgid "" "Without the ``strict=True`` argument, any bug that results in iterables of " "different lengths will be silenced, possibly manifesting as a hard-to-find " @@ -3704,17 +4020,17 @@ msgstr "" "μήκη διαφορετικού μήκους θα τεθεί σε σίγαση, πιθανώς να εμφανίζεται ως " "δυσεύρετο σφάλμα σε άλλο μέρος του προγράμματος." -#: library/functions.rst:1993 +#: library/functions.rst:2096 msgid "" "Shorter iterables can be padded with a constant value to make all the " -"iterables have the same length. This is done by :func:`itertools." -"zip_longest`." +"iterables have the same length. This is done " +"by :func:`itertools.zip_longest`." msgstr "" "Οι μικρότεροι iterables μπορούν να συμπληρωθούν σε μια σταθερή τιμή ώστε όλα " -"τα iterables να έχουνε το ίδιο μήκος. Αυτό γίνεται από το :func:`itertools." -"zip_longest`." +"τα iterables να έχουνε το ίδιο μήκος. Αυτό γίνεται από " +"το :func:`itertools.zip_longest`." -#: library/functions.rst:1997 +#: library/functions.rst:2100 msgid "" "Edge cases: With a single iterable argument, :func:`zip` returns an iterator " "of 1-tuples. With no arguments, it returns an empty iterator." @@ -3722,11 +4038,11 @@ msgstr "" "Περιπτώσεις άκρων: Με ένα μόνο επαναληπτικό όρισμα, η :func:`zip` επιστρέφει " "έναν iterator 1-πλειάδων. Χωρίς ορίσματα, επιστρέφει έναν κενό iterator." -#: library/functions.rst:2000 +#: library/functions.rst:2103 msgid "Tips and tricks:" msgstr "Συμβουλές και κόλπα:" -#: library/functions.rst:2002 +#: library/functions.rst:2105 msgid "" "The left-to-right evaluation order of the iterables is guaranteed. This " "makes possible an idiom for clustering a data series into n-length groups " @@ -3742,7 +4058,7 @@ msgstr "" "επαναλήπτη. Αυτό έχει ως αποτέλεσμα τη διαίρεση της εισόδου σε κομμάτια " "μήκους." -#: library/functions.rst:2008 +#: library/functions.rst:2111 msgid "" ":func:`zip` in conjunction with the ``*`` operator can be used to unzip a " "list::" @@ -3750,11 +4066,22 @@ msgstr "" "Η :func:`zip` σε συνδυασμό με τον τελεστή ``*`` μπορεί να χρησιμοποιηθεί για " "την αποσυμπίεση μιας λίστας::" -#: library/functions.rst:2019 +#: library/functions.rst:2114 +msgid "" +">>> x = [1, 2, 3]\n" +">>> y = [4, 5, 6]\n" +">>> list(zip(x, y))\n" +"[(1, 4), (2, 5), (3, 6)]\n" +">>> x2, y2 = zip(*zip(x, y))\n" +">>> x == list(x2) and y == list(y2)\n" +"True" +msgstr "" + +#: library/functions.rst:2122 msgid "Added the ``strict`` argument." msgstr "Προστέθηκε το όρισμα ``strict``." -#: library/functions.rst:2031 +#: library/functions.rst:2134 msgid "" "This is an advanced function that is not needed in everyday Python " "programming, unlike :func:`importlib.import_module`." @@ -3762,7 +4089,7 @@ msgstr "" "Αυτή είναι μια προηγμένη συνάρτηση που δεν χρειάζεται στον καθημερινό " "προγραμματισμό της Python, σε αντίθεση με το :func:`importlib.import_module`." -#: library/functions.rst:2034 +#: library/functions.rst:2137 msgid "" "This function is invoked by the :keyword:`import` statement. It can be " "replaced (by importing the :mod:`builtins` module and assigning to " @@ -3775,15 +4102,15 @@ msgid "" msgstr "" "Αυτή η συνάρτηση καλείται από τη δήλωση :keyword:`import`. Μπορεί να " "αντικατασταθεί (με εισαγωγή του module :mod:`builtins` και αντιστοίχιση σε " -"``builtins.__import__``) προκειμένου να αλλάξει η σημασιολογία της δήλωσης :" -"keyword:`!import`, αλλά αυτό αποθαρρύνεται **σθεναρά**, καθώς είναι συνήθως " -"απλούστερο να χρησιμοποιήσετε τα άγκιστρα εισαγωγής (δείτε :pep:`302`) για " -"την επίτευξη των ίδιων στόχων και δεν προκαλεί προβλήματα με τον κώδικα που " -"προϋποθέτει την χρήση της προεπιλεγμένης υλοποίησης εισαγωγής. Η άμεση " -"χρήση του :func:`__import__` επίσης αποθαρρύνεται υπέρ του :func:`importlib." -"import_module`." +"``builtins.__import__``) προκειμένου να αλλάξει η σημασιολογία της " +"δήλωσης :keyword:`!import`, αλλά αυτό αποθαρρύνεται **σθεναρά**, καθώς είναι " +"συνήθως απλούστερο να χρησιμοποιήσετε τα άγκιστρα εισαγωγής " +"(δείτε :pep:`302`) για την επίτευξη των ίδιων στόχων και δεν προκαλεί " +"προβλήματα με τον κώδικα που προϋποθέτει την χρήση της προεπιλεγμένης " +"υλοποίησης εισαγωγής. Η άμεση χρήση του :func:`__import__` επίσης " +"αποθαρρύνεται υπέρ του :func:`importlib.import_module`." -#: library/functions.rst:2043 +#: library/functions.rst:2146 msgid "" "The function imports the module *name*, potentially using the given " "*globals* and *locals* to determine how to interpret the name in a package " @@ -3800,7 +4127,7 @@ msgstr "" "χρησιμοποιεί τα *globals* της μόνο για να προσδιορίσει το πλαίσιο του " "πακέτου της δήλωσης :keyword:`import`." -#: library/functions.rst:2050 +#: library/functions.rst:2153 msgid "" "*level* specifies whether to use absolute or relative imports. ``0`` (the " "default) means only perform absolute imports. Positive values for *level* " @@ -3814,7 +4141,7 @@ msgstr "" "σε σχέση με τον κατάλογο του module που καλεί την :func:`__import__` (δείτε " "το :pep:`328` για λεπτομέρειες)." -#: library/functions.rst:2056 +#: library/functions.rst:2159 msgid "" "When the *name* variable is of the form ``package.module``, normally, the " "top-level package (the name up till the first dot) is returned, *not* the " @@ -3826,7 +4153,7 @@ msgstr "" "κουκκίδα), *όχι* το module που ονομάζεται *name*. Ωστόσο, όταν δίνεται ένα " "μη κενό όρισμα *fromlist*, επιστρέφεται το module με το όνομα *name*." -#: library/functions.rst:2061 +#: library/functions.rst:2164 msgid "" "For example, the statement ``import spam`` results in bytecode resembling " "the following code::" @@ -3834,11 +4161,19 @@ msgstr "" "Για παράδειγμα, η δήλωση ``import spam`` καταλήγει σε bytecode που μοιάζει " "με τον ακόλουθο κώδικα::" -#: library/functions.rst:2066 +#: library/functions.rst:2167 +msgid "spam = __import__('spam', globals(), locals(), [], 0)" +msgstr "" + +#: library/functions.rst:2169 msgid "The statement ``import spam.ham`` results in this call::" msgstr "Η δήλωση ``import spam.ham`` καταλήγει σε αυτήν την κλήση::" -#: library/functions.rst:2070 +#: library/functions.rst:2171 +msgid "spam = __import__('spam.ham', globals(), locals(), [], 0)" +msgstr "" + +#: library/functions.rst:2173 msgid "" "Note how :func:`__import__` returns the toplevel module here because this is " "the object that is bound to a name by the :keyword:`import` statement." @@ -3847,7 +4182,7 @@ msgstr "" "εδώ, επειδή αυτό είναι το αντικείμενο που συνδέεται με ένα όνομα με τη " "δήλωση :keyword:`import`." -#: library/functions.rst:2073 +#: library/functions.rst:2176 msgid "" "On the other hand, the statement ``from spam.ham import eggs, sausage as " "saus`` results in ::" @@ -3855,7 +4190,14 @@ msgstr "" "Από την άλλη πλευρά, η δήλωση ``from spam.ham import eggs, sausage as saus`` " "καταλήγει σε ::" -#: library/functions.rst:2080 +#: library/functions.rst:2179 +msgid "" +"_temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], 0)\n" +"eggs = _temp.eggs\n" +"saus = _temp.sausage" +msgstr "" + +#: library/functions.rst:2183 msgid "" "Here, the ``spam.ham`` module is returned from :func:`__import__`. From " "this object, the names to import are retrieved and assigned to their " @@ -3865,7 +4207,7 @@ msgstr "" "αυτό το αντικείμενο, τα ονόματα προς εισαγωγή ανακτώνται και εκχωρούνται στα " "αντίστοιχα ονόματά τους." -#: library/functions.rst:2084 +#: library/functions.rst:2187 msgid "" "If you simply want to import a module (potentially within a package) by " "name, use :func:`importlib.import_module`." @@ -3873,7 +4215,7 @@ msgstr "" "Εάν θέλετε απλώς να εισάγετε ένα module (ενδεχομένως μέσα σε ένα πακέτο) με " "το όνομα, χρησιμοποιήστε το :func:`importlib.import_module`." -#: library/functions.rst:2087 +#: library/functions.rst:2190 msgid "" "Negative values for *level* are no longer supported (which also changes the " "default value to 0)." @@ -3881,7 +4223,7 @@ msgstr "" "Αρνητικές τιμές για το *level* δεν υποστηρίζονται πλέον (το οποίο επίσης " "αλλάζει την προεπιλεγμένη τιμή σε 0)." -#: library/functions.rst:2091 +#: library/functions.rst:2194 msgid "" "When the command line options :option:`-E` or :option:`-I` are being used, " "the environment variable :envvar:`PYTHONCASEOK` is now ignored." @@ -3890,11 +4232,11 @@ msgstr "" "I`, τότε η μεταβλητή περιβάλλοντος :envvar:`PYTHONCASEOK` δεν λαμβάνεται " "υπόψιν." -#: library/functions.rst:2096 +#: library/functions.rst:2199 msgid "Footnotes" msgstr "Υποσημειώσεις" -#: library/functions.rst:2097 +#: library/functions.rst:2200 msgid "" "Note that the parser only accepts the Unix-style end of line convention. If " "you are reading the code from a file, make sure to use newline conversion " @@ -3905,110 +4247,187 @@ msgstr "" "την λειτουργία μετατροπής νέας γραμμής για την μετατροπή νέων γραμμών σε " "στυλ Windows ή Mac." -#: library/functions.rst:153 +#: library/functions.rst:154 msgid "Boolean" msgstr "Boolean" -#: library/functions.rst:1870 +#: library/functions.rst:1971 msgid "type" msgstr "τύπος" -#: library/functions.rst:576 +#: library/functions.rst:638 msgid "built-in function" msgstr "ενσωματωμένη συνάρτηση" -#: library/functions.rst:576 +#: library/functions.rst:638 msgid "exec" msgstr "exec" -#: library/functions.rst:653 +#: library/functions.rst:725 msgid "NaN" msgstr "NaN" -#: library/functions.rst:653 +#: library/functions.rst:725 msgid "Infinity" msgstr "Άπειρο" -#: library/functions.rst:717 +#: library/functions.rst:793 msgid "__format__" msgstr "__format__" -#: library/functions.rst:1754 +#: library/functions.rst:1855 msgid "string" msgstr "string" -#: library/functions.rst:717 +#: library/functions.rst:793 msgid "format() (built-in function)" msgstr "format() (ενσωματωμένη συνάρτηση)" -#: library/functions.rst:1165 +#: library/functions.rst:1262 msgid "file object" msgstr "αντικείμενο αρχείου" -#: library/functions.rst:1286 +#: library/functions.rst:1383 msgid "open() built-in function" msgstr "open() ενσωματωμένη συνάρτηση" -#: library/functions.rst:1193 +#: library/functions.rst:1290 msgid "file" msgstr "αρχείο" -#: library/functions.rst:1193 +#: library/functions.rst:1290 msgid "modes" msgstr "λειτουργίες" -#: library/functions.rst:1286 +#: library/functions.rst:1383 msgid "universal newlines" msgstr "καθολικές νέες γραμμές" -#: library/functions.rst:1347 +#: library/functions.rst:1444 msgid "line-buffered I/O" msgstr "γραμμική προσωρινή μνήμη I/O" -#: library/functions.rst:1347 +#: library/functions.rst:1444 msgid "unbuffered I/O" msgstr "unbuffered I/O" -#: library/functions.rst:1347 +#: library/functions.rst:1444 msgid "buffer size, I/O" msgstr "μέγεθος bugger, I/O" -#: library/functions.rst:1347 +#: library/functions.rst:1444 msgid "I/O control" msgstr "Έλεγχος I/O" -#: library/functions.rst:1347 +#: library/functions.rst:1444 msgid "buffering" msgstr "buffering" -#: library/functions.rst:1347 +#: library/functions.rst:1444 msgid "text mode" msgstr "λειτουργία κειμένου" -#: library/functions.rst:2025 +#: library/functions.rst:2128 msgid "module" msgstr "module" -#: library/functions.rst:1347 +#: library/functions.rst:1444 msgid "sys" msgstr "sys" -#: library/functions.rst:1754 +#: library/functions.rst:1855 msgid "str() (built-in function)" msgstr "str() (ενσωματωμένη συνάρτηση)" -#: library/functions.rst:1870 +#: library/functions.rst:1971 msgid "object" msgstr "αντικείμενο" -#: library/functions.rst:2025 +#: library/functions.rst:2128 msgid "statement" msgstr "δήλωση" -#: library/functions.rst:2025 +#: library/functions.rst:2128 msgid "import" msgstr "import" -#: library/functions.rst:2025 +#: library/functions.rst:2128 msgid "builtins" msgstr "builtins" + +#~ msgid "" +#~ "Raises an :ref:`auditing event ` ``compile`` with arguments " +#~ "``source``, ``filename``." +#~ msgstr "" +#~ "Εγείρει ένα :ref:`auditing event ` ``compile`` με ορίσματα " +#~ "``source``, ``filename``." + +#~ msgid "" +#~ "Return a complex number with the value *real* + *imag*\\*1j or convert a " +#~ "string or number to a complex number. If the first parameter is a " +#~ "string, it will be interpreted as a complex number and the function must " +#~ "be called without a second parameter. The second parameter can never be " +#~ "a string. Each argument may be any numeric type (including complex). If " +#~ "*imag* is omitted, it defaults to zero and the constructor serves as a " +#~ "numeric conversion like :class:`int` and :class:`float`. If both " +#~ "arguments are omitted, returns ``0j``." +#~ msgstr "" +#~ "Επιστρέφει έναν μιγαδικό αριθμό με τιμή *real* + *imag*\\*1j ή μετατρέπει " +#~ "μια συμβολοσειρά ή έναν αριθμό σε μιγαδικό αριθμό. Εάν η πρώτη " +#~ "παράμετρος είναι συμβολοσειρά, θα ερμηνευτεί ως μιγαδικός αριθμός και η " +#~ "συνάρτηση θα πρέπει να καλεστεί χωρίς δεύτερη παράμετρος. Η δεύτερη " +#~ "παράμετρος δεν μπορεί ποτέ να είναι μια συμβολοσειρά. Κάθε όρισμα μπορεί " +#~ "να είναι οποιουδήποτε αριθμητικού τύπου (συμπεριλαμβανομένου του " +#~ "μιγαδικού). Εάν το *imag* παραλειφθεί, είναι μηδέν από προεπιλογή, και ο " +#~ "constructor χρησιμεύει ως αριθμητική μετατροπή όπως :class:`int` " +#~ "και :class:`float`. Εάν παραληφθούν και τα δύο ορίσματα, επιστρέφει το " +#~ "``0j``." + +#~ msgid "" +#~ "When converting from a string, the string must not contain whitespace " +#~ "around the central ``+`` or ``-`` operator. For example, " +#~ "``complex('1+2j')`` is fine, but ``complex('1 + 2j')`` " +#~ "raises :exc:`ValueError`." +#~ msgstr "" +#~ "Κατά την μετατροπή από μια συμβολοσειρά, η συμβολοσειρά δεν πρέπει να " +#~ "περιέχει κενό διάστημα γύρω από τον κεντρικό τελεστή ``+`` ή ``-``. Για " +#~ "παράδειγμα, ``complex('1+2j')`` είναι εντάξει, αλλά το ``complex('1 + " +#~ "2j')`` κάνει raise την :exc:`ValueError`." + +#~ msgid "" +#~ "The arguments are a string and optional globals and locals. If provided, " +#~ "*globals* must be a dictionary. If provided, *locals* can be any mapping " +#~ "object." +#~ msgstr "" +#~ "Τα ορίσματα είναι μια συμβολοσειρά (string), και προαιρετικά globals και " +#~ "locals. Εάν παρέχεται το *globals* πρέπει να είναι λεξικό. Εάν " +#~ "παρέχεται το *locals* μπορεί να είναι οποιοδήποτε αντικείμενο " +#~ "χαρτογράφησης." + +#~ msgid "" +#~ "The return value is the result of the evaluated expression. Syntax errors " +#~ "are reported as exceptions. Example:" +#~ msgstr "" +#~ "Η τιμή που επιστρέφεται είναι το αποτέλεσμα της αξιολογούμενης έκφρασης. " +#~ "Τα σφάλματα σύνταξης αναφέρονται ως εξαιρέσεις. Παράδειγμα:" + +#~ msgid "" +#~ "Raises an :ref:`auditing event ` ``exec`` with argument " +#~ "``code_object``." +#~ msgstr "" +#~ "Κάνει raise ένα :ref:`auditing event ` ``exec`` με όρισμα " +#~ "``code_object``." + +#~ msgid "" +#~ "Raises an :ref:`auditing event ` ``builtins.input`` with " +#~ "argument ``prompt``." +#~ msgstr "" +#~ "Κάνει raise ένα :ref:`auditing event ` ``builtins.input`` με " +#~ "όρισμα ``prompt``." + +#~ msgid "" +#~ "Raises an :ref:`auditing event ` ``builtins.input/result`` with " +#~ "argument ``result``." +#~ msgstr "" +#~ "Κάνει raise ένα :ref:`auditing event ` ``builtins.input/" +#~ "result`` με όρισμα ``result``." diff --git a/library/functools.po b/library/functools.po index d02b519f..ef34e4a1 100644 --- a/library/functools.po +++ b/library/functools.po @@ -8,17 +8,18 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/functools.rst:2 msgid "" -":mod:`functools` --- Higher-order functions and operations on callable " +":mod:`!functools` --- Higher-order functions and operations on callable " "objects" msgstr "" @@ -47,14 +48,30 @@ msgstr "" msgid "" "Returns the same as ``lru_cache(maxsize=None)``, creating a thin wrapper " "around a dictionary lookup for the function arguments. Because it never " -"needs to evict old values, this is smaller and faster than :func:" -"`lru_cache()` with a size limit." +"needs to evict old values, this is smaller and faster than :func:`lru_cache` " +"with a size limit." msgstr "" #: library/functools.rst:291 msgid "For example::" msgstr "" +#: library/functools.rst:41 +msgid "" +"@cache\n" +"def factorial(n):\n" +" return n * factorial(n-1) if n else 1\n" +"\n" +">>> factorial(10) # no previously cached result, makes 11 recursive " +"calls\n" +"3628800\n" +">>> factorial(5) # just looks up cached value result\n" +"120\n" +">>> factorial(12) # makes two new recursive calls, the other 10 are " +"cached\n" +"479001600" +msgstr "" + #: library/functools.rst:158 msgid "" "The cache is threadsafe so that the wrapped function can be used in multiple " @@ -81,11 +98,23 @@ msgstr "" msgid "Example::" msgstr "" +#: library/functools.rst:72 +msgid "" +"class DataSet:\n" +"\n" +" def __init__(self, sequence_of_numbers):\n" +" self._data = tuple(sequence_of_numbers)\n" +"\n" +" @cached_property\n" +" def stdev(self):\n" +" return statistics.stdev(self._data)" +msgstr "" + #: library/functools.rst:81 msgid "" -"The mechanics of :func:`cached_property` are somewhat different from :func:" -"`property`. A regular property blocks attribute writes unless a setter is " -"defined. In contrast, a *cached_property* allows writes." +"The mechanics of :func:`cached_property` are somewhat different " +"from :func:`property`. A regular property blocks attribute writes unless a " +"setter is defined. In contrast, a *cached_property* allows writes." msgstr "" #: library/functools.rst:85 @@ -136,8 +165,8 @@ msgid "" "If a mutable mapping is not available or if space-efficient key sharing is " "desired, an effect similar to :func:`cached_property` can also be achieved " "by stacking :func:`property` on top of :func:`lru_cache`. See :ref:`faq-" -"cache-method-calls` for more details on how this differs from :func:" -"`cached_property`." +"cache-method-calls` for more details on how this differs " +"from :func:`cached_property`." msgstr "" #: library/functools.rst:120 @@ -152,11 +181,10 @@ msgstr "" #: library/functools.rst:130 msgid "" "Transform an old-style comparison function to a :term:`key function`. Used " -"with tools that accept key functions (such as :func:`sorted`, :func:`min`, :" -"func:`max`, :func:`heapq.nlargest`, :func:`heapq.nsmallest`, :func:" -"`itertools.groupby`). This function is primarily used as a transition tool " -"for programs being converted from Python 2 which supported the use of " -"comparison functions." +"with tools that accept key functions (such " +"as :func:`sorted`, :func:`min`, :func:`max`, :func:`heapq.nlargest`, :func:`heapq.nsmallest`, :func:`itertools.groupby`). " +"This function is primarily used as a transition tool for programs being " +"converted from Python 2 which supported the use of comparison functions." msgstr "" #: library/functools.rst:137 @@ -167,6 +195,11 @@ msgid "" "one argument and returns another value to be used as the sort key." msgstr "" +#: library/functools.rst:144 +msgid "" +"sorted(iterable, key=cmp_to_key(locale.strcoll)) # locale-aware sort order" +msgstr "" + #: library/functools.rst:146 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." @@ -200,6 +233,13 @@ msgid "" "*maxsize* at its default value of 128::" msgstr "" +#: library/functools.rst:178 +msgid "" +"@lru_cache\n" +"def count_vowels(sentence):\n" +" return sum(sentence.count(vowel) for vowel in 'AEIOUaeiou')" +msgstr "" + #: library/functools.rst:182 msgid "" "If *maxsize* is set to ``None``, the LRU feature is disabled and the cache " @@ -247,9 +287,9 @@ msgstr "" #: library/functools.rst:210 msgid "" -"The original underlying function is accessible through the :attr:" -"`__wrapped__` attribute. This is useful for introspection, for bypassing " -"the cache, or for rewrapping the function with a different cache." +"The original underlying function is accessible through " +"the :attr:`__wrapped__` attribute. This is useful for introspection, for " +"bypassing the cache, or for rewrapping the function with a different cache." msgstr "" #: library/functools.rst:214 @@ -267,7 +307,7 @@ msgstr "" #: library/functools.rst:220 msgid "" "An `LRU (least recently used) cache `_ works best when the " +"Cache_replacement_policies#Least_Recently_Used_(LRU)>`_ works best when the " "most recent calls are the best predictors of upcoming calls (for example, " "the most popular articles on a news server tend to change each day). The " "cache's size limit assures that the cache does not grow without bound on " @@ -287,11 +327,47 @@ msgstr "" msgid "Example of an LRU cache for static web content::" msgstr "" +#: library/functools.rst:235 +msgid "" +"@lru_cache(maxsize=32)\n" +"def get_pep(num):\n" +" 'Retrieve text of a Python Enhancement Proposal'\n" +" resource = f'https://peps.python.org/pep-{num:04d}'\n" +" try:\n" +" with urllib.request.urlopen(resource) as s:\n" +" return s.read()\n" +" except urllib.error.HTTPError:\n" +" return 'Not Found'\n" +"\n" +">>> for n in 8, 290, 308, 320, 8, 218, 320, 279, 289, 320, 9991:\n" +"... pep = get_pep(n)\n" +"... print(n, len(pep))\n" +"\n" +">>> get_pep.cache_info()\n" +"CacheInfo(hits=3, misses=8, maxsize=32, currsize=8)" +msgstr "" + #: library/functools.rst:252 msgid "" -"Example of efficiently computing `Fibonacci numbers `_ using a cache to implement a `dynamic " -"programming `_ technique::" +"Example of efficiently computing `Fibonacci numbers `_ using a cache to implement a " +"`dynamic programming `_ " +"technique::" +msgstr "" + +#: library/functools.rst:258 +msgid "" +"@lru_cache(maxsize=None)\n" +"def fib(n):\n" +" if n < 2:\n" +" return n\n" +" return fib(n-1) + fib(n-2)\n" +"\n" +">>> [fib(n) for n in range(16)]\n" +"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]\n" +"\n" +">>> fib.cache_info()\n" +"CacheInfo(hits=28, misses=16, maxsize=None, currsize=16)" msgstr "" #: library/functools.rst:272 @@ -320,6 +396,25 @@ msgid "" "method." msgstr "" +#: library/functools.rst:293 +msgid "" +"@total_ordering\n" +"class Student:\n" +" def _is_valid_operand(self, other):\n" +" return (hasattr(other, \"lastname\") and\n" +" hasattr(other, \"firstname\"))\n" +" def __eq__(self, other):\n" +" if not self._is_valid_operand(other):\n" +" return NotImplemented\n" +" return ((self.lastname.lower(), self.firstname.lower()) ==\n" +" (other.lastname.lower(), other.firstname.lower()))\n" +" def __lt__(self, other):\n" +" if not self._is_valid_operand(other):\n" +" return NotImplemented\n" +" return ((self.lastname.lower(), self.firstname.lower()) <\n" +" (other.lastname.lower(), other.firstname.lower()))" +msgstr "" + #: library/functools.rst:311 msgid "" "While this decorator makes it easy to create well behaved totally ordered " @@ -339,7 +434,7 @@ msgstr "" #: library/functools.rst:327 msgid "" -"Returning NotImplemented from the underlying comparison function for " +"Returning ``NotImplemented`` from the underlying comparison function for " "unrecognised types is now supported." msgstr "" @@ -352,6 +447,18 @@ msgid "" "extend and override *keywords*. Roughly equivalent to::" msgstr "" +#: library/functools.rst:340 +msgid "" +"def partial(func, /, *args, **keywords):\n" +" def newfunc(*fargs, **fkeywords):\n" +" newkeywords = {**keywords, **fkeywords}\n" +" return func(*args, *fargs, **newkeywords)\n" +" newfunc.func = func\n" +" newfunc.args = args\n" +" newfunc.keywords = keywords\n" +" return newfunc" +msgstr "" + #: library/functools.rst:349 msgid "" "The :func:`partial` is used for partial function application which " @@ -363,9 +470,9 @@ msgstr "" #: library/functools.rst:364 msgid "" -"Return a new :class:`partialmethod` descriptor which behaves like :class:" -"`partial` except that it is designed to be used as a method definition " -"rather than being directly callable." +"Return a new :class:`partialmethod` descriptor which behaves " +"like :class:`partial` except that it is designed to be used as a method " +"definition rather than being directly callable." msgstr "" #: library/functools.rst:368 @@ -376,11 +483,11 @@ msgstr "" #: library/functools.rst:371 msgid "" -"When *func* is a descriptor (such as a normal Python function, :func:" -"`classmethod`, :func:`staticmethod`, :func:`abstractmethod` or another " -"instance of :class:`partialmethod`), calls to ``__get__`` are delegated to " -"the underlying descriptor, and an appropriate :ref:`partial object` returned as the result." +"When *func* is a descriptor (such as a normal Python " +"function, :func:`classmethod`, :func:`staticmethod`, :func:`abstractmethod` " +"or another instance of :class:`partialmethod`), calls to ``__get__`` are " +"delegated to the underlying descriptor, and an appropriate :ref:`partial " +"object` returned as the result." msgstr "" #: library/functools.rst:377 @@ -388,8 +495,29 @@ msgid "" "When *func* is a non-descriptor callable, an appropriate bound method is " "created dynamically. This behaves like a normal Python function when used as " "a method: the *self* argument will be inserted as the first positional " -"argument, even before the *args* and *keywords* supplied to the :class:" -"`partialmethod` constructor." +"argument, even before the *args* and *keywords* supplied to " +"the :class:`partialmethod` constructor." +msgstr "" + +#: library/functools.rst:385 +msgid "" +">>> class Cell:\n" +"... def __init__(self):\n" +"... self._alive = False\n" +"... @property\n" +"... def alive(self):\n" +"... return self._alive\n" +"... def set_state(self, state):\n" +"... self._alive = bool(state)\n" +"... set_alive = partialmethod(set_state, True)\n" +"... set_dead = partialmethod(set_state, False)\n" +"...\n" +">>> c = Cell()\n" +">>> c.alive\n" +"False\n" +">>> c.set_alive()\n" +">>> c.alive\n" +"True" msgstr "" #: library/functools.rst:408 @@ -409,6 +537,19 @@ msgstr "" msgid "Roughly equivalent to::" msgstr "" +#: library/functools.rst:419 +msgid "" +"def reduce(function, iterable, initializer=None):\n" +" it = iter(iterable)\n" +" if initializer is None:\n" +" value = next(it)\n" +" else:\n" +" value = initializer\n" +" for element in it:\n" +" value = function(value, element)\n" +" return value" +msgstr "" + #: library/functools.rst:429 msgid "" "See :func:`itertools.accumulate` for an iterator that yields all " @@ -417,8 +558,8 @@ msgstr "" #: library/functools.rst:434 msgid "" -"Transform a function into a :term:`single-dispatch ` :term:" -"`generic function`." +"Transform a function into a :term:`single-dispatch ` :term:`generic function`." msgstr "" #: library/functools.rst:437 @@ -428,6 +569,16 @@ msgid "" "dispatch happens on the type of the first argument::" msgstr "" +#: library/functools.rst:441 +msgid "" +">>> from functools import singledispatch\n" +">>> @singledispatch\n" +"... def fun(arg, verbose=False):\n" +"... if verbose:\n" +"... print(\"Let me just say,\", end=\" \")\n" +"... print(arg)" +msgstr "" + #: library/functools.rst:448 msgid "" "To add overloaded implementations to the function, use the :func:`register` " @@ -436,80 +587,225 @@ msgid "" "first argument automatically::" msgstr "" +#: library/functools.rst:453 +msgid "" +">>> @fun.register\n" +"... def _(arg: int, verbose=False):\n" +"... if verbose:\n" +"... print(\"Strength in numbers, eh?\", end=\" \")\n" +"... print(arg)\n" +"...\n" +">>> @fun.register\n" +"... def _(arg: list, verbose=False):\n" +"... if verbose:\n" +"... print(\"Enumerate this:\")\n" +"... for i, elem in enumerate(arg):\n" +"... print(i, elem)" +msgstr "" + #: library/functools.rst:466 msgid ":data:`types.UnionType` and :data:`typing.Union` can also be used::" msgstr "" +#: library/functools.rst:468 +msgid "" +">>> @fun.register\n" +"... def _(arg: int | float, verbose=False):\n" +"... if verbose:\n" +"... print(\"Strength in numbers, eh?\", end=\" \")\n" +"... print(arg)\n" +"...\n" +">>> from typing import Union\n" +">>> @fun.register\n" +"... def _(arg: Union[list, set], verbose=False):\n" +"... if verbose:\n" +"... print(\"Enumerate this:\")\n" +"... for i, elem in enumerate(arg):\n" +"... print(i, elem)\n" +"..." +msgstr "" + #: library/functools.rst:483 msgid "" "For code which doesn't use type annotations, the appropriate type argument " "can be passed explicitly to the decorator itself::" msgstr "" -#: library/functools.rst:494 +#: library/functools.rst:486 +msgid "" +">>> @fun.register(complex)\n" +"... def _(arg, verbose=False):\n" +"... if verbose:\n" +"... print(\"Better than complicated.\", end=\" \")\n" +"... print(arg.real, arg.imag)\n" +"..." +msgstr "" + +#: library/functools.rst:493 +msgid "" +"For code that dispatches on a collections type (e.g., ``list``), but wants " +"to typehint the items of the collection (e.g., ``list[int]``), the dispatch " +"type should be passed explicitly to the decorator itself with the typehint " +"going into the function definition::" +msgstr "" + +#: library/functools.rst:498 +msgid "" +">>> @fun.register(list)\n" +"... def _(arg: list[int], verbose=False):\n" +"... if verbose:\n" +"... print(\"Enumerate this:\")\n" +"... for i, elem in enumerate(arg):\n" +"... print(i, elem)" +msgstr "" + +#: library/functools.rst:507 +msgid "" +"At runtime the function will dispatch on an instance of a list regardless of " +"the type contained within the list i.e. ``[1,2,3]`` will be dispatched the " +"same as ``[\"foo\", \"bar\", \"baz\"]``. The annotation provided in this " +"example is for static type checkers only and has no runtime impact." +msgstr "" + +#: library/functools.rst:513 msgid "" "To enable registering :term:`lambdas` and pre-existing functions, " "the :func:`register` attribute can also be used in a functional form::" msgstr "" -#: library/functools.rst:502 +#: library/functools.rst:516 +msgid "" +">>> def nothing(arg, verbose=False):\n" +"... print(\"Nothing.\")\n" +"...\n" +">>> fun.register(type(None), nothing)" +msgstr "" + +#: library/functools.rst:521 msgid "" "The :func:`register` attribute returns the undecorated function. This " "enables decorator stacking, :mod:`pickling`, and the creation of " "unit tests for each variant independently::" msgstr "" -#: library/functools.rst:516 +#: library/functools.rst:525 +msgid "" +">>> @fun.register(float)\n" +"... @fun.register(Decimal)\n" +"... def fun_num(arg, verbose=False):\n" +"... if verbose:\n" +"... print(\"Half of your number:\", end=\" \")\n" +"... print(arg / 2)\n" +"...\n" +">>> fun_num is fun\n" +"False" +msgstr "" + +#: library/functools.rst:535 msgid "" "When called, the generic function dispatches on the type of the first " "argument::" msgstr "" -#: library/functools.rst:536 +#: library/functools.rst:538 +msgid "" +">>> fun(\"Hello, world.\")\n" +"Hello, world.\n" +">>> fun(\"test.\", verbose=True)\n" +"Let me just say, test.\n" +">>> fun(42, verbose=True)\n" +"Strength in numbers, eh? 42\n" +">>> fun(['spam', 'spam', 'eggs', 'spam'], verbose=True)\n" +"Enumerate this:\n" +"0 spam\n" +"1 spam\n" +"2 eggs\n" +"3 spam\n" +">>> fun(None)\n" +"Nothing.\n" +">>> fun(1.23)\n" +"0.615" +msgstr "" + +#: library/functools.rst:555 msgid "" "Where there is no registered implementation for a specific type, its method " "resolution order is used to find a more generic implementation. The original " -"function decorated with ``@singledispatch`` is registered for the base :" -"class:`object` type, which means it is used if no better implementation is " -"found." +"function decorated with ``@singledispatch`` is registered for the " +"base :class:`object` type, which means it is used if no better " +"implementation is found." msgstr "" -#: library/functools.rst:542 +#: library/functools.rst:561 msgid "" "If an implementation is registered to an :term:`abstract base class`, " "virtual subclasses of the base class will be dispatched to that " "implementation::" msgstr "" -#: library/functools.rst:557 +#: library/functools.rst:565 +msgid "" +">>> from collections.abc import Mapping\n" +">>> @fun.register\n" +"... def _(arg: Mapping, verbose=False):\n" +"... if verbose:\n" +"... print(\"Keys & Values\")\n" +"... for key, value in arg.items():\n" +"... print(key, \"=>\", value)\n" +"...\n" +">>> fun({\"a\": \"b\"})\n" +"a => b" +msgstr "" + +#: library/functools.rst:576 msgid "" "To check which implementation the generic function will choose for a given " "type, use the ``dispatch()`` attribute::" msgstr "" -#: library/functools.rst:565 +#: library/functools.rst:579 +msgid "" +">>> fun.dispatch(float)\n" +"\n" +">>> fun.dispatch(dict) # note: default implementation\n" +"" +msgstr "" + +#: library/functools.rst:584 msgid "" "To access all registered implementations, use the read-only ``registry`` " "attribute::" msgstr "" -#: library/functools.rst:579 +#: library/functools.rst:587 +msgid "" +">>> fun.registry.keys()\n" +"dict_keys([, , ,\n" +" , ,\n" +" ])\n" +">>> fun.registry[float]\n" +"\n" +">>> fun.registry[object]\n" +"" +msgstr "" + +#: library/functools.rst:598 msgid "The :func:`register` attribute now supports using type annotations." msgstr "" -#: library/functools.rst:582 +#: library/functools.rst:601 msgid "" -"The :func:`register` attribute now supports :data:`types.UnionType` and :" -"data:`typing.Union` as type annotations." +"The :func:`register` attribute now supports :data:`types.UnionType` " +"and :data:`typing.Union` as type annotations." msgstr "" -#: library/functools.rst:589 +#: library/functools.rst:608 msgid "" -"Transform a method into a :term:`single-dispatch ` :term:" -"`generic function`." +"Transform a method into a :term:`single-dispatch ` :term:`generic function`." msgstr "" -#: library/functools.rst:592 +#: library/functools.rst:611 msgid "" "To define a generic method, decorate it with the ``@singledispatchmethod`` " "decorator. When defining a function using ``@singledispatchmethod``, note " @@ -517,23 +813,58 @@ msgid "" "argument::" msgstr "" -#: library/functools.rst:610 +#: library/functools.rst:616 +msgid "" +"class Negator:\n" +" @singledispatchmethod\n" +" def neg(self, arg):\n" +" raise NotImplementedError(\"Cannot negate a\")\n" +"\n" +" @neg.register\n" +" def _(self, arg: int):\n" +" return -arg\n" +"\n" +" @neg.register\n" +" def _(self, arg: bool):\n" +" return not arg" +msgstr "" + +#: library/functools.rst:629 +msgid "" +"``@singledispatchmethod`` supports nesting with other decorators such " +"as :func:`@classmethod`. Note that to allow for " +"``dispatcher.register``, ``singledispatchmethod`` must be the *outer most* " +"decorator. Here is the ``Negator`` class with the ``neg`` methods bound to " +"the class, rather than an instance of the class::" +msgstr "" + +#: library/functools.rst:635 msgid "" -"``@singledispatchmethod`` supports nesting with other decorators such as :" -"func:`@classmethod`. Note that to allow for ``dispatcher." -"register``, ``singledispatchmethod`` must be the *outer most* decorator. " -"Here is the ``Negator`` class with the ``neg`` methods bound to the class, " -"rather than an instance of the class::" +"class Negator:\n" +" @singledispatchmethod\n" +" @classmethod\n" +" def neg(cls, arg):\n" +" raise NotImplementedError(\"Cannot negate a\")\n" +"\n" +" @neg.register\n" +" @classmethod\n" +" def _(cls, arg: int):\n" +" return -arg\n" +"\n" +" @neg.register\n" +" @classmethod\n" +" def _(cls, arg: bool):\n" +" return not arg" msgstr "" -#: library/functools.rst:632 +#: library/functools.rst:651 msgid "" -"The same pattern can be used for other similar decorators: :func:" -"`@staticmethod`, :func:`@abstractmethod`, " +"The same pattern can be used for other similar " +"decorators: :func:`@staticmethod`, :func:`@abstractmethod`, " "and others." msgstr "" -#: library/functools.rst:641 +#: library/functools.rst:660 msgid "" "Update a *wrapper* function to look like the *wrapped* function. The " "optional arguments are tuples to specify which attributes of the original " @@ -541,13 +872,14 @@ msgid "" "function and which attributes of the wrapper function are updated with the " "corresponding attributes from the original function. The default values for " "these arguments are the module level constants ``WRAPPER_ASSIGNMENTS`` " -"(which assigns to the wrapper function's ``__module__``, ``__name__``, " -"``__qualname__``, ``__annotations__`` and ``__doc__``, the documentation " -"string) and ``WRAPPER_UPDATES`` (which updates the wrapper function's " -"``__dict__``, i.e. the instance dictionary)." +"(which assigns to the wrapper " +"function's :attr:`~function.__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :attr:`~function.__annotations__`, :attr:`~function.__type_params__`, " +"and :attr:`~function.__doc__`, the documentation string) and " +"``WRAPPER_UPDATES`` (which updates the wrapper " +"function's :attr:`~function.__dict__`, i.e. the instance dictionary)." msgstr "" -#: library/functools.rst:651 +#: library/functools.rst:672 msgid "" "To allow access to the original function for introspection and other " "purposes (e.g. bypassing a caching decorator such as :func:`lru_cache`), " @@ -555,7 +887,7 @@ msgid "" "that refers to the function being wrapped." msgstr "" -#: library/functools.rst:656 +#: library/functools.rst:677 msgid "" "The main intended use for this function is in :term:`decorator` functions " "which wrap the decorated function and return the wrapper. If the wrapper " @@ -564,7 +896,7 @@ msgid "" "is typically less than helpful." msgstr "" -#: library/functools.rst:662 +#: library/functools.rst:683 msgid "" ":func:`update_wrapper` may be used with callables other than functions. Any " "attributes named in *assigned* or *updated* that are missing from the object " @@ -573,21 +905,26 @@ msgid "" "wrapper function itself is missing any attributes named in *updated*." msgstr "" -#: library/functools.rst:668 +#: library/functools.rst:689 msgid "" -"The ``__wrapped__`` attribute is now automatically added. The " -"``__annotations__`` attribute is now copied by default. Missing attributes " -"no longer trigger an :exc:`AttributeError`." +"The ``__wrapped__`` attribute is now automatically added. " +"The :attr:`~function.__annotations__` attribute is now copied by default. " +"Missing attributes no longer trigger an :exc:`AttributeError`." msgstr "" -#: library/functools.rst:673 +#: library/functools.rst:694 msgid "" "The ``__wrapped__`` attribute now always refers to the wrapped function, " -"even if that function defined a ``__wrapped__`` attribute. (see :issue:" -"`17482`)" +"even if that function defined a ``__wrapped__`` attribute. " +"(see :issue:`17482`)" +msgstr "" + +#: library/functools.rst:699 +msgid "" +"The :attr:`~function.__type_params__` attribute is now copied by default." msgstr "" -#: library/functools.rst:681 +#: library/functools.rst:705 msgid "" "This is a convenience function for invoking :func:`update_wrapper` as a " "function decorator when defining a wrapper function. It is equivalent to " @@ -595,47 +932,72 @@ msgid "" "updated=updated)``. For example::" msgstr "" -#: library/functools.rst:707 +#: library/functools.rst:710 +msgid "" +">>> from functools import wraps\n" +">>> def my_decorator(f):\n" +"... @wraps(f)\n" +"... def wrapper(*args, **kwds):\n" +"... print('Calling decorated function')\n" +"... return f(*args, **kwds)\n" +"... return wrapper\n" +"...\n" +">>> @my_decorator\n" +"... def example():\n" +"... \"\"\"Docstring\"\"\"\n" +"... print('Called example function')\n" +"...\n" +">>> example()\n" +"Calling decorated function\n" +"Called example function\n" +">>> example.__name__\n" +"'example'\n" +">>> example.__doc__\n" +"'Docstring'" +msgstr "" + +#: library/functools.rst:731 msgid "" "Without the use of this decorator factory, the name of the example function " -"would have been ``'wrapper'``, and the docstring of the original :func:" -"`example` would have been lost." +"would have been ``'wrapper'``, and the docstring of the " +"original :func:`example` would have been lost." msgstr "" -#: library/functools.rst:715 +#: library/functools.rst:739 msgid ":class:`partial` Objects" msgstr "" -#: library/functools.rst:717 +#: library/functools.rst:741 msgid "" ":class:`partial` objects are callable objects created by :func:`partial`. " "They have three read-only attributes:" msgstr "" -#: library/functools.rst:723 +#: library/functools.rst:747 msgid "" "A callable object or function. Calls to the :class:`partial` object will be " "forwarded to :attr:`func` with new arguments and keywords." msgstr "" -#: library/functools.rst:729 +#: library/functools.rst:753 msgid "" "The leftmost positional arguments that will be prepended to the positional " "arguments provided to a :class:`partial` object call." msgstr "" -#: library/functools.rst:735 +#: library/functools.rst:759 msgid "" "The keyword arguments that will be supplied when the :class:`partial` object " "is called." msgstr "" -#: library/functools.rst:738 +#: library/functools.rst:762 msgid "" -":class:`partial` objects are like :class:`function` objects in that they are " -"callable, weak referenceable, and can have attributes. There are some " -"important differences. For instance, the :attr:`~definition.__name__` and :" -"attr:`__doc__` attributes are not created automatically. Also, :class:" -"`partial` objects defined in classes behave like static methods and do not " -"transform into bound methods during instance attribute look-up." +":class:`partial` objects are like :ref:`function objects ` in that they are callable, weak referenceable, and can have " +"attributes. There are some important differences. For instance, " +"the :attr:`~function.__name__` and :attr:`function.__doc__` attributes are " +"not created automatically. Also, :class:`partial` objects defined in " +"classes behave like static methods and do not transform into bound methods " +"during instance attribute look-up." msgstr "" diff --git a/library/gc.po b/library/gc.po index 1134f9fb..8e8b650f 100644 --- a/library/gc.po +++ b/library/gc.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/gc.rst:2 -msgid ":mod:`gc` --- Garbage Collector interface" +msgid ":mod:`!gc` --- Garbage Collector interface" msgstr "" #: library/gc.rst:12 @@ -86,8 +87,8 @@ msgstr "" #: library/gc.rst:71 msgid "" "Returns a list of all objects tracked by the collector, excluding the list " -"returned. If *generation* is not None, return only the objects tracked by " -"the collector that are in that generation." +"returned. If *generation* is not ``None``, return only the objects tracked " +"by the collector that are in that generation." msgstr "" #: library/gc.rst:75 @@ -144,9 +145,9 @@ msgid "" "examined. If generation ``0`` has been examined more than *threshold1* " "times since generation ``1`` has been examined, then generation ``1`` is " "examined as well. With the third generation, things are a bit more " -"complicated, see `Collecting the oldest generation `_ for more " -"information." +"complicated, see `Collecting the oldest generation `_ " +"for more information." msgstr "" #: library/gc.rst:121 @@ -194,13 +195,14 @@ msgstr "" #: library/gc.rst:154 msgid "" "Return a list of objects directly referred to by any of the arguments. The " -"referents returned are those objects visited by the arguments' C-level :c:" -"member:`~PyTypeObject.tp_traverse` methods (if any), and may not be all " -"objects actually directly reachable. :c:member:`~PyTypeObject.tp_traverse` " -"methods are supported only by objects that support garbage collection, and " -"are only required to visit objects that may be involved in a cycle. So, for " -"example, if an integer is directly reachable from an argument, that integer " -"object may or may not appear in the result list." +"referents returned are those objects visited by the arguments' C-" +"level :c:member:`~PyTypeObject.tp_traverse` methods (if any), and may not be " +"all objects actually directly " +"reachable. :c:member:`~PyTypeObject.tp_traverse` methods are supported only " +"by objects that support garbage collection, and are only required to visit " +"objects that may be involved in a cycle. So, for example, if an integer is " +"directly reachable from an argument, that integer object may or may not " +"appear in the result list." msgstr "" #: library/gc.rst:162 @@ -219,12 +221,44 @@ msgid "" "instances (e.g. dicts containing only atomic keys and values)::" msgstr "" +#: library/gc.rst:173 +msgid "" +">>> gc.is_tracked(0)\n" +"False\n" +">>> gc.is_tracked(\"a\")\n" +"False\n" +">>> gc.is_tracked([])\n" +"True\n" +">>> gc.is_tracked({})\n" +"False\n" +">>> gc.is_tracked({\"a\": 1})\n" +"False\n" +">>> gc.is_tracked({\"a\": []})\n" +"True" +msgstr "" + #: library/gc.rst:191 msgid "" "Returns ``True`` if the given object has been finalized by the garbage " "collector, ``False`` otherwise. ::" msgstr "" +#: library/gc.rst:194 +msgid "" +">>> x = None\n" +">>> class Lazarus:\n" +"... def __del__(self):\n" +"... global x\n" +"... x = self\n" +"...\n" +">>> lazarus = Lazarus()\n" +">>> gc.is_finalized(lazarus)\n" +"False\n" +">>> del lazarus\n" +">>> gc.is_finalized(x)\n" +"True" +msgstr "" + #: library/gc.rst:212 msgid "" "Freeze all the objects tracked by the garbage collector; move them to a " @@ -275,10 +309,10 @@ msgstr "" #: library/gc.rst:255 msgid "" -"If this list is non-empty at :term:`interpreter shutdown`, a :exc:" -"`ResourceWarning` is emitted, which is silent by default. If :const:" -"`DEBUG_UNCOLLECTABLE` is set, in addition all uncollectable objects are " -"printed." +"If this list is non-empty at :term:`interpreter shutdown`, " +"a :exc:`ResourceWarning` is emitted, which is silent by default. " +"If :const:`DEBUG_UNCOLLECTABLE` is set, in addition all uncollectable " +"objects are printed." msgstr "" #: library/gc.rst:261 diff --git a/library/getopt.po b/library/getopt.po index e8335365..15f28898 100644 --- a/library/getopt.po +++ b/library/getopt.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/getopt.rst:2 -msgid ":mod:`getopt` --- C-style parser for command line options" +msgid ":mod:`!getopt` --- C-style parser for command line options" msgstr "" #: library/getopt.rst:8 @@ -35,8 +36,8 @@ msgstr "" #: library/getopt.rst:20 msgid "" -"This module helps scripts to parse the command line arguments in ``sys." -"argv``. It supports the same conventions as the Unix :c:func:`getopt` " +"This module helps scripts to parse the command line arguments in " +"``sys.argv``. It supports the same conventions as the Unix :c:func:`getopt` " "function (including the special meanings of arguments of the form '``-``' " "and '``--``'). Long options similar to those supported by GNU software may " "be used as well via an optional third argument." @@ -52,8 +53,8 @@ msgid "" "to be parsed, without the leading reference to the running program. " "Typically, this means ``sys.argv[1:]``. *shortopts* is the string of option " "letters that the script wants to recognize, with options that require an " -"argument followed by a colon (``':'``; i.e., the same format that Unix :c:" -"func:`getopt` uses)." +"argument followed by a colon (``':'``; i.e., the same format that " +"Unix :c:func:`getopt` uses)." msgstr "" #: library/getopt.rst:40 @@ -83,9 +84,9 @@ msgid "" "value)`` pairs; the second is the list of program arguments left after the " "option list was stripped (this is a trailing slice of *args*). Each option-" "and-value pair returned has the option as its first element, prefixed with a " -"hyphen for short options (e.g., ``'-x'``) or two hyphens for long options (e." -"g., ``'--long-option'``), and the option argument as its second element, or " -"an empty string if the option has no argument. The options occur in the " +"hyphen for short options (e.g., ``'-x'``) or two hyphens for long options " +"(e.g., ``'--long-option'``), and the option argument as its second element, " +"or an empty string if the option has no argument. The options occur in the " "list in the same order in which they were found, thus allowing multiple " "occurrences. Long and short options may be mixed." msgstr "" @@ -124,25 +125,99 @@ msgstr "" msgid "An example using only Unix style options:" msgstr "" -#: library/getopt.rst:105 +#: library/getopt.rst:95 +msgid "" +">>> import getopt\n" +">>> args = '-a -b -cfoo -d bar a1 a2'.split()\n" +">>> args\n" +"['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2']\n" +">>> optlist, args = getopt.getopt(args, 'abc:d:')\n" +">>> optlist\n" +"[('-a', ''), ('-b', ''), ('-c', 'foo'), ('-d', 'bar')]\n" +">>> args\n" +"['a1', 'a2']" +msgstr "" + +#: library/getopt.rst:107 msgid "Using long option names is equally easy:" msgstr "" -#: library/getopt.rst:118 -msgid "In a script, typical usage is something like this::" +#: library/getopt.rst:109 +msgid "" +">>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'\n" +">>> args = s.split()\n" +">>> args\n" +"['--condition=foo', '--testing', '--output-file', 'abc.def', '-x', 'a1', " +"'a2']\n" +">>> optlist, args = getopt.getopt(args, 'x', [\n" +"... 'condition=', 'output-file=', 'testing'])\n" +">>> optlist\n" +"[('--condition', 'foo'), ('--testing', ''), ('--output-file', 'abc.def'), ('-" +"x', '')]\n" +">>> args\n" +"['a1', 'a2']" +msgstr "" + +#: library/getopt.rst:122 +msgid "In a script, typical usage is something like this:" msgstr "" -#: library/getopt.rst:147 +#: library/getopt.rst:124 +msgid "" +"import getopt, sys\n" +"\n" +"def main():\n" +" try:\n" +" opts, args = getopt.getopt(sys.argv[1:], \"ho:v\", [\"help\", " +"\"output=\"])\n" +" except getopt.GetoptError as err:\n" +" # print help information and exit:\n" +" print(err) # will print something like \"option -a not " +"recognized\"\n" +" usage()\n" +" sys.exit(2)\n" +" output = None\n" +" verbose = False\n" +" for o, a in opts:\n" +" if o == \"-v\":\n" +" verbose = True\n" +" elif o in (\"-h\", \"--help\"):\n" +" usage()\n" +" sys.exit()\n" +" elif o in (\"-o\", \"--output\"):\n" +" output = a\n" +" else:\n" +" assert False, \"unhandled option\"\n" +" # ...\n" +"\n" +"if __name__ == \"__main__\":\n" +" main()" +msgstr "" + +#: library/getopt.rst:153 msgid "" "Note that an equivalent command line interface could be produced with less " -"code and more informative help and error messages by using the :mod:" -"`argparse` module::" +"code and more informative help and error messages by using " +"the :mod:`argparse` module:" msgstr "" -#: library/getopt.rst:162 +#: library/getopt.rst:156 +msgid "" +"import argparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = argparse.ArgumentParser()\n" +" parser.add_argument('-o', '--output')\n" +" parser.add_argument('-v', dest='verbose', action='store_true')\n" +" args = parser.parse_args()\n" +" # ... do something with args.output ...\n" +" # ... do something with args.verbose .." +msgstr "" + +#: library/getopt.rst:170 msgid "Module :mod:`argparse`" msgstr "" -#: library/getopt.rst:163 +#: library/getopt.rst:171 msgid "Alternative command line option and argument parsing library." msgstr "" diff --git a/library/getpass.po b/library/getpass.po index f20bd089..cf8d53fa 100644 --- a/library/getpass.po +++ b/library/getpass.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/getpass.rst:2 -msgid ":mod:`getpass` --- Portable password input" +msgid ":mod:`!getpass` --- Portable password input" msgstr "" #: library/getpass.rst:11 @@ -25,7 +26,7 @@ msgid "**Source code:** :source:`Lib/getpass.py`" msgstr "" #: includes/wasm-notavail.rst:3 -msgid ":ref:`Availability `: not Emscripten, not WASI." +msgid "Availability" msgstr "" #: includes/wasm-notavail.rst:5 @@ -52,8 +53,8 @@ msgstr "" #: library/getpass.rst:28 msgid "" "If echo free input is unavailable getpass() falls back to printing a warning " -"message to *stream* and reading from ``sys.stdin`` and issuing a :exc:" -"`GetPassWarning`." +"message to *stream* and reading from ``sys.stdin`` and issuing " +"a :exc:`GetPassWarning`." msgstr "" #: library/getpass.rst:33 @@ -72,14 +73,14 @@ msgstr "" #: library/getpass.rst:45 msgid "" -"This function checks the environment variables :envvar:`LOGNAME`, :envvar:" -"`USER`, :envvar:`!LNAME` and :envvar:`USERNAME`, in order, and returns the " -"value of the first one which is set to a non-empty string. If none are set, " -"the login name from the password database is returned on systems which " -"support the :mod:`pwd` module, otherwise, an exception is raised." +"This function checks the environment " +"variables :envvar:`LOGNAME`, :envvar:`USER`, :envvar:`!LNAME` " +"and :envvar:`USERNAME`, in order, and returns the value of the first one " +"which is set to a non-empty string. If none are set, the login name from " +"the password database is returned on systems which support the :mod:`pwd` " +"module, otherwise, an exception is raised." msgstr "" #: library/getpass.rst:52 -msgid "" -"In general, this function should be preferred over :func:`os.getlogin()`." +msgid "In general, this function should be preferred over :func:`os.getlogin`." msgstr "" diff --git a/library/gettext.po b/library/gettext.po index aaf8b93e..fae5bc0d 100644 --- a/library/gettext.po +++ b/library/gettext.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/gettext.rst:2 -msgid ":mod:`gettext` --- Multilingual internationalization services" +msgid ":mod:`!gettext` --- Multilingual internationalization services" msgstr "" #: library/gettext.rst:10 @@ -57,12 +58,13 @@ msgstr "" #: library/gettext.rst:39 msgid "" -"Bind the *domain* to the locale directory *localedir*. More concretely, :" -"mod:`gettext` will look for binary :file:`.mo` files for the given domain " -"using the path (on Unix): :file:`{localedir}/{language}/LC_MESSAGES/{domain}." -"mo`, where *language* is searched for in the environment variables :envvar:" -"`LANGUAGE`, :envvar:`LC_ALL`, :envvar:`LC_MESSAGES`, and :envvar:`LANG` " -"respectively." +"Bind the *domain* to the locale directory *localedir*. More " +"concretely, :mod:`gettext` will look for binary :file:`.mo` files for the " +"given domain using the path (on Unix): :file:`{localedir}/{language}/" +"LC_MESSAGES/{domain}.mo`, where *language* is searched for in the " +"environment " +"variables :envvar:`LANGUAGE`, :envvar:`LC_ALL`, :envvar:`LC_MESSAGES`, " +"and :envvar:`LANG` respectively." msgstr "" #: library/gettext.rst:45 @@ -130,6 +132,16 @@ msgstr "" msgid "Here's an example of typical usage for this API::" msgstr "" +#: library/gettext.rst:106 +msgid "" +"import gettext\n" +"gettext.bindtextdomain('myapplication', '/path/to/my/language/directory')\n" +"gettext.textdomain('myapplication')\n" +"_ = gettext.gettext\n" +"# ...\n" +"print(_('This is a translatable string.'))" +msgstr "" + #: library/gettext.rst:115 msgid "Class-based API" msgstr "" @@ -157,11 +169,12 @@ msgstr "" msgid "" "If *localedir* is not given, then the default system locale directory is " "used. [#]_ If *languages* is not given, then the following environment " -"variables are searched: :envvar:`LANGUAGE`, :envvar:`LC_ALL`, :envvar:" -"`LC_MESSAGES`, and :envvar:`LANG`. The first one returning a non-empty " -"value is used for the *languages* variable. The environment variables should " -"contain a colon separated list of languages, which will be split on the " -"colon to produce the expected list of language code strings." +"variables are " +"searched: :envvar:`LANGUAGE`, :envvar:`LC_ALL`, :envvar:`LC_MESSAGES`, " +"and :envvar:`LANG`. The first one returning a non-empty value is used for " +"the *languages* variable. The environment variables should contain a colon " +"separated list of languages, which will be split on the colon to produce the " +"expected list of language code strings." msgstr "" #: library/gettext.rst:140 @@ -203,8 +216,8 @@ msgstr "" #: library/gettext.rst:165 msgid "" "If no :file:`.mo` file is found, this function raises :exc:`OSError` if " -"*fallback* is false (which is the default), and returns a :class:" -"`NullTranslations` instance if *fallback* is true." +"*fallback* is false (which is the default), and returns " +"a :class:`NullTranslations` instance if *fallback* is true." msgstr "" #: library/gettext.rst:169 @@ -218,8 +231,8 @@ msgstr "" #: library/gettext.rst:177 msgid "" "This installs the function :func:`!_` in Python's builtins namespace, based " -"on *domain* and *localedir* which are passed to the function :func:" -"`translation`." +"on *domain* and *localedir* which are passed to the " +"function :func:`translation`." msgstr "" #: library/gettext.rst:180 @@ -235,6 +248,10 @@ msgid "" "function, like this::" msgstr "" +#: library/gettext.rst:187 +msgid "print(_('This string will be translated.'))" +msgstr "" + #: library/gettext.rst:189 msgid "" "For convenience, you want the :func:`!_` function to be installed in " @@ -334,13 +351,20 @@ msgstr "" #: library/gettext.rst:279 msgid "" -"Note that this is only one way, albeit the most convenient way, to make the :" -"func:`!_` function available to your application. Because it affects the " -"entire application globally, and specifically the built-in namespace, " +"Note that this is only one way, albeit the most convenient way, to make " +"the :func:`!_` function available to your application. Because it affects " +"the entire application globally, and specifically the built-in namespace, " "localized modules should never install :func:`!_`. Instead, they should use " "this code to make :func:`!_` available to their module::" msgstr "" +#: library/gettext.rst:285 +msgid "" +"import gettext\n" +"t = gettext.translation('mymodule', ...)\n" +"_ = t.gettext" +msgstr "" + #: library/gettext.rst:289 msgid "" "This puts :func:`!_` only in the module's global namespace and so only " @@ -357,18 +381,18 @@ msgstr "" #: library/gettext.rst:299 msgid "" -"The :mod:`!gettext` module provides one additional class derived from :class:" -"`NullTranslations`: :class:`GNUTranslations`. This class overrides :meth:`!" -"_parse` to enable reading GNU :program:`gettext` format :file:`.mo` files in " -"both big-endian and little-endian format." +"The :mod:`!gettext` module provides one additional class derived " +"from :class:`NullTranslations`: :class:`GNUTranslations`. This class " +"overrides :meth:`!_parse` to enable reading GNU :program:`gettext` " +"format :file:`.mo` files in both big-endian and little-endian format." msgstr "" #: library/gettext.rst:304 msgid "" ":class:`GNUTranslations` parses optional metadata out of the translation " "catalog. It is convention with GNU :program:`gettext` to include metadata as " -"the translation for the empty string. This metadata is in :rfc:`822`\\ -" -"style ``key: value`` pairs, and should contain the ``Project-Id-Version`` " +"the translation for the empty string. This metadata is in :rfc:`822`\\ " +"-style ``key: value`` pairs, and should contain the ``Project-Id-Version`` " "key. If the key ``Content-Type`` is found, then the ``charset`` property is " "used to initialize the \"protected\" :attr:`!_charset` instance variable, " "defaulting to ``None`` if not found. If the charset encoding is specified, " @@ -419,15 +443,25 @@ msgstr "" #: library/gettext.rst:343 msgid "" "If the message id is not found in the catalog, and a fallback is specified, " -"the request is forwarded to the fallback's :meth:`~NullTranslations." -"ngettext` method. Otherwise, when *n* is 1 *singular* is returned, and " -"*plural* is returned in all other cases." +"the request is forwarded to the " +"fallback's :meth:`~NullTranslations.ngettext` method. Otherwise, when *n* " +"is 1 *singular* is returned, and *plural* is returned in all other cases." msgstr "" #: library/gettext.rst:348 msgid "Here is an example::" msgstr "" +#: library/gettext.rst:350 +msgid "" +"n = len(os.listdir('.'))\n" +"cat = GNUTranslations(somefile)\n" +"message = cat.ngettext(\n" +" 'There is %(num)d file in this directory',\n" +" 'There are %(num)d files in this directory',\n" +" n) % {'num': n}" +msgstr "" + #: library/gettext.rst:360 msgid "" "Look up the *context* and *message* id in the catalog and return the " @@ -473,6 +507,14 @@ msgid "" "this version has a slightly different API. Its documented usage was::" msgstr "" +#: library/gettext.rst:399 +msgid "" +"import gettext\n" +"cat = gettext.Catalog(domain, localedir)\n" +"_ = cat.gettext\n" +"print(_('hello world'))" +msgstr "" + #: library/gettext.rst:404 msgid "" "For compatibility with this older module, the function :func:`!Catalog` is " @@ -526,6 +568,14 @@ msgid "" "`. For example::" msgstr "" +#: library/gettext.rst:434 +msgid "" +"filename = 'mylog.txt'\n" +"message = _('writing a log message')\n" +"with open(filename, 'w') as fp:\n" +" fp.write(message)" +msgstr "" + #: library/gettext.rst:439 msgid "" "In this example, the string ``'writing a log message'`` is marked as a " @@ -548,34 +598,35 @@ msgstr "" #: library/gettext.rst:452 msgid "" -"(Python also includes pure-Python versions of these programs, called :" -"program:`pygettext.py` and :program:`msgfmt.py`; some Python distributions " -"will install them for you. :program:`pygettext.py` is similar to :program:" -"`xgettext`, but only understands Python source code and cannot handle other " -"programming languages such as C or C++. :program:`pygettext.py` supports a " -"command-line interface similar to :program:`xgettext`; for details on its " -"use, run ``pygettext.py --help``. :program:`msgfmt.py` is binary compatible " -"with GNU :program:`msgfmt`. With these two programs, you may not need the " -"GNU :program:`gettext` package to internationalize your Python applications.)" +"(Python also includes pure-Python versions of these programs, " +"called :program:`pygettext.py` and :program:`msgfmt.py`; some Python " +"distributions will install them for you. :program:`pygettext.py` is similar " +"to :program:`xgettext`, but only understands Python source code and cannot " +"handle other programming languages such as C or C++. :program:`pygettext.py` " +"supports a command-line interface similar to :program:`xgettext`; for " +"details on its use, run ``pygettext.py --help``. :program:`msgfmt.py` is " +"binary compatible with GNU :program:`msgfmt`. With these two programs, you " +"may not need the GNU :program:`gettext` package to internationalize your " +"Python applications.)" msgstr "" #: library/gettext.rst:464 msgid "" -":program:`xgettext`, :program:`pygettext`, and similar tools generate :file:" -"`.po` files that are message catalogs. They are structured human-readable " -"files that contain every marked string in the source code, along with a " -"placeholder for the translated versions of these strings." +":program:`xgettext`, :program:`pygettext`, and similar tools " +"generate :file:`.po` files that are message catalogs. They are structured " +"human-readable files that contain every marked string in the source code, " +"along with a placeholder for the translated versions of these strings." msgstr "" #: library/gettext.rst:470 msgid "" "Copies of these :file:`.po` files are then handed over to the individual " "human translators who write translations for every supported natural " -"language. They send back the completed language-specific versions as a :" -"file:`.po` file that's compiled into a machine-readable :file:" -"`.mo` binary catalog file using the :program:`msgfmt` program. The :file:`." -"mo` files are used by the :mod:`gettext` module for the actual translation " -"processing at run-time." +"language. They send back the completed language-specific versions as " +"a :file:`.po` file that's compiled into a machine-" +"readable :file:`.mo` binary catalog file using the :program:`msgfmt` " +"program. The :file:`.mo` files are used by the :mod:`gettext` module for " +"the actual translation processing at run-time." msgstr "" #: library/gettext.rst:479 @@ -592,8 +643,8 @@ msgstr "" #: library/gettext.rst:487 msgid "" "If you are localizing your module, you must take care not to make global " -"changes, e.g. to the built-in namespace. You should not use the GNU :program:" -"`gettext` API but instead the class-based API." +"changes, e.g. to the built-in namespace. You should not use the " +"GNU :program:`gettext` API but instead the class-based API." msgstr "" #: library/gettext.rst:491 @@ -604,6 +655,13 @@ msgid "" "your module::" msgstr "" +#: library/gettext.rst:496 +msgid "" +"import gettext\n" +"t = gettext.translation('spam', '/usr/share/locale')\n" +"_ = t.gettext" +msgstr "" + #: library/gettext.rst:502 msgid "Localizing your application" msgstr "" @@ -622,10 +680,22 @@ msgid "" "main driver file of your application::" msgstr "" +#: library/gettext.rst:512 +msgid "" +"import gettext\n" +"gettext.install('myapplication')" +msgstr "" + #: library/gettext.rst:515 msgid "" -"If you need to set the locale directory, you can pass it into the :func:" -"`install` function::" +"If you need to set the locale directory, you can pass it into " +"the :func:`install` function::" +msgstr "" + +#: library/gettext.rst:518 +msgid "" +"import gettext\n" +"gettext.install('myapplication', '/usr/share/locale')" msgstr "" #: library/gettext.rst:523 @@ -639,6 +709,24 @@ msgid "" "explicitly, like so::" msgstr "" +#: library/gettext.rst:529 +msgid "" +"import gettext\n" +"\n" +"lang1 = gettext.translation('myapplication', languages=['en'])\n" +"lang2 = gettext.translation('myapplication', languages=['fr'])\n" +"lang3 = gettext.translation('myapplication', languages=['de'])\n" +"\n" +"# start by using language1\n" +"lang1.install()\n" +"\n" +"# ... time goes by, user selects language 2\n" +"lang2.install()\n" +"\n" +"# ... more time goes by, user selects language 3\n" +"lang3.install()" +msgstr "" + #: library/gettext.rst:546 msgid "Deferred translations" msgstr "" @@ -650,6 +738,18 @@ msgid "" "actual translation until later. A classic example is::" msgstr "" +#: library/gettext.rst:552 +msgid "" +"animals = ['mollusk',\n" +" 'albatross',\n" +" 'rat',\n" +" 'penguin',\n" +" 'python', ]\n" +"# ...\n" +"for a in animals:\n" +" print(a)" +msgstr "" + #: library/gettext.rst:561 msgid "" "Here, you want to mark the strings in the ``animals`` list as being " @@ -661,6 +761,23 @@ msgstr "" msgid "Here is one way you can handle this situation::" msgstr "" +#: library/gettext.rst:567 +msgid "" +"def _(message): return message\n" +"\n" +"animals = [_('mollusk'),\n" +" _('albatross'),\n" +" _('rat'),\n" +" _('penguin'),\n" +" _('python'), ]\n" +"\n" +"del _\n" +"\n" +"# ...\n" +"for a in animals:\n" +" print(_(a))" +msgstr "" + #: library/gettext.rst:581 msgid "" "This works because the dummy definition of :func:`!_` simply returns the " @@ -681,6 +798,21 @@ msgstr "" msgid "Another way to handle this is with the following example::" msgstr "" +#: library/gettext.rst:593 +msgid "" +"def N_(message): return message\n" +"\n" +"animals = [N_('mollusk'),\n" +" N_('albatross'),\n" +" N_('rat'),\n" +" N_('penguin'),\n" +" N_('python'), ]\n" +"\n" +"# ...\n" +"for a in animals:\n" +" print(_(a))" +msgstr "" + #: library/gettext.rst:605 msgid "" "In this case, you are marking translatable strings with the function :func:`!" diff --git a/library/glob.po b/library/glob.po index 7f6de48a..c87c3097 100644 --- a/library/glob.po +++ b/library/glob.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/glob.rst:2 -msgid ":mod:`glob` --- Unix style pathname pattern expansion" +msgid ":mod:`!glob` --- Unix style pathname pattern expansion" msgstr "" #: library/glob.rst:7 @@ -37,9 +38,9 @@ msgstr "" #: library/glob.rst:28 msgid "" "Note that files beginning with a dot (``.``) can only be matched by patterns " -"that also start with a dot, unlike :func:`fnmatch.fnmatch` or :func:`pathlib." -"Path.glob`. (For tilde and shell variable expansion, use :func:`os.path." -"expanduser` and :func:`os.path.expandvars`.)" +"that also start with a dot, unlike :func:`fnmatch.fnmatch` " +"or :func:`pathlib.Path.glob`. (For tilde and shell variable expansion, " +"use :func:`os.path.expanduser` and :func:`os.path.expandvars`.)" msgstr "" #: library/glob.rst:34 @@ -56,19 +57,19 @@ msgstr "" msgid "" "Return a possibly empty list of path names that match *pathname*, which must " "be a string containing a path specification. *pathname* can be either " -"absolute (like :file:`/usr/src/Python-1.5/Makefile`) or relative (like :file:" -"`../../Tools/\\*/\\*.gif`), and can contain shell-style wildcards. Broken " -"symlinks are included in the results (as in the shell). Whether or not the " -"results are sorted depends on the file system. If a file that satisfies " -"conditions is removed or added during the call of this function, whether a " -"path name for that file will be included is unspecified." +"absolute (like :file:`/usr/src/Python-1.5/Makefile`) or relative " +"(like :file:`../../Tools/\\*/\\*.gif`), and can contain shell-style " +"wildcards. Broken symlinks are included in the results (as in the shell). " +"Whether or not the results are sorted depends on the file system. If a file " +"that satisfies conditions is removed or added during the call of this " +"function, whether a path name for that file will be included is unspecified." msgstr "" #: library/glob.rst:54 msgid "" "If *root_dir* is not ``None``, it should be a :term:`path-like object` " -"specifying the root directory for searching. It has the same effect on :" -"func:`glob` as changing the current directory before calling it. If " +"specifying the root directory for searching. It has the same effect " +"on :func:`glob` as changing the current directory before calling it. If " "*pathname* is relative, the result will contain paths relative to *root_dir*." msgstr "" @@ -92,13 +93,13 @@ msgid "" "directories." msgstr "" -#: library/glob.rst:96 +#: library/glob.rst:100 msgid "" "Raises an :ref:`auditing event ` ``glob.glob`` with arguments " "``pathname``, ``recursive``." msgstr "" -#: library/glob.rst:97 +#: library/glob.rst:101 msgid "" "Raises an :ref:`auditing event ` ``glob.glob/2`` with arguments " "``pathname``, ``recursive``, ``root_dir``, ``dir_fd``." @@ -110,25 +111,31 @@ msgid "" "inordinate amount of time." msgstr "" -#: library/glob.rst:99 +#: library/glob.rst:104 +msgid "" +"This function may return duplicate path names if *pathname* contains " +"multiple \"``**``\" patterns and *recursive* is true." +msgstr "" + +#: library/glob.rst:107 msgid "Support for recursive globs using \"``**``\"." msgstr "" -#: library/glob.rst:102 +#: library/glob.rst:110 msgid "Added the *root_dir* and *dir_fd* parameters." msgstr "" -#: library/glob.rst:105 +#: library/glob.rst:113 msgid "Added the *include_hidden* parameter." msgstr "" -#: library/glob.rst:93 +#: library/glob.rst:97 msgid "" "Return an :term:`iterator` which yields the same values as :func:`glob` " "without actually storing them all simultaneously." msgstr "" -#: library/glob.rst:111 +#: library/glob.rst:119 msgid "" "Escape all special characters (``'?'``, ``'*'`` and ``'['``). This is useful " "if you want to match an arbitrary literal string that may have special " @@ -137,27 +144,51 @@ msgid "" "c:/Quo vadis[?].txt'``." msgstr "" -#: library/glob.rst:120 +#: library/glob.rst:128 msgid "" -"For example, consider a directory containing the following files: :file:`1." -"gif`, :file:`2.txt`, :file:`card.gif` and a subdirectory :file:`sub` which " -"contains only the file :file:`3.txt`. :func:`glob` will produce the " -"following results. Notice how any leading components of the path are " -"preserved. ::" +"For example, consider a directory containing the following " +"files: :file:`1.gif`, :file:`2.txt`, :file:`card.gif` and a " +"subdirectory :file:`sub` which contains only the " +"file :file:`3.txt`. :func:`glob` will produce the following results. " +"Notice how any leading components of the path are preserved. ::" msgstr "" -#: library/glob.rst:138 +#: library/glob.rst:134 +msgid "" +">>> import glob\n" +">>> glob.glob('./[0-9].*')\n" +"['./1.gif', './2.txt']\n" +">>> glob.glob('*.gif')\n" +"['1.gif', 'card.gif']\n" +">>> glob.glob('?.gif')\n" +"['1.gif']\n" +">>> glob.glob('**/*.txt', recursive=True)\n" +"['2.txt', 'sub/3.txt']\n" +">>> glob.glob('./**/', recursive=True)\n" +"['./', './sub/']" +msgstr "" + +#: library/glob.rst:146 msgid "" "If the directory contains files starting with ``.`` they won't be matched by " -"default. For example, consider a directory containing :file:`card.gif` and :" -"file:`.card.gif`::" +"default. For example, consider a directory containing :file:`card.gif` " +"and :file:`.card.gif`::" msgstr "" #: library/glob.rst:150 +msgid "" +">>> import glob\n" +">>> glob.glob('*.gif')\n" +"['card.gif']\n" +">>> glob.glob('.c*')\n" +"['.card.gif']" +msgstr "" + +#: library/glob.rst:158 msgid "Module :mod:`fnmatch`" msgstr "" -#: library/glob.rst:151 +#: library/glob.rst:159 msgid "Shell-style filename (not path) expansion" msgstr "" diff --git a/library/graphlib.po b/library/graphlib.po index 02e8fc59..ea11c490 100644 --- a/library/graphlib.po +++ b/library/graphlib.po @@ -8,16 +8,18 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/graphlib.rst:2 -msgid ":mod:`graphlib` --- Functionality to operate with graph-like structures" +msgid "" +":mod:`!graphlib` --- Functionality to operate with graph-like structures" msgstr "" #: library/graphlib.rst:8 @@ -81,8 +83,16 @@ msgstr "" #: library/graphlib.rst:49 msgid "" "In case just an immediate sorting of the nodes in the graph is required and " -"no parallelism is involved, the convenience method :meth:`TopologicalSorter." -"static_order` can be used directly:" +"no parallelism is involved, the convenience " +"method :meth:`TopologicalSorter.static_order` can be used directly:" +msgstr "" + +#: library/graphlib.rst:53 +msgid "" +">>> graph = {\"D\": {\"B\", \"C\"}, \"C\": {\"A\"}, \"B\": {\"A\"}}\n" +">>> ts = TopologicalSorter(graph)\n" +">>> tuple(ts.static_order())\n" +"('A', 'C', 'B', 'D')" msgstr "" #: library/graphlib.rst:60 @@ -91,6 +101,31 @@ msgid "" "they become ready. For instance::" msgstr "" +#: library/graphlib.rst:63 +msgid "" +"topological_sorter = TopologicalSorter()\n" +"\n" +"# Add nodes to 'topological_sorter'...\n" +"\n" +"topological_sorter.prepare()\n" +"while topological_sorter.is_active():\n" +" for node in topological_sorter.get_ready():\n" +" # Worker threads or processes take nodes to work on off the\n" +" # 'task_queue' queue.\n" +" task_queue.put(node)\n" +"\n" +" # When the work for a node is done, workers put the node in\n" +" # 'finalized_tasks_queue' so we can get more nodes to work on.\n" +" # The definition of 'is_active()' guarantees that, at this point, at\n" +" # least one node has been placed on 'task_queue' that hasn't yet\n" +" # been passed to 'done()', so this blocking 'get()' must (eventually)\n" +" # succeed. After calling 'done()', we loop back to call 'get_ready()'\n" +" # again, so put newly freed nodes on 'task_queue' as soon as\n" +" # logically possible.\n" +" node = finalized_tasks_queue.get()\n" +" topological_sorter.done(node)" +msgstr "" + #: library/graphlib.rst:87 msgid "" "Add a new node and its predecessors to the graph. Both the *node* and all " @@ -119,21 +154,21 @@ msgstr "" #: library/graphlib.rst:102 msgid "" "Mark the graph as finished and check for cycles in the graph. If any cycle " -"is detected, :exc:`CycleError` will be raised, but :meth:`~TopologicalSorter." -"get_ready` can still be used to obtain as many nodes as possible until " -"cycles block more progress. After a call to this function, the graph cannot " -"be modified, and therefore no more nodes can be added using :meth:" -"`~TopologicalSorter.add`." +"is detected, :exc:`CycleError` will be raised, " +"but :meth:`~TopologicalSorter.get_ready` can still be used to obtain as many " +"nodes as possible until cycles block more progress. After a call to this " +"function, the graph cannot be modified, and therefore no more nodes can be " +"added using :meth:`~TopologicalSorter.add`." msgstr "" #: library/graphlib.rst:111 msgid "" "Returns ``True`` if more progress can be made and ``False`` otherwise. " "Progress can be made if cycles do not block the resolution and either there " -"are still nodes ready that haven't yet been returned by :meth:" -"`TopologicalSorter.get_ready` or the number of nodes marked :meth:" -"`TopologicalSorter.done` is less than the number that have been returned by :" -"meth:`TopologicalSorter.get_ready`." +"are still nodes ready that haven't yet been returned " +"by :meth:`TopologicalSorter.get_ready` or the number of nodes " +"marked :meth:`TopologicalSorter.done` is less than the number that have been " +"returned by :meth:`TopologicalSorter.get_ready`." msgstr "" #: library/graphlib.rst:118 @@ -142,14 +177,26 @@ msgid "" "so instead of::" msgstr "" +#: library/graphlib.rst:121 +msgid "" +"if ts.is_active():\n" +" ..." +msgstr "" + #: library/graphlib.rst:124 msgid "it is possible to simply do::" msgstr "" +#: library/graphlib.rst:126 +msgid "" +"if ts:\n" +" ..." +msgstr "" + #: library/graphlib.rst:152 msgid "" -"Raises :exc:`ValueError` if called without calling :meth:`~TopologicalSorter." -"prepare` previously." +"Raises :exc:`ValueError` if called without " +"calling :meth:`~TopologicalSorter.prepare` previously." msgstr "" #: library/graphlib.rst:134 @@ -163,9 +210,9 @@ msgstr "" msgid "" "Raises :exc:`ValueError` if any node in *nodes* has already been marked as " "processed by a previous call to this method or if a node was not added to " -"the graph by using :meth:`TopologicalSorter.add`, if called without calling :" -"meth:`~TopologicalSorter.prepare` or if node has not yet been returned by :" -"meth:`~TopologicalSorter.get_ready`." +"the graph by using :meth:`TopologicalSorter.add`, if called without " +"calling :meth:`~TopologicalSorter.prepare` or if node has not yet been " +"returned by :meth:`~TopologicalSorter.get_ready`." msgstr "" #: library/graphlib.rst:146 @@ -180,9 +227,19 @@ msgstr "" #: library/graphlib.rst:157 msgid "" "Returns an iterator object which will iterate over nodes in a topological " -"order. When using this method, :meth:`~TopologicalSorter.prepare` and :meth:" -"`~TopologicalSorter.done` should not be called. This method is equivalent " -"to::" +"order. When using this method, :meth:`~TopologicalSorter.prepare` " +"and :meth:`~TopologicalSorter.done` should not be called. This method is " +"equivalent to::" +msgstr "" + +#: library/graphlib.rst:162 +msgid "" +"def static_order(self):\n" +" self.prepare()\n" +" while self.is_active():\n" +" node_group = self.get_ready()\n" +" yield from node_group\n" +" self.done(*node_group)" msgstr "" #: library/graphlib.rst:169 @@ -191,12 +248,27 @@ msgid "" "which the items were inserted in the graph. For example:" msgstr "" +#: library/graphlib.rst:172 +msgid "" +">>> ts = TopologicalSorter()\n" +">>> ts.add(3, 2, 1)\n" +">>> ts.add(1, 0)\n" +">>> print([*ts.static_order()])\n" +"[2, 0, 1, 3]\n" +"\n" +">>> ts2 = TopologicalSorter()\n" +">>> ts2.add(1, 0)\n" +">>> ts2.add(3, 2, 1)\n" +">>> print([*ts2.static_order()])\n" +"[0, 2, 1, 3]" +msgstr "" + #: library/graphlib.rst:186 msgid "" "This is due to the fact that \"0\" and \"2\" are in the same level in the " -"graph (they would have been returned in the same call to :meth:" -"`~TopologicalSorter.get_ready`) and the order between them is determined by " -"the order of insertion." +"graph (they would have been returned in the same call " +"to :meth:`~TopologicalSorter.get_ready`) and the order between them is " +"determined by the order of insertion." msgstr "" #: library/graphlib.rst:192 @@ -220,9 +292,10 @@ msgstr "" #: library/graphlib.rst:207 msgid "" -"The detected cycle can be accessed via the second element in the :attr:" -"`~BaseException.args` attribute of the exception instance and consists in a " -"list of nodes, such that each node is, in the graph, an immediate " -"predecessor of the next node in the list. In the reported list, the first " -"and the last node will be the same, to make it clear that it is cyclic." +"The detected cycle can be accessed via the second element in " +"the :attr:`~BaseException.args` attribute of the exception instance and " +"consists in a list of nodes, such that each node is, in the graph, an " +"immediate predecessor of the next node in the list. In the reported list, " +"the first and the last node will be the same, to make it clear that it is " +"cyclic." msgstr "" diff --git a/library/grp.po b/library/grp.po index 4949bd14..f1517ff4 100644 --- a/library/grp.po +++ b/library/grp.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/grp.rst:2 -msgid ":mod:`grp` --- The group database" +msgid ":mod:`!grp` --- The group database" msgstr "" #: library/grp.rst:10 @@ -27,7 +28,7 @@ msgid "" msgstr "" #: library/grp.rst:13 -msgid ":ref:`Availability `: Unix, not Emscripten, not WASI." +msgid "Availability" msgstr "" #: library/grp.rst:15 @@ -104,8 +105,8 @@ msgid "" "members of the group they are in according to the password database. Check " "both databases to get complete membership information. Also note that a " "``gr_name`` that starts with a ``+`` or ``-`` is likely to be a YP/NIS " -"reference and may not be accessible via :func:`getgrnam` or :func:" -"`getgrgid`.)" +"reference and may not be accessible via :func:`getgrnam` " +"or :func:`getgrgid`.)" msgstr "" #: library/grp.rst:40 @@ -114,8 +115,8 @@ msgstr "" #: library/grp.rst:45 msgid "" -"Return the group database entry for the given numeric group ID. :exc:" -"`KeyError` is raised if the entry asked for cannot be found." +"Return the group database entry for the given numeric group " +"ID. :exc:`KeyError` is raised if the entry asked for cannot be found." msgstr "" #: library/grp.rst:48 @@ -133,7 +134,7 @@ msgstr "" msgid "Return a list of all available group entries, in arbitrary order." msgstr "" -#: library/grp.rst:65 +#: library/grp.rst:64 msgid "Module :mod:`pwd`" msgstr "" diff --git a/library/gzip.po b/library/gzip.po index 5d5476ee..b2bdeb69 100644 --- a/library/gzip.po +++ b/library/gzip.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/gzip.rst:2 -msgid ":mod:`gzip` --- Support for :program:`gzip` files" +msgid ":mod:`!gzip` --- Support for :program:`gzip` files" msgstr "" #: library/gzip.rst:7 @@ -36,18 +37,18 @@ msgstr "" #: library/gzip.rst:16 msgid "" -"The :mod:`gzip` module provides the :class:`GzipFile` class, as well as the :" -"func:`.open`, :func:`compress` and :func:`decompress` convenience functions. " -"The :class:`GzipFile` class reads and writes :program:`gzip`\\ -format " -"files, automatically compressing or decompressing the data so that it looks " -"like an ordinary :term:`file object`." +"The :mod:`gzip` module provides the :class:`GzipFile` class, as well as " +"the :func:`.open`, :func:`compress` and :func:`decompress` convenience " +"functions. The :class:`GzipFile` class reads and writes :program:`gzip`\\ " +"-format files, automatically compressing or decompressing the data so that " +"it looks like an ordinary :term:`file object`." msgstr "" #: library/gzip.rst:22 msgid "" -"Note that additional file formats which can be decompressed by the :program:" -"`gzip` and :program:`gunzip` programs, such as those produced by :program:" -"`compress` and :program:`pack`, are not supported by this module." +"Note that additional file formats which can be decompressed by " +"the :program:`gzip` and :program:`gunzip` programs, such as those produced " +"by :program:`compress` and :program:`pack`, are not supported by this module." msgstr "" #: library/gzip.rst:26 @@ -62,8 +63,9 @@ msgstr "" #: library/gzip.rst:34 msgid "" -"The *filename* argument can be an actual filename (a :class:`str` or :class:" -"`bytes` object), or an existing file object to read from or write to." +"The *filename* argument can be an actual filename (a :class:`str` " +"or :class:`bytes` object), or an existing file object to read from or write " +"to." msgstr "" #: library/gzip.rst:37 @@ -75,8 +77,8 @@ msgstr "" #: library/gzip.rst:41 msgid "" -"The *compresslevel* argument is an integer from 0 to 9, as for the :class:" -"`GzipFile` constructor." +"The *compresslevel* argument is an integer from 0 to 9, as for " +"the :class:`GzipFile` constructor." msgstr "" #: library/gzip.rst:44 @@ -88,8 +90,8 @@ msgstr "" #: library/gzip.rst:48 msgid "" -"For text mode, a :class:`GzipFile` object is created, and wrapped in an :" -"class:`io.TextIOWrapper` instance with the specified encoding, error " +"For text mode, a :class:`GzipFile` object is created, and wrapped in " +"an :class:`io.TextIOWrapper` instance with the specified encoding, error " "handling behavior, and line ending(s)." msgstr "" @@ -109,17 +111,17 @@ msgstr "" #: library/gzip.rst:64 msgid "" -"An exception raised for invalid gzip files. It inherits from :exc:" -"`OSError`. :exc:`EOFError` and :exc:`zlib.error` can also be raised for " -"invalid gzip files." +"An exception raised for invalid gzip files. It inherits " +"from :exc:`OSError`. :exc:`EOFError` and :exc:`zlib.error` can also be " +"raised for invalid gzip files." msgstr "" #: library/gzip.rst:72 msgid "" "Constructor for the :class:`GzipFile` class, which simulates most of the " -"methods of a :term:`file object`, with the exception of the :meth:`~io." -"IOBase.truncate` method. At least one of *fileobj* and *filename* must be " -"given a non-trivial value." +"methods of a :term:`file object`, with the exception of " +"the :meth:`~io.IOBase.truncate` method. At least one of *fileobj* and " +"*filename* must be given a non-trivial value." msgstr "" #: library/gzip.rst:77 @@ -177,15 +179,15 @@ msgid "" "Calling a :class:`GzipFile` object's :meth:`!close` method does not close " "*fileobj*, since you might wish to append more material after the compressed " "data. This also allows you to pass an :class:`io.BytesIO` object opened for " -"writing as *fileobj*, and retrieve the resulting memory buffer using the :" -"class:`io.BytesIO` object's :meth:`~io.BytesIO.getvalue` method." +"writing as *fileobj*, and retrieve the resulting memory buffer using " +"the :class:`io.BytesIO` object's :meth:`~io.BytesIO.getvalue` method." msgstr "" #: library/gzip.rst:114 msgid "" ":class:`GzipFile` supports the :class:`io.BufferedIOBase` interface, " -"including iteration and the :keyword:`with` statement. Only the :meth:`~io." -"IOBase.truncate` method isn't implemented." +"including iteration and the :keyword:`with` statement. Only " +"the :meth:`~io.IOBase.truncate` method isn't implemented." msgstr "" #: library/gzip.rst:118 @@ -201,9 +203,10 @@ msgstr "" #: library/gzip.rst:127 msgid "" -"While calling :meth:`peek` does not change the file position of the :class:" -"`GzipFile`, it may change the position of the underlying file object (e.g. " -"if the :class:`GzipFile` was constructed with the *fileobj* parameter)." +"While calling :meth:`peek` does not change the file position of " +"the :class:`GzipFile`, it may change the position of the underlying file " +"object (e.g. if the :class:`GzipFile` was constructed with the *fileobj* " +"parameter)." msgstr "" #: library/gzip.rst:136 @@ -217,9 +220,9 @@ msgstr "" msgid "" "All :program:`gzip` compressed streams are required to contain this " "timestamp field. Some programs, such as :program:`gunzip`\\ , make use of " -"the timestamp. The format is the same as the return value of :func:`time." -"time` and the :attr:`~os.stat_result.st_mtime` attribute of the object " -"returned by :func:`os.stat`." +"the timestamp. The format is the same as the return value " +"of :func:`time.time` and the :attr:`~os.stat_result.st_mtime` attribute of " +"the object returned by :func:`os.stat`." msgstr "" #: library/gzip.rst:148 @@ -282,11 +285,13 @@ msgstr "" #: library/gzip.rst:194 msgid "" "Speed is improved by compressing all data at once instead of in a streamed " -"fashion. Calls with *mtime* set to ``0`` are delegated to :func:`zlib." -"compress` for better speed." +"fashion. Calls with *mtime* set to ``0`` are delegated " +"to :func:`zlib.compress` for better speed. In this situation the output may " +"contain a gzip header \"OS\" byte value other than 255 \"unknown\" as " +"supplied by the underlying zlib implementation." msgstr "" -#: library/gzip.rst:201 +#: library/gzip.rst:203 msgid "" "Decompress the *data*, returning a :class:`bytes` object containing the " "uncompressed data. This function is capable of decompressing multi-member " @@ -295,82 +300,113 @@ msgid "" "*wbits* set to 31 is faster." msgstr "" -#: library/gzip.rst:208 +#: library/gzip.rst:210 msgid "" "Speed is improved by decompressing members at once in memory instead of in a " "streamed fashion." msgstr "" -#: library/gzip.rst:215 +#: library/gzip.rst:217 msgid "Examples of usage" msgstr "" -#: library/gzip.rst:217 +#: library/gzip.rst:219 msgid "Example of how to read a compressed file::" msgstr "" -#: library/gzip.rst:223 +#: library/gzip.rst:221 +msgid "" +"import gzip\n" +"with gzip.open('/home/joe/file.txt.gz', 'rb') as f:\n" +" file_content = f.read()" +msgstr "" + +#: library/gzip.rst:225 msgid "Example of how to create a compressed GZIP file::" msgstr "" -#: library/gzip.rst:230 +#: library/gzip.rst:227 +msgid "" +"import gzip\n" +"content = b\"Lots of content here\"\n" +"with gzip.open('/home/joe/file.txt.gz', 'wb') as f:\n" +" f.write(content)" +msgstr "" + +#: library/gzip.rst:232 msgid "Example of how to GZIP compress an existing file::" msgstr "" -#: library/gzip.rst:238 +#: library/gzip.rst:234 +msgid "" +"import gzip\n" +"import shutil\n" +"with open('/home/joe/file.txt', 'rb') as f_in:\n" +" with gzip.open('/home/joe/file.txt.gz', 'wb') as f_out:\n" +" shutil.copyfileobj(f_in, f_out)" +msgstr "" + +#: library/gzip.rst:240 msgid "Example of how to GZIP compress a binary string::" msgstr "" -#: library/gzip.rst:247 +#: library/gzip.rst:242 +msgid "" +"import gzip\n" +"s_in = b\"Lots of content here\"\n" +"s_out = gzip.compress(s_in)" +msgstr "" + +#: library/gzip.rst:248 msgid "Module :mod:`zlib`" msgstr "" -#: library/gzip.rst:247 +#: library/gzip.rst:249 msgid "" "The basic data compression module needed to support the :program:`gzip` file " "format." msgstr "" -#: library/gzip.rst:256 +#: library/gzip.rst:258 msgid "Command Line Interface" msgstr "" -#: library/gzip.rst:258 +#: library/gzip.rst:260 msgid "" "The :mod:`gzip` module provides a simple command line interface to compress " "or decompress files." msgstr "" -#: library/gzip.rst:261 +#: library/gzip.rst:263 msgid "Once executed the :mod:`gzip` module keeps the input file(s)." msgstr "" -#: library/gzip.rst:265 +#: library/gzip.rst:267 msgid "" "Add a new command line interface with a usage. By default, when you will " "execute the CLI, the default compression level is 6." msgstr "" -#: library/gzip.rst:269 +#: library/gzip.rst:271 msgid "Command line options" msgstr "" -#: library/gzip.rst:273 +#: library/gzip.rst:275 msgid "If *file* is not specified, read from :data:`sys.stdin`." msgstr "" -#: library/gzip.rst:277 +#: library/gzip.rst:279 msgid "Indicates the fastest compression method (less compression)." msgstr "" -#: library/gzip.rst:281 +#: library/gzip.rst:283 msgid "Indicates the slowest compression method (best compression)." msgstr "" -#: library/gzip.rst:285 +#: library/gzip.rst:287 msgid "Decompress the given file." msgstr "" -#: library/gzip.rst:289 +#: library/gzip.rst:291 msgid "Show the help message." msgstr "" diff --git a/library/hashlib.po b/library/hashlib.po index 9ccfd38f..290af6fc 100644 --- a/library/hashlib.po +++ b/library/hashlib.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/hashlib.rst:2 -msgid ":mod:`hashlib` --- Secure hashes and message digests" +msgid ":mod:`!hashlib` --- Secure hashes and message digests" msgstr "" #: library/hashlib.rst:10 @@ -37,8 +38,8 @@ msgstr "" #: library/hashlib.rst:33 msgid "" -"If you want the adler32 or crc32 hash functions, they are available in the :" -"mod:`zlib` module." +"If you want the adler32 or crc32 hash functions, they are available in " +"the :mod:`zlib` module." msgstr "" #: library/hashlib.rst:40 @@ -48,39 +49,38 @@ msgstr "" #: library/hashlib.rst:42 msgid "" "There is one constructor method named for each type of :dfn:`hash`. All " -"return a hash object with the same simple interface. For example: use :func:" -"`sha256` to create a SHA-256 hash object. You can now feed this object with :" -"term:`bytes-like objects ` (normally :class:`bytes`) " -"using the :meth:`update` method. At any point you can ask it " -"for the :dfn:`digest` of the concatenation of the data fed to it so far " -"using the :meth:`digest()` or :meth:`hexdigest()` methods." +"return a hash object with the same simple interface. For example: " +"use :func:`sha256` to create a SHA-256 hash object. You can now feed this " +"object with :term:`bytes-like objects ` " +"(normally :class:`bytes`) using the :meth:`update` method. At " +"any point you can ask it for the :dfn:`digest` of the concatenation of the " +"data fed to it so far using the :meth:`digest()` " +"or :meth:`hexdigest()` methods." msgstr "" #: library/hashlib.rst:50 msgid "" "To allow multithreading, the Python :term:`GIL` is released while computing " -"a hash supplied more than 2047 bytes of data at once in its constructor or :" -"meth:`.update` method." +"a hash supplied more than 2047 bytes of data at once in its constructor " +"or :meth:`.update` method." msgstr "" #: library/hashlib.rst:57 msgid "" -"Constructors for hash algorithms that are always present in this module are :" -"func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`, :func:" -"`sha512`, :func:`sha3_224`, :func:`sha3_256`, :func:`sha3_384`, :func:" -"`sha3_512`, :func:`shake_128`, :func:`shake_256`, :func:`blake2b`, and :func:" -"`blake2s`. :func:`md5` is normally available as well, though it may be " -"missing or blocked if you are using a rare \"FIPS compliant\" build of " -"Python. These correspond to :data:`algorithms_guaranteed`." +"Constructors for hash algorithms that are always present in this module " +"are :func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`, :func:`sha512`, :func:`sha3_224`, :func:`sha3_256`, :func:`sha3_384`, :func:`sha3_512`, :func:`shake_128`, :func:`shake_256`, :func:`blake2b`, " +"and :func:`blake2s`. :func:`md5` is normally available as well, though it " +"may be missing or blocked if you are using a rare \"FIPS compliant\" build " +"of Python. These correspond to :data:`algorithms_guaranteed`." msgstr "" #: library/hashlib.rst:65 msgid "" -"Additional algorithms may also be available if your Python distribution's :" -"mod:`hashlib` was linked against a build of OpenSSL that provides others. " -"Others *are not guaranteed available* on all installations and will only be " -"accessible by name via :func:`new`. See :data:`algorithms_available`." +"Additional algorithms may also be available if your Python " +"distribution's :mod:`hashlib` was linked against a build of OpenSSL that " +"provides others. Others *are not guaranteed available* on all installations " +"and will only be accessible by name via :func:`new`. " +"See :data:`algorithms_available`." msgstr "" #: library/hashlib.rst:72 @@ -92,9 +92,9 @@ msgstr "" #: library/hashlib.rst:76 msgid "" -"SHA3 (Keccak) and SHAKE constructors :func:`sha3_224`, :func:`sha3_256`, :" -"func:`sha3_384`, :func:`sha3_512`, :func:`shake_128`, :func:`shake_256` were " -"added. :func:`blake2b` and :func:`blake2s` were added." +"SHA3 (Keccak) and SHAKE " +"constructors :func:`sha3_224`, :func:`sha3_256`, :func:`sha3_384`, :func:`sha3_512`, :func:`shake_128`, :func:`shake_256` " +"were added. :func:`blake2b` and :func:`blake2s` were added." msgstr "" #: library/hashlib.rst:84 @@ -127,6 +127,19 @@ msgid "" "repetition\"``::" msgstr "" +#: library/hashlib.rst:105 +msgid "" +">>> import hashlib\n" +">>> m = hashlib.sha256()\n" +">>> m.update(b\"Nobody inspects\")\n" +">>> m.update(b\" the spammish repetition\")\n" +">>> m.digest()\n" +"b'\\x03\\x1e\\xdd}Ae\\x15\\x93\\xc5\\xfe\\\\" +"\\x00o\\xa5u+7\\xfd\\xdf\\xf7\\xbcN\\x84:\\xa6\\xaf\\x0c\\x95\\x0fK\\x94\\x06'\n" +">>> m.hexdigest()\n" +"'031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'" +msgstr "" + #: library/hashlib.rst:114 msgid "More condensed:" msgstr "" @@ -172,8 +185,8 @@ msgstr "" #: library/hashlib.rst:167 msgid "" "A set containing the names of the hash algorithms that are available in the " -"running Python interpreter. These names will be recognized when passed to :" -"func:`new`. :attr:`algorithms_guaranteed` will always be a subset. The " +"running Python interpreter. These names will be recognized when passed " +"to :func:`new`. :attr:`algorithms_guaranteed` will always be a subset. The " "same algorithm may appear multiple times in this set under different names " "(thanks to OpenSSL)." msgstr "" @@ -349,8 +362,9 @@ msgstr "" #: library/hashlib.rst:331 msgid "" -"*dklen* is the length of the derived key. If *dklen* is ``None`` then the " -"digest size of the hash algorithm *hash_name* is used, e.g. 64 for SHA-512." +"*dklen* is the length of the derived key in bytes. If *dklen* is ``None`` " +"then the digest size of the hash algorithm *hash_name* is used, e.g. 64 for " +"SHA-512." msgstr "" #: library/hashlib.rst:340 @@ -381,7 +395,7 @@ msgstr "" msgid "" "*n* is the CPU/Memory cost factor, *r* the block size, *p* parallelization " "factor and *maxmem* limits memory (OpenSSL 1.1.0 defaults to 32 MiB). " -"*dklen* is the length of the derived key." +"*dklen* is the length of the derived key in bytes." msgstr "" #: library/hashlib.rst:366 @@ -414,8 +428,8 @@ msgstr "" #: library/hashlib.rst:385 msgid "" -"Hash objects from this module follow the API of standard library's :mod:" -"`hashlib` objects." +"Hash objects from this module follow the API of standard " +"library's :mod:`hashlib` objects." msgstr "" #: library/hashlib.rst:390 @@ -566,7 +580,7 @@ msgid "" "(``False`` for sequential mode)." msgstr "" -#: library/hashlib.rst:-1 +#: library/hashlib.rst:464 msgid "Explanation of tree mode parameters." msgstr "" @@ -608,10 +622,11 @@ msgstr "" #: library/hashlib.rst:506 msgid "" "To calculate hash of some data, you should first construct a hash object by " -"calling the appropriate constructor function (:func:`blake2b` or :func:" -"`blake2s`), then update it with the data by calling :meth:`~hash.update` on " -"the object, and, finally, get the digest out of the object by calling :meth:" -"`~hash.digest` (or :meth:`~hash.hexdigest` for hex-encoded string)." +"calling the appropriate constructor function (:func:`blake2b` " +"or :func:`blake2s`), then update it with the data by " +"calling :meth:`~hash.update` on the object, and, finally, get the digest out " +"of the object by calling :meth:`~hash.digest` (or :meth:`~hash.hexdigest` " +"for hex-encoded string)." msgstr "" #: library/hashlib.rst:519 @@ -651,9 +666,9 @@ msgstr "" #: library/hashlib.rst:574 msgid "" "Keyed hashing can be used for authentication as a faster and simpler " -"replacement for `Hash-based message authentication code `_ (HMAC). BLAKE2 can be securely used in prefix-MAC " -"mode thanks to the indifferentiability property inherited from BLAKE." +"replacement for `Hash-based message authentication code `_ (HMAC). BLAKE2 can be securely used in prefix-" +"MAC mode thanks to the indifferentiability property inherited from BLAKE." msgstr "" #: library/hashlib.rst:580 @@ -662,18 +677,65 @@ msgid "" "for message ``b'message data'`` with key ``b'pseudorandom key'``::" msgstr "" +#: library/hashlib.rst:583 +msgid "" +">>> from hashlib import blake2b\n" +">>> h = blake2b(key=b'pseudorandom key', digest_size=16)\n" +">>> h.update(b'message data')\n" +">>> h.hexdigest()\n" +"'3d363ff7401e02026f4a4687d4863ced'" +msgstr "" + #: library/hashlib.rst:590 msgid "" "As a practical example, a web application can symmetrically sign cookies " "sent to users and later verify them to make sure they weren't tampered with::" msgstr "" +#: library/hashlib.rst:593 +msgid "" +">>> from hashlib import blake2b\n" +">>> from hmac import compare_digest\n" +">>>\n" +">>> SECRET_KEY = b'pseudorandomly generated server secret key'\n" +">>> AUTH_SIZE = 16\n" +">>>\n" +">>> def sign(cookie):\n" +"... h = blake2b(digest_size=AUTH_SIZE, key=SECRET_KEY)\n" +"... h.update(cookie)\n" +"... return h.hexdigest().encode('utf-8')\n" +">>>\n" +">>> def verify(cookie, sig):\n" +"... good_sig = sign(cookie)\n" +"... return compare_digest(good_sig, sig)\n" +">>>\n" +">>> cookie = b'user-alice'\n" +">>> sig = sign(cookie)\n" +">>> print(\"{0},{1}\".format(cookie.decode('utf-8'), sig))\n" +"user-alice,b'43b3c982cf697e0c5ab22172d1ca7421'\n" +">>> verify(cookie, sig)\n" +"True\n" +">>> verify(b'user-bob', sig)\n" +"False\n" +">>> verify(cookie, b'0102030405060708090a0b0c0d0e0f00')\n" +"False" +msgstr "" + #: library/hashlib.rst:619 msgid "" "Even though there's a native keyed hashing mode, BLAKE2 can, of course, be " "used in HMAC construction with :mod:`hmac` module::" msgstr "" +#: library/hashlib.rst:622 +msgid "" +">>> import hmac, hashlib\n" +">>> m = hmac.new(b'secret key', digestmod=hashlib.blake2s)\n" +">>> m.update(b'message')\n" +">>> m.hexdigest()\n" +"'e3c8102868d28b5ff85fc35dda07329970d1a01e273c37481326fe0c861c8142'" +msgstr "" + #: library/hashlib.rst:630 msgid "Randomized hashing" msgstr "" @@ -709,7 +771,7 @@ msgstr "" #: library/hashlib.rst:655 msgid "" "(`NIST SP-800-106 \"Randomized Hashing for Digital Signatures\" `_)" +"csrc.nist.gov/pubs/sp/800/106/final>`_)" msgstr "" #: library/hashlib.rst:658 @@ -757,6 +819,21 @@ msgstr "" msgid "BLAKE2 can be personalized by passing bytes to the *person* argument::" msgstr "" +#: library/hashlib.rst:705 +msgid "" +">>> from hashlib import blake2b\n" +">>> FILES_HASH_PERSON = b'MyApp Files Hash'\n" +">>> BLOCK_HASH_PERSON = b'MyApp Block Hash'\n" +">>> h = blake2b(digest_size=32, person=FILES_HASH_PERSON)\n" +">>> h.update(b'the same content')\n" +">>> h.hexdigest()\n" +"'20d9cd024d4fb086aae819a1432dd2466de12947831b75c5a30cf2676095d3b4'\n" +">>> h = blake2b(digest_size=32, person=BLOCK_HASH_PERSON)\n" +">>> h.update(b'the same content')\n" +">>> h.hexdigest()\n" +"'cf68fb5761b9c44e7878bfb2c4c9aea52264a80b75005e65619778de59f383a3'" +msgstr "" + #: library/hashlib.rst:717 msgid "" "Personalization together with the keyed mode can also be used to derive " @@ -771,12 +848,48 @@ msgstr "" msgid "Here's an example of hashing a minimal tree with two leaf nodes::" msgstr "" +#: library/hashlib.rst:735 +msgid "" +" 10\n" +" / \\\n" +"00 01" +msgstr "" + #: library/hashlib.rst:739 msgid "" "This example uses 64-byte internal digests, and returns the 32-byte final " "digest::" msgstr "" +#: library/hashlib.rst:742 +msgid "" +">>> from hashlib import blake2b\n" +">>>\n" +">>> FANOUT = 2\n" +">>> DEPTH = 2\n" +">>> LEAF_SIZE = 4096\n" +">>> INNER_SIZE = 64\n" +">>>\n" +">>> buf = bytearray(6000)\n" +">>>\n" +">>> # Left leaf\n" +"... h00 = blake2b(buf[0:LEAF_SIZE], fanout=FANOUT, depth=DEPTH,\n" +"... leaf_size=LEAF_SIZE, inner_size=INNER_SIZE,\n" +"... node_offset=0, node_depth=0, last_node=False)\n" +">>> # Right leaf\n" +"... h01 = blake2b(buf[LEAF_SIZE:], fanout=FANOUT, depth=DEPTH,\n" +"... leaf_size=LEAF_SIZE, inner_size=INNER_SIZE,\n" +"... node_offset=1, node_depth=0, last_node=True)\n" +">>> # Root node\n" +"... h10 = blake2b(digest_size=32, fanout=FANOUT, depth=DEPTH,\n" +"... leaf_size=LEAF_SIZE, inner_size=INNER_SIZE,\n" +"... node_offset=0, node_depth=1, last_node=True)\n" +">>> h10.update(h00.digest())\n" +">>> h10.update(h01.digest())\n" +">>> h10.hexdigest()\n" +"'3ad2a9b37c6070e374c7a8c508fe20ca86b6ed54e286e93a0318e95e881db5aa'" +msgstr "" + #: library/hashlib.rst:769 msgid "Credits" msgstr "" @@ -837,7 +950,7 @@ msgstr "" msgid "*Alexandr Sokolovskiy*" msgstr "" -#: library/hashlib.rst:820 +#: library/hashlib.rst:819 msgid "Module :mod:`hmac`" msgstr "" @@ -845,7 +958,7 @@ msgstr "" msgid "A module to generate message authentication codes using hashes." msgstr "" -#: library/hashlib.rst:823 +#: library/hashlib.rst:822 msgid "Module :mod:`base64`" msgstr "" @@ -853,7 +966,7 @@ msgstr "" msgid "Another way to encode binary hashes for non-binary environments." msgstr "" -#: library/hashlib.rst:826 +#: library/hashlib.rst:825 msgid "https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.180-4.pdf" msgstr "" @@ -861,15 +974,15 @@ msgstr "" msgid "The FIPS 180-4 publication on Secure Hash Algorithms." msgstr "" -#: library/hashlib.rst:829 -msgid "https://csrc.nist.gov/publications/detail/fips/202/final" +#: library/hashlib.rst:828 +msgid "https://csrc.nist.gov/pubs/fips/202/final" msgstr "" #: library/hashlib.rst:829 msgid "The FIPS 202 publication on the SHA-3 Standard." msgstr "" -#: library/hashlib.rst:832 +#: library/hashlib.rst:831 msgid "https://www.blake2.net/" msgstr "" @@ -877,7 +990,7 @@ msgstr "" msgid "Official BLAKE2 website." msgstr "" -#: library/hashlib.rst:836 +#: library/hashlib.rst:834 msgid "https://en.wikipedia.org/wiki/Cryptographic_hash_function" msgstr "" @@ -887,7 +1000,7 @@ msgid "" "what that means regarding their use." msgstr "" -#: library/hashlib.rst:839 +#: library/hashlib.rst:838 msgid "https://www.ietf.org/rfc/rfc8018.txt" msgstr "" diff --git a/library/heapq.po b/library/heapq.po index e34af524..c90c44b1 100644 --- a/library/heapq.po +++ b/library/heapq.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/heapq.rst:2 -msgid ":mod:`heapq` --- Heap queue algorithm" +msgid ":mod:`!heapq` --- Heap queue algorithm" msgstr "" #: library/heapq.rst:12 @@ -33,14 +34,20 @@ msgstr "" #: library/heapq.rst:19 msgid "" "Heaps are binary trees for which every parent node has a value less than or " -"equal to any of its children. This implementation uses arrays for which " -"``heap[k] <= heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]`` for all *k*, " -"counting elements from zero. For the sake of comparison, non-existing " -"elements are considered to be infinite. The interesting property of a heap " -"is that its smallest element is always the root, ``heap[0]``." +"equal to any of its children. We refer to this condition as the heap " +"invariant." +msgstr "" + +#: library/heapq.rst:22 +msgid "" +"This implementation uses arrays for which ``heap[k] <= heap[2*k+1]`` and " +"``heap[k] <= heap[2*k+2]`` for all *k*, counting elements from zero. For " +"the sake of comparison, non-existing elements are considered to be " +"infinite. The interesting property of a heap is that its smallest element " +"is always the root, ``heap[0]``." msgstr "" -#: library/heapq.rst:26 +#: library/heapq.rst:28 msgid "" "The API below differs from textbook heap algorithms in two aspects: (a) We " "use zero-based indexing. This makes the relationship between the index for " @@ -51,53 +58,53 @@ msgid "" "sorting)." msgstr "" -#: library/heapq.rst:33 +#: library/heapq.rst:35 msgid "" "These two make it possible to view the heap as a regular Python list without " "surprises: ``heap[0]`` is the smallest item, and ``heap.sort()`` maintains " "the heap invariant!" msgstr "" -#: library/heapq.rst:37 +#: library/heapq.rst:39 msgid "" "To create a heap, use a list initialized to ``[]``, or you can transform a " "populated list into a heap via function :func:`heapify`." msgstr "" -#: library/heapq.rst:40 +#: library/heapq.rst:42 msgid "The following functions are provided:" msgstr "" -#: library/heapq.rst:45 +#: library/heapq.rst:47 msgid "Push the value *item* onto the *heap*, maintaining the heap invariant." msgstr "" -#: library/heapq.rst:50 +#: library/heapq.rst:52 msgid "" "Pop and return the smallest item from the *heap*, maintaining the heap " "invariant. If the heap is empty, :exc:`IndexError` is raised. To access " "the smallest item without popping it, use ``heap[0]``." msgstr "" -#: library/heapq.rst:57 +#: library/heapq.rst:59 msgid "" "Push *item* on the heap, then pop and return the smallest item from the " "*heap*. The combined action runs more efficiently than :func:`heappush` " "followed by a separate call to :func:`heappop`." msgstr "" -#: library/heapq.rst:64 +#: library/heapq.rst:66 msgid "Transform list *x* into a heap, in-place, in linear time." msgstr "" -#: library/heapq.rst:69 +#: library/heapq.rst:71 msgid "" "Pop and return the smallest item from the *heap*, and also push the new " -"*item*. The heap size doesn't change. If the heap is empty, :exc:" -"`IndexError` is raised." +"*item*. The heap size doesn't change. If the heap is " +"empty, :exc:`IndexError` is raised." msgstr "" -#: library/heapq.rst:72 +#: library/heapq.rst:74 msgid "" "This one step operation is more efficient than a :func:`heappop` followed " "by :func:`heappush` and can be more appropriate when using a fixed-size " @@ -105,7 +112,7 @@ msgid "" "replaces it with *item*." msgstr "" -#: library/heapq.rst:77 +#: library/heapq.rst:79 msgid "" "The value returned may be larger than the *item* added. If that isn't " "desired, consider using :func:`heappushpop` instead. Its push/pop " @@ -113,37 +120,37 @@ msgid "" "on the heap." msgstr "" -#: library/heapq.rst:83 +#: library/heapq.rst:85 msgid "The module also offers three general purpose functions based on heaps." msgstr "" -#: library/heapq.rst:88 +#: library/heapq.rst:90 msgid "" "Merge multiple sorted inputs into a single sorted output (for example, merge " "timestamped entries from multiple log files). Returns an :term:`iterator` " "over the sorted values." msgstr "" -#: library/heapq.rst:92 +#: library/heapq.rst:94 msgid "" "Similar to ``sorted(itertools.chain(*iterables))`` but returns an iterable, " "does not pull the data into memory all at once, and assumes that each of the " "input streams is already sorted (smallest to largest)." msgstr "" -#: library/heapq.rst:96 +#: library/heapq.rst:98 msgid "" "Has two optional arguments which must be specified as keyword arguments." msgstr "" -#: library/heapq.rst:98 +#: library/heapq.rst:100 msgid "" "*key* specifies a :term:`key function` of one argument that is used to " "extract a comparison key from each input element. The default value is " "``None`` (compare the elements directly)." msgstr "" -#: library/heapq.rst:102 +#: library/heapq.rst:104 msgid "" "*reverse* is a boolean value. If set to ``True``, then the input elements " "are merged as if each comparison were reversed. To achieve behavior similar " @@ -151,11 +158,11 @@ msgid "" "be sorted from largest to smallest." msgstr "" -#: library/heapq.rst:107 +#: library/heapq.rst:109 msgid "Added the optional *key* and *reverse* parameters." msgstr "" -#: library/heapq.rst:113 +#: library/heapq.rst:115 msgid "" "Return a list with the *n* largest elements from the dataset defined by " "*iterable*. *key*, if provided, specifies a function of one argument that " @@ -164,82 +171,105 @@ msgid "" "reverse=True)[:n]``." msgstr "" -#: library/heapq.rst:122 +#: library/heapq.rst:124 msgid "" "Return a list with the *n* smallest elements from the dataset defined by " "*iterable*. *key*, if provided, specifies a function of one argument that " "is used to extract a comparison key from each element in *iterable* (for " -"example, ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key)[:" -"n]``." +"example, ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key)" +"[:n]``." msgstr "" -#: library/heapq.rst:128 +#: library/heapq.rst:130 msgid "" "The latter two functions perform best for smaller values of *n*. For larger " "values, it is more efficient to use the :func:`sorted` function. Also, when " -"``n==1``, it is more efficient to use the built-in :func:`min` and :func:" -"`max` functions. If repeated usage of these functions is required, consider " -"turning the iterable into an actual heap." +"``n==1``, it is more efficient to use the built-in :func:`min` " +"and :func:`max` functions. If repeated usage of these functions is " +"required, consider turning the iterable into an actual heap." msgstr "" -#: library/heapq.rst:136 +#: library/heapq.rst:138 msgid "Basic Examples" msgstr "" -#: library/heapq.rst:138 +#: library/heapq.rst:140 msgid "" "A `heapsort `_ can be implemented by " "pushing all values onto a heap and then popping off the smallest values one " "at a time::" msgstr "" -#: library/heapq.rst:151 +#: library/heapq.rst:144 +msgid "" +">>> def heapsort(iterable):\n" +"... h = []\n" +"... for value in iterable:\n" +"... heappush(h, value)\n" +"... return [heappop(h) for i in range(len(h))]\n" +"...\n" +">>> heapsort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])\n" +"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]" +msgstr "" + +#: library/heapq.rst:153 msgid "" "This is similar to ``sorted(iterable)``, but unlike :func:`sorted`, this " "implementation is not stable." msgstr "" -#: library/heapq.rst:154 +#: library/heapq.rst:156 msgid "" "Heap elements can be tuples. This is useful for assigning comparison values " "(such as task priorities) alongside the main record being tracked::" msgstr "" -#: library/heapq.rst:167 -msgid "Priority Queue Implementation Notes" +#: library/heapq.rst:159 +msgid "" +">>> h = []\n" +">>> heappush(h, (5, 'write code'))\n" +">>> heappush(h, (7, 'release product'))\n" +">>> heappush(h, (1, 'write spec'))\n" +">>> heappush(h, (3, 'create tests'))\n" +">>> heappop(h)\n" +"(1, 'write spec')" msgstr "" #: library/heapq.rst:169 +msgid "Priority Queue Implementation Notes" +msgstr "" + +#: library/heapq.rst:171 msgid "" "A `priority queue `_ is common " "use for a heap, and it presents several implementation challenges:" msgstr "" -#: library/heapq.rst:172 +#: library/heapq.rst:174 msgid "" "Sort stability: how do you get two tasks with equal priorities to be " "returned in the order they were originally added?" msgstr "" -#: library/heapq.rst:175 +#: library/heapq.rst:177 msgid "" "Tuple comparison breaks for (priority, task) pairs if the priorities are " "equal and the tasks do not have a default comparison order." msgstr "" -#: library/heapq.rst:178 +#: library/heapq.rst:180 msgid "" "If the priority of a task changes, how do you move it to a new position in " "the heap?" msgstr "" -#: library/heapq.rst:181 +#: library/heapq.rst:183 msgid "" "Or if a pending task needs to be deleted, how do you find it and remove it " "from the queue?" msgstr "" -#: library/heapq.rst:184 +#: library/heapq.rst:186 msgid "" "A solution to the first two challenges is to store entries as 3-element list " "including the priority, an entry count, and the task. The entry count " @@ -248,32 +278,74 @@ msgid "" "same, the tuple comparison will never attempt to directly compare two tasks." msgstr "" -#: library/heapq.rst:190 +#: library/heapq.rst:192 msgid "" "Another solution to the problem of non-comparable tasks is to create a " "wrapper class that ignores the task item and only compares the priority " "field::" msgstr "" -#: library/heapq.rst:201 +#: library/heapq.rst:195 +msgid "" +"from dataclasses import dataclass, field\n" +"from typing import Any\n" +"\n" +"@dataclass(order=True)\n" +"class PrioritizedItem:\n" +" priority: int\n" +" item: Any=field(compare=False)" +msgstr "" + +#: library/heapq.rst:203 msgid "" "The remaining challenges revolve around finding a pending task and making " "changes to its priority or removing it entirely. Finding a task can be done " "with a dictionary pointing to an entry in the queue." msgstr "" -#: library/heapq.rst:205 +#: library/heapq.rst:207 msgid "" "Removing the entry or changing its priority is more difficult because it " "would break the heap structure invariants. So, a possible solution is to " "mark the entry as removed and add a new entry with the revised priority::" msgstr "" -#: library/heapq.rst:239 -msgid "Theory" +#: library/heapq.rst:211 +msgid "" +"pq = [] # list of entries arranged in a heap\n" +"entry_finder = {} # mapping of tasks to entries\n" +"REMOVED = '' # placeholder for a removed task\n" +"counter = itertools.count() # unique sequence count\n" +"\n" +"def add_task(task, priority=0):\n" +" 'Add a new task or update the priority of an existing task'\n" +" if task in entry_finder:\n" +" remove_task(task)\n" +" count = next(counter)\n" +" entry = [priority, count, task]\n" +" entry_finder[task] = entry\n" +" heappush(pq, entry)\n" +"\n" +"def remove_task(task):\n" +" 'Mark an existing task as REMOVED. Raise KeyError if not found.'\n" +" entry = entry_finder.pop(task)\n" +" entry[-1] = REMOVED\n" +"\n" +"def pop_task():\n" +" 'Remove and return the lowest priority task. Raise KeyError if empty.'\n" +" while pq:\n" +" priority, count, task = heappop(pq)\n" +" if task is not REMOVED:\n" +" del entry_finder[task]\n" +" return task\n" +" raise KeyError('pop from an empty priority queue')" msgstr "" #: library/heapq.rst:241 +msgid "Theory" +msgstr "" + +#: library/heapq.rst:243 msgid "" "Heaps are arrays for which ``a[k] <= a[2*k+1]`` and ``a[k] <= a[2*k+2]`` for " "all *k*, counting elements from 0. For the sake of comparison, non-existing " @@ -281,13 +353,26 @@ msgid "" "is that ``a[0]`` is always its smallest element." msgstr "" -#: library/heapq.rst:246 +#: library/heapq.rst:248 msgid "" "The strange invariant above is meant to be an efficient memory " "representation for a tournament. The numbers below are *k*, not ``a[k]``::" msgstr "" -#: library/heapq.rst:259 +#: library/heapq.rst:251 +msgid "" +" 0\n" +"\n" +" 1 2\n" +"\n" +" 3 4 5 6\n" +"\n" +" 7 8 9 10 11 12 13 14\n" +"\n" +"15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30" +msgstr "" + +#: library/heapq.rst:261 msgid "" "In the tree above, each cell *k* is topping ``2*k+1`` and ``2*k+2``. In a " "usual binary tournament we see in sports, each cell is the winner over the " @@ -300,7 +385,7 @@ msgid "" "over the two topped cells." msgstr "" -#: library/heapq.rst:268 +#: library/heapq.rst:270 msgid "" "If this heap invariant is protected at all time, index 0 is clearly the " "overall winner. The simplest algorithmic way to remove it and find the " @@ -311,7 +396,7 @@ msgid "" "items, you get an *O*\\ (*n* log *n*) sort." msgstr "" -#: library/heapq.rst:275 +#: library/heapq.rst:277 msgid "" "A nice feature of this sort is that you can efficiently insert new items " "while the sort is going on, provided that the inserted items are not " @@ -323,7 +408,7 @@ msgid "" "implementing schedulers (this is what I used for my MIDI sequencer :-)." msgstr "" -#: library/heapq.rst:284 +#: library/heapq.rst:286 msgid "" "Various structures for implementing schedulers have been extensively " "studied, and heaps are good for this, as they are reasonably speedy, the " @@ -332,7 +417,7 @@ msgid "" "efficient overall, yet the worst cases might be terrible." msgstr "" -#: library/heapq.rst:290 +#: library/heapq.rst:292 msgid "" "Heaps are also very useful in big disk sorts. You most probably all know " "that a big sort implies producing \"runs\" (which are pre-sorted sequences, " @@ -346,7 +431,7 @@ msgid "" "input fuzzily ordered." msgstr "" -#: library/heapq.rst:300 +#: library/heapq.rst:302 msgid "" "Moreover, if you output the 0'th item on disk and get an input which may not " "fit in the current tournament (because the value \"wins\" over the last " @@ -357,17 +442,17 @@ msgid "" "switch heaps and start a new run. Clever and quite effective!" msgstr "" -#: library/heapq.rst:308 +#: library/heapq.rst:310 msgid "" "In a word, heaps are useful memory structures to know. I use them in a few " "applications, and I think it is good to keep a 'heap' module around. :-)" msgstr "" -#: library/heapq.rst:312 +#: library/heapq.rst:314 msgid "Footnotes" msgstr "" -#: library/heapq.rst:313 +#: library/heapq.rst:315 msgid "" "The disk balancing algorithms which are current, nowadays, are more annoying " "than clever, and this is a consequence of the seeking capabilities of the " diff --git a/library/hmac.po b/library/hmac.po index 23034bfc..4f42566a 100644 --- a/library/hmac.po +++ b/library/hmac.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/hmac.rst:2 -msgid ":mod:`hmac` --- Keyed-Hashing for Message Authentication" +msgid ":mod:`!hmac` --- Keyed-Hashing for Message Authentication" msgstr "" #: library/hmac.rst:10 @@ -55,8 +56,8 @@ msgid "" "Return digest of *msg* for given secret *key* and *digest*. The function is " "equivalent to ``HMAC(key, msg, digest).digest()``, but uses an optimized C " "or inline implementation, which is faster for messages that fit into memory. " -"The parameters *key*, *msg*, and *digest* have the same meaning as in :func:" -"`~hmac.new`." +"The parameters *key*, *msg*, and *digest* have the same meaning as " +"in :func:`~hmac.new`." msgstr "" #: library/hmac.rst:43 @@ -73,8 +74,8 @@ msgstr "" #: library/hmac.rst:54 msgid "" "Update the hmac object with *msg*. Repeated calls are equivalent to a " -"single call with the concatenation of all the arguments: ``m.update(a); m." -"update(b)`` is equivalent to ``m.update(a + b)``." +"single call with the concatenation of all the arguments: ``m.update(a); " +"m.update(b)`` is equivalent to ``m.update(a + b)``." msgstr "" #: library/hmac.rst:58 @@ -92,9 +93,9 @@ msgstr "" #: library/hmac.rst:71 msgid "" "When comparing the output of :meth:`digest` to an externally supplied digest " -"during a verification routine, it is recommended to use the :func:" -"`compare_digest` function instead of the ``==`` operator to reduce the " -"vulnerability to timing attacks." +"during a verification routine, it is recommended to use " +"the :func:`compare_digest` function instead of the ``==`` operator to reduce " +"the vulnerability to timing attacks." msgstr "" #: library/hmac.rst:79 @@ -107,9 +108,9 @@ msgstr "" #: library/hmac.rst:85 msgid "" "When comparing the output of :meth:`hexdigest` to an externally supplied " -"digest during a verification routine, it is recommended to use the :func:" -"`compare_digest` function instead of the ``==`` operator to reduce the " -"vulnerability to timing attacks." +"digest during a verification routine, it is recommended to use " +"the :func:`compare_digest` function instead of the ``==`` operator to reduce " +"the vulnerability to timing attacks." msgstr "" #: library/hmac.rst:93 @@ -150,8 +151,8 @@ msgid "" "Return ``a == b``. This function uses an approach designed to prevent " "timing analysis by avoiding content-based short circuiting behaviour, making " "it appropriate for cryptography. *a* and *b* must both be of the same type: " -"either :class:`str` (ASCII only, as e.g. returned by :meth:`HMAC." -"hexdigest`), or a :term:`bytes-like object`." +"either :class:`str` (ASCII only, as e.g. returned " +"by :meth:`HMAC.hexdigest`), or a :term:`bytes-like object`." msgstr "" #: library/hmac.rst:132 diff --git a/library/html.entities.po b/library/html.entities.po index 086f2d79..1372645f 100644 --- a/library/html.entities.po +++ b/library/html.entities.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/html.entities.rst:2 -msgid ":mod:`html.entities` --- Definitions of HTML general entities" +msgid ":mod:`!html.entities` --- Definitions of HTML general entities" msgstr "" #: library/html.entities.rst:9 @@ -26,8 +27,9 @@ msgstr "" #: library/html.entities.rst:13 msgid "" -"This module defines four dictionaries, :data:`html5`, :data:" -"`name2codepoint`, :data:`codepoint2name`, and :data:`entitydefs`." +"This module defines four " +"dictionaries, :data:`html5`, :data:`name2codepoint`, :data:`codepoint2name`, " +"and :data:`entitydefs`." msgstr "" #: library/html.entities.rst:19 @@ -36,8 +38,8 @@ msgid "" "equivalent Unicode character(s), e.g. ``html5['gt;'] == '>'``. Note that the " "trailing semicolon is included in the name (e.g. ``'gt;'``), however some of " "the names are accepted by the standard even without the semicolon: in this " -"case the name is present with and without the ``';'``. See also :func:`html." -"unescape`." +"case the name is present with and without the ``';'``. See " +"also :func:`html.unescape`." msgstr "" #: library/html.entities.rst:31 diff --git a/library/html.parser.po b/library/html.parser.po index 5ba8339a..b81f1c8f 100644 --- a/library/html.parser.po +++ b/library/html.parser.po @@ -8,16 +8,17 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-14 12:51+0000\n" +"POT-Creation-Date: 2025-02-17 21:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: library/html.parser.rst:2 -msgid ":mod:`html.parser` --- Simple HTML and XHTML parser" +msgid ":mod:`!html.parser` --- Simple HTML and XHTML parser" msgstr "" #: library/html.parser.rst:7 @@ -71,15 +72,50 @@ msgstr "" #: library/html.parser.rst:44 msgid "" -"As a basic example, below is a simple HTML parser that uses the :class:" -"`HTMLParser` class to print out start tags, end tags, and data as they are " -"encountered::" +"As a basic example, below is a simple HTML parser that uses " +"the :class:`HTMLParser` class to print out start tags, end tags, and data as " +"they are encountered::" +msgstr "" + +#: library/html.parser.rst:48 +msgid "" +"from html.parser import HTMLParser\n" +"\n" +"class MyHTMLParser(HTMLParser):\n" +" def handle_starttag(self, tag, attrs):\n" +" print(\"Encountered a start tag:\", tag)\n" +"\n" +" def handle_endtag(self, tag):\n" +" print(\"Encountered an end tag :\", tag)\n" +"\n" +" def handle_data(self, data):\n" +" print(\"Encountered some data :\", data)\n" +"\n" +"parser = MyHTMLParser()\n" +"parser.feed('Test'\n" +" '

Parse me!

')" msgstr "" #: library/html.parser.rst:64 msgid "The output will then be:" msgstr "" +#: library/html.parser.rst:66 +msgid "" +"Encountered a start tag: html\n" +"Encountered a start tag: head\n" +"Encountered a start tag: title\n" +"Encountered some data : Test\n" +"Encountered an end tag : title\n" +"Encountered an end tag : head\n" +"Encountered a start tag: body\n" +"Encountered a start tag: h1\n" +"Encountered some data : Parse me!\n" +"Encountered an end tag : h1\n" +"Encountered an end tag : body\n" +"Encountered an end tag : html" +msgstr "" + #: library/html.parser.rst:83 msgid ":class:`.HTMLParser` Methods" msgstr "" @@ -91,8 +127,8 @@ msgstr "" #: library/html.parser.rst:90 msgid "" "Feed some text to the parser. It is processed insofar as it consists of " -"complete elements; incomplete data is buffered until more data is fed or :" -"meth:`close` is called. *data* must be :class:`str`." +"complete elements; incomplete data is buffered until more data is fed " +"or :meth:`close` is called. *data* must be :class:`str`." msgstr "" #: library/html.parser.rst:97 @@ -125,8 +161,8 @@ msgstr "" msgid "" "The following methods are called when data or markup elements are " "encountered and they are meant to be overridden in a subclass. The base " -"class implementations do nothing (except for :meth:`~HTMLParser." -"handle_startendtag`):" +"class implementations do nothing (except " +"for :meth:`~HTMLParser.handle_startendtag`):" msgstr "" #: library/html.parser.rst:129 @@ -147,8 +183,8 @@ msgstr "" #: library/html.parser.rst:137 msgid "" "For instance, for the tag ````, this method " -"would be called as ``handle_starttag('a', [('href', 'https://www.cwi." -"nl/')])``." +"would be called as ``handle_starttag('a', [('href', 'https://" +"www.cwi.nl/')])``." msgstr "" #: library/html.parser.rst:140 @@ -171,8 +207,8 @@ msgid "" "Similar to :meth:`handle_starttag`, but called when the parser encounters an " "XHTML-style empty tag (````). This method may be overridden by " "subclasses which require this particular lexical information; the default " -"implementation simply calls :meth:`handle_starttag` and :meth:" -"`handle_endtag`." +"implementation simply calls :meth:`handle_starttag` " +"and :meth:`handle_endtag`." msgstr "" #: library/html.parser.rst:161 @@ -267,41 +303,156 @@ msgid "" "examples::" msgstr "" +#: library/html.parser.rst:235 +msgid "" +"from html.parser import HTMLParser\n" +"from html.entities import name2codepoint\n" +"\n" +"class MyHTMLParser(HTMLParser):\n" +" def handle_starttag(self, tag, attrs):\n" +" print(\"Start tag:\", tag)\n" +" for attr in attrs:\n" +" print(\" attr:\", attr)\n" +"\n" +" def handle_endtag(self, tag):\n" +" print(\"End tag :\", tag)\n" +"\n" +" def handle_data(self, data):\n" +" print(\"Data :\", data)\n" +"\n" +" def handle_comment(self, data):\n" +" print(\"Comment :\", data)\n" +"\n" +" def handle_entityref(self, name):\n" +" c = chr(name2codepoint[name])\n" +" print(\"Named ent:\", c)\n" +"\n" +" def handle_charref(self, name):\n" +" if name.startswith('x'):\n" +" c = chr(int(name[1:], 16))\n" +" else:\n" +" c = chr(int(name))\n" +" print(\"Num ent :\", c)\n" +"\n" +" def handle_decl(self, data):\n" +" print(\"Decl :\", data)\n" +"\n" +"parser = MyHTMLParser()" +msgstr "" + #: library/html.parser.rst:269 msgid "Parsing a doctype::" msgstr "" +#: library/html.parser.rst:271 +msgid "" +">>> parser.feed('')\n" +"Decl : DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://" +"www.w3.org/TR/html4/strict.dtd\"" +msgstr "" + #: library/html.parser.rst:275 msgid "Parsing an element with a few attributes and a title::" msgstr "" +#: library/html.parser.rst:277 +msgid "" +">>> parser.feed('\"The')\n" +"Start tag: img\n" +" attr: ('src', 'python-logo.png')\n" +" attr: ('alt', 'The Python logo')\n" +">>>\n" +">>> parser.feed('

Python

')\n" +"Start tag: h1\n" +"Data : Python\n" +"End tag : h1" +msgstr "" + #: library/html.parser.rst:287 msgid "" "The content of ``script`` and ``style`` elements is returned as is, without " "further parsing::" msgstr "" +#: library/html.parser.rst:290 +msgid "" +">>> parser.feed('