swig/Doc
William S Fulton 72ebb34a27 Update the Python 2 C API usage in the documentation
The manual still used the Python 2 compatibility macros in its typemap
examples. These were removed from the generated code in 4.5.0, so the examples
no longer compile.

Each macro is replaced with the Python 3 API that keeps the example working as
documented: PyUnicode_* where the example converts Python text (char *str,
char *argv[], const char *fmt, std::string and the char and char * typecheck
typemaps) and PyBytes_* for the read()/write() example, which passes a binary
buffer. The read/write session transcript is updated to bytes literals and
Python 3 octal syntax to match.

The "Useful Python Functions" section of the Python chapter listed the
PyString_* functions and the Python 2 only PyFile_FromFile and PyFile_AsFile.
These are replaced by the PyUnicode_*, PyBytes_* and PyObject_AsFileDescriptor
equivalents. A compatibility note is added listing every removed macro
alongside the Python 3 API it expanded to.

Also fix the "newfree" typemap example in the Ruby chapter, which called
PyString_FromString instead of rb_str_new2.

Closes #3530

Assisted-by: Claude Code (Opus 5)
2026-08-10 22:42:39 +01:00
..
Devel [MzScheme/Racket] Drop support 2025-04-01 14:05:28 +13:00
Manual Update the Python 2 C API usage in the documentation 2026-08-10 22:42:39 +01:00
README Revert rev 11187 "Merged with recent changes from trunk." 2012-05-06 01:13:16 +00:00

README

Doc/Manual    -  Latest version of the SWIG user manual
Doc/Devel     -  Developer documentation concerning SWIG internals.
                 (not necessarily up to date)

Open the index.html file in each of these directories with a web browser.